@peaceroad/markdown-it-numbering-ul-regarded-as-ol 0.1.4 → 0.1.6
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 +38 -16
- package/listTypes.json +25 -1
- package/package.json +1 -1
- package/test/examples-spantitle.txt +88 -0
- package/test/test.js +2 -1
package/index.js
CHANGED
|
@@ -54,7 +54,7 @@ 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].replace(/^\\\\/,'\\') + '(' + types[ltn].suffix + ')(' + types[ltn].joint + '))([ ])+', 'u'));
|
|
58
58
|
if (!hasSymbol) { sn++; continue; }
|
|
59
59
|
|
|
60
60
|
symbol.typesNum = ltn;
|
|
@@ -75,13 +75,12 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
function processListToken (state, n, list) {
|
|
78
|
-
list.level++;
|
|
79
78
|
const flow = {
|
|
80
79
|
level: -1,
|
|
81
80
|
type: '',
|
|
82
81
|
pos: -1,
|
|
83
82
|
attrs: [],
|
|
84
|
-
psTypes: [], //
|
|
83
|
+
psTypes: [], //parent symbol types.
|
|
85
84
|
symbols: [],
|
|
86
85
|
};
|
|
87
86
|
const startFlow = Object.create(flow);
|
|
@@ -94,22 +93,22 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
94
93
|
while (cn < state.tokens.length) {
|
|
95
94
|
const cnToken = state.tokens[cn];
|
|
96
95
|
//console.log('cn: ' + cn + ', list.level: ' + list.level + ', cnToken.type: ', cnToken.type, ', cnToken.content: ' + cnToken.content);
|
|
97
|
-
|
|
98
96
|
const isCnListOpen = cnToken.type.match(/(bullet|ordered)_list_open/);
|
|
99
97
|
const isCnListClose = cnToken.type.match(/(bullet|ordered)_list_close/);
|
|
100
98
|
|
|
101
99
|
if (isCnListClose) {
|
|
102
100
|
let stcn = list.flows.length - 1;
|
|
101
|
+
let st = {};
|
|
103
102
|
while (stcn > -1) {
|
|
104
103
|
//console.log('stcn: ' + stcn + ', list.flows[stcn].type: ' + list.flows[stcn].type);
|
|
105
104
|
list.nextPos = cn + 1;
|
|
106
|
-
|
|
105
|
+
st = list.flows[stcn].type.match(/(numbering_)?(?:bullet|ordered)_list_open/);
|
|
106
|
+
if(st && list.level === list.flows[stcn].level) {
|
|
107
107
|
break;
|
|
108
108
|
}
|
|
109
109
|
stcn--;
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
if (/numbering_(?:bullet|ordered)_list_open/.test(list.flows[stcn].type)) {
|
|
111
|
+
if (st[1]) {
|
|
113
112
|
isCnListClose[0] = 'numbering_' + isCnListClose[0];
|
|
114
113
|
cnToken.tag = 'ol';
|
|
115
114
|
}
|
|
@@ -154,7 +153,7 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
154
153
|
//Check parent list flow number.
|
|
155
154
|
let plfn = list.flows.length - 2;
|
|
156
155
|
while (plfn > -1) {
|
|
157
|
-
if (list.flows[plfn].type
|
|
156
|
+
if (/(?:bullet|ordered)_list_open/.test(list.flows[plfn].type) && listFlow.level === list.flows[plfn].level) {
|
|
158
157
|
break;
|
|
159
158
|
}
|
|
160
159
|
plfn--; continue;
|
|
@@ -167,7 +166,7 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
167
166
|
const liVal = cnToken.info;
|
|
168
167
|
let decimalSymbol = {
|
|
169
168
|
typesNum: 0,
|
|
170
|
-
typePos: liVal,
|
|
169
|
+
typePos: liVal,
|
|
171
170
|
contAll: liVal + '. ',
|
|
172
171
|
cont: liVal,
|
|
173
172
|
prefix: '',
|
|
@@ -180,6 +179,9 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
180
179
|
|
|
181
180
|
list.nextPos = cn + 1;
|
|
182
181
|
if (listFlow.symbols.length === 0) {
|
|
182
|
+
if (/^numbering_/.test(list.flows[plfn].type)) {
|
|
183
|
+
list.flows[plfn].type = list.flows[plfn].type.replace(/^numbering_/, '');
|
|
184
|
+
}
|
|
183
185
|
cn++; continue;
|
|
184
186
|
}
|
|
185
187
|
|
|
@@ -273,7 +275,6 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
273
275
|
return olTypes1All1
|
|
274
276
|
}
|
|
275
277
|
|
|
276
|
-
|
|
277
278
|
function setNumbers(state, list) {
|
|
278
279
|
let lfn = 0;
|
|
279
280
|
while (lfn < list.flows.length) {
|
|
@@ -292,6 +293,7 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
292
293
|
const olTypes1All1 = setOlTypes1All1(list, lfn, sn);
|
|
293
294
|
list.flows[lfn].olTypes1All1 = olTypes1All1
|
|
294
295
|
//console.log(olTypes1All1)
|
|
296
|
+
|
|
295
297
|
//Set type and role attribute.
|
|
296
298
|
let isOlTypes = false;
|
|
297
299
|
let isOlTypes1 = false;
|
|
@@ -371,19 +373,39 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
371
373
|
|
|
372
374
|
// list.flows[lfn].symbols.length > 0 for bullet list.
|
|
373
375
|
if (list.flows[lfn].type === 'list_item_open' && list.flows[lfn].symbols.length) {
|
|
376
|
+
|
|
374
377
|
const plfn = getParentNum(list, lfn);
|
|
375
378
|
//console.log('plfn: ' + plfn + ', list.flows[pn]: ' + JSON.stringify(list.flows[plfn]));
|
|
379
|
+
if (list.flows[plfn].type === 'bullet_list_open') {
|
|
380
|
+
lfn++; continue;
|
|
381
|
+
}
|
|
376
382
|
const sn = getSymbolsNum(list, lfn, plfn);
|
|
377
383
|
//console.log('sn: ' + sn);
|
|
378
384
|
//console.log('symbols.num: ' + +list.flows[lfn].symbols[sn].num);
|
|
379
385
|
|
|
380
386
|
//Set value attribute.
|
|
387
|
+
//console.log('!!Set Value' + JSON.stringify(list.flows[lfn]))
|
|
388
|
+
|
|
389
|
+
const psn = getSymbolsNum(list, lfn - 1, plfn);
|
|
390
|
+
/*
|
|
381
391
|
if (list.flows[lfn -1].type === 'list_item_open') {
|
|
382
|
-
const psn = getSymbolsNum(list, lfn - 1, plfn);
|
|
383
392
|
if (+list.flows[lfn -1].symbols[psn].num + 1 !== +list.flows[lfn].symbols[sn].num && !list.flows[plfn].olTypes1All1) {
|
|
384
393
|
state.tokens[cn].attrSet('value', list.flows[lfn].symbols[sn].num);
|
|
385
394
|
}
|
|
386
395
|
}
|
|
396
|
+
*/
|
|
397
|
+
let blfn = lfn - 1;
|
|
398
|
+
while (blfn) {
|
|
399
|
+
//console.log('level[lfn]: ' + list.flows[lfn].level + ', level[blfn]: ' + list.flows[blfn].level)
|
|
400
|
+
if (list.flows[blfn].type === 'list_item_open' && list.flows[lfn].level === list.flows[blfn].level) {
|
|
401
|
+
//console.log(list.flows[blfn].symbols[psn].num + list.flows[lfn].symbols[sn].num)
|
|
402
|
+
if (+list.flows[blfn].symbols[psn].num + 1 !== +list.flows[lfn].symbols[sn].num && !list.flows[plfn].olTypes1All1) {
|
|
403
|
+
state.tokens[cn].attrSet('value', list.flows[lfn].symbols[sn].num);
|
|
404
|
+
}
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
blfn--
|
|
408
|
+
}
|
|
387
409
|
|
|
388
410
|
//Set list num span element.
|
|
389
411
|
if (opt.describeListNumber) {
|
|
@@ -471,27 +493,27 @@ module.exports = function numbering_ul_regarded_as_ol_plugin(md, option) {
|
|
|
471
493
|
//console.log(state.tokens);
|
|
472
494
|
while (n < state.tokens.length) {
|
|
473
495
|
const token = state.tokens[n];
|
|
474
|
-
const isListOpen =
|
|
496
|
+
const isListOpen = /(bullet|ordered)_list_open/.test(token.type);
|
|
475
497
|
if (!isListOpen) { n++; continue; }
|
|
476
498
|
|
|
477
499
|
let list = {
|
|
478
|
-
level:
|
|
500
|
+
level: 1,
|
|
479
501
|
flows: [],
|
|
480
502
|
nextPos: n + 1,
|
|
481
503
|
};
|
|
482
504
|
processListToken(state, n, list);
|
|
483
|
-
//console.log('list: ' + JSON.stringify(list));
|
|
484
505
|
|
|
485
506
|
/*
|
|
486
507
|
if(!opt.noChangeBulletOneOrderedList) {
|
|
487
508
|
modifyBulletOneOrderedList(state, n, list);
|
|
488
509
|
}
|
|
489
510
|
*/
|
|
490
|
-
|
|
511
|
+
setNumbers(state, list);
|
|
512
|
+
|
|
491
513
|
n = list.nextPos;
|
|
492
514
|
}
|
|
493
515
|
return;
|
|
494
516
|
}
|
|
495
|
-
|
|
517
|
+
|
|
496
518
|
md.core.ruler.after('linkify', 'numbering_ul', numUl);
|
|
497
519
|
};
|
package/listTypes.json
CHANGED
|
@@ -54,4 +54,28 @@
|
|
|
54
54
|
"prefix": "",
|
|
55
55
|
"suffix": "",
|
|
56
56
|
"joint": ""
|
|
57
|
-
}
|
|
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": ["\\u{1F150}","\\u{1F151}","\\u{1F152}","\\u{1F153}","\\u{1F154}","\\u{1F155}","\\u{1F156}","\\u{1F157}","\\u{1F158}","\\u{1F159}","\\u{1F15A}","\\u{1F15B}","\\u{1F15C}","\\u{1F15D}","\\u{1F15E}","\\u{1F15F}","\\u{1F160}","\\u{1F161}","\\u{1F162}","\\u{1F163}","\\u{1F164}","\\u{1F165}","\\u{1F166}","\\u{1F167}","\\u{1F168}","\\u{1F169}"],
|
|
77
|
+
"start": 1,
|
|
78
|
+
"prefix": "",
|
|
79
|
+
"suffix": "",
|
|
80
|
+
"joint": ""
|
|
81
|
+
}]
|
package/package.json
CHANGED
|
@@ -199,3 +199,91 @@
|
|
|
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>
|
|
212
|
+
|
|
213
|
+
[Markdown]
|
|
214
|
+
- Ⓐ 項目1
|
|
215
|
+
- Ⓑ 項目2
|
|
216
|
+
- Ⓒ 項目3
|
|
217
|
+
[HTML]
|
|
218
|
+
<ol class="ol-circled-upper-latin">
|
|
219
|
+
<li><span class="li-num">Ⓐ</span> 項目1</li>
|
|
220
|
+
<li><span class="li-num">Ⓑ</span> 項目2</li>
|
|
221
|
+
<li><span class="li-num">Ⓒ</span> 項目3</li>
|
|
222
|
+
</ol>
|
|
223
|
+
|
|
224
|
+
[Markdown]
|
|
225
|
+
- 🅐 項目1
|
|
226
|
+
- 🅑 項目2
|
|
227
|
+
- 🅒 項目3
|
|
228
|
+
[HTML]
|
|
229
|
+
<ol class="ol-filled-circled-upper-latin">
|
|
230
|
+
<li><span class="li-num">🅐</span> 項目1</li>
|
|
231
|
+
<li><span class="li-num">🅑</span> 項目2</li>
|
|
232
|
+
<li><span class="li-num">🅒</span> 項目3</li>
|
|
233
|
+
</ol>
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
[Markdown]
|
|
237
|
+
- 項目1
|
|
238
|
+
- 2. 項目2
|
|
239
|
+
- 項目3
|
|
240
|
+
[HTML]
|
|
241
|
+
<ul>
|
|
242
|
+
<li>項目1</li>
|
|
243
|
+
<li>
|
|
244
|
+
<ol start="2" class="ol-decimal">
|
|
245
|
+
<li>項目2</li>
|
|
246
|
+
</ol>
|
|
247
|
+
</li>
|
|
248
|
+
<li>項目3</li>
|
|
249
|
+
</ul>
|
|
250
|
+
|
|
251
|
+
[Markdown]
|
|
252
|
+
- 項目1
|
|
253
|
+
- B. 項目2
|
|
254
|
+
- 項目3
|
|
255
|
+
[HTML]
|
|
256
|
+
<ul>
|
|
257
|
+
<li>項目1</li>
|
|
258
|
+
<li>B. 項目2</li>
|
|
259
|
+
<li>項目3</li>
|
|
260
|
+
</ul>
|
|
261
|
+
|
|
262
|
+
[Markdown]
|
|
263
|
+
1. 項目1
|
|
264
|
+
1. 項目2
|
|
265
|
+
2. 項目3
|
|
266
|
+
[HTML]
|
|
267
|
+
<ol class="ol-decimal">
|
|
268
|
+
<li>項目1
|
|
269
|
+
<ol class="ol-decimal">
|
|
270
|
+
<li>項目2</li>
|
|
271
|
+
</ol>
|
|
272
|
+
</li>
|
|
273
|
+
<li>項目3</li>
|
|
274
|
+
</ol>
|
|
275
|
+
|
|
276
|
+
[Markdown]
|
|
277
|
+
1. 項目1
|
|
278
|
+
- 項目1-1
|
|
279
|
+
3. 項目3
|
|
280
|
+
[HTML]
|
|
281
|
+
<ol class="ol-decimal">
|
|
282
|
+
<li>項目1
|
|
283
|
+
<ul>
|
|
284
|
+
<li>項目1-1</li>
|
|
285
|
+
</ul>
|
|
286
|
+
</li>
|
|
287
|
+
<li value="3">項目3</li>
|
|
288
|
+
</ol>
|
|
289
|
+
|
package/test/test.js
CHANGED