polytypo 1.17.4 → 1.17.5

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/polytypo/data/VERSION +1 -1
  3. data/lib/polytypo/data/fixtures/bg.json +1 -1
  4. data/lib/polytypo/data/fixtures/cs.json +1 -1
  5. data/lib/polytypo/data/fixtures/de-CH.json +1 -1
  6. data/lib/polytypo/data/fixtures/de-DE.json +1 -1
  7. data/lib/polytypo/data/fixtures/el.json +1 -1
  8. data/lib/polytypo/data/fixtures/en-GB.json +64 -1
  9. data/lib/polytypo/data/fixtures/en-US.json +64 -1
  10. data/lib/polytypo/data/fixtures/es.json +1 -1
  11. data/lib/polytypo/data/fixtures/fi.json +1 -1
  12. data/lib/polytypo/data/fixtures/fr-CA.json +1 -1
  13. data/lib/polytypo/data/fixtures/fr.json +1 -1
  14. data/lib/polytypo/data/fixtures/hr.json +1 -1
  15. data/lib/polytypo/data/fixtures/hu.json +1 -1
  16. data/lib/polytypo/data/fixtures/it.json +1 -1
  17. data/lib/polytypo/data/fixtures/locale-resolution.json +1 -1
  18. data/lib/polytypo/data/fixtures/lt.json +1 -1
  19. data/lib/polytypo/data/fixtures/nl.json +1 -1
  20. data/lib/polytypo/data/fixtures/pl.json +1 -1
  21. data/lib/polytypo/data/fixtures/pt-BR.json +1 -1
  22. data/lib/polytypo/data/fixtures/pt-PT.json +1 -1
  23. data/lib/polytypo/data/fixtures/ro.json +1 -1
  24. data/lib/polytypo/data/fixtures/ru.json +1 -1
  25. data/lib/polytypo/data/fixtures/sk.json +1 -1
  26. data/lib/polytypo/data/fixtures/sl.json +1 -1
  27. data/lib/polytypo/data/fixtures/sr.json +1 -1
  28. data/lib/polytypo/data/fixtures/sv.json +1 -1
  29. data/lib/polytypo/data/fixtures/tr.json +1 -1
  30. data/lib/polytypo/data/fixtures/uk.json +1 -1
  31. data/lib/polytypo/data/locales/registry.json +1 -1
  32. data/lib/polytypo/data/rules/modes.md +49 -4
  33. data/lib/polytypo/data/rules/order.json +1 -1
  34. data/lib/polytypo/modes/spans.rb +53 -2
  35. data/lib/polytypo/version.rb +1 -1
  36. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69eb58cbd8946cae18ab808072463befab815d630a56201029a26535b5530c34
4
- data.tar.gz: babcc5deb500d02ca502b845c193ceccf7ab81a8ef6f64de47fc4433cf650348
3
+ metadata.gz: 1ada78393268412e145c286f3a52ca2b1529637472b413e2ad96533763ca4feb
4
+ data.tar.gz: ca2eab4d74188ca6f57e71a573722e8b51454621e2d648fcd4df6417d4a2701b
5
5
  SHA512:
