[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/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 = "./node_modules/@wordpress/autop/build-module/index.js");
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ "./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js":
  91  /*!*******************************************************************!*\
  92    !*** ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js ***!
  93    \*******************************************************************/
  94  /*! exports provided: default */
  95  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96  
  97  "use strict";
  98  __webpack_require__.r(__webpack_exports__);
  99  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _arrayWithHoles; });
 100  function _arrayWithHoles(arr) {
 101    if (Array.isArray(arr)) return arr;
 102  }
 103  
 104  /***/ }),
 105  
 106  /***/ "./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js":
 107  /*!*************************************************************************!*\
 108    !*** ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js ***!
 109    \*************************************************************************/
 110  /*! exports provided: default */
 111  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 112  
 113  "use strict";
 114  __webpack_require__.r(__webpack_exports__);
 115  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _iterableToArrayLimit; });
 116  function _iterableToArrayLimit(arr, i) {
 117    var _arr = [];
 118    var _n = true;
 119    var _d = false;
 120    var _e = undefined;
 121  
 122    try {
 123      for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
 124        _arr.push(_s.value);
 125  
 126        if (i && _arr.length === i) break;
 127      }
 128    } catch (err) {
 129      _d = true;
 130      _e = err;
 131    } finally {
 132      try {
 133        if (!_n && _i["return"] != null) _i["return"]();
 134      } finally {
 135        if (_d) throw _e;
 136      }
 137    }
 138  
 139    return _arr;
 140  }
 141  
 142  /***/ }),
 143  
 144  /***/ "./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js":
 145  /*!********************************************************************!*\
 146    !*** ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js ***!
 147    \********************************************************************/
 148  /*! exports provided: default */
 149  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 150  
 151  "use strict";
 152  __webpack_require__.r(__webpack_exports__);
 153  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _nonIterableRest; });
 154  function _nonIterableRest() {
 155    throw new TypeError("Invalid attempt to destructure non-iterable instance");
 156  }
 157  
 158  /***/ }),
 159  
 160  /***/ "./node_modules/@babel/runtime/helpers/esm/slicedToArray.js":
 161  /*!******************************************************************!*\
 162    !*** ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js ***!
 163    \******************************************************************/
 164  /*! exports provided: default */
 165  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 166  
 167  "use strict";
 168  __webpack_require__.r(__webpack_exports__);
 169  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _slicedToArray; });
 170  /* harmony import */ var _arrayWithHoles__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arrayWithHoles */ "./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js");
 171  /* harmony import */ var _iterableToArrayLimit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./iterableToArrayLimit */ "./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js");
 172  /* harmony import */ var _nonIterableRest__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./nonIterableRest */ "./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js");
 173  
 174  
 175  
 176  function _slicedToArray(arr, i) {
 177    return Object(_arrayWithHoles__WEBPACK_IMPORTED_MODULE_0__["default"])(arr) || Object(_iterableToArrayLimit__WEBPACK_IMPORTED_MODULE_1__["default"])(arr, i) || Object(_nonIterableRest__WEBPACK_IMPORTED_MODULE_2__["default"])();
 178  }
 179  
 180  /***/ }),
 181  
 182  /***/ "./node_modules/@wordpress/autop/build-module/index.js":
 183  /*!*************************************************************!*\
 184    !*** ./node_modules/@wordpress/autop/build-module/index.js ***!
 185    \*************************************************************/
 186  /*! exports provided: autop, removep */
 187  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 188  
 189  "use strict";
 190  __webpack_require__.r(__webpack_exports__);
 191  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "autop", function() { return autop; });
 192  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removep", function() { return removep; });
 193  /* harmony import */ var _babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/slicedToArray */ "./node_modules/@babel/runtime/helpers/esm/slicedToArray.js");
 194  
 195  
 196  /**
 197   * The regular expression for an HTML element.
 198   *
 199   * @type {String}
 200   */
 201  var htmlSplitRegex = function () {
 202    /* eslint-disable no-multi-spaces */
 203    var comments = '!' + // Start of comment, after the <.
 204    '(?:' + // Unroll the loop: Consume everything until --> is found.
 205    '-(?!->)' + // Dash not followed by end of comment.
 206    '[^\\-]*' + // Consume non-dashes.
 207    ')*' + // Loop possessively.
 208    '(?:-->)?'; // End of comment. If not found, match all input.
 209  
 210    var cdata = '!\\[CDATA\\[' + // Start of comment, after the <.
 211    '[^\\]]*' + // Consume non-].
 212    '(?:' + // Unroll the loop: Consume everything until ]]> is found.
 213    '](?!]>)' + // One ] not followed by end of comment.
 214    '[^\\]]*' + // Consume non-].
 215    ')*?' + // Loop possessively.
 216    '(?:]]>)?'; // End of comment. If not found, match all input.
 217  
 218    var escaped = '(?=' + // Is the element escaped?
 219    '!--' + '|' + '!\\[CDATA\\[' + ')' + '((?=!-)' + // If yes, which type?
 220    comments + '|' + cdata + ')';
 221    var regex = '(' + // Capture the entire match.
 222    '<' + // Find start of element.
 223    '(' + // Conditional expression follows.
 224    escaped + // Find end of escaped element.
 225    '|' + // ... else ...
 226    '[^>]*>?' + // Find end of normal element.
 227    ')' + ')';
 228    return new RegExp(regex);
 229    /* eslint-enable no-multi-spaces */
 230  }();
 231  /**
 232   * Separate HTML elements and comments from the text.
 233   *
 234   * @param  {string} input The text which has to be formatted.
 235   * @return {Array}        The formatted text.
 236   */
 237  
 238  
 239  function htmlSplit(input) {
 240    var parts = [];
 241    var workingInput = input;
 242    var match;
 243  
 244    while (match = workingInput.match(htmlSplitRegex)) {
 245      parts.push(workingInput.slice(0, match.index));
 246      parts.push(match[0]);
 247      workingInput = workingInput.slice(match.index + match[0].length);
 248    }
 249  
 250    if (workingInput.length) {
 251      parts.push(workingInput);
 252    }
 253  
 254    return parts;
 255  }
 256  /**
 257   * Replace characters or phrases within HTML elements only.
 258   *
 259   * @param  {string} haystack     The text which has to be formatted.
 260   * @param  {Object} replacePairs In the form {from: 'to', ...}.
 261   * @return {string}              The formatted text.
 262   */
 263  
 264  
 265  function replaceInHtmlTags(haystack, replacePairs) {
 266    // Find all elements.
 267    var textArr = htmlSplit(haystack);
 268    var changed = false; // Extract all needles.
 269  
 270    var needles = Object.keys(replacePairs); // Loop through delimiters (elements) only.
 271  
 272    for (var i = 1; i < textArr.length; i += 2) {
 273      for (var j = 0; j < needles.length; j++) {
 274        var needle = needles[j];
 275  
 276        if (-1 !== textArr[i].indexOf(needle)) {
 277          textArr[i] = textArr[i].replace(new RegExp(needle, 'g'), replacePairs[needle]);
 278          changed = true; // After one strtr() break out of the foreach loop and look at next element.
 279  
 280          break;
 281        }
 282      }
 283    }
 284  
 285    if (changed) {
 286      haystack = textArr.join('');
 287    }
 288  
 289    return haystack;
 290  }
 291  /**
 292   * Replaces double line-breaks with paragraph elements.
 293   *
 294   * A group of regex replaces used to identify text formatted with newlines and
 295   * replace double line-breaks with HTML paragraph tags. The remaining line-
 296   * breaks after conversion become <<br />> tags, unless br is set to 'false'.
 297   *
 298   * @param  {string}    text The text which has to be formatted.
 299   * @param  {boolean}   br   Optional. If set, will convert all remaining line-
 300   *                          breaks after paragraphing. Default true.
 301   * @return {string}         Text which has been converted into paragraph tags.
 302   */
 303  
 304  
 305  function autop(text) {
 306    var br = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
 307    var preTags = [];
 308  
 309    if (text.trim() === '') {
 310      return '';
 311    } // Just to make things a little easier, pad the end.
 312  
 313  
 314    text = text + '\n';
 315    /*
 316     * Pre tags shouldn't be touched by autop.
 317     * Replace pre tags with placeholders and bring them back after autop.
 318     */
 319  
 320    if (text.indexOf('<pre') !== -1) {
 321      var textParts = text.split('</pre>');
 322      var lastText = textParts.pop();
 323      text = '';
 324  
 325      for (var i = 0; i < textParts.length; i++) {
 326        var textPart = textParts[i];
 327        var start = textPart.indexOf('<pre'); // Malformed html?
 328  
 329        if (start === -1) {
 330          text += textPart;
 331          continue;
 332        }
 333  
 334        var name = '<pre wp-pre-tag-' + i + '></pre>';
 335        preTags.push([name, textPart.substr(start) + '</pre>']);
 336        text += textPart.substr(0, start) + name;
 337      }
 338  
 339      text += lastText;
 340    } // Change multiple <br>s into two line breaks, which will turn into paragraphs.
 341  
 342  
 343    text = text.replace(/<br\s*\/?>\s*<br\s*\/?>/g, '\n\n');
 344    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.
 345  
 346    text = text.replace(new RegExp('(<' + allBlocks + '[\s\/>])', 'g'), '\n\n$1'); // Add a double line break below block-level closing tags.
 347  
 348    text = text.replace(new RegExp('(<\/' + allBlocks + '>)', 'g'), '$1\n\n'); // Standardize newline characters to "\n".
 349  
 350    text = text.replace(/\r\n|\r/g, '\n'); // Find newlines in all elements and add placeholders.
 351  
 352    text = replaceInHtmlTags(text, {
 353      '\n': ' <!-- wpnl --> '
 354    }); // Collapse line breaks before and after <option> elements so they don't get autop'd.
 355  
 356    if (text.indexOf('<option') !== -1) {
 357      text = text.replace(/\s*<option/g, '<option');
 358      text = text.replace(/<\/option>\s*/g, '</option>');
 359    }
 360    /*
 361     * Collapse line breaks inside <object> elements, before <param> and <embed> elements
 362     * so they don't get autop'd.
 363     */
 364  
 365  
 366    if (text.indexOf('</object>') !== -1) {
 367      text = text.replace(/(<object[^>]*>)\s*/g, '$1');
 368      text = text.replace(/\s*<\/object>/g, '</object>');
 369      text = text.replace(/\s*(<\/?(?:param|embed)[^>]*>)\s*/g, '$1');
 370    }
 371    /*
 372     * Collapse line breaks inside <audio> and <video> elements,
 373     * before and after <source> and <track> elements.
 374     */
 375  
 376  
 377    if (text.indexOf('<source') !== -1 || text.indexOf('<track') !== -1) {
 378      text = text.replace(/([<\[](?:audio|video)[^>\]]*[>\]])\s*/g, '$1');
 379      text = text.replace(/\s*([<\[]\/(?:audio|video)[>\]])/g, '$1');
 380      text = text.replace(/\s*(<(?:source|track)[^>]*>)\s*/g, '$1');
 381    } // Collapse line breaks before and after <figcaption> elements.
 382  
 383  
 384    if (text.indexOf('<figcaption') !== -1) {
 385      text = text.replace(/\s*(<figcaption[^>]*>)/, '$1');
 386      text = text.replace(/<\/figcaption>\s*/, '</figcaption>');
 387    } // Remove more than two contiguous line breaks.
 388  
 389  
 390    text = text.replace(/\n\n+/g, '\n\n'); // Split up the contents into an array of strings, separated by double line breaks.
 391  
 392    var texts = text.split(/\n\s*\n/).filter(Boolean); // Reset text prior to rebuilding.
 393  
 394    text = ''; // Rebuild the content as a string, wrapping every bit with a <p>.
 395  
 396    texts.forEach(function (textPiece) {
 397      text += '<p>' + textPiece.replace(/^\n*|\n*$/g, '') + '</p>\n';
 398    }); // Under certain strange conditions it could create a P of entirely whitespace.
 399  
 400    text = text.replace(/<p>\s*<\/p>/g, ''); // Add a closing <p> inside <div>, <address>, or <form> tag if missing.
 401  
 402    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.
 403  
 404    text = text.replace(new RegExp('<p>\s*(<\/?' + allBlocks + '[^>]*>)\s*<\/p>', 'g'), '$1'); // In some cases <li> may get wrapped in <p>, fix them.
 405  
 406    text = text.replace(/<p>(<li.+?)<\/p>/g, '$1'); // If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>.
 407  
 408    text = text.replace(/<p><blockquote([^>]*)>/gi, '<blockquote$1><p>');
 409    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.
 410  
 411    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.
 412  
 413    text = text.replace(new RegExp('(<\/?' + allBlocks + '[^>]*>)\s*<\/p>', 'g'), '$1'); // Optionally insert line breaks.
 414  
 415    if (br) {
 416      // Replace newlines that shouldn't be touched with a placeholder.
 417      text = text.replace(/<(script|style).*?<\/\\1>/g, function (match) {
 418        return match[0].replace(/\n/g, '<WPPreserveNewline />');
 419      }); // Normalize <br>
 420  
 421      text = text.replace(/<br>|<br\/>/g, '<br />'); // Replace any new line characters that aren't preceded by a <br /> with a <br />.
 422  
 423      text = text.replace(/(<br \/>)?\s*\n/g, function (a, b) {
 424        return b ? a : '<br />\n';
 425      }); // Replace newline placeholders with newlines.
 426  
 427      text = text.replace(/<WPPreserveNewline \/>/g, '\n');
 428    } // If a <br /> tag is after an opening or closing block tag, remove it.
 429  
 430  
 431    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.
 432  
 433    text = text.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/g, '$1');
 434    text = text.replace(/\n<\/p>$/g, '</p>'); // Replace placeholder <pre> tags with their original content.
 435  
 436    preTags.forEach(function (preTag) {
 437      var _preTag = Object(_babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__["default"])(preTag, 2),
 438          name = _preTag[0],
 439          original = _preTag[1];
 440  
 441      text = text.replace(name, original);
 442    }); // Restore newlines in all elements.
 443  
 444    if (-1 !== text.indexOf('<!-- wpnl -->')) {
 445      text = text.replace(/\s?<!-- wpnl -->\s?/g, '\n');
 446    }
 447  
 448    return text;
 449  }
 450  /**
 451   * Replaces <p> tags with two line breaks. "Opposite" of autop().
 452   *
 453   * Replaces <p> tags with two line breaks except where the <p> has attributes.
 454   * Unifies whitespace. Indents <li>, <dt> and <dd> for better readability.
 455   *
 456   * @param  {string} html The content from the editor.
 457   * @return {string}      The content with stripped paragraph tags.
 458   */
 459  
 460  function removep(html) {
 461    var blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure';
 462    var blocklist1 = blocklist + '|div|p';
 463    var blocklist2 = blocklist + '|pre';
 464    var preserve = [];
 465    var preserveLinebreaks = false;
 466    var preserveBr = false;
 467  
 468    if (!html) {
 469      return '';
 470    } // Protect script and style tags.
 471  
 472  
 473    if (html.indexOf('<script') !== -1 || html.indexOf('<style') !== -1) {
 474      html = html.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/g, function (match) {
 475        preserve.push(match);
 476        return '<wp-preserve>';
 477      });
 478    } // Protect pre tags.
 479  
 480  
 481    if (html.indexOf('<pre') !== -1) {
 482      preserveLinebreaks = true;
 483      html = html.replace(/<pre[^>]*>[\s\S]+?<\/pre>/g, function (a) {
 484        a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>');
 485        a = a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>');
 486        return a.replace(/\r?\n/g, '<wp-line-break>');
 487      });
 488    } // Remove line breaks but keep <br> tags inside image captions.
 489  
 490  
 491    if (html.indexOf('[caption') !== -1) {
 492      preserveBr = true;
 493      html = html.replace(/\[caption[\s\S]+?\[\/caption\]/g, function (a) {
 494        return a.replace(/<br([^>]*)>/g, '<wp-temp-br$1>').replace(/[\r\n\t]+/, '');
 495      });
 496    } // Normalize white space characters before and after block tags.
 497  
 498  
 499    html = html.replace(new RegExp('\\s*</(' + blocklist1 + ')>\\s*', 'g'), '</$1>\n');
 500    html = html.replace(new RegExp('\\s*<((?:' + blocklist1 + ')(?: [^>]*)?)>', 'g'), '\n<$1>'); // Mark </p> if it has any attributes.
 501  
 502    html = html.replace(/(<p [^>]+>.*?)<\/p>/g, '$1</p#>'); // Preserve the first <p> inside a <div>.
 503  
 504    html = html.replace(/<div( [^>]*)?>\s*<p>/gi, '<div$1>\n\n'); // Remove paragraph tags.
 505  
 506    html = html.replace(/\s*<p>/gi, '');
 507    html = html.replace(/\s*<\/p>\s*/gi, '\n\n'); // Normalize white space chars and remove multiple line breaks.
 508  
 509    html = html.replace(/\n[\s\u00a0]+\n/g, '\n\n'); // Replace <br> tags with line breaks.
 510  
 511    html = html.replace(/(\s*)<br ?\/?>\s*/gi, function (match, space) {
 512      if (space && space.indexOf('\n') !== -1) {
 513        return '\n\n';
 514      }
 515  
 516      return '\n';
 517    }); // Fix line breaks around <div>.
 518  
 519    html = html.replace(/\s*<div/g, '\n<div');
 520    html = html.replace(/<\/div>\s*/g, '</div>\n'); // Fix line breaks around caption shortcodes.
 521  
 522    html = html.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n');
 523    html = html.replace(/caption\]\n\n+\[caption/g, 'caption]\n\n[caption'); // Pad block elements tags with a line break.
 524  
 525    html = html.replace(new RegExp('\\s*<((?:' + blocklist2 + ')(?: [^>]*)?)\\s*>', 'g'), '\n<$1>');
 526    html = html.replace(new RegExp('\\s*</(' + blocklist2 + ')>\\s*', 'g'), '</$1>\n'); // Indent <li>, <dt> and <dd> tags.
 527  
 528    html = html.replace(/<((li|dt|dd)[^>]*)>/g, ' \t<$1>'); // Fix line breaks around <select> and <option>.
 529  
 530    if (html.indexOf('<option') !== -1) {
 531      html = html.replace(/\s*<option/g, '\n<option');
 532      html = html.replace(/\s*<\/select>/g, '\n</select>');
 533    } // Pad <hr> with two line breaks.
 534  
 535  
 536    if (html.indexOf('<hr') !== -1) {
 537      html = html.replace(/\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n');
 538    } // Remove line breaks in <object> tags.
 539  
 540  
 541    if (html.indexOf('<object') !== -1) {
 542      html = html.replace(/<object[\s\S]+?<\/object>/g, function (a) {
 543        return a.replace(/[\r\n]+/g, '');
 544      });
 545    } // Unmark special paragraph closing tags.
 546  
 547  
 548    html = html.replace(/<\/p#>/g, '</p>\n'); // Pad remaining <p> tags whit a line break.
 549  
 550    html = html.replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g, '\n$1'); // Trim.
 551  
 552    html = html.replace(/^\s+/, '');
 553    html = html.replace(/[\s\u00a0]+$/, '');
 554  
 555    if (preserveLinebreaks) {
 556      html = html.replace(/<wp-line-break>/g, '\n');
 557    }
 558  
 559    if (preserveBr) {
 560      html = html.replace(/<wp-temp-br([^>]*)>/g, '<br$1>');
 561    } // Restore preserved tags.
 562  
 563  
 564    if (preserve.length) {
 565      html = html.replace(/<wp-preserve>/g, function () {
 566        return preserve.shift();
 567      });
 568    }
 569  
 570    return html;
 571  }
 572  
 573  
 574  /***/ })
 575  
 576  /******/ });
 577  //# sourceMappingURL=autop.js.map


Generated: Mon Jan 7 01:00:05 2019 Cross-referenced by PHPXref 0.7.1