polytypo 1.17.1 → 1.17.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 (48) hide show
  1. package/dist/chunk-4YXTHZIB.cjs +38 -0
  2. package/dist/{chunk-S3THC23S.cjs.map → chunk-4YXTHZIB.cjs.map} +1 -1
  3. package/dist/{chunk-5VDPW7O6.js → chunk-4ZRTKEZA.js} +2 -2
  4. package/dist/{chunk-SPY3OYVJ.cjs → chunk-7DJG5YVG.cjs} +125 -25
  5. package/dist/chunk-7DJG5YVG.cjs.map +1 -0
  6. package/dist/{chunk-QGPUYIQ6.cjs → chunk-AWTKVV4E.cjs} +43 -8
  7. package/dist/{chunk-QGPUYIQ6.cjs.map → chunk-AWTKVV4E.cjs.map} +1 -1
  8. package/dist/{chunk-JHUR3KFU.js → chunk-BXENIIJD.js} +42 -7
  9. package/dist/{chunk-JHUR3KFU.js.map → chunk-BXENIIJD.js.map} +1 -1
  10. package/dist/{chunk-U36ZYZQT.js → chunk-D5X53S7D.js} +2 -2
  11. package/dist/{chunk-6YZ4D72Q.js → chunk-DWQ3SDHS.js} +2 -2
  12. package/dist/chunk-KZWW24OZ.cjs +36 -0
  13. package/dist/{chunk-KH57BTH6.cjs.map → chunk-KZWW24OZ.cjs.map} +1 -1
  14. package/dist/{chunk-R6IILWU3.cjs → chunk-LLKXGT4D.cjs} +6 -6
  15. package/dist/{chunk-R6IILWU3.cjs.map → chunk-LLKXGT4D.cjs.map} +1 -1
  16. package/dist/{chunk-UA7MQNBN.js → chunk-OQRJ5BMU.js} +107 -7
  17. package/dist/chunk-OQRJ5BMU.js.map +1 -0
  18. package/dist/{chunk-5WFLLIUG.js → chunk-S7NXM2JK.js} +2 -2
  19. package/dist/{chunk-3L3BHUAF.js → chunk-TQMYJT3L.js} +3 -3
  20. package/dist/chunk-UMRHMNDF.cjs +34 -0
  21. package/dist/{chunk-DBNA7GVR.cjs.map → chunk-UMRHMNDF.cjs.map} +1 -1
  22. package/dist/{chunk-3PERF7A2.cjs → chunk-VNWEZQWP.cjs} +3 -3
  23. package/dist/{chunk-3PERF7A2.cjs.map → chunk-VNWEZQWP.cjs.map} +1 -1
  24. package/dist/{chunk-PXBKWYVG.cjs → chunk-YV5DI7CN.cjs} +4 -4
  25. package/dist/{chunk-PXBKWYVG.cjs.map → chunk-YV5DI7CN.cjs.map} +1 -1
  26. package/dist/{chunk-LHYTW5VQ.js → chunk-ZC2JQGJN.js} +3 -3
  27. package/dist/html.cjs +9 -9
  28. package/dist/html.js +4 -4
  29. package/dist/index.cjs +17 -17
  30. package/dist/index.js +7 -7
  31. package/dist/markdown.cjs +10 -10
  32. package/dist/markdown.js +5 -5
  33. package/dist/text.cjs +8 -8
  34. package/dist/text.js +3 -3
  35. package/dist/yaml.cjs +9 -9
  36. package/dist/yaml.js +4 -4
  37. package/package.json +1 -1
  38. package/dist/chunk-DBNA7GVR.cjs +0 -34
  39. package/dist/chunk-KH57BTH6.cjs +0 -36
  40. package/dist/chunk-S3THC23S.cjs +0 -38
  41. package/dist/chunk-SPY3OYVJ.cjs.map +0 -1
  42. package/dist/chunk-UA7MQNBN.js.map +0 -1
  43. /package/dist/{chunk-5VDPW7O6.js.map → chunk-4ZRTKEZA.js.map} +0 -0
  44. /package/dist/{chunk-U36ZYZQT.js.map → chunk-D5X53S7D.js.map} +0 -0
  45. /package/dist/{chunk-6YZ4D72Q.js.map → chunk-DWQ3SDHS.js.map} +0 -0
  46. /package/dist/{chunk-5WFLLIUG.js.map → chunk-S7NXM2JK.js.map} +0 -0
  47. /package/dist/{chunk-3L3BHUAF.js.map → chunk-TQMYJT3L.js.map} +0 -0
  48. /package/dist/{chunk-LHYTW5VQ.js.map → chunk-ZC2JQGJN.js.map} +0 -0
@@ -5877,7 +5877,7 @@ function normalizeSpans(spans) {
5877
5877
  );
5878
5878
  }
5879
5879
  if (span.start === last.end) {
5880
- out[out.length - 1] = { start: last.start, end: span.end };
5880
+ out[out.length - 1] = { ...last, end: span.end };
5881
5881
  continue;
5882
5882
  }
5883
5883
  out.push(span);
@@ -5914,7 +5914,26 @@ function spanContaining(ranges, p) {
5914
5914
  }
5915
5915
  return void 0;
5916
5916
  }
