aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-08-29 10:12:20 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-08-29 10:12:20 -0700
commit5dcd4610e2301baf73f96abcd80315be45d41f3e (patch)
treea3d312cb28b62af00b82c0760040155ef88df441 /src/Text/Pandoc
parent6180d42434526c4c5137ceb4e7bfa284daaf6089 (diff)
downloadpandoc-5dcd4610e2301baf73f96abcd80315be45d41f3e.tar.gz
Improve asciidoc escaping for `--` in URLs. Closes #7529.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/AsciiDoc.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs
index ab7e5f1a9..bcef4a089 100644
--- a/src/Text/Pandoc/Writers/AsciiDoc.hs
+++ b/src/Text/Pandoc/Writers/AsciiDoc.hs
@@ -546,6 +546,7 @@ inlineToAsciiDoc opts (Link _ txt (src, _tit)) = do
-- or my@email.com[email john]
linktext <- inlineListToAsciiDoc opts txt
let isRelative = T.all (/= ':') src
+ let needsPassthrough = "--" `T.isInfixOf` src
let prefix = if isRelative
then text "link:"
else empty
@@ -553,9 +554,16 @@ inlineToAsciiDoc opts (Link _ txt (src, _tit)) = do
let useAuto = case txt of
[Str s] | escapeURI s == srcSuffix -> True
_ -> False
- return $ if useAuto
- then literal srcSuffix
- else prefix <> literal src <> "[" <> linktext <> "]"
+ return $
+ if needsPassthrough
+ then
+ if useAuto
+ then "link:++" <> literal srcSuffix <> "++[]"
+ else "link:++" <> literal src <> "++[" <> linktext <> "]"
+ else
+ if useAuto
+ then literal srcSuffix
+ else prefix <> literal src <> "[" <> linktext <> "]"
inlineToAsciiDoc opts (Image attr alternate (src, tit)) =
("image:" <>) <$> imageArguments opts attr alternate src tit
inlineToAsciiDoc opts (Note [Para inlines]) =