fix: crash on 2-level md heading at the beginning

This commit is contained in:
Roman Hotsiy 2018-01-29 10:51:45 +02:00
parent 4b5df22fa0
commit e9f23f76ae
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -98,7 +98,10 @@ export class MarkdownRenderer {
`<a class="share-link" href="#${id}"></a>` `<a class="share-link" href="#${id}"></a>`
); );
} else if (tokens[idx].hLevel === 2) { } else if (tokens[idx].hLevel === 2) {
const { id } = this.saveHeading(content, this.currentTopHeading.items); const { id } = this.saveHeading(
content,
this.currentTopHeading && this.currentTopHeading.items,
);
return ( return (
`<a name="${id}"></a>` + `<a name="${id}"></a>` +
`<h${tokens[idx].hLevel} ${SECTION_ATTR}="${id}" id="${id}">` + `<h${tokens[idx].hLevel} ${SECTION_ATTR}="${id}" id="${id}">` +