On Mon, Nov 04, 2019 at 02:27:38AM -0500, Steve Litt wrote: > I'm not sure, but I think if you write with a certain subset of TeX, it > would be fairly easy to write a program to convert it to XHTML5, from > which you can pretty easily create ePubs. Plain TeX as made by Knuth is > indeed simple for all simple things, and doable for more complicated > things. I do not think it's easy to define a subset of TeX and stick to it. I've used pandoc in the past to convert reasonably semantic LaTeX files to EPUB, and sticking to the right subset without accidentally using non supported commands was difficult at the time. Careful review of the produced EPUB was needed. Quite a nightmare. Thankfully, all of this ended the day I wasn't able anymore to compile pandoc and its hundred or so dependencies for OpenBSD :-)
Maybe there are better TeX to EPUB tools now - I haven't tried combining tex4ht with calibre for a long time, for example. Using a presentational format like dvi as intermediate representation is a sign that TeX is unsuitable as a common source, but it may work well enough nevertheless. Otherwise, if both LaTeX and EPUB outputs are needed, and fine-grained control of the produced EPUB is wanted, using a well-defined intermediate markup language seems the safest way to go. Oddly enough for me, markdown still appears to be the most common choice. I would have thought that its caracteristics - semantically poor, with irregular and no-warnings “every text file accepted” permissive kind of syntax - would have made it unsuitable for maintaining long works. Yon