Эх сурвалжийг харах

Merge pull request #34373 from overleaf/td-latex-parser-relax-text-restriction

Allow ^ and _ in text nodes by default in LaTeX grammar

GitOrigin-RevId: 9e94d86f7a0540431eb28d29c0fa79a0ea889855
Tim Down 4 сар өмнө
parent
commit
db2fe61a20

+ 1 - 6
services/web/frontend/js/features/source-editor/lezer-latex/latex.grammar

@@ -143,7 +143,7 @@
     Whitespace { $[ \t]+ }
     Whitespace { $[ \t]+ }
     NewLine { "\n" }
     NewLine { "\n" }
     BlankLine { "\n" "\n"+ }
     BlankLine { "\n" "\n"+ }
-    Normal { ![\\{}\[\]$&~#^_% \t\n] ![\\{}\[\]$&~#^_%\t\n]* }  // everything is normal text, except these characters
+    Normal { ![\\{}\[\]$&~#% \t\n] ![\\{}\[\]$&~#%\t\n]* }  // everything is normal text, except these characters
     @precedence { CtrlSeq, CtrlSym, BlankLine, NewLine, Whitespace, Normal }
     @precedence { CtrlSeq, CtrlSym, BlankLine, NewLine, Whitespace, Normal }
 
 
     OpenBrace[closedBy=CloseBrace] { "{" }
     OpenBrace[closedBy=CloseBrace] { "{" }
@@ -528,7 +528,6 @@ LongArg {
     | Environment
     | Environment
     | BlankLine
     | BlankLine
     | "#" // macro character
     | "#" // macro character
-    | "_" | "^" // other math chars
     )*
     )*
 }
 }
 
 
@@ -540,7 +539,6 @@ ShortArg {
     ( textWithBrackets
     ( textWithBrackets
     | NonEmptyGroup<ShortArg>
     | NonEmptyGroup<ShortArg>
     | "#" // macro character
     | "#" // macro character
-    | "_" | "^" // other math chars
     )*
     )*
 }
 }
 
 
@@ -548,7 +546,6 @@ ShortOptionalArg {
     ( textBase
     ( textBase
     | NonEmptyGroup<ShortOptionalArg>
     | NonEmptyGroup<ShortOptionalArg>
     | "#" // macro character
     | "#" // macro character
-    | "_" // underscore is used in some parameter names
     )*
     )*
 }
 }
 
 
@@ -556,7 +553,6 @@ TikzPictureContent {  /// same as Text but with added allowed characters
     ( textWithEnvironmentsAndBlankLines
     ( textWithEnvironmentsAndBlankLines
     | NonEmptyGroup<TikzPictureContent>
     | NonEmptyGroup<TikzPictureContent>
     | "#" // macro character
     | "#" // macro character
-    | "_" | "^" // other math chars
     )+
     )+
 }
 }
 
 
@@ -581,7 +577,6 @@ DefinitionFragment {
     | "#" // macro character
     | "#" // macro character
     | Ampersand // for tables
     | Ampersand // for tables
     | Tilde // unbreakable space
     | Tilde // unbreakable space
-    | "_" | "^" // other math chars
     | SectioningCommand<
     | SectioningCommand<
         BookCtrlSeq |
         BookCtrlSeq |
         PartCtrlSeq |
         PartCtrlSeq |