From 0604fa297dfdacf32cd8360a0c48651e45c9e566 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 9 Feb 2024 11:59:26 -0800 Subject: [PATCH] Fix id replacements in SVGs with clipping paths. This fixes `--embed-resources` when SVGs have `clip-path` attributes. Closes #9420. --- src/Text/Pandoc/SelfContained.hs | 4 ++++ test/command/9420.md | 13 +++++++++++++ test/command/9420.svg | 9 +++++++++ 3 files changed, 26 insertions(+) create mode 100644 test/command/9420.md create mode 100644 test/command/9420.svg diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs index 54d49127a..ddb44385a 100644 --- a/src/Text/Pandoc/SelfContained.hs +++ b/src/Text/Pandoc/SelfContained.hs @@ -185,6 +185,10 @@ convertTags (t@(TagOpen tagname as):ts) case T.uncons x of Just ('#', x') -> (k, "#" <> svgid <> "_" <> x') _ -> (k, x) + addIdPrefix ("clip-path", x) = ("clip-path", + case T.stripPrefix "url(#" x of + Just x' -> "url(#" <> svgid <> "_" <> x' + Nothing -> x) addIdPrefix kv = kv let ensureUniqueId (TagOpen tname ats) = TagOpen tname (map addIdPrefix ats) diff --git a/test/command/9420.md b/test/command/9420.md new file mode 100644 index 000000000..89f666964 --- /dev/null +++ b/test/command/9420.md @@ -0,0 +1,13 @@ +``` +% pandoc --embed-resources +![](command/9420.svg) +^D +

+ + + + + + +

+``` diff --git a/test/command/9420.svg b/test/command/9420.svg new file mode 100644 index 000000000..694278425 --- /dev/null +++ b/test/command/9420.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file