2

The following examples compiles but creates warnings just when the float parameter is used.

\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[float, language=tex, label=lst-enum, caption={Enumerated list.}]
\begin{enumerate}
\item example 1
\item example 2
\item example 3
\end{enumerate}
\end{lstlisting}
\end{document}

I'm compiling with make4ht and the warning generated are:

[WARNING] domfilter: DOM parsing of article.html failed:
[WARNING] domfilter: .../texlive/texmf-dist/tex/luatex/luaxml/luaxml-mod-xml.lua:175: Unbalanced Tag (/figure) [char=1997]

Is there something wrong or a way to avoid these warnings? Could it lead to a crash in a more complex example?

1 Answer 1

1

The domfilter error means that the generated HTML file is not valid and DOM processing failed. This is a serious issue, as make4ht uses it to fix common errors in the generated HTML file.

The problem is that TeX4ht configuration for lstlisting environment inserts 'tags around it's content, but thefloatoption inserts` tag at the wrong place.

Try this configuration file:

\Preamble{xhtml}
\begin{document}
\makeatletter
\catcode`\:=11
\ConfigureEnv{lstlisting}
   {\ifvmode \IgnorePar\fi \EndP
    \gHAdvance\listingN by 1
    \HCode{<!--l. \the\inputlineno-->}%
    \gdef\start:LstLn{%
       \HCode{<div class="lstlisting" id="listing-\listingN">}%
       \gdef\start:LstLn{\:nbsp%
\HCode{<br />\Hnewline}}}
    \bgroup
\pend:def\lst@DeInit{\ifvmode \IgnorePar\fi \EndP \HCode{</div>}}
       \Configure{listings}
         {{\everypar{}\leavevmode}}
         {{\everypar{}\leavevmode}}
         {\start:LstLn \HCode{<span class="label">}}
         {\HCode{</span>}}%
   }
   {\egroup\par
    }
   {} {}
\catcode`\:=12
\makeatother
\EndPreamble

It is a modified version from TeX4ht sources, the difference is that it patches the \lst@DeInit macro to insert the closing tag for </div> before </figure>, in order to produce the correct HTML structure.

2
  • So this a temporary patch while it is not fixed in newer versions of make4ht, right?
    – LEo
    Sep 17, 2021 at 13:48
  • 2
    @LEo yes. I've already fixed that in TeX4ht sources, so it should be available soon in TL.
    – michal.h21
    Sep 17, 2021 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.