git.iko.soy/typeable/pandoc
on master help sign in
Man reader: handle implicitly closed RS, nf, EX.

These are implicitly closed by a new section command. (See e.g. tiffcp.1)

commit8f428c4e103c5d13dc478d16a05c9f1d317fe6d0 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 23 Oct 2018, 12:47 (8 years ago) parentb0fa2b9
1 file changed+13−8
src/Text/Pandoc/Readers/Man.hs+13−8
src/Text/Pandoc/Readers/Man.hs+13−8
@@ -719,11 +719,19 @@ bareIP = msatisfy isBareIP where
719719 isBareIP (MMacro "IP" [] _) = True
720720 isBareIP _ = False
721721
722+endmacro :: PandocMonad m => String -> ManParser m ManToken
723+endmacro name = mmacro name <|> lookAhead newBlockMacro
724+ where
725+ newBlockMacro = msatisfy isNewBlockMacro
726+ isNewBlockMacro (MMacro "SH" _ _) = True
727+ isNewBlockMacro (MMacro "SS" _ _) = True
728+ isNewBlockMacro _ = False
729+
722730parseCodeBlock :: PandocMonad m => ManParser m Blocks
723731parseCodeBlock = try $ do
724732 optional bareIP -- some people indent their code
725− toks <- (mmacro "nf" *> many (mline <|> memptyLine) <* mmacro "fi")
726− <|> (mmacro "EX" *> many (mline <|> memptyLine) <* mmacro "EE")
733+ toks <- (mmacro "nf" *> many (mline <|> memptyLine) <* endmacro "fi")
734+ <|> (mmacro "EX" *> many (mline <|> memptyLine) <* endmacro "EE")
727735 return $ codeBlock (intercalate "\n" . catMaybes $
728736 extractText <$> toks)
729737
@@ -786,12 +794,9 @@ parseList = try $ do
786794 Ordered lattr -> orderedListWith lattr (x:xs)
787795
788796continuation :: PandocMonad m => ManParser m Blocks
789−continuation = (do
790− mmacro "RS"
791− bs <- mconcat <$> many (notFollowedBy (mmacro "RE") >> parseBlock)
792− mmacro "RE"
793− return bs)
794− <|> mconcat <$> many1 (try (bareIP *> parsePara))
797+continuation =
798+ mconcat <$> (mmacro "RS" *> manyTill parseBlock (endmacro "RE"))
799+ <|> mconcat <$> many1 (try (bareIP *> parsePara))
795800
796801definitionListItem :: PandocMonad m
797802 => ManParser m (Inlines, [Blocks])