1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | export const fromMarkdown: ((
|
7 | value: Value,
|
8 | encoding: Encoding,
|
9 | options?: Options | undefined
|
10 | ) => Root) &
|
11 | ((value: Value, options?: Options | undefined) => Root)
|
12 | export type Encoding = import('micromark-util-types').Encoding
|
13 | export type Event = import('micromark-util-types').Event
|
14 | export type ParseOptions = import('micromark-util-types').ParseOptions
|
15 | export type Token = import('micromark-util-types').Token
|
16 | export type TokenizeContext = import('micromark-util-types').TokenizeContext
|
17 | export type Value = import('micromark-util-types').Value
|
18 | export type UnistParent = import('unist').Parent
|
19 | export type Point = import('unist').Point
|
20 | export type PhrasingContent = import('mdast').PhrasingContent
|
21 | export type Content = import('mdast').Content
|
22 | export type Node = Root | Content
|
23 | export type Parent = Extract<Node, UnistParent>
|
24 | export type Break = import('mdast').Break
|
25 | export type Blockquote = import('mdast').Blockquote
|
26 | export type Code = import('mdast').Code
|
27 | export type Definition = import('mdast').Definition
|
28 | export type Emphasis = import('mdast').Emphasis
|
29 | export type Heading = import('mdast').Heading
|
30 | export type HTML = import('mdast').HTML
|
31 | export type Image = import('mdast').Image
|
32 | export type ImageReference = import('mdast').ImageReference
|
33 | export type InlineCode = import('mdast').InlineCode
|
34 | export type Link = import('mdast').Link
|
35 | export type LinkReference = import('mdast').LinkReference
|
36 | export type List = import('mdast').List
|
37 | export type ListItem = import('mdast').ListItem
|
38 | export type Paragraph = import('mdast').Paragraph
|
39 | export type Root = import('mdast').Root
|
40 | export type Strong = import('mdast').Strong
|
41 | export type Text = import('mdast').Text
|
42 | export type ThematicBreak = import('mdast').ThematicBreak
|
43 | export type Fragment = UnistParent & {
|
44 | type: 'fragment'
|
45 | children: Array<PhrasingContent>
|
46 | }
|
47 | export type _CompileDataFields = {
|
48 | expectingFirstListItemValue: boolean | undefined
|
49 | flowCodeInside: boolean | undefined
|
50 | setextHeadingSlurpLineEnding: boolean | undefined
|
51 | atHardBreak: boolean | undefined
|
52 | referenceType: 'collapsed' | 'full'
|
53 | inReference: boolean | undefined
|
54 | characterReferenceType:
|
55 | | 'characterReferenceMarkerHexadecimal'
|
56 | | 'characterReferenceMarkerNumeric'
|
57 | }
|
58 | export type CompileData = Record<string, unknown> & Partial<_CompileDataFields>
|
59 | export type Transform = (tree: Root) => Root | void
|
60 | export type Handle = (this: CompileContext, token: Token) => void
|
61 |
|
62 |
|
63 |
|
64 | export type Handles = Record<string, Handle>
|
65 | export type NormalizedExtension = Record<
|
66 | string,
|
67 | Record<string, unknown> | Array<unknown>
|
68 | > & {
|
69 | canContainEols: Array<string>
|
70 | transforms: Array<Transform>
|
71 | enter: Handles
|
72 | exit: Handles
|
73 | }
|
74 |
|
75 |
|
76 |
|
77 | export type Extension = Partial<NormalizedExtension>
|
78 | export type OnEnterError = (
|
79 | this: Omit<CompileContext, 'sliceSerialize'>,
|
80 | left: Token | undefined,
|
81 | right: Token
|
82 | ) => void
|
83 | export type OnExitError = (
|
84 | this: Omit<CompileContext, 'sliceSerialize'>,
|
85 | left: Token,
|
86 | right: Token
|
87 | ) => void
|
88 |
|
89 |
|
90 |
|
91 | export type CompileContext = {
|
92 | stack: Array<Node | Fragment>
|
93 | tokenStack: Array<[Token, OnEnterError | undefined]>
|
94 | |
95 |
|
96 |
|
97 | setData: (key: string, value?: unknown) => void
|
98 | |
99 |
|
100 |
|
101 | getData: <K extends string>(key: K) => CompileData[K]
|
102 | |
103 |
|
104 |
|
105 | buffer: (this: CompileContext) => void
|
106 | |
107 |
|
108 |
|
109 | resume: (this: CompileContext) => string
|
110 | |
111 |
|
112 |
|
113 | enter: <N extends Node>(
|
114 | this: CompileContext,
|
115 | node: N,
|
116 | token: Token,
|
117 | onError?: OnEnterError | undefined
|
118 | ) => N
|
119 | |
120 |
|
121 |
|
122 | exit: (
|
123 | this: CompileContext,
|
124 | token: Token,
|
125 | onError?: OnExitError | undefined
|
126 | ) => Node
|
127 | |
128 |
|
129 |
|
130 | sliceSerialize: TokenizeContext['sliceSerialize']
|
131 | |
132 |
|
133 |
|
134 | config: NormalizedExtension
|
135 | }
|
136 | export type FromMarkdownOptions = {
|
137 | mdastExtensions?: Array<Extension | Array<Extension>>
|
138 | }
|
139 | export type Options = ParseOptions & FromMarkdownOptions
|