texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Gavin D. Smith
Date: Sun, 14 Aug 2022 19:06:37 -0400 (EDT)

branch: master
commit 49a7e20989ac9ca3ace2c12d48db6dce540934af
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Aug 14 20:36:23 2022 +0100

    No \{, \} in sort key
    
    * tp/Texinfo/Convert/LaTeX.pm (_index_entry) <sortas>:
    Strip \{ and \} out of sort key.
---
 ChangeLog                                  |   7 +
 tp/Texinfo/Convert/LaTeX.pm                |   1 +
 tp/t/latex_tests.t                         |   4 +-
 tp/t/results/latex_tests/brace_in_index.pl | 246 +++++++++++++++++++++++++++--
 4 files changed, 241 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9c600523ab..e151fc887d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-08-14  Gavin Smith  <gavinsmith0123@gmail.com>
+
+       No \{, \} in sort key
+
+       * tp/Texinfo/Convert/LaTeX.pm (_index_entry) <sortas>:
+       Strip \{ and \} out of sort key.
+
 2022-08-14  Gavin Smith  <gavinsmith0123@gmail.com>
 
        * tp/texi2any.pl (makeinfo_help): Remove --commands-in-node-names
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index f5fc70f161..0d7f08ef93 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -2115,6 +2115,7 @@ sub _index_entry($$)
       my $result = '';
       if (defined($sortas)) {
         $result = _protect_text($self, $sortas).'@';
+        $result =~ s/\\[{}]//g; # cannot have unmatched braces in index entry
       }
       if ($in_code) {
         $result .= "\\texttt{$index_entry}";
diff --git a/tp/t/latex_tests.t b/tp/t/latex_tests.t
index 524765c7f1..d21fd104fc 100644
--- a/tp/t/latex_tests.t
+++ b/tp/t/latex_tests.t
@@ -785,7 +785,9 @@ Describe @error{}.
 
 @cindex @samp{@{}
 
-@printindex cp
+@defun A@{A (BBB)
+CCC
+@end defun
 '],
 );
 
diff --git a/tp/t/results/latex_tests/brace_in_index.pl 
b/tp/t/results/latex_tests/brace_in_index.pl
index 53f64222fe..9b16c2ba89 100644
--- a/tp/t/results/latex_tests/brace_in_index.pl
+++ b/tp/t/results/latex_tests/brace_in_index.pl
@@ -317,27 +317,180 @@ $result_trees{'brace_in_index'} = {
           'type' => 'empty_line'
         },
         {
-          'args' => [
+          'cmdname' => 'defun',
+          'contents' => [
             {
-              'contents' => [
+              'args' => [
                 {
+                  'contents' => [
+                    {
+                      'contents' => [
+                        {
+                          'parent' => {},
+                          'text' => 'Function'
+                        }
+                      ],
+                      'extra' => {
+                        'def_role' => 'category'
+                      },
+                      'parent' => {},
+                      'type' => 'bracketed_inserted'
+                    },
+                    {
+                      'extra' => {
+                        'def_role' => 'spaces'
+                      },
+                      'parent' => {},
+                      'text' => ' ',
+                      'type' => 'spaces_inserted'
+                    },
+                    {
+                      'contents' => [
+                        {
+                          'parent' => {},
+                          'text' => 'A'
+                        },
+                        {
+                          'cmdname' => '{',
+                          'parent' => {}
+                        },
+                        {
+                          'parent' => {},
+                          'text' => 'A'
+                        }
+                      ],
+                      'extra' => {
+                        'def_role' => 'name'
+                      },
+                      'parent' => {},
+                      'type' => 'def_aggregate'
+                    },
+                    {
+                      'extra' => {
+                        'def_role' => 'spaces'
+                      },
+                      'parent' => {},
+                      'text' => ' ',
+                      'type' => 'spaces'
+                    },
+                    {
+                      'extra' => {
+                        'def_role' => 'delimiter'
+                      },
+                      'parent' => {},
+                      'text' => '(',
+                      'type' => 'delimiter'
+                    },
+                    {
+                      'extra' => {
+                        'def_role' => 'arg'
+                      },
+                      'parent' => {},
+                      'text' => 'BBB'
+                    },
+                    {
+                      'extra' => {
+                        'def_role' => 'delimiter'
+                      },
+                      'parent' => {},
+                      'text' => ')',
+                      'type' => 'delimiter'
+                    },
+                    {
+                      'extra' => {
+                        'def_role' => 'spaces'
+                      },
+                      'parent' => {},
+                      'text' => '
+',
+                      'type' => 'spaces_at_end'
+                    }
+                  ],
                   'parent' => {},
-                  'text' => 'cp'
+                  'type' => 'block_line_arg'
                 }
               ],
               'extra' => {
-                'spaces_after_argument' => '
+                'def_command' => 'defun',
+                'def_parsed_hash' => {
+                  'category' => {},
+                  'name' => {}
+                },
+                'index_entry' => {
+                  'command' => {},
+                  'content' => [
+                    {}
+                  ],
+                  'content_normalized' => [
+                    {}
+                  ],
+                  'in_code' => 1,
+                  'index_at_command' => 'defun',
+                  'index_ignore_chars' => {},
+                  'index_name' => 'fn',
+                  'index_type_command' => 'defun',
+                  'number' => 1
+                },
+                'original_def_cmdname' => 'defun'
+              },
+              'parent' => {},
+              'source_info' => {
+                'file_name' => '',
+                'line_nr' => 15,
+                'macro' => ''
+              },
+              'type' => 'def_line'
+            },
+            {
+              'contents' => [
+                {
+                  'contents' => [
+                    {
+                      'parent' => {},
+                      'text' => 'CCC
+'
+                    }
+                  ],
+                  'parent' => {},
+                  'type' => 'paragraph'
+                }
+              ],
+              'parent' => {},
+              'type' => 'def_item'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'parent' => {},
+                      'text' => 'defun'
+                    }
+                  ],
+                  'extra' => {
+                    'spaces_after_argument' => '
 '
+                  },
+                  'parent' => {},
+                  'type' => 'line_arg'
+                }
+              ],
+              'cmdname' => 'end',
+              'extra' => {
+                'command_argument' => 'defun',
+                'spaces_before_argument' => ' ',
+                'text_arg' => 'defun'
               },
               'parent' => {},
-              'type' => 'line_arg'
+              'source_info' => {
+                'file_name' => '',
+                'line_nr' => 17,
+                'macro' => ''
+              }
             }
           ],
-          'cmdname' => 'printindex',
           'extra' => {
-            'misc_args' => [
-              'cp'
-            ],
+            'end_command' => {},
             'spaces_before_argument' => ' '
           },
           'parent' => {},
@@ -400,8 +553,32 @@ 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[11]{'extra'}{'index_e
 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[11]{'extra'}{'index_entry'}{'content_normalized'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[11]{'args'}[0]{'contents'};
 $result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[11]{'parent'} = 
$result_trees{'brace_in_index'}{'contents'}[0];
 $result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[12]{'parent'} = 
$result_trees{'brace_in_index'}{'contents'}[0];
-$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'args'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'args'}[0];
-$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'args'}[0]{'parent'}
 = $result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[1]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[2]{'contents'}[0]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[2]{'contents'}[1]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[2]{'contents'}[2]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[2]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[3]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[4]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[5]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[6]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[7]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'extra'}{'def_parsed_hash'}{'category'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'extra'}{'def_parsed_hash'}{'name'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'extra'}{'index_entry'}{'command'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'extra'}{'index_entry'}{'content'}[0]
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'extra'}{'index_entry'}{'content_normalized'}[0]
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[0]{'parent'}
 = $result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[1]{'contents'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[1]{'contents'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[1]{'contents'}[0]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[1];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[1]{'parent'}
 = $result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[2]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[2]{'args'}[0];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[2]{'args'}[0]{'parent'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[2];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[2]{'parent'}
 = $result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13];
+$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'extra'}{'end_command'}
 = 
$result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'contents'}[2];
 $result_trees{'brace_in_index'}{'contents'}[0]{'contents'}[13]{'parent'} = 
