polytypo 1.0.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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +109 -0
  4. data/lib/polytypo/data/README.md +20 -0
  5. data/lib/polytypo/data/UNICODE +1 -0
  6. data/lib/polytypo/data/VERSION +1 -0
  7. data/lib/polytypo/data/fixtures/de-CH.json +501 -0
  8. data/lib/polytypo/data/fixtures/de-DE.json +547 -0
  9. data/lib/polytypo/data/fixtures/el.json +239 -0
  10. data/lib/polytypo/data/fixtures/en-GB.json +1274 -0
  11. data/lib/polytypo/data/fixtures/en-US.json +1807 -0
  12. data/lib/polytypo/data/fixtures/fi.json +1306 -0
  13. data/lib/polytypo/data/fixtures/fr-CA.json +268 -0
  14. data/lib/polytypo/data/fixtures/fr.json +603 -0
  15. data/lib/polytypo/data/fixtures/locale-resolution.json +209 -0
  16. data/lib/polytypo/data/fixtures/ru.json +688 -0
  17. data/lib/polytypo/data/fixtures/sv.json +1290 -0
  18. data/lib/polytypo/data/locales/de-CH.json +77 -0
  19. data/lib/polytypo/data/locales/de-DE.json +76 -0
  20. data/lib/polytypo/data/locales/el.json +90 -0
  21. data/lib/polytypo/data/locales/en-GB.json +115 -0
  22. data/lib/polytypo/data/locales/en-US.json +133 -0
  23. data/lib/polytypo/data/locales/fi.json +136 -0
  24. data/lib/polytypo/data/locales/fr-CA.json +78 -0
  25. data/lib/polytypo/data/locales/fr.json +84 -0
  26. data/lib/polytypo/data/locales/registry.json +9 -0
  27. data/lib/polytypo/data/locales/ru.json +112 -0
  28. data/lib/polytypo/data/locales/sv.json +124 -0
  29. data/lib/polytypo/data/rules/dashes.md +1238 -0
  30. data/lib/polytypo/data/rules/order.json +78 -0
  31. data/lib/polytypo/data/schema/fixtures.schema.json +79 -0
  32. data/lib/polytypo/data/schema/locale.schema.json +235 -0
  33. data/lib/polytypo/data/schema/registry.schema.json +29 -0
  34. data/lib/polytypo/data/schema/resolution.schema.json +50 -0
  35. data/lib/polytypo/engine/codepoints.rb +24 -0
  36. data/lib/polytypo/engine/edits.rb +64 -0
  37. data/lib/polytypo/engine/locale.rb +138 -0
  38. data/lib/polytypo/engine/pipeline.rb +61 -0
  39. data/lib/polytypo/engine/registry.rb +47 -0
  40. data/lib/polytypo/engine/rules/apostrophe.rb +127 -0
  41. data/lib/polytypo/engine/rules/dash_shared.rb +342 -0
  42. data/lib/polytypo/engine/rules/dashes.rb +125 -0
  43. data/lib/polytypo/engine/rules/ellipsis.rb +100 -0
  44. data/lib/polytypo/engine/rules/hyphen.rb +207 -0
  45. data/lib/polytypo/engine/rules/nbsp.rb +616 -0
  46. data/lib/polytypo/engine/rules/quote_ambiguity.rb +241 -0
  47. data/lib/polytypo/engine/rules/quotes.rb +420 -0
  48. data/lib/polytypo/engine/rules/ranges.rb +124 -0
  49. data/lib/polytypo/engine/rules/spaces.rb +232 -0
  50. data/lib/polytypo/engine/rules/symbols.rb +291 -0
  51. data/lib/polytypo/engine/rules.rb +19 -0
  52. data/lib/polytypo/engine/sentinels.rb +23 -0
  53. data/lib/polytypo/engine/unicode_util.rb +390 -0
  54. data/lib/polytypo/errors.rb +24 -0
  55. data/lib/polytypo/modes/html.rb +233 -0
  56. data/lib/polytypo/modes/markdown.rb +187 -0
  57. data/lib/polytypo/modes/parse_error.rb +19 -0
  58. data/lib/polytypo/modes/runner.rb +57 -0
  59. data/lib/polytypo/modes/spans.rb +132 -0
  60. data/lib/polytypo/version.rb +5 -0
  61. data/lib/polytypo.rb +91 -0
  62. data/polytypo.gemspec +37 -0
  63. metadata +122 -0
