[texhax] latex2html and listings package

Ivan Ivanov rambiusparkisanius at gmail.com
Wed Mar 9 13:37:16 CET 2005


Hello Ross,
thank you for the reply.
On Wed, 9 Mar 2005 10:40:20 +1100, Ross Moore <ross at ics.mq.edu.au> wrote:
> Hello Ivan,
> 
> No Perl coding has been written to support the commands defined
> in the listings package.
I am new to latex2html and listings, although I know Latex and Perl.
Could you point me to some sources of latex2html internals. I might be
able to implement the support for listings commands.

> 
> However, there is code to support  \verbatiminput  from the {verbatim}
> package.
> 
> So all you need to do is recast the expansion of \lstinputlisting
> to use \verbatiminput  when processing your document with LaTeX2HTML.
> 
> Do this by adding code to your document's preamble:
> 
> \usepackage{html}   %  *always* load this for LaTeX2HTML
> \begin{htmlonly}
>   \usepackage{verbatim}
>   \providecommand{\lstinputlisting}[2][]{\verbatiminput{#2}}
> \end{htmlonly}
This snippet really works and I was able to show my C sources in the
html output.

> 
> Alternatively ...
> 
>   ... it is also possible to write a little bit of Perl to achieve
> the same effect. This could be placed in your  .latex2html-init
> file, to be available for many documents.
Shall I add .latex2html-init file in my home directory or should I add
it somewhere else?

> 
> With a bit more effort, you could write a short .perl file
> and add it to your LaTeX2HTML installation.
> There is one already that could be used as a model:
> 
>     $LATEX2HTMLDIR/styles/verbatimfiles.perl
Ok, if I write something decent concerning listings, I will contribute it back.

> 
> Note that you need to catch the options [....] part,
> and discard this.
> 
> Even better would be to parse the options and devise
> more complicated Perl coding to create "pretty-printed"
> markup. However HTML is not good at doing this, while
> also respecting spaces/indents in a code listing,
> so it's probably not worth the effort.
> 
> Hope this helps,

Yes, your advice really helped me. Thank you very much for it.

Regards
Ivan Ivanov
> 
>         Ross Moore
>



More information about the texhax mailing list