1 |
|
2 | (function() {
|
3 | var CHR, TRM, assert, echo, log, rainbow;
|
4 |
|
5 | TRM = require('coffeenode-trm');
|
6 |
|
7 | log = TRM.log.bind(TRM);
|
8 |
|
9 | echo = TRM.echo.bind(TRM);
|
10 |
|
11 | rainbow = TRM.rainbow.bind(TRM);
|
12 |
|
13 | CHR = require('../../coffeenode-chr');
|
14 |
|
15 | assert = require('assert');
|
16 |
|
17 | assert.deepEqual(('&jzr#x123;helo'.match(CHR._first_chr_matcher_xncr)).slice(1, 4), ['jzr', '123', void 0]);
|
18 |
|
19 | assert.deepEqual(('&jzr#123;helo'.match(CHR._first_chr_matcher_xncr)).slice(1, 4), ['jzr', void 0, '123']);
|
20 |
|
21 | assert.deepEqual(('ģhelo'.match(CHR._first_chr_matcher_xncr)).slice(1, 4), ['', '123', void 0]);
|
22 |
|
23 | assert.deepEqual(('ģhelo'.match(CHR._first_chr_matcher_ncr)).slice(1, 4), ['', '123', void 0]);
|
24 |
|
25 | assert.deepEqual(('{helo'.match(CHR._first_chr_matcher_ncr)).slice(1, 4), ['', void 0, '123']);
|
26 |
|
27 | assert.deepEqual(CHR._chr_csg_cid_from_chr('abc', 'plain'), ['a', 'u', 97]);
|
28 |
|
29 | assert.deepEqual(CHR._chr_csg_cid_from_chr('abc', 'ncr'), ['a', 'u', 97]);
|
30 |
|
31 | assert.deepEqual(CHR._chr_csg_cid_from_chr('abc', 'xncr'), ['a', 'u', 97]);
|
32 |
|
33 | assert.deepEqual(CHR._chr_csg_cid_from_chr('aabc', 'plain'), ['&', 'u', 38]);
|
34 |
|
35 | assert.deepEqual(CHR._chr_csg_cid_from_chr('aabc', 'ncr'), ['a', 'u', 97]);
|
36 |
|
37 | assert.deepEqual(CHR._chr_csg_cid_from_chr('aabc', 'xncr'), ['a', 'u', 97]);
|
38 |
|
39 | assert.deepEqual(CHR._chr_csg_cid_from_chr('aabc'), ['&', 'u', 38]);
|
40 |
|
41 | assert.deepEqual(CHR._chr_csg_cid_from_chr('aabc', 'plain'), ['&', 'u', 38]);
|
42 |
|
43 | assert.deepEqual(CHR._chr_csg_cid_from_chr('aabc', 'ncr'), ['a', 'u', 97]);
|
44 |
|
45 | assert.deepEqual(CHR._chr_csg_cid_from_chr('aabc', 'xncr'), ['a', 'u', 97]);
|
46 |
|
47 | assert.deepEqual(CHR.csg_cid_from_chr('𤕣'), ['u', 38]);
|
48 |
|
49 | assert.deepEqual(CHR.csg_cid_from_chr('𤕣', {
|
50 | input: 'plain'
|
51 | }), ['u', 38]);
|
52 |
|
53 | assert.deepEqual(CHR.csg_cid_from_chr('𤕣', {
|
54 | input: 'ncr'
|
55 | }), ['u', 148835]);
|
56 |
|
57 | assert.deepEqual(CHR.csg_cid_from_chr('𤕣', {
|
58 | input: 'xncr'
|
59 | }), ['u', 148835]);
|
60 |
|
61 | assert.deepEqual(CHR.csg_cid_from_chr('𤕣'), ['u', 148835]);
|
62 |
|
63 | assert.deepEqual(CHR.csg_cid_from_chr('𤕣', {
|
64 | input: 'plain'
|
65 | }), ['u', 148835]);
|
66 |
|
67 | assert.deepEqual(CHR.csg_cid_from_chr('𤕣', {
|
68 | input: 'ncr'
|
69 | }), ['u', 148835]);
|
70 |
|
71 | assert.deepEqual(CHR.csg_cid_from_chr('𤕣', {
|
72 | input: 'xncr'
|
73 | }), ['u', 148835]);
|
74 |
|
75 | assert.deepEqual(('𤕣'[0] + 'x').match(CHR._first_chr_matcher_plain), null);
|
76 |
|
77 | assert.throws((function() {
|
78 | return CHR._chr_csg_cid_from_chr('𤕣'[0]);
|
79 | }), /^Error: illegal character sequence/);
|
80 |
|
81 | assert.throws((function() {
|
82 | return CHR._chr_csg_cid_from_chr('𤕣'[0] + 'x');
|
83 | }), /^Error: illegal character sequence/);
|
84 |
|
85 | assert.throws((function() {
|
86 | return CHR.chrs_from_text('x', {
|
87 | input: 'xxx'
|
88 | });
|
89 | }), /^Error: unknown input mode: /);
|
90 |
|
91 | assert.deepEqual(CHR.chrs_from_text(''), []);
|
92 |
|
93 | assert.deepEqual(CHR.chrs_from_text('abc'), ['a', 'b', 'c']);
|
94 |
|
95 | assert.deepEqual(CHR.chrs_from_text('𤕣abc'), ['𤕣', 'a', 'b', 'c']);
|
96 |
|
97 | assert.deepEqual(CHR.chrs_from_text('𤕣ab𤕣c'), ['𤕣', 'a', 'b', '𤕣', 'c']);
|
98 |
|
99 | assert.deepEqual(CHR.chrs_from_text('𤕣a{b𤕣c'), ['𤕣', 'a', '&', '#', '1', '2', '3', ';', 'b', '𤕣', 'c']);
|
100 |
|
101 | assert.deepEqual(CHR.chrs_from_text('𤕣a&jzr#123;b𤕣c'), ['𤕣', 'a', '&', 'j', 'z', 'r', '#', '1', '2', '3', ';', 'b', '𤕣', 'c']);
|
102 |
|
103 | assert.deepEqual(CHR.chrs_from_text('𤕣a𒎫b𤕣c'), ['𤕣', 'a', '&', '#', 'x', '1', '2', '3', 'a', 'b', ';', 'b', '𤕣', 'c']);
|
104 |
|
105 | assert.deepEqual(CHR.chrs_from_text('𤕣a&jzr#x123ab;b𤕣c'), ['𤕣', 'a', '&', 'j', 'z', 'r', '#', 'x', '1', '2', '3', 'a', 'b', ';', 'b', '𤕣', 'c']);
|
106 |
|
107 | assert.deepEqual(CHR.chrs_from_text('', {
|
108 | input: 'ncr'
|
109 | }), []);
|
110 |
|
111 | assert.deepEqual(CHR.chrs_from_text('abc', {
|
112 | input: 'ncr'
|
113 | }), ['a', 'b', 'c']);
|
114 |
|
115 | assert.deepEqual(CHR.chrs_from_text('𤕣abc', {
|
116 | input: 'ncr'
|
117 | }), ['𤕣', 'a', 'b', 'c']);
|
118 |
|
119 | assert.deepEqual(CHR.chrs_from_text('𤕣ab𤕣c', {
|
120 | input: 'ncr'
|
121 | }), ['𤕣', 'a', 'b', '𤕣', 'c']);
|
122 |
|
123 | assert.deepEqual(CHR.chrs_from_text('𤕣a{b𤕣c', {
|
124 | input: 'ncr'
|
125 | }), ['𤕣', 'a', '{', 'b', '𤕣', 'c']);
|
126 |
|
127 | assert.deepEqual(CHR.chrs_from_text('𤕣a𒎫b𤕣c', {
|
128 | input: 'ncr'
|
129 | }), ['𤕣', 'a', '𒎫', 'b', '𤕣', 'c']);
|
130 |
|
131 | assert.deepEqual(CHR.chrs_from_text('𤕣a&jzr#x123ab;b𤕣c', {
|
132 | input: 'ncr'
|
133 | }), ['𤕣', 'a', '&', 'j', 'z', 'r', '#', 'x', '1', '2', '3', 'a', 'b', ';', 'b', '𤕣', 'c']);
|
134 |
|
135 | assert.deepEqual(CHR.chrs_from_text('', {
|
136 | input: 'xncr'
|
137 | }), []);
|
138 |
|
139 | assert.deepEqual(CHR.chrs_from_text('abc', {
|
140 | input: 'xncr'
|
141 | }), ['a', 'b', 'c']);
|
142 |
|
143 | assert.deepEqual(CHR.chrs_from_text('𤕣abc', {
|
144 | input: 'xncr'
|
145 | }), ['𤕣', 'a', 'b', 'c']);
|
146 |
|
147 | assert.deepEqual(CHR.chrs_from_text('𤕣ab𤕣c', {
|
148 | input: 'xncr'
|
149 | }), ['𤕣', 'a', 'b', '𤕣', 'c']);
|
150 |
|
151 | assert.deepEqual(CHR.chrs_from_text('𤕣a{b𤕣c', {
|
152 | input: 'xncr'
|
153 | }), ['𤕣', 'a', '{', 'b', '𤕣', 'c']);
|
154 |
|
155 | assert.deepEqual(CHR.chrs_from_text('𤕣a𒎫b𤕣c', {
|
156 | input: 'xncr'
|
157 | }), ['𤕣', 'a', '𒎫', 'b', '𤕣', 'c']);
|
158 |
|
159 | assert.deepEqual(CHR.chrs_from_text('𤕣a&jzr#x123ab;b𤕣c', {
|
160 | input: 'xncr'
|
161 | }), ['𤕣', 'a', '&jzr#x123ab;', 'b', '𤕣', 'c']);
|
162 |
|
163 | assert.throws((function() {
|
164 | return CHR.cid_from_chr('');
|
165 | }), /^Error: unable to obtain CID from empty string$/);
|
166 |
|
167 | assert.throws((function() {
|
168 | return CHR.cid_from_chr('', 'ncr');
|
169 | }), /^Error: unable to obtain CID from empty string$/);
|
170 |
|
171 | assert.throws((function() {
|
172 | return CHR.cid_from_chr('', 'xncr');
|
173 | }), /^Error: unable to obtain CID from empty string$/);
|
174 |
|
175 | assert.strictEqual(CHR.cid_from_chr('a'), 97);
|
176 |
|
177 | assert.strictEqual(CHR.cid_from_chr('x'), 120);
|
178 |
|
179 | assert.strictEqual(CHR.cid_from_chr('ʦ'), 38);
|
180 |
|
181 | assert.strictEqual(CHR.cid_from_chr('ٸ'), 38);
|
182 |
|
183 | assert.strictEqual(CHR.cid_from_chr('&jzr#678;'), 38);
|
184 |
|
185 | assert.strictEqual(CHR.cid_from_chr('&jzr#x678;'), 38);
|
186 |
|
187 | assert.strictEqual(CHR.cid_from_chr('a', {
|
188 | input: 'ncr'
|
189 | }), 97);
|
190 |
|
191 | assert.strictEqual(CHR.cid_from_chr('x', {
|
192 | input: 'ncr'
|
193 | }), 120);
|
194 |
|
195 | assert.strictEqual(CHR.cid_from_chr('ʦ', {
|
196 | input: 'ncr'
|
197 | }), 678);
|
198 |
|
199 | assert.strictEqual(CHR.cid_from_chr('ٸ', {
|
200 | input: 'ncr'
|
201 | }), 0x678);
|
202 |
|
203 | assert.strictEqual(CHR.cid_from_chr('&jzr#678;', {
|
204 | input: 'ncr'
|
205 | }), 38);
|
206 |
|
207 | assert.strictEqual(CHR.cid_from_chr('&jzr#x678;', {
|
208 | input: 'ncr'
|
209 | }), 38);
|
210 |
|
211 | assert.strictEqual(CHR.cid_from_chr('a', {
|
212 | input: 'xncr'
|
213 | }), 97);
|
214 |
|
215 | assert.strictEqual(CHR.cid_from_chr('x', {
|
216 | input: 'xncr'
|
217 | }), 120);
|
218 |
|
219 | assert.strictEqual(CHR.cid_from_chr('ʦ', {
|
220 | input: 'xncr'
|
221 | }), 678);
|
222 |
|
223 | assert.strictEqual(CHR.cid_from_chr('ٸ', {
|
224 | input: 'xncr'
|
225 | }), 0x678);
|
226 |
|
227 | assert.strictEqual(CHR.cid_from_chr('&jzr#678;', {
|
228 | input: 'xncr'
|
229 | }), 678);
|
230 |
|
231 | assert.strictEqual(CHR.cid_from_chr('&jzr#x678;', {
|
232 | input: 'xncr'
|
233 | }), 0x678);
|
234 |
|
235 | assert.strictEqual(CHR.html_from_text('helo wörld'), "<span class=\"u-latn\">helo w</span><span class=\"u-latn-1\">ö</span><span class=\"u-latn\">rld</span>");
|
236 |
|
237 | assert.strictEqual(CHR.html_from_text('helo 𤕣 wörld'), "<span class=\"u-latn\">helo &#x24563; w</span><span class=\"u-latn-1\">ö</span><span class=\"u-latn\">rld</span>");
|
238 |
|
239 | assert.strictEqual(CHR.html_from_text('helo 𤕣 wörld', {
|
240 | input: 'xncr'
|
241 | }), "<span class=\"u-latn\">helo </span><span class=\"u-cjk-xb\">𤕣</span><span class=\"u-latn\"> w</span><span class=\"u-latn-1\">ö</span><span class=\"u-latn\">rld</span>");
|
242 |
|
243 | assert.strictEqual(CHR.html_from_text('&jzr#xe101; & you', {
|
244 | input: 'xncr'
|
245 | }), "<span class=\"jzr-fig\"></span><span class=\"u-latn\"> & you</span>");
|
246 |
|
247 | assert.strictEqual(CHR._as_xncr('u', 0x12abc), '𒪼');
|
248 |
|
249 | assert.strictEqual(CHR._as_xncr('u', 0x12abc), '𒪼');
|
250 |
|
251 | assert.strictEqual(CHR._as_xncr('jzr', 0x12abc), '&jzr#x12abc;');
|
252 |
|
253 | assert.strictEqual(CHR._as_sfncr('u', 0x12abc), 'u-12abc');
|
254 |
|
255 | assert.strictEqual(CHR._as_sfncr('jzr', 0x12abc), 'jzr-12abc');
|
256 |
|
257 | assert.strictEqual(CHR.as_ncr(0x12abc), '𒪼');
|
258 |
|
259 | assert.strictEqual(CHR.as_sfncr('a'), 'u-61');
|
260 |
|
261 | assert.strictEqual(CHR.as_rsg('a'), 'u-latn');
|
262 |
|
263 | assert.strictEqual(CHR.as_rsg('𤕣'), 'u-cjk-xb');
|
264 |
|
265 | assert.strictEqual(CHR.as_range_name('a'), 'Basic Latin');
|
266 |
|
267 | assert.strictEqual(CHR.as_range_name('𤕣'), 'CJK Unified Ideographs Extension B');
|
268 |
|
269 | assert.strictEqual(CHR.as_range_name('', {
|
270 | input: 'plain'
|
271 | }), 'Basic Latin');
|
272 |
|
273 | assert.strictEqual(CHR.as_range_name('&jzr#xe100;', {
|
274 | input: 'plain'
|
275 | }), 'Basic Latin');
|
276 |
|
277 | assert.strictEqual(CHR.as_rsg('', {
|
278 | input: 'plain'
|
279 | }), 'u-latn');
|
280 |
|
281 | assert.strictEqual(CHR.as_rsg('&jzr#xe100;', {
|
282 | input: 'plain'
|
283 | }), 'u-latn');
|
284 |
|
285 | assert.strictEqual(CHR.as_range_name('', {
|
286 | input: 'ncr'
|
287 | }), 'Private Use Area');
|
288 |
|
289 | assert.strictEqual(CHR.as_range_name('&jzr#xe100;', {
|
290 | input: 'ncr'
|
291 | }), 'Basic Latin');
|
292 |
|
293 | assert.strictEqual(CHR.as_rsg('', {
|
294 | input: 'ncr'
|
295 | }), 'u-pua');
|
296 |
|
297 | assert.strictEqual(CHR.as_rsg('&jzr#xe100;', {
|
298 | input: 'ncr'
|
299 | }), 'u-latn');
|
300 |
|
301 | assert.strictEqual(CHR.as_range_name('', {
|
302 | input: 'xncr'
|
303 | }), 'Private Use Area');
|
304 |
|
305 | assert.strictEqual(CHR.as_range_name('&jzr#xe100;', {
|
306 | input: 'xncr'
|
307 | }), 'Jizura Character Components');
|
308 |
|
309 | assert.strictEqual(CHR.as_rsg('', {
|
310 | input: 'xncr'
|
311 | }), 'u-pua');
|
312 |
|
313 | assert.strictEqual(CHR.as_rsg('&jzr#xe100;', {
|
314 | input: 'xncr'
|
315 | }), 'jzr-fig');
|
316 |
|
317 | assert.throws((function() {
|
318 | return CHR.as_rsg('&unknown#xe100;', {
|
319 | input: 'xncr'
|
320 | });
|
321 | }), /Error: unknown CSG: 'unknown'/);
|
322 |
|
323 | assert.strictEqual(CHR.as_rsg('&jzr#xe100;', {
|
324 | input: 'xncr',
|
325 | csg: 'u'
|
326 | }), 'u-pua');
|
327 |
|
328 | assert.strictEqual(CHR.as_rsg('', {
|
329 | input: 'xncr',
|
330 | csg: 'u'
|
331 | }), 'u-pua');
|
332 |
|
333 | assert.strictEqual(CHR.as_rsg('', {
|
334 | input: 'xncr',
|
335 | csg: 'jzr'
|
336 | }), 'jzr-fig');
|
337 |
|
338 | assert.strictEqual(CHR.as_rsg('', {
|
339 | input: 'xncr',
|
340 | csg: 'jzr'
|
341 | }), null);
|
342 |
|
343 | assert.strictEqual(CHR.as_fncr('', {
|
344 | input: 'xncr',
|
345 | csg: 'jzr'
|
346 | }), 'jzr-1');
|
347 |
|
348 | assert.strictEqual(CHR.as_fncr('', {
|
349 | input: 'xncr',
|
350 | csg: 'jzr'
|
351 | }), 'jzr-fig-e123');
|
352 |
|
353 | assert.strictEqual(CHR.as_fncr('𤕣', {
|
354 | input: 'xncr'
|
355 | }), 'u-cjk-xb-24563');
|
356 |
|
357 | assert.strictEqual(CHR.as_cid('&jzr#xe100;', {
|
358 | input: 'xncr'
|
359 | }), 0xe100);
|
360 |
|
361 | assert.strictEqual(CHR.as_cid('&jzr#xe100;', {
|
362 | input: 'xncr',
|
363 | csg: 'u'
|
364 | }), 0xe100);
|
365 |
|
366 | assert.strictEqual(CHR.as_cid('𤕣', {
|
367 | input: 'xncr'
|
368 | }), 0x24563);
|
369 |
|
370 | assert.strictEqual(CHR.as_csg('&jzr#xe100;', {
|
371 | input: 'xncr'
|
372 | }), 'jzr');
|
373 |
|
374 | assert.strictEqual(CHR.as_csg('&jzr#xe100;', {
|
375 | input: 'xncr',
|
376 | csg: 'u'
|
377 | }), 'u');
|
378 |
|
379 | assert.strictEqual(CHR.as_csg('𤕣', {
|
380 | input: 'xncr'
|
381 | }), 'u');
|
382 |
|
383 | assert.deepEqual(CHR.analyze('helo world'), {
|
384 | '~isa': 'CHR/chr-description',
|
385 | "chr": "h",
|
386 | "csg": "u",
|
387 | "cid": 104,
|
388 | "fncr": "u-latn-68",
|
389 | "sfncr": "u-68",
|
390 | "ncr": "h",
|
391 | "xncr": "h",
|
392 | "rsg": "u-latn"
|
393 | });
|
394 |
|
395 | assert.deepEqual(CHR.analyze('𤕣'), {
|
396 | '~isa': 'CHR/chr-description',
|
397 | "chr": "&",
|
398 | "csg": "u",
|
399 | "cid": 38,
|
400 | "fncr": "u-latn-26",
|
401 | "sfncr": "u-26",
|
402 | "ncr": "&",
|
403 | "xncr": "&",
|
404 | "rsg": "u-latn"
|
405 | });
|
406 |
|
407 | assert.deepEqual(CHR.analyze('𤕣', {
|
408 | input: 'ncr'
|
409 | }), {
|
410 | '~isa': 'CHR/chr-description',
|
411 | "chr": "𤕣",
|
412 | "csg": "u",
|
413 | "cid": 148835,
|
414 | "fncr": "u-cjk-xb-24563",
|
415 | "sfncr": "u-24563",
|
416 | "ncr": "𤕣",
|
417 | "xncr": "𤕣",
|
418 | "rsg": "u-cjk-xb"
|
419 | });
|
420 |
|
421 | assert.deepEqual(CHR.analyze('𤕣', {
|
422 | input: 'xncr'
|
423 | }), {
|
424 | '~isa': 'CHR/chr-description',
|
425 | "chr": "𤕣",
|
426 | "csg": "u",
|
427 | "cid": 148835,
|
428 | "fncr": "u-cjk-xb-24563",
|
429 | "sfncr": "u-24563",
|
430 | "ncr": "𤕣",
|
431 | "xncr": "𤕣",
|
432 | "rsg": "u-cjk-xb"
|
433 | });
|
434 |
|
435 | assert.deepEqual(CHR.analyze('&jzr#x24563;'), {
|
436 | '~isa': 'CHR/chr-description',
|
437 | "chr": "&",
|
438 | "csg": "u",
|
439 | "cid": 38,
|
440 | "fncr": "u-latn-26",
|
441 | "sfncr": "u-26",
|
442 | "ncr": "&",
|
443 | "xncr": "&",
|
444 | "rsg": "u-latn"
|
445 | });
|
446 |
|
447 | assert.deepEqual(CHR.analyze('&jzr#x24563;', {
|
448 | input: 'ncr'
|
449 | }), {
|
450 | '~isa': 'CHR/chr-description',
|
451 | "chr": "&",
|
452 | "csg": "u",
|
453 | "cid": 38,
|
454 | "fncr": "u-latn-26",
|
455 | "sfncr": "u-26",
|
456 | "ncr": "&",
|
457 | "xncr": "&",
|
458 | "rsg": "u-latn"
|
459 | });
|
460 |
|
461 | assert.deepEqual(CHR.analyze('&jzr#x24563;', {
|
462 | input: 'xncr'
|
463 | }), {
|
464 | '~isa': 'CHR/chr-description',
|
465 | "chr": "&jzr#x24563;",
|
466 | "csg": "jzr",
|
467 | "cid": 148835,
|
468 | "fncr": "jzr-24563",
|
469 | "sfncr": "jzr-24563",
|
470 | "ncr": "𤕣",
|
471 | "xncr": "&jzr#x24563;",
|
472 | "rsg": null
|
473 | });
|
474 |
|
475 | assert.throws((function() {
|
476 | return CHR.chunks_from_text('ab&jzr#xe063;d', {
|
477 | input: 'xncr',
|
478 | output: 'xxx'
|
479 | });
|
480 | }), /Error: unknown output mode: 'xxx'/);
|
481 |
|
482 | assert.deepEqual(CHR.chunks_from_text('helo wörld'), [
|
483 | {
|
484 | "~isa": "CHR/chunk",
|
485 | "csg": "u",
|
486 | "rsg": "u-latn",
|
487 | "text": "helo w"
|
488 | }, {
|
489 | "~isa": "CHR/chunk",
|
490 | "csg": "u",
|
491 | "rsg": "u-latn-1",
|
492 | "text": "ö"
|
493 | }, {
|
494 | "~isa": "CHR/chunk",
|
495 | "csg": "u",
|
496 | "rsg": "u-latn",
|
497 | "text": "rld"
|
498 | }
|
499 | ]);
|
500 |
|
501 | assert.deepEqual(CHR.chunks_from_text('種果〇𤕣カタカナ'), [
|
502 | {
|
503 | "~isa": "CHR/chunk",
|
504 | "csg": "u",
|
505 | "rsg": "u-cjk",
|
506 | "text": "種果"
|
507 | }, {
|
508 | "~isa": "CHR/chunk",
|
509 | "csg": "u",
|
510 | "rsg": "u-cjk-sym",
|
511 | "text": "〇"
|
512 | }, {
|
513 | "~isa": "CHR/chunk",
|
514 | "csg": "u",
|
515 | "rsg": "u-cjk-xb",
|
516 | "text": "𤕣"
|
517 | }, {
|
518 | "~isa": "CHR/chunk",
|
519 | "csg": "u",
|
520 | "rsg": "u-cjk-kata",
|
521 | "text": "カタカナ"
|
522 | }
|
523 | ]);
|
524 |
|
525 | assert.deepEqual(CHR.chunks_from_text('abcd'), [
|
526 | {
|
527 | "~isa": "CHR/chunk",
|
528 | "csg": "u",
|
529 | "rsg": "u-latn",
|
530 | "text": "abcd"
|
531 | }
|
532 | ]);
|
533 |
|
534 | assert.deepEqual(CHR.chunks_from_text('abcd', {
|
535 | input: 'ncr'
|
536 | }), [
|
537 | {
|
538 | "~isa": "CHR/chunk",
|
539 | "csg": "u",
|
540 | "rsg": "u-latn",
|
541 | "text": "abcd"
|
542 | }
|
543 | ]);
|
544 |
|
545 | assert.deepEqual(CHR.chunks_from_text('abcd', {
|
546 | input: 'xncr'
|
547 | }), [
|
548 | {
|
549 | "~isa": "CHR/chunk",
|
550 | "csg": "u",
|
551 | "rsg": "u-latn",
|
552 | "text": "abcd"
|
553 | }
|
554 | ]);
|
555 |
|
556 | assert.deepEqual(CHR.chunks_from_text('ab&jzr#xe063;d'), [
|
557 | {
|
558 | "~isa": "CHR/chunk",
|
559 | "csg": "u",
|
560 | "rsg": "u-latn",
|
561 | "text": "ab&jzr#xe063;d"
|
562 | }
|
563 | ]);
|
564 |
|
565 | assert.deepEqual(CHR.chunks_from_text('ab&jzr#xe063;d', {
|
566 | input: 'ncr'
|
567 | }), [
|
568 | {
|
569 | "~isa": "CHR/chunk",
|
570 | "csg": "u",
|
571 | "rsg": "u-latn",
|
572 | "text": "ab&jzr#xe063;d"
|
573 | }
|
574 | ]);
|
575 |
|
576 | assert.deepEqual(CHR.chunks_from_text('ab&jzr#xe063;d', {
|
577 | input: 'xncr'
|
578 | }), [
|
579 | {
|
580 | "~isa": "CHR/chunk",
|
581 | "csg": "u",
|
582 | "rsg": "u-latn",
|
583 | "text": "ab"
|
584 | }, {
|
585 | "~isa": "CHR/chunk",
|
586 | "csg": "jzr",
|
587 | "rsg": "jzr-fig",
|
588 | "text": ""
|
589 | }, {
|
590 | "~isa": "CHR/chunk",
|
591 | "csg": "u",
|
592 | "rsg": "u-latn",
|
593 | "text": "d"
|
594 | }
|
595 | ]);
|
596 |
|
597 | assert.deepEqual(CHR.chunks_from_text('helo wörld', {
|
598 | output: 'html'
|
599 | }), [
|
600 | {
|
601 | "~isa": "CHR/chunk",
|
602 | "csg": "u",
|
603 | "rsg": "u-latn",
|
604 | "text": "helo w"
|
605 | }, {
|
606 | "~isa": "CHR/chunk",
|
607 | "csg": "u",
|
608 | "rsg": "u-latn-1",
|
609 | "text": "ö"
|
610 | }, {
|
611 | "~isa": "CHR/chunk",
|
612 | "csg": "u",
|
613 | "rsg": "u-latn",
|
614 | "text": "rld"
|
615 | }
|
616 | ]);
|
617 |
|
618 | assert.deepEqual(CHR.chunks_from_text('1 < 2', {
|
619 | output: 'html'
|
620 | }), [
|
621 | {
|
622 | "~isa": "CHR/chunk",
|
623 | "csg": "u",
|
624 | "rsg": "u-latn",
|
625 | "text": "1 < 2"
|
626 | }
|
627 | ]);
|
628 |
|
629 | assert.deepEqual(CHR.chunks_from_text('2 > 1', {
|
630 | output: 'html'
|
631 | }), [
|
632 | {
|
633 | "~isa": "CHR/chunk",
|
634 | "csg": "u",
|
635 | "rsg": "u-latn",
|
636 | "text": "2 > 1"
|
637 | }
|
638 | ]);
|
639 |
|
640 | assert.deepEqual(CHR.chunks_from_text('me & you', {
|
641 | output: 'html'
|
642 | }), [
|
643 | {
|
644 | "~isa": "CHR/chunk",
|
645 | "csg": "u",
|
646 | "rsg": "u-latn",
|
647 | "text": "me & you"
|
648 | }
|
649 | ]);
|
650 |
|
651 | assert.deepEqual(CHR.chunks_from_text('me & you', {
|
652 | output: 'html'
|
653 | }), [
|
654 | {
|
655 | "~isa": "CHR/chunk",
|
656 | "csg": "u",
|
657 | "rsg": "u-latn",
|
658 | "text": "me &amp; you"
|
659 | }
|
660 | ]);
|
661 |
|
662 | assert.deepEqual(CHR.chunks_from_text('ab&jzr#xe063;d', {
|
663 | input: 'xncr',
|
664 | output: 'html'
|
665 | }), [
|
666 | {
|
667 | "~isa": "CHR/chunk",
|
668 | "csg": "u",
|
669 | "rsg": "u-latn",
|
670 | "text": "ab"
|
671 | }, {
|
672 | "~isa": "CHR/chunk",
|
673 | "csg": "jzr",
|
674 | "rsg": "jzr-fig",
|
675 | "text": ""
|
676 | }, {
|
677 | "~isa": "CHR/chunk",
|
678 | "csg": "u",
|
679 | "rsg": "u-latn",
|
680 | "text": "d"
|
681 | }
|
682 | ]);
|
683 |
|
684 | }).call(this);
|