Sfoglia il codice sorgente

Merge pull request #13664 from overleaf/mj-bibtex-match-brackets

Add bibtex match brackets highlighting

GitOrigin-RevId: d0ed07d9874f097dd8b59eff582eb23a59f46332
Alf Eaton 3 anni fa
parent
commit
e41bda3e61

+ 8 - 10
services/web/frontend/js/features/source-editor/lezer-bibtex/bibtex.grammar

@@ -1,5 +1,3 @@
-
-
 @top Bibliography {
 @top Bibliography {
   (Declaration | StringDeclaration)*
   (Declaration | StringDeclaration)*
 }
 }
@@ -15,7 +13,9 @@
   EntryTypeName { $[a-zA-Z]+ }
   EntryTypeName { $[a-zA-Z]+ }
   Number { @digit+ }
   Number { @digit+ }
   StringKeyword {"@"$[Ss]$[Tt]$[Rr]$[Ii]$[Nn]$[Gg]}
   StringKeyword {"@"$[Ss]$[Tt]$[Rr]$[Ii]$[Nn]$[Gg]}
-  "@" "{" "}" "\"" "," "#" "@string"
+  "{"[closedBy="}"]
+  "}"[openedBy="{"]
+  "@" "\"" "," "#" "@string"
   Comment { "%" ![\n]* }
   Comment { "%" ![\n]* }
 }
 }
 
 
@@ -51,8 +51,8 @@ Expression {
 }
 }
 
 
 @local tokens {
 @local tokens {
-  openBracedContents {"{"}
-  closeBracedContents {"}"}
+  OpenBracedContents[closedBy="}", @name="{"] {"{"}
+  CloseBracedContents[openedBy="{", @name="}"] {"}"}
   @else nonClosingBracedContents
   @else nonClosingBracedContents
 }
 }
 
 
@@ -61,19 +61,17 @@ Expression {
   (
   (
       nonClosingBracedContents |
       nonClosingBracedContents |
       nestedBracedString {
       nestedBracedString {
-        openBracedContents 
+        OpenBracedContents
         bracedStringContents
         bracedStringContents
-        closeBracedContents
+        CloseBracedContents
       }
       }
     )*
     )*
 }
 }
   BracedString {
   BracedString {
-    "{"
-    bracedStringContents closeBracedContents
+    "{" bracedStringContents CloseBracedContents
   }  
   }  
 }
 }
 
 
-// TODO: Implement this
 @precedence { concatenation @left }
 @precedence { concatenation @left }
 
 
 StringConcatenation {
 StringConcatenation {