michal-h21 / make4ht

Build system for tex4ht
140 stars 15 forks source link

\toprule, \midrule, \bottomrule and make4ht #142

Open danielezambelli opened 10 months ago

danielezambelli commented 10 months ago

The macros in question produce a fatal error while \hline compiles correctly. Can this be corrected or should I replace all \*rule with \hline?

Here is a minimal example:

%--8<-------------------------------------
\documentclass[10pt,a4paper]{memoir}
\RequirePackage[italian]{babel}

\begin{document}

\begin{tabular}{cc}
\toprule
Valore per difetto di \(\sqrt{2}\) &Valore per eccesso di \(\sqrt{2}\) \\
\midrule
1 & 2\\
1,4 & 1,5 \\
1,41 & 1,42\\
1,414 & 1,415\\
1,4142 & 1,4143\\
\ldots & \ldots\\
\bottomrule
\end{tabular}

\end{document}
%--8<-------------------------------------

Compiled with: make4ht toprule.tex -c ml_make4ht -l -u -s -d ./html/mathjax "mathjax, 3, sec-filename, fn-in, blind"

Thank you for your attention.

michal-h21 commented 10 months ago

Thanks for the report. It seems that Memoir's support for the Booktabs package changed, so TeX4ht clashes with it. Try this configuration file, memoir.4ht, it should fix it:

% memoir.4ht (2023-08-16-13:07), generated from tex4ht-4ht.tex
% Copyright 2003-2009 Eitan M. Gurari
% Copyright 2009-2023 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2023-08-16-13:07}

\input book.4ht
\input verse.4ht
%\input booktabs.4ht
\let\columnlines\empty

\let\rm\empty
\let\sf\empty
\let\tt\empty
\let\bf\empty
\let\it\empty

\renewcommand*{\@memoldfonterr}[3]{}
\renewcommand*{\@memoldfontwarn}[3]{}

