polytypo 1.22.1 → 1.23.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. 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 +1 -1
  9. data/lib/polytypo/data/fixtures/en-US.json +109 -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 +20 -3
  33. data/lib/polytypo/data/rules/order.json +1 -1
  34. data/lib/polytypo/data/rules/quote-punctuation.md +11 -7
  35. data/lib/polytypo/modes/html.rb +10 -0
  36. data/lib/polytypo/version.rb +1 -1
  37. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 628f79717701bdcc0e0ab7c2404871531419d1eeba728038bb3da3d368c60ea9
4
- data.tar.gz: ee52fdea129fc159545c3b83a986839f982bfc9614fef90f9c14adc4da196dc4
3
+ metadata.gz: cf32a1fd59f440c4a84d20c8bfc7b060dedbe31ef49645157c7c6a9444de5ee2
4
+ data.tar.gz: b5dbda1251e0ba0126e3c7c5434d499222043ffac43b54ceb3de59e522f3b9e8
5
5
  SHA512:
6
- metadata.gz: ed34c803c365eb7dee5e03c5c73d5325319e1a41553b0473d14186bcd782b27eec92ac7f2a70bd0d8320ad3d20a10b9dbff81057a26147fc582d492859584ba8
7
- data.tar.gz: 7db118f6093c809a0e083c59189377ada3c2d2b060d9776ecf5bbb4b2bd3f0b6ef13614a0d06566890139be5a500a532fd12930cd14b18e7d6b0c80679ce216c
6
+ metadata.gz: 6b4fbc155ef5232f02f6dae3e2a487d0ef538e51840f7d5d344f08734810553e66c9dcfba93838926e65c95e73a9c7d0aaf43342152bbc82c8423c479c9e84ac
7
+ data.tar.gz: d8149021c09b493ed7cd2e77275e893898e1be9502856797a2e01d8c89eedae0b370681cb4e4e8e30dcc5333330bd666777bd1e6a730d881f209f7d53c632566
@@ -1 +1 @@
1
- 1.22.0
1
+ 1.23.0
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "bg",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "cs",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "de-CH",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "de-DE",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "el",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "en-GB",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "en-US",
4
4
  "cases": [
5
5
  {
@@ -4993,6 +4993,114 @@
4993
4993
  },
4994
4994
  "note": "quote-punctuation.md §3.3, §6 row H5, accepted cost: the gap between the paragraphs is a -1 marker at cp[i+2], so C4 fails."
4995
4995
  },
