@peaceroad/markdown-it-numbering-ul-regarded-as-ol 0.2.0 → 0.2.1
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 +336 -335
- package/debug/dump_listinfos.mjs +65 -0
- package/debug/dump_tokens.mjs +72 -0
- package/index.js +5 -0
- package/package.json +5 -2
- package/src/phase0-description-list.js +654 -654
- package/src/phase1-analyze.js +90 -7
- package/src/phase2-convert.js +1037 -738
- package/src/phase3-attributes.js +260 -244
- package/src/phase5-spans.js +1 -1
- package/src/phase6-attrs-migration.js +1 -1
- package/src/preprocess-literal-lists.js +776 -0
- package/src/types-utility.js +995 -991
package/README.md
CHANGED
|
@@ -1,335 +1,336 @@
|
|
|
1
|
-
# p7d-markdown-it-numbering-ul-regarded-as-ol
|
|
2
|
-
|
|
3
|
-
Markdown's default ordered list markers are limited. This plugin extends Markdown's unordered lists so they can use many kinds of ordered markers.
|
|
4
|
-
|
|
5
|
-
Also, this plugin option provides a description-list conversion. Unordered list items whose first line is wrapped in `**` and followed by two spaces are converted into `<dl>` elements.
|
|
6
|
-
|
|
7
|
-
## Ordered lists conversion behavior
|
|
8
|
-
|
|
9
|
-
This plugin detects unordered lists that use number-like markers (for example `- a.`, `- ①`) and converts them into appropriate ordered lists (`<ol>`). During conversion the plugin also attaches informative attributes to the generated elements.
|
|
10
|
-
|
|
11
|
-
Code. Conversion of a lowercase Roman numeral list.
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
[Markdown]
|
|
15
|
-
- i. First item
|
|
16
|
-
- ii. Second item
|
|
17
|
-
- iii. Third item
|
|
18
|
-
|
|
19
|
-
[HTML]
|
|
20
|
-
<ol type="i" class="ol-lower-roman" data-marker-suffix=".">
|
|
21
|
-
<li>First item</li>
|
|
22
|
-
<li>Second item</li>
|
|
23
|
-
<li>Third item</li>
|
|
24
|
-
</ol>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Supported Marker Types
|
|
28
|
-
|
|
29
|
-
The plugin supports the following marker types.
|
|
30
|
-
|
|
31
|
-
- **HTML Standard Markers (with `type` attribute)**
|
|
32
|
-
- decimal: `1`, `2`, `3`, pattern: common
|
|
33
|
-
- lower-latin: `a`, `b`, `c`, pattern: common
|
|
34
|
-
- upper-latin: `A`, `B`, `C`, pattern: common
|
|
35
|
-
- lower-roman: `i`, `ii`, `iii`, pattern: common
|
|
36
|
-
- upper-roman: `I`, `II`, `III`, pattern: common
|
|
37
|
-
- **Custom Markers (with `role="list"`)**
|
|
38
|
-
- circled-decimal: `①`, `②`, `③`, pattern: enclosed
|
|
39
|
-
- filled-circled-decimal: `❶`, `❷`, `❸`, pattern: enclosed
|
|
40
|
-
- circled-lower-latin: `ⓐ`, `ⓑ`, `ⓒ`, pattern: enclosed
|
|
41
|
-
- circled-upper-latin: `Ⓐ`, `Ⓑ`, `Ⓒ`, pattern: enclosed
|
|
42
|
-
- filled-circled-upper-latin: `🅐`, `🅑`, `🅒`, pattern: enclosed
|
|
43
|
-
- squared-decimal: `1⃣`, `2⃣`, `3⃣`, pattern: enclosed
|
|
44
|
-
- squared-upper-latin: `🄰`, `🄱`, `🄲`, pattern: enclosed
|
|
45
|
-
- filled-squared-upper-latin: `🅰`, `🅱`, `🅲`, pattern: enclosed
|
|
46
|
-
- fullwidth-lower-roman: `ⅰ`, `ⅱ`, `ⅲ`, pattern: fullwidth
|
|
47
|
-
- fullwidth-upper-roman: `Ⅰ`, `Ⅱ`, `Ⅲ`, pattern: fullwidth
|
|
48
|
-
- japanese-informal: `一`, `二`, `三`, pattern: fullwidth
|
|
49
|
-
- katakana: `ア`, `イ`, `ウ`, pattern: fullwidth
|
|
50
|
-
- katakana-iroha: `イ`, `ロ`, `ハ`, pattern: fullwidth
|
|
51
|
-
- lower-greek: `α`, `β`, `γ`, pattern: common
|
|
52
|
-
|
|
53
|
-
Marker separators differ depending on the character style used for the ordinal marker: ASCII markers (`- a.`, `- a)`, `(a)`), fullwidth markers (`- 一、`, `- 一.`), or enclosed glyphs (`- ①`, `- ❶`). The `pattern` value for each marker type indicates which separator rules apply:
|
|
54
|
-
|
|
55
|
-
- `common`: examples include `a.`, `a)`, `(a)`;
|
|
56
|
-
- `fullwidth`: includes fullwidth separators such as `イ.`, `イ)`, `(イ)`;
|
|
57
|
-
- `enclosed`: enclosed glyphs like `①` which do not use `.` or `)` as separators.
|
|
58
|
-
|
|
59
|
-
After the marker separator, an ASCII space is normally expected. For `fullwidth` and `enclosed` patterns a fullwidth space is accepted in place of the ASCII space; enclosed markers may also appear without a following space. See `listTypes.json` for the canonical marker definitions.
|
|
60
|
-
|
|
61
|
-
### Attributes and markers
|
|
62
|
-
|
|
63
|
-
- The generated `<ol>` receives a `class` of the form `ol-<marker-name>`. For example, a `- a.` marker results in `class="ol-lower-latin"` on the `<ol>`.
|
|
64
|
-
- Standard HTML markers (decimal, latin, roman) produce an `<ol>` with a `type` attribute (for example `type="1"`, `type="a"`, `type="i"`). Custom markers (circled numbers, Katakana, Kanji, etc.) do not set a `type` attribute by default; instead the plugin emits `role="list"` on the `<ol>`.
|
|
65
|
-
- When the starting number is not `1`, the plugin adds a native `start` attribute to the `<ol>` for both standard and custom markers.
|
|
66
|
-
- When a marker separator is present, the plugin adds `data-marker-prefix` and/or `data-marker-suffix` attributes with the matched strings. These attributes are omitted if there is no prefix/suffix (or if the suffix is visually only whitespace). For example, `- a.` results in `data-marker-suffix="."`.
|
|
67
|
-
- For custom markers the plugin inserts the visible marker text inside a `span` with the configured `markerSpanClass` (default: `li-num`). Example: `- ①` becomes `<li><span class="li-num" aria-hidden="true">①</span> A item.</li>`.
|
|
68
|
-
- When individual list item numbers jump, the plugin sets the native `value` attribute on the `li` element for both standard and custom markers.
|
|
69
|
-
|
|
70
|
-
### Structures
|
|
71
|
-
|
|
72
|
-
- Marker type detection is deterministic: gather all markers at a nesting level, match them against the canonical definitions, keep the type that explains the most items while preserving numeric continuity, and use the order in `listTypes.json` only as a final tiebreaker.
|
|
73
|
-
- Flattening: A pattern like `- 1.` is represented by the default `ul > li > ol` nesting structure in markdown-it, but this plugin simplifies it to a single `ol` by default to match the representation of other markers.
|
|
74
|
-
|
|
75
|
-
Note: For custom marker lists (those rendered with `role="list"`) the plugin assumes you will hide the native marker via CSS (for example `ol[role="list"] { list-style: none; }`). The `hasListStyleNone` option can be enabled to add `style="list-style: none;"` directly to generated `<ol>` elements.
|
|
76
|
-
|
|
77
|
-
### Behavior customization
|
|
78
|
-
|
|
79
|
-
You can customize the conversion using options.
|
|
80
|
-
|
|
81
|
-
- `unremoveUlNest` (boolean) — If `true`, preserve the original `ul > li > ol` nesting instead of flattening into `ol > li`.
|
|
82
|
-
- `alwaysMarkerSpan` (boolean) — Wrap markers in a `<span>` (class `markerSpanClass`, default: `li-num`). When markers are rendered as custom markers the plugin emits `role="list"` and does not set a `type` attribute on the `<ol>`.
|
|
83
|
-
- `useCounterStyle` (boolean) — When `true` the plugin suppresses generated marker spans (no `span.li-num`) and prefers native `start`/`value` attributes so you can style lists with CSS `@counter-style`. Note that in this case the marker will not be selectable, as browsers currently do not support CSS `user-select` on markers.
|
|
84
|
-
- `markerSpanClass` (string) — Specify the class name applied to the marker `<span>` (default: `li-num`).
|
|
85
|
-
- `hasListStyleNone` (boolean) — When the plugin emits `role="list"`, also add `style="list-style: none;"` to the `<ol>`.
|
|
86
|
-
- `omitMarkerMetadata` (boolean) — If `true`, omit the `data-marker-prefix` / `data-marker-suffix` attributes.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
- `
|
|
103
|
-
- `
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
<
|
|
118
|
-
<li>
|
|
119
|
-
<li>
|
|
120
|
-
</
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
<
|
|
134
|
-
<li><span class="li-num" aria-hidden="true"
|
|
135
|
-
<li><span class="li-num" aria-hidden="true"
|
|
136
|
-
</
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
<
|
|
150
|
-
<li>
|
|
151
|
-
</
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
-
|
|
160
|
-
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
<
|
|
165
|
-
<li>
|
|
166
|
-
<li>
|
|
167
|
-
</
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
-
|
|
177
|
-
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
<
|
|
182
|
-
<
|
|
183
|
-
<
|
|
184
|
-
<li
|
|
185
|
-
</
|
|
186
|
-
</
|
|
187
|
-
|
|
188
|
-
</
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
-
|
|
194
|
-
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
<
|
|
199
|
-
<
|
|
200
|
-
<
|
|
201
|
-
<li>Child item
|
|
202
|
-
</
|
|
203
|
-
</
|
|
204
|
-
|
|
205
|
-
</
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
<
|
|
219
|
-
<
|
|
220
|
-
</
|
|
221
|
-
|
|
222
|
-
<
|
|
223
|
-
</
|
|
224
|
-
</
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
<
|
|
239
|
-
<
|
|
240
|
-
<p>First item
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
<
|
|
244
|
-
<p>Second item
|
|
245
|
-
|
|
246
|
-
</
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
<
|
|
263
|
-
<
|
|
264
|
-
<
|
|
265
|
-
</
|
|
266
|
-
|
|
267
|
-
<
|
|
268
|
-
<
|
|
269
|
-
</
|
|
270
|
-
</
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
<
|
|
281
|
-
<
|
|
282
|
-
<
|
|
283
|
-
</
|
|
284
|
-
|
|
285
|
-
<
|
|
286
|
-
<
|
|
287
|
-
</
|
|
288
|
-
</
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
<
|
|
306
|
-
<
|
|
307
|
-
<
|
|
308
|
-
<p>Description 1, line
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
<
|
|
312
|
-
<
|
|
313
|
-
<p>Description 2, line
|
|
314
|
-
|
|
315
|
-
</
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
import
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
md
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
1
|
+
# p7d-markdown-it-numbering-ul-regarded-as-ol
|
|
2
|
+
|
|
3
|
+
Markdown's default ordered list markers are limited. This plugin extends Markdown's unordered lists so they can use many kinds of ordered markers.
|
|
4
|
+
|
|
5
|
+
Also, this plugin option provides a description-list conversion. Unordered list items whose first line is wrapped in `**` and followed by two spaces are converted into `<dl>` elements.
|
|
6
|
+
|
|
7
|
+
## Ordered lists conversion behavior
|
|
8
|
+
|
|
9
|
+
This plugin detects unordered lists that use number-like markers (for example `- a.`, `- ①`) and converts them into appropriate ordered lists (`<ol>`). During conversion the plugin also attaches informative attributes to the generated elements.
|
|
10
|
+
|
|
11
|
+
Code. Conversion of a lowercase Roman numeral list.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
[Markdown]
|
|
15
|
+
- i. First item
|
|
16
|
+
- ii. Second item
|
|
17
|
+
- iii. Third item
|
|
18
|
+
|
|
19
|
+
[HTML]
|
|
20
|
+
<ol type="i" class="ol-lower-roman" data-marker-suffix=".">
|
|
21
|
+
<li>First item</li>
|
|
22
|
+
<li>Second item</li>
|
|
23
|
+
<li>Third item</li>
|
|
24
|
+
</ol>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Supported Marker Types
|
|
28
|
+
|
|
29
|
+
The plugin supports the following marker types.
|
|
30
|
+
|
|
31
|
+
- **HTML Standard Markers (with `type` attribute)**
|
|
32
|
+
- decimal: `1`, `2`, `3`, pattern: common
|
|
33
|
+
- lower-latin: `a`, `b`, `c`, pattern: common
|
|
34
|
+
- upper-latin: `A`, `B`, `C`, pattern: common
|
|
35
|
+
- lower-roman: `i`, `ii`, `iii`, pattern: common
|
|
36
|
+
- upper-roman: `I`, `II`, `III`, pattern: common
|
|
37
|
+
- **Custom Markers (with `role="list"`)**
|
|
38
|
+
- circled-decimal: `①`, `②`, `③`, pattern: enclosed
|
|
39
|
+
- filled-circled-decimal: `❶`, `❷`, `❸`, pattern: enclosed
|
|
40
|
+
- circled-lower-latin: `ⓐ`, `ⓑ`, `ⓒ`, pattern: enclosed
|
|
41
|
+
- circled-upper-latin: `Ⓐ`, `Ⓑ`, `Ⓒ`, pattern: enclosed
|
|
42
|
+
- filled-circled-upper-latin: `🅐`, `🅑`, `🅒`, pattern: enclosed
|
|
43
|
+
- squared-decimal: `1⃣`, `2⃣`, `3⃣`, pattern: enclosed
|
|
44
|
+
- squared-upper-latin: `🄰`, `🄱`, `🄲`, pattern: enclosed
|
|
45
|
+
- filled-squared-upper-latin: `🅰`, `🅱`, `🅲`, pattern: enclosed
|
|
46
|
+
- fullwidth-lower-roman: `ⅰ`, `ⅱ`, `ⅲ`, pattern: fullwidth
|
|
47
|
+
- fullwidth-upper-roman: `Ⅰ`, `Ⅱ`, `Ⅲ`, pattern: fullwidth
|
|
48
|
+
- japanese-informal: `一`, `二`, `三`, pattern: fullwidth
|
|
49
|
+
- katakana: `ア`, `イ`, `ウ`, pattern: fullwidth
|
|
50
|
+
- katakana-iroha: `イ`, `ロ`, `ハ`, pattern: fullwidth
|
|
51
|
+
- lower-greek: `α`, `β`, `γ`, pattern: common
|
|
52
|
+
|
|
53
|
+
Marker separators differ depending on the character style used for the ordinal marker: ASCII markers (`- a.`, `- a)`, `(a)`), fullwidth markers (`- 一、`, `- 一.`), or enclosed glyphs (`- ①`, `- ❶`). The `pattern` value for each marker type indicates which separator rules apply:
|
|
54
|
+
|
|
55
|
+
- `common`: examples include `a.`, `a)`, `(a)`;
|
|
56
|
+
- `fullwidth`: includes fullwidth separators such as `イ.`, `イ)`, `(イ)`;
|
|
57
|
+
- `enclosed`: enclosed glyphs like `①` which do not use `.` or `)` as separators.
|
|
58
|
+
|
|
59
|
+
After the marker separator, an ASCII space is normally expected. For `fullwidth` and `enclosed` patterns a fullwidth space is accepted in place of the ASCII space; enclosed markers may also appear without a following space. See `listTypes.json` for the canonical marker definitions.
|
|
60
|
+
|
|
61
|
+
### Attributes and markers
|
|
62
|
+
|
|
63
|
+
- The generated `<ol>` receives a `class` of the form `ol-<marker-name>`. For example, a `- a.` marker results in `class="ol-lower-latin"` on the `<ol>`.
|
|
64
|
+
- Standard HTML markers (decimal, latin, roman) produce an `<ol>` with a `type` attribute (for example `type="1"`, `type="a"`, `type="i"`). Custom markers (circled numbers, Katakana, Kanji, etc.) do not set a `type` attribute by default; instead the plugin emits `role="list"` on the `<ol>`.
|
|
65
|
+
- When the starting number is not `1`, the plugin adds a native `start` attribute to the `<ol>` for both standard and custom markers.
|
|
66
|
+
- When a marker separator is present, the plugin adds `data-marker-prefix` and/or `data-marker-suffix` attributes with the matched strings. These attributes are omitted if there is no prefix/suffix (or if the suffix is visually only whitespace). For example, `- a.` results in `data-marker-suffix="."`.
|
|
67
|
+
- For custom markers the plugin inserts the visible marker text inside a `span` with the configured `markerSpanClass` (default: `li-num`). Example: `- ①` becomes `<li><span class="li-num" aria-hidden="true">①</span> A item.</li>`.
|
|
68
|
+
- When individual list item numbers jump, the plugin sets the native `value` attribute on the `li` element for both standard and custom markers.
|
|
69
|
+
|
|
70
|
+
### Structures
|
|
71
|
+
|
|
72
|
+
- Marker type detection is deterministic: gather all markers at a nesting level, match them against the canonical definitions, keep the type that explains the most items while preserving numeric continuity, and use the order in `listTypes.json` only as a final tiebreaker.
|
|
73
|
+
- Flattening: A pattern like `- 1.` is represented by the default `ul > li > ol` nesting structure in markdown-it, but this plugin simplifies it to a single `ol` by default to match the representation of other markers.
|
|
74
|
+
|
|
75
|
+
Note: For custom marker lists (those rendered with `role="list"`) the plugin assumes you will hide the native marker via CSS (for example `ol[role="list"] { list-style: none; }`). The `hasListStyleNone` option can be enabled to add `style="list-style: none;"` directly to generated `<ol>` elements.
|
|
76
|
+
|
|
77
|
+
### Behavior customization
|
|
78
|
+
|
|
79
|
+
You can customize the conversion using options.
|
|
80
|
+
|
|
81
|
+
- `unremoveUlNest` (boolean) — If `true`, preserve the original `ul > li > ol` nesting instead of flattening into `ol > li`.
|
|
82
|
+
- `alwaysMarkerSpan` (boolean) — Wrap markers in a `<span>` (class `markerSpanClass`, default: `li-num`). When markers are rendered as custom markers the plugin emits `role="list"` and does not set a `type` attribute on the `<ol>`.
|
|
83
|
+
- `useCounterStyle` (boolean) — When `true` the plugin suppresses generated marker spans (no `span.li-num`) and prefers native `start`/`value` attributes so you can style lists with CSS `@counter-style`. Note that in this case the marker will not be selectable, as browsers currently do not support CSS `user-select` on markers.
|
|
84
|
+
- `markerSpanClass` (string) — Specify the class name applied to the marker `<span>` (default: `li-num`).
|
|
85
|
+
- `hasListStyleNone` (boolean) — When the plugin emits `role="list"`, also add `style="list-style: none;"` to the `<ol>`.
|
|
86
|
+
- `omitMarkerMetadata` (boolean) — If `true`, omit the `data-marker-prefix` / `data-marker-suffix` attributes.
|
|
87
|
+
- `addMarkerStyleToClass` (boolean) — When `true`, append suffix-style information to the generated class name (e.g. `ol-decimal-with-round-round`). When `false` (default) the class stays as `ol-decimal`.
|
|
88
|
+
|
|
89
|
+
## Description lists conversion behavior
|
|
90
|
+
|
|
91
|
+
When the `descriptionList` option is enabled the plugin converts specially formatted bullet lists into HTML description lists (`<dl>`).
|
|
92
|
+
|
|
93
|
+
- Each list item must start with a `**Term**` line.
|
|
94
|
+
- If the Term line is not separated from the description by a blank line, then the Term line must end with two ASCII spaces (a Markdown line-break) or a backslash `\` to indicate the description follows.
|
|
95
|
+
|
|
96
|
+
In the conversion the `**Term**` line becomes a `<dt>` and the subsequent lines become the corresponding `<dd>`.
|
|
97
|
+
|
|
98
|
+
Note: Currently the content inside `<dd>` elements is always wrapped in `<p>` elements.
|
|
99
|
+
|
|
100
|
+
### Description list options
|
|
101
|
+
|
|
102
|
+
- `descriptionList` (boolean) — Enable conversion of `**Term**` list patterns into `<dl>` description lists.
|
|
103
|
+
- `descriptionListWithDiv` (boolean) — Wrap `<dt>/<dd>` pairs in a `<div>` when enabled.
|
|
104
|
+
- `descriptionListDivClass` (string) — Class applied to the wrapper `<div>` when `descriptionListWithDiv` is enabled (empty string disables the class).
|
|
105
|
+
|
|
106
|
+
## Examples: Ordered Lists
|
|
107
|
+
|
|
108
|
+
HTML standard marker conversion (markers that set the `type` attribute). The plugin also accepts `)` as a separator in place of `.`:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
[Markdown]
|
|
112
|
+
- A) First
|
|
113
|
+
- B) Second
|
|
114
|
+
- C) Third
|
|
115
|
+
|
|
116
|
+
[HTML]
|
|
117
|
+
<ol type="A" class="ol-upper-latin" data-marker-suffix=")">
|
|
118
|
+
<li>First</li>
|
|
119
|
+
<li>Second</li>
|
|
120
|
+
<li>Third</li>
|
|
121
|
+
</ol>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Custom marker conversion example:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
[Markdown]
|
|
128
|
+
- ① First
|
|
129
|
+
- ② Second
|
|
130
|
+
- ③ Third
|
|
131
|
+
|
|
132
|
+
[HTML]
|
|
133
|
+
<ol role="list" class="ol-filled-circled-decimal">
|
|
134
|
+
<li><span class="li-num" aria-hidden="true">①</span> First</li>
|
|
135
|
+
<li><span class="li-num" aria-hidden="true">②</span> Second</li>
|
|
136
|
+
<li><span class="li-num" aria-hidden="true">③</span> Third</li>
|
|
137
|
+
</ol>
|
|
138
|
+
<!-- In this case the stylesheet is expected to hide the native marker, e.g. ol[role="list"] { list-style: none; } -->
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Standard numeric markdown is converted as usual:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
[Markdown]
|
|
145
|
+
1. First item
|
|
146
|
+
2. Second item
|
|
147
|
+
|
|
148
|
+
[HTML]
|
|
149
|
+
<ol type="1" class="ol-decimal" data-marker-suffix=".">
|
|
150
|
+
<li>First item</li>
|
|
151
|
+
<li>Second item</li>
|
|
152
|
+
</ol>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
For lists written in the `- 1.` style this plugin flattens the default `ul > li > ol` nesting into a single `ol > li` structure to match other conversion patterns:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
[Markdown]
|
|
159
|
+
- 1. First item
|
|
160
|
+
- 2. Second item
|
|
161
|
+
- 3. Third item
|
|
162
|
+
|
|
163
|
+
[HTML]
|
|
164
|
+
<ol type="1" class="ol-decimal" data-marker-suffix=".">
|
|
165
|
+
<li>First item</li>
|
|
166
|
+
<li>Second item</li>
|
|
167
|
+
<li>Third item</li>
|
|
168
|
+
</ol>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Nested lists are supported as well:
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
[Markdown]
|
|
175
|
+
- ② First item
|
|
176
|
+
- i. Subitem A
|
|
177
|
+
- iii. Subitem C
|
|
178
|
+
- ④ Second item
|
|
179
|
+
|
|
180
|
+
[HTML]
|
|
181
|
+
<ol role="list" start="2" class="ol-circled-decimal">
|
|
182
|
+
<li><span class="li-num" aria-hidden="true">②</span> First item
|
|
183
|
+
<ol type="i" class="ol-lower-roman" data-marker-suffix=".">
|
|
184
|
+
<li>Subitem A</li>
|
|
185
|
+
<li value="3">Subitem C</li>
|
|
186
|
+
</ol>
|
|
187
|
+
</li>
|
|
188
|
+
<li value="4"><span class="li-num" aria-hidden="true">④</span> Second item</li>
|
|
189
|
+
</ol>
|
|
190
|
+
|
|
191
|
+
[Markdown]
|
|
192
|
+
- 1. Parent item
|
|
193
|
+
- a. Child item A
|
|
194
|
+
- b. Child item B
|
|
195
|
+
- 2. Another parent
|
|
196
|
+
|
|
197
|
+
[HTML]
|
|
198
|
+
<ol type="1" class="ol-decimal" data-marker-suffix=".">
|
|
199
|
+
<li>Parent item
|
|
200
|
+
<ol type="a" class="ol-lower-latin" data-marker-suffix=".">
|
|
201
|
+
<li>Child item A</li>
|
|
202
|
+
<li>Child item B</li>
|
|
203
|
+
</ol>
|
|
204
|
+
</li>
|
|
205
|
+
<li>Another parent</li>
|
|
206
|
+
</ol>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The plugin also handles loose lists (lists where items are separated by blank lines):
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
[Markdown]
|
|
213
|
+
- a. First item
|
|
214
|
+
|
|
215
|
+
- b. Second item
|
|
216
|
+
|
|
217
|
+
[HTML]
|
|
218
|
+
<ol type="a" class="ol-lower-latin" data-marker-suffix=".">
|
|
219
|
+
<li>
|
|
220
|
+
<p>First item</p>
|
|
221
|
+
</li>
|
|
222
|
+
<li>
|
|
223
|
+
<p>Second item</p>
|
|
224
|
+
</li>
|
|
225
|
+
</ol>
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
[Markdown]
|
|
229
|
+
- a. First item first paragraph.
|
|
230
|
+
|
|
231
|
+
First item second paragraph.
|
|
232
|
+
|
|
233
|
+
- b. Second item first paragraph.
|
|
234
|
+
|
|
235
|
+
Second item second paragraph.
|
|
236
|
+
|
|
237
|
+
[HTML]
|
|
238
|
+
<ol type="a" class="ol-lower-latin" data-marker-suffix=".">
|
|
239
|
+
<li>
|
|
240
|
+
<p>First item first paragraph.</p>
|
|
241
|
+
<p>First item second paragraph.</p>
|
|
242
|
+
</li>
|
|
243
|
+
<li>
|
|
244
|
+
<p>Second item first paragraph.</p>
|
|
245
|
+
<p>Second item second paragraph.</p>
|
|
246
|
+
</li>
|
|
247
|
+
</ol>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Examples: Description Lists
|
|
251
|
+
|
|
252
|
+
When description lists are enabled the plugin can convert the following patterns:
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
[Markdown]
|
|
256
|
+
- **Term 1**
|
|
257
|
+
Description text for term 1
|
|
258
|
+
- **Term 2**
|
|
259
|
+
Description text for term 2
|
|
260
|
+
|
|
261
|
+
[HTML]
|
|
262
|
+
<dl>
|
|
263
|
+
<dt>Term 1</dt>
|
|
264
|
+
<dd>
|
|
265
|
+
<p>Description text for term 1</p>
|
|
266
|
+
</dd>
|
|
267
|
+
<dt>Term 2</dt>
|
|
268
|
+
<dd>
|
|
269
|
+
<p>Description text for term 2</p>
|
|
270
|
+
</dd>
|
|
271
|
+
</dl>
|
|
272
|
+
|
|
273
|
+
[Markdown]
|
|
274
|
+
- **Term 1**\
|
|
275
|
+
Description text for term 1
|
|
276
|
+
- **Term 2**\
|
|
277
|
+
Description text for term 2
|
|
278
|
+
|
|
279
|
+
[HTML]
|
|
280
|
+
<dl>
|
|
281
|
+
<dt>Term 1</dt>
|
|
282
|
+
<dd>
|
|
283
|
+
<p>Description text for term 1</p>
|
|
284
|
+
</dd>
|
|
285
|
+
<dt>Term 2</dt>
|
|
286
|
+
<dd>
|
|
287
|
+
<p>Description text for term 2</p>
|
|
288
|
+
</dd>
|
|
289
|
+
</dl>
|
|
290
|
+
|
|
291
|
+
[Markdown]
|
|
292
|
+
- **Term 1**
|
|
293
|
+
|
|
294
|
+
Description 1, line 1.
|
|
295
|
+
|
|
296
|
+
Description 1, line 2.
|
|
297
|
+
|
|
298
|
+
- **Term 2**
|
|
299
|
+
|
|
300
|
+
Description 2, line 1.
|
|
301
|
+
|
|
302
|
+
Description 2, line 2.
|
|
303
|
+
|
|
304
|
+
[HTML]
|
|
305
|
+
<dl>
|
|
306
|
+
<dt>Term 1</dt>
|
|
307
|
+
<dd>
|
|
308
|
+
<p>Description 1, line 1.</p>
|
|
309
|
+
<p>Description 1, line 2.</p>
|
|
310
|
+
</dd>
|
|
311
|
+
<dt>Term 2</dt>
|
|
312
|
+
<dd>
|
|
313
|
+
<p>Description 2, line 1.</p>
|
|
314
|
+
<p>Description 2, line 2.</p>
|
|
315
|
+
</dd>
|
|
316
|
+
</dl>
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## Install
|
|
320
|
+
|
|
321
|
+
```pwsh
|
|
322
|
+
npm install @peaceroad/markdown-it-numbering-ul-regarded-as-ol
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Basic usage
|
|
326
|
+
|
|
327
|
+
```js
|
|
328
|
+
import mdit from 'markdown-it'
|
|
329
|
+
import mditNumberingUl from '@peaceroad/markdown-it-numbering-ul-regarded-as-ol'
|
|
330
|
+
|
|
331
|
+
const md = new mdit()
|
|
332
|
+
md.use(mditNumberingUl)
|
|
333
|
+
|
|
334
|
+
const html = md.render(`- a. First\n- b. Second`)
|
|
335
|
+
console.log(html)
|
|
336
|
+
```
|