fix nested taskList in markdown export (#1443)
This commit is contained in:
parent
dddfd48934
commit
b0c557272d
1 changed files with 11 additions and 2 deletions
|
|
@ -70,7 +70,16 @@ function taskList(turndownService: TurndownService) {
|
||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
const isChecked = checkbox.checked;
|
const isChecked = checkbox.checked;
|
||||||
|
|
||||||
return `- ${isChecked ? '[x]' : '[ ]'} ${content.trim()} \n`;
|
// Process content like regular list items
|
||||||
|
content = content
|
||||||
|
.replace(/^\n+/, '') // remove leading newlines
|
||||||
|
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
||||||
|
.replace(/\n/gm, '\n '); // indent nested content with 2 spaces
|
||||||
|
|
||||||
|
// Create the checkbox prefix
|
||||||
|
const prefix = `- ${isChecked ? '[x]' : '[ ]'} `;
|
||||||
|
|
||||||
|
return prefix + content + (node.nextSibling && !/\n$/.test(content) ? '\n' : '');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue