Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3 Treesitter Engine #1020

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft

V3 Treesitter Engine #1020

wants to merge 14 commits into from

Conversation

vhyrro
Copy link
Member

@vhyrro vhyrro commented Aug 9, 2023

Would've been cooler if it were called the V8 engine but it's supposed to be the 3rd version of the parser so I can't just do that :p

It's finally here! The parser is so close to completion that I can already start migrating all of Neorg to the new engine. It's fast, it's much more reliable and it's 7.7x smaller than the previous iteration(s). And if it ever breaks, then it's simple to debug and actually consistent in when it errors in my experience. V1 would work for 90% of cases and then break super randomly in irreproducible environments.

Thanks to this we can also use treesitter as a source of truth for pandoc parsers or highlighting engines (looking at you, github) 👀

EDIT: It also now compiles natively on MacOS! Wohoo!!!

TODOs

There's a lot to do for this PR alone, and there's still some preliminary stuff. Here's the checklist:

  • Implement inline maths and inline macros parsing and make conflicts work as intended within TS.
  • Implement free-form attached modifiers in the parser. These are pretty hard, but they're about halfway there.
  • Test the parser in MacOS environments to see if it compiles natively without hacks.
  • Fix up some odd edge cases
  • Put it all in Neorg!

@c3n21
Copy link

c3n21 commented Aug 1, 2024

Hi! Just saw your PR and was wondering when this will be merged because I'm implementing a LaTeX concealer inside Neorg and with the new Neorg parser it seems that it should be simpler to query injected LaTeX nodes, am I right?

Because right now I need to create a new parser for each inline_math and fetch all the nodes so that I can conceal them

@boltlessengineer
Copy link
Contributor

Hi! Just saw your PR and was wondering when this will be merged because I'm implementing a LaTeX concealer inside Neorg and with the new Neorg parser it seems that it should be simpler to query injected LaTeX nodes, am I right?
Because right now I need to create a new parser for each inline_math and fetch all the nodes so that I can conceal them

To merge this PR, we have to complete the v3 parser first, and to do that, we should make a new spec because v1 spec currently has several issues to discuss.

@benlubas
Copy link
Contributor

benlubas commented Aug 2, 2024

I'm implementing a LaTeX concealer inside Neorg

I just want to make sure that you're aware of core.renderer.latex which conceals inline math with a rendered version of the latex.

Assuming that you know about that and you want to conceal like \epsilon into the actual symbol (and similar conceals). I'll say that we already inject the latex parser into math blocks, and inline math blocks are already query-able with the current parser. So I can't imagine that your implementation would be affected too heavily by the new parser. After all, language injections are defined as queries, not by the parser.

@c3n21
Copy link

c3n21 commented Aug 6, 2024

I'm implementing a LaTeX concealer inside Neorg

I just want to make sure that you're aware of core.renderer.latex which conceals inline math with a rendered version of the latex.

Assuming that you know about that and you want to conceal like \epsilon into the actual symbol (and similar conceals). I'll say that we already inject the latex parser into math blocks, and inline math blocks are already query-able with the current parser. So I can't imagine that your implementation would be affected too heavily by the new parser. After all, language injections are defined as queries, not by the parser.

Thanks for your comment, I'm already aware of that.

As a newbie of the matter I dig through the whole codebase.

But to achieve what I need to do (which is exactly what you said, concealing each command with the actual symbol) I also need to parse the Latex inside the inline_math node, am I right?

Only then I can effectively substitute each command node's text with the symbol

image

@max397574
Copy link
Contributor

max397574 commented Aug 6, 2024

But to achieve what I need to do (which is exactly what you said, concealing each command with the actual symbol) I also need to parse the Latex inside the inline_math node, am I right?

yes I think. But for that it doesn't matter which neorg parser is used I guess
This should already be doable with the current implementation and won't be easier with v3

@flexagoon
Copy link

As someone suggested in the Discord, since the V2 parser never really existed and was just a failed experiment, wouldn't it make sense to call this the V2 parser to make it match the version of the specification?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants