Oh, as a a more general response I can only reiterate what has been said already: Depending on your particular needs it might be better to start with some neutral input and generate output formats from there. There are plenty of options each with particular up- and downsides, e.g. markdown via pandoc, or asciidoc., or XML with XSLT. In the Racket ecosystem there's also scribble/pollen which looks quite interesting. I have never used that though. Denis
-----Ursprüngliche Nachricht----- Von: ntg-context
Im Auftrag von Denis Maier via ntg-context Gesendet: Freitag, 10. September 2021 17:35 An: ntg-context@ntg.nl Cc: Maier, Denis Christian (UB) ; hugo.fisher@gmail.com Betreff: Re: [NTG-context] LuaMetaTEX as LaTeX to XHTML/ePub transpiler? You may want to have a look at the lwarp package as an alternative to tex4ht.
Denis
-----Ursprüngliche Nachricht----- Von: ntg-context
Im Auftrag von Hugh Fisher via ntg-context Gesendet: Freitag, 10. September 2021 13:14 An: ntg-context@ntg.nl Cc: Hugh Fisher Betreff: [NTG-context] LuaMetaTEX as LaTeX to XHTML/ePub transpiler? I have documents in LaTeX, and would like to generate XHTML (ePub) output without going through an intermediate DVI or PDF step. Markup to markup, translating or transpiling rather than typesetting.
My use case is that I have two tabletop gaming books, 60 - 80 pages of text and diagrams, written for pdfLaTeX and now with XeLaTeX. I'm very happy with LaTeX and the wonderful PDF output for print.
But now I also want to create ePub/XHTML as well as print versions. So far I've tried tex4ebook and tex4ht and neither works for me. Firstly, some of the LaTeX commands are not recognised or causing errors.
And secondly, when I managed to get a small test section to work, the generated XHTML/HTML is very large, full of tiny <span>s. The problem seems to be that tex4ht runs TeX which typesets everything into DVI with every element carefully placed on a page, and then tex4ht tries to reverse that back into HTML. All this extra HTML will slow down / interfere with the ebook reader which is doing the final page layout at runtime on a particular device.
How I would like it to work is directly from LaTeX to HTML without any low level typesetting. If I have a LaTex source paragraph
This is some text with \textbf{some parts} in bold.
The <whatever>TEX will copy the source text to the destination. If there's a TeX command, here \textbf, it looks for a Lua function with that name and invokes it with whatever argument text is present. The Lua function emits <b>, then recursively processes the argument text, then emits </b>. Similarly there would be an implied lookup of \beginParagraph and \endParagraph which would emit <p> and </p>. Plain text just gets copied through unchanged.
So (finally) my question: is LuaMetaTEX what I'm looking for?
Yes is the answer I'm hoping for. And any guidance would be much appreciated.
No, but best starting point? I've never tried modifying TeX code itself, but I am an experienced and sometimes competent programmer. who has written a compiler parser and a high level code generator.
No and not a good idea to try?
Any other responses?
--
cheers, Hugh Fisher
________________________________________________________________
___________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net
________________________________________________________________
___________________
___________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ________________________________________________________________ ___________________