Create `Heading.toMarkdown` method
This commit is contained in:
parent
60b8f7e5a9
commit
4a9457efd7
|
@ -10,10 +10,14 @@ export class Heading {
|
|||
treeLevel: number,
|
||||
parent: Heading | null,
|
||||
) {
|
||||
Object.assign(this, {title, hLevel, treeLevel, parent})
|
||||
Object.assign(this, { title, hLevel, treeLevel, parent });
|
||||
}
|
||||
|
||||
getParent(hLevel: number): Heading | undefined {
|
||||
return this.hLevel < hLevel ? this : this.parent?.getParent(hLevel);
|
||||
}
|
||||
|
||||
toMarkdown(): string {
|
||||
return `${"\t".repeat(this.treeLevel)}- [ ] ${this.title}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,11 +75,7 @@ export default class OutlineTaskListPlugin extends Plugin {
|
|||
* Build the task list from the specified outline.
|
||||
*/
|
||||
static buildTasklist(outline: Outline): string {
|
||||
return outline
|
||||
.map(
|
||||
(heading) => `${"\t".repeat(heading.treeLevel)}- [ ] ${heading.title}`,
|
||||
)
|
||||
.join("\r\n");
|
||||
return outline.map((heading) => heading.toMarkdown()).join("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue