ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Hans Hagen <j.hagen@xs4all.nl>, Hugh Fisher <hugo.fisher@gmail.com>
Subject: Re: LuaMetaTEX as LaTeX to XHTML/ePub transpiler?
Date: Fri, 10 Sep 2021 13:47:46 +0200	[thread overview]
Message-ID: <12ab7d82-fcdf-0602-8588-82213bb44cee@xs4all.nl> (raw)
In-Reply-To: <CAAahdHPkX-K94aqBO_ETJYYHQNzhqM7LnNVXp_v2HMUPCUb9_g@mail.gmail.com>

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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

  parent reply	other threads:[~2021-09-10 11:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 11:13 Hugh Fisher via ntg-context
2021-09-10 11:26 ` Henning Hraban Ramm via ntg-context
2021-09-11 11:14   ` Hugh Fisher via ntg-context
2021-09-10 11:47 ` Hans Hagen via ntg-context [this message]
2021-09-11 11:19   ` Hugh Fisher via ntg-context
2021-09-11 12:00     ` Hans Hagen via ntg-context
2021-09-10 15:34 ` Denis Maier via ntg-context
2021-09-10 15:50   ` Denis Maier via ntg-context
2021-09-11 11:49   ` Hugh Fisher via ntg-context
2021-09-11 12:03     ` Hans Hagen via ntg-context

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12ab7d82-fcdf-0602-8588-82213bb44cee@xs4all.nl \
    --to=ntg-context@ntg.nl \
    --cc=hugo.fisher@gmail.com \
    --cc=j.hagen@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).