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

\begin{lstlisting}[float, language=tex, label=lst-enum, caption={Enumerated list.}]
\item example 1
\item example 2
\item example 3

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


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:

   {\ifvmode \IgnorePar\fi \EndP
    \gHAdvance\listingN by 1
    \HCode{<!--l. \the\inputlineno-->}%
       \HCode{<div class="lstlisting" id="listing-\listingN">}%
\HCode{<br />\Hnewline}}}
\pend:def\lst@DeInit{\ifvmode \IgnorePar\fi \EndP \HCode{</div>}}
         {\start:LstLn \HCode{<span class="label">}}
   {} {}

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.

  • 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .