Skip to content

Commit

Permalink
Fix #3948 Mathtools and amsopn new command support
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Jun 29, 2023
1 parent d6c912a commit 1da250a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/components/parserlib/unified-defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const MACROS: MacroInfoRecord = {
newacronym: { signature: 'o m m m'},
newabbreviation: { signature: 'o m m m'},
newabbr: { signature: 'o m m m'},
DeclareMathOperator: { signature: 'm m'},
DeclarePairedDelimiter: { signature: 'm m m'},
DeclarePairedDelimiterX: { signature: 'm o m m m'},
DeclarePairedDelimiterXPP: { signature: 'm o m m m m m'},
}

const ENVS: EnvInfoRecord = {}
Expand Down
5 changes: 3 additions & 2 deletions src/providers/completer/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,14 @@ export class Command implements IProvider {
defined = defined ?? new Set<string>()
let cmds: CmdEnvSuggestion[] = []
if (node.type === 'macro' &&
['renewcommand', 'newcommand', 'providecommand', 'DeclareMathOperator'].includes(node.content) &&
['renewcommand', 'newcommand', 'providecommand', 'DeclareMathOperator', 'DeclarePairedDelimiter', 'DeclarePairedDelimiterX', 'DeclarePairedDelimiterXPP'].includes(node.content) &&
node.args?.[2]?.content?.[0]?.type === 'macro') {
// \newcommand{\fix}[3][]{\chdeleted{#2}\chadded[comment={#1}]{#3}}
// \newcommand\WARNING{\textcolor{red}{WARNING}}
const name = node.args[2].content[0].content
let args = ''
if (node.args?.[3].content?.[0]?.type === 'string' &&
if (['renewcommand', 'newcommand', 'providecommand'].includes(node.content) &&
node.args?.[3].content?.[0]?.type === 'string' &&
parseInt(node.args?.[3].content?.[0].content) > 0) {
args = (node.args?.[4].openMark === '[' ? '[]' : '{}') + '{}'.repeat(parseInt(node.args?.[3].content?.[0].content) - 1)
}
Expand Down

0 comments on commit 1da250a

Please sign in to comment.