diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-10-04 22:22:25 -0700 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-10-04 22:22:25 -0700 |
| commit | 5a691e8c3f412e8949f34e59debd794444a954fb (patch) | |
| tree | 3c0e25362b8da0c321a17f55c6c7b5b1fed05097 /src/Text | |
| parent | e426b3d885fe0fd59ab449815524e3e800746574 (diff) | |
Man writer: use UR, MT macros for URLs, emails.
Closes #9120.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Writers/Man.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index 6187232b3..a32733ec3 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -316,13 +316,17 @@ inlineToMan _ Space = return space inlineToMan opts (Link _ txt (src, _)) | not (isURI src) = inlineListToMan opts txt -- skip relative links | otherwise = do - linktext <- inlineListToMan opts txt let srcSuffix = fromMaybe src (T.stripPrefix "mailto:" src) - return $ case txt of - [Str s] - | escapeURI s == srcSuffix -> - char '<' <> literal srcSuffix <> char '>' - _ -> linktext <> literal " (" <> literal src <> char ')' + linktext <- case txt of + [Str s] | escapeURI s == srcSuffix -> pure mempty + _ -> inlineListToMan opts txt + let (start, end) = if "mailto:" `T.isPrefixOf` src + then (".MT", ".ME") + else (".UR", ".UE") + return $ cr + $$ (start <+> literal srcSuffix) + $$ linktext + $$ (end <+> "\\c" <> cr) -- \c avoids space after inlineToMan opts (Image attr alternate (source, tit)) = do let txt = if null alternate || (alternate == [Str ""]) || (alternate == [Str source]) -- to prevent autolinks |
