Skip to content

Commit 5982b9e

Browse files
committed
Refactor to move implementation to lib/
1 parent 17fa207 commit 5982b9e

File tree

7 files changed

+330
-314
lines changed

7 files changed

+330
-314
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
coverage/
22
node_modules/
33
.DS_Store
4-
index.d.ts
5-
test.d.ts
4+
*.d.ts
65
*.log
76
yarn.lock
7+
!/complex-types.d.ts
8+
!/index.d.ts

complex-types.d.ts

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,4 @@
1-
import type {Literal} from 'mdast'
1+
// To do: next major: remove this file.
2+
export type {Math, InlineMath} from './index.js'
23

3-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
4-
export interface Math extends Literal {
5-
type: 'math'
6-
meta?: string | null
7-
}
8-
9-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
10-
export interface InlineMath extends Literal {
11-
type: 'inlineMath'
12-
}
13-
declare module 'mdast-util-from-markdown' {
14-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
15-
interface CompileData {
16-
/**
17-
* Whether we’re in math (flow).
18-
*/
19-
mathFlowInside?: boolean | undefined
20-
}
21-
}
22-
23-
declare module 'mdast-util-to-markdown' {
24-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
25-
interface ConstructNameMap {
26-
/**
27-
* Math (flow).
28-
*
29-
* ```markdown
30-
* > | $$
31-
* ^^
32-
* > | a
33-
* ^
34-
* > | $$
35-
* ^^
36-
* ```
37-
*/
38-
mathFlow: 'mathFlow'
39-
40-
/**
41-
* Math (flow) meta flag.
42-
*
43-
* ```markdown
44-
* > | $$a
45-
* ^
46-
* | b
47-
* | $$
48-
* ```
49-
*/
50-
mathFlowMeta: 'mathFlowMeta'
51-
}
52-
}
53-
54-
declare module 'mdast' {
55-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
56-
interface StaticPhrasingContentMap {
57-
inlineMath: InlineMath
58-
}
59-
60-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
61-
interface BlockContentMap {
62-
math: Math
63-
}
64-
}
4+
/// <reference types="./index.js" />

index.d.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import type {Literal} from 'mdast'
2+
3+
export {mathFromMarkdown, mathToMarkdown} from './lib/index.js'
4+
5+
export type {ToOptions} from './lib/index.js'
6+
7+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
8+
export interface Math extends Literal {
9+
type: 'math'
10+
meta?: string | null
11+
}
12+
13+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
14+
export interface InlineMath extends Literal {
15+
type: 'inlineMath'
16+
}
17+
18+
// Add custom data tracked to turn markdown into a tree.
19+
declare module 'mdast-util-from-markdown' {
20+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
21+
interface CompileData {
22+
/**
23+
* Whether we’re in math (flow).
24+
*/
25+
mathFlowInside?: boolean | undefined
26+
}
27+
}
28+
29+
// Add custom data tracked to turn a tree into markdown.
30+
declare module 'mdast-util-to-markdown' {
31+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
32+
interface ConstructNameMap {
33+
/**
34+
* Math (flow).
35+
*
36+
* ```markdown
37+
* > | $$
38+
* ^^
39+
* > | a
40+
* ^
41+
* > | $$
42+
* ^^
43+
* ```
44+
*/
45+
mathFlow: 'mathFlow'
46+
47+
/**
48+
* Math (flow) meta flag.
49+
*
50+
* ```markdown
51+
* > | $$a
52+
* ^
53+
* | b
54+
* | $$
55+
* ```
56+
*/
57+
mathFlowMeta: 'mathFlowMeta'
58+
}
59+
}
60+
61+
// Add nodes to tree.
62+
declare module 'mdast' {
63+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
64+
interface StaticPhrasingContentMap {
65+
inlineMath: InlineMath
66+
}
67+
68+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
69+
interface BlockContentMap {
70+
math: Math
71+
}
72+
}

0 commit comments

Comments
 (0)