@peaceroad/markdown-it-table-ex 0.1.0 → 0.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peaceroad/markdown-it-table-ex",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "A markdown-it plugin. Add matrix and wrapper notation for table processing.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -11,8 +11,9 @@
11
11
  "author": "peaceroad <peaceroad@gmail.com>",
12
12
  "license": "MIT",
13
13
  "devDependencies": {
14
- "markdown-it-multimd-table": "^4.2.3",
15
- "@peaceroad/markdown-it-figure-with-p-caption": "^0.10.0",
16
- "markdown-it": "^14.1.0"
14
+ "@peaceroad/markdown-it-figure-with-p-caption": "^0.12.0",
15
+ "@peaceroad/markdown-it-strong-ja": "^0.4.2",
16
+ "markdown-it": "^14.1.0",
17
+ "markdown-it-multimd-table": "^4.2.3"
17
18
  }
18
19
  }
package/test/examples.txt CHANGED
@@ -362,19 +362,19 @@
362
362
  <table>
363
363
  <thead>
364
364
  <tr>
365
- <th scope="col"><strong>h</strong>h<strong>0</strong></th>
365
+ <th scope="col">h<strong>h</strong>0</th>
366
366
  <th scope="col">hh1</th>
367
367
  <th scope="col">hh2</th>
368
368
  </tr>
369
369
  </thead>
370
370
  <tbody>
371
371
  <tr>
372
- <td><strong>v</strong>h<strong>1</strong></td>
372
+ <th scope="row">v<strong>h</strong>1</th>
373
373
  <td>11</td>
374
374
  <td>12</td>
375
375
  </tr>
376
376
  <tr>
377
- <td><strong>vh2</strong></td>
377
+ <th scope="row">vh2</th>
378
378
  <td>21</td>
379
379
  <td>22</td>
380
380
  </tr>
@@ -385,25 +385,25 @@
385
385
  [Markdown]
386
386
  | **h**h**0** | hh1 | hh2 |
387
387
  | ------- | ---- | ---- |
388
- | **v**h**1**c**d** | 11 | 12 |
388
+ | **v<span>c</span>d** | 11 | 12 |
389
389
  | **vh2** | 21 | 22 |
390
390
  [HTML]
391
391
  <table>
392
392
  <thead>
393
393
  <tr>
394
- <th scope="col"><strong>h</strong>h<strong>0</strong></th>
394
+ <th scope="col">h<strong>h</strong>0</th>
395
395
  <th scope="col">hh1</th>
396
396
  <th scope="col">hh2</th>
397
397
  </tr>
398
398
  </thead>
399
399
  <tbody>
400
400
  <tr>
401
- <td><strong>v</strong>h<strong>1</strong>c<strong>d</strong></td>
401
+ <th scope="row">v<span>c</span>d</th>
402
402
  <td>11</td>
403
403
  <td>12</td>
404
404
  </tr>
405
405
  <tr>
406
- <td><strong>vh2</strong></td>
406
+ <th scope="row">vh2</th>
407
407
  <td>21</td>
408
408
  <td>22</td>
409
409
  </tr>
