From e9f23f76aefe5dd2d2e7ac0fa37909a97d8b6f07 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 29 Jan 2018 10:51:45 +0200 Subject: [PATCH] fix: crash on 2-level md heading at the beginning --- src/services/MarkdownRenderer.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/MarkdownRenderer.ts b/src/services/MarkdownRenderer.ts index 4b51381f..491ed374 100644 --- a/src/services/MarkdownRenderer.ts +++ b/src/services/MarkdownRenderer.ts @@ -98,7 +98,10 @@ export class MarkdownRenderer { `` ); } 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 ( `` + `` +