polytypo 1.0.2 → 1.2.0

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 (37) hide show
  1. package/README.md +14 -5
  2. package/dist/{chunk-UKWVAQMR.js → chunk-44A6YP7S.js} +3 -3
  3. package/dist/chunk-5VBDCDS6.cjs +19 -0
  4. package/dist/{chunk-DZ72ITYV.cjs.map → chunk-5VBDCDS6.cjs.map} +1 -1
  5. package/dist/{chunk-HZPDGNOO.js → chunk-6NTDU63P.js} +3 -3
  6. package/dist/{chunk-MOVY7OL2.cjs → chunk-B4O4R6HI.cjs} +183 -185
  7. package/dist/chunk-B4O4R6HI.cjs.map +1 -0
  8. package/dist/chunk-HGUA2NVX.cjs +21 -0
  9. package/dist/{chunk-F3BDCZSG.cjs.map → chunk-HGUA2NVX.cjs.map} +1 -1
  10. package/dist/{chunk-MMU4UU46.js → chunk-KAO74OJ6.js} +2 -2
  11. package/dist/{chunk-YS3FXB5V.cjs → chunk-LS57O4KJ.cjs} +14 -14
  12. package/dist/{chunk-YS3FXB5V.cjs.map → chunk-LS57O4KJ.cjs.map} +1 -1
  13. package/dist/{chunk-47XAYIKV.js → chunk-OHF7OFWY.js} +183 -185
  14. package/dist/{chunk-47XAYIKV.js.map → chunk-OHF7OFWY.js.map} +1 -1
  15. package/dist/{chunk-M2UGLSIB.cjs → chunk-POGDWVG5.cjs} +11 -11
  16. package/dist/{chunk-M2UGLSIB.cjs.map → chunk-POGDWVG5.cjs.map} +1 -1
  17. package/dist/{chunk-7L4ECXDJ.js → chunk-RC3UKUYZ.js} +2 -2
  18. package/dist/{chunk-E63PQ3N7.js → chunk-VARU43JT.js} +2 -2
  19. package/dist/{chunk-7IZAODBB.cjs → chunk-YYHKX5HE.cjs} +3 -3
  20. package/dist/{chunk-7IZAODBB.cjs.map → chunk-YYHKX5HE.cjs.map} +1 -1
  21. package/dist/html.cjs +7 -7
  22. package/dist/html.js +4 -4
  23. package/dist/index.cjs +10 -10
  24. package/dist/index.js +5 -5
  25. package/dist/markdown.cjs +7 -7
  26. package/dist/markdown.js +4 -4
  27. package/dist/text.cjs +6 -6
  28. package/dist/text.js +3 -3
  29. package/package.json +1 -1
  30. package/dist/chunk-DZ72ITYV.cjs +0 -19
  31. package/dist/chunk-F3BDCZSG.cjs +0 -21
  32. package/dist/chunk-MOVY7OL2.cjs.map +0 -1
  33. /package/dist/{chunk-UKWVAQMR.js.map → chunk-44A6YP7S.js.map} +0 -0
  34. /package/dist/{chunk-HZPDGNOO.js.map → chunk-6NTDU63P.js.map} +0 -0
  35. /package/dist/{chunk-MMU4UU46.js.map → chunk-KAO74OJ6.js.map} +0 -0
  36. /package/dist/{chunk-7L4ECXDJ.js.map → chunk-RC3UKUYZ.js.map} +0 -0
  37. /package/dist/{chunk-E63PQ3N7.js.map → chunk-VARU43JT.js.map} +0 -0
@@ -3835,131 +3835,8 @@ function isMarker(value) {
3835
3835
  return value === MARKER || value === LINE_MARKER;
3836
3836
  }
3837
3837
 
