@peaceroad/markdown-it-numbering-ul-regarded-as-ol 0.1.3 → 0.1.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.
- package/index.js +35 -13
- package/listTypes.json +40 -8
- package/package.json +1 -1
- package/test/examples-spantitle.txt +10 -0
- package/test/examples.txt +41 -6
- package/test/test.js +1 -1
package/index.js
CHANGED
|
@@ -54,15 +54,15 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
54
54
|
}
|
|
55
55
|
let hasSymbol = null;
|
|
56
56
|
while (sn < types[ltn].symbols.length) {
|
|
57
|
-
hasSymbol = inlineToken.content.match(new RegExp('^'+ '((' + types[ltn].prefix + ')' + types[ltn].symbols[sn] + '(' + types[ltn].suffix + ')(' + types[ltn].joint + '))'));
|
|
57
|
+
hasSymbol = inlineToken.content.match(new RegExp('^'+ '((' + types[ltn].prefix + ')' + types[ltn].symbols[sn] + '(' + types[ltn].suffix + ')(' + types[ltn].joint + '))([ ])+'));
|
|
58
58
|
if (!hasSymbol) { sn++; continue; }
|
|
59
59
|
|
|
60
60
|
symbol.typesNum = ltn;
|
|
61
61
|
symbol.contAll = hasSymbol[0];
|
|
62
|
-
symbol.cont = hasSymbol[1].replace(new RegExp('(' + types[ltn].joint + ')
|
|
62
|
+
symbol.cont = hasSymbol[1].replace(new RegExp('(' + types[ltn].joint + ')'), '');
|
|
63
63
|
symbol.prefix = hasSymbol[2];
|
|
64
|
-
symbol.suffix = hasSymbol[3].replace(new RegExp('(' + types[ltn].joint + ')
|
|
65
|
-
symbol.joint = hasSymbol[4].replace(
|
|
64
|
+
symbol.suffix = hasSymbol[3].replace(new RegExp('(' + types[ltn].joint + ')'), '');
|
|
65
|
+
symbol.joint = hasSymbol[4].replace(/^[ ]+$/, '');
|
|
66
66
|
symbol.typePos = sn;
|
|
67
67
|
symbol.num = sn + types[ltn].start;
|
|
68
68
|
symbols.push(symbol);
|
|
@@ -70,7 +70,7 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
70
70
|
}
|
|
71
71
|
ltn++;
|
|
72
72
|
}
|
|
73
|
-
//console.log('symbols: ' + symbols);
|
|
73
|
+
//console.log('symbols: ' + JSON.stringify(symbols));
|
|
74
74
|
return symbols;
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -88,7 +88,6 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
88
88
|
startFlow.type = state.tokens[n].type;
|
|
89
89
|
startFlow.pos = n;
|
|
90
90
|
startFlow.level = list.level;
|
|
91
|
-
startFlow.psTypes = [];
|
|
92
91
|
list.flows.push(startFlow);
|
|
93
92
|
|
|
94
93
|
let cn = list.nextPos;
|
|
@@ -166,7 +165,6 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
166
165
|
const parentToken = state.tokens[list.flows[plfn].pos];
|
|
167
166
|
if (parentToken.type === 'ordered_list_open' && listFlow.symbols.length === 0) {
|
|
168
167
|
const liVal = cnToken.info;
|
|
169
|
-
|
|
170
168
|
let decimalSymbol = {
|
|
171
169
|
typesNum: 0,
|
|
172
170
|
typePos: liVal,
|
|
@@ -190,7 +188,7 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
190
188
|
list.flows[plfn].type = 'numbering_' + list.flows[plfn].type;
|
|
191
189
|
}
|
|
192
190
|
|
|
193
|
-
//Set possible
|
|
191
|
+
//Set possible symbol types.
|
|
194
192
|
let sn = 0;
|
|
195
193
|
while (sn < listFlow.symbols.length) {
|
|
196
194
|
let plt = 0
|
|
@@ -252,11 +250,34 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
252
250
|
return sn;
|
|
253
251
|
}
|
|
254
252
|
|
|
253
|
+
function setOlTypes1All1(list, lfn, sn) {
|
|
254
|
+
let olTypes1All1 = true;
|
|
255
|
+
if (list.flows[lfn].typesNum !== 0) {
|
|
256
|
+
return olTypes1All1 = false;
|
|
257
|
+
}
|
|
258
|
+
let n = 0;
|
|
259
|
+
//console.log(list.flows)
|
|
260
|
+
while (n < list.flows.length) {
|
|
261
|
+
if (list.flows[n].type === 'list_item_open') {
|
|
262
|
+
//console.log(list.flows[n].symbols)
|
|
263
|
+
if (list.flows[lfn].level !== list.flows[n].level) {
|
|
264
|
+
n++; continue;
|
|
265
|
+
}
|
|
266
|
+
if (+list.flows[n].symbols[sn].cont !== 1) {
|
|
267
|
+
olTypes1All1 = false;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
n++
|
|
272
|
+
}
|
|
273
|
+
return olTypes1All1
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
|
|
255
277
|
function setNumbers(state, list) {
|
|
256
278
|
let lfn = 0;
|
|
257
279
|
while (lfn < list.flows.length) {
|
|
258
280
|
//console.log('list.flows[' + lfn + ']: '+ JSON.stringify(list.flows[lfn]));
|
|
259
|
-
|
|
260
281
|
const cn = list.flows[lfn].pos;
|
|
261
282
|
const isParent = list.flows[lfn].type.match(/(numbering_bullet|ordered)_list_open/);
|
|
262
283
|
if (isParent) {
|
|
@@ -268,6 +289,9 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
268
289
|
const ptn = getParentTypeNum(list, lfn);
|
|
269
290
|
list.flows[lfn].typesNum = ptn;
|
|
270
291
|
const sn = getSymbolsNum(list, lfn+1, lfn);
|
|
292
|
+
const olTypes1All1 = setOlTypes1All1(list, lfn, sn);
|
|
293
|
+
list.flows[lfn].olTypes1All1 = olTypes1All1
|
|
294
|
+
//console.log(olTypes1All1)
|
|
271
295
|
//Set type and role attribute.
|
|
272
296
|
let isOlTypes = false;
|
|
273
297
|
let isOlTypes1 = false;
|
|
@@ -280,7 +304,6 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
280
304
|
if (!isOlTypes1) {
|
|
281
305
|
state.tokens[cn].attrSet('type', olTypes[otn][0]);
|
|
282
306
|
}
|
|
283
|
-
|
|
284
307
|
break;
|
|
285
308
|
}
|
|
286
309
|
otn++;
|
|
@@ -357,7 +380,7 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
357
380
|
//Set value attribute.
|
|
358
381
|
if (list.flows[lfn -1].type === 'list_item_open') {
|
|
359
382
|
const psn = getSymbolsNum(list, lfn - 1, plfn);
|
|
360
|
-
if (+list.flows[lfn -1].symbols[psn].num + 1 !== +list.flows[lfn].symbols[sn].num) {
|
|
383
|
+
if (+list.flows[lfn -1].symbols[psn].num + 1 !== +list.flows[lfn].symbols[sn].num && !list.flows[plfn].olTypes1All1) {
|
|
361
384
|
state.tokens[cn].attrSet('value', list.flows[lfn].symbols[sn].num);
|
|
362
385
|
}
|
|
363
386
|
}
|
|
@@ -445,7 +468,6 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
445
468
|
|
|
446
469
|
function numUl (state) {
|
|
447
470
|
let n = 0;
|
|
448
|
-
|
|
449
471
|
//console.log(state.tokens);
|
|
450
472
|
while (n < state.tokens.length) {
|
|
451
473
|
const token = state.tokens[n];
|
|
@@ -471,5 +493,5 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
471
493
|
return;
|
|
472
494
|
}
|
|
473
495
|
|
|
474
|
-
md.core.ruler.
|
|
496
|
+
md.core.ruler.after('linkify', 'numbering_ul', numUl);
|
|
475
497
|
};
|
package/listTypes.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"start": 0,
|
|
6
6
|
"prefix": "[(]?",
|
|
7
7
|
"suffix": "[)]?",
|
|
8
|
-
"joint": "[.]
|
|
8
|
+
"joint": "[.]"
|
|
9
9
|
},{
|
|
10
10
|
"name": "lower-latin",
|
|
11
11
|
"symbolsCont": "abcdefghijklmnopqrstuvwxyz",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"start": 1,
|
|
14
14
|
"prefix": "[(]?",
|
|
15
15
|
"suffix": "[)]?",
|
|
16
|
-
"joint": "[.]
|
|
16
|
+
"joint": "[.]"
|
|
17
17
|
},{
|
|
18
18
|
"name": "upper-latin",
|
|
19
19
|
"symbolsCont": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"start": 1,
|
|
22
22
|
"prefix": "[(]?",
|
|
23
23
|
"suffix": "[)]?",
|
|
24
|
-
"joint": "[.]
|
|
24
|
+
"joint": "[.]"
|
|
25
25
|
},{
|
|
26
26
|
"name": "lower-roman",
|
|
27
27
|
"symbolsCont": "ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻ",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"start": 1,
|
|
30
30
|
"prefix": "[(]?",
|
|
31
31
|
"suffix": "[)]?",
|
|
32
|
-
"joint": "[.]
|
|
32
|
+
"joint": "[.]"
|
|
33
33
|
},{
|
|
34
34
|
"name": "upper-roman",
|
|
35
35
|
"symbolsCont": "ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"start": 1,
|
|
38
38
|
"prefix": "[(]?",
|
|
39
39
|
"suffix": "[)]?",
|
|
40
|
-
"joint": "[.]
|
|
40
|
+
"joint": "[.]"
|
|
41
41
|
},{
|
|
42
42
|
"name": "filled-circled-decimal",
|
|
43
43
|
"symbolsCont": "❶❷❸❹❺❻❼❽❾❿⓫⓬⓭⓮⓯⓰⓱⓲⓳⓴",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"start": 1,
|
|
46
46
|
"prefix": "",
|
|
47
47
|
"suffix": "",
|
|
48
|
-
"joint": "
|
|
48
|
+
"joint": ""
|
|
49
49
|
},{
|
|
50
50
|
"name": "circled-decimal",
|
|
51
51
|
"symbolsCont": "⓪①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳㉑㉒㉓㉔㉕㉖㉗㉘㉙㉚㉛㉜㉝㉞㉟㊱㊲㊳㊴㊵㊶㊷㊸㊹㊺㊻㊼㊽㊾㊿",
|
|
@@ -53,5 +53,37 @@
|
|
|
53
53
|
"start": 0,
|
|
54
54
|
"prefix": "",
|
|
55
55
|
"suffix": "",
|
|
56
|
-
"joint": "
|
|
57
|
-
}
|
|
56
|
+
"joint": ""
|
|
57
|
+
},{
|
|
58
|
+
"name": "circled-lower-latin",
|
|
59
|
+
"symbolsCont": "ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ",
|
|
60
|
+
"symbols": ["\u24D0","\u24D1","\u24D2","\u24D3","\u24D4","\u24D5","\u24D6","\u24D7","\u24D8","\u24D9","\u24DA","\u24DB","\u24DC","\u24DD","\u24DE","\u24DF","\u24E0","\u24E1","\u24E2","\u24E3","\u24E4","\u24E5","\u24E6","\u24E7","\u24E8","\u24E9"],
|
|
61
|
+
"start": 1,
|
|
62
|
+
"prefix": "",
|
|
63
|
+
"suffix": "",
|
|
64
|
+
"joint": ""
|
|
65
|
+
},{
|
|
66
|
+
"name": "circled-upper-latin",
|
|
67
|
+
"symbolsCont": "ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ",
|
|
68
|
+
"symbols": ["\u24B6","\u24B7","\u24B8","\u24B9","\u24BA","\u24BB","\u24BC","\u24BD","\u24BE","\u24BF","\u24C0","\u24C1","\u24C2","\u24C3","\u24C4","\u24C5","\u24C6","\u24C7","\u24C8","\u24C9","\u24CA","\u24CB","\u24CC","\u24CD","\u24CE","\u24CF"],
|
|
69
|
+
"start": 1,
|
|
70
|
+
"prefix": "",
|
|
71
|
+
"suffix": "",
|
|
72
|
+
"joint": ""
|
|
73
|
+
},{
|
|
74
|
+
"name": "filled-circled-upper-latin",
|
|
75
|
+
"symbolsCont": "🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩",
|
|
76
|
+
"symbols": ["\u1F150","\u1F151","\u1F152","\u1F153","\u1F154","\u1F155","\u1F156","\u1F157","\u1F158","\u1F159","\u1F15A","\u1F15B","\u1F15C","\u1F15D","\u1F15E","\u1F15F","\u1F160","\u1F161","\u1F162","\u1F163","\u1F164","\u1F165","\u1F166","\u1F167","\u1F168","\u1F169"],
|
|
77
|
+
"start": 1,
|
|
78
|
+
"prefix": "",
|
|
79
|
+
"suffix": "",
|
|
80
|
+
"joint": ""
|
|
81
|
+
},{
|
|
82
|
+
"name": "filled-circled-upper-latin",
|
|
83
|
+
"symbolsCont": "🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩",
|
|
84
|
+
"symbols": ["\u1F150","\u1F151","\u1F152","\u1F153","\u1F154","\u1F155","\u1F156","\u1F157","\u1F158","\u1F159","\u1F15A","\u1F15B","\u1F15C","\u1F15D","\u1F15E","\u1F15F","\u1F160","\u1F161","\u1F162","\u1F163","\u1F164","\u1F165","\u1F166","\u1F167","\u1F168","\u1F169"],
|
|
85
|
+
"start": 1,
|
|
86
|
+
"prefix": "",
|
|
87
|
+
"suffix": "",
|
|
88
|
+
"joint": ""
|
|
89
|
+
}]
|
package/package.json
CHANGED
|
@@ -199,3 +199,13 @@
|
|
|
199
199
|
<li>項目3</li>
|
|
200
200
|
</ol>
|
|
201
201
|
|
|
202
|
+
[Markdown]
|
|
203
|
+
- ⓐ 項目1
|
|
204
|
+
- ⓑ 項目2
|
|
205
|
+
- ⓒ 項目3
|
|
206
|
+
[HTML]
|
|
207
|
+
<ol class="ol-circled-lower-latin">
|
|
208
|
+
<li><span class="li-num">ⓐ</span> 項目1</li>
|
|
209
|
+
<li><span class="li-num">ⓑ</span> 項目2</li>
|
|
210
|
+
<li><span class="li-num">ⓒ</span> 項目3</li>
|
|
211
|
+
</ol>
|
package/test/examples.txt
CHANGED
|
@@ -151,12 +151,12 @@
|
|
|
151
151
|
</ol>
|
|
152
152
|
|
|
153
153
|
[Markdown]
|
|
154
|
-
-
|
|
155
|
-
-
|
|
156
|
-
-
|
|
157
|
-
-
|
|
158
|
-
-
|
|
159
|
-
-
|
|
154
|
+
- ❸ 項目❸
|
|
155
|
+
- ❹ 項目❹
|
|
156
|
+
- ② 項目❹-②
|
|
157
|
+
- ③ 項目❹-③
|
|
158
|
+
- ④ 項目❹-④
|
|
159
|
+
- ❺ 項目❺
|
|
160
160
|
[HTML]
|
|
161
161
|
<ol start="3" role="list" class="ol-filled-circled-decimal">
|
|
162
162
|
<li aria-label="❸">項目❸</li>
|
|
@@ -199,3 +199,38 @@
|
|
|
199
199
|
<li>項目3</li>
|
|
200
200
|
</ol>
|
|
201
201
|
|
|
202
|
+
|
|
203
|
+
[Markdown]
|
|
204
|
+
- 1.0 項目1
|
|
205
|
+
- 2.0 項目2
|
|
206
|
+
- 3.0 項目3
|
|
207
|
+
[HTML]
|
|
208
|
+
<ul>
|
|
209
|
+
<li>1.0 項目1</li>
|
|
210
|
+
<li>2.0 項目2</li>
|
|
211
|
+
<li>3.0 項目3</li>
|
|
212
|
+
</ul>
|
|
213
|
+
|
|
214
|
+
[Markdown]
|
|
215
|
+
1. 1.0 項目1
|
|
216
|
+
2. 2.0 項目2
|
|
217
|
+
3. 3.0 項目3
|
|
218
|
+
[HTML]
|
|
219
|
+
<ol class="ol-decimal">
|
|
220
|
+
<li>1.0 項目1</li>
|
|
221
|
+
<li>2.0 項目2</li>
|
|
222
|
+
<li>3.0 項目3</li>
|
|
223
|
+
</ol>
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
[Markdown]
|
|
227
|
+
1. 1.0 項目1
|
|
228
|
+
1. 2.0 項目2
|
|
229
|
+
1. 3.0 項目3
|
|
230
|
+
[HTML]
|
|
231
|
+
<ol class="ol-decimal">
|
|
232
|
+
<li>1.0 項目1</li>
|
|
233
|
+
<li>2.0 項目2</li>
|
|
234
|
+
<li>3.0 項目3</li>
|
|
235
|
+
</ol>
|
|
236
|
+
|