Skip to content

Commit

Permalink
Fix to use footnote label over identifier
Browse files Browse the repository at this point in the history
Related to mdx-js/mdx#545.

Closes GH-31

Reviewed-by: Titus Wormer <tituswormer@gmail.com>
Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
  • Loading branch information
lehnerpat authored and wooorm committed Apr 28, 2019
1 parent cb12c28 commit 795af36
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion lib/handlers/footnote-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function footnoteReference(h, node) {

return h(node.position, 'sup', {id: 'fnref-' + identifier}, [
h(node, 'a', {href: '#fn-' + identifier, className: ['footnote-ref']}, [
u('text', identifier)
u('text', node.label || identifier)
])
])
}
53 changes: 26 additions & 27 deletions test/footnote-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,34 @@ var to = require('..')

test('FootnoteReference', function(t) {
t.deepEqual(
to(
u('footnoteReference', {
identifier: 'alpha'
})
),
u(
'element',
{
tagName: 'sup',
properties: {
id: 'fnref-alpha'
}
},
[
u(
'element',
{
tagName: 'a',
properties: {
href: '#fn-alpha',
className: ['footnote-ref']
}
},
[u('text', 'alpha')]
)
]
),
to(u('footnoteReference', {identifier: 'alpha'})),
u('element', {tagName: 'sup', properties: {id: 'fnref-alpha'}}, [
u(
'element',
{
tagName: 'a',
properties: {href: '#fn-alpha', className: ['footnote-ref']}
},
[u('text', 'alpha')]
)
]),
'should render `footnoteReference`s'
)

t.deepEqual(
to(u('footnoteReference', {identifier: 'alpha', label: 'Alpha'})),
u('element', {tagName: 'sup', properties: {id: 'fnref-alpha'}}, [
u(
'element',
{
tagName: 'a',
properties: {href: '#fn-alpha', className: ['footnote-ref']}
},
[u('text', 'Alpha')]
)
]),
'should render `footnoteReference`s (#2)'
)

t.end()
})

0 comments on commit 795af36

Please sign in to comment.