LaTeX.js icon indicating copy to clipboard operation
LaTeX.js copied to clipboard

Design and implement an AST

Open michael-brade opened this issue 7 years ago • 7 comments
trafficstars

Now that other projects start using this, it is about time to fix the one big limitation I should have thought about right from the start: the lack of an AST. It causes the following limitations:

  • \unskip is very hard to implement (and thus still missing)
  • conditionals cannot be implemented at all
  • loops and generally macros that are supposed to contribute TeX source cannot be implemented; an example would be LaTeX's native \and implementation - it ends the previous tabular environment and begins a new one - LaTeX.js cannot do that without an AST
  • and last, font handling is broken... my idea to wrap text directly with a span that sets the right font is nice but flawed: relative spaces (e.g. ems) that depend on the current font may thus depend on the wrong font. With an AST, this could be determined at the end and then done properly during the DOM creation

However, I have quite a few more macros that I want to implement and/or finish first, so if anyone wants to help, this would be it: the most helpful and significant contribution I can imagine right now.

michael-brade avatar Mar 27 '18 13:03 michael-brade

I am not familiar with AST but I found this issue by using the search, since I was looking for custom font support. I also found this repo, maybe it is useful?

jankapunkt avatar Sep 15 '18 20:09 jankapunkt

Wow, what an interesting repo! Thanks for finding it. I will take a look :)

michael-brade avatar Sep 15 '18 23:09 michael-brade

the node object in Luatex is related to this topic, see http://wiki.luatex.org/index.php/TeX_without_TeX

seuliang avatar May 20 '19 12:05 seuliang

This is very cool! Some immediate applications that come to mind are accessing the ecosystem of text processors implemented by unified.js and better version control of latex files with semantic merging.

kskyten avatar Jun 14 '19 18:06 kskyten

very cool indeed! So I could create last to join the family of mdast, hast, and nlcst :-) Gee, lots of work ahead....

michael-brade avatar Jun 14 '19 20:06 michael-brade

Hey, author of unified etc here! 👋 I’m very interested in connecting more syntaxes to unist/unified, so do feel free to ping me if there are questions, we can help out. Ideas for unified can be posted here: https://github.com/unifiedjs/ideas (and for syntax-tree here: https://github.com/syntax-tree/ideas).

For previous work, see rebber. It only does mdast/markdown -> latex though

wooorm avatar Jun 15 '19 10:06 wooorm

http://www-sop.inria.fr/marelle/tralics/
Tralics: a LaTeX to XML translator maybe help to build AST

seuliang avatar Jun 18 '19 13:06 seuliang