@@ -10797,80 +10797,6 @@ function escapeStringRegexp(string) {
1079710797 .replace(/-/g, '\\x2d');
1079810798}
1079910799
10800- function color$1(d) {
10801- return '\u001B[33m' + d + '\u001B[39m'
10802- }
10803-
10804- const CONTINUE = true;
10805- const SKIP = 'skip';
10806- const EXIT = false;
10807- const visitParents =
10808- (
10809- function (tree, test, visitor, reverse) {
10810- if (typeof test === 'function' && typeof visitor !== 'function') {
10811- reverse = visitor;
10812- visitor = test;
10813- test = null;
10814- }
10815- var is = convert(test);
10816- var step = reverse ? -1 : 1;
10817- factory(tree, null, [])();
10818- function factory(node, index, parents) {
10819- var value = typeof node === 'object' && node !== null ? node : {};
10820- var name;
10821- if (typeof value.type === 'string') {
10822- name =
10823- typeof value.tagName === 'string'
10824- ? value.tagName
10825- : typeof value.name === 'string'
10826- ? value.name
10827- : undefined;
10828- Object.defineProperty(visit, 'name', {
10829- value:
10830- 'node (' +
10831- color$1(value.type + (name ? '<' + name + '>' : '')) +
10832- ')'
10833- });
10834- }
10835- return visit
10836- function visit() {
10837- var result = [];
10838- var subresult;
10839- var offset;
10840- var grandparents;
10841- if (!test || is(node, index, parents[parents.length - 1] || null)) {
10842- result = toResult(visitor(node, parents));
10843- if (result[0] === EXIT) {
10844- return result
10845- }
10846- }
10847- if (node.children && result[0] !== SKIP) {
10848- offset = (reverse ? node.children.length : -1) + step;
10849- grandparents = parents.concat(node);
10850- while (offset > -1 && offset < node.children.length) {
10851- subresult = factory(node.children[offset], offset, grandparents)();
10852- if (subresult[0] === EXIT) {
10853- return subresult
10854- }
10855- offset =
10856- typeof subresult[1] === 'number' ? subresult[1] : offset + step;
10857- }
10858- }
10859- return result
10860- }
10861- }
10862- }
10863- );
10864- function toResult(value) {
10865- if (Array.isArray(value)) {
10866- return value
10867- }
10868- if (typeof value === 'number') {
10869- return [CONTINUE, value]
10870- }
10871- return [value]
10872- }
10873-
1087410800const own$3 = {}.hasOwnProperty;
1087510801const findAndReplace =
1087610802 (
@@ -10891,7 +10817,7 @@ const findAndReplace =
1089110817 const pairs = toPairs(schema);
1089210818 let pairIndex = -1;
1089310819 while (++pairIndex < pairs.length) {
10894- visitParents(tree, 'text', visitor);
10820+ visitParents$1 (tree, 'text', visitor);
1089510821 }
1089610822 return tree
1089710823 function visitor(node, parents) {
@@ -10911,28 +10837,33 @@ const findAndReplace =
1091110837 grandparent = parent;
1091210838 }
1091310839 if (grandparent) {
10914- return handler(node, grandparent )
10840+ return handler(node, parents )
1091510841 }
1091610842 }
10917- function handler(node, parent) {
10843+ function handler(node, parents) {
10844+ const parent = parents[parents.length - 1];
1091810845 const find = pairs[pairIndex][0];
1091910846 const replace = pairs[pairIndex][1];
1092010847 let start = 0;
10921- let index = parent.children.indexOf(node);
10848+ const index = parent.children.indexOf(node);
1092210849 let nodes = [];
1092310850 let position;
1092410851 find.lastIndex = 0;
1092510852 let match = find.exec(node.value);
1092610853 while (match) {
1092710854 position = match.index;
10928- let value = replace(...match, {
10855+ const matchObject = {
1092910856 index: match.index,
10930- input: match.input
10931- });
10857+ input: match.input,
10858+ stack: [...parents, node]
10859+ };
10860+ let value = replace(...match, matchObject);
1093210861 if (typeof value === 'string') {
1093310862 value = value.length > 0 ? {type: 'text', value} : undefined;
1093410863 }
10935- if (value !== false) {
10864+ if (value === false) {
10865+ position = undefined;
10866+ } else {
1093610867 if (start !== position) {
1093710868 nodes.push({
1093810869 type: 'text',
@@ -10953,14 +10884,13 @@ const findAndReplace =
1095310884 }
1095410885 if (position === undefined) {
1095510886 nodes = [node];
10956- index--;
1095710887 } else {
1095810888 if (start < node.value.length) {
1095910889 nodes.push({type: 'text', value: node.value.slice(start)});
1096010890 }
1096110891 parent.children.splice(index, 1, ...nodes);
1096210892 }
10963- return index + nodes.length + 1
10893+ return index + nodes.length
1096410894 }
1096510895 }
1096610896 );
@@ -11747,6 +11677,80 @@ function location(file) {
1174711677 }
1174811678}
1174911679
11680+ function color$1(d) {
11681+ return '\u001B[33m' + d + '\u001B[39m'
11682+ }
11683+
11684+ const CONTINUE = true;
11685+ const SKIP = 'skip';
11686+ const EXIT = false;
11687+ const visitParents =
11688+ (
11689+ function (tree, test, visitor, reverse) {
11690+ if (typeof test === 'function' && typeof visitor !== 'function') {
11691+ reverse = visitor;
11692+ visitor = test;
11693+ test = null;
11694+ }
11695+ var is = convert(test);
11696+ var step = reverse ? -1 : 1;
11697+ factory(tree, null, [])();
11698+ function factory(node, index, parents) {
11699+ var value = typeof node === 'object' && node !== null ? node : {};
11700+ var name;
11701+ if (typeof value.type === 'string') {
11702+ name =
11703+ typeof value.tagName === 'string'
11704+ ? value.tagName
11705+ : typeof value.name === 'string'
11706+ ? value.name
11707+ : undefined;
11708+ Object.defineProperty(visit, 'name', {
11709+ value:
11710+ 'node (' +
11711+ color$1(value.type + (name ? '<' + name + '>' : '')) +
11712+ ')'
11713+ });
11714+ }
11715+ return visit
11716+ function visit() {
11717+ var result = [];
11718+ var subresult;
11719+ var offset;
11720+ var grandparents;
11721+ if (!test || is(node, index, parents[parents.length - 1] || null)) {
11722+ result = toResult(visitor(node, parents));
11723+ if (result[0] === EXIT) {
11724+ return result
11725+ }
11726+ }
11727+ if (node.children && result[0] !== SKIP) {
11728+ offset = (reverse ? node.children.length : -1) + step;
11729+ grandparents = parents.concat(node);
11730+ while (offset > -1 && offset < node.children.length) {
11731+ subresult = factory(node.children[offset], offset, grandparents)();
11732+ if (subresult[0] === EXIT) {
11733+ return subresult
11734+ }
11735+ offset =
11736+ typeof subresult[1] === 'number' ? subresult[1] : offset + step;
11737+ }
11738+ }
11739+ return result
11740+ }
11741+ }
11742+ }
11743+ );
11744+ function toResult(value) {
11745+ if (Array.isArray(value)) {
11746+ return value
11747+ }
11748+ if (typeof value === 'number') {
11749+ return [CONTINUE, value]
11750+ }
11751+ return [value]
11752+ }
11753+
1175011754const visit =
1175111755 (
1175211756 function (tree, test, visitor, reverse) {
0 commit comments