wp/wp-includes/js/dist/autop.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    80 /******/ 	// __webpack_public_path__
    80 /******/ 	// __webpack_public_path__
    81 /******/ 	__webpack_require__.p = "";
    81 /******/ 	__webpack_require__.p = "";
    82 /******/
    82 /******/
    83 /******/
    83 /******/
    84 /******/ 	// Load entry module and return exports
    84 /******/ 	// Load entry module and return exports
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 283);
    85 /******/ 	return __webpack_require__(__webpack_require__.s = "zbAn");
    86 /******/ })
    86 /******/ })
    87 /************************************************************************/
    87 /************************************************************************/
    88 /******/ ({
    88 /******/ ({
    89 
    89 
    90 /***/ 14:
    90 /***/ "zbAn":
    91 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
    92 
       
    93 "use strict";
       
    94 
       
    95 // EXPORTS
       
    96 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; });
       
    97 
       
    98 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
       
    99 var arrayWithHoles = __webpack_require__(38);
       
   100 
       
   101 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
       
   102 function _iterableToArrayLimit(arr, i) {
       
   103   if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
       
   104   var _arr = [];
       
   105   var _n = true;
       
   106   var _d = false;
       
   107   var _e = undefined;
       
   108 
       
   109   try {
       
   110     for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
       
   111       _arr.push(_s.value);
       
   112 
       
   113       if (i && _arr.length === i) break;
       
   114     }
       
   115   } catch (err) {
       
   116     _d = true;
       
   117     _e = err;
       
   118   } finally {
       
   119     try {
       
   120       if (!_n && _i["return"] != null) _i["return"]();
       
   121     } finally {
       
   122       if (_d) throw _e;
       
   123     }
       
   124   }
       
   125 
       
   126   return _arr;
       
   127 }
       
   128 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
       
   129 var unsupportedIterableToArray = __webpack_require__(29);
       
   130 
       
   131 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
       
   132 var nonIterableRest = __webpack_require__(39);
       
   133 
       
   134 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
       
   135 
       
   136 
       
   137 
       
   138 
       
   139 function _slicedToArray(arr, i) {
       
   140   return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])();
       
   141 }
       
   142 
       
   143 /***/ }),
       
   144 
       
   145 /***/ 26:
       
   146 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
   147 
       
   148 "use strict";
       
   149 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
       
   150 function _arrayLikeToArray(arr, len) {
       
   151   if (len == null || len > arr.length) len = arr.length;
       
   152 
       
   153   for (var i = 0, arr2 = new Array(len); i < len; i++) {
       
   154     arr2[i] = arr[i];
       
   155   }
       
   156 
       
   157   return arr2;
       
   158 }
       
   159 
       
   160 /***/ }),
       
   161 
       
   162 /***/ 283:
       
   163 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    91 /***/ (function(module, __webpack_exports__, __webpack_require__) {
   164 
    92 
   165 "use strict";
    93 "use strict";
   166 __webpack_require__.r(__webpack_exports__);
    94 __webpack_require__.r(__webpack_exports__);
   167 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "autop", function() { return autop; });
    95 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "autop", function() { return autop; });
   168 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removep", function() { return removep; });
    96 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removep", function() { return removep; });
   169 /* harmony import */ var _babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
       
   170 
       
   171 
       
   172 /**
    97 /**
   173  * The regular expression for an HTML element.
    98  * The regular expression for an HTML element.
   174  *
    99  *
   175  * @type {RegExp}
   100  * @type {RegExp}
   176  */
   101  */
   177 var htmlSplitRegex = function () {
   102 const htmlSplitRegex = (() => {
   178   /* eslint-disable no-multi-spaces */
   103   /* eslint-disable no-multi-spaces */
   179   var comments = '!' + // Start of comment, after the <.
   104   const comments = '!' + // Start of comment, after the <.
   180   '(?:' + // Unroll the loop: Consume everything until --> is found.
   105   '(?:' + // Unroll the loop: Consume everything until --> is found.
   181   '-(?!->)' + // Dash not followed by end of comment.
   106   '-(?!->)' + // Dash not followed by end of comment.
   182   '[^\\-]*' + // Consume non-dashes.
   107   '[^\\-]*' + // Consume non-dashes.
   183   ')*' + // Loop possessively.
   108   ')*' + // Loop possessively.
   184   '(?:-->)?'; // End of comment. If not found, match all input.
   109   '(?:-->)?'; // End of comment. If not found, match all input.
   185 
   110 
   186   var cdata = '!\\[CDATA\\[' + // Start of comment, after the <.
   111   const cdata = '!\\[CDATA\\[' + // Start of comment, after the <.
   187   '[^\\]]*' + // Consume non-].
   112   '[^\\]]*' + // Consume non-].
   188   '(?:' + // Unroll the loop: Consume everything until ]]> is found.
   113   '(?:' + // Unroll the loop: Consume everything until ]]> is found.
   189   '](?!]>)' + // One ] not followed by end of comment.
   114   '](?!]>)' + // One ] not followed by end of comment.
   190   '[^\\]]*' + // Consume non-].
   115   '[^\\]]*' + // Consume non-].
   191   ')*?' + // Loop possessively.
   116   ')*?' + // Loop possessively.
   192   '(?:]]>)?'; // End of comment. If not found, match all input.
   117   '(?:]]>)?'; // End of comment. If not found, match all input.
   193 
   118 
   194   var escaped = '(?=' + // Is the element escaped?
   119   const escaped = '(?=' + // Is the element escaped?
   195   '!--' + '|' + '!\\[CDATA\\[' + ')' + '((?=!-)' + // If yes, which type?
   120   '!--' + '|' + '!\\[CDATA\\[' + ')' + '((?=!-)' + // If yes, which type?
   196   comments + '|' + cdata + ')';
   121   comments + '|' + cdata + ')';
   197   var regex = '(' + // Capture the entire match.
   122   const regex = '(' + // Capture the entire match.
   198   '<' + // Find start of element.
   123   '<' + // Find start of element.
   199   '(' + // Conditional expression follows.
   124   '(' + // Conditional expression follows.
   200   escaped + // Find end of escaped element.
   125   escaped + // Find end of escaped element.
   201   '|' + // ... else ...
   126   '|' + // ... else ...
   202   '[^>]*>?' + // Find end of normal element.
   127   '[^>]*>?' + // Find end of normal element.
   203   ')' + ')';
   128   ')' + ')';
   204   return new RegExp(regex);
   129   return new RegExp(regex);
   205   /* eslint-enable no-multi-spaces */
   130   /* eslint-enable no-multi-spaces */
   206 }();
   131 })();
   207 /**
   132 /**
   208  * Separate HTML elements and comments from the text.
   133  * Separate HTML elements and comments from the text.
   209  *
   134  *
   210  * @param  {string} input The text which has to be formatted.
   135  * @param  {string} input The text which has to be formatted.
   211  * @return {string[]}        The formatted text.
   136  * @return {string[]}        The formatted text.
   212  */
   137  */
   213 
   138 
   214 
   139 
   215 function htmlSplit(input) {
   140 function htmlSplit(input) {
   216   var parts = [];
   141   const parts = [];
   217   var workingInput = input;
   142   let workingInput = input;
   218   var match;
   143   let match;
   219 
   144 
   220   while (match = workingInput.match(htmlSplitRegex)) {
   145   while (match = workingInput.match(htmlSplitRegex)) {
   221     // The `match` result, when invoked on a RegExp with the `g` flag (`/foo/g`) will not include `index`.
   146     // The `match` result, when invoked on a RegExp with the `g` flag (`/foo/g`) will not include `index`.
   222     // If the `g` flag is omitted, `index` is included.
   147     // If the `g` flag is omitted, `index` is included.
   223     // `htmlSplitRegex` does not have the `g` flag so we can assert it will have an index number.
   148     // `htmlSplitRegex` does not have the `g` flag so we can assert it will have an index number.
   224     // Assert `match.index` is a number.
   149     // Assert `match.index` is a number.
   225     var index =
   150     const index =
   226     /** @type {number} */
   151     /** @type {number} */
   227     match.index;
   152     match.index;
   228     parts.push(workingInput.slice(0, index));
   153     parts.push(workingInput.slice(0, index));
   229     parts.push(match[0]);
   154     parts.push(match[0]);
   230     workingInput = workingInput.slice(index + match[0].length);
   155     workingInput = workingInput.slice(index + match[0].length);
   245  */
   170  */
   246 
   171 
   247 
   172 
   248 function replaceInHtmlTags(haystack, replacePairs) {
   173 function replaceInHtmlTags(haystack, replacePairs) {
   249   // Find all elements.
   174   // Find all elements.
   250   var textArr = htmlSplit(haystack);
   175   const textArr = htmlSplit(haystack);
   251   var changed = false; // Extract all needles.
   176   let changed = false; // Extract all needles.
   252 
   177 
   253   var needles = Object.keys(replacePairs); // Loop through delimiters (elements) only.
   178   const needles = Object.keys(replacePairs); // Loop through delimiters (elements) only.
   254 
   179 
   255   for (var i = 1; i < textArr.length; i += 2) {
   180   for (let i = 1; i < textArr.length; i += 2) {
   256     for (var j = 0; j < needles.length; j++) {
   181     for (let j = 0; j < needles.length; j++) {
   257       var needle = needles[j];
   182       const needle = needles[j];
   258 
   183 
   259       if (-1 !== textArr[i].indexOf(needle)) {
   184       if (-1 !== textArr[i].indexOf(needle)) {
   260         textArr[i] = textArr[i].replace(new RegExp(needle, 'g'), replacePairs[needle]);
   185         textArr[i] = textArr[i].replace(new RegExp(needle, 'g'), replacePairs[needle]);
   261         changed = true; // After one strtr() break out of the foreach loop and look at next element.
   186         changed = true; // After one strtr() break out of the foreach loop and look at next element.
   262 
   187 
   290  *
   215  *
   291  * @return {string}         Text which has been converted into paragraph tags.
   216  * @return {string}         Text which has been converted into paragraph tags.
   292  */
   217  */
   293 
   218 
   294 
   219 
   295 function autop(text) {
   220 function autop(text, br = true) {
   296   var br = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
   221   const preTags = [];
   297   var preTags = [];
       
   298 
   222 
   299   if (text.trim() === '') {
   223   if (text.trim() === '') {
   300     return '';
   224     return '';
   301   } // Just to make things a little easier, pad the end.
   225   } // Just to make things a little easier, pad the end.
   302 
   226 
   306    * Pre tags shouldn't be touched by autop.
   230    * Pre tags shouldn't be touched by autop.
   307    * Replace pre tags with placeholders and bring them back after autop.
   231    * Replace pre tags with placeholders and bring them back after autop.
   308    */
   232    */
   309 
   233 
   310   if (text.indexOf('<pre') !== -1) {
   234   if (text.indexOf('<pre') !== -1) {
   311     var textParts = text.split('</pre>');
   235     const textParts = text.split('</pre>');
   312     var lastText = textParts.pop();
   236     const lastText = textParts.pop();
   313     text = '';
   237     text = '';
   314 
   238 
   315     for (var i = 0; i < textParts.length; i++) {
   239     for (let i = 0; i < textParts.length; i++) {
   316       var textPart = textParts[i];
   240       const textPart = textParts[i];
   317       var start = textPart.indexOf('<pre'); // Malformed html?
   241       const start = textPart.indexOf('<pre'); // Malformed html?
   318 
   242 
   319       if (start === -1) {
   243       if (start === -1) {
   320         text += textPart;
   244         text += textPart;
   321         continue;
   245         continue;
   322       }
   246       }
   323 
   247 
   324       var name = '<pre wp-pre-tag-' + i + '></pre>';
   248       const name = '<pre wp-pre-tag-' + i + '></pre>';
   325       preTags.push([name, textPart.substr(start) + '</pre>']);
   249       preTags.push([name, textPart.substr(start) + '</pre>']);
   326       text += textPart.substr(0, start) + name;
   250       text += textPart.substr(0, start) + name;
   327     }
   251     }
   328 
   252 
   329     text += lastText;
   253     text += lastText;
   330   } // Change multiple <br>s into two line breaks, which will turn into paragraphs.
   254   } // Change multiple <br>s into two line breaks, which will turn into paragraphs.
   331 
   255 
   332 
   256 
   333   text = text.replace(/<br\s*\/?>\s*<br\s*\/?>/g, '\n\n');
   257   text = text.replace(/<br\s*\/?>\s*<br\s*\/?>/g, '\n\n');
   334   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.
   258   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)'; // Add a double line break above block-level opening tags.
   335 
   259 
   336   text = text.replace(new RegExp('(<' + allBlocks + '[\\s/>])', 'g'), '\n\n$1'); // Add a double line break below block-level closing tags.
   260   text = text.replace(new RegExp('(<' + allBlocks + '[\\s/>])', 'g'), '\n\n$1'); // Add a double line break below block-level closing tags.
   337 
   261 
   338   text = text.replace(new RegExp('(</' + allBlocks + '>)', 'g'), '$1\n\n'); // Standardize newline characters to "\n".
   262   text = text.replace(new RegExp('(</' + allBlocks + '>)', 'g'), '$1\n\n'); // Standardize newline characters to "\n".
   339 
   263 
   377   } // Remove more than two contiguous line breaks.
   301   } // Remove more than two contiguous line breaks.
   378 
   302 
   379 
   303 
   380   text = text.replace(/\n\n+/g, '\n\n'); // Split up the contents into an array of strings, separated by double line breaks.
   304   text = text.replace(/\n\n+/g, '\n\n'); // Split up the contents into an array of strings, separated by double line breaks.
   381 
   305 
   382   var texts = text.split(/\n\s*\n/).filter(Boolean); // Reset text prior to rebuilding.
   306   const texts = text.split(/\n\s*\n/).filter(Boolean); // Reset text prior to rebuilding.
   383 
   307 
   384   text = ''; // Rebuild the content as a string, wrapping every bit with a <p>.
   308   text = ''; // Rebuild the content as a string, wrapping every bit with a <p>.
   385 
   309 
   386   texts.forEach(function (textPiece) {
   310   texts.forEach(textPiece => {
   387     text += '<p>' + textPiece.replace(/^\n*|\n*$/g, '') + '</p>\n';
   311     text += '<p>' + textPiece.replace(/^\n*|\n*$/g, '') + '</p>\n';
   388   }); // Under certain strange conditions it could create a P of entirely whitespace.
   312   }); // Under certain strange conditions it could create a P of entirely whitespace.
   389 
   313 
   390   text = text.replace(/<p>\s*<\/p>/g, ''); // Add a closing <p> inside <div>, <address>, or <form> tag if missing.
   314   text = text.replace(/<p>\s*<\/p>/g, ''); // Add a closing <p> inside <div>, <address>, or <form> tag if missing.
   391 
   315 
   402 
   326 
   403   text = text.replace(new RegExp('(</?' + allBlocks + '[^>]*>)\\s*</p>', 'g'), '$1'); // Optionally insert line breaks.
   327   text = text.replace(new RegExp('(</?' + allBlocks + '[^>]*>)\\s*</p>', 'g'), '$1'); // Optionally insert line breaks.
   404 
   328 
   405   if (br) {
   329   if (br) {
   406     // Replace newlines that shouldn't be touched with a placeholder.
   330     // Replace newlines that shouldn't be touched with a placeholder.
   407     text = text.replace(/<(script|style).*?<\/\\1>/g, function (match) {
   331     text = text.replace(/<(script|style).*?<\/\\1>/g, match => match[0].replace(/\n/g, '<WPPreserveNewline />')); // Normalize <br>
   408       return match[0].replace(/\n/g, '<WPPreserveNewline />');
       
   409     }); // Normalize <br>
       
   410 
   332 
   411     text = text.replace(/<br>|<br\/>/g, '<br />'); // Replace any new line characters that aren't preceded by a <br /> with a <br />.
   333     text = text.replace(/<br>|<br\/>/g, '<br />'); // Replace any new line characters that aren't preceded by a <br /> with a <br />.
   412 
   334 
   413     text = text.replace(/(<br \/>)?\s*\n/g, function (a, b) {
   335     text = text.replace(/(<br \/>)?\s*\n/g, (a, b) => b ? a : '<br />\n'); // Replace newline placeholders with newlines.
   414       return b ? a : '<br />\n';
       
   415     }); // Replace newline placeholders with newlines.
       
   416 
   336 
   417     text = text.replace(/<WPPreserveNewline \/>/g, '\n');
   337     text = text.replace(/<WPPreserveNewline \/>/g, '\n');
   418   } // If a <br /> tag is after an opening or closing block tag, remove it.
   338   } // If a <br /> tag is after an opening or closing block tag, remove it.
   419 
   339 
   420 
   340 
   421   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.
   341   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.
   422 
   342 
   423   text = text.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/g, '$1');
   343   text = text.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/g, '$1');
   424   text = text.replace(/\n<\/p>$/g, '</p>'); // Replace placeholder <pre> tags with their original content.
   344   text = text.replace(/\n<\/p>$/g, '</p>'); // Replace placeholder <pre> tags with their original content.
   425 
   345 
   426   preTags.forEach(function (preTag) {
   346   preTags.forEach(preTag => {
   427     var _preTag = Object(_babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(preTag, 2),
   347     const [name, original] = preTag;
   428         name = _preTag[0],
       
   429         original = _preTag[1];
       
   430 
       
   431     text = text.replace(name, original);
   348     text = text.replace(name, original);
   432   }); // Restore newlines in all elements.
   349   }); // Restore newlines in all elements.
   433 
   350 
   434   if (-1 !== text.indexOf('<!-- wpnl -->')) {
   351   if (-1 !== text.indexOf('<!-- wpnl -->')) {
   435     text = text.replace(/\s?<!-- wpnl -->\s?/g, '\n');
   352     text = text.replace(/\s?<!-- wpnl -->\s?/g, '\n');
   453  *
   370  *
   454  * @return {string}      The content with stripped paragraph tags.
   371  * @return {string}      The content with stripped paragraph tags.
   455  */
   372  */
   456 
   373 
   457 function removep(html) {
   374 function removep(html) {
   458   var blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure';
   375   const blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure';
   459   var blocklist1 = blocklist + '|div|p';
   376   const blocklist1 = blocklist + '|div|p';
   460   var blocklist2 = blocklist + '|pre';
   377   const blocklist2 = blocklist + '|pre';
   461   /** @type {string[]} */
   378   /** @type {string[]} */
   462 
   379 
   463   var preserve = [];
   380   const preserve = [];
   464   var preserveLinebreaks = false;
   381   let preserveLinebreaks = false;
   465   var preserveBr = false;
   382   let preserveBr = false;
   466 
   383 
   467   if (!html) {
   384   if (!html) {
   468     return '';
   385     return '';
   469   } // Protect script and style tags.
   386   } // Protect script and style tags.
   470 
   387 
   471 
   388 
   472   if (html.indexOf('<script') !== -1 || html.indexOf('<style') !== -1) {
   389   if (html.indexOf('<script') !== -1 || html.indexOf('<style') !== -1) {
   473     html = html.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/g, function (match) {
   390     html = html.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/g, match => {
   474       preserve.push(match);
   391       preserve.push(match);
   475       return '<wp-preserve>';
   392       return '<wp-preserve>';
   476     });
   393     });
   477   } // Protect pre tags.
   394   } // Protect pre tags.
   478 
   395 
   479 
   396 
   480   if (html.indexOf('<pre') !== -1) {
   397   if (html.indexOf('<pre') !== -1) {
   481     preserveLinebreaks = true;
   398     preserveLinebreaks = true;
   482     html = html.replace(/<pre[^>]*>[\s\S]+?<\/pre>/g, function (a) {
   399     html = html.replace(/<pre[^>]*>[\s\S]+?<\/pre>/g, a => {
   483       a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>');
   400       a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>');
   484       a = a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>');
   401       a = a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>');
   485       return a.replace(/\r?\n/g, '<wp-line-break>');
   402       return a.replace(/\r?\n/g, '<wp-line-break>');
   486     });
   403     });
   487   } // Remove line breaks but keep <br> tags inside image captions.
   404   } // Remove line breaks but keep <br> tags inside image captions.
   488 
   405 
   489 
   406 
   490   if (html.indexOf('[caption') !== -1) {
   407   if (html.indexOf('[caption') !== -1) {
   491     preserveBr = true;
   408     preserveBr = true;
   492     html = html.replace(/\[caption[\s\S]+?\[\/caption\]/g, function (a) {
   409     html = html.replace(/\[caption[\s\S]+?\[\/caption\]/g, a => {
   493       return a.replace(/<br([^>]*)>/g, '<wp-temp-br$1>').replace(/[\r\n\t]+/, '');
   410       return a.replace(/<br([^>]*)>/g, '<wp-temp-br$1>').replace(/[\r\n\t]+/, '');
   494     });
   411     });
   495   } // Normalize white space characters before and after block tags.
   412   } // Normalize white space characters before and after block tags.
   496 
   413 
   497 
   414 
   505   html = html.replace(/\s*<p>/gi, '');
   422   html = html.replace(/\s*<p>/gi, '');
   506   html = html.replace(/\s*<\/p>\s*/gi, '\n\n'); // Normalize white space chars and remove multiple line breaks.
   423   html = html.replace(/\s*<\/p>\s*/gi, '\n\n'); // Normalize white space chars and remove multiple line breaks.
   507 
   424 
   508   html = html.replace(/\n[\s\u00a0]+\n/g, '\n\n'); // Replace <br> tags with line breaks.
   425   html = html.replace(/\n[\s\u00a0]+\n/g, '\n\n'); // Replace <br> tags with line breaks.
   509 
   426 
   510   html = html.replace(/(\s*)<br ?\/?>\s*/gi, function (_, space) {
   427   html = html.replace(/(\s*)<br ?\/?>\s*/gi, (_, space) => {
   511     if (space && space.indexOf('\n') !== -1) {
   428     if (space && space.indexOf('\n') !== -1) {
   512       return '\n\n';
   429       return '\n\n';
   513     }
   430     }
   514 
   431 
   515     return '\n';
   432     return '\n';
   536     html = html.replace(/\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n');
   453     html = html.replace(/\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n');
   537   } // Remove line breaks in <object> tags.
   454   } // Remove line breaks in <object> tags.
   538 
   455 
   539 
   456 
   540   if (html.indexOf('<object') !== -1) {
   457   if (html.indexOf('<object') !== -1) {
   541     html = html.replace(/<object[\s\S]+?<\/object>/g, function (a) {
   458     html = html.replace(/<object[\s\S]+?<\/object>/g, a => {
   542       return a.replace(/[\r\n]+/g, '');
   459       return a.replace(/[\r\n]+/g, '');
   543     });
   460     });
   544   } // Unmark special paragraph closing tags.
   461   } // Unmark special paragraph closing tags.
   545 
   462 
   546 
   463 
   559     html = html.replace(/<wp-temp-br([^>]*)>/g, '<br$1>');
   476     html = html.replace(/<wp-temp-br([^>]*)>/g, '<br$1>');
   560   } // Restore preserved tags.
   477   } // Restore preserved tags.
   561 
   478 
   562 
   479 
   563   if (preserve.length) {
   480   if (preserve.length) {
   564     html = html.replace(/<wp-preserve>/g, function () {
   481     html = html.replace(/<wp-preserve>/g, () => {
   565       return (
   482       return (
   566         /** @type {string} */
   483         /** @type {string} */
   567         preserve.shift()
   484         preserve.shift()
   568       );
   485       );
   569     });
   486     });
   571 
   488 
   572   return html;
   489   return html;
   573 }
   490 }
   574 
   491 
   575 
   492 
   576 /***/ }),
       
   577 
       
   578 /***/ 29:
       
   579 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
   580 
       
   581 "use strict";
       
   582 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
       
   583 /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26);
       
   584 
       
   585 function _unsupportedIterableToArray(o, minLen) {
       
   586   if (!o) return;
       
   587   if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
       
   588   var n = Object.prototype.toString.call(o).slice(8, -1);
       
   589   if (n === "Object" && o.constructor) n = o.constructor.name;
       
   590   if (n === "Map" || n === "Set") return Array.from(o);
       
   591   if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
       
   592 }
       
   593 
       
   594 /***/ }),
       
   595 
       
   596 /***/ 38:
       
   597 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
   598 
       
   599 "use strict";
       
   600 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
       
   601 function _arrayWithHoles(arr) {
       
   602   if (Array.isArray(arr)) return arr;
       
   603 }
       
   604 
       
   605 /***/ }),
       
   606 
       
   607 /***/ 39:
       
   608 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
   609 
       
   610 "use strict";
       
   611 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
       
   612 function _nonIterableRest() {
       
   613   throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
       
   614 }
       
   615 
       
   616 /***/ })
   493 /***/ })
   617 
   494 
   618 /******/ });
   495 /******/ });