@@ -0,0 +1,380 @@
1
+ [Markdown]
2
+ | hh0 | hh1 | hh2 | hh1 | hh2 |
3
+ | --- | ---- | ---- | ---- | ---- |
4
+ | vh1 | 11 | 12 | 13 | 14 |
5
+ | vh2 | 21 | 22 | 23 | 24 |
6
+ [HTML]
7
+ <table>
8
+ <thead>
9
+ <tr>
10
+ <th scope="col">hh0</th>
11
+ <th scope="col">hh1</th>
12
+ <th scope="col">hh2</th>
13
+ <th scope="col">hh1</th>
14
+ <th scope="col">hh2</th>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+ <tr>
19
+ <td>vh1</td>
20
+ <td>11</td>
21
+ <td>12</td>
22
+ <td>13</td>
23
+ <td>14</td>
24
+ </tr>
25
+ <tr>
26
+ <td>vh2</td>
27
+ <td>21</td>
28
+ <td>22</td>
29
+ <td>23</td>
30
+ <td>24</td>
31
+ </tr>
32
+ </tbody>
33
+ </table>
34
+
35
+
36
+ [Markdown]
37
+ | hh0 | **group:** hh1 | **group:** hh2 | **group2:** hh1 | **group2:** hh2 |
38
+ | --- | ---- | ---- | ---- | ---- |
39
+ | vh1 | 11 | 12 | 13 | 14 |
40
+ | vh2 | 21 | 22 | 23 | 24 |
41
+ [HTML]
42
+ <table>
43
+ <colgroup>
44
+ <col>
45
+ <col span="2">
46
+ <col span="2">
47
+ </colgroup>
48
+ <thead>
49
+ <tr>
50
+ <th rowspan="2" scope="col">hh0</th>
51
+ <th colspan="2" scope="col">group</th>
52
+ <th colspan="2" scope="col">group2</th>
53
+ </tr>
54
+ <tr>
55
+ <th scope="col">hh1</th>
56
+ <th scope="col">hh2</th>
57
+ <th scope="col">hh1</th>
58
+ <th scope="col">hh2</th>
59
+ </tr>
60
+ </thead>
61
+ <tbody>
62
+ <tr>
63
+ <td>vh1</td>
64
+ <td>11</td>
65
+ <td>12</td>
66
+ <td>13</td>
67
+ <td>14</td>
68
+ </tr>
69
+ <tr>
70
+ <td>vh2</td>
71
+ <td>21</td>
72
+ <td>22</td>
73
+ <td>23</td>
74
+ <td>24</td>
75
+ </tr>
76
+ </tbody>
77
+ </table>
78
+
79
+
80
+ [Markdown]
81
+ | | **group:** hh1 | **group:** hh2 | hh1 | hh2 |
82
+ | --- | ---- | ---- | ---- | ---- |
83
+ | vh1 | 11 | 12 | 13 | 14 |
84
+ | vh2 | 21 | 22 | 23 | 24 |
85
+ [HTML]
86
+ <table>
87
+ <colgroup>
88
+ <col>
89
+ <col span="2">
90
+ <col>
91
+ <col>
92
+ </colgroup>
93
+ <thead>
94
+ <tr>
95
+ <th rowspan="2" scope="col"></th>
96
+ <th colspan="2" scope="col">group</th>
97
+ <th rowspan="2" scope="col">hh1</th>
98
+ <th rowspan="2" scope="col">hh2</th>
99
+ </tr>
100
+ <tr>
101
+ <th scope="col">hh1</th>
102
+ <th scope="col">hh2</th>
103
+ </tr>
104
+ </thead>
105
+ <tbody>
106
+ <tr>
107
+ <td>vh1</td>
108
+ <td>11</td>
109
+ <td>12</td>
110
+ <td>13</td>
111
+ <td>14</td>
112
+ </tr>
113
+ <tr>
114
+ <td>vh2</td>
115
+ <td>21</td>
116
+ <td>22</td>
117
+ <td>23</td>
118
+ <td>24</td>
119
+ </tr>
120
+ </tbody>
121
+ </table>
122
+
123
+
124
+ [Markdown]
125
+ | hh0 | **foods:** hh1 | **foods:** hh2 | **drinks:** hh1 | **drinks:** hh2 |
126
+ | --- | ---- | ---- | ---- | ---- |
127
+ | vh1 | 11 | 12 | 13 | 14 |
128
+ | vh2 | 21 | 22 | 23 | 24 |
129
+ [HTML]
130
+ <table>
131
+ <colgroup>
132
+ <col>
133
+ <col span="2">
134
+ <col span="2">
135
+ </colgroup>
136
+ <thead>
137
+ <tr>
138
+ <th rowspan="2" scope="col">hh0</th>
139
+ <th colspan="2" scope="col">foods</th>
140
+ <th colspan="2" scope="col">drinks</th>
141
+ </tr>
142
+ <tr>
143
+ <th scope="col">hh1</th>
144
+ <th scope="col">hh2</th>
145
+ <th scope="col">hh1</th>
146
+ <th scope="col">hh2</th>
147
+ </tr>
148
+ </thead>
149
+ <tbody>
150
+ <tr>
151
+ <td>vh1</td>
152
+ <td>11</td>
153
+ <td>12</td>
154
+ <td>13</td>
155
+ <td>14</td>
156
+ </tr>
157
+ <tr>
158
+ <td>vh2</td>
159
+ <td>21</td>
160
+ <td>22</td>
161
+ <td>23</td>
162
+ <td>24</td>
163
+ </tr>
164
+ </tbody>
165
+ </table>
166
+
167
+
168
+ [Markdown]
169
+ | **hh0** | **group:** hh1 | **group:** hh2 | **group2:** hh1 | **group2:** hh2 |
170
+ | --- | ---- | ---- | ---- | ---- |
171
+ | **vh1** | 11 | 12 | 13 | 14 |
172
+ | **vh2** | 21 | 22 | 23 | 24 |
173
+ [HTML]
174
+ <table>
175
+ <colgroup>
176
+ <col>
177
+ <col span="2">
178
+ <col span="2">
179
+ </colgroup>
180
+ <thead>
181
+ <tr>
182
+ <th rowspan="2" scope="col">hh0</th>
183
+ <th colspan="2" scope="col">group</th>
184
+ <th colspan="2" scope="col">group2</th>
185
+ </tr>
186
+ <tr>
187
+ <th scope="col">hh1</th>
188
+ <th scope="col">hh2</th>
189
+ <th scope="col">hh1</th>
190
+ <th scope="col">hh2</th>
191
+ </tr>
192
+ </thead>
193
+ <tbody>
194
+ <tr>
195
+ <th scope="row">vh1</th>
196
+ <td>11</td>
197
+ <td>12</td>
198
+ <td>13</td>
199
+ <td>14</td>
200
+ </tr>
201
+ <tr>
202
+ <th scope="row">vh2</th>
203
+ <td>21</td>
204
+ <td>22</td>
205
+ <td>23</td>
206
+ <td>24</td>
207
+ </tr>
208
+ </tbody>
209
+ </table>
210
+
211
+
212
+ [Markdown]
213
+ | | **group:** hh1 | **group:** hh2 | **group2:** hh1 | **group2:** hh2 |
214
+ | --- | ---- | ---- | ---- | ---- |
215
+ | **vh1** | 11 | 12 | 13 | 14 |
216
+ | **vh2** | 21 | 22 | 23 | 24 |
217
+ [HTML]
218
+ <table>
219
+ <colgroup>
220
+ <col>
221
+ <col span="2">
222
+ <col span="2">
223
+ </colgroup>
224
+ <thead>
225
+ <tr>
226
+ <th rowspan="2" scope="col"></th>
227
+ <th colspan="2" scope="col">group</th>
228
+ <th colspan="2" scope="col">group2</th>
229
+ </tr>
230
+ <tr>
231
+ <th scope="col">hh1</th>
232
+ <th scope="col">hh2</th>
233
+ <th scope="col">hh1</th>
234
+ <th scope="col">hh2</th>
235
+ </tr>
236
+ </thead>
237
+ <tbody>
238
+ <tr>
239
+ <th scope="row">vh1</th>
240
+ <td>11</td>
241
+ <td>12</td>
242
+ <td>13</td>
243
+ <td>14</td>
244
+ </tr>
245
+ <tr>
246
+ <th scope="row">vh2</th>
247
+ <td>21</td>
248
+ <td>22</td>
249
+ <td>23</td>
250
+ <td>24</td>
251
+ </tr>
252
+ </tbody>
253
+ </table>
254
+
255
+
256
+ [Markdown]
257
+ | hh0 | **group:** hh1 | **group:** hh2 | **group:** hh3 | **group2:** hh1 | **group2:** hh2 |
258
+ | --- | ---- | ---- | ---- | ---- | ---- |
259
+ | vh1 | 11 | 12 | 13 | 14 | 15 |
260
+ | vh2 | 21 | 22 | 23 | 24 | 25 |
261
+ [HTML]
262
+ <table>
263
+ <colgroup>
264
+ <col>
265
+ <col span="3">
266
+ <col span="2">
267
+ </colgroup>
268
+ <thead>
269
+ <tr>
270
+ <th rowspan="2" scope="col">hh0</th>
271
+ <th colspan="3" scope="col">group</th>
272
+ <th colspan="2" scope="col">group2</th>
273
+ </tr>
274
+ <tr>
275
+ <th scope="col">hh1</th>
276
+ <th scope="col">hh2</th>
277
+ <th scope="col">hh3</th>
278
+ <th scope="col">hh1</th>
279
+ <th scope="col">hh2</th>
280
+ </tr>
281
+ </thead>
282
+ <tbody>
283
+ <tr>
284
+ <td>vh1</td>
285
+ <td>11</td>
286
+ <td>12</td>
287
+ <td>13</td>
288
+ <td>14</td>
289
+ <td>15</td>
290
+ </tr>
291
+ <tr>
292
+ <td>vh2</td>
293
+ <td>21</td>
294
+ <td>22</td>
295
+ <td>23</td>
296
+ <td>24</td>
297
+ <td>25</td>
298
+ </tr>
299
+ </tbody>
300
+ </table>
301
+
302
+
303
+ [Markdown]
304
+ | | **group:** hh1 | group: hh2 | hh1 | hh2 |
305
+ | --- | ---- | ---- | ---- | ---- |
306
+ | vh1 | 11 | 12 | 13 | 14 |
307
+ | vh2 | 21 | 22 | 23 | 24 |
308
+ [HTML]
309
+ <table>
310
+ <thead>
311
+ <tr>
312
+ <th scope="col"></th>
313
+ <th scope="col"><strong>group:</strong> hh1</th>
314
+ <th scope="col">group: hh2</th>
315
+ <th scope="col">hh1</th>
316
+ <th scope="col">hh2</th>
317
+ </tr>
318
+ </thead>
319
+ <tbody>
320
+ <tr>
321
+ <td>vh1</td>
322
+ <td>11</td>
323
+ <td>12</td>
324
+ <td>13</td>
325
+ <td>14</td>
326
+ </tr>
327
+ <tr>
328
+ <td>vh2</td>
329
+ <td>21</td>
330
+ <td>22</td>
331
+ <td>23</td>
332
+ <td>24</td>
333
+ </tr>
334
+ </tbody>
335
+ </table>
336
+
337
+
338
+ [Markdown]
339
+ | hh0 | **料理:**hh1 | **料理:**hh2 | **飲み物:**hh1 | **飲み物:**hh2 |
340
+ | --- | ---- | ---- | ---- | ---- |
341
+ | vh1 | 11 | 12 | 13 | 14 |
342
+ | vh2 | 21 | 22 | 23 | 24 |
343
+ [HTML]
344
+ <table>
345
+ <colgroup>
346
+ <col>
347
+ <col span="2">
348
+ <col span="2">
349
+ </colgroup>
350
+ <thead>
351
+ <tr>
352
+ <th rowspan="2" scope="col">hh0</th>
353
+ <th colspan="2" scope="col">料理</th>
354
+ <th colspan="2" scope="col">飲み物</th>
355
+ </tr>
356
+ <tr>
357
+ <th scope="col">hh1</th>
358
+ <th scope="col">hh2</th>
359
+ <th scope="col">hh1</th>
360
+ <th scope="col">hh2</th>
361
+ </tr>
362
+ </thead>
363
+ <tbody>
364
+ <tr>
365
+ <td>vh1</td>
366
+ <td>11</td>
367
+ <td>12</td>
368
+ <td>13</td>
369
+ <td>14</td>
370
+ </tr>
371
+ <tr>
372
+ <td>vh2</td>
373
+ <td>21</td>
374
+ <td>22</td>
375
+ <td>23</td>
376
+ <td>24</td>
377
+ </tr>
378
+ </tbody>
379
+ </table>
380
+
@@ -0,0 +1,88 @@
1
+ [Markdown]
2
+ | hh0 | foods: hh1 | foods: hh2 | drinks: hh1 | drinks: hh2 |
3
+ | --- | ---- | ---- | ---- | ---- |
4
+ | vh1 | 11 | 12 | 13 | 14 |
5
+ | vh2 | 21 | 22 | 23 | 24 |
6
+ [HTML]
7
+ <table>
8
+ <colgroup>
9
+ <col>
10
+ <col span="2">
11
+ <col span="2">
12
+ </colgroup>
13
+ <thead>
14
+ <tr>
15
+ <th rowspan="2" scope="col">hh0</th>
16
+ <th colspan="2" scope="col">foods</th>
17
+ <th colspan="2" scope="col">drinks</th>
18
+ </tr>
19
+ <tr>
20
+ <th scope="col">hh1</th>
21
+ <th scope="col">hh2</th>
22
+ <th scope="col">hh1</th>
23
+ <th scope="col">hh2</th>
24
+ </tr>
25
+ </thead>
26
+ <tbody>
27
+ <tr>
28
+ <td>vh1</td>
29
+ <td>11</td>
30
+ <td>12</td>
31
+ <td>13</td>
32
+ <td>14</td>
33
+ </tr>
34
+ <tr>
35
+ <td>vh2</td>
36
+ <td>21</td>
37
+ <td>22</td>
38
+ <td>23</td>
39
+ <td>24</td>
40
+ </tr>
41
+ </tbody>
42
+ </table>
43
+
44
+
45
+
46
+ [Markdown]
47
+ | hh0 | 料理:hh1 | 料理:hh2 | 飲み物:hh1 | 飲み物:hh2 |
48
+ | --- | ---- | ---- | ---- | ---- |
49
+ | vh1 | 11 | 12 | 13 | 14 |
50
+ | vh2 | 21 | 22 | 23 | 24 |
51
+ [HTML]
52
+ <table>
53
+ <colgroup>
54
+ <col>
55
+ <col span="2">
56
+ <col span="2">
57
+ </colgroup>
58
+ <thead>
59
+ <tr>
60
+ <th rowspan="2" scope="col">hh0</th>
61
+ <th colspan="2" scope="col">料理</th>
62
+ <th colspan="2" scope="col">飲み物</th>
63
+ </tr>
64
+ <tr>
65
+ <th scope="col">hh1</th>
66
+ <th scope="col">hh2</th>
67
+ <th scope="col">hh1</th>
68
+ <th scope="col">hh2</th>
69
+ </tr>
70
+ </thead>
71
+ <tbody>
72
+ <tr>
73
+ <td>vh1</td>
74
+ <td>11</td>
75
+ <td>12</td>
76
+ <td>13</td>
77
+ <td>14</td>
78
+ </tr>
79
+ <tr>
80
+ <td>vh2</td>
81
+ <td>21</td>
82
+ <td>22</td>
83
+ <td>23</td>
84
+ <td>24</td>
85
+ </tr>
86
+ </tbody>
87
+ </table>
88
+
package/test/test.js CHANGED
@@ -4,6 +4,7 @@ import path from 'path'
4
4
  import mdit from 'markdown-it'