$result_trees{'brace_in_index'}{'contents'}[0];
 $result_trees{'brace_in_index'}{'contents'}[0]{'parent'} = 
$result_trees{'brace_in_index'};
 
@@ -419,7 +596,9 @@ $result_texis{'brace_in_index'} = '@{
 
 @cindex @samp{@{}
 
-@printindex cp
+@defun A@{A (BBB)
+CCC
+@end defun
 ';
 
 
@@ -432,6 +611,8 @@ $result_texts{'brace_in_index'} = '{
 
 
 
+Function: A{A (BBB)
+CCC
 ';
 
 $result_errors{'brace_in_index'} = [
@@ -463,12 +644,12 @@ $result_errors{'brace_in_index'} = [
     'type' => 'warning'
   },
   {
-    'error_line' => 'warning: printindex before document beginning: 
@printindex cp
+    'error_line' => 'warning: entry for index `fn\' outside of any node
 ',
     'file_name' => '',
     'line_nr' => 15,
     'macro' => '',
-    'text' => 'printindex before document beginning: @printindex cp',
+    'text' => 'entry for index `fn\' outside of any node',
     'type' => 'warning'
   }
 ];
@@ -482,6 +663,9 @@ $result_indices_sort_strings{'brace_in_index'} = {
     '{',
     '{',
     '{'
+  ],
+  'fn' => [
+    'A{A'
   ]
 };
 
@@ -502,7 +686,18 @@ $$
 
 \\index[cp]{`\\texttt{\\textbraceleft{}}\'}%
 
-\\printindex[cp]
+
+\\noindent\\begin{tabularx}{\\linewidth}{@{}Xr}
+\\rightskip=5em plus 1 fill
+\\hangindent=2em
+\\noindent\\texttt{A\\{A 
\\EmbracOn{}\\textnormal{\\textsl{(BBB)}}\\EmbracOff{}}& [Function]
+\\end{tabularx}
+
+\\index[fn]{AA@\\texttt{A\\textbraceleft{}A}}%
+\\begin{quote}
+\\unskip{\\parskip=0pt\\noindent}%
+CCC
+\\end{quote}
 ';
 
 
@@ -515,6 +710,9 @@ $result_converted{'file_latex'}->{'brace_in_index'} = 
'\\documentclass{book}
 \\usepackage{textcomp}
 \\usepackage{graphicx}
 \\usepackage{etoolbox}
+\\usepackage{embrac}
+\\usepackage{expl3}
+\\usepackage{tabularx}
 \\usepackage{titleps}
 \\usepackage{float}
 % use hidelinks to remove boxes around links to be similar with Texinfo TeX
@@ -525,6 +723,7 @@ $result_converted{'file_latex'}->{'brace_in_index'} = 
'\\documentclass{book}
 \\newcommand{\\GNUTexinfosettitle}{No Title}%
 
 \\makeindex[name=cp]%
+\\makeindex[name=fn]%
 
 % redefine the \\mainmatter command such that it does not clear page
 % as if in double page
@@ -560,6 +759,10 @@ $result_converted{'file_latex'}->{'brace_in_index'} = 
'\\documentclass{book}
 % avoid pagebreak and headings setting for a sectionning command
 \\newcommand{\\GNUTexinfonopagebreakheading}[2]{\\let\\clearpage\\relax 
\\let\\cleardoublepage\\relax \\let\\thispagestyle\\GNUTexinfoplaceholder 
#1{#2}}
 
+% braces are upright in italic and slanted only in @def*
+% so it is turned off here, and turned on @def* lines
+\\EmbracOff{}%
+
 \\renewcommand{\\includegraphics}[1]{\\fbox{FIG \\detokenize{#1}}}
 
 \\makeatother
@@ -584,7 +787,18 @@ $$
 
 \\index[cp]{`\\texttt{\\textbraceleft{}}\'}%
 
-\\printindex[cp]
+
+\\noindent\\begin{tabularx}{\\linewidth}{@{}Xr}
+\\rightskip=5em plus 1 fill
+\\hangindent=2em
+\\noindent\\texttt{A\\{A 
\\EmbracOn{}\\textnormal{\\textsl{(BBB)}}\\EmbracOff{}}& [Function]
+\\end{tabularx}
+
+\\index[fn]{AA@\\texttt{A\\textbraceleft{}A}}%
+\\begin{quote}
+\\unskip{\\parskip=0pt\\noindent}%
+CCC
+\\end{quote}
 \\end{document}
 ';
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]