-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
39 lines (38 loc) · 1.44 KB
/
index.ts
File metadata and controls
39 lines (38 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { dom } from "@typeup/dom"
import { mendly } from "mendly"
import { block as internalBlock } from "./block"
import { inline as internalInline } from "./inline"
import { Source } from "./Source"
export namespace parser {
export function parse(reader: string | undefined, handler?: mendly.Error.Handler): dom.Document | undefined
export function parse(reader: mendly.Reader | undefined, handler?: mendly.Error.Handler): dom.Document | undefined
export function parse(
reader: mendly.Reader | string | undefined,
handler?: mendly.Error.Handler
): dom.Document | undefined {
const source = Source.from(reader, handler)
return source && new dom.Document(internalBlock.parseAll(source) || [], source.mark())
}
export function open(path: string | undefined, handler?: mendly.Error.Handler): dom.Document | undefined {
const locator = mendly.Uri.parse(path)
return locator && parse(mendly.Reader.open(locator), handler)
}
export namespace inline {
export function parse(
reader: mendly.Reader | string | undefined,
handler?: mendly.Error.Handler
): dom.Inline[] | undefined {
const source = Source.from(reader, handler)
return source && internalInline.parse(source)
}
}
export namespace block {
export function parse(
reader: mendly.Reader | string | undefined,
handler?: mendly.Error.Handler
): dom.Block[] | undefined {
const source = Source.from(reader, handler)
return source && internalBlock.parseAll(source)
}
}
}