/
githubmirror
/
marktext
Обзор
Документация
Войти
/
githubmirror
/
marktext
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/muya/src/state/__tests__/mathTrailingSpace.spec.ts
37 строк
2 KB
Ran Luo
fix(muya): allow trailing whitespace after closing $$ of a math block (#1931) (#4649)
23 июн 2026, 10:49
Не верифицирован
23 июн 2026, 10:49
b657f16
Код
Авторство
О чём код?
import { describe, expect, it } from 'vitest'; import { MarkdownToState } from '../markdownToState'; // #1931: a display-math block whose closing `$$` has trailing whitespace // (e.g. `$$ `) was not recognized as math — the block regex required the // closing marker to be immediately followed by a newline or end-of-input, so // any trailing space made it fall through to plain text. Fenced code blocks // already tolerate trailing spaces; math should too. interface IBlock { name: string; text?: string } function parse(markdown: string): IBlock[] { return new MarkdownToState({ footnote: false, math: true, isGitlabCompatibilityEnabled: false, trimUnnecessaryCodeBlockEmptyLines: false, frontMatter: false, } as never).generate(markdown) as unknown as IBlock[]; } describe('block math — closing $$ with trailing whitespace (#1931)', () => { it('parses a math block whose closing $$ has a trailing space', () => { const states = parse('$$\nx = 1\n$$ \n\nbar\n'); expect(states.some(s => s.name === 'math-block')).toBe(true); }); it('parses a math block whose closing $$ has a trailing tab', () => { const states = parse('$$\nx = 1\n$$\t\n\nbar\n'); expect(states.some(s => s.name === 'math-block')).toBe(true); }); it('still parses a math block with no trailing space (regression)', () => { const states = parse('$$\nx = 1\n$$\n\nbar\n'); expect(states.some(s => s.name === 'math-block')).toBe(true); }); });