fix(lint): 修复 Biome 检查错误
- mermaid-renderer/src/index.ts: import 与后续语句间补空行(organizeImports) - tiptap-editor footnote.test.ts: 局部 unescape 重命名为 unescapeFootnote, 避免遮蔽全局 restricted name(noShadowRestrictedNames)
This commit is contained in:
parent
db74a96de1
commit
644db48d17
@ -5,6 +5,7 @@
|
||||
// 直接赋给 window.MermaidRenderer 作为构建时副作用,使 window.MermaidRenderer
|
||||
// 本身即 mermaid API(initialize/render)。
|
||||
import mermaid from 'mermaid';
|
||||
|
||||
// 构建时副作用:把 mermaid 挂到全局。ES module 的顶层赋值会被 vite 保留。
|
||||
(globalThis as unknown as { MermaidRenderer: typeof mermaid }).MermaidRenderer = mermaid;
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ import { beforeEach, describe, expect, it } from 'vitest';
|
||||
*/
|
||||
|
||||
const UNESCAPE_RE = /\\\[\^([^\n\\]*?)\\\]/g;
|
||||
const unescape = (md: string) => md.replace(UNESCAPE_RE, '[^$1]');
|
||||
const unescapeFootnote = (md: string) => md.replace(UNESCAPE_RE, '[^$1]');
|
||||
|
||||
function makeEditor() {
|
||||
return new Editor({
|
||||
@ -41,31 +41,31 @@ describe('脚注语法 - escapeMarkdownSyntax 破坏与修复', () => {
|
||||
});
|
||||
|
||||
it('unescape 正则还原脚注引用 \\[^1\\] → [^1]', () => {
|
||||
expect(unescape('\\[^1\\]')).toBe('[^1]');
|
||||
expect(unescapeFootnote('\\[^1\\]')).toBe('[^1]');
|
||||
});
|
||||
|
||||
it('unescape 正则还原含空格的脚注 label', () => {
|
||||
expect(unescape('\\[^my note\\]')).toBe('[^my note]');
|
||||
expect(unescapeFootnote('\\[^my note\\]')).toBe('[^my note]');
|
||||
});
|
||||
|
||||
it('unescape 正则还原脚注定义 \\[^1\\]: → [^1]:', () => {
|
||||
expect(unescape('\\[^1\\]: 定义内容')).toBe('[^1]: 定义内容');
|
||||
expect(unescapeFootnote('\\[^1\\]: 定义内容')).toBe('[^1]: 定义内容');
|
||||
});
|
||||
|
||||
it('unescape 正则不影响普通链接 [text](url)', () => {
|
||||
const md = '\\[text\\](https://example.com)';
|
||||
// 普通链接的 \[text\] 不以 ^ 开头,不会被误改
|
||||
expect(unescape(md)).toBe(md);
|
||||
expect(unescapeFootnote(md)).toBe(md);
|
||||
});
|
||||
|
||||
it('unescape 正则一次处理多个脚注引用', () => {
|
||||
const md = '引用了\\[^1\\]和\\[^pc\\]和\\[^2\\]';
|
||||
expect(unescape(md)).toBe('引用了[^1]和[^pc]和[^2]');
|
||||
expect(unescapeFootnote(md)).toBe('引用了[^1]和[^pc]和[^2]');
|
||||
});
|
||||
|
||||
it('完整往返:unescape(getMarkdown()) 保留脚注引用语法', () => {
|
||||
editor.commands.setContent('正文[^1]', { contentType: 'markdown' });
|
||||
const fixed = unescape(editor.getMarkdown());
|
||||
const fixed = unescapeFootnote(editor.getMarkdown());
|
||||
expect(fixed).toContain('[^1]');
|
||||
expect(fixed).not.toContain('\\[^1\\]');
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user