5
5
  import mditFigureWithPCaption from '@peaceroad/markdown-it-figure-with-p-caption'
6
6
  import mditMultimdTable from 'markdown-it-multimd-table'
7
+ import mditStrongJa from '@peaceroad/markdown-it-strong-ja'
7
8
 
8
9
  import mditTableEx from '../index.js'
9
10
 
@@ -11,7 +12,7 @@ const md = mdit({ html: true }).use(mditMultimdTable, {
11
12
  headerless: true,
12
13
  multiline: true,
13
14
  rowspan: true,
14
- }).use(mditTableEx)
15
+ }).use(mditTableEx).use(mditStrongJa)
15
16
  const mdWrapper = mdit({ html: true }).use(mditMultimdTable, {
16
17
  headerless: true,
17
18
  multiline: true,
@@ -22,6 +23,20 @@ const mdWrapperWithCaption = mdit({ html: true }).use(mditFigureWithPCaption).us
22
23
  multiline: true,
23
24
  rowspan: true,
24
25
  }).use(mditTableEx, { wrapper: true })
26
+ const mdColgruop = mdit({ html: true }).use(mditMultimdTable, {
27
+ headerless: true,
28
+ multiline: true,
29
+ rowspan: true,
30
+ }).use(mditTableEx, { colgroup: true })
31
+
32
+ const mdColgruopWithNoAsterisk = mdit({ html: true }).use(mditMultimdTable, {
33
+ headerless: true,
34
+ multiline: true,
35
+ rowspan: true,
36
+ }).use(mditTableEx, {
37
+ colgroup: true,
38
+ colgroupWithNoAsterisk: true,
39
+ })
25
40
 
