@peaceroad/markdown-it-numbering-ul-regarded-as-ol 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -108,9 +108,9 @@ md.use(mdNumUl, {
108
108
  - iii. c
109
109
  [HTML]
110
110
  <ol type="i" class="ol-lower-roman">
111
- <li><span class="li-num">i<span class="li-num-joint">.</span></span> a</li>
112
- <li><span class="li-num">ii<span class="li-num-joint">.</span></span> b</li>
113
- <li><span class="li-num">iii<span class="li-num-joint">.</span></span> c</li>
111
+ <li>a</li>
112
+ <li>b</li>
113
+ <li>c</li>
114
114
  </ol>
115
115
 
116
116
  [Markdown]
@@ -192,9 +192,9 @@ md.use(mdNumUl, {
192
192
  <li>項目1</li>
193
193
  <li>項目2
194
194
  <ol type="i" class="ol-lower-roman">
195
- <li><span class="li-num">i<span class="li-num-joint">.</span></span> 項目2-i</li>
196
- <li><span class="li-num">ii<span class="li-num-joint">.</span></span> 項目2-ii</li>
197
- <li><span class="li-num">iii<span class="li-num-joint">.</span></span> 項目2-iii</li>
195
+ <li>項目2-i</li>
196
+ <li>項目2-ii</li>
197
+ <li>項目2-iii</li>
198
198
  </ol>
199
199
  </li>
200
200
  <li>項目3</li>
@@ -209,15 +209,15 @@ md.use(mdNumUl, {
209
209
  - iii. 項目iii
210
210
  [HTML]
211
211
  <ol type="i" class="ol-lower-roman">
212
- <li><span class="li-num">i<span class="li-num-joint">.</span></span> 項目i</li>
213
- <li><span class="li-num">ii<span class="li-num-joint">.</span></span> 項目ii
212
+ <li>項目i</li>
213
+ <li>項目ii
214
214
  <ol class="ol-decimal">
215
215
  <li>項目ii-1</li>
216
216
  <li>項目ii-2</li>
217
217
  <li>項目ii-3</li>
218
218
  </ol>
219
219
  </li>
220
- <li><span class="li-num">iii<span class="li-num-joint">.</span></span> 項目iii</li>
220
+ <li>項目iii</li>
221
221
  </ol>
222
222
 
223
223
  [Markdown]
@@ -255,17 +255,18 @@ md.use(mdNumUl, {
255
255
  <li>項目1</li>
256
256
  <li>項目2
257
257
  <ol type="i" class="ol-lower-roman">
258
- <li><span class="li-num">i<span class="li-num-joint">.</span></span> 項目2-i</li>
259
- <li><span class="li-num">ii<span class="li-num-joint">.</span></span> 項目2-ii
258
+ <li>項目2-i</li>
259
+ <li>項目2-ii
260
260
  <ol type="a" class="ol-lower-latin">
261
- <li><span class="li-num">a<span class="li-num-joint">.</span></span> 項目2-ii-a</li>
262
- <li><span class="li-num">b<span class="li-num-joint">.</span></span> 項目2-ii-b</li>
263
- <li><span class="li-num">c<span class="li-num-joint">.</span></span> 項目2-ii-c</li>
261
+ <li>項目2-ii-a</li>
262
+ <li>項目2-ii-b</li>
263
+ <li>項目2-ii-c</li>
264
264
  </ol>
265
265
  </li>
266
- <li><span class="li-num">iii<span class="li-num-joint">.</span></span> 項目2-iii</li>
266
+ <li>項目2-iii</li>
267
267
  </ol>
268
268
  </li>
269
269
  <li>項目3</li>
270
270
  </ol>
271
+
271
272
  ```
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 symbole types.
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.before('linkify', 'numbering_ul', numUl);
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,5 @@
53
53
  "start": 0,
54
54
  "prefix": "",
55
55
  "suffix": "",
56
- "joint": " *"
56
+ "joint": ""
57
57
  }]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peaceroad/markdown-it-numbering-ul-regarded-as-ol",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "This markdown-it plugin regard ul element with numbering lists as ol element.",
5
5
  "main": "index.js",
6
6
  "scripts": {
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
+
package/test/test.js CHANGED
@@ -48,7 +48,7 @@ setMs(example, ms);
48
48
 
49
49
  let n = 1;
50
50
  while(n < ms.length) {
51
- //if (n >= 5) { n++; continue };
51
+ // if (n !== 17) { n++; continue };
52
52
  console.log('Test: ' + n + ' >>>');
53
53
  //console.log(ms[n].markdown);
54
54