From fe799eea91089aa90b935d2cab5cd87223906f65 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 29 Nov 2022 09:56:41 -0800 Subject: AsciiDoc writer: in link text, only replace commas... ...with entities when they're in Str elements. If a link contains an image, it may have attributes, and the commas there should not be converted. See #8437, #8070. --- src/Text/Pandoc/Writers/AsciiDoc.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs index 1c54584c4..54fd33596 100644 --- a/src/Text/Pandoc/Writers/AsciiDoc.hs +++ b/src/Text/Pandoc/Writers/AsciiDoc.hs @@ -40,7 +40,7 @@ import Text.Pandoc.Shared import Text.Pandoc.URI import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Shared - +import Text.Pandoc.Walk (walk) data WriterState = WriterState { defListMarker :: Text , orderedListLevel :: Int @@ -563,8 +563,12 @@ inlineToAsciiDoc opts (Link _ txt (src, _tit)) = do -- relative: link:downloads/foo.zip[download foo.zip] -- abs: http://google.cod[Google] -- or my@email.com[email john] - let fixCommas = T.replace "," "," -- see #8070 - linktext <- fmap fixCommas <$> inlineListToAsciiDoc opts txt + let fixCommas (Str t) = + intersperse (RawInline (Format "asciidoc") ",") + $ map Str $ T.splitOn "," t -- see #8070 + fixCommas x = [x] + + linktext <- inlineListToAsciiDoc opts $ walk (concatMap fixCommas) txt let isRelative = T.all (/= ':') src let needsPassthrough = "--" `T.isInfixOf` src let prefix = if isRelative -- cgit v1.2.3