修改了默认的构建模式为模板与源码分离,加入文件系统区分专栏模式
This commit is contained in:
1 parent
dabb04773e
commit
ab5ca2485f
230 files changed
+677
-20542
No files matched your search
@@ -41,6 +41,29 @@ export async function generate_md() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function generate_txt() {
|
||||
const cfg = JSON.parse(await Deno.readTextFile("config.json"));
|
||||
|
||||
try {
|
||||
for (const config of cfg.settings) {
|
||||
const builder = new DocuBuilder(config);
|
||||
|
||||
console.debug(`Processing config: ${JSON.stringify(config)}`);
|
||||
builder.with_files_sync(config.journal.from_directory);
|
||||
await builder.as_txt();
|
||||
const markdownPath = config.md?.path ?? config.markdown_output;
|
||||
if (!markdownPath) {
|
||||
throw new Error("Missing txt output path in config. Use md.path.");
|
||||
}
|
||||
const txtPath = markdownPath.replace("md", "txt");
|
||||
|
||||
await builder.build_as_raw(txtPath);
|
||||
}
|
||||
} finally {
|
||||
// No browser to close in this function
|
||||
}
|
||||
}
|
||||
|
||||
export async function add_index_to_pdf(insert_index_after_page: number = 1) {
|
||||
const config = JSON.parse(await Deno.readTextFile("config.json"));
|
||||
for (const cfg of config.settings) {
|
||||
@@ -48,7 +71,7 @@ export async function add_index_to_pdf(insert_index_after_page: number = 1) {
|
||||
|
||||
const indexBuilder = new IndexBuilder(
|
||||
cfg.playwright.path,
|
||||
cfg.journal.from_directory,
|
||||
cfg,
|
||||
);
|
||||
await indexBuilder.build_index();
|
||||
const _html = indexBuilder.as_html_page();
|
||||
@@ -56,6 +79,14 @@ export async function add_index_to_pdf(insert_index_after_page: number = 1) {
|
||||
await indexBuilder.html2pdf({
|
||||
"path": "./tmps/index.pdf",
|
||||
"format": "A4",
|
||||
"headerTemplate":
|
||||
'<div style="width:100%; font-size:10px; text-align:center; color:#666;"><span class="title"></span></div>',
|
||||
"footerTemplate":
|
||||
'<div style="width:100%; font-size:10px; text-align:center; color:#666;"><span class="title"></span></div>',
|
||||
"margin": {
|
||||
"top": "20mm",
|
||||
"bottom": "20mm",
|
||||
},
|
||||
"printBackground": true,
|
||||
});
|
||||
//console.log(indexBuilder.indexed_map);
|
||||
|
||||
Reference in new issue
Block a user