Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

fix: katex snippets handle back slash

Smaug6739f8bb42fb3e2b
diff --git a/frontend/app/components/MarkdownEditor/katex-snippets.ts b/frontend/app/components/MarkdownEditor/katex-snippets.ts
index d7a7561f..4f403b27 100644
--- a/frontend/app/components/MarkdownEditor/katex-snippets.ts
+++ b/frontend/app/components/MarkdownEditor/katex-snippets.ts
@@ -1,305 +1,305 @@
export const katexSnippets = [
// ---------- Accents ----------
- { id: 'acute', label: '\\acute{${0}}' },
- { id: 'grave', label: '\\grave{${0}}' },
- { id: 'hat', label: '\\hat{${0}}' },
- { id: 'widehat', label: '\\widehat{${0}}' },
- { id: 'bar', label: '\\bar{${0}}' },
- { id: 'overline', label: '\\overline{${0}}' },
- { id: 'underline', label: '\\underline{${0}}' },
- { id: 'vec', label: '\\vec{${0}}' },
- { id: 'tilde', label: '\\tilde{${0}}' },
- { id: 'widetilde', label: '\\widetilde{${0}}' },
- { id: 'check', label: '\\check{${0}}' },
- { id: 'breve', label: '\\breve{${0}}' },
- { id: 'dot', label: '\\dot{${0}}' },
- { id: 'ddot', label: '\\ddot{${0}}' },
- { id: 'dddot', label: '\\dddot{${0}}' },
- { id: 'ddddot', label: '\\ddddot{${0}}' },
- { id: 'overbrace', label: '\\overbrace{${0}}^{${1}}' },
- { id: 'underbrace', label: '\\underbrace{${0}}_{${1}}' },
- { id: 'overleftarrow', label: '\\overleftarrow{${0}}' },
- { id: 'overrightarrow', label: '\\overrightarrow{${0}}' },
- { id: 'underleftarrow', label: '\\underleftarrow{${0}}' },
- { id: 'underrightarrow', label: '\\underrightarrow{${0}}' },
- { id: 'overleftrightarrow', label: '\\overleftrightarrow{${0}}' },
- { id: 'underleftrightarrow', label: '\\underleftrightarrow{${0}}' },
- { id: 'overgroup', label: '\\overgroup{${0}}' },
- { id: 'undergroup', label: '\\undergroup{${0}}' },
- { id: 'utilde', label: '\\utilde{${0}}' },
- { id: 'widecheck', label: '\\widecheck{${0}}' },
- { id: 'overlinesegment', label: '\\overlinesegment{${0}}' },
- { id: 'underlinesegment', label: '\\underlinesegment{${0}}' },
- { id: 'underbar', label: '\\underbar{${0}}' },
+ { id: '\\acute', label: '\\acute{${0}}' },
+ { id: '\\grave', label: '\\grave{${0}}' },
+ { id: '\\hat', label: '\\hat{${0}}' },
+ { id: '\\widehat', label: '\\widehat{${0}}' },
+ { id: '\\bar', label: '\\bar{${0}}' },
+ { id: '\\overline', label: '\\overline{${0}}' },
+ { id: '\\underline', label: '\\underline{${0}}' },
+ { id: '\\vec', label: '\\vec{${0}}' },
+ { id: '\\tilde', label: '\\tilde{${0}}' },
+ { id: '\\widetilde', label: '\\widetilde{${0}}' },
+ { id: '\\check', label: '\\check{${0}}' },
+ { id: '\\breve', label: '\\breve{${0}}' },
+ { id: '\\dot', label: '\\dot{${0}}' },
+ { id: '\\ddot', label: '\\ddot{${0}}' },
+ { id: '\\dddot', label: '\\dddot{${0}}' },
+ { id: '\\ddddot', label: '\\ddddot{${0}}' },
+ { id: '\\overbrace', label: '\\overbrace{${0}}^{${1}}' },
+ { id: '\\underbrace', label: '\\underbrace{${0}}_{${1}}' },
+ { id: '\\overleftarrow', label: '\\overleftarrow{${0}}' },
+ { id: '\\overrightarrow', label: '\\overrightarrow{${0}}' },
+ { id: '\\underleftarrow', label: '\\underleftarrow{${0}}' },
+ { id: '\\underrightarrow', label: '\\underrightarrow{${0}}' },
+ { id: '\\overleftrightarrow', label: '\\overleftrightarrow{${0}}' },
+ { id: '\\underleftrightarrow', label: '\\underleftrightarrow{${0}}' },
+ { id: '\\overgroup', label: '\\overgroup{${0}}' },
+ { id: '\\undergroup', label: '\\undergroup{${0}}' },
+ { id: '\\utilde', label: '\\utilde{${0}}' },
+ { id: '\\widecheck', label: '\\widecheck{${0}}' },
+ { id: '\\overlinesegment', label: '\\overlinesegment{${0}}' },
+ { id: '\\underlinesegment', label: '\\underlinesegment{${0}}' },
+ { id: '\\underbar', label: '\\underbar{${0}}' },
// ---------- Delimiters ----------
- { id: 'lparen', label: '\\lparen' },
- { id: 'rparen', label: '\\rparen' },
- { id: 'lbrack', label: '\\lbrack' },
- { id: 'rbrack', label: '\\rbrack' },
- { id: 'lbrace', label: '\\lbrace' },
- { id: 'rbrace', label: '\\rbrace' },
- { id: 'langle', label: '\\langle' },
- { id: 'rangle', label: '\\rangle' },
- { id: 'lgroup', label: '\\lgroup' },
- { id: 'rgroup', label: '\\rgroup' },
- { id: 'ulcorner', label: '\\ulcorner' },
- { id: 'urcorner', label: '\\urcorner' },
- { id: 'llcorner', label: '\\llcorner' },
- { id: 'lrcorner', label: '\\lrcorner' },
- { id: 'vert', label: '\\vert' },
- { id: 'Vert', label: '\\Vert' },
- { id: 'backslash', label: '\\backslash' },
- { id: 'left', label: '\\left${0}' },
- { id: 'right', label: '\\right${0}' },
- { id: 'middle', label: '\\middle${0}' },
- { id: 'big', label: '\\big${0}' },
- { id: 'Big', label: '\\Big${0}' },
- { id: 'bigg', label: '\\bigg${0}' },
- { id: 'Bigg', label: '\\Bigg${0}' },
- { id: 'bigl', label: '\\bigl${0}' },
- { id: 'bigr', label: '\\bigr${0}' },
- { id: 'bigm', label: '\\bigm${0}' },
- { id: 'Bigl', label: '\\Bigl${0}' },
- { id: 'Bigr', label: '\\Bigr${0}' },
- { id: 'Bigm', label: '\\Bigm${0}' },
- { id: 'biggl', label: '\\biggl${0}' },
- { id: 'biggr', label: '\\biggr${0}' },
- { id: 'biggm', label: '\\biggm${0}' },
- { id: 'Biggl', label: '\\Biggl${0}' },
- { id: 'Biggr', label: '\\Biggr${0}' },
- { id: 'Biggm', label: '\\Biggm${0}' },
+ { id: '\\lparen', label: '\\lparen' },
+ { id: '\\rparen', label: '\\rparen' },
+ { id: '\\lbrack', label: '\\lbrack' },
+ { id: '\\rbrack', label: '\\rbrack' },
+ { id: '\\lbrace', label: '\\lbrace' },
+ { id: '\\rbrace', label: '\\rbrace' },
+ { id: '\\langle', label: '\\langle' },
+ { id: '\\rangle', label: '\\rangle' },
+ { id: '\\lgroup', label: '\\lgroup' },
+ { id: '\\rgroup', label: '\\rgroup' },
+ { id: '\\ulcorner', label: '\\ulcorner' },
+ { id: '\\urcorner', label: '\\urcorner' },
+ { id: '\\llcorner', label: '\\llcorner' },
+ { id: '\\lrcorner', label: '\\lrcorner' },
+ { id: '\\vert', label: '\\vert' },
+ { id: '\\Vert', label: '\\Vert' },
+ { id: '\\backslash', label: '\\backslash' },
+ { id: '\\left', label: '\\left${0}' },
+ { id: '\\right', label: '\\right${0}' },
+ { id: '\\middle', label: '\\middle${0}' },
+ { id: '\\big', label: '\\big${0}' },
+ { id: '\\Big', label: '\\Big${0}' },
+ { id: '\\bigg', label: '\\bigg${0}' },
+ { id: '\\Bigg', label: '\\Bigg${0}' },
+ { id: '\\bigl', label: '\\bigl${0}' },
+ { id: '\\bigr', label: '\\bigr${0}' },
+ { id: '\\bigm', label: '\\bigm${0}' },
+ { id: '\\Bigl', label: '\\Bigl${0}' },
+ { id: '\\Bigr', label: '\\Bigr${0}' },
+ { id: '\\Bigm', label: '\\Bigm${0}' },
+ { id: '\\biggl', label: '\\biggl${0}' },
+ { id: '\\biggr', label: '\\biggr${0}' },
+ { id: '\\biggm', label: '\\biggm${0}' },
+ { id: '\\Biggl', label: '\\Biggl${0}' },
+ { id: '\\Biggr', label: '\\Biggr${0}' },
+ { id: '\\Biggm', label: '\\Biggm${0}' },
// ---------- Environments (snippets) ----------
- { id: 'matrix', label: '\\begin{matrix}${0}\\\\${1}\\end{matrix}' },
- { id: 'pmatrix', label: '\\begin{pmatrix}${0}\\\\${1}\\end{pmatrix}' },
- { id: 'bmatrix', label: '\\begin{bmatrix}${0}\\\\${1}\\end{bmatrix}' },
- { id: 'vmatrix', label: '\\begin{vmatrix}${0}\\\\${1}\\end{vmatrix}' },
- { id: 'Vmatrix', label: '\\begin{Vmatrix}${0}\\\\${1}\\end{Vmatrix}' },
- { id: 'Bmatrix', label: '\\begin{Bmatrix}${0}\\\\${1}\\end{Bmatrix}' },
- { id: 'smallmatrix', label: '\\begin{smallmatrix}${0}\\\\${1}\\end{smallmatrix}' },
- { id: 'array', label: '\\begin{array}{${0}}${1}\\end{array}' },
- { id: 'cases', label: '\\begin{cases}${0}\\end{cases}' },
- { id: 'rcases', label: '\\begin{rcases}${0}\\end{rcases}' },
- { id: 'darray', label: '\\begin{darray}${0}\\end{darray}' },
- { id: 'dcases', label: '\\begin{dcases}${0}\\end{dcases}' },
- { id: 'drcases', label: '\\begin{drcases}${0}\\end{drcases}' },
- { id: 'equation', label: '\\begin{equation}${0}\\end{equation}' },
- { id: 'equation*', label: '\\begin{equation*}${0}\\end{equation*}' },
- { id: 'split', label: '\\begin{split}${0}\\end{split}' },
- { id: 'align', label: '\\begin{align}${0}\\end{align}' },
- { id: 'align*', label: '\\begin{align*}${0}\\end{align*}' },
- { id: 'gather', label: '\\begin{gather}${0}\\end{gather}' },
- { id: 'gather*', label: '\\begin{gather*}${0}\\end{gather*}' },
- { id: 'alignat', label: '\\begin{alignat}{${0}}${1}\\end{alignat}' },
- { id: 'alignat*', label: '\\begin{alignat*}{${0}}${1}\\end{alignat*}' },
- { id: 'gathered', label: '\\begin{gathered}${0}\\end{gathered}' },
- { id: 'aligned', label: '\\begin{aligned}${0}\\end{aligned}' },
- { id: 'alignedat', label: '\\begin{alignedat}{${0}}${1}\\end{alignedat}' },
- { id: 'CD', label: '\\begin{CD}${0}\\end{CD}' },
+ { id: '\\matrix', label: '\\begin{matrix}${0}\\\\${1}\\end{matrix}' },
+ { id: '\\pmatrix', label: '\\begin{pmatrix}${0}\\\\${1}\\end{pmatrix}' },
+ { id: '\\bmatrix', label: '\\begin{bmatrix}${0}\\\\${1}\\end{bmatrix}' },
+ { id: '\\vmatrix', label: '\\begin{vmatrix}${0}\\\\${1}\\end{vmatrix}' },
+ { id: '\\Vmatrix', label: '\\begin{Vmatrix}${0}\\\\${1}\\end{Vmatrix}' },
+ { id: '\\Bmatrix', label: '\\begin{Bmatrix}${0}\\\\${1}\\end{Bmatrix}' },
+ { id: '\\smallmatrix', label: '\\begin{smallmatrix}${0}\\\\${1}\\end{smallmatrix}' },
+ { id: '\\array', label: '\\begin{array}{${0}}${1}\\end{array}' },
+ { id: '\\cases', label: '\\begin{cases}${0}\\end{cases}' },
+ { id: '\\rcases', label: '\\begin{rcases}${0}\\end{rcases}' },
+ { id: '\\darray', label: '\\begin{darray}${0}\\end{darray}' },
+ { id: '\\dcases', label: '\\begin{dcases}${0}\\end{dcases}' },
+ { id: '\\drcases', label: '\\begin{drcases}${0}\\end{drcases}' },
+ { id: '\\equation', label: '\\begin{equation}${0}\\end{equation}' },
+ { id: '\\equation*', label: '\\begin{equation*}${0}\\end{equation*}' },
+ { id: '\\split', label: '\\begin{split}${0}\\end{split}' },
+ { id: '\\align', label: '\\begin{align}${0}\\end{align}' },
+ { id: '\\align*', label: '\\begin{align*}${0}\\end{align*}' },
+ { id: '\\gather', label: '\\begin{gather}${0}\\end{gather}' },
+ { id: '\\gather*', label: '\\begin{gather*}${0}\\end{gather*}' },
+ { id: '\\alignat', label: '\\begin{alignat}{${0}}${1}\\end{alignat}' },
+ { id: '\\alignat*', label: '\\begin{alignat*}{${0}}${1}\\end{alignat*}' },
+ { id: '\\gathered', label: '\\begin{gathered}${0}\\end{gathered}' },
+ { id: '\\aligned', label: '\\begin{aligned}${0}\\end{aligned}' },
+ { id: '\\alignedat', label: '\\begin{alignedat}{${0}}${1}\\end{alignedat}' },
+ { id: '\\CD', label: '\\begin{CD}${0}\\end{CD}' },
// ---------- Basic structures ----------
- { id: 'frac', label: '\\frac{${0}}{${1}}' },
- { id: 'dfrac', label: '\\dfrac{${0}}{${1}}' },
- { id: 'tfrac', label: '\\tfrac{${0}}{${1}}' },
- { id: 'binom', label: '\\binom{${0}}{${1}}' },
- { id: 'sqrt', label: '\\sqrt{${0}}' },
- { id: 'sqrtn', label: '\\sqrt[${0}]{${1}}' },
- { id: 'boxed', label: '\\boxed{${0}}' },
- { id: 'cancel', label: '\\cancel{${0}}' },
- { id: 'bcancel', label: '\\bcancel{${0}}' },
- { id: 'xcancel', label: '\\xcancel{${0}}' },
- { id: 'sout', label: '\\sout{${0}}' },
+ { id: '\\frac', label: '\\frac{${0}}{${1}}' },
+ { id: '\\dfrac', label: '\\dfrac{${0}}{${1}}' },
+ { id: '\\tfrac', label: '\\tfrac{${0}}{${1}}' },
+ { id: '\\binom', label: '\\binom{${0}}{${1}}' },
+ { id: '\\sqrt', label: '\\sqrt{${0}}' },
+ { id: '\\sqrtn', label: '\\sqrt[${0}]{${1}}' },
+ { id: '\\boxed', label: '\\boxed{${0}}' },
+ { id: '\\cancel', label: '\\cancel{${0}}' },
+ { id: '\\bcancel', label: '\\bcancel{${0}}' },
+ { id: '\\xcancel', label: '\\xcancel{${0}}' },
+ { id: '\\sout', label: '\\sout{${0}}' },
// ---------- Arrows ----------
- { id: 'to', label: '\\to' },
- { id: 'rightarrow', label: '\\rightarrow' },
- { id: 'leftarrow', label: '\\leftarrow' },
- { id: 'leftrightarrow', label: '\\leftrightarrow' },
- { id: 'Rightarrow', label: '\\Rightarrow' },
- { id: 'Leftarrow', label: '\\Leftarrow' },
- { id: 'Leftrightarrow', label: '\\Leftrightarrow' },
- { id: 'mapsto', label: '\\mapsto' },
- { id: 'longrightarrow', label: '\\longrightarrow' },
- { id: 'longleftarrow', label: '\\longleftarrow' },
- { id: 'longleftrightarrow', label: '\\longleftrightarrow' },
- { id: 'uparrow', label: '\\uparrow' },
- { id: 'downarrow', label: '\\downarrow' },
- { id: 'updownarrow', label: '\\updownarrow' },
- { id: 'Uparrow', label: '\\Uparrow' },
- { id: 'Downarrow', label: '\\Downarrow' },
- { id: 'Updownarrow', label: '\\Updownarrow' },
+ { id: '\\to', label: '\\to' },
+ { id: '\\rightarrow', label: '\\rightarrow' },
+ { id: '\\leftarrow', label: '\\leftarrow' },
+ { id: '\\leftrightarrow', label: '\\leftrightarrow' },
+ { id: '\\Rightarrow', label: '\\Rightarrow' },
+ { id: '\\Leftarrow', label: '\\Leftarrow' },
+ { id: '\\Leftrightarrow', label: '\\Leftrightarrow' },
+ { id: '\\mapsto', label: '\\mapsto' },
+ { id: '\\longrightarrow', label: '\\longrightarrow' },
+ { id: '\\longleftarrow', label: '\\longleftarrow' },
+ { id: '\\longleftrightarrow', label: '\\longleftrightarrow' },
+ { id: '\\uparrow', label: '\\uparrow' },
+ { id: '\\downarrow', label: '\\downarrow' },
+ { id: '\\updownarrow', label: '\\updownarrow' },
+ { id: '\\Uparrow', label: '\\Uparrow' },
+ { id: '\\Downarrow', label: '\\Downarrow' },
+ { id: '\\Updownarrow', label: '\\Updownarrow' },
// ---------- Relations & operators ----------
- { id: 'cdot', label: '\\cdot' },
- { id: 'times', label: '\\times' },
- { id: 'div', label: '\\div' },
- { id: 'pm', label: '\\pm' },
- { id: 'mp', label: '\\mp' },
- { id: 'leq', label: '\\leq' },
- { id: 'geq', label: '\\geq' },
- { id: 'neq', label: '\\neq' },
- { id: 'approx', label: '\\approx' },
- { id: 'sim', label: '\\sim' },
- { id: 'propto', label: '\\propto' },
- { id: 'equiv', label: '\\equiv' },
- { id: 'subset', label: '\\subset' },
- { id: 'supset', label: '\\supset' },
- { id: 'subseteq', label: '\\subseteq' },
- { id: 'supseteq', label: '\\supseteq' },
- { id: 'in', label: '\\in' },
- { id: 'notin', label: '\\notin' },
- { id: 'ni', label: '\\ni' },
- { id: 'mid', label: '\\mid' },
- { id: 'land', label: '\\land' },
- { id: 'lor', label: '\\lor' },
- { id: 'forall', label: '\\forall' },
- { id: 'exists', label: '\\exists' },
- { id: 'nexists', label: '\\nexists' },
- { id: 'therefore', label: '\\therefore' },
- { id: 'because', label: '\\because' },
- { id: 'implies', label: '\\implies' },
- { id: 'impliedby', label: '\\impliedby' },
- { id: 'iff', label: '\\iff' },
+ { id: '\\cdot', label: '\\cdot' },
+ { id: '\\times', label: '\\times' },
+ { id: '\\div', label: '\\div' },
+ { id: '\\pm', label: '\\pm' },
+ { id: '\\mp', label: '\\mp' },
+ { id: '\\leq', label: '\\leq' },
+ { id: '\\geq', label: '\\geq' },
+ { id: '\\neq', label: '\\neq' },
+ { id: '\\approx', label: '\\approx' },
+ { id: '\\sim', label: '\\sim' },
+ { id: '\\propto', label: '\\propto' },
+ { id: '\\equiv', label: '\\equiv' },
+ { id: '\\subset', label: '\\subset' },
+ { id: '\\supset', label: '\\supset' },
+ { id: '\\subseteq', label: '\\subseteq' },
+ { id: '\\supseteq', label: '\\supseteq' },
+ { id: '\\in', label: '\\in' },
+ { id: '\\notin', label: '\\notin' },
+ { id: '\\ni', label: '\\ni' },
+ { id: '\\mid', label: '\\mid' },
+ { id: '\\land', label: '\\land' },
+ { id: '\\lor', label: '\\lor' },
+ { id: '\\forall', label: '\\forall' },
+ { id: '\\exists', label: '\\exists' },
+ { id: '\\nexists', label: '\\nexists' },
+ { id: '\\therefore', label: '\\therefore' },
+ { id: '\\because', label: '\\because' },
+ { id: '\\implies', label: '\\implies' },
+ { id: '\\impliedby', label: '\\impliedby' },
+ { id: '\\iff', label: '\\iff' },
// ---------- Spacing ----------
- { id: 'thinspace', label: '\\thinspace' },
- { id: 'medspace', label: '\\medspace' },
- { id: 'thickspace', label: '\\thickspace' },
- { id: 'enspace', label: '\\enspace' },
- { id: 'quad', label: '\\quad' },
- { id: 'qquad', label: '\\qquad' },
- { id: 'negthinspace', label: '\\negthinspace' },
- { id: 'negmedspace', label: '\\negmedspace' },
- { id: 'negthickspace', label: '\\negthickspace' },
- { id: 'kern', label: '\\kern${0}' },
- { id: 'mkern', label: '\\mkern${0}' },
- { id: 'hspace', label: '\\hspace{${0}}' },
- { id: 'hphantom', label: '\\hphantom{${0}}' },
- { id: 'vphantom', label: '\\vphantom{${0}}' },
- { id: 'phantom', label: '\\phantom{${0}}' },
+ { id: '\\thinspace', label: '\\thinspace' },
+ { id: '\\medspace', label: '\\medspace' },
+ { id: '\\thickspace', label: '\\thickspace' },
+ { id: '\\enspace', label: '\\enspace' },
+ { id: '\\quad', label: '\\quad' },
+ { id: '\\qquad', label: '\\qquad' },
+ { id: '\\negthinspace', label: '\\negthinspace' },
+ { id: '\\negmedspace', label: '\\negmedspace' },
+ { id: '\\negthickspace', label: '\\negthickspace' },
+ { id: '\\kern', label: '\\kern${0}' },
+ { id: '\\mkern', label: '\\mkern${0}' },
+ { id: '\\hspace', label: '\\hspace{${0}}' },
+ { id: '\\hphantom', label: '\\hphantom{${0}}' },
+ { id: '\\vphantom', label: '\\vphantom{${0}}' },
+ { id: '\\phantom', label: '\\phantom{${0}}' },
// ---------- Layout ----------
- { id: 'stackrel', label: '\\stackrel{${0}}{${1}}' },
- { id: 'overset', label: '\\overset{${0}}{${1}}' },
- { id: 'underset', label: '\\underset{${0}}{${1}}' },
- { id: 'atop', label: '${0} \\atop ${1}' },
- { id: 'raisebox', label: '\\raisebox{${0}}{${1}}' },
- { id: 'vcenter', label: '\\vcenter{${0}}' },
- { id: 'smash', label: '\\smash{${0}}' },
- { id: 'mathllap', label: '\\mathllap{${0}}' },
- { id: 'mathrlap', label: '\\mathrlap{${0}}' },
- { id: 'mathclap', label: '\\mathclap{${0}}' },
+ { id: '\\stackrel', label: '\\stackrel{${0}}{${1}}' },
+ { id: '\\overset', label: '\\overset{${0}}{${1}}' },
+ { id: '\\underset', label: '\\underset{${0}}{${1}}' },
+ { id: '\\atop', label: '${0} \\atop ${1}' },
+ { id: '\\raisebox', label: '\\raisebox{${0}}{${1}}' },
+ { id: '\\vcenter', label: '\\vcenter{${0}}' },
+ { id: '\\smash', label: '\\smash{${0}}' },
+ { id: '\\mathllap', label: '\\mathllap{${0}}' },
+ { id: '\\mathrlap', label: '\\mathrlap{${0}}' },
+ { id: '\\mathclap', label: '\\mathclap{${0}}' },
// ---------- Tags ----------
- { id: 'tag', label: '\\tag{${0}} ${1}' },
- { id: 'tag*', label: '\\tag*{${0}} ${1}' },
+ { id: '\\tag', label: '\\tag{${0}} ${1}' },
+ { id: '\\tag*', label: '\\tag*{${0}} ${1}' },
// ---------- HTML (trust option required) ----------
- { id: 'href', label: '\\href{${0}}{${1}}' },
- { id: 'url', label: '\\url{${0}}' },
- { id: 'includegraphics', label: '\\includegraphics[height=${0}]{${1}}' },
- { id: 'htmlId', label: '\\htmlId{${0}}{${1}}' },
- { id: 'htmlClass', label: '\\htmlClass{${0}}{${1}}' },
- { id: 'htmlStyle', label: '\\htmlStyle{${0}}{${1}}' },
- { id: 'htmlData', label: '\\htmlData{${0}}{${1}}' },
+ { id: '\\href', label: '\\href{${0}}{${1}}' },
+ { id: '\\url', label: '\\url{${0}}' },
+ { id: '\\includegraphics', label: '\\includegraphics[height=${0}]{${1}}' },
+ { id: '\\htmlId', label: '\\htmlId{${0}}{${1}}' },
+ { id: '\\htmlClass', label: '\\htmlClass{${0}}{${1}}' },
+ { id: '\\htmlStyle', label: '\\htmlStyle{${0}}{${1}}' },
+ { id: '\\htmlData', label: '\\htmlData{${0}}{${1}}' },
// ---------- Greek letters (lowercase) ----------
- { id: 'alpha', label: '\\alpha' },
- { id: 'beta', label: '\\beta' },
- { id: 'gamma', label: '\\gamma' },
- { id: 'delta', label: '\\delta' },
- { id: 'epsilon', label: '\\epsilon' },
- { id: 'zeta', label: '\\zeta' },
- { id: 'eta', label: '\\eta' },
- { id: 'theta', label: '\\theta' },
- { id: 'iota', label: '\\iota' },
- { id: 'kappa', label: '\\kappa' },
- { id: 'lambda', label: '\\lambda' },
- { id: 'mu', label: '\\mu' },
- { id: 'nu', label: '\\nu' },
- { id: 'xi', label: '\\xi' },
- { id: 'omicron', label: '\\omicron' },
- { id: 'pi', label: '\\pi' },
- { id: 'rho', label: '\\rho' },
- { id: 'sigma', label: '\\sigma' },
- { id: 'tau', label: '\\tau' },
- { id: 'upsilon', label: '\\upsilon' },
- { id: 'phi', label: '\\phi' },
- { id: 'chi', label: '\\chi' },
- { id: 'psi', label: '\\psi' },
- { id: 'omega', label: '\\omega' },
- { id: 'varepsilon', label: '\\varepsilon' },
- { id: 'varkappa', label: '\\varkappa' },
- { id: 'vartheta', label: '\\vartheta' },
- { id: 'thetasym', label: '\\thetasym' },
- { id: 'varpi', label: '\\varpi' },
- { id: 'varrho', label: '\\varrho' },
- { id: 'varsigma', label: '\\varsigma' },
- { id: 'varphi', label: '\\varphi' },
+ { id: '\\alpha', label: '\\alpha' },
+ { id: '\\beta', label: '\\beta' },
+ { id: '\\gamma', label: '\\gamma' },
+ { id: '\\delta', label: '\\delta' },
+ { id: '\\epsilon', label: '\\epsilon' },
+ { id: '\\zeta', label: '\\zeta' },
+ { id: '\\eta', label: '\\eta' },
+ { id: '\\theta', label: '\\theta' },
+ { id: '\\iota', label: '\\iota' },
+ { id: '\\kappa', label: '\\kappa' },
+ { id: '\\lambda', label: '\\lambda' },
+ { id: '\\mu', label: '\\mu' },
+ { id: '\\nu', label: '\\nu' },
+ { id: '\\xi', label: '\\xi' },
+ { id: '\\omicron', label: '\\omicron' },
+ { id: '\\pi', label: '\\pi' },
+ { id: '\\rho', label: '\\rho' },
+ { id: '\\sigma', label: '\\sigma' },
+ { id: '\\tau', label: '\\tau' },
+ { id: '\\upsilon', label: '\\upsilon' },
+ { id: '\\phi', label: '\\phi' },
+ { id: '\\chi', label: '\\chi' },
+ { id: '\\psi', label: '\\psi' },
+ { id: '\\omega', label: '\\omega' },
+ { id: '\\varepsilon', label: '\\varepsilon' },
+ { id: '\\varkappa', label: '\\varkappa' },
+ { id: '\\vartheta', label: '\\vartheta' },
+ { id: '\\thetasym', label: '\\thetasym' },
+ { id: '\\varpi', label: '\\varpi' },
+ { id: '\\varrho', label: '\\varrho' },
+ { id: '\\varsigma', label: '\\varsigma' },
+ { id: '\\varphi', label: '\\varphi' },
// ---------- Greek letters (uppercase) ----------
- { id: 'Gamma', label: '\\Gamma' },
- { id: 'Delta', label: '\\Delta' },
- { id: 'Theta', label: '\\Theta' },
- { id: 'Lambda', label: '\\Lambda' },
- { id: 'Xi', label: '\\Xi' },
- { id: 'Pi', label: '\\Pi' },
- { id: 'Sigma', label: '\\Sigma' },
- { id: 'Upsilon', label: '\\Upsilon' },
- { id: 'Phi', label: '\\Phi' },
- { id: 'Psi', label: '\\Psi' },
- { id: 'Omega', label: '\\Omega' },
- { id: 'varGamma', label: '\\varGamma' },
- { id: 'varDelta', label: '\\varDelta' },
- { id: 'varTheta', label: '\\varTheta' },
- { id: 'varLambda', label: '\\varLambda' },
- { id: 'varXi', label: '\\varXi' },
- { id: 'varPi', label: '\\varPi' },
- { id: 'varSigma', label: '\\varSigma' },
- { id: 'varUpsilon', label: '\\varUpsilon' },
- { id: 'varPhi', label: '\\varPhi' },
- { id: 'varPsi', label: '\\varPsi' },
- { id: 'varOmega', label: '\\varOmega' },
+ { id: '\\Gamma', label: '\\Gamma' },
+ { id: '\\Delta', label: '\\Delta' },
+ { id: '\\Theta', label: '\\Theta' },
+ { id: '\\Lambda', label: '\\Lambda' },
+ { id: '\\Xi', label: '\\Xi' },
+ { id: '\\Pi', label: '\\Pi' },
+ { id: '\\Sigma', label: '\\Sigma' },
+ { id: '\\Upsilon', label: '\\Upsilon' },
+ { id: '\\Phi', label: '\\Phi' },
+ { id: '\\Psi', label: '\\Psi' },
+ { id: '\\Omega', label: '\\Omega' },
+ { id: '\\varGamma', label: '\\varGamma' },
+ { id: '\\varDelta', label: '\\varDelta' },
+ { id: '\\varTheta', label: '\\varTheta' },
+ { id: '\\varLambda', label: '\\varLambda' },
+ { id: '\\varXi', label: '\\varXi' },
+ { id: '\\varPi', label: '\\varPi' },
+ { id: '\\varSigma', label: '\\varSigma' },
+ { id: '\\varUpsilon', label: '\\varUpsilon' },
+ { id: '\\varPhi', label: '\\varPhi' },
+ { id: '\\varPsi', label: '\\varPsi' },
+ { id: '\\varOmega', label: '\\varOmega' },
// ---------- Other letters/symbols ----------
- { id: 'imath', label: '\\imath' },
- { id: 'jmath', label: '\\jmath' },
- { id: 'nabla', label: '\\nabla' },
- { id: 'partial', label: '\\partial' },
- { id: 'aleph', label: '\\aleph' },
- { id: 'beth', label: '\\beth' },
- { id: 'gimel', label: '\\gimel' },
- { id: 'daleth', label: '\\daleth' },
- { id: 'eth', label: '\\eth' },
- { id: 'hbar', label: '\\hbar' },
- { id: 'hslash', label: '\\hslash' },
- { id: 'wp', label: '\\wp' },
- { id: 'Im', label: '\\Im' },
- { id: 'Re', label: '\\Re' },
- { id: 'Bbbk', label: '\\Bbbk' },
- { id: 'cnums', label: '\\cnums' },
- { id: 'Complex', label: '\\Complex' },
- { id: 'N', label: '\\N' },
- { id: 'Z', label: '\\Z' },
- { id: 'Q', label: '\\Q' },
- { id: 'R', label: '\\R' },
- { id: 'Reals', label: '\\Reals' },
- { id: 'reals', label: '\\reals' },
+ { id: '\\imath', label: '\\imath' },
+ { id: '\\jmath', label: '\\jmath' },
+ { id: '\\nabla', label: '\\nabla' },
+ { id: '\\partial', label: '\\partial' },
+ { id: '\\aleph', label: '\\aleph' },
+ { id: '\\beth', label: '\\beth' },
+ { id: '\\gimel', label: '\\gimel' },
+ { id: '\\daleth', label: '\\daleth' },
+ { id: '\\eth', label: '\\eth' },
+ { id: '\\hbar', label: '\\hbar' },
+ { id: '\\hslash', label: '\\hslash' },
+ { id: '\\wp', label: '\\wp' },
+ { id: '\\Im', label: '\\Im' },
+ { id: '\\Re', label: '\\Re' },
+ { id: '\\Bbbk', label: '\\Bbbk' },
+ { id: '\\cnums', label: '\\cnums' },
+ { id: '\\Complex', label: '\\Complex' },
+ { id: '\\N', label: '\\N' },
+ { id: '\\Z', label: '\\Z' },
+ { id: '\\Q', label: '\\Q' },
+ { id: '\\R', label: '\\R' },
+ { id: '\\Reals', label: '\\Reals' },
+ { id: '\\reals', label: '\\reals' },
// ---------- Logic and set helpers ----------
- { id: 'Set', label: '\\Set{${0} \\mid ${1}}' },
- { id: 'set', label: '\\set{${0} \\mid ${1}}' },
+ { id: '\\Set', label: '\\Set{${0} \\mid ${1}}' },
+ { id: '\\set', label: '\\set{${0} \\mid ${1}}' },
// ---------- Macros helpers ----------
- { id: 'def', label: '\\def\\${0}{${1}}' },
- { id: 'gdef', label: '\\gdef\\${0}{${1}}' },
- { id: 'newcommand', label: '\\newcommand\\${0}[${1}]{${2}}' },
- { id: 'renewcommand', label: '\\renewcommand\\${0}[${1}]{${2}}' },
- { id: 'providecommand', label: '\\providecommand\\${0}[${1}]{${2}}' },
- { id: 'let', label: '\\let\\${0}=\\${1}' },
- { id: 'globaldef', label: '\\global\\def\\${0}{${1}}' },
+ { id: '\\def', label: '\\def\\${0}{${1}}' },
+ { id: '\\gdef', label: '\\gdef\\${0}{${1}}' },
+ { id: '\\newcommand', label: '\\newcommand\\${0}[${1}]{${2}}' },
+ { id: '\\renewcommand', label: '\\renewcommand\\${0}[${1}]{${2}}' },
+ { id: '\\providecommand', label: '\\providecommand\\${0}[${1}]{${2}}' },
+ { id: '\\let', label: '\\let\\${0}=\\${1}' },
+ { id: '\\globaldef', label: '\\global\\def\\${0}{${1}}' },
// ---------- Misc ----------
- { id: 'char', label: '\\char"${0}' },
+ { id: '\\char', label: '\\char"${0}' },
] as const;
diff --git a/frontend/app/components/MarkdownEditor/modules/editorUtils.ts b/frontend/app/components/MarkdownEditor/modules/editorUtils.ts
index b488f8b8..5c8c9acc 100644
--- a/frontend/app/components/MarkdownEditor/modules/editorUtils.ts
+++ b/frontend/app/components/MarkdownEditor/modules/editorUtils.ts
@@ -48,11 +48,12 @@ export function createSnippetSource(preferences: ReturnType<typeof import('~/com
if (!preferences.get('editorSnippetsEnabled').value) return null;
const allSnippets = preferences.get('snippets').value;
- const word = context.matchBefore(/[\w!:]+/);
- if (!word && !context.explicit) return null;
-
const inMath = isInsideMath(context);
+ // Include backslash in the match when in math mode for KaTeX commands
+ const word = inMath ? context.matchBefore(/\\?[\w!:*]+/) : context.matchBefore(/[\w!:]+/);
+ if (!word && !context.explicit) return null;
+
return {
from: word ? word.from : context.pos,
options: [