mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-29 01:41:20 +08:00
Markdown writer: don't create autolinks when this loses information.
Previously we sometimes lost attributes when rendering links as autolinks. Closes #7692.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
```
|
||||
% pandoc -t markdown
|
||||
[https://example.com](https://example.com){.clz}
|
||||
^D
|
||||
[https://example.com](https://example.com){.clz}
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f markdown -t html | pandoc -f html -t markdown
|
||||
<http://example.com>
|
||||
^D
|
||||
<http://example.com>
|
||||
```
|
||||
Reference in New Issue
Block a user