aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-08-09 21:33:24 +0200
committerGitHub <noreply@github.com>2016-08-09 21:33:24 +0200
commit13424a2bd7ffbf049a6f3b3303fcb486f9385511 (patch)
tree11221926df62b48b75d33b36b0c6a92a7d0270c5 /src/Text/Pandoc
parent3a6e15a3131f2ced7daf912ed9df16e6a0860a37 (diff)
parent13280a811264690c42ac7d795efa0c702fad0b7b (diff)
downloadpandoc-13424a2bd7ffbf049a6f3b3303fcb486f9385511.tar.gz
Merge pull request #3065 from tarleb/org-verse-indent
Org reader: preserve indentation of verse lines
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Org/Blocks.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs
index 80895e038..6a8bb8b28 100644
--- a/src/Text/Pandoc/Readers/Org/Blocks.hs
+++ b/src/Text/Pandoc/Readers/Org/Blocks.hs
@@ -422,7 +422,16 @@ verseBlock blockType = try $ do
ignHeaders
content <- rawBlockContent blockType
fmap B.para . mconcat . intersperse (pure B.linebreak)
- <$> mapM (parseFromString inlines) (map (++ "\n") . lines $ content)
+ <$> mapM parseVerseLine (lines content)
+ where
+ -- replace initial spaces with nonbreaking spaces to preserve
+ -- indentation, parse the rest as normal inline
+ parseVerseLine :: String -> OrgParser (F Inlines)
+ parseVerseLine cs = do
+ let (initialSpaces, indentedLine) = span isSpace cs
+ let nbspIndent = B.str $ map (const '\160') initialSpaces
+ line <- parseFromString inlines (indentedLine ++ "\n")
+ return (pure nbspIndent <> line)
-- | Read a code block and the associated results block if present. Which of
-- boths blocks is included in the output is determined using the "exports"