git.iko.soy/typeable/pandoc
on master help sign in
Man reader: fixed spurious newlines in code blocks.

These were caused by lines that just changed to typewriter font. The lexer has been adjusted so these no longer show up as blank lines. Closes #5005.

commit8f97c8e4580390a5c611c07925f1e38cfa42fb2a authorJohn MacFarlane <jgm@berkeley.edu> dateMon 22 Oct 2018, 10:41 (8 years ago) parent9608fd0
1 file changed+7−7
src/Text/Pandoc/Readers/Man.hs+7−7
src/Text/Pandoc/Readers/Man.hs+7−7
@@ -416,8 +416,12 @@ lexLine :: PandocMonad m => ManLexer m ManTokens
416416lexLine = do
417417 lnparts <- mconcat <$> many1 linePart
418418 eofline
419− return $ singleTok $ MLine lnparts
420− where
419+ go lnparts
420+ where -- return empty line if we only have empty strings;
421+ -- this can happen if the line just contains \f[C], for example.
422+ go [] = return mempty
423+ go (RoffStr ("",_):xs) = go xs
424+ go xs = return $ singleTok $ MLine xs
421425
422426linePart :: PandocMonad m => ManLexer m [LinePart]
423427linePart = macroArg <|> esc <|> escStar <|>
@@ -647,15 +651,11 @@ parseCodeBlock = try $ do
647651 mmacro "nf"
648652 toks <- many (mline <|> memptyLine)
649653 mmacro "fi"
650− return $ codeBlock (removeFinalNewline $
651− intercalate "\n" . catMaybes $
654+ return $ codeBlock (intercalate "\n" . catMaybes $
652655 extractText <$> toks)
653656
654657 where
655658
656− removeFinalNewline [] = []
657− removeFinalNewline xs = if last xs == '\n' then init xs else xs
658−
659659 extractText :: ManToken -> Maybe String
660660 extractText (MLine ss) = Just $ linePartsToString ss
661661 extractText MEmptyLine = Just ""