File tree 2 files changed +34
-6
lines changed
2 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,44 @@ import type {Literal} from 'mdast'
3
3
declare module 'mdast-util-from-markdown' {
4
4
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
5
5
interface CompileData {
6
- // Register a new field.
6
+ /**
7
+ * Whether we’re in math (flow).
8
+ */
7
9
mathFlowInside ?: boolean | undefined
8
10
}
9
11
}
10
12
13
+ declare module 'mdast-util-to-markdown' {
14
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
15
+ interface ConstructNameMap {
16
+ /**
17
+ * Math (flow).
18
+ *
19
+ * ```markdown
20
+ * > | $$
21
+ * ^^
22
+ * > | a
23
+ * ^
24
+ * > | $$
25
+ * ^^
26
+ * ```
27
+ */
28
+ mathFlow : 'mathFlow'
29
+
30
+ /**
31
+ * Math (flow) meta flag.
32
+ *
33
+ * ```markdown
34
+ * > | $$a
35
+ * ^
36
+ * | b
37
+ * | $$
38
+ * ```
39
+ */
40
+ mathFlowMeta : 'mathFlowMeta'
41
+ }
42
+ }
43
+
11
44
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
12
45
export interface Math extends Literal {
13
46
type : 'math'
Original file line number Diff line number Diff line change @@ -158,11 +158,8 @@ export function mathToMarkdown(options = {}) {
158
158
159
159
return {
160
160
unsafe : [
161
- // @ts -expect-error: To do: use context map.
162
161
{ character : '\r' , inConstruct : [ 'mathFlowMeta' ] } ,
163
- // @ts -expect-error: To do: use context map.
164
162
{ character : '\r' , inConstruct : [ 'mathFlowMeta' ] } ,
165
- // @ts -expect-error: To do: use context map.
166
163
single
167
164
? { character : '$' , inConstruct : [ 'mathFlowMeta' , 'phrasing' ] }
168
165
: {
@@ -182,13 +179,11 @@ export function mathToMarkdown(options = {}) {
182
179
function math ( node , _ , context , safeOptions ) {
183
180
const raw = node . value || ''
184
181
const sequence = '$' . repeat ( Math . max ( longestStreak ( raw , '$' ) + 1 , 2 ) )
185
- // @ts -expect-error: To do: use context map.
186
182
const exit = context . enter ( 'mathFlow' )
187
183
const tracker = track ( safeOptions )
188
184
let value = tracker . move ( sequence )
189
185
190
186
if ( node . meta ) {
191
- // @ts -expect-error: To do: use context map.
192
187
const subexit = context . enter ( 'mathFlowMeta' )
193
188
value += tracker . move (
194
189
safe ( context , node . meta , {
You can’t perform that action at this time.
0 commit comments