5917
- function filterBoundaryEdits(cp, edits, ranges) {
5917
+ var DELIMITERS = /* @__PURE__ */ new Set([42, 95, 126]);
5918
+ function isMarkdownWhitespace(c) {
5919
+ if (c === void 0) return false;
5920
+ return c === 9 || c === 10 || c === 12 || c === 13 || c === 32 || c === 160 || c === 5760 || c >= 8192 && c <= 8202 || c === 8239 || c === 8287 || c === 12288;
5921
+ }
5922
+ function changesDelimiterFlank(cp, p, q, w) {
5923
+ const r = w.length;
5924
+ if (p - 1 >= 0 && DELIMITERS.has(cp[p - 1])) {
5925
+ const before = cp[p];
5926
+ const after = r > 0 ? w[0] : cp[q + 1];
5927
+ if (isMarkdownWhitespace(before) !== isMarkdownWhitespace(after)) return true;
5928
+ }
5929
+ if (q + 1 < cp.length && DELIMITERS.has(cp[q + 1])) {
5930
+ const before = cp[q];
5931
+ const after = r > 0 ? w[r - 1] : cp[p - 1];
5932
+ if (isMarkdownWhitespace(before) !== isMarkdownWhitespace(after)) return true;
5933
+ }
5934
+ return false;
5935
+ }
5936
+ function filterBoundaryEdits(cp, edits, ranges, delimiterNeighbours = false, guarded = []) {
5918
5937
  const out = [];
5919
5938
  for (const edit of edits) {
5920
5939
  let containsMarker = false;
@@ -5929,7 +5948,11 @@ function filterBoundaryEdits(cp, edits, ranges) {
5929
5948
  const q = edit.end - 1;
5930
5949
  const d = edit.end - edit.start;
5931
5950
  const r = edit.replacement.length;
5951
+ if (delimiterNeighbours && changesDelimiterFlank(cp, p, q, edit.replacement)) continue;
5932
5952
  const span = spanContaining(ranges, p);
5953
+ if (span !== void 0 && p === span.first && guarded[ranges.indexOf(span)] === true) {
5954
+ if (edit.replacement.length === 0 || edit.replacement[0] !== SPACE5) continue;
5955
+ }
5933
5956
  if (span !== void 0 && (p === span.first || q === span.last)) {
5934
5957
  if (r > d) continue;
5935
5958
  const first = edit.replacement[0];
@@ -5983,13 +6006,17 @@ function originOfSpans(source, spans) {
5983
6006
  }
5984
6007
 
5985
6008
  // src/engine/span-runner.ts
5986
- function runRulesOverSpans(cp, planned, locale, mode, narrowTarget) {
6009
+ function runRulesOverSpans(cp, planned, locale, mode, narrowTarget, guarded = []) {
5987
6010
  let current = cp;
5988
6011
  for (const id of planned) {
5989
6012
  const rule = RULES[id];
5990
6013
  if (rule === void 0) continue;
5991
6014
  const edits = rule.apply({ cp: current, locale, mode, narrowTarget });
5992
- current = applyEdits(current, filterBoundaryEdits(current, edits, spanRangesOf(current)), id);
6015
+ current = applyEdits(
6016
+ current,
6017
+ filterBoundaryEdits(current, edits, spanRangesOf(current), mode === "markdown", guarded),
6018
+ id
6019
+ );
5993
6020
  }
5994
6021
  return current;
5995
6022
  }
@@ -6001,7 +6028,8 @@ function replacementsOfUnit(source, spans, planned, locale, mode, narrowTarget)
6001
6028
  planned,
6002
6029
  locale,
6003
6030
  mode,
6004
- narrowTarget
6031
+ narrowTarget,
6032
+ normalized.map((span) => span.urlTail === true)
6005
6033
  );
6006
6034
  const pieces = splitOnMarker(transformed, normalized.length);
6007
6035
  return normalized.map((span, i) => ({ span, text: fromCodePoints(pieces[i]) }));
@@ -6038,7 +6066,13 @@ function analyzeOverSpans(source, spans, planned, locale, mode, narrowTarget) {
6038
6066
  narrowTarget,
6039
6067
  originOfSpans(source, normalized),
6040
6068
  toCodePoints(source).length,
6041
- (current, edits) => filterBoundaryEdits(current, edits, spanRangesOf(current))
6069
+ (current, edits) => filterBoundaryEdits(
6070
+ current,
6071
+ edits,
6072
+ spanRangesOf(current),
6073
+ mode === "markdown",
6074
+ normalized.map((span) => span.urlTail === true)
6075
+ )
6042
6076
  );
6043
6077
  }
6044
6078
 
@@ -6162,6 +6196,7 @@ export {
6162
6196
  fromCodePoints,
6163
6197
  getLocaleData,
6164
6198
  resolveNarrowTarget,
6199
+ normalizeSpans,
6165
6200
  planRules,
6166
6201
  runRules,
6167
6202
  runRulesRecording,
@@ -6174,4 +6209,4 @@ export {
6174
6209
  runProtected,
6175
6210
  analyzeProtected
6176
6211
  };
6177
- //# sourceMappingURL=chunk-JHUR3KFU.js.map
6212
+ //# sourceMappingURL=chunk-BXENIIJD.js.map