aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-18 23:52:07 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-18 23:54:13 -0700
commitb59ba39e1ad17d62f67b071a97b4dc820b447be5 (patch)
tree59d78c8e54a07b298839fc3f3a7fae52ce9f002a /src/Text/Pandoc/Readers
parente9c422649df5504ab58616a51e30671af23265a0 (diff)
downloadpandoc-b59ba39e1ad17d62f67b071a97b4dc820b447be5.tar.gz
Man reader: remove final newline in code blocks.
This is consistent with other readers.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Man.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs
index 3aab375ab..f10546839 100644
--- a/src/Text/Pandoc/Readers/Man.hs
+++ b/src/Text/Pandoc/Readers/Man.hs
@@ -530,10 +530,14 @@ parseCodeBlock = do
mmacro KCodeBlStart
toks <- many (mstr <|> mline <|> mmaybeLink <|> memplyLine <|> munknownMacro <|> mcomment)
mmacro KCodeBlEnd
- return $ codeBlock (intercalate "\n" . catMaybes $ extractText <$> toks)
+ return $ codeBlock (removeFinalNewline $
+ intercalate "\n" . catMaybes $
+ extractText <$> toks)
where
+ removeFinalNewline [] = []
+ removeFinalNewline xs = if last xs == '\n' then init xs else xs
extractText :: ManToken -> Maybe String
extractText (MStr (s, _)) = Just s
extractText (MLine ss) = Just . concat $ map fst ss -- TODO maybe unwords?