22 * @typedef {import('hast').Element } Element
33 * @typedef {import('hast').ElementContent } ElementContent
44 *
5- * @typedef {import('./index .js').H } H
5+ * @typedef {import('./state .js').State } State
66 */
77
88import { normalizeUri } from 'micromark-util-sanitize-uri'
@@ -12,45 +12,45 @@ import {wrap} from './wrap.js'
1212/**
1313 * Generate a hast footer for called footnote definitions.
1414 *
15- * @param {H } h
15+ * @param {State } state
1616 * Info passed around.
1717 * @returns {Element | undefined }
1818 * `section` element or `undefined`.
1919 */
20- export function footer ( h ) {
20+ export function footer ( state ) {
2121 /** @type {Array<ElementContent> } */
2222 const listItems = [ ]
2323 let index = - 1
2424
25- while ( ++ index < h . footnoteOrder . length ) {
26- const def = h . footnoteById [ h . footnoteOrder [ index ] . toUpperCase ( ) ]
25+ while ( ++ index < state . footnoteOrder . length ) {
26+ const def = state . footnoteById [ state . footnoteOrder [ index ] . toUpperCase ( ) ]
2727
2828 if ( ! def ) {
2929 continue
3030 }
3131
32- const content = all ( h , def )
32+ const content = all ( state , def )
3333 const id = String ( def . identifier )
3434 const safeId = normalizeUri ( id . toLowerCase ( ) )
3535 let referenceIndex = 0
3636 /** @type {Array<ElementContent> } */
3737 const backReferences = [ ]
3838
39- while ( ++ referenceIndex <= h . footnoteCounts [ id ] ) {
39+ while ( ++ referenceIndex <= state . footnoteCounts [ id ] ) {
4040 /** @type {Element } */
4141 const backReference = {
4242 type : 'element' ,
4343 tagName : 'a' ,
4444 properties : {
4545 href :
4646 '#' +
47- h . clobberPrefix +
47+ state . clobberPrefix +
4848 'fnref-' +
4949 safeId +
5050 ( referenceIndex > 1 ? '-' + referenceIndex : '' ) ,
5151 dataFootnoteBackref : true ,
5252 className : [ 'data-footnote-backref' ] ,
53- ariaLabel : h . footnoteBackLabel
53+ ariaLabel : state . footnoteBackLabel
5454 } ,
5555 children : [ { type : 'text' , value : '↩' } ]
5656 }
@@ -89,11 +89,11 @@ export function footer(h) {
8989 const listItem = {
9090 type : 'element' ,
9191 tagName : 'li' ,
92- properties : { id : h . clobberPrefix + 'fn-' + safeId } ,
92+ properties : { id : state . clobberPrefix + 'fn-' + safeId } ,
9393 children : wrap ( content , true )
9494 }
9595
96- h . patch ( def , listItem )
96+ state . patch ( def , listItem )
9797
9898 listItems . push ( listItem )
9999 }
@@ -109,13 +109,13 @@ export function footer(h) {
109109 children : [
110110 {
111111 type : 'element' ,
112- tagName : h . footnoteLabelTagName ,
112+ tagName : state . footnoteLabelTagName ,
113113 properties : {
114114 // To do: use structured clone.
115- ...JSON . parse ( JSON . stringify ( h . footnoteLabelProperties ) ) ,
115+ ...JSON . parse ( JSON . stringify ( state . footnoteLabelProperties ) ) ,
116116 id : 'footnote-label'
117117 } ,
118- children : [ { type : 'text' , value : h . footnoteLabel } ]
118+ children : [ { type : 'text' , value : state . footnoteLabel } ]
119119 } ,
120120 { type : 'text' , value : '\n' } ,
121121 {
0 commit comments