diff --git a/data/packages/physics2.json b/data/packages/physics2.json index e2504e344..d25e8b099 100644 --- a/data/packages/physics2.json +++ b/data/packages/physics2.json @@ -30,30 +30,6 @@ "keyPos": 0 } }, - { - "name": "bigg" - }, - { - "name": "Bigg" - }, - { - "name": "bigg" - }, - { - "name": "bigg" - }, - { - "name": "bigg" - }, - { - "name": "Bigg" - }, - { - "name": "Bigg" - }, - { - "name": "Bigg" - }, { "name": "pab", "arg": { diff --git a/data/packages/tex.json b/data/packages/tex.json index 14d1bbf4e..d95045702 100644 --- a/data/packages/tex.json +++ b/data/packages/tex.json @@ -1425,22 +1425,22 @@ "name": "Bigg" }, { - "name": "bigg" + "name": "biggl" }, { - "name": "Bigg" + "name": "Biggl" }, { - "name": "bigg" + "name": "biggm" }, { - "name": "Bigg" + "name": "Biggm" }, { - "name": "bigg" + "name": "biggr" }, { - "name": "Bigg" + "name": "Biggr" }, { "name": "bigl" @@ -2911,92 +2911,130 @@ "doc": "Vertical ellipsis" }, { - "name": "big", + "name": "big(", "arg": { - "format": "()", - "snippet": "big(${1:%<..%>\\big})" + "format": "", + "snippet": "big(${1}\\big)" } }, { - "name": "big", + "name": "big[", "arg": { - "format": "[]", - "snippet": "big[${1:..\\big}]" + "format": "", + "snippet": "big[${1}\\big]" } }, { - "name": "big", + "name": "big|", "arg": { - "format": "||", - "snippet": "big|${1:..\\big}|" + "format": "", + "snippet": "big|${1}\\big|" } }, { - "name": "Big", + "name": "Big(", "arg": { - "format": "()", - "snippet": "Big(${1:%<..%>\\Big})" + "format": "", + "snippet": "Big(${1}\\Big)" } }, { - "name": "Big", + "name": "Big[", "arg": { - "format": "[]", - "snippet": "Big[${1:..\\Big}]" + "format": "", + "snippet": "Big[${1}\\Big]" } }, { - "name": "Big", + "name": "Big|", "arg": { - "format": "||", - "snippet": "Big|${1:..\\Big}|" + "format": "", + "snippet": "Big|${1}\\Big|" } }, { - "name": "bigl", + "name": "bigl(", "arg": { - "format": "()", - "snippet": "bigl(${1:%<..%>\\bigr})" + "format": "", + "snippet": "bigl(${1}\\bigr)" } }, { - "name": "bigl", + "name": "bigl[", "arg": { - "format": "[]", - "snippet": "bigl[${1:..\\bigr}]" + "format": "", + "snippet": "bigl[${1}\\bigr]" } }, { - "name": "Bigl", + "name": "bigl\\{", "arg": { - "format": "()", - "snippet": "Bigl(${1:%<..%>\\Bigr})" + "format": "", + "snippet": "bigl\\{${1}\\bigr\\\\}" } }, { - "name": "Bigl", + "name": "Bigl(", "arg": { - "format": "[]", - "snippet": "Bigl[${1:..\\Bigr}]" + "format": "", + "snippet": "Bigl(${1}\\Bigr)" } }, { - "name": "bigg" + "name": "Bigl[", + "arg": { + "format": "", + "snippet": "Bigl[${1}\\Bigr]" + } }, { - "name": "bigg" + "name": "Bigl\\{", + "arg": { + "format": "", + "snippet": "Bigl\\{${1}\\Bigr\\\\}" + } }, { - "name": "bigg" + "name": "biggl(", + "arg": { + "format": "", + "snippet": "biggl(${1}\\biggr)" + } }, { - "name": "Bigg" + "name": "biggl[", + "arg": { + "format": "", + "snippet": "biggl[${1}\\biggr]" + } }, { - "name": "Bigg" + "name": "biggl\\{", + "arg": { + "format": "", + "snippet": "biggl\\{${1}\\biggr\\\\}" + } }, { - "name": "Bigg" + "name": "Biggl(", + "arg": { + "format": "", + "snippet": "Biggl(${1}\\Biggr)" + } + }, + { + "name": "Biggl[", + "arg": { + "format": "", + "snippet": "Biggl[${1}\\Biggr]" + } + }, + { + "name": "Biggl\\{", + "arg": { + "format": "", + "snippet": "Biggl\\{${1}\\Biggr\\\\}" + } }, { "name": "int_", diff --git a/dev/packages/tex.json b/dev/packages/tex.json index 14d1bbf4e..11232d2b7 100644 --- a/dev/packages/tex.json +++ b/dev/packages/tex.json @@ -1425,22 +1425,22 @@ "name": "Bigg" }, { - "name": "bigg" + "name": "biggl" }, { - "name": "Bigg" + "name": "Biggl" }, { - "name": "bigg" + "name": "biggm" }, { - "name": "Bigg" + "name": "Biggm" }, { - "name": "bigg" + "name": "biggr" }, { - "name": "Bigg" + "name": "Biggr" }, { "name": "bigl" @@ -2911,92 +2911,130 @@ "doc": "Vertical ellipsis" }, { - "name": "big", + "name": "big(", "arg": { - "format": "()", - "snippet": "big(${1:%<..%>\\big})" + "format": "", + "snippet": "big(${1}\\big)" } }, { - "name": "big", + "name": "big[", "arg": { - "format": "[]", - "snippet": "big[${1:..\\big}]" + "format": "", + "snippet": "big[${1}\\big]" } }, { - "name": "big", + "name": "big|", "arg": { - "format": "||", - "snippet": "big|${1:..\\big}|" + "format": "", + "snippet": "big|${1}\\big|" } }, { - "name": "Big", + "name": "Big(", "arg": { - "format": "()", - "snippet": "Big(${1:%<..%>\\Big})" + "format": "", + "snippet": "Big(${1}\\Big)" } }, { - "name": "Big", + "name": "Big[", "arg": { - "format": "[]", - "snippet": "Big[${1:..\\Big}]" + "format": "", + "snippet": "Big[${1}\\Big]" } }, { - "name": "Big", + "name": "Big|", "arg": { - "format": "||", - "snippet": "Big|${1:..\\Big}|" + "format": "", + "snippet": "Big|${1}\\Big|" } }, { - "name": "bigl", + "name": "bigl(", "arg": { - "format": "()", - "snippet": "bigl(${1:%<..%>\\bigr})" + "format": "", + "snippet": "bigl(${1}\\bigr)" } }, { - "name": "bigl", + "name": "bigl[", "arg": { - "format": "[]", - "snippet": "bigl[${1:..\\bigr}]" + "format": "", + "snippet": "bigl[${1}\\bigr]" } }, { - "name": "Bigl", + "name": "bigl\\{", "arg": { - "format": "()", - "snippet": "Bigl(${1:%<..%>\\Bigr})" + "format": "", + "snippet": "bigl\\{${1}\\bigr\\}" } }, { - "name": "Bigl", + "name": "Bigl(", "arg": { - "format": "[]", - "snippet": "Bigl[${1:..\\Bigr}]" + "format": "", + "snippet": "Bigl(${1}\\Bigr)" } }, { - "name": "bigg" + "name": "Bigl[", + "arg": { + "format": "", + "snippet": "Bigl[${1}\\Bigr]" + } }, { - "name": "bigg" + "name": "Bigl\\{", + "arg": { + "format": "", + "snippet": "Bigl\\{${1}\\Bigr\\}" + } }, { - "name": "bigg" + "name": "biggl(", + "arg": { + "format": "", + "snippet": "biggl(${1}\\biggr)" + } }, { - "name": "Bigg" + "name": "biggl[", + "arg": { + "format": "", + "snippet": "biggl[${1}\\biggr]" + } }, { - "name": "Bigg" + "name": "biggl\\{", + "arg": { + "format": "", + "snippet": "biggl\\{${1}\\biggr\\}" + } }, { - "name": "Bigg" + "name": "Biggl(", + "arg": { + "format": "", + "snippet": "Biggl(${1}\\Biggr)" + } + }, + { + "name": "Biggl[", + "arg": { + "format": "", + "snippet": "Biggl[${1}\\Biggr]" + } + }, + { + "name": "Biggl\\{", + "arg": { + "format": "", + "snippet": "Biggl\\{${1}\\Biggr\\}" + } }, { "name": "int_", diff --git a/dev/parse-cwl.ts b/dev/parse-cwl.ts index 615a3ba1b..2564dcbb0 100644 --- a/dev/parse-cwl.ts +++ b/dev/parse-cwl.ts @@ -281,19 +281,9 @@ function parseMacro(pkg: PackageRaw, line: string, ifCond?: string): void { if (/(?:\\left|\\right)[^a-zA-Z]/.test(line)) { return } - // Special cases in latex-document - if (line.toLowerCase().startsWith('\\bigg')) { - const match = /^\\([Bb]igg)([([|])?.*?(?:#(.*))?$/.exec(line) - if (match === null) { - return - } - const pairs = { '(': ')', '[': ']', '|': '|' } - const macro: MacroRaw = { name: match[1] + (match[2] ?? '') } - if (match[2] === '(' || match[2] === '[' || match[2] === '|') { - macro.arg = { format: '', snippet: `${match[1]}${match[2]}$\{1}\\${match[1]}${pairs[match[2]]}` } - } - pkg.macros.push(macro) - return + // Special cases in latex-document and tex, e.g., \Bigg(%|\Bigg)#mM + if (line.toLowerCase().split('\\big').length === 3) { + return handleBigMacros(pkg, line) } // \mint[keys]{language}{verbatimSymbol}#S // \mint{%}|%|#M @@ -322,6 +312,23 @@ function parseMacro(pkg: PackageRaw, line: string, ifCond?: string): void { } } +function handleBigMacros(pkg: PackageRaw, line: string): void { + let snippet = line.slice(1, line.lastIndexOf('#')) // Remove leading backslash and type indicator + snippet = snippet + .replaceAll('%|', '${1}') // Replace %| with cursor position + .replaceAll('%<..%>', '${1}') // Remove %<..%> with cursor position + .replaceAll('\\}', '\\\\}') // Right curly brace needs double escape + const macro: MacroRaw = { + name: line.slice(1, line.indexOf('%')), + arg: { + format: '', + snippet + } + } + pkg.macros.push(macro) + return +} + /** * Constructs a macro environment based on the provided context, match, and * ifCond parameters.