From b59ba39e1ad17d62f67b071a97b4dc820b447be5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 18 Oct 2018 23:52:07 -0700 Subject: Man reader: remove final newline in code blocks. This is consistent with other readers. --- src/Text/Pandoc/Readers/Man.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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? -- cgit v1.2.3