aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-21 12:18:46 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-21 12:18:53 -0700
commite388dddefa3e4b0793ff23282db80bf885ed019c (patch)
tree12bf30f9e0195102d0059c2960a48d12c550af2d /src
parent25248c7a378f8e875ccb5cf55d1d7a9855bde93e (diff)
downloadpandoc-e388dddefa3e4b0793ff23282db80bf885ed019c.tar.gz
Man reader: Clean up inline parsing.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Man.hs27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs
index d6a6fa494..cf1b14ac5 100644
--- a/src/Text/Pandoc/Readers/Man.hs
+++ b/src/Text/Pandoc/Readers/Man.hs
@@ -545,9 +545,16 @@ parsePara :: PandocMonad m => ManParser m Blocks
parsePara = para . trimInlines <$> parseInlines
parseInlines :: PandocMonad m => ManParser m Inlines
-parseInlines = do
- inls <- many1 (lineInl <|> parseLink <|> parseEmailLink)
- return $ mconcat $ intersperse B.space inls
+parseInlines = mconcat . intersperse B.space <$> many1 parseInline
+
+parseInline :: PandocMonad m => ManParser m Inlines
+parseInline = do
+ tok <- mline <|> mmacro "UR" <|> mmacro "MT"
+ case tok of
+ MLine lparts -> return $ linePartsToInlines lparts
+ MMacro "UR" args -> parseLink args
+ MMacro "MT" args -> parseEmailLink args
+ _ -> fail "Unknown token in parseInline"
lineInl :: PandocMonad m => ManParser m Inlines
lineInl = do
@@ -650,20 +657,18 @@ definitionListItem = try $ do
parseDefinitionList :: PandocMonad m => ManParser m Blocks
parseDefinitionList = definitionList <$> many1 definitionListItem
-parseLink :: PandocMonad m => ManParser m Inlines
-parseLink = try $ do
- MMacro _ args <- mmacro "UR"
- contents <- mconcat <$> many1 lineInl
+parseLink :: PandocMonad m => [[LinePart]] -> ManParser m Inlines
+parseLink args = do
+ contents <- mconcat <$> many lineInl
mmacro "UE"
let url = case args of
[] -> ""
(x:_) -> linePartsToString x
return $ link url "" contents
-parseEmailLink :: PandocMonad m => ManParser m Inlines
-parseEmailLink = do
- MMacro _ args <- mmacro "MT"
- contents <- mconcat <$> many1 lineInl
+parseEmailLink :: PandocMonad m => [[LinePart]] -> ManParser m Inlines
+parseEmailLink args = do
+ contents <- mconcat <$> many lineInl
mmacro "ME"
let url = case args of
[] -> ""