@willbooster/tree-sitter-javascript 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/grammar.js CHANGED
@@ -573,12 +573,24 @@ module.exports = grammar({
573
573
  choice(
574
574
  seq(
575
575
  '"',
576
- repeat(choice(alias($.unescaped_double_jsx_string_fragment, $.string_fragment), $.html_character_reference)),
576
+ repeat(
577
+ choice(
578
+ alias($.unescaped_double_jsx_string_fragment, $.string_fragment),
579
+ $.html_character_reference,
580
+ alias($._jsx_string_ampersand, $.string_fragment)
581
+ )
582
+ ),
577
583
  '"'
578
584
  ),
579
585
  seq(
580
586
  "'",
581
- repeat(choice(alias($.unescaped_single_jsx_string_fragment, $.string_fragment), $.html_character_reference)),
587
+ repeat(
588
+ choice(
589
+ alias($.unescaped_single_jsx_string_fragment, $.string_fragment),
590
+ $.html_character_reference,
591
+ alias($._jsx_string_ampersand, $.string_fragment)
592
+ )
593
+ ),
582
594
  "'"
583
595
  )
584
596
  ),
@@ -587,10 +599,14 @@ module.exports = grammar({
587
599
  // We give names to the token() constructs containing a regexp
588
600
  // so as to obtain a node in the CST.
589
601
  //
590
- unescaped_double_jsx_string_fragment: () => token.immediate(prec(1, /([^"&]|&[^#A-Za-z])+/)),
602
+ unescaped_double_jsx_string_fragment: () => token.immediate(prec(1, /([^"&]|&[^#A-Za-z"&])+/)),
591
603
 
592
604
  // same here
593
- unescaped_single_jsx_string_fragment: () => token.immediate(prec(1, /([^'&]|&[^#A-Za-z])+/)),
605
+ unescaped_single_jsx_string_fragment: () => token.immediate(prec(1, /([^'&]|&[^#A-Za-z'&])+/)),
606
+
607
+ // An `&` that does not start a complete html_character_reference is a literal character, as in HTML. The lexer
608
+ // prefers the longer html_character_reference when one follows.
609
+ _jsx_string_ampersand: () => token.immediate(/&/),
594
610
 
595
611
  _jsx_attribute_value: ($) => choice(alias($._jsx_string, $.string), $.jsx_expression, $._jsx_element),
596
612
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -16,7 +16,7 @@
16
16
  }
17
17
  ],
18
18
  "metadata": {
19
- "version": "1.0.0",
19
+ "version": "1.0.1",
20
20
  "license": "MIT",
21
21
  "description": "JavaScript grammar for tree-sitter",
22
22
  "authors": [