Selvakumar has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I need to convert Latex to XML using perl module. Can anyone please suggest how we can do and if anybody tried with this i need some rough idea about how much percentage we will get accuracy and if any other details i will get it would be greatful for me.

Replies are listed 'Best First'.
Re: Latex to XML
by Ea (Chaplain) on Jan 25, 2012 at 11:53 UTC
    I've been using LaTeXML (which is second result from a web search on LaTeX to XML) and it works for my purposes. It takes particular care of handling equations and has hooks for writing your own handlers for unusual style files.

    perl -e 'print qq(Just another Perl Hacker\n)' # where's the irony switch?
      Hi, I want to convert tex file content to xml format. I tried to install latexml but not even able to install prerequisites modules. Please guide. thanks

        I would start by installing the prerequisites.

        Hmmm ... if you're struggling to install standard modules, you'd best go to the basic documentation on How to install CPAN modules and use that to help you install the prerequisits It assumes that you have these 2 xml libraries on your system, libxml2 and libxslt. These libraries are not perl. You will need to install them if they are not already on your system.

        perl -e 'print qq(Just another Perl Hacker\n)' # where's the irony switch?
Re: Latex to XML
by Anonymous Monk on Jan 25, 2012 at 03:55 UTC
    http://www-sop.inria.fr/apics/tralics/# TRALICS : a LaTeX to XML translator
Re: Latex to XML
by LanX (Saint) on Jan 25, 2012 at 04:36 UTC
    Since TeX is an interpreted macro language and LaTeX a package on top of it I think a really accurate translation can only be done by a modified interpreter.

    I don't think it's reasonable to reimplement an interpreter in Perl.

    I'd rather try to modify the existing codebase to produce XML instead of DVI or PDF.

    But my insights into the detailed mechanisms of TeX and LaTeX are however limited...

    Cheers Rolf

Re: Latex to XML
by choroba (Cardinal) on Jan 25, 2012 at 09:10 UTC
    What kind of XML do you want? And why? Just adding <latex> at the beginnning and </latex> at the end plus escaping all <'s and &'s (and ]]>'s) creates a well-formed XML.