Skip to content

Commit 795af36

Browse files
lehnerpatwooorm
authored andcommitted
Fix to use footnote label over identifier
Related to mdx-js/mdx#545. Closes GH-31 Reviewed-by: Titus Wormer <[email protected]> Reviewed-by: Christian Murphy <[email protected]>
1 parent cb12c28 commit 795af36

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

lib/handlers/footnote-reference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function footnoteReference(h, node) {
99

1010
return h(node.position, 'sup', {id: 'fnref-' + identifier}, [
1111
h(node, 'a', {href: '#fn-' + identifier, className: ['footnote-ref']}, [
12-
u('text', identifier)
12+
u('text', node.label || identifier)
1313
])
1414
])
1515
}

test/footnote-reference.js

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,34 @@ var to = require('..')
66

77
test('FootnoteReference', function(t) {
88
t.deepEqual(
9-
to(
10-
u('footnoteReference', {
11-
identifier: 'alpha'
12-
})
13-
),
14-
u(
15-
'element',
16-
{
17-
tagName: 'sup',
18-
properties: {
19-
id: 'fnref-alpha'
20-
}
21-
},
22-
[
23-
u(
24-
'element',
25-
{
26-
tagName: 'a',
27-
properties: {
28-
href: '#fn-alpha',
29-
className: ['footnote-ref']
30-
}
31-
},
32-
[u('text', 'alpha')]
33-
)
34-
]
35-
),
9+
to(u('footnoteReference', {identifier: 'alpha'})),
10+
u('element', {tagName: 'sup', properties: {id: 'fnref-alpha'}}, [
11+
u(
12+
'element',
13+
{
14+
tagName: 'a',
15+
properties: {href: '#fn-alpha', className: ['footnote-ref']}
16+
},
17+
[u('text', 'alpha')]
18+
)
19+
]),
3620
'should render `footnoteReference`s'
3721
)
3822

23+
t.deepEqual(
24+
to(u('footnoteReference', {identifier: 'alpha', label: 'Alpha'})),
25+
u('element', {tagName: 'sup', properties: {id: 'fnref-alpha'}}, [
26+
u(
27+
'element',
28+
{
29+
tagName: 'a',
30+
properties: {href: '#fn-alpha', className: ['footnote-ref']}
31+
},
32+
[u('text', 'Alpha')]
33+
)
34+
]),
35+
'should render `footnoteReference`s (#2)'
36+
)
37+
3938
t.end()
4039
})

0 commit comments

Comments
 (0)