diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-10-23 12:47:49 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-23 12:48:17 -0700 |
commit | 8f428c4e103c5d13dc478d16a05c9f1d317fe6d0 (patch) | |
tree | 8ca973f70878ac40d25673b2adae3375510ea0de /src/Text/Pandoc/Readers | |
parent | b0fa2b954f2b48a77e0f8b38d38873530c864d29 (diff) | |
download | pandoc-8f428c4e103c5d13dc478d16a05c9f1d317fe6d0.tar.gz |
Man reader: handle implicitly closed RS, nf, EX.
These are implicitly closed by a new section command.
(See e.g. tiffcp.1)
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Man.hs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs index 7cf46a59a..fb10e3613 100644 --- a/src/Text/Pandoc/Readers/Man.hs +++ b/src/Text/Pandoc/Readers/Man.hs @@ -719,11 +719,19 @@ bareIP = msatisfy isBareIP where isBareIP (MMacro "IP" [] _) = True isBareIP _ = False +endmacro :: PandocMonad m => String -> ManParser m ManToken +endmacro name = mmacro name <|> lookAhead newBlockMacro + where + newBlockMacro = msatisfy isNewBlockMacro + isNewBlockMacro (MMacro "SH" _ _) = True + isNewBlockMacro (MMacro "SS" _ _) = True + isNewBlockMacro _ = False + parseCodeBlock :: PandocMonad m => ManParser m Blocks parseCodeBlock = try $ do optional bareIP -- some people indent their code - toks <- (mmacro "nf" *> many (mline <|> memptyLine) <* mmacro "fi") - <|> (mmacro "EX" *> many (mline <|> memptyLine) <* mmacro "EE") + toks <- (mmacro "nf" *> many (mline <|> memptyLine) <* endmacro "fi") + <|> (mmacro "EX" *> many (mline <|> memptyLine) <* endmacro "EE") return $ codeBlock (intercalate "\n" . catMaybes $ extractText <$> toks) @@ -786,12 +794,9 @@ parseList = try $ do Ordered lattr -> orderedListWith lattr (x:xs) continuation :: PandocMonad m => ManParser m Blocks -continuation = (do - mmacro "RS" - bs <- mconcat <$> many (notFollowedBy (mmacro "RE") >> parseBlock) - mmacro "RE" - return bs) - <|> mconcat <$> many1 (try (bareIP *> parsePara)) +continuation = + mconcat <$> (mmacro "RS" *> manyTill parseBlock (endmacro "RE")) + <|> mconcat <$> many1 (try (bareIP *> parsePara)) definitionListItem :: PandocMonad m => ManParser m (Inlines, [Blocks]) |