From 8daf965788a6739de09af68e9b4f88b85027e6e9 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 28 May 2026 16:37:02 -0500 Subject: [PATCH 1/2] fix math inside of color blocks --- src/app/plugins/markdown/extensions/matrix-math.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/plugins/markdown/extensions/matrix-math.ts b/src/app/plugins/markdown/extensions/matrix-math.ts index 21265f70f..26248a0b8 100644 --- a/src/app/plugins/markdown/extensions/matrix-math.ts +++ b/src/app/plugins/markdown/extensions/matrix-math.ts @@ -221,12 +221,18 @@ function isIgnorableMathContent(latex: string): boolean { * - the closing `$` is not preceded by whitespace, and * - the closing `$` is not immediately followed by an ASCII digit. */ +/** Opening `$[fg.color=…]` / `$[bg.color=…]` */ +const MFM_COLOR_FN_OPEN = /^\$\[(?:fg|bg)\.color=/; + function tryTokenizeInlineMath( src: string ): { type: 'math'; raw: string; latex: string } | undefined { if (!src.startsWith('$')) { return undefined; } + if (MFM_COLOR_FN_OPEN.test(src)) { + return undefined; + } if (src.startsWith('$$') && (src.length < 3 || src.charAt(2) !== '$')) { return undefined; } @@ -256,7 +262,7 @@ export const matrixMathExtension = { name: 'math', level: 'inline', start(src: string) { - if (/^\$\[(?:fg|bg)\.color=/.test(src)) return -1; + if (MFM_COLOR_FN_OPEN.test(src)) return -1; return src.indexOf('$'); }, tokenizer(src: string) { From b706cb9ed3f00a6ee8715846c5d7b56f1a481216 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 28 May 2026 17:41:06 -0500 Subject: [PATCH 2/2] changeset --- .changeset/fix-math-in-color.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-math-in-color.md diff --git a/.changeset/fix-math-in-color.md b/.changeset/fix-math-in-color.md new file mode 100644 index 000000000..cb09b6eeb --- /dev/null +++ b/.changeset/fix-math-in-color.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix math parsing inside of color blocks not being parsed properly.