home/beautybuzzbeyond/public_html/wp-includes/js/dist/autop.js 0000604 00000037156 14720023063 0020707 0 ustar 00 /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ autop: () => (/* binding */ autop),
/* harmony export */ removep: () => (/* binding */ removep)
/* harmony export */ });
/**
* The regular expression for an HTML element.
*/
const htmlSplitRegex = (() => {
/* eslint-disable no-multi-spaces */
const comments = '!' +
// Start of comment, after the <.
'(?:' +
// Unroll the loop: Consume everything until --> is found.
'-(?!->)' +
// Dash not followed by end of comment.
'[^\\-]*' +
// Consume non-dashes.
')*' +
// Loop possessively.
'(?:-->)?'; // End of comment. If not found, match all input.
const cdata = '!\\[CDATA\\[' +
// Start of comment, after the <.
'[^\\]]*' +
// Consume non-].
'(?:' +
// Unroll the loop: Consume everything until ]]> is found.
'](?!]>)' +
// One ] not followed by end of comment.
'[^\\]]*' +
// Consume non-].
')*?' +
// Loop possessively.
'(?:]]>)?'; // End of comment. If not found, match all input.
const escaped = '(?=' +
// Is the element escaped?
'!--' + '|' + '!\\[CDATA\\[' + ')' + '((?=!-)' +
// If yes, which type?
comments + '|' + cdata + ')';
const regex = '(' +
// Capture the entire match.
'<' +
// Find start of element.
'(' +
// Conditional expression follows.
escaped +
// Find end of escaped element.
'|' +
// ... else ...
'[^>]*>?' +
// Find end of normal element.
')' + ')';
return new RegExp(regex);
/* eslint-enable no-multi-spaces */
})();
/**
* Separate HTML elements and comments from the text.
*
* @param input The text which has to be formatted.
*
* @return The formatted text.
*/
function htmlSplit(input) {
const parts = [];
let workingInput = input;
let match;
while (match = workingInput.match(htmlSplitRegex)) {
// The `match` result, when invoked on a RegExp with the `g` flag (`/foo/g`) will not include `index`.
// If the `g` flag is omitted, `index` is included.
// `htmlSplitRegex` does not have the `g` flag so we can assert it will have an index number.
// Assert `match.index` is a number.
const index = match.index;
parts.push(workingInput.slice(0, index));
parts.push(match[0]);
workingInput = workingInput.slice(index + match[0].length);
}
if (workingInput.length) {
parts.push(workingInput);
}
return parts;
}
/**
* Replace characters or phrases within HTML elements only.
*
* @param haystack The text which has to be formatted.
* @param replacePairs In the form {from: 'to', …}.
*
* @return The formatted text.
*/
function replaceInHtmlTags(haystack, replacePairs) {
// Find all elements.
const textArr = htmlSplit(haystack);
let changed = false;
// Extract all needles.
const needles = Object.keys(replacePairs);
// Loop through delimiters (elements) only.
for (let i = 1; i < textArr.length; i += 2) {
for (let j = 0; j < needles.length; j++) {
const needle = needles[j];
if (-1 !== textArr[i].indexOf(needle)) {
textArr[i] = textArr[i].replace(new RegExp(needle, 'g'), replacePairs[needle]);
changed = true;
// After one strtr() break out of the foreach loop and look at next element.
break;
}
}
}
if (changed) {
haystack = textArr.join('');
}
return haystack;
}
/**
* Replaces double line-breaks with paragraph elements.
*
* A group of regex replaces used to identify text formatted with newlines and
* replace double line-breaks with HTML paragraph tags. The remaining line-
* breaks after conversion become `
` tags, unless br is set to 'false'.
*
* @param text The text which has to be formatted.
* @param br Optional. If set, will convert all remaining line-
* breaks after paragraphing. Default true.
*
* @example
*```js
* import { autop } from '@wordpress/autop';
* autop( 'my text' ); // "
my text
" * ``` * * @return Text which has been converted into paragraph tags. */ function autop(text, br = true) { const preTags = []; if (text.trim() === '') { return ''; } // Just to make things a little easier, pad the end. text = text + '\n'; /* * Pre tags shouldn't be touched by autop. * Replace pre tags with placeholders and bring them back after autop. */ if (text.indexOf(''); const lastText = textParts.pop(); text = ''; for (let i = 0; i < textParts.length; i++) { const textPart = textParts[i]; const start = textPart.indexOf(''; preTags.push([name, textPart.substr(start) + '']); text += textPart.substr(0, start) + name; } text += lastText; } // Change multiple