Skip to content

Commit 500e861

Browse files
committed
fix: add containers
1 parent 1442acc commit 500e861

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

src/containers.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { Parent, Image, Table } from 'mdast';
2+
import type { Enumerated } from './enumerated';
3+
import type { FlowContent } from './flow';
4+
5+
export interface Caption extends Parent {
6+
type: 'caption';
7+
children: FlowContent[];
8+
}
9+
10+
export interface Legend extends Parent {
11+
type: 'legend';
12+
children: FlowContent[];
13+
}
14+
15+
export interface Container extends Parent, Partial<Enumerated> {
16+
type: 'container';
17+
kind: 'figure' | 'table';
18+
class?: string;
19+
children: (Caption | Legend | Image | Table)[];
20+
}

src/flow.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
import type { Blockquote, Code, Heading, Html, List, ThematicBreak, RootContent } from 'mdast';
1+
import type {
2+
Blockquote,
3+
Code,
4+
Heading,
5+
Html,
6+
List,
7+
ThematicBreak,
8+
RootContent,
9+
Paragraph,
10+
Definition,
11+
FootnoteDefinition,
12+
} from 'mdast';
213
import type { Math } from './math';
314
import type { Admonition } from './admonitions';
415
import type { Comment } from './comments';
16+
import type { Container } from './containers';
517
import type { Directive } from './directives';
618
import type { Target } from './references';
719

@@ -12,12 +24,16 @@ export interface FlowContentMap {
1224
html: Html;
1325
list: List;
1426
thematicBreak: ThematicBreak;
15-
rootContent: RootContent;
27+
paragraph: Paragraph;
28+
definition: Definition;
29+
footnoteDefinition: FootnoteDefinition;
30+
1631
math: Math;
32+
admonition: Admonition;
1733
comment: Comment;
1834
directive: Directive;
19-
admonition: Admonition;
2035
mystTarget: Target;
36+
container: Container;
2137
}
2238

2339
export type FlowContent = FlowContentMap[keyof FlowContentMap];

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { InlineMath, Math } from './math';
77
import type { Directive } from './directives';
88
import type { CrossReference, Target } from './references';
99
import type { Subscript, Superscript, Underline } from './styles';
10+
import type { Caption, Container, Legend } from './containers';
1011

1112
declare module 'mdast' {
1213
// Extend Association to include HTML ID
@@ -61,6 +62,9 @@ declare module 'mdast' {
6162
underline: Underline;
6263
crossReference: CrossReference;
6364
mystTarget: Target;
65+
container: Container;
66+
caption: Caption;
67+
legend: Legend;
6468
}
6569
}
6670

0 commit comments

Comments
 (0)