Re: [NTG-context] LuaMetaTEX as LaTeX to XHTML/ePub transpiler?

2021-09-11 Thread Hugh Fisher via ntg-context
Collating several suggestions into one:

On Fri, 10 Sept 2021 at 21:26, Henning Hraban Ramm  wrote:
> Did you try pandoc?

On Fri, 10 Sept 2021 at 21:47, Hans Hagen  wrote:
> you can consider coding your documents in xml and convert them to latex
> and html .. neutral input so to say

On Sat, 11 Sept 2021 at 01:07, T. Kurt Bond  wrote:
> You might also consider hevea (a LaTeX to HTML translator) and pandoc (which 
> bills itself as a universal document converter) and can convert into and out 
> of LaTeX.  I use pandoc a lot, although not for LaTeX to HTML translation.  
> Pandoc can output EPUB, BTW.

On Sat, 11 Sept 2021 at 01:34,  wrote:
> You may want to have a look at the lwarp package as an alternative to tex4ht.

Thanks T. Kurt Bond and Denis Maier for the suggestions. A better alternative
to tex4ht / tex4ebook would certainly be much easier for me, even if I'm still
somewhat offended by the intermediate steps.

As for xml or pandoc, I'd rather not because I want to keep print (PDF) as the
primary output, and I don't want to lose what TeX/LaTeX can do that most
markup languages can't.

From what I know of pandoc, it is like Sphinx in that the way it generates PDF
output is by translating pandoc into LaTeX/TeX, then running TeX! So instead
of my current toolchain where I write the LaTeX I want directly, I'd
be examining
the pandoc output and if it isn't what I want, poking at pandoc in the hope of
making things better.

It may be unfair, but my impression is that TeX and typesetting / layout systems
based on TeX can do more interesting things than say XML or Sphinx. Moving
to a more "universal" markup format might broaden my options, but I don't
want a lowest common denominator solution.

--

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
___


Re: [NTG-context] LuaMetaTEX as LaTeX to XHTML/ePub transpiler?

2021-09-11 Thread Hugh Fisher via ntg-context
On Fri, 10 Sept 2021 at 21:47, Hans Hagen  wrote:
>
[ munch ]

>
> in this area there is nothing in luametatex that luatex can't do

As in my earlier reply, I'm thinking about replacing Adobe Illustrator with
Metapost, and LuaMetaTEX seems to have better integration?

>
> so, if your source uses a limited set of commands you can write a parser
> (in any language)

This parser would need to understand TeX source files and conventions
such as % for comments, recognise commands starting with \ and with
arguments/parameters bracketed by [] and {}, and look up command names
that might be written in Lua, then call them.

Isn't that what LuaMetaTEX does? No, I haven't looked at the actual source
code yet, but starting with something that already does most of what you
want is always quicker than writing from scratch.


-- 

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
___


Re: [NTG-context] LuaMetaTEX as LaTeX to XHTML/ePub transpiler?

2021-09-11 Thread Hugh Fisher via ntg-context
On Fri, 10 Sept 2021 at 21:26, Henning Hraban Ramm  wrote:
>
> No.
>
> LuaMetaTeX is ConTeXt-only.
> You would need a LaTeX -> ConTeXt conversion, and there is none.
>

Well I am thinking about switching to ConTeX/LuaMetaTEX anyway, because at the
moment I draw vector art in the last non-subscription version of Adobe
Illustrator, now
approaching ten years old. I'll be trying out Metapost as a replacement.

My markup isn't that complicated, so at worst I could translate by
hand. But it occurs
to me that if I get this markup to markup text translation going, I'd
be able to write a
LaTeX -> ConTeXt converter as a set of LaTeX named Lua functions.

-- 

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
___


[NTG-context] LuaMetaTEX as LaTeX to XHTML/ePub transpiler?

2021-09-10 Thread Hugh Fisher via ntg-context
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 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 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 , then recursively processes the argument
text, then emits . Similarly there would be an implied lookup
of \beginParagraph and \endParagraph which would emit  and .
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
___