git.iko.soy/typeable/pandoc
on master help sign in
App: allow tabs expansion even if file-scope is used

Tabs in plain-text inputs are now handled correctly, even if the `--file-scope` flag is used. Closes: #6709

commit8357b835d9c6d17f32bded56aa24059c2f6e0678 authorAlbert Krewinkel <albert@zeitkraut.de> dateWed 5 May 2021, 19:00 (5 years ago) parentddbf83f
2 files changed+22−7
src/Text/Pandoc/App.hs+11−7 test/command/6709.md+11
src/Text/Pandoc/App.hs+11−7
@@ -255,13 +255,17 @@ convertWithOpts opts = do
255255 let sourceToDoc :: [FilePath] -> PandocIO Pandoc
256256 sourceToDoc sources' =
257257 case reader of
258− TextReader r
259− | optFileScope opts || readerNameBase == "json" ->
260− mconcat <$> mapM (readSource >=> r readerOpts) sources'
261− | otherwise ->
262− readSources sources' >>= r readerOpts
263− ByteStringReader r ->
264− mconcat <$> mapM (readFile' >=> r readerOpts) sources'
258+ TextReader r
259+ | readerNameBase == "json" ->
260+ mconcat <$> mapM (readSource >=> r readerOpts) sources'
261+ | optFileScope opts ->
262+ -- Read source and convert tabs (see #6709)
263+ let readSource' = fmap convertTabs . readSource
264+ in mconcat <$> mapM (readSource' >=> r readerOpts) sources'
265+ | otherwise ->
266+ readSources sources' >>= r readerOpts
267+ ByteStringReader r ->
268+ mconcat <$> mapM (readFile' >=> r readerOpts) sources'
265269
266270
267271 when (readerNameBase == "markdown_github" ||
test/command/6709.mdnew file+11
@@ -0,0 +1,11 @@
1+Tabs must be expanded even if --file-scope is used
2+````
3+% pandoc -t native --file-scope --tab-stop=2
4+```
5+if true; then
6+ echo "yup"
7+fi
8+```
9+^D
10+[CodeBlock ("",[],[]) "if true; then\n echo \"yup\"\nfi"]
11+````