diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-11-15 11:06:08 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-11-15 11:06:50 -0800 |
commit | c19f0634203f224a26851635f4b86e1013a6618a (patch) | |
tree | 630c68467d4b80a07335fa4c88dfa420576aed6a /src/Text/Pandoc/Writers/Markdown | |
parent | ea268fd8a72fe59e6cb0086b0c7471b8aa316af1 (diff) | |
download | pandoc-c19f0634203f224a26851635f4b86e1013a6618a.tar.gz |
Markdown writer: don't create autolinks when this loses information.
Previously we sometimes lost attributes when rendering links as autolinks.
Closes #7692.
Diffstat (limited to 'src/Text/Pandoc/Writers/Markdown')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown/Inline.hs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown/Inline.hs b/src/Text/Pandoc/Writers/Markdown/Inline.hs index 065157e80..be22f8d9f 100644 --- a/src/Text/Pandoc/Writers/Markdown/Inline.hs +++ b/src/Text/Pandoc/Writers/Markdown/Inline.hs @@ -531,7 +531,7 @@ inlineToMarkdown opts (Cite (c:cs) lst) return $ pdoc <+> r modekey SuppressAuthor = "-" modekey _ = "" -inlineToMarkdown opts lnk@(Link attr txt (src, tit)) = do +inlineToMarkdown opts lnk@(Link attr@(ident,classes,kvs) txt (src, tit)) = do variant <- asks envVariant linktext <- inlineListToMarkdown opts txt let linktitle = if T.null tit @@ -539,6 +539,9 @@ inlineToMarkdown opts lnk@(Link attr txt (src, tit)) = do else literal $ " \"" <> tit <> "\"" let srcSuffix = fromMaybe src (T.stripPrefix "mailto:" src) let useAuto = isURI src && + T.null ident && + null kvs && + (null classes || classes == ["uri"] || classes == ["email"]) && case txt of [Str s] | escapeURI s == srcSuffix -> True _ -> False |