文档部分基本完成,还需要完善生成目录
This commit is contained in:
1 parent
578109c8de
commit
365b1db47e
109 files changed
+6222
-289
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import { DocuBuilder } from "../pdf_builder/builder.ts";
|
||||
|
||||
export async function generate_pdf() {
|
||||
const builder = new DocuBuilder();
|
||||
try {
|
||||
await builder.with_browser();
|
||||
|
||||
const cfg = JSON.parse(await Deno.readTextFile("config.json"));
|
||||
for (const config of cfg.settings) {
|
||||
console.debug(`Processing config: ${JSON.stringify(config)}`);
|
||||
builder.with_files_sync(config.journal.from_directory);
|
||||
builder.as_html_page();
|
||||
await builder.build_as_pdf(config.playwright);
|
||||
}
|
||||
} finally {
|
||||
await builder.close_browser();
|
||||
}
|
||||
}
|
||||
|
||||
export async function generate_md() {
|
||||
const builder = new DocuBuilder();
|
||||
try {
|
||||
const cfg = JSON.parse(await Deno.readTextFile("config.json"));
|
||||
for (const config of cfg.settings) {
|
||||
console.debug(`Processing config: ${JSON.stringify(config)}`);
|
||||
builder.with_files_sync(config.journal.from_directory);
|
||||
builder.as_markdown();
|
||||
const markdownPath = config.md?.path ?? config.markdown_output;
|
||||
if (!markdownPath) {
|
||||
throw new Error("Missing markdown output path in config. Use md.path.");
|
||||
}
|
||||
await builder.build_as_raw(markdownPath);
|
||||
}
|
||||
} finally {
|
||||
// No browser to close in this function
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user