26
41
  let __dirname = path.dirname(new URL(import.meta.url).pathname)
27
42
  const isWindows = (process.platform === 'win32')
@@ -33,6 +48,8 @@ const testData = {
33
48
  noOption: __dirname + path.sep + 'examples.txt',
34
49
  wrapper: __dirname + path.sep + 'examples_wrapper.txt',
35
50
  wrapperWithCaption: __dirname + path.sep + 'examples_wrapper_with_caption.txt',
51
+ colgroup: __dirname + path.sep + 'examples_colgroup.txt',
52
+ colgroupWithNoAsterisk: __dirname + path.sep + 'examples_colgroup_with_no_asterisk.txt',
36
53
  }
37
54
 
38
55
  const getTestData = (pat) => {
@@ -85,7 +102,7 @@ const runTest = (process, pat, pass, testId) => {
85
102
  while(n <= end) {
86
103
 
87
104
  if (!ms[n]
88
- // || n != 3
105
+ // || n != 3
89
106
  ) {
90
107
  n++
91
108
  continue
@@ -113,5 +130,7 @@ let pass = true
113
130
  pass = runTest(md, testData.noOption, pass)
114
131
  pass = runTest(mdWrapper, testData.wrapper, pass)
115
132
  pass = runTest(mdWrapperWithCaption, testData.wrapperWithCaption, pass)
133
+ pass = runTest(mdColgruop, testData.colgroup, pass)
134
+ pass = runTest(mdColgruopWithNoAsterisk, testData.colgroupWithNoAsterisk, pass)
116
135
 
117
136
  if (pass) console.log('Passed all test.')