This commit is contained in:
Zef Hemel
2026-04-14 07:57:26 +02:00
parent f46196adcf
commit 628fbb3ed3
2 changed files with 40 additions and 4 deletions
+32
View File
@@ -72,3 +72,35 @@ test("Test item indexing", async () => {
expect(items[8].links).toEqual(["link 2"]);
expect(new Set(items[8].ilinks)).toEqual(new Set(["link", "link 2"]));
});
// Regression test for https://github.com/silverbulletmd/silverbullet/issues/1932
// and https://github.com/silverbulletmd/silverbullet/issues/1903
const nestedListMd = `
* 1. Foobar
* Regular item
- 2. second
- - nested bullet
- * mixed markers
* - reverse mixed
`;
test("Test item indexing with nested lists in list items", async () => {
createMockSystem();
const tree = parseMarkdown(nestedListMd);
const frontmatter = extractFrontMatter(tree);
const pageMeta: PageMeta = {
ref: "test",
name: "test",
tag: "page",
created: "",
lastModified: "",
perm: "rw",
};
// Should not throw an error
const items = await indexItems(pageMeta, frontmatter, tree);
expect(items.length).toBeGreaterThan(0);
// The regular item should still be indexed correctly
const regularItem = items.find((i) => i.name === "Regular item");
expect(regularItem).toBeDefined();
});
+8 -4
View File
@@ -143,10 +143,14 @@ export function extractItemFromNode(
item.text = renderToText(nameNode).trim();
const nameNodeClone = cloneTree(nameNode!);
cleanTags(nameNodeClone);
cleanAttributes(nameNodeClone);
item.name = renderToText(nameNodeClone).trim();
if (nameNode) {
const nameNodeClone = cloneTree(nameNode);
cleanTags(nameNodeClone);
cleanAttributes(nameNodeClone);
item.name = renderToText(nameNodeClone).trim();
} else {
item.name = item.text;
}
if (tags.length > 0) {
item.tags = tags;