@peaceroad/markdown-it-table-ex 0.2.0 → 0.3.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.
@@ -1,141 +0,0 @@
1
- [Markdown]
2
- Table 1. A caption.
3
-
4
- | hh0 | hh1 | hh2 |
5
- | --- | ---- | ---- |
6
- | vh1 | 11 | 12 |
7
- | vh2 | 21 | 22 |
8
- [HTML]
9
- <figure class="f-table">
10
- <figcaption><span class="f-table-label">Table 1<span class="f-table-label-joint">.</span></span> A caption.</figcaption>
11
- <div class="table-wrapper">
12
- <table>
13
- <thead>
14
- <tr>
15
- <th scope="col">hh0</th>
16
- <th scope="col">hh1</th>
17
- <th scope="col">hh2</th>
18
- </tr>
19
- </thead>
20
- <tbody>
21
- <tr>
22
- <td>vh1</td>
23
- <td>11</td>
24
- <td>12</td>
25
- </tr>
26
- <tr>
27
- <td>vh2</td>
28
- <td>21</td>
29
- <td>22</td>
30
- </tr>
31
- </tbody>
32
- </table>
33
- </div>
34
- </figure>
35
-
36
-
37
- [Markdown]
38
- | hh0 | hh1 | hh2 |
39
- | --- | ---- | ---- |
40
- | vh1 | 11 | 12 |
41
- | vh2 | 21 | 22 |
42
-
43
- Table 1. A caption.
44
- [HTML]
45
- <figure class="f-table">
46
- <div class="table-wrapper">
47
- <table>
48
- <thead>
49
- <tr>
50
- <th scope="col">hh0</th>
51
- <th scope="col">hh1</th>
52
- <th scope="col">hh2</th>
53
- </tr>
54
- </thead>
55
- <tbody>
56
- <tr>
57
- <td>vh1</td>
58
- <td>11</td>
59
- <td>12</td>
60
- </tr>
61
- <tr>
62
- <td>vh2</td>
63
- <td>21</td>
64
- <td>22</td>
65
- </tr>
66
- </tbody>
67
- </table>
68
- </div>
69
- <figcaption><span class="f-table-label">Table 1<span class="f-table-label-joint">.</span></span> A caption.</figcaption>
70
- </figure>
71
-
72
-
73
- [Markdown]
74
- | **hh0** | hh1 | hh2 |
75
- | ------- | ---- | ---- |
76
- | **vh1** | 11 | 12 |
77
- | **vh2** | 21 | 22 |
78
-
79
- Table 1. A caption.
80
-
81
- Table 2. A caption.
82
-
83
- | **hh0** | hh1 | hh2 |
84
- | ------- | ---- | ---- |
85
- | **vh1** | 11 | 12 |
86
- | **vh2** | 21 | 22 |
87
-
88
-
89
- [HTML]
90
- <figure class="f-table">
91
- <div class="table-wrapper">
92
- <table>
93
- <thead>
94
- <tr>
95
- <th scope="col">hh0</th>
96
- <th scope="col">hh1</th>
97
- <th scope="col">hh2</th>
98
- </tr>
99
- </thead>
100
- <tbody>
101
- <tr>
102
- <th scope="row">vh1</th>
103
- <td>11</td>
104
- <td>12</td>
105
- </tr>
106
- <tr>
107
- <th scope="row">vh2</th>
108
- <td>21</td>
109
- <td>22</td>
110
- </tr>
111
- </tbody>
112
- </table>
113
- </div>
114
- <figcaption><span class="f-table-label">Table 1<span class="f-table-label-joint">.</span></span> A caption.</figcaption>
115
- </figure>
116
- <figure class="f-table">
117
- <figcaption><span class="f-table-label">Table 2<span class="f-table-label-joint">.</span></span> A caption.</figcaption>
118
- <div class="table-wrapper">
119
- <table>
120
- <thead>
121
- <tr>
122
- <th scope="col">hh0</th>
123
- <th scope="col">hh1</th>
124
- <th scope="col">hh2</th>
125
- </tr>
126
- </thead>
127
- <tbody>
128
- <tr>
129
- <th scope="row">vh1</th>
130
- <td>11</td>
131
- <td>12</td>
132
- </tr>
133
- <tr>
134
- <th scope="row">vh2</th>
135
- <td>21</td>
136
- <td>22</td>
137
- </tr>
138
- </tbody>
139
- </table>
140
- </div>
141
- </figure>
package/test/test.js DELETED
@@ -1,136 +0,0 @@
1
- import assert from 'assert'
2
- import fs from 'fs'
3
- import path from 'path'
4
- import mdit from 'markdown-it'
5
- import mditFigureWithPCaption from '@peaceroad/markdown-it-figure-with-p-caption'
6
- import mditMultimdTable from 'markdown-it-multimd-table'
7
- import mditStrongJa from '@peaceroad/markdown-it-strong-ja'
8
-
9
- import mditTableEx from '../index.js'
10
-
11
- const md = mdit({ html: true }).use(mditMultimdTable, {
12
- headerless: true,
13
- multiline: true,
14
- rowspan: true,
15
- }).use(mditTableEx).use(mditStrongJa)
16
- const mdWrapper = mdit({ html: true }).use(mditMultimdTable, {
17
- headerless: true,
18
- multiline: true,
19
- rowspan: true,
20
- }).use(mditTableEx, { wrapper: true })
21
- const mdWrapperWithCaption = mdit({ html: true }).use(mditFigureWithPCaption).use(mditMultimdTable, {
22
- headerless: true,
23
- multiline: true,
24
- rowspan: true,
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
- })
40
-
41
- let __dirname = path.dirname(new URL(import.meta.url).pathname)
42
- const isWindows = (process.platform === 'win32')
43
- if (isWindows) {
44
- __dirname = __dirname.replace(/^\/+/, '').replace(/\//g, '\\')
45
- }
46
-
47
- const testData = {
48
- noOption: __dirname + path.sep + 'examples.txt',
49
- wrapper: __dirname + path.sep + 'examples_wrapper.txt',
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',
53
- }
54
-
55
- const getTestData = (pat) => {
56
- let ms = [];
57
- if(!fs.existsSync(pat)) {
58
- console.log('No exist: ' + pat)
59
- return ms
60
- }
61
- const exampleCont = fs.readFileSync(pat, 'utf-8').trim();
62
-
63
- let ms0 = exampleCont.split(/\n*\[Markdown\]\n/);
64
- let n = 1;
65
- while(n < ms0.length) {
66
- let mhs = ms0[n].split(/\n+\[HTML[^\]]*?\]\n/);
67
- let i = 1;
68
- while (i < 2) {
69
- if (mhs[i] === undefined) {
70
- mhs[i] = '';
71
- } else {
72
- mhs[i] = mhs[i].replace(/$/,'\n');
73
- }
74
- i++;
75
- }
76
- ms[n] = {
77
- "markdown": mhs[0],
78
- "html": mhs[1],
79
- };
80
- n++;
81
- }
82
- return ms
83
- }
84
-
85
- const runTest = (process, pat, pass, testId) => {
86
- console.log('===========================================================')
87
- console.log(pat)
88
- let ms = getTestData(pat)
89
- if (ms.length === 0) return
90
- let n = 1;
91
- let end = ms.length - 1
92
- if(testId) {
93
- if (testId[0]) n = testId[0]
94
- if (testId[1]) {
95
- if (ms.length >= testId[1]) {
96
- end = testId[1]
97
- }
98
- }
99
- }
100
- //console.log(n, end)
101
-
102
- while(n <= end) {
103
-
104
- if (!ms[n]
105
- // || n != 3
106
- ) {
107
- n++
108
- continue
109
- }
110
-
111
- const m = ms[n].markdown;
112
- const h = process.render(m)
113
- console.log('Test: ' + n + ' >>>');
114
- try {
115
- assert.strictEqual(h, ms[n].html);
116
- } catch(e) {
117
- pass = false
118
- //console.log('Test: ' + n + ' >>>');
119
- //console.log(opt);
120
- console.log(ms[n].markdown);
121
- console.log('incorrect:');
122
- console.log('H: ' + h +'C: ' + ms[n].html);
123
- }
124
- n++;
125
- }
126
- return pass
127
- }
128
-
129
- let pass = true
130
- pass = runTest(md, testData.noOption, pass)
131
- pass = runTest(mdWrapper, testData.wrapper, pass)
132
- pass = runTest(mdWrapperWithCaption, testData.wrapperWithCaption, pass)
133
- pass = runTest(mdColgruop, testData.colgroup, pass)
134
- pass = runTest(mdColgruopWithNoAsterisk, testData.colgroupWithNoAsterisk, pass)
135
-
136
- if (pass) console.log('Passed all test.')