[latex3-commits] [git/LaTeX3-latex3-hyperref] cleanup-patches: allow to suppress toc patches (8fd5bd1)

Ulrike Fischer fischer at troubleshooting-tex.de
Tue Feb 7 15:32:33 CET 2023


Repository : https://github.com/latex3/hyperref
On branch  : cleanup-patches
Link       : https://github.com/latex3/hyperref/commit/8fd5bd198e250e16c44cd01c2fe978b3109abcb6

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

commit 8fd5bd198e250e16c44cd01c2fe978b3109abcb6
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Tue Feb 7 15:32:33 2023 +0100

    allow to suppress toc patches


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

8fd5bd198e250e16c44cd01c2fe978b3109abcb6
 ChangeLog.txt        |   5 +-
 doc/hyperref-doc.tex |   4 ++
 hyperref.dtx         | 170 ++++++++++++++++++++++++++-------------------------
 3 files changed, 95 insertions(+), 84 deletions(-)

diff --git a/ChangeLog.txt b/ChangeLog.txt
index 9c2269b..84e4509 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -2,7 +2,10 @@
     * if babel is loaded casing with \MakeUppercase and \MakeLowercase
       respects the rules of the current locale/language in the bookmarks.
     * removed old amstex patch of \@seteqlabel
-    * add \hyper at nopatch@amsmath at tag to allow to suppress an amsmath patch
+    * added test for \hyper at nopatch@amsmath at tag to allow to suppress an amsmath patch
+    * added test for \hyper at nopatch@counter to allow to suppress redefinitions of counter commands
+    * added test for \hyper at nopatch@mathenv to suppress math related patches
+    * added test for \hyper at nopatch@toc to suppress redefinition of toc related commands.
 
 2023-02-04 Yukai Chou
     * change puenc-greek.def to puenc-greekbasic.def in docs, to sync with file
diff --git a/doc/hyperref-doc.tex b/doc/hyperref-doc.tex
index 8a9e647..ac7a5d7 100644
--- a/doc/hyperref-doc.tex
+++ b/doc/hyperref-doc.tex
@@ -554,6 +554,10 @@ Check the \xpackage{nameref} documentation about a way to suppress these patches
 \item[math environments] hyperref patches \cs{equation}/\cs{endequation}, \cs{eqnarray},    
     \cs{endeqnarray}. This code can be suppressed by 
     defining \cs{hyper at nopatch@mathenv}. 
+    
+\item[table of contents] hyperref redefines \cs{contentsline} to be able to add links to
+toc entries. It redefines \cs{addcontentsline} to create the bookmarks and pass the 
+destination names to the toc entries. This code can be suppressed by defining \cs{hyper at nopatch@toc}.     
 \end{description}
 
 \section{Package options}
