Skip to content

Commit e9f23f7

Browse files
committed
fix: crash on 2-level md heading at the beginning
1 parent 4b5df22 commit e9f23f7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/services/MarkdownRenderer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ export class MarkdownRenderer {
9898
`<a class="share-link" href="#${id}"></a>`
9999
);
100100
} else if (tokens[idx].hLevel === 2) {
101-
const { id } = this.saveHeading(content, this.currentTopHeading.items);
101+
const { id } = this.saveHeading(
102+
content,
103+
this.currentTopHeading && this.currentTopHeading.items,
104+
);
102105
return (
103106
`<a name="${id}"></a>` +
104107
`<h${tokens[idx].hLevel} ${SECTION_ATTR}="${id}" id="${id}">` +

0 commit comments

Comments
 (0)