Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: autop.js
/******/ (() => { // webpackBootstrap
[0] Fix | Delete
/******/ "use strict";
[1] Fix | Delete
/******/ // The require scope
[2] Fix | Delete
/******/ var __webpack_require__ = {};
[3] Fix | Delete
/******/
[4] Fix | Delete
/************************************************************************/
[5] Fix | Delete
/******/ /* webpack/runtime/define property getters */
[6] Fix | Delete
/******/ (() => {
[7] Fix | Delete
/******/ // define getter functions for harmony exports
[8] Fix | Delete
/******/ __webpack_require__.d = (exports, definition) => {
[9] Fix | Delete
/******/ for(var key in definition) {
[10] Fix | Delete
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
[11] Fix | Delete
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
[12] Fix | Delete
/******/ }
[13] Fix | Delete
/******/ }
[14] Fix | Delete
/******/ };
[15] Fix | Delete
/******/ })();
[16] Fix | Delete
/******/
[17] Fix | Delete
/******/ /* webpack/runtime/hasOwnProperty shorthand */
[18] Fix | Delete
/******/ (() => {
[19] Fix | Delete
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
[20] Fix | Delete
/******/ })();
[21] Fix | Delete
/******/
[22] Fix | Delete
/******/ /* webpack/runtime/make namespace object */
[23] Fix | Delete
/******/ (() => {
[24] Fix | Delete
/******/ // define __esModule on exports
[25] Fix | Delete
/******/ __webpack_require__.r = (exports) => {
[26] Fix | Delete
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
[27] Fix | Delete
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
[28] Fix | Delete
/******/ }
[29] Fix | Delete
/******/ Object.defineProperty(exports, '__esModule', { value: true });
[30] Fix | Delete
/******/ };
[31] Fix | Delete
/******/ })();
[32] Fix | Delete
/******/
[33] Fix | Delete
/************************************************************************/
[34] Fix | Delete
var __webpack_exports__ = {};
[35] Fix | Delete
__webpack_require__.r(__webpack_exports__);
[36] Fix | Delete
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
[37] Fix | Delete
/* harmony export */ autop: () => (/* binding */ autop),
[38] Fix | Delete
/* harmony export */ removep: () => (/* binding */ removep)
[39] Fix | Delete
/* harmony export */ });
[40] Fix | Delete
/**
[41] Fix | Delete
* The regular expression for an HTML element.
[42] Fix | Delete
*
[43] Fix | Delete
* @type {RegExp}
[44] Fix | Delete
*/
[45] Fix | Delete
const htmlSplitRegex = (() => {
[46] Fix | Delete
/* eslint-disable no-multi-spaces */
[47] Fix | Delete
const comments = '!' +
[48] Fix | Delete
// Start of comment, after the <.
[49] Fix | Delete
'(?:' +
[50] Fix | Delete
// Unroll the loop: Consume everything until --> is found.
[51] Fix | Delete
'-(?!->)' +
[52] Fix | Delete
// Dash not followed by end of comment.
[53] Fix | Delete
'[^\\-]*' +
[54] Fix | Delete
// Consume non-dashes.
[55] Fix | Delete
')*' +
[56] Fix | Delete
// Loop possessively.
[57] Fix | Delete
'(?:-->)?'; // End of comment. If not found, match all input.
[58] Fix | Delete
[59] Fix | Delete
const cdata = '!\\[CDATA\\[' +
[60] Fix | Delete
// Start of comment, after the <.
[61] Fix | Delete
'[^\\]]*' +
[62] Fix | Delete
// Consume non-].
[63] Fix | Delete
'(?:' +
[64] Fix | Delete
// Unroll the loop: Consume everything until ]]> is found.
[65] Fix | Delete
'](?!]>)' +
[66] Fix | Delete
// One ] not followed by end of comment.
[67] Fix | Delete
'[^\\]]*' +
[68] Fix | Delete
// Consume non-].
[69] Fix | Delete
')*?' +
[70] Fix | Delete
// Loop possessively.
[71] Fix | Delete
'(?:]]>)?'; // End of comment. If not found, match all input.
[72] Fix | Delete
[73] Fix | Delete
const escaped = '(?=' +
[74] Fix | Delete
// Is the element escaped?
[75] Fix | Delete
'!--' + '|' + '!\\[CDATA\\[' + ')' + '((?=!-)' +
[76] Fix | Delete
// If yes, which type?
[77] Fix | Delete
comments + '|' + cdata + ')';
[78] Fix | Delete
const regex = '(' +
[79] Fix | Delete
// Capture the entire match.
[80] Fix | Delete
'<' +
[81] Fix | Delete
// Find start of element.
[82] Fix | Delete
'(' +
[83] Fix | Delete
// Conditional expression follows.
[84] Fix | Delete
escaped +
[85] Fix | Delete
// Find end of escaped element.
[86] Fix | Delete
'|' +
[87] Fix | Delete
// ... else ...
[88] Fix | Delete
'[^>]*>?' +
[89] Fix | Delete
// Find end of normal element.
[90] Fix | Delete
')' + ')';
[91] Fix | Delete
return new RegExp(regex);
[92] Fix | Delete
/* eslint-enable no-multi-spaces */
[93] Fix | Delete
})();
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Separate HTML elements and comments from the text.
[97] Fix | Delete
*
[98] Fix | Delete
* @param {string} input The text which has to be formatted.
[99] Fix | Delete
*
[100] Fix | Delete
* @return {string[]} The formatted text.
[101] Fix | Delete
*/
[102] Fix | Delete
function htmlSplit(input) {
[103] Fix | Delete
const parts = [];
[104] Fix | Delete
let workingInput = input;
[105] Fix | Delete
let match;
[106] Fix | Delete
while (match = workingInput.match(htmlSplitRegex)) {
[107] Fix | Delete
// The `match` result, when invoked on a RegExp with the `g` flag (`/foo/g`) will not include `index`.
[108] Fix | Delete
// If the `g` flag is omitted, `index` is included.
[109] Fix | Delete
// `htmlSplitRegex` does not have the `g` flag so we can assert it will have an index number.
[110] Fix | Delete
// Assert `match.index` is a number.
[111] Fix | Delete
const index = /** @type {number} */match.index;
[112] Fix | Delete
parts.push(workingInput.slice(0, index));
[113] Fix | Delete
parts.push(match[0]);
[114] Fix | Delete
workingInput = workingInput.slice(index + match[0].length);
[115] Fix | Delete
}
[116] Fix | Delete
if (workingInput.length) {
[117] Fix | Delete
parts.push(workingInput);
[118] Fix | Delete
}
[119] Fix | Delete
return parts;
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
/**
[123] Fix | Delete
* Replace characters or phrases within HTML elements only.
[124] Fix | Delete
*
[125] Fix | Delete
* @param {string} haystack The text which has to be formatted.
[126] Fix | Delete
* @param {Record<string,string>} replacePairs In the form {from: 'to', …}.
[127] Fix | Delete
*
[128] Fix | Delete
* @return {string} The formatted text.
[129] Fix | Delete
*/
[130] Fix | Delete
function replaceInHtmlTags(haystack, replacePairs) {
[131] Fix | Delete
// Find all elements.
[132] Fix | Delete
const textArr = htmlSplit(haystack);
[133] Fix | Delete
let changed = false;
[134] Fix | Delete
[135] Fix | Delete
// Extract all needles.
[136] Fix | Delete
const needles = Object.keys(replacePairs);
[137] Fix | Delete
[138] Fix | Delete
// Loop through delimiters (elements) only.
[139] Fix | Delete
for (let i = 1; i < textArr.length; i += 2) {
[140] Fix | Delete
for (let j = 0; j < needles.length; j++) {
[141] Fix | Delete
const needle = needles[j];
[142] Fix | Delete
if (-1 !== textArr[i].indexOf(needle)) {
[143] Fix | Delete
textArr[i] = textArr[i].replace(new RegExp(needle, 'g'), replacePairs[needle]);
[144] Fix | Delete
changed = true;
[145] Fix | Delete
// After one strtr() break out of the foreach loop and look at next element.
[146] Fix | Delete
break;
[147] Fix | Delete
}
[148] Fix | Delete
}
[149] Fix | Delete
}
[150] Fix | Delete
if (changed) {
[151] Fix | Delete
haystack = textArr.join('');
[152] Fix | Delete
}
[153] Fix | Delete
return haystack;
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
/**
[157] Fix | Delete
* Replaces double line-breaks with paragraph elements.
[158] Fix | Delete
*
[159] Fix | Delete
* A group of regex replaces used to identify text formatted with newlines and
[160] Fix | Delete
* replace double line-breaks with HTML paragraph tags. The remaining line-
[161] Fix | Delete
* breaks after conversion become `<br />` tags, unless br is set to 'false'.
[162] Fix | Delete
*
[163] Fix | Delete
* @param {string} text The text which has to be formatted.
[164] Fix | Delete
* @param {boolean} br Optional. If set, will convert all remaining line-
[165] Fix | Delete
* breaks after paragraphing. Default true.
[166] Fix | Delete
*
[167] Fix | Delete
* @example
[168] Fix | Delete
*```js
[169] Fix | Delete
* import { autop } from '@wordpress/autop';
[170] Fix | Delete
* autop( 'my text' ); // "<p>my text</p>"
[171] Fix | Delete
* ```
[172] Fix | Delete
*
[173] Fix | Delete
* @return {string} Text which has been converted into paragraph tags.
[174] Fix | Delete
*/
[175] Fix | Delete
function autop(text, br = true) {
[176] Fix | Delete
const preTags = [];
[177] Fix | Delete
if (text.trim() === '') {
[178] Fix | Delete
return '';
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
// Just to make things a little easier, pad the end.
[182] Fix | Delete
text = text + '\n';
[183] Fix | Delete
[184] Fix | Delete
/*
[185] Fix | Delete
* Pre tags shouldn't be touched by autop.
[186] Fix | Delete
* Replace pre tags with placeholders and bring them back after autop.
[187] Fix | Delete
*/
[188] Fix | Delete
if (text.indexOf('<pre') !== -1) {
[189] Fix | Delete
const textParts = text.split('</pre>');
[190] Fix | Delete
const lastText = textParts.pop();
[191] Fix | Delete
text = '';
[192] Fix | Delete
for (let i = 0; i < textParts.length; i++) {
[193] Fix | Delete
const textPart = textParts[i];
[194] Fix | Delete
const start = textPart.indexOf('<pre');
[195] Fix | Delete
[196] Fix | Delete
// Malformed html?
[197] Fix | Delete
if (start === -1) {
[198] Fix | Delete
text += textPart;
[199] Fix | Delete
continue;
[200] Fix | Delete
}
[201] Fix | Delete
const name = '<pre wp-pre-tag-' + i + '></pre>';
[202] Fix | Delete
preTags.push([name, textPart.substr(start) + '</pre>']);
[203] Fix | Delete
text += textPart.substr(0, start) + name;
[204] Fix | Delete
}
[205] Fix | Delete
text += lastText;
[206] Fix | Delete
}
[207] Fix | Delete
// Change multiple <br>s into two line breaks, which will turn into paragraphs.
[208] Fix | Delete
text = text.replace(/<br\s*\/?>\s*<br\s*\/?>/g, '\n\n');
[209] Fix | Delete
const allBlocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
[210] Fix | Delete
[211] Fix | Delete
// Add a double line break above block-level opening tags.
[212] Fix | Delete
text = text.replace(new RegExp('(<' + allBlocks + '[\\s/>])', 'g'), '\n\n$1');
[213] Fix | Delete
[214] Fix | Delete
// Add a double line break below block-level closing tags.
[215] Fix | Delete
text = text.replace(new RegExp('(</' + allBlocks + '>)', 'g'), '$1\n\n');
[216] Fix | Delete
[217] Fix | Delete
// Standardize newline characters to "\n".
[218] Fix | Delete
text = text.replace(/\r\n|\r/g, '\n');
[219] Fix | Delete
[220] Fix | Delete
// Find newlines in all elements and add placeholders.
[221] Fix | Delete
text = replaceInHtmlTags(text, {
[222] Fix | Delete
'\n': ' <!-- wpnl --> '
[223] Fix | Delete
});
[224] Fix | Delete
[225] Fix | Delete
// Collapse line breaks before and after <option> elements so they don't get autop'd.
[226] Fix | Delete
if (text.indexOf('<option') !== -1) {
[227] Fix | Delete
text = text.replace(/\s*<option/g, '<option');
[228] Fix | Delete
text = text.replace(/<\/option>\s*/g, '</option>');
[229] Fix | Delete
}
[230] Fix | Delete
[231] Fix | Delete
/*
[232] Fix | Delete
* Collapse line breaks inside <object> elements, before <param> and <embed> elements
[233] Fix | Delete
* so they don't get autop'd.
[234] Fix | Delete
*/
[235] Fix | Delete
if (text.indexOf('</object>') !== -1) {
[236] Fix | Delete
text = text.replace(/(<object[^>]*>)\s*/g, '$1');
[237] Fix | Delete
text = text.replace(/\s*<\/object>/g, '</object>');
[238] Fix | Delete
text = text.replace(/\s*(<\/?(?:param|embed)[^>]*>)\s*/g, '$1');
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
/*
[242] Fix | Delete
* Collapse line breaks inside <audio> and <video> elements,
[243] Fix | Delete
* before and after <source> and <track> elements.
[244] Fix | Delete
*/
[245] Fix | Delete
if (text.indexOf('<source') !== -1 || text.indexOf('<track') !== -1) {
[246] Fix | Delete
text = text.replace(/([<\[](?:audio|video)[^>\]]*[>\]])\s*/g, '$1');
[247] Fix | Delete
text = text.replace(/\s*([<\[]\/(?:audio|video)[>\]])/g, '$1');
[248] Fix | Delete
text = text.replace(/\s*(<(?:source|track)[^>]*>)\s*/g, '$1');
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
// Collapse line breaks before and after <figcaption> elements.
[252] Fix | Delete
if (text.indexOf('<figcaption') !== -1) {
[253] Fix | Delete
text = text.replace(/\s*(<figcaption[^>]*>)/, '$1');
[254] Fix | Delete
text = text.replace(/<\/figcaption>\s*/, '</figcaption>');
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
// Remove more than two contiguous line breaks.
[258] Fix | Delete
text = text.replace(/\n\n+/g, '\n\n');
[259] Fix | Delete
[260] Fix | Delete
// Split up the contents into an array of strings, separated by double line breaks.
[261] Fix | Delete
const texts = text.split(/\n\s*\n/).filter(Boolean);
[262] Fix | Delete
[263] Fix | Delete
// Reset text prior to rebuilding.
[264] Fix | Delete
text = '';
[265] Fix | Delete
[266] Fix | Delete
// Rebuild the content as a string, wrapping every bit with a <p>.
[267] Fix | Delete
texts.forEach(textPiece => {
[268] Fix | Delete
text += '<p>' + textPiece.replace(/^\n*|\n*$/g, '') + '</p>\n';
[269] Fix | Delete
});
[270] Fix | Delete
[271] Fix | Delete
// Under certain strange conditions it could create a P of entirely whitespace.
[272] Fix | Delete
text = text.replace(/<p>\s*<\/p>/g, '');
[273] Fix | Delete
[274] Fix | Delete
// Add a closing <p> inside <div>, <address>, or <form> tag if missing.
[275] Fix | Delete
text = text.replace(/<p>([^<]+)<\/(div|address|form)>/g, '<p>$1</p></$2>');
[276] Fix | Delete
[277] Fix | Delete
// If an opening or closing block element tag is wrapped in a <p>, unwrap it.
[278] Fix | Delete
text = text.replace(new RegExp('<p>\\s*(</?' + allBlocks + '[^>]*>)\\s*</p>', 'g'), '$1');
[279] Fix | Delete
[280] Fix | Delete
// In some cases <li> may get wrapped in <p>, fix them.
[281] Fix | Delete
text = text.replace(/<p>(<li.+?)<\/p>/g, '$1');
[282] Fix | Delete
[283] Fix | Delete
// If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>.
[284] Fix | Delete
text = text.replace(/<p><blockquote([^>]*)>/gi, '<blockquote$1><p>');
[285] Fix | Delete
text = text.replace(/<\/blockquote><\/p>/g, '</p></blockquote>');
[286] Fix | Delete
[287] Fix | Delete
// If an opening or closing block element tag is preceded by an opening <p> tag, remove it.
[288] Fix | Delete
text = text.replace(new RegExp('<p>\\s*(</?' + allBlocks + '[^>]*>)', 'g'), '$1');
[289] Fix | Delete
[290] Fix | Delete
// If an opening or closing block element tag is followed by a closing <p> tag, remove it.
[291] Fix | Delete
text = text.replace(new RegExp('(</?' + allBlocks + '[^>]*>)\\s*</p>', 'g'), '$1');
[292] Fix | Delete
[293] Fix | Delete
// Optionally insert line breaks.
[294] Fix | Delete
if (br) {
[295] Fix | Delete
// Replace newlines that shouldn't be touched with a placeholder.
[296] Fix | Delete
text = text.replace(/<(script|style).*?<\/\\1>/g, match => match[0].replace(/\n/g, '<WPPreserveNewline />'));
[297] Fix | Delete
[298] Fix | Delete
// Normalize <br>
[299] Fix | Delete
text = text.replace(/<br>|<br\/>/g, '<br />');
[300] Fix | Delete
[301] Fix | Delete
// Replace any new line characters that aren't preceded by a <br /> with a <br />.
[302] Fix | Delete
text = text.replace(/(<br \/>)?\s*\n/g, (a, b) => b ? a : '<br />\n');
[303] Fix | Delete
[304] Fix | Delete
// Replace newline placeholders with newlines.
[305] Fix | Delete
text = text.replace(/<WPPreserveNewline \/>/g, '\n');
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
// If a <br /> tag is after an opening or closing block tag, remove it.
[309] Fix | Delete
text = text.replace(new RegExp('(</?' + allBlocks + '[^>]*>)\\s*<br />', 'g'), '$1');
[310] Fix | Delete
[311] Fix | Delete
// If a <br /> tag is before a subset of opening or closing block tags, remove it.
[312] Fix | Delete
text = text.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/g, '$1');
[313] Fix | Delete
text = text.replace(/\n<\/p>$/g, '</p>');
[314] Fix | Delete
[315] Fix | Delete
// Replace placeholder <pre> tags with their original content.
[316] Fix | Delete
preTags.forEach(preTag => {
[317] Fix | Delete
const [name, original] = preTag;
[318] Fix | Delete
text = text.replace(name, original);
[319] Fix | Delete
});
[320] Fix | Delete
[321] Fix | Delete
// Restore newlines in all elements.
[322] Fix | Delete
if (-1 !== text.indexOf('<!-- wpnl -->')) {
[323] Fix | Delete
text = text.replace(/\s?<!-- wpnl -->\s?/g, '\n');
[324] Fix | Delete
}
[325] Fix | Delete
return text;
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
/**
[329] Fix | Delete
* Replaces `<p>` tags with two line breaks. "Opposite" of autop().
[330] Fix | Delete
*
[331] Fix | Delete
* Replaces `<p>` tags with two line breaks except where the `<p>` has attributes.
[332] Fix | Delete
* Unifies whitespace. Indents `<li>`, `<dt>` and `<dd>` for better readability.
[333] Fix | Delete
*
[334] Fix | Delete
* @param {string} html The content from the editor.
[335] Fix | Delete
*
[336] Fix | Delete
* @example
[337] Fix | Delete
* ```js
[338] Fix | Delete
* import { removep } from '@wordpress/autop';
[339] Fix | Delete
* removep( '<p>my text</p>' ); // "my text"
[340] Fix | Delete
* ```
[341] Fix | Delete
*
[342] Fix | Delete
* @return {string} The content with stripped paragraph tags.
[343] Fix | Delete
*/
[344] Fix | Delete
function removep(html) {
[345] Fix | Delete
const blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure';
[346] Fix | Delete
const blocklist1 = blocklist + '|div|p';
[347] Fix | Delete
const blocklist2 = blocklist + '|pre';
[348] Fix | Delete
/** @type {string[]} */
[349] Fix | Delete
const preserve = [];
[350] Fix | Delete
let preserveLinebreaks = false;
[351] Fix | Delete
let preserveBr = false;
[352] Fix | Delete
if (!html) {
[353] Fix | Delete
return '';
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
// Protect script and style tags.
[357] Fix | Delete
if (html.indexOf('<script') !== -1 || html.indexOf('<style') !== -1) {
[358] Fix | Delete
html = html.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/g, match => {
[359] Fix | Delete
preserve.push(match);
[360] Fix | Delete
return '<wp-preserve>';
[361] Fix | Delete
});
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
// Protect pre tags.
[365] Fix | Delete
if (html.indexOf('<pre') !== -1) {
[366] Fix | Delete
preserveLinebreaks = true;
[367] Fix | Delete
html = html.replace(/<pre[^>]*>[\s\S]+?<\/pre>/g, a => {
[368] Fix | Delete
a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>');
[369] Fix | Delete
a = a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>');
[370] Fix | Delete
return a.replace(/\r?\n/g, '<wp-line-break>');
[371] Fix | Delete
});
[372] Fix | Delete
}
[373] Fix | Delete
[374] Fix | Delete
// Remove line breaks but keep <br> tags inside image captions.
[375] Fix | Delete
if (html.indexOf('[caption') !== -1) {
[376] Fix | Delete
preserveBr = true;
[377] Fix | Delete
html = html.replace(/\[caption[\s\S]+?\[\/caption\]/g, a => {
[378] Fix | Delete
return a.replace(/<br([^>]*)>/g, '<wp-temp-br$1>').replace(/[\r\n\t]+/, '');
[379] Fix | Delete
});
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
// Normalize white space characters before and after block tags.
[383] Fix | Delete
html = html.replace(new RegExp('\\s*</(' + blocklist1 + ')>\\s*', 'g'), '</$1>\n');
[384] Fix | Delete
html = html.replace(new RegExp('\\s*<((?:' + blocklist1 + ')(?: [^>]*)?)>', 'g'), '\n<$1>');
[385] Fix | Delete
[386] Fix | Delete
// Mark </p> if it has any attributes.
[387] Fix | Delete
html = html.replace(/(<p [^>]+>[\s\S]*?)<\/p>/g, '$1</p#>');
[388] Fix | Delete
[389] Fix | Delete
// Preserve the first <p> inside a <div>.
[390] Fix | Delete
html = html.replace(/<div( [^>]*)?>\s*<p>/gi, '<div$1>\n\n');
[391] Fix | Delete
[392] Fix | Delete
// Remove paragraph tags.
[393] Fix | Delete
html = html.replace(/\s*<p>/gi, '');
[394] Fix | Delete
html = html.replace(/\s*<\/p>\s*/gi, '\n\n');
[395] Fix | Delete
[396] Fix | Delete
// Normalize white space chars and remove multiple line breaks.
[397] Fix | Delete
html = html.replace(/\n[\s\u00a0]+\n/g, '\n\n');
[398] Fix | Delete
[399] Fix | Delete
// Replace <br> tags with line breaks.
[400] Fix | Delete
html = html.replace(/(\s*)<br ?\/?>\s*/gi, (_, space) => {
[401] Fix | Delete
if (space && space.indexOf('\n') !== -1) {
[402] Fix | Delete
return '\n\n';
[403] Fix | Delete
}
[404] Fix | Delete
return '\n';
[405] Fix | Delete
});
[406] Fix | Delete
[407] Fix | Delete
// Fix line breaks around <div>.
[408] Fix | Delete
html = html.replace(/\s*<div/g, '\n<div');
[409] Fix | Delete
html = html.replace(/<\/div>\s*/g, '</div>\n');
[410] Fix | Delete
[411] Fix | Delete
// Fix line breaks around caption shortcodes.
[412] Fix | Delete
html = html.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n');
[413] Fix | Delete
html = html.replace(/caption\]\n\n+\[caption/g, 'caption]\n\n[caption');
[414] Fix | Delete
[415] Fix | Delete
// Pad block elements tags with a line break.
[416] Fix | Delete
html = html.replace(new RegExp('\\s*<((?:' + blocklist2 + ')(?: [^>]*)?)\\s*>', 'g'), '\n<$1>');
[417] Fix | Delete
html = html.replace(new RegExp('\\s*</(' + blocklist2 + ')>\\s*', 'g'), '</$1>\n');
[418] Fix | Delete
[419] Fix | Delete
// Indent <li>, <dt> and <dd> tags.
[420] Fix | Delete
html = html.replace(/<((li|dt|dd)[^>]*)>/g, ' \t<$1>');
[421] Fix | Delete
[422] Fix | Delete
// Fix line breaks around <select> and <option>.
[423] Fix | Delete
if (html.indexOf('<option') !== -1) {
[424] Fix | Delete
html = html.replace(/\s*<option/g, '\n<option');
[425] Fix | Delete
html = html.replace(/\s*<\/select>/g, '\n</select>');
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
// Pad <hr> with two line breaks.
[429] Fix | Delete
if (html.indexOf('<hr') !== -1) {
[430] Fix | Delete
html = html.replace(/\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n');
[431] Fix | Delete
}
[432] Fix | Delete
[433] Fix | Delete
// Remove line breaks in <object> tags.
[434] Fix | Delete
if (html.indexOf('<object') !== -1) {
[435] Fix | Delete
html = html.replace(/<object[\s\S]+?<\/object>/g, a => {
[436] Fix | Delete
return a.replace(/[\r\n]+/g, '');
[437] Fix | Delete
});
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
// Unmark special paragraph closing tags.
[441] Fix | Delete
html = html.replace(/<\/p#>/g, '</p>\n');
[442] Fix | Delete
[443] Fix | Delete
// Pad remaining <p> tags whit a line break.
[444] Fix | Delete
html = html.replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g, '\n$1');
[445] Fix | Delete
[446] Fix | Delete
// Trim.
[447] Fix | Delete
html = html.replace(/^\s+/, '');
[448] Fix | Delete
html = html.replace(/[\s\u00a0]+$/, '');
[449] Fix | Delete
if (preserveLinebreaks) {
[450] Fix | Delete
html = html.replace(/<wp-line-break>/g, '\n');
[451] Fix | Delete
}
[452] Fix | Delete
if (preserveBr) {
[453] Fix | Delete
html = html.replace(/<wp-temp-br([^>]*)>/g, '<br$1>');
[454] Fix | Delete
}
[455] Fix | Delete
[456] Fix | Delete
// Restore preserved tags.
[457] Fix | Delete
if (preserve.length) {
[458] Fix | Delete
html = html.replace(/<wp-preserve>/g, () => {
[459] Fix | Delete
return /** @type {string} */preserve.shift();
[460] Fix | Delete
});
[461] Fix | Delete
}
[462] Fix | Delete
return html;
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
(window.wp = window.wp || {}).autop = __webpack_exports__;
[466] Fix | Delete
/******/ })()
[467] Fix | Delete
;
[468] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function