@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/README.md +140 -13
- package/index.js +600 -63
- package/package.json +5 -4
- package/test/examples.txt +7 -7
- package/test/examples_colgroup.txt +380 -0
- package/test/examples_colgroup_with_no_asterisk.txt +88 -0
- package/test/test.js +21 -2
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@ A markdown-it plugin. For table processing, this plugin plus some extended synta
|
|
|
4
4
|
|
|
5
5
|
- matrix (enabled by default.)
|
|
6
6
|
- wrapper (option.)
|
|
7
|
+
- colgroup (option.)
|
|
7
8
|
|
|
8
9
|
Notice. This is intended to be used in conjunction with [markdown-it-multimd-table](https://github.com/redbug312/markdown-it-multimd-table) enabled the option: headerless, multiline, rowspan.
|
|
9
10
|
|
|
@@ -21,19 +22,6 @@ const md = mdit({ html: true }).use(mditMultimdTable, {
|
|
|
21
22
|
}).use(mditTableEx)
|
|
22
23
|
```
|
|
23
24
|
|
|
24
|
-
wrapper will be enabled as follows:
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
const md = mdit({ html: true }).use(mditMultimdTable, {
|
|
28
|
-
headerless: true,
|
|
29
|
-
multiline: true,
|
|
30
|
-
rowspan: true,
|
|
31
|
-
}).use(mditTableEx, {
|
|
32
|
-
wrapper: true,
|
|
33
|
-
})
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
25
|
## Extended notation
|
|
38
26
|
|
|
39
27
|
### matrix
|
|
@@ -100,6 +88,18 @@ If the leftmost cell of the table is surrounded by `**`, it will be converted to
|
|
|
100
88
|
|
|
101
89
|
### wrapper
|
|
102
90
|
|
|
91
|
+
colgroup will be enabled as follows:
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
const md = mdit({ html: true }).use(mditMultimdTable, {
|
|
95
|
+
headerless: true,
|
|
96
|
+
multiline: true,
|
|
97
|
+
rowspan: true,
|
|
98
|
+
}).use(mditTableEx, {
|
|
99
|
+
wrapper: true,
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
103
|
The table is wrapped in a div.table-wrapper element.
|
|
104
104
|
I think this is useful for moving the table left and right when the screen width is narrow.
|
|
105
105
|
|
|
@@ -134,3 +134,130 @@ I think this is useful for moving the table left and right when the screen width
|
|
|
134
134
|
</table>
|
|
135
135
|
</div>
|
|
136
136
|
```
|
|
137
|
+
|
|
138
|
+
## colgroup
|
|
139
|
+
|
|
140
|
+
colgroup will be enabled as follows:
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
const md = mdit({ html: true }).use(mditMultimdTable, {
|
|
144
|
+
headerless: true,
|
|
145
|
+
multiline: true,
|
|
146
|
+
rowspan: true,
|
|
147
|
+
}).use(mditTableEx, {
|
|
148
|
+
colgroup: true,
|
|
149
|
+
})
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
If you use grouped header notation in the table header (e.g., `**group:** hh1`), `<colgroup>` and `<thead>` with two tr lines will be generated. If there is no grouped header notation or only one, a normal single-row header is output and no colgroup is generated.
|
|
153
|
+
|
|
154
|
+
In other words, to determine the group, if there is `**` at the beginning of a cell followed by `:**` (`:**`), it becomes a candidate, and is determined by matching it with the adjacent cells.
|
|
155
|
+
|
|
156
|
+
**Examples**:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
[Markdown]
|
|
160
|
+
| hh0 | **group:** hh1 | **group:** hh2 | **group2:** hh1 | **group2:** hh2 |
|
|
161
|
+
| --- | ---- | ---- | ---- | ---- |
|
|
162
|
+
| vh1 | 11 | 12 | 13 | 14 |
|
|
163
|
+
| vh2 | 21 | 22 | 23 | 24 |
|
|
164
|
+
[HTML]
|
|
165
|
+
<table>
|
|
166
|
+
<colgroup>
|
|
167
|
+
<col>
|
|
168
|
+
<col span="2">
|
|
169
|
+
<col span="2">
|
|
170
|
+
</colgroup>
|
|
171
|
+
<thead>
|
|
172
|
+
<tr>
|
|
173
|
+
<th rowspan="2" scope="col">hh0</th>
|
|
174
|
+
<th colspan="2" scope="col">group</th>
|
|
175
|
+
<th colspan="2" scope="col">group2</th>
|
|
176
|
+
</tr>
|
|
177
|
+
<tr>
|
|
178
|
+
<th scope="col">hh1</th>
|
|
179
|
+
<th scope="col">hh2</th>
|
|
180
|
+
<th scope="col">hh1</th>
|
|
181
|
+
<th scope="col">hh2</th>
|
|
182
|
+
</tr>
|
|
183
|
+
</thead>
|
|
184
|
+
<tbody>
|
|
185
|
+
<tr>
|
|
186
|
+
<td>vh1</td>
|
|
187
|
+
<td>11</td>
|
|
188
|
+
<td>12</td>
|
|
189
|
+
<td>13</td>
|
|
190
|
+
<td>14</td>
|
|
191
|
+
</tr>
|
|
192
|
+
<tr>
|
|
193
|
+
<td>vh2</td>
|
|
194
|
+
<td>21</td>
|
|
195
|
+
<td>22</td>
|
|
196
|
+
<td>23</td>
|
|
197
|
+
<td>24</td>
|
|
198
|
+
</tr>
|
|
199
|
+
</tbody>
|
|
200
|
+
</table>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### colgroup with no asterisk
|
|
204
|
+
|
|
205
|
+
Do you find it troublesome to write `**`? You can omit it by adding more options.
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
const md = mdit({ html: true }).use(mditMultimdTable, {
|
|
209
|
+
headerless: true,
|
|
210
|
+
multiline: true,
|
|
211
|
+
rowspan: true,
|
|
212
|
+
}).use(mditTableEx, {
|
|
213
|
+
colgroup: true,
|
|
214
|
+
colgroupWithNoAsterisk: true,
|
|
215
|
+
})
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
In this case, if you use a half-width `:`, you need to follow it with one or more half-width spaces. If you use a full-width `:`, you don't need to follow it with a space.
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
[Markdown]
|
|
222
|
+
| hh0 | foods: hh1 | foods: hh2 | drinks: hh1 | drinks: hh2 |
|
|
223
|
+
| --- | ---- | ---- | ---- | ---- |
|
|
224
|
+
| vh1 | 11 | 12 | 13 | 14 |
|
|
225
|
+
| vh2 | 21 | 22 | 23 | 24 |
|
|
226
|
+
[HTML]
|
|
227
|
+
<table>
|
|
228
|
+
<colgroup>
|
|
229
|
+
<col>
|
|
230
|
+
<col span="2">
|
|
231
|
+
<col span="2">
|
|
232
|
+
</colgroup>
|
|
233
|
+
<thead>
|
|
234
|
+
<tr>
|
|
235
|
+
<th rowspan="2" scope="col">hh0</th>
|
|
236
|
+
<th colspan="2" scope="col">foods</th>
|
|
237
|
+
<th colspan="2" scope="col">drinks</th>
|
|
238
|
+
</tr>
|
|
239
|
+
<tr>
|
|
240
|
+
<th scope="col">hh1</th>
|
|
241
|
+
<th scope="col">hh2</th>
|
|
242
|
+
<th scope="col">hh1</th>
|
|
243
|
+
<th scope="col">hh2</th>
|
|
244
|
+
</tr>
|
|
245
|
+
</thead>
|
|
246
|
+
<tbody>
|
|
247
|
+
<tr>
|
|
248
|
+
<td>vh1</td>
|
|
249
|
+
<td>11</td>
|
|
250
|
+
<td>12</td>
|
|
251
|
+
<td>13</td>
|
|
252
|
+
<td>14</td>
|
|
253
|
+
</tr>
|
|
254
|
+
<tr>
|
|
255
|
+
<td>vh2</td>
|
|
256
|
+
<td>21</td>
|
|
257
|
+
<td>22</td>
|
|
258
|
+
<td>23</td>
|
|
259
|
+
<td>24</td>
|
|
260
|
+
</tr>
|
|
261
|
+
</tbody>
|
|
262
|
+
</table>
|
|
263
|
+
```
|