[tex4ht] Typesetting source code and pseudo-code

Jagath AR jagathar at gmail.com
Tue Jan 5 08:31:11 CET 2016


Hi George,
If you remove the option "mozilla" from the command line then the XML
syntax problem will be fixed and you can render it without any problem in
Firefox. There is some problem associated with the conversion to MathML
which need to be fixed when the "mozilla" option is used.

If you need to change the element "div" to "code", then use the following
tex4ht configuration in a separate cfg file or use the attached TeX file.

Change the command line to:
htlatex test.tex "xhtml,2,charset=utf-8" " -cmozhtf -utf8"  "-ccvalidate"

Regards
Jagath

On 5 January 2016 at 11:41, Hans Georg Schaathun <georg+tex at schaathun.net>
wrote:

> On Tue, Jan 05, 2016 at 10:19:17AM +0530, Jagath AR wrote:
> > Hi Hans,
> > Could you please send a minimal working example with the problem and the
> > command line used to generate the html file.
>
> Sure.  I attach a TeX file and the resulting XML file compiled using
>   htlatex test.tex "xhtml,2,mozilla,charset=utf-8" " -cmozhtf -utf8" \
>       "-cvalidate"
>
> As you can see, tex4ht uses a <div> tag where obviously a <code>
> tag should be used, and the XML is not syntactically correct,
> firefox reports that
>   XML Parsing Error: mismatched tag. Expected: </div>.
>   Location: file:///home/georg/tmp/test.xml
>   Line Number 37, Column 34:
>
>   class="cmmi-10x-x-109">A</span></mrow><mrow
>   ---------------------------------^
>
> (I should also have liked to make a verbatim-like environment which
> uses a <code> tag as the main (outermost) tag, but I do not have a
> minimal example since I do not know where to start defining it.)
>
> :-- George
>
> >
> > Jagath
> >
> > On 4 January 2016 at 22:08, Hans Georg Schaathun <
> georg+tex at schaathun.net>
> > wrote:
> >
> > > Hi,
> > >
> > > I am struggling to find a good way to typeset source code
> > > with tex4ht.  In my opinion the <code> tag should be used
> > > in HTML, for the benefit of screen readers and search engines
> > > which might need the semantics.
> > >
> > > I am used to using both lstlisting (listings package), verbatim,
> > > and code (texpower package).  Texpower does not seem to be supported
> > > by tex4ht at all.  verbatim is ok, except that I should like to
> > > reconfigure it to use the <code> tag.  lstlisting is brilliant for
> > > source code, except for the <code> tag.  For pseudo-code I also
> > > have the problem that tex4ht does not grok maths within lstlisting.
> > > It causes an unclosed tags.
> > >
> > > Has anyone found a way cleanly to produce <code> elements with tex4ht?
> > > All my attempts either produce an excess of tags which mess up
> > > the spacing, or they make tex strip linebreaks before it gets
> > > to tex4ht.  I do not understand all the low-level TeX code in the
> > > listings.4ht style, and I would really hope I don't have to ...
> > >
> > > Preferably, I should like to specify a custom class name for the
> > > purpose of CSS configuration, but it is obviously possible to tailor
> > > the CSS style to a non-custom class name if I have to.
> > >
> > > Secondly, is there a good fix to make tex4ht accept maths within
> > > lstlisting?
> > >
> > > Thanks a lot for any pointers,
> > > --
> > > :-- Hans Georg
> > >
>
> --
> :-- Hans Georg
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/tex4ht/attachments/20160105/1a65da7f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tex
Type: application/x-tex
Size: 859 bytes
Desc: not available
URL: <http://tug.org/pipermail/tex4ht/attachments/20160105/1a65da7f/attachment-0001.tex>


More information about the tex4ht mailing list