aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-09-27 22:14:43 -0700
committerJohn MacFarlane <[email protected]>2022-09-28 08:34:50 -0700
commitbcf06e7f5e508f548f7060ba3e7281766aa2c1ea (patch)
treea1206ed92ff7964ffc836b8a9aa366f11b881ffb /src
parent2ff0b9a9efd959ea146d599379368ab00fae90cb (diff)
HTML writer: prevent `<a>` inside `<a>`.
If a link text contains a link, we replace it with a span. See #7585.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index f74ce75d0..06d8d4e8a 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -1547,10 +1547,10 @@ inlineToHtml opts inline = do
_ -> do report $ InlineNotRendered inline
return mempty
(Link attr txt (s,_)) | "mailto:" `T.isPrefixOf` s -> do
- linkText <- inlineListToHtml opts txt
+ linkText <- inlineListToHtml opts (removeLinks txt)
obfuscateLink opts attr linkText s
(Link (ident,classes,kvs) txt (s,tit)) -> do
- linkText <- inlineListToHtml opts txt
+ linkText <- inlineListToHtml opts (removeLinks txt)
slideVariant <- gets stSlideVariant
let s' = case T.uncons s of
Just ('#',xs) -> let prefix = if slideVariant == RevealJsSlides
@@ -1731,3 +1731,11 @@ isRawHtml f = do
html5 <- gets stHtml5
return $ f == Format "html" ||
((html5 && f == Format "html5") || f == Format "html4")
+
+-- We need to remove links from link text, because an <a> element is
+-- not allowed inside another <a> element.
+removeLinks :: [Inline] -> [Inline]
+removeLinks = walk go
+ where
+ go (Link attr ils _) = Span attr ils
+ go x = x