diff --git a/src/js/parsers/section.js b/src/js/parsers/section.js
index c8c01a824..8d3a40563 100644
--- a/src/js/parsers/section.js
+++ b/src/js/parsers/section.js
@@ -191,7 +191,12 @@ class SectionParser {
) {
// don't break out of the list for list items that contain a single
.
// deals with typical case of
Text
Text
- if (this.state.section.isListItem && tagName === 'p' && !node.nextSibling) {
+ if (
+ this.state.section.isListItem &&
+ tagName === 'p' &&
+ !node.nextSibling &&
+ contains(VALID_LIST_ITEM_TAGNAMES, normalizeTagName(node.parentElement.tagName))
+ ) {
this.parseElementNode(node);
return;
}
diff --git a/tests/unit/parsers/section-test.js b/tests/unit/parsers/section-test.js
index 497e1b368..67a58f456 100644
--- a/tests/unit/parsers/section-test.js
+++ b/tests/unit/parsers/section-test.js
@@ -396,6 +396,24 @@ test('#parse doesn\'t group consecutive lists of different types', (assert) => {
assert.equal(ol.items.objectAt(0).text, 'Two');
});
+test('#parse handles p following list', (assert) => {
+ let container = buildDOM(`
+
+ `);
+
+ let element = container.firstChild;
+ parser = new SectionParser(builder);
+ let sections = parser.parse(element);
+
+ assert.equal(sections.length, 2, 'two sections');
+
+ let ol = sections[0];
+ assert.equal(ol.items.length, 2, 'two list items');
+
+ let p = sections[1];
+ assert.equal(p.text, 'para');
+});
+
test('#parse skips STYLE nodes', (assert) => {
let element = buildDOM(`