Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// close a trailing text node if it exists
if (state.text.length && state.section.isMarkerable) {
this._createMarker();
}
// push listItems onto the listSection or add a new section
if (state.section.isListItem && lastSection && lastSection.isListSection) {
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() &&
!any(state.section.markers, marker => marker.isAtom)
) {
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();
}
sections.push(state.section);
}
state.section = null;
state.text = '';
// close a trailing text node if it exists
if (state.text.length && state.section.isMarkerable) {
this._createMarker();
}
// push listItems onto the listSection or add a new section
if (state.section.isListItem && lastSection && lastSection.isListSection) {
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() &&
!any(state.section.markers, marker => marker.isAtom)
) {
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();
}
sections.push(state.section);
}
state.section = null;
state.text = '';