[tex4ht-commits] [SCM] tex4ht updated: r1632 - trunk/lit

Michal Hoftich INVALID.NOREPLY at gnu.org.ua
Thu Jan 23 13:34:17 CET 2025


Author: michal_h21
Date: 2025-01-23 12:34:17 +0000 (Thu, 23 Jan 2025)
New Revision: 1632

Modified:
   trunk/lit/ChangeLog
   trunk/lit/tex4ht-4ht.tex
Log:
fixed support for the list of listings{U+00A7}

Modified: trunk/lit/ChangeLog
===================================================================
--- trunk/lit/ChangeLog	2025-01-21 14:29:06 UTC (rev 1631)
+++ trunk/lit/ChangeLog	2025-01-23 12:34:17 UTC (rev 1632)
@@ -1,3 +1,9 @@
+2025-01-23  Michal Hoftich  <michal.h21 at gmail.com>
+
+	* tex4ht-4ht.tex (listigns.4ht): fixed support for the list of
+	listings.
+	https://tex.stackexchange.com/a/734717/2891
+	
 2025-01-21  Michal Hoftich  <michal.h21 at gmail.com>
 
 	* tex4ht-fonts-modern.tex

Modified: trunk/lit/tex4ht-4ht.tex
===================================================================
--- trunk/lit/tex4ht-4ht.tex	2025-01-21 14:29:06 UTC (rev 1631)
+++ trunk/lit/tex4ht-4ht.tex	2025-01-23 12:34:17 UTC (rev 1632)
@@ -34068,6 +34068,7 @@
 % Copyright |CopyYear.2001. Eitan M. Gurari
 |<TeX4ht copywrite|>
 |<listings sty|>
+|<listings list of|>
 |<lstmisc sty|>
 \Hinput{listings}
 \endinput
@@ -34137,17 +34138,48 @@
 \NewConfigure{lstinline}{2}
 >>>
 
-\<listings sty\><<<
+It seems that \Verb|\addcontentsline| is redefined in listings, which prevents 
+correct handling of \Verb|\lstlistoflistings|. We need to pass our definition 
+of \Verb|\addcontentsline| which can then be used to write the correct TOC
+information to the .4tc file.
+
+\<listings list of\><<<
+\def\lst:newaddcontentsline#1#2#3{\gHAdvance\TitleCount by 1
+  {\protect:wrtoc%
+  \protected at edef\:temp{#3}%
+   \protected at edef\:temp{\the\:tokwrite{\string\doTocEntry%
+   \string\toclol% identify this entry as list of listings
+   {\thetable}{\string\csname\space a:TocLink\string\endcsname%
+     {\FileNumber}{\cur:th \:currentlabel}{}{\ifx\:temp\empty\else \ignorespaces #3\fi}}%
+       {}\relax}}\:temp%
+}}%
+>>>
+
+We need to redefine \Verb|\addcontentsline| inside of Listing's version of MakeCaption.
+
+\<listings list of\><<<
 \pend:defI\lst at MakeCaption{%
-  \let\lst:addcontentsline\addcontentsline
-  \def\addcontentsline{\gHAdvance\TitleCount by 1
-                       \lst:addcontentsline}%
+  \let\lst:addcontentsline\addcontentsline%
+  \let\addcontentsline\lst:newaddcontentsline%
 }
 \append:defI\lst at MakeCaption{%
+  % insert destination ID for the list of listings
+  \Link{}{\cur:th\:currentlabel}\EndLink
   \let\addcontentsline\lst:addcontentsline
 }
 >>>
 
+And lastly, we need to use TeX4ht commands to print th elist of listings.
+
+\<listings list of\><<<
+\ConfigureToc{lol} {}{\empty}{}{\newline}
+\AtBeginDocument{%
+\def\lstlistoflistings{\bgroup%
+    \ifdefined\chapter\chapter*{\lstlistlistingname}\else\section*{\lstlistlistingname}\fi%
+    \TableOfContents[lol]%
+  \egroup}}
+>>>
+
 \<lstmisc sty\><<<
 \HLet\lst at frameInit=\empty
 \HLet\lst at frameExit=\empty



More information about the tex4ht-commits mailing list.