diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2021-05-05 19:00:53 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2021-05-05 19:09:21 +0200 |
commit | 8357b835d9c6d17f32bded56aa24059c2f6e0678 (patch) | |
tree | e93428fe479e1449054a6d4f51630a6eed13fb18 | |
parent | ddbf83f62c8bb6516203c99acd894c404351b5ae (diff) | |
download | pandoc-8357b835d9c6d17f32bded56aa24059c2f6e0678.tar.gz |
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
-rw-r--r-- | src/Text/Pandoc/App.hs | 18 | ||||
-rw-r--r-- | test/command/6709.md | 11 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index 4e8c9f2ab..96e4b5f47 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -255,13 +255,17 @@ convertWithOpts opts = do let sourceToDoc :: [FilePath] -> PandocIO Pandoc sourceToDoc sources' = case reader of - TextReader r - | optFileScope opts || readerNameBase == "json" -> - mconcat <$> mapM (readSource >=> r readerOpts) sources' - | otherwise -> - readSources sources' >>= r readerOpts - ByteStringReader r -> - mconcat <$> mapM (readFile' >=> r readerOpts) sources' + TextReader r + | readerNameBase == "json" -> + mconcat <$> mapM (readSource >=> r readerOpts) sources' + | optFileScope opts -> + -- Read source and convert tabs (see #6709) + let readSource' = fmap convertTabs . readSource + in mconcat <$> mapM (readSource' >=> r readerOpts) sources' + | otherwise -> + readSources sources' >>= r readerOpts + ByteStringReader r -> + mconcat <$> mapM (readFile' >=> r readerOpts) sources' when (readerNameBase == "markdown_github" || diff --git a/test/command/6709.md b/test/command/6709.md new file mode 100644 index 000000000..d6d514552 --- /dev/null +++ b/test/command/6709.md @@ -0,0 +1,11 @@ +Tabs must be expanded even if --file-scope is used +```` +% pandoc -t native --file-scope --tab-stop=2 +``` +if true; then + echo "yup" +fi +``` +^D +[CodeBlock ("",[],[]) "if true; then\n echo \"yup\"\nfi"] +```` |