asciidoctor / asciimath

Asciimath parser
MIT License
24 stars 18 forks source link

LaTeX output support #16

Closed GarkGarcia closed 4 years ago

GarkGarcia commented 4 years ago

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 and asciidoctor-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.

pepijnve commented 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.

GarkGarcia commented 4 years ago

Fixed in 946ff0a.

GarkGarcia commented 4 years ago

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.

pepijnve commented 4 years ago

That's great news!