On 9/10/2021 1:13 PM, Hugh Fisher via ntg-context wrote:
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.
indeed, stay with what you're happy working with
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.
i suppose that you can define commands that somehow make your own commands export something; i have no experience with latex or tex4ht
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.
that's probbaly because there is not enough info in the dvi file ... maybe you can use xslt to sanitize the spans?
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.
so kind of interpreting
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.
i once played with this (context speak): \def\textbf#1{\type{<bf>}#1\type{</bf>}} so, you define all the commands that you use (normally a subset of what a macro package provides, you just ignore what doesn't make sense) then you define a very large page (say A1) that you use completely then you typeset the document in verbatim (nil headers and footers) the resulting pdf can then be converted to html with pdftotex or something like that so, basically, you just typeset the html
So (finally) my question: is LuaMetaTEX what I'm looking for?
in this area there is nothing in luametatex that luatex can't do
Yes is the answer I'm hoping for. And any guidance would be much appreciated.
as said, i don't know latex but context has an xml export option
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.
so, if your source uses a limited set of commands you can write a parser (in any language)
No and not a good idea to try?
Any other responses? you can consider coding your documents in xml and convert them to latex and html .. neutral input so to say
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------