\def\@chapter[#1]#2{%
   \gHAdvance\:mpNum by 1
\HAssign\minipageNum=\:mpNum \relax
%
   {\SkipRefstepAnchor \let\addcontentsline\:gobbleIII\no@chapter[#1]{}%
    \global\let\f@rtoc\f@rtoc
    \ifx\f@rtoc\empty\gdef\f@rtoc{#2}\fi
    \global\let\f@rhdr\f@rhdr  }%
   \HtmlEnv   \Toc:Title{\f@rtoc}\:chapter{#2}}
\def\:tempc{\@ifstar\o:tableofcontents:\o:tableofcontents:}
\HLet\tableofcontents\:tempc
\Def:Section\book{\thebook}{#1}
\NewConfigure{abstracttitle}{2}
\newenvironment{abstracttitle4ht}{\a:abstracttitle}{\b:abstracttitle\par\noindent}
% get rid of all extra <span> elements introduced by smaller font size
% \renewcommand{\abstracttextfont}{\normalfont}
% \renewcommand{\abstractnamefont}{\normalfont}
% use our dummy environment to insert tags around the abstract title
\renewcommand{\absnamepos}{abstracttitle4ht}

\NewConfigure{poemline}{2}
\NewConfigure{legend}{2}
\renewcommand\legend[1]{\a:legend #1\b:legend}
\@ifpackageloaded{hyperref}{%
\ifHy@hyperfootnotes
\Hy@hyperfootnotesfalse
\newcounter{Hfootnote}
\fi
}{}
\def\:tempa#1|#2|#3\\{%
  \html:addr\hbox{\Link-{}{dx\last:haddr}\EndLink}%
  \expandafter\protected@write\csname \jobname @idxfile\endcsname{}{\string\beforeentry{\RefFileNumber\FileNumber}{dx\last:haddr}{}}%
  \expandafter\protected@write\csname \jobname @idxfile\endcsname{}{\string\indexentry[\@idxfile]{#1}{\thepage}}%
  \endgroup%
  \@esphack%
}
\HLet\@@wrindexhyp\:tempa
\HLet\@@wrspindexhyp\:tempa

% we use make4ht's splitindex functionality, which produces .ind files in the form of \jobname-idxname.ind
\renewcommand{\printindex}[1][\jobname]{\@input@{\jobname-#1.ind}}

\ifx \memgobble\:UnDef
   \pend:defI\getthelinenumber{%
   \let\sv:thepoemline\thepoemline
   \pend:def\thepoemline{\a:poemline}%
   \append:def\thepoemline{\b:poemline}}
\append:defI\getthelinenumber{\let\thepoemline\sv:thepoemline}

\else
   \pend:defII\getthelinenumber{%
   \let\sv:thepoemline\thepoemline
   \pend:def\thepoemline{\a:poemline}%
   \append:def\thepoemline{\b:poemline}}
\append:defII\getthelinenumber{\let\thepoemline\sv:thepoemline}

   \let\no@Msect\M@sect
\NewConfigure{@sec @ssect}[1]{%
   \def\rdef:sec##1{#1\csname no@##1\endcsname}}
\:CheckOption{sections-}     \if:Option
   \Configure{@sec @ssect}{}
\else
   \Configure{@sec @ssect}{%
      \let\sv:Sc\:Sc \let\sv:sect\@sect \let\sv:ssect\@ssect
\let\sv:Msect\M@sect
\let\:Sc\:gobble
      \def\M@sect##1##2##3##4##5##6[##7][##8]##9{%
   \ifx \o:@seccntformat:\:UnDef
  \let\o:@seccntformat:\@seccntformat
\fi
\let\@seccntformat\:gobble
%
   \let\M@sect\no@Msect   \xdef\c:secnumdepth{##2}%
   {\SkipRefstepAnchor \let\addcontentsline\:gobbleIII \let\mark\:gobble
    \no@Msect{##1}{##2}{##3}{##4}{##5}{##6}[{##7}][{##8}]{}}%
   \let\:Sc\sv:Sc \let\@sect\sv:sect \let\@ssect\sv:ssect
\let\M@sect\sv:Msect
%
   \let\@seccntformat=\o:@seccntformat:
%
   \HtmlEnv    \Toc:Title{##8}\csname no:#1\endcsname{##9}}%
%
      \def\@sect##1##2##3##4##5##6[##7]##8{%
   \ifx \o:@seccntformat:\:UnDef
  \let\o:@seccntformat:\@seccntformat
\fi
\let\@seccntformat\:gobble
%
   \let\@sect\no@sect   \xdef\c:secnumdepth{##2}%
   {\SkipRefstepAnchor \let\addcontentsline\:gobbleIII \let\mark\:gobble
    \no@sect{##1}{##2}{##3}{##4}{##5}{##6}[{##7}]{}}%
   \let\:Sc\sv:Sc \let\@sect\sv:sect \let\@ssect\sv:ssect
\let\M@sect\sv:Msect
%
   \let\@seccntformat=\o:@seccntformat:
%
   \HtmlEnv    \Toc:Title{##7}\csname no:#1\endcsname{##8}}%
%
      \def\@ssect##1##2##3##4##5{%
   \gdef\ssect:ttl{##5}%
%
   \let\@ssect\no@ssect
   {\def\addcontentsline####1####2####3{}%
    \no@ssect{##1}{##2}{##3}{##4}{}}%
   \let\:Sc\sv:Sc \let\@sect\sv:sect \let\@ssect\sv:ssect
\let\M@sect\sv:Msect
%
   \HtmlEnv   \csname :like#1\endcsname{##5}}%
\IgnorePar}
\fi

\fi
\Hinput{memoir}
\endinput
danielezambelli commented 10 months ago

Thank you, it works perfectly!

If you can, I would ask one more thing:

during compilation I get these warning messages:

[WARNING] tocid: char-def module not found [WARNING] tocid: cannot fix section id's [...] [WARNING] domfilter: DOM parsing of ml01InsiemiNumerici.html failed: [WARNING] domfilter: .../texlive/texmf-dist/tex/luatex/luaxml/luaxml-mod-xml.lua:175: Unbalanced Tag (/p) [char=14719]

Is there an easy way to avoid them and get a clean compilation?

The command I use is:

make4ht ml01InsiemiNumerici.tex -c ml_make4ht -l -u -s -d ./html/mathjax "mathjax, 3, sec-filename, fn-in, blind"

and configuration file is as follows:

\Preamble{xhtml}

%\renewenvironment{alternativetext}[1]{\Configure{Picture-alt}{#1}}{}

\catcode`\:=11
\Configure{underbrace}
   {\Configure{mathop*}{*}
         {<\a:mathml munder
                 \a:mathml accentunder="false"><\a:mathml mrow>}
         {</\a:mathml mrow><\a:mathml mo>\string
               &\#x23DF;</\a:mathml mo></\a:mathml munder>}
         {\Configure{mathop}{}{}{}{}}%
   }
   {\let\o:underbrace:=\displaystyle}
   {}
\Configure{overrightarrow}
  {\leavevmode\hbox\bgroup$\Tg<\a:mathml mover accent="true" class="overrightarrow">%
   \Tg<\a:mathml mrow\Hnewline>\:gobble}
  {\Tg</\a:mathml mrow>\HCode{<\a:mathml mo>&\#x2192;</\a:mathml mo>}%
   \Tg</\a:mathml mover>$\egroup}
\Configure{overleftarrow}
  {\leavevmode\hbox\bgroup$\Tg<\a:mathml mover accent="true" class="overleftarrow">%
   \Tg<\a:mathml mrow\Hnewline>\:gobble}
  {\Tg</\a:mathml mrow>\HCode{<\a:mathml mo>&\#x2190;</\a:mathml mo>}%
   \Tg</\a:mathml mover>$\egroup}

\catcode`\:=12

\makeatletter
\@ifpackageloaded{ulem}{%
\Configure{uline}
   {\HCode{<span class="uline">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Configure{uline-math}
   {\HCode{<span class="uline">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Css{.uline,.uline-math{ text-decoration:underline; }}
\Configure{uuline}
   {\HCode{<span class="uuline">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Configure{uuline-math}
   {\HCode{<span class="uuline">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Css{.uuline,.uuline-math{ text-decoration:underline double; }}
\Configure{sout}
   {\HCode{<span class="sout">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Configure{sout-math}
   {\HCode{<span class="sout">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Css{span.sout, .sout-math {text-decoration: line-through }}
\Configure{xout}
   {\HCode{<span class="xout">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Configure{xout-math}
   {\HCode{<span class="xout-math">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Css{span.xout, .xout-math {text-decoration: line-through underline }}
\Configure{uwave}
   {\HCode{<span class="uwave">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Configure{uwave-math}
   {\HCode{<span class="uwave-math">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Css{span.uwave, .uwave-math {text-decoration:underline wavy; }}
\Configure{dashuline}
   {\HCode{<span class="dashuline">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Configure{dashuline-math}
   {\HCode{<span class="dashuline-math">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Css{span.dashuline, .dashuline-math {text-decoration:underline dashed;}}
\Configure{dotuline}
   {\HCode{<span class="dotuline">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Configure{dotuline-math}
   {\HCode{<span class="dotuline-math">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Css{span.dotuline, .dotuline-math {text-decoration:underline dotted;}}
}{}
\makeatother

\ifcsname a:MathJaxConfig\endcsname

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Configurations for MathJax %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\catcode`\#=11 
\Configure{MathJaxConfig}{{ 
  tex: { 
    tags: "ams", 
    packages: {'[+]': ['html','enclose']},
    \detokenize{% 
      macros: { 
        uline: ["\\enclose{bottom}{#1}",1], 
        uuline: ["\\enclose{bottom}{\\enclose{bottom}{#1}}",1],  
        uwave: ["#1",1], 
%         uwave: ["\\enclose{bottom}{#1}",1],
%         uwave: ["\\style{border-bottom:1px underline wavy black;}{#1}",1], 
        sout: ["\\enclose{horizontalstrike}{#1}",1], 
        xout: ["\\enclose{bottom}{\\enclose{horizontalstrike}{#1}}",1], 
        dashuline: ["\\style{border-bottom:1px dashed black;}{#1}",1], 
        dotuline: ["\\style{border-bottom:1px dotted black;}{#1}",1], 
%%%% Insiemi numerici %%%%
        N: "\\mathbb{N}", 
        Nz: "\\mathbb{N}^0",
        Z: "\\mathbb{Z}",
        Zz: "\\mathbb{Z}^0",
        Q: "\\mathbb{Q}",
        Qz: "\\mathbb{Q}^0",
        Qp: "\\mathbb{Q}^+",
        J: "\\mathbb{J}",
        R: "\\mathbb{R}",
        Rz: "\\mathbb{R}^0",
        Rp: "\\mathbb{R}^+",
        C: "\\mathbb{C}",
        IN: "{}^*\\hspace{-.12em}\\mathbb{N}",
        IZ: "{}^*\\hspace{-.12em}\\mathbb{Z}",
        IR: "{}^*\\hspace{-.12em}\\mathbb{R}",
        IC: "{}^*\\hspace{-.12em}\\mathbb{C}",
        A: "\\mathbb{A}",
        K: "\\mathbb{K}",
        Dispari: "\\mathbb{D}",
        Pari: "\\mathbb{P}",
        Pol: "\\mathbb{P}",
%%%% Lettere greche in corsivo %%%%
        epsilon: "\\varepsilon",
        theta: "\\vartheta",
        rho: "\\varrho",
        phi: "\\varphi",
%%%% Delimitatori e parentesi %%%%
        tonda: ["\\left(#1\\right)", 1],
        quadra: ["\\left[#1\\right]", 1],
        rquadra: ["\\left]#1\\right[", 1],
        graffa: ["\\left\\{#1\\right\\}", 1],
        abs: ["\\left\\lvert#1\\right\\lvert", 1],
        valass: ["\\left\\lvert#1\\right\\lvert", 1],
        angolare: ["\\left\\langle#1\\right\\rangle", 1],
        pint: ["\\left\\lfloor#1\\right\\rfloor", 1],
        compreso: ["~[#1]~", 1],
        escluso: ["~]#1[~", 1],
%%%% Sistemi, vettori, punto %%%%
        sistema: ["\\left\\{\\begin{array}{lcl}#1\\end{array}\\right.", 1],
        fatratti: ["\\left\\{\\begin{array}{rclcl}#1\\end{array}\\right.", 1],
        matrice: ["\\begin{bmatrix}#1\\end{bmatrix}", 1],
        determ: ["\\begin{vmatrix}#1\\end{vmatrix}", 1],
%         vettore: ["\\left(\\begin{array}{c}#1\\end{array}\\right)", 1],
%         matrice: ["\\tonda{\\begin{array}{#1}#2\\end{array}}", 2],
        vect: ["\\overrightarrow{#1}", 1],
        coppia: ["\\tonda{#1;~#2}", 2],
        terna: ["\\tonda{#1;~#2;~#3}", 3],
        punto: ["#1\\tonda{#2;~#3}", 3],
        dist: ["\\mathcal{D}\\coppia{#1}{#2}", 2],
        lung: ["\\mathcal{L}\\coppia{#1}{#2}", 2],
        area: ["\\mathcal{A}_{#1}", 1],
        duep: "\\!:~",
%%%% Intervalli %%%%
        intervcc: ["\\left[#1;~#2\\right]", 2],
        intervac: ["\\left]#1;~#2\\right]", 2],
        intervca: ["\\left[#1;~#2\\right[", 2],
        intervaa: ["\\left]#1;~#2\\right[", 2],
%%%% Aggiunta di spazi ad alcuni operatori %%%%
        sand: "~ \\wedge ~",
        sor: "~ \\vee ~",
        scap: "~ \\cap ~",
        scup: "~ \\cup ~",
        svert: "~ \\vert ~",
        sLarrow: "~ \\Leftarrow ~",
        ssLarrow: "\\quad \\Leftarrow \\quad",
        sLRarrow: "~ \\Leftrightarrow ~",
        ssLRarrow: "\\quad \\Leftrightarrow \\quad",
        sRarrow: "~ \\Rightarrow ~",
        ssRarrow: "\\quad \\Rightarrow \\quad",
        slarrow: "~ \\leftarrow ~",
        sslarrow: "\\quad \\leftarrow \\quad",
        slrarrow: "~ \\leftrightarrow ~",
        sslrarrow: "\\quad \\leftrightarrow \\quad",
        srarrow: "~ \\rightarrow ~",
        ssrarrow: "\\quad \\rightarrow \\quad",
        stext: ["~~\\text{#1}~~", 1],
        sstext: ["\\quad\\text{#1}\\quad", 1],
%%%% Funzioni, derivate %%%%
        Dom: "\\mathcal{D}",
        ID: "\\mathrm{I.D.}",
        Cod: "\\mathcal{C}",
        II: "\\mathrm{I.I.}",
        CE: "\\mathrm{C.E.}",
        IS: "\\mathrm{I.S.}",
        dd: "\\mathrm{d}",
        dx: "\\mathrm{d}x",
        Deriv: ["\\mathit{D}\\quadra{#1}", 1],
%         effestar: "{}^*\\hspace{-.15em}f",
        fstar: ["{}^*\\hspace{-.15em}#1", 1],
%%%% Funzioni circolari %%%%
        sen: "\\sin",
        tg: "\\tan",
        Log: "\\mathrm{Log}",
%%%% Iperreali %%%%
        ost: "\\mathrm{st}",
        st: ["\\ost \\tonda{#1}", 1], 
        omon: "\\mathrm{mon}",
        mon: ["\\omon \\tonda{#1}", 1],
        oGal: "\\mathrm{Gal}",
        Gal: ["\\oGal \\tonda{#1}", 1],
        infvic: "\\approx",
        indist: "\\sim",
%%%% Insiemi e numeri %%%%
        Kor: "\\mathbf{K}",
        Rel: "\\mathfrak{R}",
        divint: "\\;\\mathrm{div}\\;",
        Mod: "\\;\\mathrm{mod}\\;",
        mcd: "\\mathrm{MCD}",
        mcm: "\\mathrm{mcm}",
        card: "\\mathrm{card}",
        Area: "\\mathrm{Area}",
%%%% Statistica %%%%
        vari: "\\mathrm{Var}",
        cfvar: "\\mathrm{CV}",
        cvar: "\\mathrm{CVar}",
        spV: "\\mathbf{V}",
        media: "\\mathrm{media}",
        mediana: "\\mathrm{mediana}",
        moda: "\\mathrm{moda}",
%%%% Unità di misura %%%%
        cels: "{}^\\circ\\hspace{-.10em}\\mathrm{C}",
        grado: "{}^{\\circ}",
        meuro: "\\, \\text{€}",
        munit: ["\\, \\mathrm{#1}", 1],
%%%% Varie %%%%
        qed: "q.e.d.",
        Ast: "{}^{\\ast}",
        aC: "a.C.",
        dC: "d.C.",
        aev: "a.C.",
        paev: "d.C.",
        unit: "\\,",
        relax: "",
      } 
    } 
  } 
} 
//}}}
\catcode`\#=6 

\else

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% code for MathML            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fi

\begin{document} 
\EndPreamble

Thank you anyway for your work and the great expertise you make available to those who need to convert LaTeX to html.

michal-h21 commented 10 months ago

The missing char-def warning can be fixed by installing ConTeXt.

Regarding the DOM error, do you experience it on this sample file? I can compile it without any errors with your configuration file.

danielezambelli commented 10 months ago

The missing char-def warning can be fixed by installing ConTeXt.

This works, thank you.

Regarding the DOM error, do you experience it on this sample file? I can compile it without any errors with your configuration file.

Here I give an example, not quite minimal:

%--8<-------------------------------------
\documentclass[10pt,a4paper]{memoir}
\RequirePackage[italian]{babel}

\RequirePackage[inline]{enumitem} % elenchi
\RequirePackage{amsmath, amssymb, amsthm}% amsfonts è caricato da amssymb
\RequirePackage[most]{tcolorbox}% per i box colorati

\newcommand{\colormd}{Mahogany}
\newcommand{\colortcblist}{BlueGreen}
\newcommand{\coloross}{violet}
\newcommand{\coloresem}{yellow}
\newcommand{\colorproc}{teal}
\newcommand{\colordef}{blue}
\newcommand{\colortheo}{green}
\newcommand{\colorproof}{orange}
\newcommand{\colortit}{green}

\newtheorem{esercizio}{\color{Sepia}}[chapter]

\DeclareTCBListing{latexlistingbox}{ s O{} m }{%
breakable,
colback = \colortcblist!5!white,
colframe = \colortcblist!75!black,
fonttitle = \bfseries,
IfBooleanTF = {#1}{}{listing side text},
title={#3},#2}

\theoremstyle{plain}
\tcbset{
ossstyle/.style={fonttitle=\bfseries\upshape, fontupper=\slshape,
arc=0mm, colback=\coloross!5!white, colframe=\coloross!50!black,
theorem style=plain, coltitle=\coloross!30!black},
procstyle/.style={fonttitle=\bfseries\upshape, fontupper=\slshape,
arc=0mm, colback=\colorproc!5!white, colframe=\colorproc!50!black,
theorem style=plain, coltitle=\colortit!30!black},
defstyle/.style={fonttitle=\bfseries\upshape, fontupper=\slshape,
colback=\colordef!5!white, colframe=\colordef!50!black,
theorem style=plain, coltitle=\colortit!30!black},
poststyle/.style={fonttitle=\bfseries\upshape, fontupper=\slshape,
colback=\colortheo!10!white, colframe=\colortheo!75!black,
theorem style=plain, coltitle=\colortit!30!black},
theostyle/.style={fonttitle=\bfseries\upshape, fontupper=\slshape,
colback=\colortheo!5!white, colframe=\colortheo!50!black,
theorem style=plain, coltitle=\colortit!30!black},
esemstyle/.style={
fonttitle=\bfseries\upshape, fontupper=\slshape,
enhanced jigsaw, breakable,
arc=0mm, colback=\coloresem!5!white, colframe=\coloresem!50!black,
theorem style=plain, coltitle=\coloresem!30!black}
}

\tcolorboxenvironment{proof}{% `proof' from `amsthm'
blanker, breakable, left=5mm, oversize,
before skip=10pt, after skip=10pt,
borderline west={1mm}{0pt}{\colorproof!60!black!20!white}}

\newenvironment{dimostrazione}{%
  \begin{proof}[Dimostrazione]%
}{%
  \end{proof}%
}

\newenvironment{soluzione}{%
  \begin{proof}[Soluzione]%
}{%
  \end{proof}%
}

\newtcbtheorem[number within=chapter]{osservazione}{Osservazione}
              {ossstyle}{oss}

\newtcbtheorem[use counter from=osservazione]{osservazioni}{Osservazioni}
              {ossstyle}{oss}

\newtcbtheorem[number within=chapter]{esempio}{Esempio}
              {esemstyle}{esem}

\newtcbtheorem[use counter from=esempio]{esempi}{Esempi}
              {esemstyle}{esem}

\newtcbtheorem[use counter from=esempio]{problema}{Problema}
              {esemstyle}{prob}

\newtcbtheorem[number within=chapter]{procedura}{Procedura}
              {procstyle}{proc}

\newtcbtheorem[number within=chapter]{definizione}{Definizione}
              {defstyle}{def}

\newtcbtheorem[number within=chapter]{postulato}{Postulato}
              {poststyle}{post}

\newtcbtheorem[number within=chapter]{teorema}{Teorema}
              {theostyle}{th}

\newtcbtheorem[use counter from=teorema]{lemma}{Lemma}
              {theostyle}{th}

\newtcbtheorem[use counter from=teorema]{corollario}{Corollario}
              {theostyle}{th}

\begin{document}

\chapter{Numeri naturali}

\section{Confronto tra numeri naturali}
\label{sec:nat_confronto}

\begin{osservazione}{Principio di tricotomia}{}
Dati due numeri naturali \(n\) e \(m\) vale sempre una delle seguenti tre 
relazioni: 

\vspace{-1em}
\[\quad n < m,\quad n = m, \quad n > m\]
\end{osservazione}

\begin{esempio}{Principio di tricotomia}{}
Dati due numeri naturali \(n\) e \(m\) vale sempre una delle seguenti tre 
relazioni: 

\vspace{-1em}
\[\quad n < m,\quad n = m, \quad n > m\]
\end{esempio}

\begin{problema}{Principio di tricotomia}{}
Dati due numeri naturali \(n\) e \(m\) vale sempre una delle seguenti tre 
relazioni: 

\vspace{-1em}
\[\quad n < m,\quad n = m, \quad n > m\]
\end{problema}

\begin{procedura}{Principio di tricotomia}{}
Dati due numeri naturali \(n\) e \(m\) vale sempre una delle seguenti tre 
relazioni: 

\vspace{-1em}
\[\quad n < m,\quad n = m, \quad n > m\]
\end{procedura}

\begin{postulato}{Principio di tricotomia}{}
Dati due numeri naturali \(n\) e \(m\) vale sempre una delle seguenti tre 
relazioni: 

\vspace{-1em}
\[\quad n < m,\quad n = m, \quad n > m\]
\end{postulato}

\begin{teorema}{Principio di tricotomia}{}
Dati due numeri naturali \(n\) e \(m\) vale sempre una delle seguenti tre 
relazioni: 

\vspace{-1em}
\[\quad n < m,\quad n = m, \quad n > m\]
\end{teorema}

\end{document}
%--8<-------------------------------------

The warning:

[WARNING] domfilter: .../texlive/texmf-dist/tex/luatex/luaxml/luaxml-mod-xml.lua:175: Unbalanced Tag (/p) [char=4871]

Appears only once even if there are multiple calls.

Thank you for your helpfulness.

michal-h21 commented 10 months ago

There seems to be two issues. First is that the wrong Pgf driver for SVG is used, which leads to some non-HTML tags in the document, second is that one of the boxes isn't started correctly, so it gets no frame.

The first issue can be fixed by adding this line to your TeX file, before \usepackage{tcolorbox}:

 \def\pgfsysdriver{pgfsys-dvisvgm4ht.def}%

The second can be fixed using this version of tcolorbox.4ht:

% tcolorbox.4ht (2023-10-20-09:23), generated from tex4ht-4ht.tex
% Copyright 2020-2023 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2023-10-20-09:23}

% use custom counter that increments for every \tcolorbox
\newcounter{:tcbcolcount}

\def\:tempa{%
  \stepcounter{:tcbcolcount}%
  % save text and background colors for use in CSS
  \get:xcolorcss{tcbcolbacktitle}\:tcbcolbacktitle%
  \get:xcolorcss{tcbcoltitle}\:tcbcoltitle%
  \get:xcolorcss{tcbcolback}\:tcbcolback%
  \get:xcolorcss{tcbcolframe}\:tcbcolframe%
  \get:xcolorcss{tcbcolupper}\:tcbcolupper%
  % make unique ID for this box
  \gdef\:tcbcolid{tcolobox-\arabic{:tcbcolcount}}
  % Open box
  \a:tcolorbox%
  % set label if it exists
  \ifdefined\tcolorbox:label:key%
    \let\@currentlabel\tcolorbox:currentlabel% at this moment, \@currentlabel has wrong value
    \o:tcb@set@label:{\tcolorbox:label:key}%
    \AnchorLabel% save cross-ref destination
    \global\let\tcolorbox:label:key\undefined%
  \fi%
  % open title
  \b:tcolorbox%
  \kvtcb@before@title\kvtcb@title\kvtcb@after@title%
  % close title and open main box
  \c:tcolorbox%
  \box\tcb@upperbox%
  % the paragraph opened in the upper box can be unclosed
  \RecallEndP
  % deal with lower box, if it is set
  \iftcb@hasLower%
    \a:tcolorlowerbox%
    \box\tcb@lowerbox%
    \b:tcolorlowerbox%
  \fi%
  % We need to close box in \tcb@endboxanddraw
}

\HLet\tcb@drawcolorbox\:tempa
% overwrite other versions of box drawing macros
\HLet\tcb@drawcolorbox@standalone\:tempa
\HLet\tcb@drawcolorbox@breakable\:tempa

% save the state of paragraph before opening the content box
\pend:def\tcb@set@@upper@and@lower{\SaveEndP}

% we need to close tcolorbox environment here,
% in the box. otherwise, last paragraph end
% would be ignored and we would get invalid XML
\def\:tempb{\d:tcolorbox\o:tcb@endboxanddraw:}
\HLet\tcb@endboxanddraw\:tempb

% tcolorbox supports libraries, but it loads them
% in a way that doesn't register them for the use
% with .4ht files.
% this fix is for tcblistingscore.code.tex
\NewConfigure{tcblisting}{1}
\def\:tempb{\o:endtcblisting:\d:tcolorbox\a:tcblisting}
\HLet\endtcblisting\:tempb

% this code prevents emptying of the box title when
% some Tcolorbox options are used
\def\:tempb{}
\HLet\tcb@detach@title@code\:tempb

% require end of paragraph before Tcolorbox
\long\def\:tempb[#1]{\EndP\o:tcb@@icolorbox:[#1]}
\HLet\tcb@@icolorbox\:tempb

\NewConfigure{tcolorbox}{4}
\NewConfigure{tcolorlowerbox}{2}

% we need to save current label for a later use
\def\:tempa#1{%
  \xdef\tcolorbox:label:key{#1}%
  \global\let\tcolorbox:currentlabel\@currentlabel%
}
\HLet\tcb@set@label\:tempa

\pend:def\tcb@minipage{\SaveEndP}
\pend:def\tcb@minipage@top{\SaveEndP}
\pend:def\tcb@minipage@bottom{\SaveEndP}
\pend:def\tcb@minipage@center{\SaveEndP}

\AfterEndPreamble{%
  % fix \nameref support
  \def\:tempa#1{%
    \gdef\NR:Title{\a:newlabel{#1}}%
    \o:tcb@gettitle:{#1}%
  }%
  \HLet\tcb@gettitle\:tempa
}

\Hinput{tcolorbox}
\endinput

I've added both of these fixes to TeX4ht sources, so you can also just wait few days and they should be included in TeX Live.

danielezambelli commented 10 months ago

I have made the two changes you propose, but I still get the same warning message (:-?).

michal-h21 commented 10 months ago

Ah, I see, I didn't use the exact same options as you. I can reproduce this when I use them. Try this version of tcolorbox.4ht:

% tcolorbox.4ht (2023-10-20-09:23), generated from tex4ht-4ht.tex
% Copyright 2020-2023 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2023-10-20-09:23}

% use custom counter that increments for every \tcolorbox
\newcounter{:tcbcolcount}

\def\:tempa{%
  \stepcounter{:tcbcolcount}%
  % save text and background colors for use in CSS
  \get:xcolorcss{tcbcolbacktitle}\:tcbcolbacktitle%
  \get:xcolorcss{tcbcoltitle}\:tcbcoltitle%
  \get:xcolorcss{tcbcolback}\:tcbcolback%
  \get:xcolorcss{tcbcolframe}\:tcbcolframe%
  \get:xcolorcss{tcbcolupper}\:tcbcolupper%
  % make unique ID for this box
  \gdef\:tcbcolid{tcolobox-\arabic{:tcbcolcount}}
  % Open box
  \a:tcolorbox%
  % set label if it exists
  \ifdefined\tcolorbox:label:key%
    \let\@currentlabel\tcolorbox:currentlabel% at this moment, \@currentlabel has wrong value
    \o:tcb@set@label:{\tcolorbox:label:key}%
    \AnchorLabel% save cross-ref destination
    \global\let\tcolorbox:label:key\undefined%
  \fi%
  % open title
  \b:tcolorbox%
  \kvtcb@before@title\kvtcb@title\kvtcb@after@title%
  % close title and open main box
  \c:tcolorbox%
  \box\tcb@upperbox%
  % the paragraph opened in the upper box can be unclosed
  % \RecallEndP
  % deal with lower box, if it is set
  \iftcb@hasLower%
    \a:tcolorlowerbox%
    \box\tcb@lowerbox%
    \b:tcolorlowerbox%
  \fi%
  % We need to close box in \tcb@endboxanddraw
}

\HLet\tcb@drawcolorbox\:tempa
% overwrite other versions of box drawing macros
\HLet\tcb@drawcolorbox@standalone\:tempa
\HLet\tcb@drawcolorbox@breakable\:tempa

% save the state of paragraph before opening the content box
\pend:def\tcb@set@@upper@and@lower{\SaveEndP}

% we need to close tcolorbox environment here,
% in the box. otherwise, last paragraph end
% would be ignored and we would get invalid XML
\def\:tempb{\d:tcolorbox\o:tcb@endboxanddraw:}
\HLet\tcb@endboxanddraw\:tempb

% tcolorbox supports libraries, but it loads them
% in a way that doesn't register them for the use
% with .4ht files.
% this fix is for tcblistingscore.code.tex
\NewConfigure{tcblisting}{1}
\def\:tempb{\o:endtcblisting:\d:tcolorbox\a:tcblisting}
\HLet\endtcblisting\:tempb

% this code prevents emptying of the box title when
% some Tcolorbox options are used
\def\:tempb{}
\HLet\tcb@detach@title@code\:tempb

% require end of paragraph before Tcolorbox
\long\def\:tempb[#1]{\EndP\o:tcb@@icolorbox:[#1]}
\HLet\tcb@@icolorbox\:tempb

\NewConfigure{tcolorbox}{4}
\NewConfigure{tcolorlowerbox}{2}

% we need to save current label for a later use
\def\:tempa#1{%
  \xdef\tcolorbox:label:key{#1}%
  \global\let\tcolorbox:currentlabel\@currentlabel%
}
\HLet\tcb@set@label\:tempa

\pend:def\tcb@minipage{\SaveEndP}
\pend:def\tcb@minipage@top{\SaveEndP}
\pend:def\tcb@minipage@bottom{\SaveEndP}
\pend:def\tcb@minipage@center{\SaveEndP}

\AfterEndPreamble{%
  % fix \nameref support
  \def\:tempa#1{%
    \gdef\NR:Title{\a:newlabel{#1}}%
    \o:tcb@gettitle:{#1}%
  }%
  \HLet\tcb@gettitle\:tempa
}

\Hinput{tcolorbox}
\endinput