1
1
/**
2
2
* @typedef {import('mdast').FootnoteReference } FootnoteReference
3
3
* @typedef {import('mdast').FootnoteDefinition } FootnoteDefinition
4
+ * @typedef {import('mdast-util-from-markdown').CompileContext } CompileContext
4
5
* @typedef {import('mdast-util-from-markdown').Extension } FromMarkdownExtension
5
6
* @typedef {import('mdast-util-from-markdown').Handle } FromMarkdownHandle
6
7
* @typedef {import('mdast-util-to-markdown').Options } ToMarkdownExtension
@@ -34,20 +35,29 @@ export function gfmFootnoteFromMarkdown() {
34
35
}
35
36
}
36
37
37
- /** @type {FromMarkdownHandle } */
38
+ /**
39
+ * @this {CompileContext}
40
+ * @type {FromMarkdownHandle }
41
+ */
38
42
function enterFootnoteDefinition ( token ) {
39
43
this . enter (
40
44
{ type : 'footnoteDefinition' , identifier : '' , label : '' , children : [ ] } ,
41
45
token
42
46
)
43
47
}
44
48
45
- /** @type {FromMarkdownHandle } */
49
+ /**
50
+ * @this {CompileContext}
51
+ * @type {FromMarkdownHandle }
52
+ */
46
53
function enterFootnoteDefinitionLabelString ( ) {
47
54
this . buffer ( )
48
55
}
49
56
50
- /** @type {FromMarkdownHandle } */
57
+ /**
58
+ * @this {CompileContext}
59
+ * @type {FromMarkdownHandle }
60
+ */
51
61
function exitFootnoteDefinitionLabelString ( token ) {
52
62
const label = this . resume ( )
53
63
const node = /** @type {FootnoteDefinition } */ (
@@ -59,22 +69,34 @@ export function gfmFootnoteFromMarkdown() {
59
69
) . toLowerCase ( )
60
70
}
61
71
62
- /** @type {FromMarkdownHandle } */
72
+ /**
73
+ * @this {CompileContext}
74
+ * @type {FromMarkdownHandle }
75
+ */
63
76
function exitFootnoteDefinition ( token ) {
64
77
this . exit ( token )
65
78
}
66
79
67
- /** @type {FromMarkdownHandle } */
80
+ /**
81
+ * @this {CompileContext}
82
+ * @type {FromMarkdownHandle }
83
+ */
68
84
function enterFootnoteCall ( token ) {
69
85
this . enter ( { type : 'footnoteReference' , identifier : '' , label : '' } , token )
70
86
}
71
87
72
- /** @type {FromMarkdownHandle } */
88
+ /**
89
+ * @this {CompileContext}
90
+ * @type {FromMarkdownHandle }
91
+ */
73
92
function enterFootnoteCallString ( ) {
74
93
this . buffer ( )
75
94
}
76
95
77
- /** @type {FromMarkdownHandle } */
96
+ /**
97
+ * @this {CompileContext}
98
+ * @type {FromMarkdownHandle }
99
+ */
78
100
function exitFootnoteCallString ( token ) {
79
101
const label = this . resume ( )
80
102
const node = /** @type {FootnoteDefinition } */ (
@@ -86,7 +108,10 @@ export function gfmFootnoteFromMarkdown() {
86
108
) . toLowerCase ( )
87
109
}
88
110
89
- /** @type {FromMarkdownHandle } */
111
+ /**
112
+ * @this {CompileContext}
113
+ * @type {FromMarkdownHandle }
114
+ */
90
115
function exitFootnoteCall ( token ) {
91
116
this . exit ( token )
92
117
}
@@ -111,6 +136,7 @@ export function gfmFootnoteToMarkdown() {
111
136
function footnoteReference ( node , _ , context , safeOptions ) {
112
137
const tracker = track ( safeOptions )
113
138
let value = tracker . move ( '[^' )
139
+ // @ts -expect-error: use map.
114
140
const exit = context . enter ( 'footnoteReference' )
115
141
const subexit = context . enter ( 'reference' )
116
142
value += tracker . move (
@@ -138,6 +164,7 @@ export function gfmFootnoteToMarkdown() {
138
164
function footnoteDefinition ( node , _ , context , safeOptions ) {
139
165
const tracker = track ( safeOptions )
140
166
let value = tracker . move ( '[^' )
167
+ // @ts -expect-error: use map.
141
168
const exit = context . enter ( 'footnoteDefinition' )
142
169
const subexit = context . enter ( 'label' )
143
170
value += tracker . move (
0 commit comments