[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/LaTeX.pm (_protect_index_tex
From: |
Gavin D. Smith |
Subject: |
branch master updated: * tp/Texinfo/Convert/LaTeX.pm (_protect_index_text): Protect \ before ", so @"a outputs as "\""a. (_protect_text): Do not call _protect_index_text. (_index_entry): Call _protect_index_test as needed. |
Date: |
Sat, 08 Oct 2022 07:08:24 -0400 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 41fbcfdd6b * tp/Texinfo/Convert/LaTeX.pm (_protect_index_text):
Protect \ before ", so @"a outputs as "\""a. (_protect_text): Do not call
_protect_index_text. (_index_entry): Call _protect_index_test as needed.
41fbcfdd6b is described below
commit 41fbcfdd6b5ef311b0bf5e465336d940a7a9245a
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Oct 8 12:08:00 2022 +0100
* tp/Texinfo/Convert/LaTeX.pm (_protect_index_text):
Protect \ before ", so @"a outputs as "\""a.
(_protect_text): Do not call _protect_index_text.
(_index_entry): Call _protect_index_test as needed.
---
ChangeLog | 7 +++++++
tp/Texinfo/Convert/LaTeX.pm | 21 ++++++++++-----------
tp/t/results/latex_tests/indices.pl | 2 +-
.../latex_tests/indices/res_latex/indices.tex | 2 +-
4 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9170566f73..ab9a9cb9eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-10-08 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/Convert/LaTeX.pm (_protect_index_text):
+ Protect \ before ", so @"a outputs as "\""a.
+ (_protect_text): Do not call _protect_index_text.
+ (_index_entry): Call _protect_index_test as needed.
+
2022-10-08 Patrice Dumas <pertusus@free.fr>
* Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 4af63e128d..753a7fc28b 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -1628,6 +1628,10 @@ sub _protect_index_text($)
{
my $text = shift;
$text =~ s/([!|"@])/"$1/g;
+
+ # if " is preceded by \ it does not quote the next character unless the
+ # \ itself is preceded by ".
+ $text =~ s/\\"/"\\"/g;
return $text;
}
@@ -1636,12 +1640,9 @@ sub _protect_text($$)
{
my ($self, $text) = @_;
- # FIXME are there some special characters to protect in math mode,
- # for instance # and ~?
if ($self->{'formatting_context'}->[-1]->{'text_context'}->[-1] eq
'ctx_math') {
- if ($self->{'formatting_context'}->[-1]->{'index'}) {
- $text = _protect_index_text($text);
- }
+ # FIXME are there any special characters to protect in math mode,
+ # for instance # and ~?
} elsif ($self->{'formatting_context'}->[-1]->{'text_context'}->[-1]
ne 'ctx_raw') {
# temporarily replace \ with a control character
@@ -1654,9 +1655,6 @@ sub _protect_text($$)
$text =~ s/\x08/\\textbackslash{}/g;
- if ($self->{'formatting_context'}->[-1]->{'index'}) {
- $text = _protect_index_text($text);
- }
if ($self->{'formatting_context'}->[-1]->{'code'}->[-1]) {
# Prevent extra space after punctuation. (We could use \frenchspacing
# in the output, but this can break in section titles with hyperref.)
@@ -2142,13 +2140,14 @@ sub _index_entry($$)
if (defined($sortas)) {
# | in sort key breaks with hyperref
$sortas =~ s/\|//g;
- $result = _protect_text($self, $sortas).'@';
+ $result = _protect_text($self, $sortas);
$result =~ s/\\[{}]//g; # cannot have unmatched braces in index entry
+ $result = _protect_index_text($result).'@';
}
if ($in_code) {
- $result .= "\\texttt{$index_entry}";
+ $result .= "\\texttt{" . _protect_index_text($index_entry) . "}";
} else {
- $result .= $index_entry;
+ $result .= _protect_index_text($index_entry);
}
push @result, $result;
}
diff --git a/tp/t/results/latex_tests/indices.pl
b/tp/t/results/latex_tests/indices.pl
index e8c8ad4dab..e748b7c76e 100644
--- a/tp/t/results/latex_tests/indices.pl
+++ b/tp/t/results/latex_tests/indices.pl
@@ -1319,7 +1319,7 @@ $result_converted{'latex_text'}->{'indices'} = '
\\chapter{{Index}}
\\label{anchor:chapter}%
-\\index[cp]{a"!"""@b """!"@ a"" o""@$a"!"""@b$ """!"@ \\"{a}
\\"{o}!a"!"""@b@sub$a"!"""@b$ sub """!"@ \\"{a} \\"{o}|seealso{$a"!"""@b$
"""!"@ \\"{a} \\"{o}}}%
+\\index[cp]{a"!"""@b """!"@ a"" o""@$a"!"""@b$ """!"@ "\\""{a}
"\\""{o}!a"!"""@b@sub$a"!"""@b$ sub """!"@ "\\""{a} "\\""{o}|seealso{$a!"@b$
"!@ \\"{a} \\"{o}}}%
\\index[cp]{cmd@\\textbackslash{}cmd}%
\\index[cp]{\\textbackslash{}cmd@totocmd}%
diff --git a/tp/t/results/latex_tests/indices/res_latex/indices.tex
b/tp/t/results/latex_tests/indices/res_latex/indices.tex
index 407e614493..5bf96037ba 100644
--- a/tp/t/results/latex_tests/indices/res_latex/indices.tex
+++ b/tp/t/results/latex_tests/indices/res_latex/indices.tex
@@ -51,7 +51,7 @@
\chapter{{Index}}
\label{anchor:chapter}%
-\index[cp]{a"!"""@b """!"@ a"" o""@$a"!"""@b$ """!"@ \"{a}
\"{o}!a"!"""@b@sub$a"!"""@b$ sub """!"@ \"{a} \"{o}|seealso{$a"!"""@b$ """!"@
\"{a} \"{o}}}%
+\index[cp]{a"!"""@b """!"@ a"" o""@$a"!"""@b$ """!"@ "\""{a}
"\""{o}!a"!"""@b@sub$a"!"""@b$ sub """!"@ "\""{a} "\""{o}|seealso{$a!"@b$ "!@
\"{a} \"{o}}}%
\index[cp]{cmd@\textbackslash{}cmd}%
\index[cp]{\textbackslash{}cmd@totocmd}%
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/LaTeX.pm (_protect_index_text): Protect \ before ", so @"a outputs as "\""a. (_protect_text): Do not call _protect_index_text. (_index_entry): Call _protect_index_test as needed.,
Gavin D. Smith <=