Fix: highlight not rendering in task items (#2088)
This commit is contained in:
@@ -177,6 +177,17 @@ test("Unmatched HTML tags render as literal text", () => {
|
||||
expect(html).toEqual('<span class="p">text <b>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 = {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user