[tex4ht] Typesetting source code and pseudo-code

Hans Georg Schaathun georg+tex at schaathun.net
Mon Jan 4 17:38:38 CET 2016


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


More information about the tex4ht mailing list