Edit File by line
/home/zeestwma/richards.../wp-inclu.../js/dist
File: shortcode.js
/******/ (() => { // webpackBootstrap
[0] Fix | Delete
/******/ "use strict";
[1] Fix | Delete
/******/ // The require scope
[2] Fix | Delete
/******/ var __webpack_require__ = {};
[3] Fix | Delete
/******/
[4] Fix | Delete
/************************************************************************/
[5] Fix | Delete
/******/ /* webpack/runtime/define property getters */
[6] Fix | Delete
/******/ (() => {
[7] Fix | Delete
/******/ // define getter functions for harmony exports
[8] Fix | Delete
/******/ __webpack_require__.d = (exports, definition) => {
[9] Fix | Delete
/******/ for(var key in definition) {
[10] Fix | Delete
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
[11] Fix | Delete
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
[12] Fix | Delete
/******/ }
[13] Fix | Delete
/******/ }
[14] Fix | Delete
/******/ };
[15] Fix | Delete
/******/ })();
[16] Fix | Delete
/******/
[17] Fix | Delete
/******/ /* webpack/runtime/hasOwnProperty shorthand */
[18] Fix | Delete
/******/ (() => {
[19] Fix | Delete
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
[20] Fix | Delete
/******/ })();
[21] Fix | Delete
/******/
[22] Fix | Delete
/************************************************************************/
[23] Fix | Delete
var __webpack_exports__ = {};
[24] Fix | Delete
[25] Fix | Delete
// EXPORTS
[26] Fix | Delete
__webpack_require__.d(__webpack_exports__, {
[27] Fix | Delete
"default": () => (/* binding */ build_module)
[28] Fix | Delete
});
[29] Fix | Delete
[30] Fix | Delete
// UNUSED EXPORTS: attrs, fromMatch, next, regexp, replace, string
[31] Fix | Delete
[32] Fix | Delete
;// ./node_modules/memize/dist/index.js
[33] Fix | Delete
/**
[34] Fix | Delete
* Memize options object.
[35] Fix | Delete
*
[36] Fix | Delete
* @typedef MemizeOptions
[37] Fix | Delete
*
[38] Fix | Delete
* @property {number} [maxSize] Maximum size of the cache.
[39] Fix | Delete
*/
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Internal cache entry.
[43] Fix | Delete
*
[44] Fix | Delete
* @typedef MemizeCacheNode
[45] Fix | Delete
*
[46] Fix | Delete
* @property {?MemizeCacheNode|undefined} [prev] Previous node.
[47] Fix | Delete
* @property {?MemizeCacheNode|undefined} [next] Next node.
[48] Fix | Delete
* @property {Array<*>} args Function arguments for cache
[49] Fix | Delete
* entry.
[50] Fix | Delete
* @property {*} val Function result.
[51] Fix | Delete
*/
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* Properties of the enhanced function for controlling cache.
[55] Fix | Delete
*
[56] Fix | Delete
* @typedef MemizeMemoizedFunction
[57] Fix | Delete
*
[58] Fix | Delete
* @property {()=>void} clear Clear the cache.
[59] Fix | Delete
*/
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Accepts a function to be memoized, and returns a new memoized function, with
[63] Fix | Delete
* optional options.
[64] Fix | Delete
*
[65] Fix | Delete
* @template {(...args: any[]) => any} F
[66] Fix | Delete
*
[67] Fix | Delete
* @param {F} fn Function to memoize.
[68] Fix | Delete
* @param {MemizeOptions} [options] Options object.
[69] Fix | Delete
*
[70] Fix | Delete
* @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.
[71] Fix | Delete
*/
[72] Fix | Delete
function memize(fn, options) {
[73] Fix | Delete
var size = 0;
[74] Fix | Delete
[75] Fix | Delete
/** @type {?MemizeCacheNode|undefined} */
[76] Fix | Delete
var head;
[77] Fix | Delete
[78] Fix | Delete
/** @type {?MemizeCacheNode|undefined} */
[79] Fix | Delete
var tail;
[80] Fix | Delete
[81] Fix | Delete
options = options || {};
[82] Fix | Delete
[83] Fix | Delete
function memoized(/* ...args */) {
[84] Fix | Delete
var node = head,
[85] Fix | Delete
len = arguments.length,
[86] Fix | Delete
args,
[87] Fix | Delete
i;
[88] Fix | Delete
[89] Fix | Delete
searchCache: while (node) {
[90] Fix | Delete
// Perform a shallow equality test to confirm that whether the node
[91] Fix | Delete
// under test is a candidate for the arguments passed. Two arrays
[92] Fix | Delete
// are shallowly equal if their length matches and each entry is
[93] Fix | Delete
// strictly equal between the two sets. Avoid abstracting to a
[94] Fix | Delete
// function which could incur an arguments leaking deoptimization.
[95] Fix | Delete
[96] Fix | Delete
// Check whether node arguments match arguments length
[97] Fix | Delete
if (node.args.length !== arguments.length) {
[98] Fix | Delete
node = node.next;
[99] Fix | Delete
continue;
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
// Check whether node arguments match arguments values
[103] Fix | Delete
for (i = 0; i < len; i++) {
[104] Fix | Delete
if (node.args[i] !== arguments[i]) {
[105] Fix | Delete
node = node.next;
[106] Fix | Delete
continue searchCache;
[107] Fix | Delete
}
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
// At this point we can assume we've found a match
[111] Fix | Delete
[112] Fix | Delete
// Surface matched node to head if not already
[113] Fix | Delete
if (node !== head) {
[114] Fix | Delete
// As tail, shift to previous. Must only shift if not also
[115] Fix | Delete
// head, since if both head and tail, there is no previous.
[116] Fix | Delete
if (node === tail) {
[117] Fix | Delete
tail = node.prev;
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
// Adjust siblings to point to each other. If node was tail,
[121] Fix | Delete
// this also handles new tail's empty `next` assignment.
[122] Fix | Delete
/** @type {MemizeCacheNode} */ (node.prev).next = node.next;
[123] Fix | Delete
if (node.next) {
[124] Fix | Delete
node.next.prev = node.prev;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
node.next = head;
[128] Fix | Delete
node.prev = null;
[129] Fix | Delete
/** @type {MemizeCacheNode} */ (head).prev = node;
[130] Fix | Delete
head = node;
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
// Return immediately
[134] Fix | Delete
return node.val;
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
// No cached value found. Continue to insertion phase:
[138] Fix | Delete
[139] Fix | Delete
// Create a copy of arguments (avoid leaking deoptimization)
[140] Fix | Delete
args = new Array(len);
[141] Fix | Delete
for (i = 0; i < len; i++) {
[142] Fix | Delete
args[i] = arguments[i];
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
node = {
[146] Fix | Delete
args: args,
[147] Fix | Delete
[148] Fix | Delete
// Generate the result from original function
[149] Fix | Delete
val: fn.apply(null, args),
[150] Fix | Delete
};
[151] Fix | Delete
[152] Fix | Delete
// Don't need to check whether node is already head, since it would
[153] Fix | Delete
// have been returned above already if it was
[154] Fix | Delete
[155] Fix | Delete
// Shift existing head down list
[156] Fix | Delete
if (head) {
[157] Fix | Delete
head.prev = node;
[158] Fix | Delete
node.next = head;
[159] Fix | Delete
} else {
[160] Fix | Delete
// If no head, follows that there's no tail (at initial or reset)
[161] Fix | Delete
tail = node;
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
// Trim tail if we're reached max size and are pending cache insertion
[165] Fix | Delete
if (size === /** @type {MemizeOptions} */ (options).maxSize) {
[166] Fix | Delete
tail = /** @type {MemizeCacheNode} */ (tail).prev;
[167] Fix | Delete
/** @type {MemizeCacheNode} */ (tail).next = null;
[168] Fix | Delete
} else {
[169] Fix | Delete
size++;
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
head = node;
[173] Fix | Delete
[174] Fix | Delete
return node.val;
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
memoized.clear = function () {
[178] Fix | Delete
head = null;
[179] Fix | Delete
tail = null;
[180] Fix | Delete
size = 0;
[181] Fix | Delete
};
[182] Fix | Delete
[183] Fix | Delete
// Ignore reason: There's not a clear solution to create an intersection of
[184] Fix | Delete
// the function with additional properties, where the goal is to retain the
[185] Fix | Delete
// function signature of the incoming argument and add control properties
[186] Fix | Delete
// on the return value.
[187] Fix | Delete
[188] Fix | Delete
// @ts-ignore
[189] Fix | Delete
return memoized;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
[193] Fix | Delete
[194] Fix | Delete
;// ./node_modules/@wordpress/shortcode/build-module/index.js
[195] Fix | Delete
/**
[196] Fix | Delete
* External dependencies
[197] Fix | Delete
*/
[198] Fix | Delete
[199] Fix | Delete
[200] Fix | Delete
[201] Fix | Delete
/**
[202] Fix | Delete
* Find the next matching shortcode.
[203] Fix | Delete
*
[204] Fix | Delete
* @param {string} tag Shortcode tag.
[205] Fix | Delete
* @param {string} text Text to search.
[206] Fix | Delete
* @param {number} index Index to start search from.
[207] Fix | Delete
*
[208] Fix | Delete
* @return {import('./types').ShortcodeMatch | undefined} Matched information.
[209] Fix | Delete
*/
[210] Fix | Delete
function next(tag, text, index = 0) {
[211] Fix | Delete
const re = regexp(tag);
[212] Fix | Delete
re.lastIndex = index;
[213] Fix | Delete
const match = re.exec(text);
[214] Fix | Delete
if (!match) {
[215] Fix | Delete
return;
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
// If we matched an escaped shortcode, try again.
[219] Fix | Delete
if ('[' === match[1] && ']' === match[7]) {
[220] Fix | Delete
return next(tag, text, re.lastIndex);
[221] Fix | Delete
}
[222] Fix | Delete
const result = {
[223] Fix | Delete
index: match.index,
[224] Fix | Delete
content: match[0],
[225] Fix | Delete
shortcode: fromMatch(match)
[226] Fix | Delete
};
[227] Fix | Delete
[228] Fix | Delete
// If we matched a leading `[`, strip it from the match and increment the
[229] Fix | Delete
// index accordingly.
[230] Fix | Delete
if (match[1]) {
[231] Fix | Delete
result.content = result.content.slice(1);
[232] Fix | Delete
result.index++;
[233] Fix | Delete
}
[234] Fix | Delete
[235] Fix | Delete
// If we matched a trailing `]`, strip it from the match.
[236] Fix | Delete
if (match[7]) {
[237] Fix | Delete
result.content = result.content.slice(0, -1);
[238] Fix | Delete
}
[239] Fix | Delete
return result;
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
/**
[243] Fix | Delete
* Replace matching shortcodes in a block of text.
[244] Fix | Delete
*
[245] Fix | Delete
* @param {string} tag Shortcode tag.
[246] Fix | Delete
* @param {string} text Text to search.
[247] Fix | Delete
* @param {import('./types').ReplaceCallback} callback Function to process the match and return
[248] Fix | Delete
* replacement string.
[249] Fix | Delete
*
[250] Fix | Delete
* @return {string} Text with shortcodes replaced.
[251] Fix | Delete
*/
[252] Fix | Delete
function replace(tag, text, callback) {
[253] Fix | Delete
return text.replace(regexp(tag), function (match, left, $3, attrs, slash, content, closing, right) {
[254] Fix | Delete
// If both extra brackets exist, the shortcode has been properly
[255] Fix | Delete
// escaped.
[256] Fix | Delete
if (left === '[' && right === ']') {
[257] Fix | Delete
return match;
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
// Create the match object and pass it through the callback.
[261] Fix | Delete
const result = callback(fromMatch(arguments));
[262] Fix | Delete
[263] Fix | Delete
// Make sure to return any of the extra brackets if they weren't used to
[264] Fix | Delete
// escape the shortcode.
[265] Fix | Delete
return result || result === '' ? left + result + right : match;
[266] Fix | Delete
});
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
/**
[270] Fix | Delete
* Generate a string from shortcode parameters.
[271] Fix | Delete
*
[272] Fix | Delete
* Creates a shortcode instance and returns a string.
[273] Fix | Delete
*
[274] Fix | Delete
* Accepts the same `options` as the `shortcode()` constructor, containing a
[275] Fix | Delete
* `tag` string, a string or object of `attrs`, a boolean indicating whether to
[276] Fix | Delete
* format the shortcode using a `single` tag, and a `content` string.
[277] Fix | Delete
*
[278] Fix | Delete
* @param {Object} options
[279] Fix | Delete
*
[280] Fix | Delete
* @return {string} String representation of the shortcode.
[281] Fix | Delete
*/
[282] Fix | Delete
function string(options) {
[283] Fix | Delete
return new shortcode(options).string();
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
/**
[287] Fix | Delete
* Generate a RegExp to identify a shortcode.
[288] Fix | Delete
*
[289] Fix | Delete
* The base regex is functionally equivalent to the one found in
[290] Fix | Delete
* `get_shortcode_regex()` in `wp-includes/shortcodes.php`.
[291] Fix | Delete
*
[292] Fix | Delete
* Capture groups:
[293] Fix | Delete
*
[294] Fix | Delete
* 1. An extra `[` to allow for escaping shortcodes with double `[[]]`
[295] Fix | Delete
* 2. The shortcode name
[296] Fix | Delete
* 3. The shortcode argument list
[297] Fix | Delete
* 4. The self closing `/`
[298] Fix | Delete
* 5. The content of a shortcode when it wraps some content.
[299] Fix | Delete
* 6. The closing tag.
[300] Fix | Delete
* 7. An extra `]` to allow for escaping shortcodes with double `[[]]`
[301] Fix | Delete
*
[302] Fix | Delete
* @param {string} tag Shortcode tag.
[303] Fix | Delete
*
[304] Fix | Delete
* @return {RegExp} Shortcode RegExp.
[305] Fix | Delete
*/
[306] Fix | Delete
function regexp(tag) {
[307] Fix | Delete
return new RegExp('\\[(\\[?)(' + tag + ')(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)', 'g');
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
/**
[311] Fix | Delete
* Parse shortcode attributes.
[312] Fix | Delete
*
[313] Fix | Delete
* Shortcodes accept many types of attributes. These can chiefly be divided into
[314] Fix | Delete
* named and numeric attributes:
[315] Fix | Delete
*
[316] Fix | Delete
* Named attributes are assigned on a key/value basis, while numeric attributes
[317] Fix | Delete
* are treated as an array.
[318] Fix | Delete
*
[319] Fix | Delete
* Named attributes can be formatted as either `name="value"`, `name='value'`,
[320] Fix | Delete
* or `name=value`. Numeric attributes can be formatted as `"value"` or just
[321] Fix | Delete
* `value`.
[322] Fix | Delete
*
[323] Fix | Delete
* @param {string} text Serialised shortcode attributes.
[324] Fix | Delete
*
[325] Fix | Delete
* @return {import('./types').ShortcodeAttrs} Parsed shortcode attributes.
[326] Fix | Delete
*/
[327] Fix | Delete
const attrs = memize(text => {
[328] Fix | Delete
const named = {};
[329] Fix | Delete
const numeric = [];
[330] Fix | Delete
[331] Fix | Delete
// This regular expression is reused from `shortcode_parse_atts()` in
[332] Fix | Delete
// `wp-includes/shortcodes.php`.
[333] Fix | Delete
//
[334] Fix | Delete
// Capture groups:
[335] Fix | Delete
//
[336] Fix | Delete
// 1. An attribute name, that corresponds to...
[337] Fix | Delete
// 2. a value in double quotes.
[338] Fix | Delete
// 3. An attribute name, that corresponds to...
[339] Fix | Delete
// 4. a value in single quotes.
[340] Fix | Delete
// 5. An attribute name, that corresponds to...
[341] Fix | Delete
// 6. an unquoted value.
[342] Fix | Delete
// 7. A numeric attribute in double quotes.
[343] Fix | Delete
// 8. A numeric attribute in single quotes.
[344] Fix | Delete
// 9. An unquoted numeric attribute.
[345] Fix | Delete
const pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g;
[346] Fix | Delete
[347] Fix | Delete
// Map zero-width spaces to actual spaces.
[348] Fix | Delete
text = text.replace(/[\u00a0\u200b]/g, ' ');
[349] Fix | Delete
let match;
[350] Fix | Delete
[351] Fix | Delete
// Match and normalize attributes.
[352] Fix | Delete
while (match = pattern.exec(text)) {
[353] Fix | Delete
if (match[1]) {
[354] Fix | Delete
named[match[1].toLowerCase()] = match[2];
[355] Fix | Delete
} else if (match[3]) {
[356] Fix | Delete
named[match[3].toLowerCase()] = match[4];
[357] Fix | Delete
} else if (match[5]) {
[358] Fix | Delete
named[match[5].toLowerCase()] = match[6];
[359] Fix | Delete
} else if (match[7]) {
[360] Fix | Delete
numeric.push(match[7]);
[361] Fix | Delete
} else if (match[8]) {
[362] Fix | Delete
numeric.push(match[8]);
[363] Fix | Delete
} else if (match[9]) {
[364] Fix | Delete
numeric.push(match[9]);
[365] Fix | Delete
}
[366] Fix | Delete
}
[367] Fix | Delete
return {
[368] Fix | Delete
named,
[369] Fix | Delete
numeric
[370] Fix | Delete
};
[371] Fix | Delete
});
[372] Fix | Delete
[373] Fix | Delete
/**
[374] Fix | Delete
* Generate a Shortcode Object from a RegExp match.
[375] Fix | Delete
*
[376] Fix | Delete
* Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated
[377] Fix | Delete
* by `regexp()`. `match` can also be set to the `arguments` from a callback
[378] Fix | Delete
* passed to `regexp.replace()`.
[379] Fix | Delete
*
[380] Fix | Delete
* @param {import('./types').Match} match Match array.
[381] Fix | Delete
*
[382] Fix | Delete
* @return {InstanceType<import('./types').shortcode>} Shortcode instance.
[383] Fix | Delete
*/
[384] Fix | Delete
function fromMatch(match) {
[385] Fix | Delete
let type;
[386] Fix | Delete
if (match[4]) {
[387] Fix | Delete
type = 'self-closing';
[388] Fix | Delete
} else if (match[6]) {
[389] Fix | Delete
type = 'closed';
[390] Fix | Delete
} else {
[391] Fix | Delete
type = 'single';
[392] Fix | Delete
}
[393] Fix | Delete
return new shortcode({
[394] Fix | Delete
tag: match[2],
[395] Fix | Delete
attrs: match[3],
[396] Fix | Delete
type,
[397] Fix | Delete
content: match[5]
[398] Fix | Delete
});
[399] Fix | Delete
}
[400] Fix | Delete
[401] Fix | Delete
/**
[402] Fix | Delete
* Creates a shortcode instance.
[403] Fix | Delete
*
[404] Fix | Delete
* To access a raw representation of a shortcode, pass an `options` object,
[405] Fix | Delete
* containing a `tag` string, a string or object of `attrs`, a string indicating
[406] Fix | Delete
* the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a
[407] Fix | Delete
* `content` string.
[408] Fix | Delete
*
[409] Fix | Delete
* @type {import('./types').shortcode} Shortcode instance.
[410] Fix | Delete
*/
[411] Fix | Delete
const shortcode = Object.assign(function (options) {
[412] Fix | Delete
const {
[413] Fix | Delete
tag,
[414] Fix | Delete
attrs: attributes,
[415] Fix | Delete
type,
[416] Fix | Delete
content
[417] Fix | Delete
} = options || {};
[418] Fix | Delete
Object.assign(this, {
[419] Fix | Delete
tag,
[420] Fix | Delete
type,
[421] Fix | Delete
content
[422] Fix | Delete
});
[423] Fix | Delete
[424] Fix | Delete
// Ensure we have a correctly formatted `attrs` object.
[425] Fix | Delete
this.attrs = {
[426] Fix | Delete
named: {},
[427] Fix | Delete
numeric: []
[428] Fix | Delete
};
[429] Fix | Delete
if (!attributes) {
[430] Fix | Delete
return;
[431] Fix | Delete
}
[432] Fix | Delete
const attributeTypes = ['named', 'numeric'];
[433] Fix | Delete
[434] Fix | Delete
// Parse a string of attributes.
[435] Fix | Delete
if (typeof attributes === 'string') {
[436] Fix | Delete
this.attrs = attrs(attributes);
[437] Fix | Delete
// Identify a correctly formatted `attrs` object.
[438] Fix | Delete
} else if (attributes.length === attributeTypes.length && attributeTypes.every((t, key) => t === attributes[key])) {
[439] Fix | Delete
this.attrs = attributes;
[440] Fix | Delete
// Handle a flat object of attributes.
[441] Fix | Delete
} else {
[442] Fix | Delete
Object.entries(attributes).forEach(([key, value]) => {
[443] Fix | Delete
this.set(key, value);
[444] Fix | Delete
});
[445] Fix | Delete
}
[446] Fix | Delete
}, {
[447] Fix | Delete
next,
[448] Fix | Delete
replace,
[449] Fix | Delete
string,
[450] Fix | Delete
regexp,
[451] Fix | Delete
attrs,
[452] Fix | Delete
fromMatch
[453] Fix | Delete
});
[454] Fix | Delete
Object.assign(shortcode.prototype, {
[455] Fix | Delete
/**
[456] Fix | Delete
* Get a shortcode attribute.
[457] Fix | Delete
*
[458] Fix | Delete
* Automatically detects whether `attr` is named or numeric and routes it
[459] Fix | Delete
* accordingly.
[460] Fix | Delete
*
[461] Fix | Delete
* @param {(number|string)} attr Attribute key.
[462] Fix | Delete
*
[463] Fix | Delete
* @return {string} Attribute value.
[464] Fix | Delete
*/
[465] Fix | Delete
get(attr) {
[466] Fix | Delete
return this.attrs[typeof attr === 'number' ? 'numeric' : 'named'][attr];
[467] Fix | Delete
},
[468] Fix | Delete
/**
[469] Fix | Delete
* Set a shortcode attribute.
[470] Fix | Delete
*
[471] Fix | Delete
* Automatically detects whether `attr` is named or numeric and routes it
[472] Fix | Delete
* accordingly.
[473] Fix | Delete
*
[474] Fix | Delete
* @param {(number|string)} attr Attribute key.
[475] Fix | Delete
* @param {string} value Attribute value.
[476] Fix | Delete
*
[477] Fix | Delete
* @return {InstanceType< import('./types').shortcode >} Shortcode instance.
[478] Fix | Delete
*/
[479] Fix | Delete
set(attr, value) {
[480] Fix | Delete
this.attrs[typeof attr === 'number' ? 'numeric' : 'named'][attr] = value;
[481] Fix | Delete
return this;
[482] Fix | Delete
},
[483] Fix | Delete
/**
[484] Fix | Delete
* Transform the shortcode into a string.
[485] Fix | Delete
*
[486] Fix | Delete
* @return {string} String representation of the shortcode.
[487] Fix | Delete
*/
[488] Fix | Delete
string() {
[489] Fix | Delete
let text = '[' + this.tag;
[490] Fix | Delete
this.attrs.numeric.forEach(value => {
[491] Fix | Delete
if (/\s/.test(value)) {
[492] Fix | Delete
text += ' "' + value + '"';
[493] Fix | Delete
} else {
[494] Fix | Delete
text += ' ' + value;
[495] Fix | Delete
}
[496] Fix | Delete
});
[497] Fix | Delete
Object.entries(this.attrs.named).forEach(([name, value]) => {
[498] Fix | Delete
text += ' ' + name + '="' + value + '"';
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function