6
- metadata.gz: 235400a68e2ff2b49dca1e934ea57cf17e913ac2028ad09161a9b76d2eb7cb4d63aa4143d3426629037332c8c564a30f93d89ff71d9690c757a6e8cf11d3fafc
7
- data.tar.gz: 295dd2e1443b5d7c5e1fb3098bf060e3740fd8d420d5d4eebbe7e2dae34607bd1c8a5c96bfd35bf358ce8cfa508518d919a77cc566809f9b6f9084edd8b5934c
6
+ metadata.gz: 72da361c3230aa58f7c06cb595685d53e6a949858eae318ae207fc5819924c598d99246393afdc917c3abe1431a6cbe88d548133e758668ef3d23ad382bfc6f2
7
+ data.tar.gz: b7b2f9646e6f326010604a6097409d34e3c80b3ffabf4a28582946832c4705da343437bd538188363b32b97393889f6ed204d06de47cf315623e80765e61830e
@@ -1 +1 @@
1
- 1.17.4
1
+ 1.17.5
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "bg",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "cs",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "de-CH",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "de-DE",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "el",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "en-GB",
4
4
  "cases": [
5
5
  {
@@ -1871,6 +1871,69 @@
1871
1871
  "in": "Note[^a's] and it's.\n\n[^a's]: it's text\n",
1872
1872
  "out": "Note[^a's] and it’s.\n\n[^a's]: it’s text\n",
1873
1873
  "note": "modes.md §3.7.3: footnote labels are skipped in both dialects."
1874
+ },
1875
+ {
1876
+ "id": "en-gb-markdown-commonmark-bracket-task-marker-space-after-open",
1877
+ "rule": "spaces",
1878
+ "mode": "markdown",
1879
+ "dialect": "commonmark",
1880
+ "in": "- [ x] item and a , b.\n",
1881
+ "out": "- [ x] item and a, b.\n",
1882
+ "note": "modes.md §3.4 bracket-shape rule: deleting the space after the opening bracket would make a task-list marker for a parser with GFM extensions; that edit is discarded. The space in a , b is deleted as usual."
1883
+ },
1884
+ {
1885
+ "id": "en-gb-markdown-commonmark-bracket-task-marker-space-before-close",
1886
+ "rule": "spaces",
1887
+ "mode": "markdown",
1888
+ "dialect": "commonmark",
1889
+ "in": "- [x ] item and a , b.\n",
1890
+ "out": "- [x ] item and a, b.\n",
1891
+ "note": "modes.md §3.4 bracket-shape rule: the same marker from the other side: deleting the space before the closing bracket is discarded."
1892
+ },
1893
+ {
1894
+ "id": "en-gb-markdown-commonmark-bracket-task-marker-both-spaces",
1895
+ "rule": "spaces",
1896
+ "mode": "markdown",
1897
+ "dialect": "commonmark",
1898
+ "in": "- [ X ] item , y\n",
1899
+ "out": "- [ X ] item, y\n",
1900
+ "note": "modes.md §3.4 bracket-shape rule: the skip over spaces keeps both deletions from being evaluated as safe on their own; the two are discarded together, and the space before the comma is deleted."
1901
+ },
1902
+ {
1903
+ "id": "en-gb-markdown-commonmark-bracket-footnote-space-after-open",
1904
+ "rule": "spaces",
1905
+ "mode": "markdown",
1906
+ "dialect": "commonmark",
1907
+ "in": "a [ ^1] b , c\n\n[^1]: n\n",
1908
+ "out": "a [ ^1] b, c\n\n[^1]: n\n",
1909
+ "note": "modes.md §3.4 bracket-shape rule: deleting the space after the opening bracket would make a footnote reference; that edit is discarded."
1910
+ },
1911
+ {
1912
+ "id": "en-gb-markdown-commonmark-bracket-footnote-space-before-close",
1913
+ "rule": "spaces",
1914
+ "mode": "markdown",
1915
+ "dialect": "commonmark",
1916
+ "in": "a [^1 ] b , c\n\n[^1]: n\n",
1917
+ "out": "a [^1 ] b, c\n\n[^1]: n\n",
1918
+ "note": "modes.md §3.4 bracket-shape rule: deleting the space before the closing bracket would make a footnote reference; that edit is discarded."
1919
+ },
1920
+ {
1921
+ "id": "en-gb-markdown-commonmark-bracket-ordinary-text-still-tightened",
1922
+ "rule": "spaces",
1923
+ "mode": "markdown",
1924
+ "dialect": "commonmark",
1925
+ "in": "a [ word ] b and ( x ) c.\n",
1926
+ "out": "a [word] b and (x) c.\n",
1927
+ "note": "modes.md §3.4 bracket-shape rule: the rule tests a shape, not a bracket: a bracket around an ordinary word, and a parenthesis around a single letter, are tightened as before."
1928
+ },
1929
+ {
1930
+ "id": "en-gb-markdown-commonmark-bracket-task-marker-two-spaces",
1931
+ "rule": "spaces",
1932
+ "mode": "markdown",
1933
+ "dialect": "commonmark",
1934
+ "in": "- [ ] item and a , b.\n",
1935
+ "out": "- [ ] item and a, b.\n",
1936
+ "note": "modes.md §3.4 bracket-shape rule: collapsing two spaces between the brackets to one would make an unchecked task-list marker out of literal text; that edit is discarded."
1874
1937
  }
1875
1938
  ]
