diff --git a/src/js/parsers/section.js b/src/js/parsers/section.js index c919ada7f..2ad7a8475 100644 --- a/src/js/parsers/section.js +++ b/src/js/parsers/section.js @@ -287,6 +287,13 @@ class SectionParser { trimSectionText(state.section); lastSection.items.append(state.section); } else { + // avoid creating empty markup sections, especially useful for indented source + if (state.section.isMarkerable && !state.section.text.trim()) { + state.section = null; + state.text = ''; + return; + } + // remove empty list sections before creating a new section if (lastSection && lastSection.isListSection && lastSection.items.length === 0) { sections.pop(); diff --git a/tests/unit/parsers/section-test.js b/tests/unit/parsers/section-test.js index 4127385b8..1bd13f5f8 100644 --- a/tests/unit/parsers/section-test.js +++ b/tests/unit/parsers/section-test.js @@ -325,6 +325,29 @@ test('#parse handles insignificant whitespace', (assert) => { assert.equal(list.items.objectAt(0).text, 'One'); }); +test('#parse handles insignificant whitespace (wrapped)', (assert) => { + let container = buildDOM(` +