Closed GarkGarcia closed 4 years ago
Thanks for the suggestion. Definitely sounds like a good idea.
Regarding the AST... it's kind of messy. This started out as a quick and dirty implementation, very loosely inspired by the JS implementation. As a consequence the AST consists of kind of ad hoc Hashes and Arrays. Your best source of information at the moment is the code.
Note that I've been working on filling in functional gaps compared to the JS implementation. That work is not 100% complete yet so you may run into differences in output or unsupported functionality in the parser.
Fixed in 946ff0a.
For reference, AciiMath support has been implemented in asciidoctor/asciidoctor-mathematical
(https://github.com/asciidoctor/asciidoctor-mathematical/commit/d82041ddce64ea6014f3f3d613f3d5e6c4d257d3)!
asciidocto-mathematical
now uses asciimath
to transpile AsciiMath blocks to LaTeX and then render them to PNG/SVG.
That's great news!
The title of this issue is a bit misleading 😁️. Parsing LaTeX is definitively out of scope. However, I believe we should consider LaTeX as an output format. In other words, maybe we should implement a
LatexBuilder
class.Besides making the library more useful for other projects, that would allow
asciidoctor-latex
andasciidoctor-mathematical
to transpile asciimath blocks to LaTeX, bringing asciimath support to the LaTeX and PDF backends.Looking at the official asciimath grammar specification, it's clear that asciimath could be unambiguously traspiled to LaTeX.
I'm available to work on this, but I don't quite understand how the parsed asciimath AST looks like. If you guys could help me on that, I'd be glad to contribute to the project.