1876
1939
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "en-US",
4
4
  "cases": [
5
5
  {
@@ -4284,6 +4284,69 @@
4284
4284
  "in": "Read https://example.com/a -- fine and b -- c\n",
4285
4285
  "out": "Read https://example.com/a -- fine and b—c\n",
4286
4286
  "note": "modes.md §3.7.3 terminator guard: collapsing the spaced dash would delete the space that ends the URL, and the parser would read the dash and the next word as part of it; that edit is discarded. The same collapse away from a URL (b -- c) is applied."
4287
+ },
4288
+ {
4289
+ "id": "en-us-markdown-commonmark-bracket-task-marker-space-after-open",
4290
+ "rule": "spaces",
4291
+ "mode": "markdown",
4292
+ "dialect": "commonmark",
4293
+ "in": "- [ x] item and a , b.\n",
4294
+ "out": "- [ x] item and a, b.\n",
4295
+ "note": "modes.md §3.4 bracket-shape rule: deleting the space after the opening bracket would make a task-list marker for a parser with GFM extensions; that edit is discarded. The space in a , b is deleted as usual."
4296
+ },
4297
+ {
4298
+ "id": "en-us-markdown-commonmark-bracket-task-marker-space-before-close",
4299
+ "rule": "spaces",
4300
+ "mode": "markdown",
4301
+ "dialect": "commonmark",
4302
+ "in": "- [x ] item and a , b.\n",
4303
+ "out": "- [x ] item and a, b.\n",
4304
+ "note": "modes.md §3.4 bracket-shape rule: the same marker from the other side: deleting the space before the closing bracket is discarded."
4305
+ },
4306
+ {
4307
+ "id": "en-us-markdown-commonmark-bracket-task-marker-both-spaces",
4308
+ "rule": "spaces",
4309
+ "mode": "markdown",
4310
+ "dialect": "commonmark",
4311
+ "in": "- [ X ] item , y\n",
4312
+ "out": "- [ X ] item, y\n",
4313
+ "note": "modes.md §3.4 bracket-shape rule: the skip over spaces keeps both deletions from being evaluated as safe on their own; the two are discarded together, and the space before the comma is deleted."
4314
+ },
4315
+ {
4316
+ "id": "en-us-markdown-commonmark-bracket-footnote-space-after-open",
4317
+ "rule": "spaces",
4318
+ "mode": "markdown",
4319
+ "dialect": "commonmark",
4320
+ "in": "a [ ^1] b , c\n\n[^1]: n\n",
4321
+ "out": "a [ ^1] b, c\n\n[^1]: n\n",
4322
+ "note": "modes.md §3.4 bracket-shape rule: deleting the space after the opening bracket would make a footnote reference; that edit is discarded."
4323
+ },
4324
+ {
4325
+ "id": "en-us-markdown-commonmark-bracket-footnote-space-before-close",
4326
+ "rule": "spaces",
4327
+ "mode": "markdown",
4328
+ "dialect": "commonmark",
4329
+ "in": "a [^1 ] b , c\n\n[^1]: n\n",
4330
+ "out": "a [^1 ] b, c\n\n[^1]: n\n",
4331
+ "note": "modes.md §3.4 bracket-shape rule: deleting the space before the closing bracket would make a footnote reference; that edit is discarded."
4332
+ },
4333
+ {
4334
+ "id": "en-us-markdown-commonmark-bracket-ordinary-text-still-tightened",
4335
+ "rule": "spaces",
4336
+ "mode": "markdown",
4337
+ "dialect": "commonmark",
4338
+ "in": "a [ word ] b and ( x ) c.\n",
4339
+ "out": "a [word] b and (x) c.\n",
4340
+ "note": "modes.md §3.4 bracket-shape rule: the rule tests a shape, not a bracket: a bracket around an ordinary word, and a parenthesis around a single letter, are tightened as before."
4341
+ },
4342
+ {
4343
+ "id": "en-us-markdown-commonmark-bracket-task-marker-two-spaces",
4344
+ "rule": "spaces",
4345
+ "mode": "markdown",
4346
+ "dialect": "commonmark",
4347
+ "in": "- [ ] item and a , b.\n",
4348
+ "out": "- [ ] item and a, b.\n",
4349
+ "note": "modes.md §3.4 bracket-shape rule: collapsing two spaces between the brackets to one would make an unchecked task-list marker out of literal text; that edit is discarded."
4287
4350
  }
4288
4351
  ]
