Debian Codegraph @

texmf-dist/tex/generic/tex4ht/listings.4ht

raw
1 % listings.4ht (2025-02-27-12:30), generated from tex4ht-4ht.tex
2 % Copyright 2001-2009 Eitan M. Gurari
3 % Copyright 2009-2025 TeX Users Group
4 %
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either
7 % version 1.3c of this license or (at your option) any
8 % later version. The latest version of this license is in
9 % https://www.latex-project.org/lppl.txt
10 % and version 1.3c or later is part of all distributions
11 % of LaTeX version 2005/12/01 or later.
12 %
13 % This work has the LPPL maintenance status "maintained".
14 %
15 % The Current Maintainer of this work
16 % is the TeX4ht Project <https://tug.org/tex4ht>.
17 %
18 % If you modify this program, changing the
19 % version identification would be appreciated.
20 \immediate\write-1{version 2025-02-27-12:30}
21
22 \@ifpackageloaded{xcolor}{}{%
23 \RequirePackage{xcolor}
24 }
25 \def\lst@makecaption#1#2{\cptA: #1\if :#1:\else\cptB:\fi \cptC: #2\cptD:}
26
27 \newif\iflstnest
28 \append:defII\lst@EnterMode{%
29 \ifx \lsthk:EveryLine\:UnDef
30 \let\lsthk:EveryLine\lsthk@EveryLine
31 \fi
32 \ifx \lsthk:EveryLine\lsthk@EveryLine
33 \pend:def\lsthk@EveryLine{\c:listings
34 \def\dd:listings{\d:listings\let\dd:listings\empty}}%
35 \fi
36 \append:def\lsthk@EveryPar{\dd:listings}%
37 \iflstnest\else
38 \a:listings\fi\bgroup
39 %\Configure{$}{}{}{}%
40 \aftergroup\lst:EnterMode }
41 \def\lst:EnterMode{\iflstnest\else\b:listings\fi\egroup}
42 \NewConfigure{listings}{4}
43 \let\dd:listings=\empty
44 \append:defI\lst@Init{\csname a:listings-init\endcsname\global\lstnesttrue}
45 \pend:def\lst@DeInit{\csname b:listings-init\endcsname\global\lstnestfalse}
46 \NewConfigure{listings-init}{2}
47 \pend:def\lst@escapebegin{\csname b:listings-init\endcsname\nobreak\hbox\bgroup\lsthk@OutputBox}
48 \append:def\lst@escapeend{\lsthk@PostOutput\egroup\csname a:listings-init\endcsname}
49 \lst@AddToHook{TextStyle}{%
50 \Configure{listings}{}{}{}{}%
51 \lst@ifmode\else%
52 \a:lstinline \bgroup \aftergroup\b:lstinline\aftergroup\egroup%
53 \fi%
54 }
55 \NewConfigure{lstinline}{2}
56 \ConfigureToc{lol} {}{\empty}{}{\newline}
57 \lst@UserCommand\lstlistoflistings{\bgroup%
58 \ifdefined\chapter\chapter*{\lstlistlistingname}\else\section*{\lstlistlistingname}\fi%
59 \TableOfContents[lol]%
60 \egroup}
61 \def\:tempa{%
62 \ifx\lst@OutputBox\@gobble\else \the\everypar \fi
63 \global\advance\lst@newlines\m@ne
64 \lst@newlinetrue
65 }%
66 \HLet\lst@NewLine\:tempa
67 \def\:tempa#1{
68 \begingroup%
69 \lsthk@PreSet\gdef\lst@intname{#1}%
70 \expandafter\lstset\expandafter{\lst@set}%
71 \lsthk@DisplayStyle%
72 \catcode\active=\active%
73 \a:lstinputlisting\ht:special{t4ht@[}
74 \pend:def\cptA:{\ht:special{t4ht@]}}
75 \append:def\cptD:{\ht:special{t4ht@[}}
76 \lst@Init\relax \let\lst@gobble\z@%
77 \lst@SkipToFirst%
78 \lst@ifprint \def\lst@next{\input{#1}}%
79 \else \let\lst@next\@empty \fi%
80 \ht:special{t4ht@]}\lst@next\ht:special{t4ht@[}\lst@DeInit\ht:special{t4ht@]}%
81 \b:lstinputlisting%
82 \endgroup}
83
84 \HLet\lst@InputListing\:tempa
85 \NewConfigure{lstinputlisting}{2}
86 \def\:tempa#1{%
87 \setbox\z@\hbox{{\lst@currstyle{\kern#1}}}%
88 \global\advance\lst@currlwidth \wd\z@
89 \tmp:dim=#1 \let\:tempc=\empty
90 \loop \ifdim \tmp:dim>\a:lst@Kern
91 \advance \tmp:dim by -\a:lst@Kern
92 \advance \tmp:dim by -\b:lst@Kern
93 \append:def\:tempc{\:nbsp}%
94 \repeat
95 \setbox\z@\hbox{{\lst@currstyle{\:tempc}}}%
96 \lst@OutputBox\z@}
97 \HLet\lst@Kern\:tempa
98 \NewConfigure{lst@Kern}{2}
99 \Configure{lst@Kern}{0.499em}{0.1em}
100 \def\lst@outputspace{\HCode{ }}
101
102 \def\lst:newaddcontentsline#1#2#3{\gHAdvance\TitleCount by 1
103 {\protect:wrtoc%
104 \Tag{)Qlisting-\the\numexpr\listingN+1\relax}{\FileNumber}% write listings id to the xref file, so it can be used in links
105 \protected@edef\:temp{#3}%
106 \protected@edef\:temp{\the\:tokwrite{\string\doTocEntry%
107 \string\toclol% identify this entry as list of listings
108 {\thetable}{\string\csname\space a:TocLink\string\endcsname%
109 {\FileNumber}{listing-\the\numexpr\listingN+1\relax}{}{\ifx\:temp\empty\else \ignorespaces #3\fi}}%
110 {}\relax}}\:temp%
111 }}%
112 \pend:defI\lst@MakeCaption{%
113 \let\lst:addcontentsline\addcontentsline%
114 \let\addcontentsline\lst:newaddcontentsline%
115 }
116 \append:defI\lst@MakeCaption{%
117 \let\addcontentsline\lst:addcontentsline
118 }
119 \ConfigureToc{lol} {}{\empty}{}{\newline}
120 \AtBeginDocument{%
121 \def\lstlistoflistings{\bgroup%
122 \ifdefined\chapter\chapter*{\lstlistlistingname}\else\section*{\lstlistlistingname}\fi%
123 \TableOfContents[lol]%
124 \egroup}}
125
126 \HLet\lst@frameInit=\empty
127 \HLet\lst@frameExit=\empty
128
129 \Hinput{listings}
130 \endinput
131