[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Sun, 14 Aug 2022 13:07:03 -0400 (EDT) |
branch: master
commit 97e7c04f0ce4e7e8bdc2ed3eedf4c3229a136ed1
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Aug 14 18:06:54 2022 +0100
@{, @} in index entry
* tp/Texinfo/Convert/LaTeX.pm (_convert) <@{, @}>:
If in an index, use \lbrace or \rbrace in math, and
\textbraceleft or \textbraceright otherwise.
---
ChangeLog | 8 ++++++++
tp/Texinfo/Convert/LaTeX.pm | 30 +++++++++++++++++++++++-------
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b28b0f3fb1..b5d0fd6db7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-08-14 Gavin Smith <gavinsmith0123@gmail.com>
+
+ @{, @} in index entry
+
+ * tp/Texinfo/Convert/LaTeX.pm (_convert) <@{, @}>:
+ If in an index, use \lbrace or \rbrace in math, and
+ \textbraceleft or \textbraceright otherwise.
+
2022-08-14 Gavin Smith <gavinsmith0123@gmail.com>
Better output for "maintain/all_tests.sh generate"
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 17d73e06d3..f5fc70f161 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -61,10 +61,6 @@
# or two hyphen, no break between __ or hyphen. See near \global\def\code
# in texinfo.tex.
#
-# Index with unmatched braces leads to e.g.
-# \index[cp]{\{}%
-# which doesn't work.
-#
#
# RELEVANT BUT NOT DECISIVE
#
@@ -2313,9 +2309,29 @@ sub _convert($$)
$result .= "\\ {}";
} elsif ($cmdname eq '-') {
$result .= "\\-{}";
- } elsif ($cmdname eq '}' or $cmdname eq '{') {
- # always protect, even in math mode
- $result .= "\\$cmdname";
+
+ } elsif ($cmdname eq '{' or $cmdname eq '}') {
+ # Index entries need balanced braces so we can't use \{ and \}.
+ if ($self->{'formatting_context'}->[-1]->{'index'}) {
+ if ($cmdname eq '{') {
+ if ($self->{'formatting_context'}->[-1]->{'text_context'}->[-1]
+ eq 'ctx_math') {
+ $result .= '\\lbrace{}';
+ } else {
+ $result .= '\\textbraceleft{}';
+ }
+ } elsif ($cmdname eq '}') {
+ if ($self->{'formatting_context'}->[-1]->{'text_context'}->[-1]
+ eq 'ctx_math') {
+ $result .= '\\rbrace{}';
+ } else {
+ $result .= '\\textbraceright{}';
+ }
+ }
+ } else {
+ # always protect, even in math mode
+ $result .= "\\$cmdname";
+ }
} else {
$result .= _protect_text($self, $no_brace_commands{$cmdname});
}