aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2016-08-08 09:40:50 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2016-08-08 09:40:50 +0200
commit13280a811264690c42ac7d795efa0c702fad0b7b (patch)
treeac46a78f0a0a960e62589d54d1cdd5b049518b69 /src/Text
parent0fbb676c81ea258cfbfa8f1a726b37edf2bd2b90 (diff)
downloadpandoc-13280a811264690c42ac7d795efa0c702fad0b7b.tar.gz
Org reader: preserve indentation of verse lines
Leading spaces in verse lines are converted to non-breaking spaces, so indentation is preserved. This fixes #3064.
Diffstat (limited to 'src/Text')
-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 0bd82ce2f..66db207d9 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"