|
10 | 10 | * @typedef {import('hast').Element} Element
|
11 | 11 | * @typedef {import('hast').Root} Root
|
12 | 12 | * @typedef {import('unist-util-position').PositionLike} PositionLike
|
13 |
| - * @typedef {import('unist-util-visit').Visitor<FootnoteDefinition>} FootnoteDefinitionVisitor |
14 | 13 | *
|
15 | 14 | * @typedef {Element|Text|Comment} Content
|
16 | 15 | *
|
@@ -95,7 +94,15 @@ function factory(tree, options) {
|
95 | 94 | h.unknownHandler = settings.unknownHandler
|
96 | 95 | h.passThrough = settings.passThrough
|
97 | 96 |
|
98 |
| - visit(tree, 'footnoteDefinition', onfootnotedefinition) |
| 97 | + visit(tree, 'footnoteDefinition', (definition) => { |
| 98 | + const id = String(definition.identifier).toUpperCase() |
| 99 | + |
| 100 | + // Mimick CM behavior of link definitions. |
| 101 | + // See: <https://github.com/syntax-tree/mdast-util-definitions/blob/8290999/index.js#L26>. |
| 102 | + if (!own.call(footnoteById, id)) { |
| 103 | + footnoteById[id] = definition |
| 104 | + } |
| 105 | + }) |
99 | 106 |
|
100 | 107 | // @ts-expect-error Hush, it’s fine!
|
101 | 108 | return h
|
@@ -164,19 +171,6 @@ function factory(tree, options) {
|
164 | 171 | children: children || []
|
165 | 172 | })
|
166 | 173 | }
|
167 |
| - |
168 |
| - /** |
169 |
| - * @type {FootnoteDefinitionVisitor} |
170 |
| - */ |
171 |
| - function onfootnotedefinition(definition) { |
172 |
| - const id = String(definition.identifier).toUpperCase() |
173 |
| - |
174 |
| - // Mimick CM behavior of link definitions. |
175 |
| - // See: <https://github.com/syntax-tree/mdast-util-definitions/blob/8290999/index.js#L26>. |
176 |
| - if (!own.call(footnoteById, id)) { |
177 |
| - footnoteById[id] = definition |
178 |
| - } |
179 |
| - } |
180 | 174 | }
|
181 | 175 |
|
182 | 176 | /**
|
|
0 commit comments