]*)>/gi, '');
text = text.replace(/<\/blockquote><\/p>/g, '
'); // If an opening or closing block element tag is preceded by an opening tag, remove it.
text = text.replace(new RegExp('
\s*(<\/?' + allBlocks + '[^>]*>)', 'g'), '$1'); // If an opening or closing block element tag is followed by a closing
tag, remove it.
text = text.replace(new RegExp('(<\/?' + allBlocks + '[^>]*>)\s*<\/p>', 'g'), '$1'); // Optionally insert line breaks.
if (br) {
// Replace newlines that shouldn't be touched with a placeholder.
text = text.replace(/<(script|style).*?<\/\\1>/g, function (match) {
return match[0].replace(/\n/g, '');
}); // Normalize
text = text.replace(/
|
/g, '
'); // Replace any new line characters that aren't preceded by a
with a
.
text = text.replace(/(
)?\s*\n/g, function (a, b) {
return b ? a : '
\n';
}); // Replace newline placeholders with newlines.
text = text.replace(//g, '\n');
} // If a
tag is after an opening or closing block tag, remove it.
text = text.replace(new RegExp('(<\/?' + allBlocks + '[^>]*>)\s*
', 'g'), '$1'); // If a
tag is before a subset of opening or closing block tags, remove it.
text = text.replace(/
(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/g, '$1');
text = text.replace(/\n<\/p>$/g, '
'); // Replace placeholder tags with their original content.
preTags.forEach(function (preTag) {
var _preTag = Object(_babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(preTag, 2),
name = _preTag[0],
original = _preTag[1];
text = text.replace(name, original);
}); // Restore newlines in all elements.
if (-1 !== text.indexOf('')) {
text = text.replace(/\s?\s?/g, '\n');
}
return text;
}
/**
* Replaces tags with two line breaks. "Opposite" of autop().
*
* Replaces
tags with two line breaks except where the
has attributes.
* Unifies whitespace. Indents
, and for better readability.
*
* @param {string} html The content from the editor.
* @return {string} The content with stripped paragraph tags.
*/
function removep(html) {
var blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure';
var blocklist1 = blocklist + '|div|p';
var blocklist2 = blocklist + '|pre';
var preserve = [];
var preserveLinebreaks = false;
var preserveBr = false;
if (!html) {
return '';
} // Protect script and style tags.
if (html.indexOf('