From 9593b375d747d681db0d3aba3af0f1ffd2db0f2f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 20 Oct 2018 22:55:03 -0700 Subject: Man reader: support UR/UE, MT/ME for links. Closes #4989. --- src/Text/Pandoc/Readers/Man.hs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs index 52f4ef2f7..9ef20be0e 100644 --- a/src/Text/Pandoc/Readers/Man.hs +++ b/src/Text/Pandoc/Readers/Man.hs @@ -497,9 +497,8 @@ parsePara = para . trimInlines <$> parseInlines parseInlines :: PandocMonad m => ManParser m Inlines parseInlines = do - inls <- many1 (lineInl <|> comment) - let withspaces = intersperse B.space inls - return $ mconcat withspaces + inls <- many1 (lineInl <|> comment <|> parseLink <|> parseEmailLink) + return $ mconcat $ intersperse B.space inls lineInl :: PandocMonad m => ManParser m Inlines lineInl = do @@ -605,6 +604,26 @@ 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 <|> comment) + 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 <|> comment) + mmacro "ME" + let url = case args of + [] -> "" + (x:_) -> "mailto:" ++ linePartsToString x + return $ link url "" contents + parseMacroDef :: PandocMonad m => ManParser m Blocks parseMacroDef = do MMacro _ args <- mmacro "de" -- cgit v1.2.3