@peaceroad/markdown-it-table-ex 0.1.0 → 0.3.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 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,18 +22,9 @@ 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
- ```
25
+ ## StrongJa detection
35
26
 
27
+ When `@peaceroad/markdown-it-strong-ja` is registered, this plugin detects `**` markers by checking the inline rule named `strong_ja` and relies on inline tokens. If that rule is not present, it falls back to simple `**` string checks so matrix/colgroup still work without strongJa.
36
28
 
37
29
  ## Extended notation
38
30
 
@@ -100,6 +92,18 @@ If the leftmost cell of the table is surrounded by `**`, it will be converted to
100
92
 
101
93
  ### wrapper
102
94
 
95
+ colgroup will be enabled as follows:
96
+
97
+ ```js
98
+ const md = mdit({ html: true }).use(mditMultimdTable, {
99
+ headerless: true,
100
+ multiline: true,
101
+ rowspan: true,
102
+ }).use(mditTableEx, {
103
+ wrapper: true,
104
+ })
105
+ ```
106
+
103
107
  The table is wrapped in a div.table-wrapper element.
104
108
  I think this is useful for moving the table left and right when the screen width is narrow.
105
109
 
@@ -134,3 +138,130 @@ I think this is useful for moving the table left and right when the screen width
134
138
  </table>
135
139
  </div>
136
140
  ```
141
+
142
+ ## colgroup
143
+
144
+ colgroup will be enabled as follows:
145
+
146
+ ```js
147
+ const md = mdit({ html: true }).use(mditMultimdTable, {
148
+ headerless: true,
149
+ multiline: true,
150
+ rowspan: true,
151
+ }).use(mditTableEx, {
152
+ colgroup: true,
153
+ })
154
+ ```
155
+
156
+ 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.
157
+
158
+ 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.
159
+
160
+ **Examples**:
161
+
162
+ ```
163
+ [Markdown]
164
+ | hh0 | **group:** hh1 | **group:** hh2 | **group2:** hh1 | **group2:** hh2 |
165
+ | --- | ---- | ---- | ---- | ---- |
166
+ | vh1 | 11 | 12 | 13 | 14 |
167
+ | vh2 | 21 | 22 | 23 | 24 |
168
+ [HTML]
169
+ <table>
170
+ <colgroup>
171
+ <col>
172
+ <col span="2">
173
+ <col span="2">
174
+ </colgroup>
175
+ <thead>
176
+ <tr>
177
+ <th rowspan="2" scope="col">hh0</th>
178
+ <th colspan="2" scope="col">group</th>
179
+ <th colspan="2" scope="col">group2</th>
180
+ </tr>
181
+ <tr>
182
+ <th scope="col">hh1</th>
183
+ <th scope="col">hh2</th>
184
+ <th scope="col">hh1</th>
185
+ <th scope="col">hh2</th>
186
+ </tr>
187
+ </thead>
188
+ <tbody>
189
+ <tr>
190
+ <td>vh1</td>
191
+ <td>11</td>
192
+ <td>12</td>
193
+ <td>13</td>
194
+ <td>14</td>
195
+ </tr>
196
+ <tr>
197
+ <td>vh2</td>
198
+ <td>21</td>
199
+ <td>22</td>
200
+ <td>23</td>
201
+ <td>24</td>
202
+ </tr>
203
+ </tbody>
204
+ </table>
205
+ ```
206
+
207
+ ### colgroup with no asterisk
208
+
209
+ Do you find it troublesome to write `**`? You can omit it by adding more options.
210
+
211
+ ```js
212
+ const md = mdit({ html: true }).use(mditMultimdTable, {
213
+ headerless: true,
214
+ multiline: true,
215
+ rowspan: true,
216
+ }).use(mditTableEx, {
217
+ colgroup: true,
218
+ colgroupWithNoAsterisk: true,
219
+ })
220
+ ```
221
+
222
+ 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.
223
+
224
+ ```
225
+ [Markdown]
226
+ | hh0 | foods: hh1 | foods: hh2 | drinks: hh1 | drinks: hh2 |
227
+ | --- | ---- | ---- | ---- | ---- |
228
+ | vh1 | 11 | 12 | 13 | 14 |
229
+ | vh2 | 21 | 22 | 23 | 24 |
230
+ [HTML]
231
+ <table>
232
+ <colgroup>
233
+ <col>
234
+ <col span="2">
235
+ <col span="2">
236
+ </colgroup>
237
+ <thead>
238
+ <tr>
239
+ <th rowspan="2" scope="col">hh0</th>
240
+ <th colspan="2" scope="col">foods</th>
241
+ <th colspan="2" scope="col">drinks</th>
242
+ </tr>
243
+ <tr>
244
+ <th scope="col">hh1</th>
245
+ <th scope="col">hh2</th>
246
+ <th scope="col">hh1</th>
247
+ <th scope="col">hh2</th>
248
+ </tr>
249
+ </thead>
250
+ <tbody>
251
+ <tr>
252
+ <td>vh1</td>
253
+ <td>11</td>
254
+ <td>12</td>
255
+ <td>13</td>
256
+ <td>14</td>
257
+ </tr>
258
+ <tr>
259
+ <td>vh2</td>
260
+ <td>21</td>
261
+ <td>22</td>
262
+ <td>23</td>
263
+ <td>24</td>
264
+ </tr>
265
+ </tbody>
266
+ </table>
267
+ ```