Commit caad9cd 1 parent cb58ea7 commit caad9cd Copy full SHA for caad9cd
File tree 3 files changed +58
-2
lines changed
3 files changed +58
-2
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,12 @@ import {all} from '../traverse.js'
16
16
*/
17
17
export function table ( h , node ) {
18
18
const rows = node . children
19
- let index = rows . length
19
+ let index = - 1
20
20
const align = node . align || [ ]
21
21
/** @type {Array.<Element> } */
22
22
const result = [ ]
23
23
24
- while ( index -- ) {
24
+ while ( ++ index < rows . length ) {
25
25
const row = rows [ index ] . children
26
26
const name = index === 0 ? 'th' : 'td'
27
27
let pos = node . align ? align . length : row . length
Original file line number Diff line number Diff line change 47
47
"devDependencies" : {
48
48
"@types/tape" : " ^4.0.0" ,
49
49
"c8" : " ^7.0.0" ,
50
+ "hast-util-to-html" : " ^8.0.0" ,
51
+ "mdast-util-footnote" : " ^1.0.0" ,
52
+ "mdast-util-from-markdown" : " ^1.0.0" ,
53
+ "mdast-util-gfm" : " ^1.0.0" ,
54
+ "micromark-extension-footnote" : " ^1.0.0" ,
55
+ "micromark-extension-gfm" : " ^1.0.0" ,
50
56
"prettier" : " ^2.0.0" ,
51
57
"remark-cli" : " ^9.0.0" ,
52
58
"remark-preset-wooorm" : " ^8.0.0" ,
Original file line number Diff line number Diff line change 1
1
import test from 'tape'
2
2
import { u } from 'unist-builder'
3
+ import { fromMarkdown } from 'mdast-util-from-markdown'
4
+ import { gfm } from 'micromark-extension-gfm'
5
+ import { gfmFromMarkdown } from 'mdast-util-gfm'
6
+ import { footnote } from 'micromark-extension-footnote'
7
+ import { footnoteFromMarkdown } from 'mdast-util-footnote'
8
+ import { toHtml } from 'hast-util-to-html'
3
9
import { toHast } from '../index.js'
4
10
5
11
test ( 'Footnote' , ( t ) => {
@@ -234,5 +240,49 @@ test('Footnote', (t) => {
234
240
'should render `footnote`s (#3)'
235
241
)
236
242
243
+ t . equal (
244
+ toHtml (
245
+ // @ts -expect-error: fine.
246
+ toHast (
247
+ fromMarkdown (
248
+ `| Footnotes |
249
+ | ---- |
250
+ | [^1] |
251
+ | [^2] |
252
+
253
+ [^1]: a
254
+ [^2]: b` ,
255
+ {
256
+ extensions : [ gfm ( ) , footnote ( ) ] ,
257
+ mdastExtensions : [ gfmFromMarkdown , footnoteFromMarkdown ]
258
+ }
259
+ )
260
+ )
261
+ ) ,
262
+ `<table>
263
+ <thead>
264
+ <tr>
265
+ <th>Footnotes</th>
266
+ </tr>
267
+ </thead>
268
+ <tbody>
269
+ <tr>
270
+ <td><a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a></td>
271
+ </tr>
272
+ <tr>
273
+ <td><a href="#fn2" class="footnote-ref" id="fnref2" role="doc-noteref"><sup>2</sup></a></td>
274
+ </tr>
275
+ </tbody>
276
+ </table>
277
+ <section class="footnotes" role="doc-endnotes">
278
+ <hr>
279
+ <ol>
280
+ <li id="fn1" role="doc-endnote">a<a href="#fnref1" class="footnote-back" role="doc-backlink">↩</a></li>
281
+ <li id="fn2" role="doc-endnote">b<a href="#fnref2" class="footnote-back" role="doc-backlink">↩</a></li>
282
+ </ol>
283
+ </section>` ,
284
+ 'should render footnotes in tables'
285
+ )
286
+
237
287
t . end ( )
238
288
} )
You can’t perform that action at this time.
0 commit comments