[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Idea to support math in HTML output
From: |
Oliver Heimlich |
Subject: |
Idea to support math in HTML output |
Date: |
Tue, 31 May 2016 00:01:14 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0 |
Hello,
I would like to do something about the missing support of the @math
macro in HTML output. It has always bugged me that this macro does
nothing for non-PDF output, since the TeX-syntax math is pretty useless
for many readers of the final document. So, it would be better to have
@math support for PDF and HTML at least.
The basic idea is to use the @math macro with TeX's math syntax and
produce HTML with MathML from that. Thus, the user can have the same
Texinfo input for both PDF and HTML output.
Some details that I have figured out already:
1. MathML is part of HTML5. To make use of it, the doctype has to be
changed to <!DOCTYPE html>. For legacy browser support, it is possible
to use <!DOCTYPE html SYSTEM "about:legacy-compat">. The “acronym” tag
is no longer allowed in HTML5, thus the @acronym macro has to be changed
(use “abbr” tag instead). I am not aware of other issues with changing
to HTML5.
2. There is a perl module that could possibly be used in texi2any for
the conversion from TeX math code into MathML: LaTeXML [1]. It is
distributed under public domain / CC0. It seems to produce good results
as can be seen in the Digital Library of Mathematical Functions [2], and
should more than suffice for inline math expressions that the @math
macro is used for at the moment.
3. The only browsers with significant market share which have MathML
support at the moment are based on the Gecko engine (Firefox and
derivatives) [3]. For other browsers it is possible to simulate MathML
support with a Javascript application MathJax (free software, Apache 2.0
license). There is a minimal MML_HTMLorMML configuration [4] which could
be used for that purpose (you have to add only a few lines of script
into the HTML, the application is loaded from a CDN). There could be a
new texi2any option for HTML output (or a customization variable):
--math=verbatim (default, current behavior), --math=mathml (convert math
in TeX syntax into MathML), --math=mathjax (convert math in TeX syntax
into MathML and use MathJax to support more browsers with Javascript).
4. There seems to be support for latex2html in Texinfo (L2H…
customization variables), although this is well hidden in the manual. I
can't get it to work on my system (don't know why) and as far as I
understand, it would render the math as images (png), which I don't find
very useful nowadays.
5. A potential follow-up target would be to use some MathML-to-text
converter and extend @math support to info and plaintext output formats,
e. g., with AsciiMath, which is better to read than the TeX math code. [5]
Some outstanding issues:
- I am unfamiliar with perl and have to learn it. Also I have to get
familiar with Texinfo hacking, since I am only a Texinfo user at the
moment. Shouldn't be problems.
- I have to find a way to bundle / integrate / use the other perl module
LaTeXML into Texinfo.
- Prototyping / testing the perl module LaTeXML.
- How should I contribute code? Would you prefer a patch file?
Looking forward to hear your comments and suggestions on this idea.
Best
Oliver
[1] http://dlmf.nist.gov/LaTeXML/
[2] e. g. http://dlmf.nist.gov/4.12
[3] http://caniuse.com/#feat=mathml
[4]
http://docs.mathjax.org/en/latest/config-files.html#the-mml-htmlormml-configuration-file
[5] http://asciimath.org/
- Idea to support math in HTML output,
Oliver Heimlich <=