mimamo / source /third_party /llama.cpp-1.0.0 /tools /ui /tests /unit /markdown-syntax.test.ts
Yakimask's picture
Upload 4178 files
89565fe verified
Raw History Blame Contribute Delete
698 Bytes
import { markdownLanguage } from '@codemirror/lang-markdown';
import { LanguageSupport } from '@codemirror/language';
import { EditorState } from '@codemirror/state';
import { codeRanges } from '$lib/components/app/content/MarkdownEditor/markdown-syntax';
import { describe, expect, it } from 'vitest';
function stateOf(doc: string): EditorState {
return EditorState.create({ doc, extensions: new LanguageSupport(markdownLanguage) });
}
describe('codeRanges', () => {
it('lists inline code and code blocks in range', () => {
const doc = 'a `b` c\n\n~~~\nd\n~~~';
const state = stateOf(doc);
expect(codeRanges(state, 0, doc.length)).toEqual([
[2, 5],
[9, doc.length]
]);
});
});