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