blob: bce317e6e157ba2670d71c14c7eb0a6eff4d5a5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import { Config } from "../config.ts";
import { parseXmlFile } from "../xml.ts";
import { DocBookError, XmlParseError } from "../errors.ts";
import { createNewDocumentFromRootElement, Document } from "./document.ts";
import toHtml from "./to_html.ts";
export async function parseDocBookFile(
filePath: string,
config: Config,
): Promise<Document> {
try {
const root = await parseXmlFile(filePath);
const doc = createNewDocumentFromRootElement(root, filePath, config);
return toHtml(doc);
} catch (e) {
if (e instanceof DocBookError || e instanceof XmlParseError) {
e.message = `${e.message} in ${filePath}`;
}
throw e;
}
}
|