diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-11-19 10:44:27 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-11-19 10:45:05 -0800 |
| commit | 49e64c1451b9933a025d059f7dae287788c7d1cc (patch) | |
| tree | de50756f7fad3c7a6cf58f117163eee8ef68488c /src | |
| parent | a3fba6d83e86978d91a913a3113bb3db92195298 (diff) | |
Man reader: properly handle `.sp` macro inside lists and block quotes.
Closes #9201.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Readers/Man.hs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs index 0f88b77b2..77d7c1a61 100644 --- a/src/Text/Pandoc/Readers/Man.hs +++ b/src/Text/Pandoc/Readers/Man.hs @@ -406,7 +406,16 @@ parseHeader = do return $ header lvl contents parseBlockQuote :: PandocMonad m => ManParser m Blocks -parseBlockQuote = blockQuote <$> continuation +parseBlockQuote = blockQuote <$> + ( (mmacro "RS" *> (mconcat <$> manyTill parseBlock (endmacro "RE"))) + <|> parseIndentedParagraphs + ) + where + parseIndentedParagraphs = try $ do + bareIP + first <- parsePara <|> parseCodeBlock + rest <- many $ try (memptyLine *> (parsePara <|> parseCodeBlock)) + pure (first <> mconcat rest) data ListType = Ordered ListAttributes | Bullet @@ -457,10 +466,8 @@ parseList = try $ do continuation :: PandocMonad m => ManParser m Blocks continuation = - mconcat <$> (mmacro "RS" *> manyTill parseBlock (endmacro "RE")) - <|> mconcat <$> many1 ( try (bareIP *> parsePara) - <|> try (bareIP *> parseCodeBlock) - ) + (mmacro "RS" *> (mconcat <$> manyTill parseBlock (endmacro "RE"))) + <|> try ((memptyLine <|> bareIP) *> (parsePara <|> parseCodeBlock)) definitionListItem :: PandocMonad m => ManParser m (Inlines, [Blocks]) @@ -473,11 +480,10 @@ definitionListItem = try $ do mmacro "TQ" parseInline skipMany memptyLine - inls <- option mempty parseInlines - skipMany memptyLine - continuations <- mconcat <$> many continuation + firstBlock <- parseBlock + otherBlocks <- mconcat <$> many continuation return ( mconcat (intersperse B.linebreak (term:moreterms)) - , [para inls <> continuations]) + , [firstBlock <> otherBlocks]) parseDefinitionList :: PandocMonad m => ManParser m Blocks parseDefinitionList = definitionList <$> many1 definitionListItem |