4996
+ {
4997
+ "id": "en-us-quote-punctuation-html-line-break-gap",
4998
+ "rule": "quote-punctuation",
4999
+ "mode": "html",
5000
+ "in": "<p>She said \"hello\".</p>\n<p>Next.</p>",
5001
+ "out": "<p>She said “hello.”</p>\n<p>Next.</p>",
5002
+ "rules": {
5003
+ "quote-punctuation": true
5004
+ },
5005
+ "note": "quote-punctuation.md §3.3, §6 row H6; modes.md §3.6: the whitespace-only text node holding the line feed is not a span, so the gap is a -2 marker at cp[i+2] and C4 holds."
5006
+ },
5007
+ {
5008
+ "id": "en-us-quote-punctuation-html-blank-lines-gap",
5009
+ "rule": "quote-punctuation",
5010
+ "mode": "html",
5011
+ "in": "<p>She said \"hello\".</p>\n\n <p>Next.</p>",
5012
+ "out": "<p>She said “hello.”</p>\n\n <p>Next.</p>",
5013
+ "rules": {
5014
+ "quote-punctuation": true
5015
+ },
5016
+ "note": "modes.md §3.6: a whitespace-only text node of line feeds and spaces is skipped whole."
5017
+ },
5018
+ {
5019
+ "id": "en-us-quote-punctuation-html-crlf-gap",
5020
+ "rule": "quote-punctuation",
5021
+ "mode": "html",
5022
+ "in": "<p>She said \"hello\".</p>\r\n<p>Next.</p>",
5023
+ "out": "<p>She said “hello.”</p>\r\n<p>Next.</p>",
5024
+ "rules": {
5025
+ "quote-punctuation": true
5026
+ },
5027
+ "note": "modes.md §3.6: a run of CR and LF is whitespace-only with a line break, so it is not a span."
5028
+ },
5029
+ {
5030
+ "id": "en-us-quote-punctuation-html-form-feed-gap",
5031
+ "rule": "quote-punctuation",
5032
+ "mode": "html",
5033
+ "in": "<p>She said \"hello\".</p>\f<p>Next.</p>",
5034
+ "out": "<p>She said “hello.”</p>\f<p>Next.</p>",
5035
+ "rules": {
5036
+ "quote-punctuation": true
5037
+ },
5038
+ "note": "modes.md §3.6: U+000C is a line terminator in §3.2's sense, so a run of it between the blocks is not a span."
5039
+ },
5040
+ {
5041
+ "id": "en-us-quote-punctuation-html-reference-in-gap-space",
5042
+ "rule": "quote-punctuation",
5043
+ "mode": "html",
5044
+ "in": "<p>She said \"hello\".</p>\n&#32;\n<p>Next.</p>",
5045
+ "out": "<p>She said “hello”.</p>\n&#32;\n<p>Next.</p>",
5046
+ "rules": {
5047
+ "quote-punctuation": true
5048
+ },
5049
+ "note": "modes.md §3.6: a character reference is never whitespace for the test, so the run stays spans and the markers are -1."
5050
+ },
5051
+ {
5052
+ "id": "en-us-quote-punctuation-html-reference-in-gap-amp",
5053
+ "rule": "quote-punctuation",
5054
+ "mode": "html",
5055
+ "in": "<p>She said \"hello\".</p>\n&amp;\n<p>Next.</p>",
5056
+ "out": "<p>She said “hello”.</p>\n&amp;\n<p>Next.</p>",
5057
+ "rules": {
5058
+ "quote-punctuation": true
5059
+ },
5060
+ "note": "modes.md §3.6: as for &#32;, the reference keeps the run processable."
5061
+ },
5062
+ {
5063
+ "id": "en-us-quote-punctuation-html-trailing-line-break",
5064
+ "rule": "quote-punctuation",
5065
+ "mode": "html",
5066
+ "in": "<p>She said \"hello\".</p>\n",
5067
+ "out": "<p>She said “hello.”</p>\n",
5068
+ "rules": {
5069
+ "quote-punctuation": true
5070
+ },
5071
+ "note": "modes.md §3.6, §3.5 step 2: the trailing line feed is not a span and leaves no marker, so cp[i+2] is NONE and the stop moves."
5072
+ },
5073
+ {
5074
+ "id": "en-us-quote-punctuation-markdown-html-block-line-break-gap",
5075
+ "rule": "quote-punctuation",
5076
+ "mode": "markdown",
5077
+ "dialect": "commonmark",
5078
+ "in": "<div>\n<p>She said \"hello\".</p>\n<p>Next.</p>\n</div>\n",
5079
+ "out": "<div>\n<p>She said “hello.”</p>\n<p>Next.</p>\n</div>\n",
5080
+ "rules": {
5081
+ "quote-punctuation": true
5082
+ },
5083
+ "note": "modes.md §3.6, §3.7.3: a markdown HTML block uses the html rule, so the line feed between the paragraphs is a -2 marker."
5084
+ },
5085
+ {
5086
+ "id": "en-us-quote-punctuation-html-space-only-node",
5087
+ "rule": "quote-punctuation",
5088
+ "mode": "html",
5089
+ "in": "<p>She said \"hello\".</p> <p>Next.</p>",
5090
+ "out": "<p>She said “hello”.</p> <p>Next.</p>",
5091
+ "rules": {
5092
+ "quote-punctuation": true
5093
+ },
5094
+ "note": "modes.md §3.6: a whitespace-only text node with no line break is still a span, so the markers around it are -1 and C4 fails."
5095
+ },
5096
+ {
5097
+ "id": "en-us-dashes-html-spaced-hyphen-on-own-line",
5098
+ "rule": "dashes",
5099
+ "mode": "html",
5100
+ "in": "<p>a</p>\n<p> - </p>\n<p>b</p>",
5101
+ "out": "<p>a</p>\n<p> - </p>\n<p>b</p>",
5102
+ "note": "modes.md §3.6, accepted cost: the line feeds around the paragraph are -2 markers, a BREAK at cp[L] and cp[R], so dashes declines the token as it does in text mode."
5103
+ },
4996
5104
  {
4997
5105
  "id": "en-us-quote-punctuation-markdown-commonmark-one-span",
4998
5106
  "rule": "quote-punctuation",
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "es",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "fi",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "fr-CA",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "fr",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "hr",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "hu",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "it",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "cases": [
4
4
  {
5
5
  "id": "exact-en-us",
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "lt",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "nl",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "pl",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "pt-BR",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "pt-PT",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "ro",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "ru",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "sk",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "sl",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "sr",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "sv",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "tr",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
3
3
  "locale": "uk",
4
4
  "cases": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
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, and §3.4's bracket-shape rule, added in 1.17.5).
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, and §3.6's whitespace-only text node rule, added in 1.23.0).
23
23
 
24
24
  ---
25
25
 
@@ -125,7 +125,7 @@ possibility of collision with author content and makes the classification table
125
125
 
126
126
  The test is on the raw source bytes of the gap, so it is decidable without asking the parser
127
127
  anything and is identical in five runtimes. `a<em>x</em>b` gives −1; `foo\nbar`, `foo\n\nbar`
128
- and `<p>a</p>\n<p>b</p>` all give −2.
128
+ and `<p>a</p>\n<p>b</p>` all give −2 (in the last the text node `\n` is not a span, §3.6).
129
129
 
130
130
  **Why a line boundary is a `BREAK` and not just another opaque marker.** Every rule already has
131
131
  correct, specified, fixture-covered behaviour at a line terminator, because `text` mode has real
@@ -539,7 +539,24 @@ Skipped, exhaustively and exactly:
539
539
  conversions on both sides of it for nothing — `Tom & Jerry's "book"` would lose the pairing of
540
540
  its quotation marks. Well-formedness, not the presence of an ampersand, is what makes a
541
541
  skipped region;
542
- - comments, CDATA, doctype, processing instructions, and any prologue.
542
+ - comments, CDATA, doctype, processing instructions, and any prologue;
543
+ - every **whitespace-only text run that contains a line break** (since 1.23.0): a maximal run of
544
+ source text between two pieces of markup (a tag, comment, CDATA section, doctype or processing
545
+ instruction) or a document edge, whose **raw source**, as written and before the split around
546
+ character references, consists only of U+0009, U+000A, U+000C, U+000D and U+0020, at least one
547
+ of them U+000A, U+000C or U+000D. A character reference is never whitespace for this test, so
548
+ `\n&#32;\n` and `\n&amp;\n` are processed as before. Such a run is not a span, so it lies in the
549
+ gap between the spans on either side and §3.2 chooses the marker from its raw source: the
550
+ pretty-printed `<p>a</p>\n<p>b</p>` has one −2 line marker between `a` and `b`, as the same text
551
+ has in `text` mode, instead of two −1 markers around a literal line feed. At the start or end
552
+ of a text unit such a run leaves no marker at all (§3.5 step 2), so `<p>Call it "ready".</p>`
553
+ followed by a line feed ends the unit as it does without one. The same holds inside a
554
+ `markdown` HTML block, which §3.7.3 hands to this list. A whitespace-only text node with **no** line break
555
+ (`<b>a</b> <i>b</i>`), and any text node holding a non-whitespace code point, is processed
556
+ as before. The accepted cost: no rule reaches the node's own characters any more, and a
557
+ line of its own that holds only ` - ` (`<p>a</p>`, a line feed, `<p> - </p>`, a line feed,
558
+ `<p>b</p>`) is now left alone, exactly as `text` mode leaves it between two line feeds,
559
+ where before 1.23.0 it became a dash.
543
560
 
544
561
  **Element names compare case-insensitively**, per HTML: `<CODE>`, `<Code>` and `<code>` are all
545
562
  skipped. (In MDX, JSX names compare case-sensitively — §3.7.3.)
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "1.22.0",
2
+ "spec": "1.23.0",
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
  {
@@ -98,7 +98,7 @@ opposite order. After an edit continue from `i + 2`; otherwise from `i + 1`.
98
98
  any quotation mark (a nested quotation, `“He said ‘hi’”.`), after a bracket, and across any
99
99
  boundary marker or protected run (the marker is not `LETTER`).
100
100
  - **C4** requires the punctuation to end its clause. It declines when a letter, a digit, a
101
- bracket, another dot, a quotation mark or a boundary marker comes next: `“file”.txt`,
101
+ bracket, another dot, a quotation mark or a −1 boundary marker comes next: `“file”.txt`,
102
102
  `(“hi”.)`, `“wait”…`, and `“file”.${ext}` with a protected `${ext}`.
103
103
  - **C2** moves only the comma and the full stop. `;` `:` `?` `!` and the dashes are positional in
104
104
  no locale this specification has verified — Chicago puts them outside unless they belong to the
@@ -112,12 +112,15 @@ first and last code points are not U+0020.
112
112
  ### 3.3 Modes, `protect`, `analyze`
113
113
 
114
114
  **Document modes.** A span boundary between the mark and the punctuation, or on either side of
115
- the pair, puts a marker at `cp[i-1]`, `cp[i+1]` or `cp[i+2]`. A marker at `cp[i-1]` fails C3, at
116
- `cp[i+1]` fails C2, and at `cp[i+2]` fails C4. The rule therefore needs no special handling of
117
- `html`, `markdown` or `yaml`: it acts only when the whole of `Q`, the punctuation, and the text on
118
- either side are in one span, and the redistribution of edits to spans is trivial because the edit
119
- never contains a marker. The end of a text unit is `NONE`, not a marker, so `<p>Call it
120
- "ready".</p>` moves the stop while `<p>Call it "ready".</p><p>Next</p>` does not (§6).
115
+ the pair, puts a marker at `cp[i-1]`, `cp[i+1]` or `cp[i+2]`. A −1 marker at `cp[i-1]` fails C3, at
116
+ `cp[i+1]` fails C2, and at `cp[i+2]` fails C4; a −2 line marker at `cp[i+2]` is `SPACELIKE` and
117
+ satisfies C4. The rule therefore needs no special handling of `html`, `markdown` or `yaml`: `Q` and
118
+ the punctuation are always in one span, and the redistribution of edits to spans is trivial because
119
+ the edit never contains a marker. The end of a text unit is `NONE`, not a marker, so `<p>Call it
120
+ "ready".</p>` moves the stop while `<p>Call it "ready".</p><p>Next</p>` does not (§6). A line
121
+ break in the source between the blocks changes that: the whitespace-only text node holding it is
122
+ not a span (`modes.md` §3.6), the gap is a −2 line marker, a member of `SPACELIKE`, and C4 holds,
123
+ so `<p>Call it "ready".</p>` + U+000A + `<p>Next</p>` moves the stop (§6, row H6).
121
124
 
122
125
  **`text` mode `protect`.** A protected run is a boundary marker, including at the very start or
123
126
  end of the input (`modes.md` §3.9.3), so it blocks the scan the same way. The edit never changes
@@ -277,6 +280,7 @@ move together.
277
280
  | H2 | `html` | `<p>She said <em>"hello"</em>, then left.</p>` | `<p>She said <em>“hello”</em>, then left.</p>` | a marker at `cp[i+1]` fails C2 |
278
281
  | H3 | `html` | `<p>She said "<em>hello</em>", then left.</p>` | `<p>She said “<em>hello</em>”, then left.</p>` | a marker at `cp[i-1]` fails C3 |
279
282
  | H5 | `html` | `<p>She said "hello".</p><p>Next.</p>` | `<p>She said “hello”.</p><p>Next.</p>` | the gap between the paragraphs is a −1 marker at `cp[i+2]`: C4 fails |
283
+ | H6 | `html` | `<p>She said "hello".</p>` + U+000A + `<p>Next.</p>` | `<p>She said “hello.”</p>` + U+000A + `<p>Next.</p>` | the line break between the paragraphs is a −2 marker at `cp[i+2]`, `SPACELIKE`: C4 holds |
280
284
  | M1 | `markdown` | `She said "hello", then left.` + U+000A | `She said “hello,” then left.` + U+000A | one span |
281
285
  | M2 | `markdown` | `*She said "hello"*, then left.` | `*She said “hello”*, then left.` | the closing `*` is a boundary |
282
286
  | M3 | `markdown` | `*He said "hi".* Next` | `*He said “hi”.* Next` | the same, at `cp[i+2]` |
@@ -218,6 +218,10 @@ module Polytypo
218
218
  return if skip_depth != 0 || to <= from
219
219
 
220
220
  slice = chars[from...to]
221
+ # modes.md 3.6: a whitespace-only node holding a line break is no span, so the gap test
222
+ # between its neighbours sees the line terminator and yields the line marker.
223
+ return if line_break_whitespace?(slice)
224
+
221
225
  refs = find_entity_refs(slice)
222
226
  cursor = 0
223
227
  refs.each do |ref_start, ref_end|
@@ -227,6 +231,12 @@ module Polytypo
227
231
  spans << Spans::Span.new(from + cursor, to) if cursor < slice.length
228
232
  end
229
233
  private_class_method :emit_text
234
+
235
+ def self.line_break_whitespace?(chars)
236
+ chars.all? { |c| c == " " || c == "\t" || c == "\n" || c == "\f" || c == "\r" } &&
237
+ chars.any? { |c| c == "\n" || c == "\f" || c == "\r" }
238
+ end
239
+ private_class_method :line_break_whitespace?
230
240
  end
231
241
  end
232
242
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polytypo
4
- VERSION = "1.22.1"
4
+ VERSION = "1.23.0"
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.22.1
4
+ version: 1.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iurii Rogulia