@@ -0,0 +1,209 @@
1
+ {
2
+ "spec": "1.0.0",
3
+ "cases": [
4
+ {
5
+ "id": "exact-en-us",
6
+ "tag": "en-US",
7
+ "resolves": "en-US",
8
+ "note": "locale-resolution.md section 5, exact match"
9
+ },
10
+ {
11
+ "id": "exact-en-gb",
12
+ "tag": "en-GB",
13
+ "resolves": "en-GB"
14
+ },
15
+ {
16
+ "id": "exact-de-de",
17
+ "tag": "de-DE",
18
+ "resolves": "de-DE"
19
+ },
20
+ {
21
+ "id": "exact-de-ch",
22
+ "tag": "de-CH",
23
+ "resolves": "de-CH"
24
+ },
25
+ {
26
+ "id": "exact-fr",
27
+ "tag": "fr",
28
+ "resolves": "fr"
29
+ },
30
+ {
31
+ "id": "exact-ru",
32
+ "tag": "ru",
33
+ "resolves": "ru"
34
+ },
35
+ {
36
+ "id": "exact-fi",
37
+ "tag": "fi",
38
+ "resolves": "fi"
39
+ },
40
+ {
41
+ "id": "exact-sv",
42
+ "tag": "sv",
43
+ "resolves": "sv"
44
+ },
45
+ {
46
+ "id": "alias-en",
47
+ "tag": "en",
48
+ "resolves": "en-US",
49
+ "note": "aliases.en; never the first entry of locales, never a nearest match"
50
+ },
51
+ {
52
+ "id": "alias-de",
53
+ "tag": "de",
54
+ "resolves": "de-DE"
55
+ },
56
+ {
57
+ "id": "strip-en-au",
58
+ "tag": "en-AU",
59
+ "resolves": "en-US",
60
+ "note": "no exact, no alias, strip region once to en, then the alias table"
61
+ },
62
+ {
63
+ "id": "strip-de-at",
64
+ "tag": "de-AT",
65
+ "resolves": "de-DE",
66
+ "note": "worked table row: de-AT resolves through de to de-DE"
67
+ },
68
+ {
69
+ "id": "exact-fr-ca",
70
+ "tag": "fr-CA",
71
+ "resolves": "fr-CA",
72
+ "note": "fr-CA is its own registered locale as of spec 0.2.0 (Québec French nbsp practice differs from France's before ; ! ?), not a stripped variant of fr."
73
+ },
74
+ {
75
+ "id": "strip-fr-be",
76
+ "tag": "fr-BE",
77
+ "resolves": "fr",
78
+ "note": "A French region with no locale of its own still strips to the base language, exactly as fr-CA did before it was registered."
79
+ },
80
+ {
81
+ "id": "strip-fi-fi",
82
+ "tag": "fi-FI",
83
+ "resolves": "fi"
84
+ },
85
+ {
86
+ "id": "strip-sv-fi",
87
+ "tag": "sv-FI",
88
+ "resolves": "sv",
89
+ "note": "section 6.3 open question: Finland Swedish has no locale of its own yet"
90
+ },
91
+ {
92
+ "id": "exact-el",
93
+ "tag": "el",
94
+ "resolves": "el",
95
+ "note": "locale-resolution.md section 5. Greek is registered with no alias: it has no region variants in the registry, so nothing needs to point at it."
96
+ },
97
+ {
98
+ "id": "strip-el-gr",
99
+ "tag": "el-GR",
100
+ "resolves": "el",
101
+ "note": "locale-resolution.md section 5, strip the region once. el-GR is by far the commonest way the tag is written in the wild, and it must not need an alias entry to work."
102
+ },
103
+ {
104
+ "id": "unknown-gr",
105
+ "tag": "gr",
106
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
107
+ "note": "The ISO 3166 country code for Greece is GR but the ISO 639 language code is el, and `gr` is a common mistake. It must throw rather than quietly resolve — locale-resolution.md section 6.1 forbids a nearest-language fallback."
108
+ },
109
+ {
110
+ "id": "strip-ru-by",
111
+ "tag": "ru-BY",
112
+ "resolves": "ru"
113
+ },
114
+ {
115
+ "id": "canonical-en-us-mixed-case",
116
+ "tag": "EN-us",
117
+ "resolves": "en-US",
118
+ "note": "section 3.2 canonicalisation, ASCII arithmetic only — no host-locale case folding"
119
+ },
120
+ {
121
+ "id": "canonical-en-us-underscore",
122
+ "tag": "en_US",
123
+ "resolves": "en-US",
124
+ "note": "section 3.2 step 1: U+005F is accepted as a separator. Section 6.4 flags this leniency as the one behavioural choice awaiting operator confirmation."
125
+ },
126
+ {
127
+ "id": "canonical-de-uppercase",
128
+ "tag": "DE",
129
+ "resolves": "de-DE",
130
+ "note": "canonicalise, then the alias table"
131
+ },
132
+ {
133
+ "id": "canonical-de-ch-underscore-lowercase",
134
+ "tag": "de_ch",
135
+ "resolves": "de-CH"
136
+ },
137
+ {
138
+ "id": "unknown-xx-yy",
139
+ "tag": "xx-YY",
140
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
141
+ "note": "worked table row: no exact, no alias, strip to xx, still nothing — never falls back to English"
142
+ },
143
+ {
144
+ "id": "unknown-xx",
145
+ "tag": "xx",
146
+ "throws": "POLYTYPO_UNKNOWN_LOCALE"
147
+ },
148
+ {
149
+ "id": "unknown-nb-no",
150
+ "tag": "nb-NO",
151
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
152
+ "note": "section 4: nb must not resolve to the nearest language sv"
153
+ },
154
+ {
155
+ "id": "unknown-es",
156
+ "tag": "es",
157
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
158
+ "note": "a language polytypo does not carry yet is an error, not a default"
159
+ },
160
+ {
161
+ "id": "invalid-three-letter",
162
+ "tag": "eng",
163
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
164
+ "note": "section 3.3: length 3 is neither of the two accepted shapes"
165
+ },
166
+ {
167
+ "id": "invalid-script-subtag",
168
+ "tag": "sr-Latn",
169
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
170
+ "note": "section 3.3: length 7"
171
+ },
172
+ {
173
+ "id": "invalid-numeric-region",
174
+ "tag": "es-419",
175
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
176
+ "note": "section 3.3: region code points are not in U+0041-U+005A"
177
+ },
178
+ {
179
+ "id": "invalid-und",
180
+ "tag": "und",
181
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
182
+ "note": "section 3.3: the wildcard is not a locale"
183
+ },
184
+ {
185
+ "id": "invalid-empty",
186
+ "tag": "",
187
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
188
+ "note": "section 3.1: there is no default locale"
189
+ },
190
+ {
191
+ "id": "invalid-single-letter",
192
+ "tag": "e",
193
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
194
+ "note": "section 3.3: length 1"
195
+ },
196
+ {
197
+ "id": "invalid-trailing-separator",
198
+ "tag": "de-",
199
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
200
+ "note": "section 3.3: length 3 is rejected before any lookup, so this is not the alias de"
201
+ },
202
+ {
203
+ "id": "invalid-extra-subtag",
204
+ "tag": "en-US-POSIX",
205
+ "throws": "POLYTYPO_UNKNOWN_LOCALE",
206
+ "note": "section 3.3: length 11. Section 7 open question 7: region is the only supported variation, so extra subtags are rejected rather than ignored."
207
+ }
208
+ ]
209
+ }