mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #19072 from overleaf/mj-known-commands-reuse
[web] Parse known commands in math mode GitOrigin-RevId: e7937fc46320f13c716d1612eca36aa67c8fb967
This commit is contained in:
parent
283c972842
commit
46a160f127
2 changed files with 21 additions and 31 deletions
|
@ -219,7 +219,7 @@ OptionalMacroParameter {
|
|||
// The autocompletion code in services/web/frontend/js/features/source-editor/utils/tree-operations/commands.ts
|
||||
// depends on following the `KnownCommand { Command { CommandCtrlSeq [args] } }`
|
||||
// structure
|
||||
KnownCommand {
|
||||
KnownCommand<ArgumentType> {
|
||||
Title {
|
||||
TitleCtrlSeq optionalWhitespace? OptionalArgument? TextArgument
|
||||
} |
|
||||
|
@ -249,10 +249,10 @@ KnownCommand {
|
|||
PackageArgument
|
||||
} |
|
||||
TextColorCommand {
|
||||
TextColorCtrlSeq optionalWhitespace? ShortTextArgument optionalWhitespace? TextArgument
|
||||
TextColorCtrlSeq optionalWhitespace? ShortTextArgument optionalWhitespace? ArgumentType
|
||||
} |
|
||||
ColorBoxCommand {
|
||||
ColorBoxCtrlSeq optionalWhitespace? ShortTextArgument optionalWhitespace? TextArgument
|
||||
ColorBoxCtrlSeq optionalWhitespace? ShortTextArgument optionalWhitespace? ArgumentType
|
||||
} |
|
||||
HrefCommand {
|
||||
HrefCtrlSeq optionalWhitespace? UrlArgument ShortTextArgument
|
||||
|
@ -295,12 +295,6 @@ KnownCommand {
|
|||
Hbox {
|
||||
HboxCtrlSeq optionalWhitespace? TextArgument
|
||||
} |
|
||||
Left {
|
||||
LeftCtrlSeq optionalWhitespace?
|
||||
} |
|
||||
Right {
|
||||
RightCtrlSeq optionalWhitespace?
|
||||
} |
|
||||
NewCommand {
|
||||
NewCommandCtrlSeq optionalWhitespace?
|
||||
(Csname | OpenBrace LiteralArgContent CloseBrace)
|
||||
|
@ -350,20 +344,27 @@ KnownCommand {
|
|||
optionalWhitespace? SpanArgument { ShortTextArgument }
|
||||
optionalWhitespace? ColumnArgument { ShortTextArgument }
|
||||
optionalWhitespace? TabularArgument
|
||||
} |
|
||||
MathTextCommand {
|
||||
MathTextCtrlSeq optionalWhitespace? "*"? TextArgument
|
||||
}
|
||||
}
|
||||
|
||||
UnknownCommand {
|
||||
(CtrlSeq !argument Whitespace (OptionalArgument | TextArgument)+)
|
||||
| ((CtrlSeq | MathTextCtrlSeq) (OptionalArgument | TextArgument)+)
|
||||
| (CtrlSeq (OptionalArgument | TextArgument)+)
|
||||
| CtrlSeq Whitespace?
|
||||
| CtrlSym
|
||||
}
|
||||
|
||||
Command {
|
||||
KnownCommand
|
||||
KnownCommand<TextArgument>
|
||||
| UnknownCommand
|
||||
| KnownCtrlSym
|
||||
// Not technically allowed in normal mode, but not worth failing the parse over
|
||||
| LeftCtrlSeq
|
||||
| RightCtrlSeq
|
||||
|
||||
}
|
||||
|
||||
KnownCtrlSym {
|
||||
|
@ -480,7 +481,7 @@ TikzPictureContent { /// same as Text but with added allowed characters
|
|||
}
|
||||
|
||||
DefinitionFragment {
|
||||
( KnownCommand
|
||||
( KnownCommand<TextArgument>
|
||||
| CtrlSeq optionalWhitespace?
|
||||
| CtrlSym
|
||||
| Begin
|
||||
|
@ -491,6 +492,8 @@ DefinitionFragment {
|
|||
| CloseParenCtrlSym
|
||||
| OpenBracketCtrlSym
|
||||
| CloseBracketCtrlSym
|
||||
| LeftCtrlSeq
|
||||
| RightCtrlSeq
|
||||
| KnownCtrlSym
|
||||
| BlankLine
|
||||
| NewLine
|
||||
|
@ -686,21 +689,9 @@ Math {
|
|||
|
||||
|
||||
MathCommand {
|
||||
MathKnownCommand
|
||||
KnownCommand<MathArgument>
|
||||
| MathUnknownCommand
|
||||
}
|
||||
|
||||
MathKnownCommand {
|
||||
KnownCtrlSym
|
||||
| Label {
|
||||
LabelCtrlSeq optionalWhitespace? OptionalArgument? LabelArgument
|
||||
}
|
||||
| Ref {
|
||||
(RefCtrlSeq | RefStarrableCtrlSeq "*"?) optionalWhitespace? OptionalArgument? optionalWhitespace? OptionalArgument? optionalWhitespace? RefArgument
|
||||
}
|
||||
| MathTextCommand {
|
||||
(MathTextCtrlSeq | HboxCtrlSeq) optionalWhitespace? "*"? TextArgument
|
||||
}
|
||||
| KnownCtrlSym
|
||||
}
|
||||
|
||||
@external tokens endOfArgumentListTokenizer from "./tokens.mjs" {
|
||||
|
|
|
@ -75,14 +75,13 @@ export const enterNode = (
|
|||
} else if (
|
||||
node.type.is('UnknownCommand') ||
|
||||
node.type.is('KnownCommand') ||
|
||||
node.type.is('MathUnknownCommand') ||
|
||||
node.type.is('MathKnownCommand')
|
||||
node.type.is('MathUnknownCommand')
|
||||
) {
|
||||
let commandNode: SyntaxNode | null = node.node
|
||||
if (node.type.is('KnownCommand') || node.type.is('MathKnownCommand')) {
|
||||
// (Math)KnownCommands are defined as
|
||||
if (node.type.is('KnownCommand')) {
|
||||
// KnownCommands are defined as
|
||||
//
|
||||
// (Math)KnownCommand {
|
||||
// KnownCommand {
|
||||
// CommandName {
|
||||
// CommandCtrlSeq [args]
|
||||
// }
|
||||
|
|
Loading…
Reference in a new issue