3838
- // src/rules/quote-ambiguity.ts
3839
- var SQ = 39;
3840
- var MIN_ENCLOSED = 1;
3841
- var MAX_ENCLOSED = 3;
3842
- var NARROW = /* @__PURE__ */ new Set([
3843
- 39,
3844
- 8216,
3845
- 8217,
3846
- 8218,
3847
- 8219,
3848
- 8249,
3849
- 8250
3850
- ]);
3851
- var INLINE_SPACE = /* @__PURE__ */ new Set([
3852
- 32,
3853
- 9,
3854
- 160,
3855
- 8239,
3856
- 8199,
3857
- 8201,
3858
- 8202
3859
- ]);
3860
- function at(cp, i) {
3861
- const value = cp[i];
3862
- return value === void 0 ? NONE : value;
3863
- }
3864
- function asciiLower(cp) {
3865
- return cp >= 65 && cp <= 90 ? cp + 32 : cp;
3866
- }
3867
- function isAlnum(cp) {
3868
- const DIGIT_ZERO9 = 48;
3869
- const DIGIT_NINE8 = 57;
3870
- return cp >= DIGIT_ZERO9 && cp <= DIGIT_NINE8 || isLetter(cp);
3871
- }
3872
- function wordEndsAt(arr, end, word) {
3873
- const start = end - word.length;
3874
- if (start < 0) return false;
3875
- for (let k = 0; k < word.length; k += 1) {
3876
- const c = at(arr, start + k);
3877
- const matches = k === 0 ? asciiLower(c) === asciiLower(word[k]) : c === word[k];
3878
- if (!matches) return false;
3879
- }
3880
- const before = start > 0 ? at(arr, start - 1) : NONE;
3881
- return before === NONE || !isAlnum(before);
3882
- }
3883
- function wordStartsAt(arr, start, word) {
3884
- const n = arr.length;
3885
- for (let k = 0; k < word.length; k += 1) {
3886
- const c = at(arr, start + k);
3887
- const matches = k === 0 ? asciiLower(c) === asciiLower(word[k]) : c === word[k];
3888
- if (!matches) return false;
3889
- }
3890
- const after = start + word.length < n ? at(arr, start + word.length) : NONE;
3891
- return after === NONE || !isAlnum(after);
3892
- }
3893
- function computeIdiomMatchedIndices(arr, idioms) {
3894
- const vetoed = /* @__PURE__ */ new Set();
3895
- if (idioms.length === 0) return vetoed;
3896
- const n = arr.length;
3897
- const compiled = idioms.map((idiom) => ({
3898
- left: toCodePoints(idiom.left),
3899
- elided: toCodePoints(idiom.elided),
3900
- right: toCodePoints(idiom.right)
3901
- }));
3902
- for (let i = 0; i < n; i += 1) {
3903
- const g = at(arr, i);
3904
- if (!NARROW.has(g)) continue;
3905
- const lLit = i > 0 ? at(arr, i - 1) : NONE;
3906
- if (lLit === NONE || !INLINE_SPACE.has(lLit)) continue;
3907
- for (const idiom of compiled) {
3908
- const k = idiom.elided.length;
3909
- const j = i + 1 + k;
3910
- if (j >= n) continue;
3911
- let elidedMatches = true;
3912
- for (let w = 0; w < k; w += 1) {
3913
- if (at(arr, i + 1 + w) !== idiom.elided[w]) {
3914
- elidedMatches = false;
3915
- break;
3916
- }
3917
- }
3918
- if (!elidedMatches) continue;
3919
- if (!NARROW.has(at(arr, j))) continue;
3920
- const rLit = j + 1 < n ? at(arr, j + 1) : NONE;
3921
- if (rLit === NONE || !INLINE_SPACE.has(rLit)) continue;
3922
- if (!wordEndsAt(arr, i - 1, idiom.left)) continue;
3923
- if (!wordStartsAt(arr, j + 2, idiom.right)) continue;
3924
- vetoed.add(i);
3925
- vetoed.add(j);
3926
- }
3927
- }
3928
- return vetoed;
3929
- }
3930
- function computeAmbiguousShapeIndices(cp) {
3931
- const ambiguous = /* @__PURE__ */ new Set();
3932
- const n = cp.length;
3933
- for (let i = 0; i < n; i += 1) {
3934
- if (at(cp, i) !== SQ) continue;
3935
- const lLit = i > 0 ? at(cp, i - 1) : NONE;
3936
- if (lLit === NONE || !INLINE_SPACE.has(lLit)) continue;
3937
- let k = 0;
3938
- while (k < MAX_ENCLOSED && isLetter(at(cp, i + 1 + k))) k += 1;
3939
- if (k < MIN_ENCLOSED) continue;
3940
- const j = i + 1 + k;
3941
- if (at(cp, j) !== SQ) continue;
3942
- const rLit = j + 1 < n ? at(cp, j + 1) : NONE;
3943
- if (rLit === NONE || !INLINE_SPACE.has(rLit)) continue;
3944
- ambiguous.add(i);
3945
- ambiguous.add(j);
3946
- }
3947
- return ambiguous;
3948
- }
3949
- function computePreserveIndices(cp, idioms) {
3950
- const ambiguous = computeAmbiguousShapeIndices(cp);
3951
- if (ambiguous.size === 0) return ambiguous;
3952
- const idiomMatched = computeIdiomMatchedIndices(cp, idioms);
3953
- if (idiomMatched.size === 0) return ambiguous;
3954
- const preserve = /* @__PURE__ */ new Set();
3955
- for (const index of ambiguous) {
3956
- if (!idiomMatched.has(index)) preserve.add(index);
3957
- }
3958
- return preserve;
3959
- }
3960
-
3961
3838
  // src/rules/apostrophe.ts
