Fix parsing wrong superscripts like 10^10 (#132)

pull/813/head
Patrick Förster 2024-06-22 09:50:44 +07:00 committed by GitHub
parent cd82eb40d3
commit 6b572f0f70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 10 deletions

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add missing citation commands: `\citeA`, `\citeR`, `\citeS`, `\citeyearR` ([#94](https://github.com/latex-lsp/tree-sitter-latex/issues/94))
- Let `\declaretheorem` accept multiple environment names ([texlab/#1075](https://github.com/latex-lsp/texlab/issues/1075))
- Fix parsing wrong superscripts like `10^10` ([#107](https://github.com/latex-lsp/tree-sitter-latex/issues/107))
## [0.4.0] - 2024-04-01

@ -393,16 +393,18 @@ module.exports = grammar({
operator: $ => choice('+', '-', '*', '/', '<', '>', '!', '|', ':', "'"),
letter: $ => /[^\\%\{\}\$\#_\^]/,
subscript: $ =>
seq(
'_',
field('subscript', choice($.curly_group, $.word, $.generic_command)),
field('subscript', choice($.curly_group, $.letter, $.command_name)),
),
superscript: $ =>
seq(
'^',
field('superscript', choice($.curly_group, $.word, $.generic_command)),
field('superscript', choice($.curly_group, $.letter, $.command_name)),
),
//--- Key / Value

@ -481,11 +481,11 @@ Let
(text
(word)
(superscript
(word))
(letter))
(operator)
(word)
(superscript
(word)))
(letter)))
(text_mode
(curly_group
(text
@ -497,11 +497,12 @@ Let
(text
(word)
(superscript
(word))
(letter))
(operator)
(word)
(superscript
(word)))
(letter))
(word))
(end
(curly_group_text
(text
@ -756,6 +757,21 @@ r \big|_0^a
(command_name))
(operator)
(subscript
(word))
(letter))
(superscript
(word))))
(letter))))
================================================================================
tree-sitter-latex (Issue #107) | subscript
================================================================================
10^10
--------------------------------------------------------------------------------
(source_file
(text
(word)
(superscript
(letter))
(word)))

@ -220,6 +220,6 @@ Foo_{bar}^2
(subscript
(curly_group
(text
(word))))
(word))))
(superscript
(word))))
(letter))))