[latex3-commits] [git/LaTeX3-latex3-latex3] main: l3doc: suppress indexing within the table of contents (actually fixes #649) (8bed31fc3)

Bruno Le Floch blflatex at gmail.com
Sat May 1 00:10:56 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/8bed31fc384c550348554862d4b2bfb95cb1508c

>---------------------------------------------------------------

commit 8bed31fc384c550348554862d4b2bfb95cb1508c
Author: Bruno Le Floch <blflatex at gmail.com>
Date:   Sat May 1 00:10:56 2021 +0200

    l3doc: suppress indexing within the table of contents (actually fixes #649)


>---------------------------------------------------------------

8bed31fc384c550348554862d4b2bfb95cb1508c
 l3kernel/l3doc.dtx | 41 +++++++++++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 8 deletions(-)

diff --git a/l3kernel/l3doc.dtx b/l3kernel/l3doc.dtx
index 0debde18e..dad842120 100644
--- a/l3kernel/l3doc.dtx
+++ b/l3kernel/l3doc.dtx
@@ -1981,7 +1981,7 @@ and all files in that bundle must be distributed together.
         \tl_replace_all:Nno \l_@@_cmd_tl { _ } \l_@@_tmpb_tl
       }
 %    \end{macrocode}
-% \paragraph{Typesetting}
+% Typesetting.
 % Note the replacement for the underscore is to permit linebreaks.
 % The \texttt{underscore} package adds the linebreak,
 % and the regex results in applying the breakable underscore only to the \emph{last}
@@ -1989,9 +1989,9 @@ and all files in that bundle must be distributed together.
 %    \begin{macrocode}
     \mode_if_math:T { \mbox }
       {
-        \mode_leave_vertical:
+        \bool_if:NT \l_@@_allow_indexing_bool
+          { \mode_leave_vertical: \HD at target }
         \verbatim at font
-        \HD at target
         \@@_if_almost_str:VT \l_@@_cmd_tl
           {
             \__kernel_tl_set:Nx \l_@@_cmd_tl { \tl_to_str:N \l_@@_cmd_tl }
@@ -2008,16 +2008,17 @@ and all files in that bundle must be distributed together.
         \@
       }
 %    \end{macrocode}
-% \paragraph{Indexing}
+% Indexing.
 %    \begin{macrocode}
-    \bool_if:NF \l_@@_cmd_noindex_bool
-      {
+    \bool_if:NT \l_@@_allow_indexing_bool
+     {
+      \bool_if:NF \l_@@_cmd_noindex_bool
+       {
         \quark_if_no_value:NF \l_@@_cmd_index_tl
           {
             \__kernel_tl_set:Nx \l_@@_cmd_tl
               { \c_backslash_str \exp_not:o { \l_@@_cmd_index_tl } }
           }
-
         \exp_args:No \@@_key_get:n { \l_@@_cmd_tl }
         \quark_if_no_value:NF \l_@@_cmd_module_tl
           {
@@ -2030,7 +2031,8 @@ and all files in that bundle must be distributed together.
           { \l_@@_index_module_tl }
           { usage }
           \l_@@_index_internal_bool
-      }
+       }
+     }
   }
 \cs_generate_variant:Nn \@@_cmd:nn { no }
 %    \end{macrocode}
@@ -4040,6 +4042,29 @@ and all files in that bundle must be distributed together.
 %
 % \subsection{Indexing}
 %
+% \subsubsection{Necessary patching}
+%
+% Inside the table of contents (and other similar lists introduced by
+% \cs{@starttoc}), we suppress indexing.  This is because \cs{cmd},
+% \cs{cs}, or \cs{tn} appearing in titles only gets typeset in the
+% second run, and getting their indexing right would require even more
+% runs than we already need.  Besides, it is not useful to index uses of
+% some command in the table of contents.
+%    \begin{macrocode}
+\bool_new:N \l_@@_allow_indexing_bool
+\bool_set_true:N \l_@@_allow_indexing_bool
+\use:x
+  {
+    \exp_not:n { \cs_set_nopar:Npn \@starttoc #1 }
+      {
+        \group_begin:
+          \bool_set_false:N \l_@@_allow_indexing_bool
+          \exp_not:o { \@starttoc {#1} }
+        \group_end:
+      }
+  }
+%    \end{macrocode}
+%
 % \subsubsection{Userspace commands}
 %
 % Fix index (for now):





More information about the latex3-commits mailing list.