3962
- var SQ2 = 39;
3839
+ var SQ = 39;
3963
3840
  var RIGHT_SINGLE = 8217;
3964
3841
  var DIGIT_ZERO = 48;
3965
3842
  var DIGIT_NINE = 57;
@@ -4020,22 +3897,33 @@ var CLOSEISH = /* @__PURE__ */ new Set([
4020
3897
  8211,
4021
3898
  8212
4022
3899
  ]);
4023
- function at2(cp, i) {
3900
+ var OPENQUOTE = /* @__PURE__ */ new Set([
3901
+ 171,
3902
+ 8216,
3903
+ 8218,
3904
+ 8219,
3905
+ 8220,
3906
+ 8222,
3907
+ 8223,
3908
+ 8249
3909
+ ]);
3910
+ function at(cp, i) {
4024
3911
  const value = cp[i];
4025
3912
  return value === void 0 ? NONE : value;
4026
3913
  }
4027
3914
  function isDigit(cp) {
4028
3915
  return cp >= DIGIT_ZERO && cp <= DIGIT_NINE;
4029
3916
  }
4030
- function isAlnum2(cp) {
3917
+ function isAlnum(cp) {
4031
3918
  return isDigit(cp) || isLetter(cp);
4032
3919
  }
4033
3920
  function isApostrophe(left, right) {
4034
3921
  if (isDigit(left) && !isLetter(right)) return false;
4035
- if (isAlnum2(left) && isAlnum2(right)) return true;
3922
+ if (isAlnum(left) && isAlnum(right)) return true;
4036
3923
  if (isLetter(left) && (right === NONE || SPACELIKE.has(right) || CLOSEISH.has(right)))
4037
3924
  return true;
4038
- if ((left === NONE || SPACELIKE.has(left) || OPENISH.has(left)) && isAlnum2(right)) return true;
3925
+ if (isLetter(left) && OPENQUOTE.has(right)) return true;
3926
+ if ((left === NONE || SPACELIKE.has(left) || OPENISH.has(left)) && isAlnum(right)) return true;
4039
3927
  return false;
4040
3928
  }
4041
3929
  var apostropheRule = {
@@ -4044,12 +3932,10 @@ var apostropheRule = {
4044
3932
  const cp = ctx.cp;
4045
3933
  const n = cp.length;
4046
3934
  const edits = [];
4047
- const preserve = computePreserveIndices(cp, ctx.locale.quotes.elisionIdioms);
4048
3935
  for (let i = 0; i < n; i += 1) {
4049
- if (at2(cp, i) !== SQ2) continue;
4050
- if (preserve.has(i)) continue;
4051
- const left = i > 0 ? at2(cp, i - 1) : NONE;
4052
- const right = i + 1 < n ? at2(cp, i + 1) : NONE;
3936
+ if (at(cp, i) !== SQ) continue;
3937
+ const left = i > 0 ? at(cp, i - 1) : NONE;
3938
+ const right = i + 1 < n ? at(cp, i + 1) : NONE;
4053
3939
  if (isApostrophe(left, right)) {
4054
3940
  edits.push({ start: i, end: i + 1, replacement: [RIGHT_SINGLE], ruleId: "apostrophe" });
4055
3941
  }
@@ -4284,7 +4170,7 @@ var DOT = 46;
4284
4170
  var ELL = 8230;
4285
4171
  var EXCLAMATION = 33;
4286
4172
  var QUESTION = 63;
4287
- function at3(cp, i) {
4173
+ function at2(cp, i) {
4288
4174
  const value = cp[i];
4289
4175
  return value === void 0 ? NONE : value;
4290
4176
  }
@@ -4297,7 +4183,7 @@ function isTerminal(cp) {
4297
4183
  function isSameRun(cp, s, e, target) {
4298
4184
  if (e - s !== target.length) return false;
4299
4185
  for (let j = 0; j < target.length; j += 1) {
4300
- if (at3(cp, s + j) !== target[j]) return false;
4186
+ if (at2(cp, s + j) !== target[j]) return false;
4301
4187
  }
4302
4188
  return true;
4303
4189
  }
@@ -4310,19 +4196,19 @@ var ellipsisRule = {
4310
4196
  const edits = [];
4311
4197
  let i = 0;
4312
4198
  while (i < n) {
4313
- if (!isDotlike(at3(cp, i))) {
4199
+ if (!isDotlike(at2(cp, i))) {
4314
4200
  i += 1;
4315
4201
  continue;
4316
4202
  }
4317
4203
  const s = i;
4318
4204
  let e = s;
4319
4205
  let q = 0;
4320
- while (e < n && isDotlike(at3(cp, e))) {
4321
- if (at3(cp, e) === ELL) q += 1;
4206
+ while (e < n && isDotlike(at2(cp, e))) {
4207
+ if (at2(cp, e) === ELL) q += 1;
4322
4208
  e += 1;
4323
4209
  }
4324
4210
  const k = e - s;
4325
- const left = at3(cp, s - 1);
4211
+ const left = at2(cp, s - 1);
4326
4212
  const target = runTarget(k, q, left, abbreviated);
4327
4213
  if (target !== null && !isSameRun(cp, s, e, target)) {
4328
4214
  edits.push({ start: s, end: e, replacement: target, ruleId: "ellipsis" });
@@ -4348,7 +4234,7 @@ var HYPHEN_MINUS2 = 45;
4348
4234
  var NON_BREAKING_HYPHEN = 8209;
4349
4235
  var DIGIT_ZERO3 = 48;
4350
4236
  var DIGIT_NINE3 = 57;
4351
- function at4(cp, i) {
4237
+ function at3(cp, i) {
4352
4238
  const value = cp[i];
4353
4239
  return value === void 0 ? NONE : value;
4354
4240
  }
@@ -4399,19 +4285,19 @@ function bind(index) {
4399
4285
  return { start: index, end: index + 1, replacement: [NON_BREAKING_HYPHEN], ruleId: "hyphen" };
4400
4286
  }
4401
4287
  function guardCompound(cp, a, k) {
4402
- const before = at4(cp, a - 1);
4288
+ const before = at3(cp, a - 1);
4403
4289
  if (before !== NONE && isWordish(before)) return false;
4404
- const after = at4(cp, a + k);
4290
+ const after = at3(cp, a + k);
4405
4291
  return after === NONE || !isWordish(after);
4406
4292
  }
4407
4293
  function guardPrefix(cp, a, k) {
4408
- const before = at4(cp, a - 1);
4294
+ const before = at3(cp, a - 1);
4409
4295
  if (before !== NONE && isWordish(before)) return false;
4410
- return isLetter(at4(cp, a + k));
4296
+ return isLetter(at3(cp, a + k));
4411
4297
  }
4412
4298
  function guardSuffix(cp, a, k) {
4413
- if (!isLetter(at4(cp, a - 1))) return false;
4414
- const after = at4(cp, a + k);
4299
+ if (!isLetter(at3(cp, a - 1))) return false;
4300
+ const after = at3(cp, a + k);
4415
4301
  return after === NONE || !isWordish(after);
4416
4302
  }
4417
4303
  function scan2(ctx) {
@@ -4489,14 +4375,14 @@ var BRACE_CLOSE = 125;
4489
4375
  var EN_DASH2 = 8211;
4490
4376
  var EM_DASH2 = 8212;
4491
4377
  var ELLIPSIS = 8230;
4492
- function at5(cp, i) {
4378
+ function at4(cp, i) {
4493
4379
  const value = cp[i];
4494
4380
  return value === void 0 ? NONE : value;
4495
4381
  }
4496
4382
  function isDigit4(cp) {
4497
4383
  return cp >= DIGIT_ZERO4 && cp <= DIGIT_NINE4;
4498
4384
  }
4499
- function isAlnum3(cp) {
4385
+ function isAlnum2(cp) {
4500
4386
  return isDigit4(cp) || isLetter(cp);
4501
4387
  }
4502
4388
  function isBreak2(cp) {
@@ -4594,7 +4480,7 @@ function isOpenish(prep, cp) {
4594
4480
  return contains(prep.opens, cp);
4595
4481
  }
4596
4482
  function isCloseish(prep, cp) {
4597
- return contains(prep.closes, cp);
4483
+ return cp === MARKER || contains(prep.closes, cp);
4598
4484
  }
4599
4485
  function isMark(prep, cp) {
4600
4486
  return contains(prep.beforePunctuation, cp) || contains(prep.narrowBeforePunctuation, cp);
@@ -4646,14 +4532,14 @@ function punctuationSubRule(cp, prep, claims, marks, target, other) {
4646
4532
  if (marks.length === 0) return;
4647
4533
  for (let i = 0; i < cp.length; i += 1) {
4648
4534
  if (!contains(marks, cp[i])) continue;
4649
- const left = at5(cp, i - 1);
4535
+ const left = at4(cp, i - 1);
4650
4536
  if (left !== NONE && isMark(prep, left)) continue;
4651
- const after = at5(cp, i + 1);
4537
+ const after = at4(cp, i + 1);
4652
4538
  if (after !== NONE && !isSpaceLike(after) && !isCloseish(prep, after) && after !== ELLIPSIS && !isMark(prep, after)) {
4653
4539
  continue;
4654
4540
  }
4655
4541
  if (isOpenish(prep, left)) continue;
4656
- if (left !== NONE && isSpaceLike(left) && isOpenish(prep, at5(cp, i - 2))) continue;
4542
+ if (left !== NONE && isSpaceLike(left) && isOpenish(prep, at4(cp, i - 2))) continue;
4657
4543
  if (left === target) continue;
4658
4544
  if (left === SPACE2 || left === other) {
4659
4545
  claimConversion(claims, i - 1, target);
@@ -4670,15 +4556,15 @@ function shortWordsSubRule(cp, prep, claims) {
4670
4556
  const w = longestMatch(prep.shortWords, cp, a, matchFirstCharLenient);
4671
4557
  if (w === void 0) continue;
4672
4558
  const k = w.length;
4673
- const before = at5(cp, a - 1);
4559
+ const before = at4(cp, a - 1);
4674
4560
  if (!(before === NONE || isSpaceLike(before) || isOpenish(prep, before) || isSentenceDash(before))) {
4675
4561
  continue;
4676
4562
  }
4677
- const separator = at5(cp, a + k);
4563
+ const separator = at4(cp, a + k);
4678
4564
  if (separator === NBSP) continue;
4679
4565
  if (separator !== SPACE2) continue;
4680
- const next = at5(cp, a + k + 1);
4681
- if (!isAlnum3(next) && !isOpenish(prep, next)) continue;
4566
+ const next = at4(cp, a + k + 1);
4567
+ if (!isAlnum2(next) && !isOpenish(prep, next)) continue;
4682
4568
  claimConversion(claims, a + k, NBSP);
4683
4569
  }
4684
4570
  }
@@ -4688,8 +4574,8 @@ function abbreviationsSubRule(cp, prep, claims) {
4688
4574
  const w = longestMatch(prep.abbreviations, cp, a, matchSpaceLenient);
4689
4575
  if (w === void 0) continue;
4690
4576
  const k = w.length;
4691
- if (isAlnum3(at5(cp, a - 1))) continue;
4692
- if (isAlnum3(at5(cp, a + k))) continue;
4577
+ if (isAlnum2(at4(cp, a - 1))) continue;
4578
+ if (isAlnum2(at4(cp, a + k))) continue;
4693
4579
  for (let j = 0; j < k; j += 1) {
4694
4580
  if (w[j] !== SPACE2) continue;
4695
4581
  if (cp[a + j] === NBSP) continue;
@@ -4703,14 +4589,14 @@ function unitsSubRule(cp, prep, claims) {
4703
4589
  const w = longestMatch(prep.units, cp, a, matchExact);
4704
4590
  if (w === void 0) continue;
4705
4591
  const k = w.length;
4706
- if (isAlnum3(at5(cp, a + k))) continue;
4707
- const left = at5(cp, a - 1);
4592
+ if (isAlnum2(at4(cp, a + k))) continue;
4593
+ const left = at4(cp, a - 1);
4708
4594
  if (left === NBSP) continue;
4709
4595
  if (left !== SPACE2) continue;
4710
- if (!isDigit4(at5(cp, a - 2))) continue;
4596
+ if (!isDigit4(at4(cp, a - 2))) continue;
4711
4597
  let b = a - 2;
4712
4598
  while (b - 1 >= 0 && isDigit4(cp[b - 1])) b -= 1;
4713
- if (isLetter(at5(cp, b - 1))) continue;
4599
+ if (isLetter(at4(cp, b - 1))) continue;
4714
4600
  claimConversion(claims, a - 1, NBSP);
4715
4601
  }
4716
4602
  }
@@ -4720,31 +4606,31 @@ function symbolsSubRule(cp, prep, claims) {
4720
4606
  const w = longestMatch(prep.symbols, cp, a, matchExact);
4721
4607
  if (w === void 0) continue;
4722
4608
  const k = w.length;
4723
- if (isAlnum3(at5(cp, a - 1))) continue;
4724
- const separator = at5(cp, a + k);
4609
+ if (isAlnum2(at4(cp, a - 1))) continue;
4610
+ const separator = at4(cp, a + k);
4725
4611
  if (separator === NBSP) continue;
4726
4612
  if (separator !== SPACE2) continue;
4727
- if (!isDigit4(at5(cp, a + k + 1))) continue;
4613
+ if (!isDigit4(at4(cp, a + k + 1))) continue;
4728
4614
  claimConversion(claims, a + k, NBSP);
4729
4615
  }
4730
4616
  }
4731
4617
  function isInitialAt(cp, prep, p) {
4732
4618
  if (p < 0) return false;
4733
- if (!isUpper(at5(cp, p))) return false;
4734
- if (at5(cp, p + 1) !== FULL_STOP2) return false;
4735
- const before = at5(cp, p - 1);
4619
+ if (!isUpper(at4(cp, p))) return false;
4620
+ if (at4(cp, p + 1) !== FULL_STOP2) return false;
4621
+ const before = at4(cp, p - 1);
4736
4622
  return before === NONE || isSpaceLike(before) || isOpenish(prep, before);
4737
4623
  }
4738
4624
  function isAbbreviationTail(cp, p) {
4739
- if (!isSpaceLike(at5(cp, p - 1))) return false;
4740
- if (at5(cp, p - 2) !== FULL_STOP2) return false;
4741
- const head = at5(cp, p - 3);
4625
+ if (!isSpaceLike(at4(cp, p - 1))) return false;
4626
+ if (at4(cp, p - 2) !== FULL_STOP2) return false;
4627
+ const head = at4(cp, p - 3);
4742
4628
  return isLetter(head) && !isUpper(head);
4743
4629
  }
4744
4630
  function hasPrecedingInitial(cp, prep, p) {
4745
- const gap = at5(cp, p - 1);
4631
+ const gap = at4(cp, p - 1);
4746
4632
  if (gap !== SPACE2 && gap !== NBSP) return false;
4747
- if (at5(cp, p - 2) !== FULL_STOP2) return false;
4633
+ if (at4(cp, p - 2) !== FULL_STOP2) return false;
4748
4634
  return isInitialAt(cp, prep, p - 3);
4749
4635
  }
4750
4636
  function initialsSubRule(cp, prep, claims) {
@@ -4754,10 +4640,10 @@ function initialsSubRule(cp, prep, claims) {
4754
4640
  const here = cp[q];
4755
4641
  if (here !== SPACE2 && here !== NBSP) continue;
4756
4642
  const leftInitialP = q - 2;
4757
- const c1Shape = at5(cp, q - 1) === FULL_STOP2 && isInitialAt(cp, prep, leftInitialP) && isUpper(at5(cp, q + 1)) && !isAbbreviationTail(cp, leftInitialP);
4643
+ const c1Shape = at4(cp, q - 1) === FULL_STOP2 && isInitialAt(cp, prep, leftInitialP) && isUpper(at4(cp, q + 1)) && !isAbbreviationTail(cp, leftInitialP);
4758
4644
  const c1 = c1Shape && (mode === "single" || isInitialAt(cp, prep, q + 1) || hasPrecedingInitial(cp, prep, leftInitialP));
4759
- const rightSpace = at5(cp, q + 3);
4760
- const c2 = isLetter(at5(cp, q - 1)) && isInitialAt(cp, prep, q + 1) && (rightSpace === SPACE2 || rightSpace === NBSP) && isInitialAt(cp, prep, q + 4);
4645
+ const rightSpace = at4(cp, q + 3);
4646
+ const c2 = isLetter(at4(cp, q - 1)) && isInitialAt(cp, prep, q + 1) && (rightSpace === SPACE2 || rightSpace === NBSP) && isInitialAt(cp, prep, q + 4);
4761
4647
  if (!c1 && !c2) continue;
4762
4648
  if (here === NBSP) continue;
4763
4649
  claimConversion(claims, q, NBSP);
@@ -4768,7 +4654,7 @@ function quotesSubRule(cp, prep, claims) {
4768
4654
  for (let i = 0; i < cp.length; i += 1) {
4769
4655
  const here = cp[i];
4770
4656
  if (here === pair.open) {
4771
- const right = at5(cp, i + 1);
4657
+ const right = at4(cp, i + 1);
4772
4658
  if (right === pair.target) continue;
4773
4659
  if (right === SPACE2 || isNoBreak(right)) {
4774
4660
  claimConversion(claims, i + 1, pair.target);
@@ -4779,7 +4665,7 @@ function quotesSubRule(cp, prep, claims) {
4779
4665
  continue;
4780
4666
  }
4781
4667
  if (here !== pair.close) continue;
4782
- const left = at5(cp, i - 1);
4668
+ const left = at4(cp, i - 1);
4783
4669
  if (left === pair.target) continue;
4784
4670
  if (left === SPACE2 || isNoBreak(left)) {
4785
4671
  claimConversion(claims, i - 1, pair.target);
@@ -4799,14 +4685,14 @@ function forwardBindingSubRule(cp, prep, claims, patterns, wantsDigit) {
4799
4685
  if (!wantsDigit && prep.initialBinding !== "none" && k === 2 && isUpper(w[0]) && w[1] === FULL_STOP2) {
4800
4686
  continue;
4801
4687
  }
4802
- const before = at5(cp, a - 1);
4688
+ const before = at4(cp, a - 1);
4803
4689
  if (!(before === NONE || isSpaceLike(before) || isOpenish(prep, before) || isSentenceDash(before))) {
4804
4690
  continue;
4805
4691
  }
4806
- const separator = at5(cp, a + k);
4692
+ const separator = at4(cp, a + k);
4807
4693
  if (separator === NBSP) continue;
4808
4694
  if (separator !== SPACE2) continue;
4809
- const next = at5(cp, a + k + 1);
4695
+ const next = at4(cp, a + k + 1);
4810
4696
  if (isSpaceLike(next)) continue;
4811
4697
  if (wantsDigit ? !isDigit4(next) : !isLetter(next)) continue;
4812
4698
  claimConversion(claims, a + k, NBSP);
@@ -4838,13 +4724,123 @@ var nbspRule = {
4838
4724
  apply: scan3
4839
4725
  };
4840
4726
 
4727
+ // src/rules/quote-ambiguity.ts
4728
+ var LOWER_N = 110;
4729
+ var UPPER_N = 78;
4730
+ var NARROW = /* @__PURE__ */ new Set([
4731
+ 39,
4732
+ 8216,
4733
+ 8217,
4734
+ 8218,
4735
+ 8219,
4736
+ 8249,
4737
+ 8250
4738
+ ]);
4739
+ var INLINE_SPACE = /* @__PURE__ */ new Set([
4740
+ 32,
4741
+ 9,
4742
+ 160,
4743
+ 8239,
4744
+ 8199,
4745
+ 8201,
4746
+ 8202
4747
+ ]);
4748
+ function at5(cp, i) {
4749
+ const value = cp[i];
4750
+ return value === void 0 ? NONE : value;
4751
+ }
4752
+ function asciiLower(cp) {
4753
+ return cp >= 65 && cp <= 90 ? cp + 32 : cp;
4754
+ }
4755
+ function isAlnum3(cp) {
4756
+ const DIGIT_ZERO9 = 48;
4757
+ const DIGIT_NINE8 = 57;
4758
+ return cp >= DIGIT_ZERO9 && cp <= DIGIT_NINE8 || isLetter(cp);
4759
+ }
4760
+ function wordEndsAt(arr, end, word) {
4761
+ const start = end - word.length;
4762
+ if (start < 0) return false;
4763
+ for (let k = 0; k < word.length; k += 1) {
4764
+ const c = at5(arr, start + k);
4765
+ const matches = k === 0 ? asciiLower(c) === asciiLower(word[k]) : c === word[k];
4766
+ if (!matches) return false;
4767
+ }
4768
+ const before = start > 0 ? at5(arr, start - 1) : NONE;
4769
+ return before === NONE || !isAlnum3(before);
4770
+ }
4771
+ function wordStartsAt(arr, start, word) {
4772
+ const n = arr.length;
4773
+ for (let k = 0; k < word.length; k += 1) {
4774
+ const c = at5(arr, start + k);
4775
+ const matches = k === 0 ? asciiLower(c) === asciiLower(word[k]) : c === word[k];
4776
+ if (!matches) return false;
4777
+ }
4778
+ const after = start + word.length < n ? at5(arr, start + word.length) : NONE;
4779
+ return after === NONE || !isAlnum3(after);
4780
+ }
4781
+ function computeIdiomMatchedIndices(arr, idioms) {
4782
+ const vetoed = /* @__PURE__ */ new Set();
4783
+ if (idioms.length === 0) return vetoed;
4784
+ const n = arr.length;
4785
+ const compiled = idioms.map((idiom) => ({
4786
+ left: toCodePoints(idiom.left),
4787
+ elided: toCodePoints(idiom.elided),
4788
+ right: toCodePoints(idiom.right)
4789
+ }));
4790
+ for (let i = 0; i < n; i += 1) {
4791
+ const g = at5(arr, i);
4792
+ if (!NARROW.has(g)) continue;
4793
+ const lLit = i > 0 ? at5(arr, i - 1) : NONE;
4794
+ if (lLit === NONE || !INLINE_SPACE.has(lLit)) continue;
4795
+ for (const idiom of compiled) {
4796
+ const k = idiom.elided.length;
4797
+ const j = i + 1 + k;
4798
+ if (j >= n) continue;
4799
+ let elidedMatches = true;
4800
+ for (let w = 0; w < k; w += 1) {
4801
+ if (at5(arr, i + 1 + w) !== idiom.elided[w]) {
4802
+ elidedMatches = false;
4803
+ break;
4804
+ }
4805
+ }
4806
+ if (!elidedMatches) continue;
4807
+ if (!NARROW.has(at5(arr, j))) continue;
4808
+ const rLit = j + 1 < n ? at5(arr, j + 1) : NONE;
4809
+ if (rLit === NONE || !INLINE_SPACE.has(rLit)) continue;
4810
+ if (!wordEndsAt(arr, i - 1, idiom.left)) continue;
4811
+ if (!wordStartsAt(arr, j + 2, idiom.right)) continue;
4812
+ vetoed.add(i);
4813
+ vetoed.add(j);
4814
+ }
4815
+ }
4816
+ return vetoed;
4817
+ }
4818
+ function computeAmbiguousShapeIndices(cp) {
4819
+ const ambiguous = /* @__PURE__ */ new Set();
4820
+ const n = cp.length;
4821
+ for (let i = 0; i < n; i += 1) {
4822
+ if (!NARROW.has(at5(cp, i))) continue;
4823
+ const lLit = i > 0 ? at5(cp, i - 1) : NONE;
4824
+ if (lLit === NONE || !INLINE_SPACE.has(lLit)) continue;
4825
+ const enclosed = at5(cp, i + 1);
4826
+ if (enclosed !== LOWER_N && enclosed !== UPPER_N) continue;
4827
+ const j = i + 2;
4828
+ if (!NARROW.has(at5(cp, j))) continue;
4829
+ const rLit = j + 1 < n ? at5(cp, j + 1) : NONE;
4830
+ if (rLit === NONE || !INLINE_SPACE.has(rLit)) continue;
4831
+ ambiguous.add(i);
4832
+ ambiguous.add(j);
4833
+ }
4834
+ return ambiguous;
4835
+ }
4836
+
4841
4837
  // src/rules/quotes.ts
4842
4838
  var DIGIT_ZERO5 = 48;
4843
4839
  var DIGIT_NINE5 = 57;
4844
- var SQ3 = 39;
4840
+ var SQ2 = 39;
4845
4841
  var RIGHT_SINGLE_QUOTE = 8217;
4846
4842
  function v1Identity(cp) {
4847
- return cp === SQ3 ? RIGHT_SINGLE_QUOTE : cp;
4843
+ return cp === SQ2 ? RIGHT_SINGLE_QUOTE : cp;
4848
4844
  }
4849
4845
  var WIDE = /* @__PURE__ */ new Set([
4850
4846
  34,
@@ -5262,7 +5258,9 @@ function isEmptyBracketGuarded(left, right) {
5262
5258
  }
5263
5259
  function isLoneDot(cp, e) {
5264
5260
  if (at7(cp, e) !== FULL_STOP4) return true;
5265
- return !isDotlike2(at7(cp, e + 1));
5261
+ const next = at7(cp, e + 1);
5262
+ if (isLetter(next) || isDigitAscii(next)) return false;
5263
+ return !isDotlike2(next);
5266
5264
  }
5267
5265
  function isDigitAscii(cp) {
5268
5266
  return cp >= DIGIT_ZERO7 && cp <= DIGIT_NINE6;
@@ -5632,4 +5630,4 @@ export {
5632
5630
  planRules,
5633
5631
  runRules
5634
5632
  };
5635
- //# sourceMappingURL=chunk-47XAYIKV.js.map
5633
+ //# sourceMappingURL=chunk-OHF7OFWY.js.map