diff --git a/src/heading.ts b/src/heading.ts index 9014b19..b6a5b0a 100644 --- a/src/heading.ts +++ b/src/heading.ts @@ -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}`; + } } diff --git a/src/plugin.ts b/src/plugin.ts index 2af4987..77094ad 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -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"); } /**