Skip to content

Commit 0d244c6

Browse files
committed
wip: all types
1 parent 4b0e828 commit 0d244c6

File tree

11 files changed

+158
-10
lines changed

11 files changed

+158
-10
lines changed

src/abbreviations.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Parent, PhrasingContent } from 'mdast';
2+
3+
export interface Abbreviation extends Parent {
4+
type: 'abbreviation';
5+
children: PhrasingContent[];
6+
title?: string;
7+
}

src/admonitions.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { Parent, PhrasingContent } from 'mdast';
2+
import type { FlowContent } from './flow';
3+
4+
export interface AdmonitionTitle extends Parent {
5+
type: 'admonitionTitle';
6+
children: PhrasingContent[];
7+
}
8+
9+
export type AdmonitionKind =
10+
| 'attention'
11+
| 'caution'
12+
| 'danger'
13+
| 'error'
14+
| 'hint'
15+
| 'important'
16+
| 'note'
17+
| 'seealso'
18+
| 'tip'
19+
| 'warning';
20+
21+
export interface Admonition extends Parent {
22+
type: 'admonition';
23+
kind?: AdmonitionKind;
24+
class?: string;
25+
children: (FlowContent | AdmonitionTitle)[];
26+
}

src/comments.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { Literal } from 'mdast';
2+
3+
export interface Comment extends Literal {
4+
type: 'comment';
5+
}

src/directives.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Parent, Literal, PhrasingContent } from 'mdast';
2+
import type { FlowContent } from './flow';
3+
4+
export interface Directive extends Parent, Literal {
5+
type: 'mystDirective';
6+
name: string;
7+
args?: string;
8+
options?: Record<string, any>;
9+
value: string;
10+
children: (FlowContent | PhrasingContent)[];
11+
}

src/enumerated.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface Enumerated {
2+
enumerated: boolean;
3+
enumerator: string;
4+
}

src/flow.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import type { Blockquote, Code, Heading, Html, List, ThematicBreak, RootContent } from 'mdast';
2+
import type { Math } from './math';
3+
import type { Admonition } from './admonitions';
4+
import type { Comment } from './comments';
5+
import type { Directive } from './directives';
6+
import type { Target } from './references';
7+
28
export interface FlowContentMap {
39
blockQuote: Blockquote;
410
code: Code;
@@ -7,6 +13,11 @@ export interface FlowContentMap {
713
list: List;
814
thematicBreak: ThematicBreak;
915
rootContent: RootContent;
16+
math: Math;
17+
comment: Comment;
18+
directive: Directive;
19+
admonition: Admonition;
20+
mystTarget: Target;
1021
}
1122

1223
export type FlowContent = FlowContentMap[keyof FlowContentMap];

src/index.ts

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,58 @@
1-
//import type { InlineMath } from './math';
21
import type { Role } from './roles';
32
import type { BlockBreak, Block } from './blocks';
3+
import type { AdmonitionTitle, Admonition } from './admonitions';
4+
import type { Abbreviation } from './abbreviations';
5+
import type { Comment } from './comments';
6+
import type { InlineMath, Math } from './math';
7+
import type { Directive } from './directives';
8+
import type { CrossReference, Target } from './references';
9+
import type { Subscript, Superscript, Underline } from './styles';
410

511
declare module 'mdast' {
6-
interface Node {
7-
// Referencing semantics
8-
identifier?: string;
12+
// Extend Association to include HTML ID
13+
interface Association {
914
html_id?: string;
1015
}
1116

17+
// All nodes are referenceable now
18+
interface Node extends Partial<Association> {}
19+
1220
interface PhrasingContentMap {
13-
// Extend MDAST to use our types
14-
//inlineMath: InlineMath;
21+
inlineMath: InlineMath;
1522
mystRole: Role;
16-
//subscriptStatic: SubscriptStatic;
17-
//superscriptStatic: SuperscriptStatic;
18-
//underlineStatic: UnderlineStatic;
23+
subscript: Subscript;
24+
superscript: Superscript;
25+
underline: Underline;
26+
crossReference: CrossReference;
27+
abbreviation: Abbreviation;
1928
}
2029

2130
interface RootContentMap {
2231
mystRole: Role;
2332
block: Block;
2433
blockBreak: BlockBreak;
34+
admonition: Admonition;
35+
admonitionTitle: AdmonitionTitle;
36+
abbreviation: Abbreviation;
37+
comment: Comment;
38+
mystDirective: Directive;
39+
math: Math;
40+
inlineMath: InlineMath;
41+
subscript: Subscript;
42+
superscript: Superscript;
43+
underline: Underline;
44+
crossReference: CrossReference;
45+
mystTarget: Target;
2546
}
2647
}
2748

2849
export type * from 'mdast';
2950
export type * from './roles';
3051
export type * from './blocks';
31-
export type * from './flow';
52+
export type * from './admonitions';
53+
export type * from './abbreviations';
54+
export type * from './comments';
55+
export type * from './math';
56+
export type * from './directives';
57+
export type * from './references';
58+
export type * from './styles';

src/math.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Association, Literal } from 'mdast';
2+
import type { Enumerated } from './enumerated';
3+
4+
export interface Math extends Partial<Association>, Partial<Enumerated>, Literal {
5+
type: 'math';
6+
}
7+
export interface InlineMath extends Literal {
8+
type: 'inlineMath';
9+
}

src/references.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { Association, Parent, PhrasingContent, Node } from 'mdast';
2+
3+
export interface Target extends Node {
4+
type: 'mystTarget';
5+
label?: string;
6+
}
7+
8+
export interface CrossReference extends Association, Pick<Parent, 'children'> {
9+
type: 'crossReference';
10+
kind?: 'eq' | 'numref' | 'ref';
11+
children: PhrasingContent[];
12+
}

src/styles.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { Parent, PhrasingContent } from 'mdast';
2+
3+
export interface Subscript extends Parent {
4+
type: 'subscript';
5+
children: PhrasingContent[];
6+
}
7+
8+
export interface Superscript extends Parent {
9+
type: 'superscript';
10+
children: PhrasingContent[];
11+
}
12+
13+
export interface Underline extends Parent {
14+
type: 'underline';
15+
children: PhrasingContent[];
16+
}

0 commit comments

Comments
 (0)