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