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

Michal Hoftich INVALID.NOREPLY at gnu.org.ua
Sun Mar 20 15:18:12 CET 2022


Author: michal_h21
Date: 2022-03-20 14:18:12 +0000 (Sun, 20 Mar 2022)
New Revision: 1092

Modified:
   trunk/lit/ChangeLog
   trunk/lit/tex4ht-html4.tex
Log:
Added support for background and border colors in listings

Modified: trunk/lit/ChangeLog
===================================================================
--- trunk/lit/ChangeLog	2022-03-17 11:02:16 UTC (rev 1091)
+++ trunk/lit/ChangeLog	2022-03-20 14:18:12 UTC (rev 1092)
@@ -1,3 +1,9 @@
+2021-03-20  Michal Hoftich  <michal.h21 at gmail.com>
+
+	* tex4ht-html4.tex (html4.4ht): added support for background and
+	border colors in Listings.
+	https://tex.stackexchange.com/a/637789/2891
+
 2021-03-17  Michal Hoftich  <michal.h21 at gmail.com>
 
 	* tex4ht-fonts-opensans.tex: added support for OpenSans fonts.

Modified: trunk/lit/tex4ht-html4.tex
===================================================================
--- trunk/lit/tex4ht-html4.tex	2022-03-17 11:02:16 UTC (rev 1091)
+++ trunk/lit/tex4ht-html4.tex	2022-03-20 14:18:12 UTC (rev 1092)
@@ -15222,10 +15222,13 @@
 \subsection{Listings}
 %%%%%%%%%%%%%%%%%%%%%
 
+Inline listings snippets
+
 \<configure html4 listings\><<<
 \Configure{lstinline}
-   {\HCode{<span class="lstinline">}}
-   {\HCode{</span>}}
+   {\HCode{<code class="lstinline">}\NoFonts}
+   {\EndNoFonts\HCode{</code>}}
+\Css{code.lstinline{font-family:monospace,monospace;}}
 >>>
 
 \<configure html4 listings\><<<
@@ -15307,18 +15310,19 @@
 \Configure{lstinputlisting}  
    {\ifvmode \IgnorePar\fi \EndP  
     \HCode{<!--l. \the\inputlineno-->}%  
-    \HCode{<pre class="lstinputlisting">}%  
-    \bgroup \tt %\special{t4ht@(}%  
-       \Configure{listings}  
-         {{\everypar{}\leavevmode}}  
-         {{\everypar{}\leavevmode}}  
+    \gHAdvance\listingN by 1%
+    \HCode{<pre class="lstinputlisting" id="listing-\listingN">}%  
+    \bgroup\ttfamily%\special{t4ht@(}%  
+       \Configure{listings}%
+         {{\everypar{}\leavevmode}}%  
+         {{\everypar{}\leavevmode}}%  
          {|<nbsp|>%
-             \HCode{<br />\Hnewline<span class="label">}}  
+             \HCode{<br />\Hnewline<span class="label">}}%  
          {\HCode{</span>}}%  
    }  
    {%\special{t4ht@)}
-    \egroup  
-    \ifvmode \IgnorePar\fi \EndP  \HCode{</pre>}\par} 
+    \egroup%  
+    \ifvmode \IgnorePar\fi \EndP  \HCode{</pre>}\par}% 
 \Css{pre.lstinputlisting{
    font-family: monospace,monospace;
    white-space: nowrap;
@@ -15354,6 +15358,28 @@
   \HCode{<span style="color:\#\html at color">}}% init
 >>>
 
+Support for background and border color
+
+\<configure html4 listings\><<<
+\lst at AddToHook{Init}{%
+\bgroup%
+  % handle backround color and border in listings
+  \ifx\lst at fillcolor\@empty\else%
+    \lst at fillcolor%
+    \extractcolorspec{.}\html at fillcolor%
+    \expandafter\convertcolorspec\html at fillcolor{HTML}\html at fillcolor%
+    \Css{\#listing-\listingN{background-color:\#\html at fillcolor;}}%
+  \fi%
+  \ifx\lst at rulecolor\@empty\else%
+    \lst at rulecolor%
+    \extractcolorspec{.}\html at rulecolor%
+    \expandafter\convertcolorspec\html at rulecolor{HTML}\html at rulecolor%
+    \Css{\#listing-\listingN{border: 1px solid \#\html at rulecolor;}}%
+  \fi%
+\egroup%
+}
+>>>
+
 %%%%%%%%%%%%%%%%%%%%%
 \subsection{Verbatim}
 %%%%%%%%%%%%%%%%%%%%%



More information about the tex4ht-commits mailing list.