4289
4352
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "es",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "fi",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "fr-CA",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "fr",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "hr",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "hu",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "it",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "cases": [
4
4
  {
5
5
  "id": "exact-en-us",
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "lt",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "nl",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "pl",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "pt-BR",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "pt-PT",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "ro",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "ru",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "sk",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "sl",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "sr",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "sv",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "tr",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "locale": "uk",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "$comment": "Locale resolution input. Algorithm is specified in spec/rules/locale-resolution.md and is identical in every runtime — never delegate it to a platform locale-negotiation library. \"spec\" here must track spec/VERSION exactly — it is not itself the global version source; scripts/validate-spec.mjs enforces the match.",
4
4
  "locales": [
5
5
  "en-US",
@@ -19,7 +19,7 @@ step 9 with §3.8.5's content-line condition, added in 1.10.0, §3.8.4's carriag
19
19
  continuation line with the bails of §3.8.6 that use it, added in 1.11.0, and §3.8.4's node lines,
20
20
  declined keys, node markers and own-line region, with the changes to steps 1, 3, 4, 5, 6, 7 and 8
21
21
  that go with them, added in 1.11.0, and §3.9 with the amendments it carries to §3.1, §3.5 step 2,
22
- §4, §5, §7 item 7 and §8, added in 1.13.0, and §3.4's delimiter-neighbour rule with §3.7.3's autolink-literal tail, terminator guard and reference labels, and the amendments they carry to §3.4's deletion paragraph, §5 items 2 and 3, its fifth-part note and testing obligation, and §6, added in 1.17.2, and §3.4's escape-and-reference rule with the amendments it carries to §3.6, §3.7.3, §5 item 2's fifth-part note, §5 item 3 and the testing obligation, added in 1.17.4).
22
+ §4, §5, §7 item 7 and §8, added in 1.13.0, and §3.4's delimiter-neighbour rule with §3.7.3's autolink-literal tail, terminator guard and reference labels, and the amendments they carry to §3.4's deletion paragraph, §5 items 2 and 3, its fifth-part note and testing obligation, and §6, added in 1.17.2, and §3.4's escape-and-reference rule with the amendments it carries to §3.6, §3.7.3, §5 item 2's fifth-part note, §5 item 3 and the testing obligation, added in 1.17.4, and §3.4's bracket-shape rule, added in 1.17.5).
23
23
 
24
24
  ---
25
25
 
@@ -460,6 +460,48 @@ in five runtimes; it is therefore stricter than a parser: `AT&T ;x` (en-US) keep
460
460
  though `&T;` is no reference. **That is the accepted cost**, together with a literal backslash
461
461
  before a space and punctuation, which is rare in prose.
462
462
 
463
+ **The bracket-shape rule (`markdown` only, spec 1.17.5).** Three more shapes are made by joining
464
+ what a deleted space kept apart, and both dialects, which enable GFM (§3.7), read the joined form
465
+ as structure where the spaced form is literal text: a task-list marker, `[x]`, `[X]` or `[ ]` at the
466
+ start of a list item, and a footnote reference or definition, `[^label]`. Measured, with the
467
+ pre-1.17.5 behaviour:
468
+
469
+ | Mode | Input | Locale | Output before 1.17.5 | What changed |
470
+ | ---------- | ------------- | ------- | -------------------- | --------------------------------------------------------------- |
471
+ | `markdown` | `- [ x] item` | `en-GB` | `- [x] item` | the text of a literal bracket becomes a checked task-list item |
472
+ | `markdown` | `- [x ] item` | `en-GB` | `- [x] item` | the same item, from the other side |
473
+ | `markdown` | `- [ ] item` | `en-GB` | `- [ ] item` | two spaces become one, and the text becomes an unchecked item |
474
+ | `markdown` | `a [ ^1] b` | `en-GB` | `a [^1] b` | a footnote reference, if a definition `[^1]: …` exists |
475
+
476
+ Write `SKIP(i, +1)` for the smallest index greater than `i` whose code point is not U+0020, and
477
+ `SKIP(i, −1)` for the largest index smaller than `i` whose code point is not U+0020; a marker, or a
478
+ position outside the array, belongs to no class below. With `p`, `q` and `r` as before, and
479
+ `a = SKIP(p, −1)` and `b = SKIP(q, +1)` (so that `a` and `b` are the nearest code points that are
480
+ not U+0020 on either side of the deleted run):
481
+
482
+ > **A deletion (`r = 0`) is discarded if either of these holds, evaluated on the array the rule read.**
483
+ >
484
+ > 1. `cp[a]` is U+005B, and either `cp[b]` is U+005E or U+005D, or `cp[b]` is U+0078 or U+0058 and
485
+ > `cp[SKIP(b, +1)]` is U+005D.
486
+ > 2. `cp[b]` is U+005D, and either `cp[a]` is U+0078 or U+0058 and `cp[SKIP(a, −1)]` is U+005B, or
487
+ > the **label run** is at least two code points long, its leftmost code point is U+005E, and
488
+ > the nearest code point left of the run that is not U+0020 is U+005B. The label run is the
489
+ > longest run ending at `a` of code points that are none of U+0020, U+005B, U+005D, and not a
490
+ > marker.
491
+ >
492
+ > **An edit whose replacement is the single code point U+0020 is discarded** when `cp[a]` is U+005B
493
+ > and `cp[b]` is U+005D: `spaces` collapses a run of spaces to one rather than deleting it, and
494
+ > `[ ]` becoming `[ ]` is the unchecked marker.
495
+
496
+ The skip over U+0020 is what keeps `[ x ]` whole: the two deletions are evaluated on the same
497
+ array, and each sees the other space as absent. The rule reads no parser state and no dialect, so it
498
+ fires identically on every run (§5 item 3), and it tests deletions only because `spaces` is the
499
+ only rule that deletes. It is a test of _shape_, not of whether a footnote definition or a list item
500
+ exists. **The accepted costs:** `a [ x] b` in the middle of a sentence keeps its space although no
501
+ list item is there, as do `[ x ]`, `[ ^1]` and `[ ]` in prose; `a [ ^ ] b` loses its second space only,
502
+ because a label run needs two code points; and a footnote label that contains an inline element
503
+ (`[^*a*b ]`) is missed, because a marker ends the label run.
504
+
463
505
  ### 3.5 Applying the result
464
506
 
465
507
  1. Extract the span sequence from the source. Record each span's **source offsets**.
@@ -1830,7 +1872,8 @@ they do not carry it over for free either. Write `M` for the whole mode transfor
1830
1872
  can also create a backslash escape or a character reference from literal text (`foo\ ,`
1831
1873
  becomes `foo\,` and `AT&amp ;T` becomes `AT&T`): the parse tree keeps its shape and its
1832
1874
  text changes, which a shape comparison does not see. That class was not closed by 1.17.2 and
1833
- is closed by §3.4's escape-and-reference rule (spec 1.17.4).
1875
+ is closed by §3.4's escape-and-reference rule (spec 1.17.4). A deletion can also join
1876
+ `[` and `x` or `^` into a shape a GFM parser reads as structure, and §3.4's bracket-shape rule (spec 1.17.5) closes that.
1834
1877
  - **Deletion** is only ever of a U+0020, and structural whitespace borders a `BREAK` — a real
1835
1878
  one in `text` mode, a −2 marker in the others — where `spaces` refuses to act
1836
1879
  (`spaces.md` §3.2 step 4). A deletion therefore cannot turn `- item` into `-item`, collapse
@@ -1904,7 +1947,7 @@ they do not carry it over for free either. Write `M` for the whole mode transfor
1904
1947
  to a side. The discard is a pure function of the array and its span table (since 1.17.2: of
1905
1948
  `(p, q, r, s₀, s₁)`, of the code points beside the edit for §3.4's delimiter-neighbour rule, of
1906
1949
  the same code points and the run of letters and digits around the join for §3.4's
1907
- escape-and-reference rule (since 1.17.4), and of whether the span begins at the end of a web address for §3.7.3's terminator guard), so it
1950
+ escape-and-reference rule (since 1.17.4), of the code points around the join for §3.4's bracket-shape rule (since 1.17.5), and of whether the span begins at the end of a web address for §3.7.3's terminator guard), so it
1908
1951
  happens identically on every run: a rule that was declined at an edge once is declined there always, and the output
1909
1952
  contains nothing for the next run to reconsider.
1910
1953
 
@@ -1944,7 +1987,9 @@ must include an address with `_`, `*` and `~` inside it after `"`, `'` and `(`,
1944
1987
  directly after a digit. **Since 1.17.4 the comparison also covers the text values of the tree**, not only its shape: the
1945
1988
  defect behind the escape-and-reference rule left the shape unchanged. The alphabet must then include
1946
1989
  U+005C, `&`, `#`, `;`, `,` and a letter, and the templates a literal backslash and a literal
1947
- `&name` each followed by a space and by each punctuation mark. **Two classes are carved out because they are accepted, not because
1990
+ `&name` each followed by a space and by each punctuation mark. **Since 1.17.5 the alphabet also includes** U+005B, U+005D, U+005E,
1991
+ `x` and `X`, and the templates a list item and a footnote definition each holding every
1992
+ combination of those with zero, one or two spaces inside the brackets. **Two classes are carved out because they are accepted, not because
1948
1993
  they are untested**: a text that matched no definition in the input and matches one in the output
1949
1994
  (§3.7.3's accepted case), and an e-mail address, whose end only the parser decides.
1950
1995
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.17.4",
2
+ "spec": "1.17.5",
3
3
  "$comment": "Single source of truth for pipeline order. Rules run in ascending `order`. Disabling a rule removes it from the sequence and never reorders the rest. Rule ids are public API (see docs/ARCHITECTURE.md section 5). \"spec\" here must track spec/VERSION exactly — it is not itself the global version source; scripts/validate-spec.mjs enforces the match.",
4
4
  "rules": [
5
5
  {
@@ -189,6 +189,56 @@ module Polytypo
189
189
  end
190
190
  private_class_method :creates_reference?
191
191
 
192
+ # modes.md 3.4 bracket-shape rule (markdown only, spec 1.17.5): a deletion that joins a
193
+ # task-list marker or a footnote label. A marker or a position outside the array is in no
194
+ # class. Ruby indexes negatively, so every read goes through +code_point_at+.
195
+ def self.code_point_at(cp, i)
196
+ i.negative? ? nil : cp[i]
197
+ end
198
+ private_class_method :code_point_at
199
+
200
+ def self.skip_spaces(cp, i, step)
201
+ k = i
202
+ k += step while k >= 0 && k < cp.length && cp[k] == SPACE
203
+ k
204
+ end
205
+ private_class_method :skip_spaces
206
+
207
+ def self.x_letter?(c)
208
+ c == 0x78 || c == 0x58
209
+ end
210
+ private_class_method :x_letter?
211
+
212
+ def self.label_character?(c)
213
+ !c.nil? && c >= 0 && c != SPACE && c != 0x5B && c != 0x5D
214
+ end
215
+ private_class_method :label_character?
216
+
217
+ def self.creates_bracket_shape?(cp, p, q, replacement)
218
+ is_collapse = replacement.length == 1 && replacement[0] == SPACE
219
+ return false unless replacement.empty? || is_collapse
220
+
221
+ a = skip_spaces(cp, p - 1, -1)
222
+ b = skip_spaces(cp, q + 1, 1)
223
+ at_a = code_point_at(cp, a)
224
+ at_b = code_point_at(cp, b)
225
+ return at_a == 0x5B && at_b == 0x5D if is_collapse
226
+ return true if at_a == 0x5B && at_b == 0x5D
227
+ if at_a == 0x5B
228
+ return true if at_b == 0x5E
229
+
230
+ return x_letter?(at_b) && code_point_at(cp, skip_spaces(cp, b + 1, 1)) == 0x5D
231
+ end
232
+ return false if at_b != 0x5D
233
+ return true if x_letter?(at_a) && code_point_at(cp, skip_spaces(cp, a - 1, -1)) == 0x5B
234
+
235
+ run = a
236
+ run -= 1 while run >= 0 && label_character?(cp[run])
237
+ first = run + 1
238
+ a - first >= 1 && cp[first] == 0x5E && code_point_at(cp, skip_spaces(cp, run, -1)) == 0x5B
239
+ end
240
+ private_class_method :creates_bracket_shape?
241
+
192
242
  # modes.md 3.4, two safety nets, both pure functions of (p, q, r, s0, s1):
193
243
  #
194
244
  # 1. No edit may contain a marker -- one that does is a bug, discarded rather than
@@ -202,8 +252,8 @@ module Polytypo
202
252
  # point any rule emits whose meaning comes from its position rather than from itself
203
253
  # (modes.md 5 item 2).
204
254
  #
205
- # +mode+ selects the neighbour rules of modes.md 3.4 -- delimiter-neighbour and the escape rule
206
- # for markdown, the reference rule for markdown and html -- and +guarded+ holds, per span,
255
+ # +mode+ selects the neighbour rules of modes.md 3.4 -- delimiter-neighbour, the escape rule
256
+ # and the bracket-shape rule for markdown, the reference rule for markdown and html -- and +guarded+ holds, per span,
207
257
  # whether its first code point is the terminator of a bare web address (modes.md 3.7.3).
208
258
  def self.filter_boundary_edits(cp, edits, ranges, mode: nil, guarded: [])
209
259
  edits.select do |edit|
@@ -216,6 +266,7 @@ module Polytypo
216
266
  markdown = mode == "markdown"
217
267
  next false if markdown && changes_delimiter_flank?(cp, p, q, edit.replacement)
218
268
  next false if markdown && creates_escape?(cp, p, q, edit.replacement)
269
+ next false if markdown && creates_bracket_shape?(cp, p, q, edit.replacement)
219
270
  next false if (markdown || mode == "html") && creates_reference?(cp, p, q, edit.replacement)
220
271
 
221
272
  span = span_containing(ranges, p)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polytypo
4
- VERSION = "1.17.4"
4
+ VERSION = "1.17.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polytypo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.4
4
+ version: 1.17.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iurii Rogulia