Open dirichy opened 3 weeks ago
I think this isn't a bug
because this is latex math yes
but the $
signs are part of norg syntax
so it's correct that just everything inbetween is seen as latex
which makes it not being recognizes as math in latex
it's not something wanted but it's the correct behavior
I know $ is part of norg syntax, but it is also used in latex syntax. More exactly, the injection language is not latex, instead it’s latex_inline_math. In nvim-treesitter for markdown, they pass the $ to latex parser to specify the inner is latex_inline_math, not a normal latex file. The “$” is also part of markdown syntax, but they also pass it. So I think in norg, we can do it, too, to let some latex thing based on treesitter works in norg inline_math, too. Thank you!
I am making a plug for latex and all latex-injected language, and I want it work in norg, too.
well if latex_inline_math
is a separate parser then it shouldn't require a $
being present at the start
that's imo a flaw of the parser then
Since there is no separate parser for latex_inline_math, we need to pass $ to tell latex parser it’s inline_math in it. That’s how nvim-treesitter do for markdown. I know maybe it’s hacking, but it works. If you think I am wrong, you can just close this issue. maybe I well overwrite injections.scm in my plug. Thank you!
@dirichy how do you suggest we pass a $
when $|\alpha|$
is used? This would then parse as "the absolute value of alpha", right?
I tried remove the #offset! line and it works will, since “|” is named node in norg parser, it will not pass to latex parser.
BTW, if you really think the part of neorg syntax should not be passed, the offset number should be 2, not 1, since “|” is norg syntax, too, but now pass to latex parser.
Prerequisites
Neovim Version
NVIM v0.10.0 Build type: Release LuaJIT 2.1.1713484068 Run "nvim -V1 -v" for more info
Neorg setup
require(“neorg”).setup()
Actual behavior
I have some snip and conceal for latex only in mathmode. This code:
is not parsed as latex mathmode. I can’t use mathmodesnip and mathmode conceal in it.
Expected behavior
Change the injection.scm, remove the line contains “offset” in latex injection, then the “$”will pass to latex parser. So that we can know it’s in mathmode form latex parser.
Steps to reproduce
Put your cursor on “\alpha” and run this function(used in latex file to detect whether the cursor is in mathmode)
will return false, but it should return true.
Potentially conflicting plugins
No response
Other information
No response
Help
Yes
Implementation help
just remove the offset line in injection.scm for inline_math will work.