[tex4ht] How to insert HTML code at any location in the generated HTML file?

Nasser M. Abbasi nma at 12000.org
Wed Jul 10 13:32:42 CEST 2013

On 7/10/2013 6:14 AM, Michal Hoftich wrote:
> Correct way is to not insert any HTML code to the document, but
> instead redefine ordinary LaTeX commands to insert html codes in .4ht
> files.
> If you really want to insert HTML code directly, you can define
> command which will eat arguments in normally LaTeX run and insert
> \HCode with tex4ht. Like this (untested, just an idea):
> \documentclass{article}
> \ifdefined\HCode
> \newcommand\html[1]{%
> \HCode{#1}%
> }%
> \else
> \newcommand\html[1]{}%
> \fi
> \begin{document}
> \html{<div class="hello>world</div>}
> \end{document}
> Regards,
> Michal

Thanks. I know the above. But it does not work for large
amount of code, it gives the error I posted.

As I mentioned, this is an old tex file, which contains large
amount of raw HTML code which was processed in latex2html.

I would not do that today, but that is how the tex file is and
I am trying to compile it with htlatex.

Using your example above, if I add just one extra line to
your example HTML code, it fails:


\html{<div class="hello>world</div>

test  %or any other HTML code

htlatex foo3.tex

Runaway argument?
{<div class="hello>world</div>
! Paragraph ended before \HCode was complete.
<to be read again>
l.13 }

The tex file has pages and pages of raw HTML code inserted in

  pages and pages of HTML code


is it possible to do something like the above in htlatex?


More information about the tex4ht mailing list