[tex4ht] Issues with unpaired brackets
William F Hammond
hammond at csc.albany.edu
Sat Apr 15 01:38:19 CEST 2017
Michal --
> In most cases it is probably mistake, but one can too
> often see various hacks in TeX sources which can work in
> PDF but explode when you want semantic output.
Yes.
> Some more realistic example is the following, coming from
> a real-world document:
>
> \documentclass{article}
> \usepackage{amsmath}
> \newcommand{\Bv}{\mathbf{B}}
> \begin{document}
> \begin{equation}
> \Bv = \frac{ \mu_0 m}{4 \pi \epsilon_0r^3}[3 \hat p \cdot \hat r) \hat
> r - \hat {p}].
> \end{equation}
> \end{document}
>
> I guess that there is missing left parenthesis between "["
> and "3".
Perhaps the author intended
\left[ 3 \hat p \cdot \hat r \right)
or, I think more likely, the author intended that the two
delimiters should match.
>> I find it impossible to make a rational decision on how
>> examples of this type should be handled by a translator.
>> Again I say, it would be better to trap nonsensical
>> source.
>
> These issues can be found in HTML validation. It is not
> that straightforward to go from mathml snippet back to TeX
> source, but probably only realistic way with tex4ht.
But these issues can be handled with LaTeX profile
validation, and it is straightforward to go from the XML
form of profiled LaTeX to the LaTeX source. Profile-level
validation should be done before running the source through
either pdflatex or htlatex since otherwise one risks
inconsistency between pdf and html outputs.
-- Bill
More information about the tex4ht
mailing list