diff --git a/hyperref.dtx b/hyperref.dtx
index acdae76..022615b 100644
--- a/hyperref.dtx
+++ b/hyperref.dtx
@@ -11961,56 +11961,58 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\def\addcontentsline#1#2#3{% toc extension, type, tag
-  \begingroup
-    \let\label\@gobble
-    \ifx\@currentHref\@empty
-      \Hy at Warning{%
-        No destination for bookmark of \string\addcontentsline,%
-        \MessageBreak destination is added%
-      }%
-      \phantomsection
-    \fi
-    \expandafter\ifx\csname toclevel@#2\endcsname\relax
-      \begingroup
-        \def\Hy at tempa{#1}%
-        \ifx\Hy at tempa\Hy at bookmarkstype
-          \Hy at WarningNoLine{%
-            bookmark level for unknown #2 defaults to 0%
-          }%
-        \else
-          \Hy at Info{bookmark level for unknown #2 defaults to 0}%
-        \fi
-      \endgroup
-      \expandafter\gdef\csname toclevel@#2\endcsname{0}%
-    \fi
-    \edef\Hy at toclevel{\csname toclevel@#2\endcsname}%
-    \Hy at writebookmark{\csname the#2\endcsname}%
-      {#3}%
-      {\@currentHref}%
-      {\Hy at toclevel}%
-      {#1}%
-    \ifHy at verbose
-      \begingroup
-        \def\Hy at tempa{#3}%
-        \@onelevel at sanitize\Hy at tempa
-        \let\temp at online\on at line
-        \let\on at line\@empty
-        \Hy at Info{%
-          bookmark\temp at online:\MessageBreak
-          thecounter {\csname the#2\endcsname}\MessageBreak
-          text {\Hy at tempa}\MessageBreak
-          reference {\@currentHref}\MessageBreak
-          toclevel {\Hy at toclevel}\MessageBreak
-          type {#1}%
+\@ifundefined{hyper at nopatch@toc}{%
+  \def\addcontentsline#1#2#3{% toc extension, type, tag
+    \begingroup
+      \let\label\@gobble
+      \ifx\@currentHref\@empty
+        \Hy at Warning{%
+          No destination for bookmark of \string\addcontentsline,%
+          \MessageBreak destination is added%
         }%
-      \endgroup
-    \fi
-    \addtocontents{#1}{%
-      \protect\contentsline{#2}{#3}{\thepage}{\@currentHref}\protected at file@percent
-    }%
-  \endgroup
-}
+        \phantomsection
+      \fi
+      \expandafter\ifx\csname toclevel@#2\endcsname\relax
+        \begingroup
+          \def\Hy at tempa{#1}%
+          \ifx\Hy at tempa\Hy at bookmarkstype
+            \Hy at WarningNoLine{%
+              bookmark level for unknown #2 defaults to 0%
+            }%
+          \else
+            \Hy at Info{bookmark level for unknown #2 defaults to 0}%
+          \fi
+        \endgroup
+        \expandafter\gdef\csname toclevel@#2\endcsname{0}%
+      \fi
+      \edef\Hy at toclevel{\csname toclevel@#2\endcsname}%
+      \Hy at writebookmark{\csname the#2\endcsname}%
+        {#3}%
+        {\@currentHref}%
+        {\Hy at toclevel}%
+        {#1}%
+      \ifHy at verbose
+        \begingroup
+          \def\Hy at tempa{#3}%
+          \@onelevel at sanitize\Hy at tempa
+          \let\temp at online\on at line
+          \let\on at line\@empty
+          \Hy at Info{%
+            bookmark\temp at online:\MessageBreak
+            thecounter {\csname the#2\endcsname}\MessageBreak
+            text {\Hy at tempa}\MessageBreak
+            reference {\@currentHref}\MessageBreak
+            toclevel {\Hy at toclevel}\MessageBreak
+            type {#1}%
+          }%
+        \endgroup
+      \fi
+      \addtocontents{#1}{%
+        \protect\contentsline{#2}{#3}{\thepage}{\@currentHref}\protected at file@percent
+      }%
+    \endgroup
+  }
+}{}  
 %    \end{macrocode}
 %    \begin{macro}{\contentsline}
 %    The page number might be empty. In this case the link for the
@@ -12023,46 +12025,48 @@
 \protected\def\Hy at toclinkstart{\hyper at linkstart{link}{\Hy at tocdestname}}
 \protected\def\Hy at toclinkend{\hyper at linkend}
 
-\def\contentsline#1#2#3#4{%
-  \begingroup
-    \Hy at safe@activestrue
-  \edef\x{\endgroup
-    \def\noexpand\Hy at tocdestname{#4}%
-  }\x
-  \ifx\Hy at tocdestname\ltx at empty
-    \csname l@#1\endcsname{#2}{#3}%
-  \else
-    \ifcase\Hy at linktoc % none
+\@ifundefined{hyper at nopatch@toc}{%
+  \def\contentsline#1#2#3#4{%
+    \begingroup
+      \Hy at safe@activestrue
+    \edef\x{\endgroup
+      \def\noexpand\Hy at tocdestname{#4}%
+    }\x
+    \ifx\Hy at tocdestname\ltx at empty
       \csname l@#1\endcsname{#2}{#3}%
-    \or % section
-      \csname l@#1\endcsname{%
-        \Hy at toclinkstart{#2}\Hy at toclinkend
-      }{#3}%
-    \or % page
-      \def\Hy at temp{#3}%
-      \ifx\Hy at temp\ltx at empty
+    \else
+      \ifcase\Hy at linktoc % none
         \csname l@#1\endcsname{#2}{#3}%
-      \else
-        \csname l@#1\endcsname{{#2}}{%
-          \Hy at toclinkstart{#3}\Hy at toclinkend
-        }%
-      \fi
-    \else % all
-      \def\Hy at temp{#3}%
-      \ifx\Hy at temp\ltx at empty
-        \csname l@#1\endcsname{%
-          \Hy at toclinkstart{#2}\Hy at toclinkend
-        }{}%
-      \else
+      \or % section
         \csname l@#1\endcsname{%
           \Hy at toclinkstart{#2}\Hy at toclinkend
-        }{%
-          \Hy at toclinkstart{#3}\Hy at toclinkend
-        }%
+        }{#3}%
+      \or % page
+        \def\Hy at temp{#3}%
+        \ifx\Hy at temp\ltx at empty
+          \csname l@#1\endcsname{#2}{#3}%
+        \else
+          \csname l@#1\endcsname{{#2}}{%
+            \Hy at toclinkstart{#3}\Hy at toclinkend
+          }%
+        \fi
+      \else % all
+        \def\Hy at temp{#3}%
+        \ifx\Hy at temp\ltx at empty
+          \csname l@#1\endcsname{%
+            \Hy at toclinkstart{#2}\Hy at toclinkend
+          }{}%
+        \else
+          \csname l@#1\endcsname{%
+            \Hy at toclinkstart{#2}\Hy at toclinkend
+          }{%
+            \Hy at toclinkstart{#3}\Hy at toclinkend
+          }%
+        \fi
       \fi
     \fi
-  \fi
-}
+  }
+}{}
 %    \end{macrocode}
 %    \end{macro}
 %





More information about the latex3-commits mailing list.