@digipair/skill-html 0.104.0 → 0.105.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs.js +113 -57
  2. package/index.esm.js +108 -52
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -23923,14 +23923,14 @@ function indent(str, spaces) {
23923
23923
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
23924
23924
  // match is required
23925
23925
  if (!match) {
23926
- return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
23926
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
23927
23927
  v: nextMatch1
23928
23928
  };
23929
23929
  }
23930
23930
  var token = match.token, offset = match.offset;
23931
23931
  i1 += offset;
23932
23932
  if (token === " ") {
23933
- return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23933
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23934
23934
  }
23935
23935
  tokens1 = _to_consumable_array$1(tokens1).concat([
23936
23936
  token
@@ -23949,7 +23949,7 @@ function indent(str, spaces) {
23949
23949
  if (contextKeys.some(function(el) {
23950
23950
  return el.startsWith(name);
23951
23951
  })) {
23952
- return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23952
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23953
23953
  }
23954
23954
  if (dateTimeIdentifiers.some(function(el) {
23955
23955
  return el === name;
@@ -23968,9 +23968,9 @@ function indent(str, spaces) {
23968
23968
  if (dateTimeIdentifiers.some(function(el) {
23969
23969
  return el.startsWith(name);
23970
23970
  })) {
23971
- return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23971
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23972
23972
  }
23973
- return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
23973
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1,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(V#X#Y(V~+QP!Q!['w~+YO$]~~+_O$s~R+fP!]QsP!_!`+iP+nOsPR+uP!YQsP!_!`+i~+}O$l~~,SO!i~~,XO!g~~,[WOY,XZ#O,X#O#P,t#P#S,X#S#T-p#T;'S,X;'S;=`-u<%lO,X~,wRO;'S,X;'S;=`-Q;=`O,X~-TXOY,XZ#O,X#O#P,t#P#S,X#S#T-p#T;'S,X;'S;=`-u;=`<%l,X<%lO,X~-uO$Z~~-xP;=`<%l,X~.QO#S~~.VO#R~",
24838
24838
  tokenizers: [
24839
24839
  propertyIdentifiers,
24840
24840
  identifiers,
@@ -25350,6 +25350,9 @@ function parseParameterNames(fn) {
25350
25350
  function notImplemented(thing) {
25351
25351
  return new Error("not implemented: ".concat(thing));
25352
25352
  }
25353
+ function isNotImplemented(err) {
25354
+ return /^not implemented/.test(err.message);
25355
+ }
25353
25356
  /**
25354
25357
  * Returns a name from context or undefined if it does not exist.
25355
25358
  *
@@ -25470,6 +25473,9 @@ var builtins = {
25470
25473
  d = from;
25471
25474
  }
25472
25475
  if (year) {
25476
+ if (!isNumber(month) || !isNumber(day)) {
25477
+ return null;
25478
+ }
25473
25479
  d = date().setZone("utc").set({
25474
25480
  year: year,
25475
25481
  month: month,
@@ -25524,7 +25530,7 @@ var builtins = {
25524
25530
  from = hour;
25525
25531
  hour = null;
25526
25532
  }
25527
- if (isString(from)) {
25533
+ if (isString(from) && from) {
25528
25534
  t = date(null, from);
25529
25535
  }
25530
25536
  if (isDateTime(from)) {
@@ -25535,6 +25541,9 @@ var builtins = {
25535
25541
  });
25536
25542
  }
25537
25543
  if (isNumber(hour)) {
25544
+ if (!isNumber(minute) || !isNumber(second)) {
25545
+ return null;
25546
+ }
25538
25547
  // TODO: support offset = days and time duration
25539
25548
  t = date().set({
25540
25549
  hour: hour,
@@ -25644,7 +25653,8 @@ var builtins = {
25644
25653
  "string"
25645
25654
  ]),
25646
25655
  "replace": fn(function(input, pattern, replacement, flags) {
25647
- return input.replace(new RegExp(pattern, "ug" + (flags || "").replace(/[x]/g, "")), replacement.replace(/\$0/g, "$$&"));
25656
+ var regexp = createRegexp(pattern, flags || "", "g");
25657
+ return regexp && input.replace(regexp, replacement.replace(/\$0/g, "$$&"));
25648
25658
  }, [
25649
25659
  "string",
25650
25660
  "string",
@@ -25657,9 +25667,9 @@ var builtins = {
25657
25667
  "string",
25658
25668
  "string"
25659
25669
  ]),
25660
- // eslint-disable-next-line
25661
25670
  "matches": fn(function(input, pattern, flags) {
25662
- throw notImplemented("matches");
25671
+ var regexp = createRegexp(pattern, flags || "", "");
25672
+ return regexp && regexp.test(input);
25663
25673
  }, [
25664
25674
  "string",
25665
25675
  "string",
@@ -25678,7 +25688,8 @@ var builtins = {
25678
25688
  "string"
25679
25689
  ]),
25680
25690
  "split": fn(function(string, delimiter) {
25681
- return string.split(new RegExp(delimiter, "u"));
25691
+ var regexp = createRegexp(delimiter, "", "");
25692
+ return regexp && string.split(regexp);
25682
25693
  }, [
25683
25694
  "string",
25684
25695
  "string"
@@ -26594,6 +26605,35 @@ function mode(array) {
26594
26605
  function ifValid(o) {
26595
26606
  return o.isValid ? o : null;
26596
26607
  }
26608
+ /**
26609
+ * Concatenates flags for a regular expression.
26610
+ *
26611
+ * Ensures that default flags are included without duplication, even if
26612
+ * user-specified flags overlap with the defaults.
26613
+ */ function buildFlags(flags, defaultFlags) {
26614
+ var unsupportedFlags = flags.replace(/[smix]/g, "");
26615
+ if (unsupportedFlags) {
26616
+ throw new Error("illegal flags: " + unsupportedFlags);
26617
+ }
26618
+ // we don't implement the <x> flag
26619
+ if (/x/.test(flags)) {
26620
+ throw notImplemented("matches <x> flag");
26621
+ }
26622
+ return flags + defaultFlags;
26623
+ }
26624
+ /**
26625
+ * Creates a regular expression from a given pattern
26626
+ */ function createRegexp(pattern, flags) {
26627
+ var defaultFlags = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
26628
+ try {
26629
+ return new RegExp(pattern, "u" + buildFlags(flags, defaultFlags));
26630
+ } catch (_err) {
26631
+ if (isNotImplemented(_err)) {
26632
+ throw _err;
26633
+ }
26634
+ }
26635
+ return null;
26636
+ }
26597
26637
  function parseExpression(expression) {
26598
26638
  var context = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, dialect = arguments.length > 2 ? arguments[2] : void 0;
26599
26639
  return parser.configure({
@@ -27048,27 +27088,59 @@ function evalNode(node, input, args) {
27048
27088
  };
27049
27089
  case "Type":
27050
27090
  return args[0];
27091
+ // (x in [ [1,2], [3,4] ]), (y in x)
27051
27092
  case "InExpressions":
27052
27093
  return function(context) {
27053
- var iterationContexts = args.map(function(ctx) {
27054
- return ctx(context);
27055
- });
27056
- if (iterationContexts.some(function(ctx) {
27057
- return getType(ctx) !== "list";
27058
- })) {
27059
- return null;
27060
- }
27061
- return cartesianProduct(iterationContexts).map(function(ctx) {
27062
- var _Object;
27063
- if (!isArray(ctx)) {
27064
- ctx = [
27065
- ctx
27066
- ];
27094
+ // we build up evaluation contexts from left to right,
27095
+ // ending up with the cartesian product over all available contexts
27096
+ //
27097
+ // previous context is provided to later context providers
27098
+ // producing <null> as a context during evaluation causes the
27099
+ // whole result to turn <null>
27100
+ var isValidContexts = function(contexts) {
27101
+ if (contexts === null || contexts.some(function(arr) {
27102
+ return getType(arr) === "nil";
27103
+ })) {
27104
+ return false;
27105
+ }
27106
+ return true;
27107
+ };
27108
+ var join = function(aContexts, bContextProducer) {
27109
+ var _instance;
27110
+ return (_instance = []).concat.apply(_instance, _to_consumable_array(aContexts.map(function(aContext) {
27111
+ var bContexts = bContextProducer(Object.assign(Object.assign({}, context), aContext));
27112
+ if (!isValidContexts(bContexts)) {
27113
+ return null;
27114
+ }
27115
+ return bContexts.map(function(bContext) {
27116
+ return Object.assign(Object.assign({}, aContext), bContext);
27117
+ });
27118
+ })));
27119
+ };
27120
+ var cartesian = function(aContexts, bContextProducer) {
27121
+ for(var _len = arguments.length, otherContextProducers = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
27122
+ otherContextProducers[_key - 2] = arguments[_key];
27123
+ }
27124
+ if (!isValidContexts(aContexts)) {
27125
+ return null;
27126
+ }
27127
+ if (!bContextProducer) {
27128
+ return aContexts;
27067
27129
  }
27068
- return (_Object = Object).assign.apply(_Object, [
27069
- {},
27070
- context
27071
- ].concat(_to_consumable_array(ctx)));
27130
+ return cartesian.apply(void 0, [
27131
+ join(aContexts, bContextProducer)
27132
+ ].concat(_to_consumable_array(otherContextProducers)));
27133
+ };
27134
+ var cartesianProduct = function(contextProducers) {
27135
+ var _contextProducers = _to_array(contextProducers), aContextProducer = _contextProducers[0], otherContextProducers = _contextProducers.slice(1);
27136
+ var aContexts = aContextProducer(context);
27137
+ return cartesian.apply(void 0, [
27138
+ aContexts
27139
+ ].concat(_to_consumable_array(otherContextProducers)));
27140
+ };
27141
+ var product = cartesianProduct(args);
27142
+ return product && product.map(function(p) {
27143
+ return Object.assign(Object.assign({}, context), p);
27072
27144
  });
27073
27145
  };
27074
27146
  // Name kw<"in"> Expr
@@ -27698,31 +27770,6 @@ function createDateTimeRange(start, end, startIncluded, endIncluded) {
27698
27770
  includes: includes
27699
27771
  });
27700
27772
  }
27701
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27702
- function cartesianProduct(arrays) {
27703
- var _instance;
27704
- if (arrays.some(function(arr) {
27705
- return getType(arr) === "nil";
27706
- })) {
27707
- return null;
27708
- }
27709
- var f = function(a, b) {
27710
- return (_instance = []).concat.apply(_instance, _to_consumable_array(a.map(function(d) {
27711
- return b.map(function(e) {
27712
- return [].concat(d, e);
27713
- });
27714
- })));
27715
- };
27716
- var cartesian = function(a, b) {
27717
- for(var _len = arguments.length, c = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
27718
- c[_key - 2] = arguments[_key];
27719
- }
27720
- return b ? cartesian.apply(void 0, [
27721
- f(a, b)
27722
- ].concat(_to_consumable_array(c))) : a || [];
27723
- };
27724
- return cartesian.apply(void 0, _to_consumable_array(arrays));
27725
- }
27726
27773
  function coalecenseTypes(a, b) {
27727
27774
  if (!b) {
27728
27775
  return a.type;
@@ -27784,15 +27831,24 @@ function parseString(str) {
27784
27831
  if (str.endsWith('"')) {
27785
27832
  str = str.slice(0, -1);
27786
27833
  }
27787
- return str.replace(/(\\")|(\\\\)|(\\u[a-fA-F0-9]{5,6})|((?:\\u[a-fA-F0-9]{1,4})+)/ig, function(substring) {
27834
+ return str.replace(/(\\")|(\\\\)|(\\n)|(\\r)|(\\t)|(\\u[a-fA-F0-9]{5,6})|((?:\\u[a-fA-F0-9]{1,4})+)/ig, function(substring) {
27788
27835
  for(var _len = arguments.length, groups = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
27789
27836
  groups[_key - 1] = arguments[_key];
27790
27837
  }
27791
- var _groups = _sliced_to_array(groups, 4), quotes = _groups[0], escape = _groups[1], codePoint = _groups[2], charCodes = _groups[3];
27838
+ var _groups = _sliced_to_array(groups, 7), quotes = _groups[0], backslash = _groups[1], newline = _groups[2], carriageReturn = _groups[3], tab = _groups[4], codePoint = _groups[5], charCodes = _groups[6];
27792
27839
  if (quotes) {
27793
27840
  return '"';
27794
27841
  }
27795
- if (escape) {
27842
+ if (newline) {
27843
+ return "\n";
27844
+ }
27845
+ if (carriageReturn) {
27846
+ return "\r";
27847
+ }
27848
+ if (tab) {
27849
+ return " ";
27850
+ }
27851
+ if (backslash) {
27796
27852
  return "\\";
27797
27853
  }
27798
27854
  var escapePattern = /\\u([a-fA-F0-9]+)/ig;
package/index.esm.js CHANGED
@@ -24812,7 +24812,7 @@ var parser = LRParser.deserialize({
24812
24812
  2
24813
24813
  ],
24814
24814
  repeatNodeCount: 14,
24815
- tokenData: ".Z~RvXY#iYZ$^Z[#i]^$^pq#iqr$crs$nwx&fxy&kyz&pz{&u{|'S|}'X}!O'^!O!P'k!P!Q(u!Q![*p![!]+X!]!^+^!^!_+c!_!`$i!`!a+r!b!c+|!}#O,R#P#Q,W#Q#R&}#S#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O#R~",
24816
24816
  tokenizers: [
24817
24817
  propertyIdentifiers,
24818
24818
  identifiers,
@@ -25328,6 +25328,9 @@ function parseParameterNames(fn) {
25328
25328
  function notImplemented(thing) {
25329
25329
  return new Error("not implemented: ".concat(thing));
25330
25330
  }
25331
+ function isNotImplemented(err) {
25332
+ return /^not implemented/.test(err.message);
25333
+ }
25331
25334
  /**
25332
25335
  * Returns a name from context or undefined if it does not exist.
25333
25336
  *
@@ -25448,6 +25451,9 @@ var builtins = {
25448
25451
  d = from;
25449
25452
  }
25450
25453
  if (year) {
25454
+ if (!isNumber(month) || !isNumber(day)) {
25455
+ return null;
25456
+ }
25451
25457
  d = date().setZone("utc").set({
25452
25458
  year: year,
25453
25459
  month: month,
@@ -25502,7 +25508,7 @@ var builtins = {
25502
25508
  from = hour;
25503
25509
  hour = null;
25504
25510
  }
25505
- if (isString(from)) {
25511
+ if (isString(from) && from) {
25506
25512
  t = date(null, from);
25507
25513
  }
25508
25514
  if (isDateTime(from)) {
@@ -25513,6 +25519,9 @@ var builtins = {
25513
25519
  });
25514
25520
  }
25515
25521
  if (isNumber(hour)) {
25522
+ if (!isNumber(minute) || !isNumber(second)) {
25523
+ return null;
25524
+ }
25516
25525
  // TODO: support offset = days and time duration
25517
25526
  t = date().set({
25518
25527
  hour: hour,
@@ -25622,7 +25631,8 @@ var builtins = {
25622
25631
  "string"
25623
25632
  ]),
25624
25633
  "replace": fn(function(input, pattern, replacement, flags) {
25625
- return input.replace(new RegExp(pattern, "ug" + (flags || "").replace(/[x]/g, "")), replacement.replace(/\$0/g, "$$&"));
25634
+ var regexp = createRegexp(pattern, flags || "", "g");
25635
+ return regexp && input.replace(regexp, replacement.replace(/\$0/g, "$$&"));
25626
25636
  }, [
25627
25637
  "string",
25628
25638
  "string",
@@ -25635,9 +25645,9 @@ var builtins = {
25635
25645
  "string",
25636
25646
  "string"
25637
25647
  ]),
25638
- // eslint-disable-next-line
25639
25648
  "matches": fn(function(input, pattern, flags) {
25640
- throw notImplemented("matches");
25649
+ var regexp = createRegexp(pattern, flags || "", "");
25650
+ return regexp && regexp.test(input);
25641
25651
  }, [
25642
25652
  "string",
25643
25653
  "string",
@@ -25656,7 +25666,8 @@ var builtins = {
25656
25666
  "string"
25657
25667
  ]),
25658
25668
  "split": fn(function(string, delimiter) {
25659
- return string.split(new RegExp(delimiter, "u"));
25669
+ var regexp = createRegexp(delimiter, "", "");
25670
+ return regexp && string.split(regexp);
25660
25671
  }, [
25661
25672
  "string",
25662
25673
  "string"
@@ -26572,6 +26583,35 @@ function mode(array) {
26572
26583
  function ifValid(o) {
26573
26584
  return o.isValid ? o : null;
26574
26585
  }
26586
+ /**
26587
+ * Concatenates flags for a regular expression.
26588
+ *
26589
+ * Ensures that default flags are included without duplication, even if
26590
+ * user-specified flags overlap with the defaults.
26591
+ */ function buildFlags(flags, defaultFlags) {
26592
+ var unsupportedFlags = flags.replace(/[smix]/g, "");
26593
+ if (unsupportedFlags) {
26594
+ throw new Error("illegal flags: " + unsupportedFlags);
26595
+ }
26596
+ // we don't implement the <x> flag
26597
+ if (/x/.test(flags)) {
26598
+ throw notImplemented("matches <x> flag");
26599
+ }
26600
+ return flags + defaultFlags;
26601
+ }
26602
+ /**
26603
+ * Creates a regular expression from a given pattern
26604
+ */ function createRegexp(pattern, flags) {
26605
+ var defaultFlags = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
26606
+ try {
26607
+ return new RegExp(pattern, "u" + buildFlags(flags, defaultFlags));
26608
+ } catch (_err) {
26609
+ if (isNotImplemented(_err)) {
26610
+ throw _err;
26611
+ }
26612
+ }
26613
+ return null;
26614
+ }
26575
26615
  function parseExpression(expression) {
26576
26616
  var context = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, dialect = arguments.length > 2 ? arguments[2] : void 0;
26577
26617
  return parser.configure({
@@ -27026,27 +27066,59 @@ function evalNode(node, input, args) {
27026
27066
  };
27027
27067
  case "Type":
27028
27068
  return args[0];
27069
+ // (x in [ [1,2], [3,4] ]), (y in x)
27029
27070
  case "InExpressions":
27030
27071
  return function(context) {
27031
- var iterationContexts = args.map(function(ctx) {
27032
- return ctx(context);
27033
- });
27034
- if (iterationContexts.some(function(ctx) {
27035
- return getType(ctx) !== "list";
27036
- })) {
27037
- return null;
27038
- }
27039
- return cartesianProduct(iterationContexts).map(function(ctx) {
27040
- var _Object;
27041
- if (!isArray(ctx)) {
27042
- ctx = [
27043
- ctx
27044
- ];
27072
+ // we build up evaluation contexts from left to right,
27073
+ // ending up with the cartesian product over all available contexts
27074
+ //
27075
+ // previous context is provided to later context providers
27076
+ // producing <null> as a context during evaluation causes the
27077
+ // whole result to turn <null>
27078
+ var isValidContexts = function(contexts) {
27079
+ if (contexts === null || contexts.some(function(arr) {
27080
+ return getType(arr) === "nil";
27081
+ })) {
27082
+ return false;
27083
+ }
27084
+ return true;
27085
+ };
27086
+ var join = function(aContexts, bContextProducer) {
27087
+ var _instance;
27088
+ return (_instance = []).concat.apply(_instance, _to_consumable_array(aContexts.map(function(aContext) {
27089
+ var bContexts = bContextProducer(Object.assign(Object.assign({}, context), aContext));
27090
+ if (!isValidContexts(bContexts)) {
27091
+ return null;
27092
+ }
27093
+ return bContexts.map(function(bContext) {
27094
+ return Object.assign(Object.assign({}, aContext), bContext);
27095
+ });
27096
+ })));
27097
+ };
27098
+ var cartesian = function(aContexts, bContextProducer) {
27099
+ for(var _len = arguments.length, otherContextProducers = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
27100
+ otherContextProducers[_key - 2] = arguments[_key];
27101
+ }
27102
+ if (!isValidContexts(aContexts)) {
27103
+ return null;
27104
+ }
27105
+ if (!bContextProducer) {
27106
+ return aContexts;
27045
27107
  }
27046
- return (_Object = Object).assign.apply(_Object, [
27047
- {},
27048
- context
27049
- ].concat(_to_consumable_array(ctx)));
27108
+ return cartesian.apply(void 0, [
27109
+ join(aContexts, bContextProducer)
27110
+ ].concat(_to_consumable_array(otherContextProducers)));
27111
+ };
27112
+ var cartesianProduct = function(contextProducers) {
27113
+ var _contextProducers = _to_array(contextProducers), aContextProducer = _contextProducers[0], otherContextProducers = _contextProducers.slice(1);
27114
+ var aContexts = aContextProducer(context);
27115
+ return cartesian.apply(void 0, [
27116
+ aContexts
27117
+ ].concat(_to_consumable_array(otherContextProducers)));
27118
+ };
27119
+ var product = cartesianProduct(args);
27120
+ return product && product.map(function(p) {
27121
+ return Object.assign(Object.assign({}, context), p);
27050
27122
  });
27051
27123
  };
27052
27124
  // Name kw<"in"> Expr
@@ -27676,31 +27748,6 @@ function createDateTimeRange(start, end, startIncluded, endIncluded) {
27676
27748
  includes: includes
27677
27749
  });
27678
27750
  }
27679
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27680
- function cartesianProduct(arrays) {
27681
- var _instance;
27682
- if (arrays.some(function(arr) {
27683
- return getType(arr) === "nil";
27684
- })) {
27685
- return null;
27686
- }
27687
- var f = function(a, b) {
27688
- return (_instance = []).concat.apply(_instance, _to_consumable_array(a.map(function(d) {
27689
- return b.map(function(e) {
27690
- return [].concat(d, e);
27691
- });
27692
- })));
27693
- };
27694
- var cartesian = function(a, b) {
27695
- for(var _len = arguments.length, c = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
27696
- c[_key - 2] = arguments[_key];
27697
- }
27698
- return b ? cartesian.apply(void 0, [
27699
- f(a, b)
27700
- ].concat(_to_consumable_array(c))) : a || [];
27701
- };
27702
- return cartesian.apply(void 0, _to_consumable_array(arrays));
27703
- }
27704
27751
  function coalecenseTypes(a, b) {
27705
27752
  if (!b) {
27706
27753
  return a.type;
@@ -27762,15 +27809,24 @@ function parseString(str) {
27762
27809
  if (str.endsWith('"')) {
27763
27810
  str = str.slice(0, -1);
27764
27811
  }
27765
- return str.replace(/(\\")|(\\\\)|(\\u[a-fA-F0-9]{5,6})|((?:\\u[a-fA-F0-9]{1,4})+)/ig, function(substring) {
27812
+ return str.replace(/(\\")|(\\\\)|(\\n)|(\\r)|(\\t)|(\\u[a-fA-F0-9]{5,6})|((?:\\u[a-fA-F0-9]{1,4})+)/ig, function(substring) {
27766
27813
  for(var _len = arguments.length, groups = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
27767
27814
  groups[_key - 1] = arguments[_key];
27768
27815
  }
27769
- var _groups = _sliced_to_array(groups, 4), quotes = _groups[0], escape = _groups[1], codePoint = _groups[2], charCodes = _groups[3];
27816
+ var _groups = _sliced_to_array(groups, 7), quotes = _groups[0], backslash = _groups[1], newline = _groups[2], carriageReturn = _groups[3], tab = _groups[4], codePoint = _groups[5], charCodes = _groups[6];
27770
27817
  if (quotes) {
27771
27818
  return '"';
27772
27819
  }
27773
- if (escape) {
27820
+ if (newline) {
27821
+ return "\n";
27822
+ }
27823
+ if (carriageReturn) {
27824
+ return "\r";
27825
+ }
27826
+ if (tab) {
27827
+ return " ";
27828
+ }
27829
+ if (backslash) {
27774
27830
  return "\\";
27775
27831
  }
27776
27832
  var escapePattern = /\\u([a-fA-F0-9]+)/ig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-html",
3
- "version": "0.104.0",
3
+ "version": "0.105.2",
4
4
  "keywords": [
5
5
  "digipair",
6
6
  "service",