Ihor Radchenko <[email protected]> writes:
> Jonas Bernoulli <[email protected]> writes:
>
>>> * lisp/ox-texinfo.el (org-texinfo--sanitize-content): Sanitize commas
>>> everywhere to make sure that we do not end up with text commas being
>>> interpreted as argument separator in @command{arg1, arg2, ...}. This
>>> approach will produce @comma{} even when it is not necessary, but it
>>> is the safest approach.
>>
>> Could you please find a more localized solution? I would expect that
>> this can be done in org-texinfo-link instead. Replacing every comma
>> with @comma{} makes the resulting texinfo much harder to read.
>
> It indeed makes texinfo harder to read, but the original bug did not
> only reveal problems with @uref. At least, commands like @email (or
> anything else that can accept multiple arguments) are also bugged.
>
> Unfortunately, I am not very familiar with Texinfo (and ox-texinfo does
> not have a dedicated maintainer). So, given that comma appears to be
> special in various Texinfo constructs, I went with the safest option
> available.
>
> If someone who knows Texinfo syntax and how comma is used there can
> provide information on where exactly "," is special, it would help
> creating a clearner fix.
>
> For the time being, I judged that ugly texi sources are better than
> buggy export.
That's reasonable@comma{} but it also turned out rather painful for me.
In thousands of lines of mine@comma{} which are exported to texi@comma{}
not a single such comma appears@comma{} but there are many longer
sentences@comma{} which require comma@comma{} and become all but
unreadable in the output.
That is a problem because due to limitations in MELPA and some third-
party package managers, I am forced to check the texi files into git,
and since they are being tracked, I would like these files to remain
readable. So I was forced to revert this commit locally, but that also
means that I can no longer simply tell contributors to "edit manual.org
and then export to update manual.texi". I also have to make sure they
use "make texi" (which overrides org-texinfo--sanitize-content) and not
"C-c e i t".
Would you be willing to apply the below patch? That would allow me to
drop the patch and instead set that variable locally in all my manuals.
Cheers,
Jonas
commit 1f1bd99915c07889e2c264447fe4567fb084dbc9
Author: Jonas Bernoulli <[email protected]>
Date: Fri Aug 21 19:46:12 2026 +0200
Texinfo export: New option org-texinfo-escape-comma
* lisp/ox-texinfo.el (org-texinfo-sanitize-comma): New option.
(org-texinfo--sanitize-content): Use it.
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 191771d2c..cc389d4f7 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -416,6 +416,17 @@ (defcustom org-texinfo-remove-logfiles t
:group 'org-export-latex
:type 'boolean)
+;;;; Escape characters
+
+(defcustom org-texinfo-escape-comma t
+ "When non-nil comma (,) are replaced with `@comma{}'.
+This is useful when some comma appear in places where they actually have
+to be escaped, but has the downside that they are also escaped in places
+where that is not necessary, which makes the output much harder to read."
+ :package-version '(Org . "9.9")
+ :type 'boolean)
+;;;###autoload (put 'org-texinfo-escape-comma 'safe-local-variable 'booleanp)
+
;;; Constants
(defconst org-texinfo-max-toc-depth 4
@@ -604,11 +615,13 @@ (defun org-texinfo--sanitize-title-reference (title info)
(defun org-texinfo--sanitize-content (text)
"Escape special characters in string TEXT.
-Special characters are: @ { } ,"
- (thread-last
- text
- (replace-regexp-in-string "[@{}]" "@\\&")
- (replace-regexp-in-string "," "@comma{}")))
+Special characters are: @ { } ,
+Whether , are escaped depends on `org-texinfo-escape-comma';
+by default they are."
+ (setq text (replace-regexp-in-string "[@{}]" "@\\&" text))
+ (when org-texinfo-escape-comma
+ (setq text (replace-regexp-in-string "," "@comma{}" text)))
+ text)
(defun org-texinfo--wrap-float (value info &optional type label caption short)
"Wrap string VALUE within a @float command.