@@ -363,6 +363,11 @@ function linkDestinationEnd(text: string, start: number): number {
363363 return - 1 ;
364364}
365365
366+ // Mirrors micromark's normalizeIdentifier so chunks match footnotes exactly as one render would.
367+ function footnoteLabelKey ( label : string ) : string {
368+ return label . toLowerCase ( ) . toUpperCase ( ) ;
369+ }
370+
366371const TABLE_URI_AUTOLINK = / < [ A - Z a - z ] [ A - Z a - z 0 - 9 + . - ] { 1 , 31 } : [ ^ \x00 - \x20 < > ] * > / y;
367372const TABLE_EMAIL_AUTOLINK =
368373 / < [ a - z A - Z 0 - 9 . ! # $ % & ' * + / = ? ^ _ ` { | } ~ - ] + @ [ a - z A - Z 0 - 9 ] (?: [ a - z A - Z 0 - 9 - ] { 0 , 61 } [ a - z A - Z 0 - 9 ] ) ? (?: \. [ a - z A - Z 0 - 9 ] (?: [ a - z A - Z 0 - 9 - ] { 0 , 61 } [ a - z A - Z 0 - 9 ] ) ? ) * > / y;
@@ -804,7 +809,7 @@ function extractFootnoteRefs(
804809 const isDefAtLineStart = ! tableCell && text [ j + 1 ] === ":" && isAtLineStart ( i ) ;
805810 if ( ! isDefAtLineStart ) {
806811 const label = text . slice ( i + 2 , j ) ;
807- if ( definedKeys . has ( label . toLowerCase ( ) ) ) {
812+ if ( definedKeys . has ( footnoteLabelKey ( label ) ) ) {
808813 refs . push ( label ) ;
809814 }
810815 }
@@ -895,7 +900,7 @@ function splitMarkdownBlocks(
895900 if ( activeFootnoteLabel !== null && activeFootnoteLines !== null ) {
896901 const block = activeFootnoteLines . join ( "\n" ) . trimEnd ( ) ;
897902 if ( footnoteChars + block . length < SHARED_FOOTNOTES_MAX_CHARS ) {
898- capturedFootnoteKeys . add ( activeFootnoteLabel . toLowerCase ( ) ) ;
903+ capturedFootnoteKeys . add ( footnoteLabelKey ( activeFootnoteLabel ) ) ;
899904 capturedFootnoteLabels . push ( activeFootnoteLabel ) ;
900905 footnoteDefs . push ( block ) ;
901906 footnoteDefSpans . push ( [ activeFootnoteOffset , block . length ] ) ;
@@ -1057,7 +1062,7 @@ function splitMarkdownBlocks(
10571062 mayHaveFootnotes && line . includes ( "[^" ) ? FOOTNOTE_DEFINITION_START . exec ( line ) : null ;
10581063 if ( fnMatch ) {
10591064 const label = fnMatch [ 1 ] ! ;
1060- const key = label . toLowerCase ( ) ;
1065+ const key = footnoteLabelKey ( label ) ;
10611066 inFootnoteDef = true ;
10621067 if ( ! seenFootnoteKeys . has ( key ) ) {
10631068 seenFootnoteKeys . add ( key ) ;
@@ -1548,7 +1553,7 @@ export function findFootnoteRefChunkIndex(
15481553 const refs = footnotes . chunkRefs [ chunkIndex ] ;
15491554 if ( ! refs ) continue ;
15501555 for ( const label of refs ) {
1551- const key = label . toLowerCase ( ) ;
1556+ const key = footnoteLabelKey ( label ) ;
15521557 let num = numberByKey . get ( key ) ;
15531558 if ( num === undefined ) {
15541559 num = nextNumber ++ ;
0 commit comments