Skip to content

Commit 218d370

Browse files
committed
2 parents b745128 + 0f5dead commit 218d370

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎src/cm/supportedModes.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ function createLanguageLoader(name: string, lang: LanguageDescription) {
7272
return javascript({ jsx: true });
7373
};
7474

75+
case "markdown":
76+
return async () => {
77+
const { markdown, markdownLanguage } = await import(
78+
"@codemirror/lang-markdown"
79+
);
80+
return markdown({ base: markdownLanguage });
81+
};
82+
7583
case "html":
7684
return async () => {
7785
const { html } = await import("@codemirror/lang-html");

‎tests/unit/modelist.test.js‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,30 @@ function registerTestMode(name, extensions, options) {
147147
}
148148

149149
describe("getModeForPath", () => {
150+
it("loads Markdown with extended GFM syntax", async () => {
151+
const markdownMode = getModeForPath("README.md");
152+
const loadMarkdown = markdownMode.getExtension();
153+
expect(loadMarkdown).toEqual(expect.any(Function));
154+
155+
const support = await loadMarkdown();
156+
const tree = support.language.parser.parse(
157+
[
158+
"~~Strikethrough~~",
159+
"",
160+
"- [x] Completed task",
161+
"",
162+
"| Column 1 | Column 2 |",
163+
"|----------|----------|",
164+
"| A | B |",
165+
].join("\n"),
166+
);
167+
const syntax = tree.toString();
168+
169+
expect(syntax).toContain("Strikethrough");
170+
expect(syntax).toContain("TaskMarker");
171+
expect(syntax).toContain("Table");
172+
});
173+
150174
it("matches the previous sort-and-scan result for built-in modes", () => {
151175
const paths = collectParityPaths();
152176
expect(paths.length).toBeGreaterThan(100);

0 commit comments

Comments
 (0)