Skip to content

Commit

Permalink
fix: crash on 2-level md heading at the beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Jan 29, 2018
1 parent 4b5df22 commit e9f23f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/services/MarkdownRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export class MarkdownRenderer {
`<a class="share-link" href="#${id}"></a>`
);
} 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 (
`<a name="${id}"></a>` +
`<h${tokens[idx].hLevel} ${SECTION_ATTR}="${id}" id="${id}">` +
Expand Down

0 comments on commit e9f23f7

Please sign in to comment.