aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-19 20:56:00 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-19 20:56:00 -0700
commit3b710b6fa7aad461302225abedd273dab06a40cd (patch)
treeebc2c94f19e4347958e7b1097b5ab81e273b1464 /src/Text
parent4333556bcf8ea6575eb426d6167be77ca4f736f9 (diff)
downloadpandoc-3b710b6fa7aad461302225abedd273dab06a40cd.tar.gz
Man reader: minor refactoring.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Man.hs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs
index 77f8d42ec..9ead84f3e 100644
--- a/src/Text/Pandoc/Readers/Man.hs
+++ b/src/Text/Pandoc/Readers/Man.hs
@@ -145,13 +145,21 @@ lexMan = many (lexComment <|> lexMacro <|> lexLine <|> lexEmptyLine)
parseMan :: PandocMonad m => ManParser m Pandoc
parseMan = do
- let parsers = [ try parseList, parseTitle, parsePara, parseSkippedContent
- , try parseCodeBlock, parseHeader, parseSkipMacro]
- bs <- many $ choice parsers
- let (Pandoc _ blocks) = doc $ mconcat bs
+ bs <- many parseBlock
meta <- stateMeta <$> getState
+ let (Pandoc _ blocks) = doc $ mconcat bs
return $ Pandoc meta blocks
+parseBlock :: PandocMonad m => ManParser m Blocks
+parseBlock = choice [ parseList
+ , parseTitle
+ , parsePara
+ , parseSkippedContent
+ , parseCodeBlock
+ , parseHeader
+ , parseSkipMacro
+ ]
+
eofline :: Stream s m Char => ParsecT s u m ()
eofline = void newline <|> eof
@@ -495,7 +503,7 @@ parseInlines = do
parseCodeBlock :: PandocMonad m => ManParser m Blocks
-parseCodeBlock = do
+parseCodeBlock = try $ do
mmacro "nf"
toks <- many (mstr <|> mline <|> mmaybeLink <|> memptyLine <|> mcomment)
mmacro "fi"
@@ -522,7 +530,7 @@ parseHeader = do
type ListBuilder = [Blocks] -> Blocks
parseList :: PandocMonad m => ManParser m Blocks
-parseList = do
+parseList = try $ do
xx <- many1 paras
let bls = map snd xx
let bldr = fst $ head xx