Texinfo writer: fix escaping in links.

Previously we dropped periods, commas, etc. This was a regression
from 2024. All we really need to do is escape the comma.

Closes #11758.
This commit is contained in:
John MacFarlane
2026-07-11 10:57:33 +02:00
parent ce1327e0b8
commit 780e605c95
3 changed files with 19 additions and 5 deletions
+5 -4
View File
@@ -48,7 +48,7 @@ data WriterState =
, stOptions :: WriterOptions -- writer options
}
data Context = NormalContext | NodeContext
data Context = NormalContext | NodeContext | ArgumentContext
deriving (Eq, Show)
withContext :: PandocMonad m => Context -> TI m a -> TI m a
@@ -138,6 +138,7 @@ stringToTexinfo t
escChar '\x2026' = "@dots{}"
escChar '\x2019' = "'"
escChar ',' | context == NodeContext = ""
escChar ',' | context == ArgumentContext = "@comma{}"
escChar ':' | context == NodeContext = ""
escChar '.' | context == NodeContext = ""
escChar '(' | context == NodeContext = ""
@@ -529,7 +530,7 @@ inlineToTexinfo (Link _ txt (src, _))
Nothing -> literal <$> stringToTexinfo
(T.filter (not . disallowedInNode) src)
Just node -> pure $ literal node
contents <- withContext NodeContext $ inlineListToTexinfo txt
contents <- withContext ArgumentContext $ inlineListToTexinfo txt
return $ text "@ref"
<> braces (target <> if contents == target
then mempty
@@ -538,13 +539,13 @@ inlineToTexinfo (Link _ txt (src, _))
[Str x] | escapeURI x == src -> -- autolink
return $ literal $ "@url{" <> x <> "}"
_ -> do
contents <- withContext NodeContext $ inlineListToTexinfo txt
contents <- withContext ArgumentContext $ inlineListToTexinfo txt
src1 <- stringToTexinfo src
return $ literal ("@uref{" <> src1 <> ",") <> contents <>
char '}'
inlineToTexinfo (Image attr alternate (source, _)) = do
content <- withContext NodeContext $ inlineListToTexinfo alternate
content <- withContext ArgumentContext $ inlineListToTexinfo alternate
opts <- gets stOptions
let showDim dim = case dimension dim attr of
(Just (Pixel a)) -> showInInch opts (Pixel a) <> "in"
+13
View File
@@ -0,0 +1,13 @@
```
% pandoc -t texinfo
[a.b](url)
[a,b](url)
^D
@node Top
@top Top
@uref{url,a.b}
@uref{url,a@comma{}b}
```
+1 -1
View File
@@ -948,7 +948,7 @@ In a list?
It should.
@end itemize
An e-mail address: @uref{mailto:nobody@@nowhere.net,nobody@@nowherenet}
An e-mail address: @uref{mailto:nobody@@nowhere.net,nobody@@nowhere.net}
@quotation
Blockquoted: @url{http://example.com/}