[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> autop.js (source)

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


Generated : Tue May 18 08:20:01 2021 Cross-referenced by PHPXref