8

I know there are a lot of threads on existing Tex-HTML converters already, but I have a question about the feasibility of creating one.

Existing tools use other scripting languages to parse raw TeX and output HTML.

Would it be a better idea to write a package for TeX that overrides commands and outputs content to a HTML file?

For instance overriding \section to write a <h1>{content}</h1> tag to another file.

Is this feasible? I'm sure everyone knows more about TeX than me so I'd like to hear your thoughts.

Caramdir
  • 89,023
  • 26
  • 255
  • 291
Alex
  • 83
  • 4
    You might be interested in this blog post: http://tex.blogoverflow.com/2011/07/getting-latex-on-to-the-web/ – Caramdir Dec 13 '11 at 02:47
  • 1
    In ConTeXt, this can be achieved by adding \setupbackend[export=yes,xhtml=yes] at the top of your file. – Aditya Dec 13 '11 at 06:57
  • 5
    This is more-or-less what TeX4ht does. Could you explain what the issue is with that approach? – Joseph Wright Dec 13 '11 at 07:37
  • Caramdir > Looks interesting, but there's no code there and I was looking for HTML not plain text. I wanted to preserve tables, figures etc. – Alex Dec 14 '11 at 00:55
  • Only indirectly related on how to convert a markdown syntax into LaTeX: https://tex.stackexchange.com/questions/236439/use-markdown-style-formatting-for-bold-and-italic – Steven B. Segletes Aug 18 '18 at 19:22

1 Answers1

3

(This is as much an answer to get this off the "unanswered" list as anything else.)

This is feasible. I've started writing such a package and have used it successfully for many projects: all of my blog posts on the TeX-SX blog were written in LaTeX and I now write my major contributions to the nLab in LaTeX, including converting an article that wasn't written specifically for use with my package.

I do intend releasing the code soon (to reply to your comment on the blog post). There's a few things I'd like to get right before releasing an alpha release (I keep changing my mind on how to deal with certain things that either need a slick catcode change or a more heavy duty macro). Keep hassling me and I might just get round to it! There is an early version available at https://github.com/loopspace/latex-to-internet but it has changed a lot since then.

To comment on your comment to Caramdir: the export is not plain text but is usually some variant of Markdown; also, if you notice, several of my blog posts have pictures. Those were done in TikZ and exported to PNG via my package. So there is rudimentary support for pictures.

(I'd also like to say that this package would not have been possible without this site. Many of the issues I encountered were solved thanks to people here.)

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751