Fix: highlight not rendering in task items (#2088)

This commit is contained in:
Sviatoslav Kokurin
2026-08-11 09:14:17 +02:00
committed by GitHub
parent e34d6edb3c
commit 411a6c3ad2
2 changed files with 18 additions and 2 deletions
@@ -177,6 +177,17 @@ test("Unmatched HTML tags render as literal text", () => {
expect(html).toEqual('<span class="p">text &lt;b&gt;unclosed</span>');
});
test("Inline HTML renders inside task items", () => {
const tree = parse(
extendedMarkdownLanguage,
"* [ ] <mark>highlighted</mark> task",
);
const html = renderMarkdownToHtml(tree, { failOnUnknown: true });
expect(html).toEqual(
'<ul><li><span class="sb-task"><input type="checkbox" data-state=" "> <mark>highlighted</mark> task</span></li></ul>',
);
});
test("CustomSyntaxRenderedHtml renders raw HTML", () => {
// Directly test the renderer with a synthetic parse tree
const tree = {
+7 -2
View File
@@ -259,7 +259,7 @@ function render(t: ParseTree, options: MarkdownRenderOptions = {}): Tag | null {
return {
name: "span",
attrs: {
class: "highlight",
class: "sb-highlight",
},
body: cleanTags(mapRender(t.children!)),
};
@@ -453,6 +453,7 @@ function render(t: ParseTree, options: MarkdownRenderOptions = {}): Tag | null {
}
});
const hasHtml = t.children!.some((c) => c.type === "HTMLTag");
return {
name: "span",
attrs: {
@@ -461,7 +462,11 @@ function render(t: ParseTree, options: MarkdownRenderOptions = {}): Tag | null {
? { "data-external-task-ref": externalTaskRef }
: {}),
},
body: cleanTags(mapRender(t.children!)),
body: cleanTags(
hasHtml
? groupInlineHtml(t.children!, options, posPreservingRender)
: mapRender(t.children!),
),
};
}
case "TaskState": {