2

When compiling the following document with htlatex test.tex "xhtml,mathml" the generated HTML document contains an unencoded < in the alt attribute of the image which is not XML standard-compliant.

What can I add to the configuration file to make htlatex correctly encode < as &lt; in the alt attributes?

\documentclass[12pt]{article}
\usepackage{pst-all}
\begin{document}
$\begin{pspicture}(0.8,1)
\psgrid(1,1)\end{pspicture}$
\end{document}

The body of the generated html document is (with a bit of formatting):

<p class="noindent" >
 <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline" >
  <img src="test0x.png" alt="<mi>P</mi><mi>I</mi><mi>C</mi>" class="pspicture" />
 </math>
</p>
1
  • @DavidCarlisle it is generating mathml, but the pspicture inside math is generating image. The PIC alt text is then converted to mathml.
    – michal.h21
    Commented Mar 5, 2017 at 13:15

1 Answer 1

2

Default alt text, PIC, is produced when pspicture is converted to image. Because you use it inside math, this alt text is treated as math text and each character is surrounded by <mi> element. We have two options - to put the alt text inside \HCode command, which will block the processing the text to mathml, or to remove it completely.

There is a special configuration for pspicture alt text, pspictureAlt. You can try the following configuration file:

\Preamble{xhtml,mathml}

\Configure{pspictureAlt}{\HCode{pspicture figure}}
\begin{document}
\EndPreamble

I noticed also another issue when I compiled your code: the pstricks to png failed with errors. I tried dvipng and dvips -> ghostscript. Only dvisvgm seems to work. If you use updated TL 2016 distribution, you can request dvisvgm compilation if you add the following line the the configuration file:

\Configure{Picture}{.svg}

You can compile your document using:

make4ht -um draft -c configfilename.cfg test.tex

And this is the result:

<!--l. 4--><p class="noindent" ><!--l. 4--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><!--width="22.76227pt" height="28.45274pt"--><img 
src="sample0x.svg" alt="pspicture figure" class="pspicture" /></math>
</p> 

enter image description here

0

You must log in to answer this question.

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