Man reader: remove final newline in code blocks.

This is consistent with other readers.
This commit is contained in:
John MacFarlane 2018-10-18 23:52:07 -07:00
parent e9c422649d
commit b59ba39e1a

View file

@ -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?