-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
20 lines (19 loc) · 775 Bytes
/
index.ts
File metadata and controls
20 lines (19 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { dom } from "@typeup/dom"
import { mendly } from "mendly"
import { block } from "./block"
import { CommentStripper } from "./CommentStripper"
import { Source } from "./Source"
export namespace parser {
export function parse(reader: mendly.Reader | undefined, handler: mendly.Error.Handler): dom.Document | undefined {
let result: dom.Document | undefined
if (reader) {
const source = new Source(new CommentStripper(reader), handler)
result = new dom.Document(block.parseAll(source) || [], source.mark())
}
return result
}
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) : undefined
}
}