-
DescriptionI have following structure.
I want to create pdf and docx output along with html my
this creates
how do I create
I can write
in each |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Could you format your post using code blocks, etc., and possibly share a concrete example as a Git repository? |
Beta Was this translation helpful? Give feedback.
-
Please see a demo repository at |
Beta Was this translation helpful? Give feedback.
-
You can't do what you want or your post-render script will also have to modify the HTML files. Alternatively, you can have a pre-render script that does the setup for you, i.e., setting the Below are two versions of the same script:
import * as fs from "node:fs";
import * as path from "node:path";
fs.readdirSync("content", { withFileTypes: true }).forEach((dirent) => {
if (dirent.isDirectory()) {
const metadataPath = path.join("content", dirent.name, "_metadata.yml");
const metadataContent = `format:\n html: default\n pdf:\n output-file: ${dirent.name}.pdf\n docx:\n output-file: ${dirent.name}.docx\n`;
fs.writeFileSync(metadataPath, metadataContent);
}
});
import os
for dirpath, dirnames, filenames in os.walk("content"):
for dirname in dirnames:
metadata_path = os.path.join(dirpath, dirname, "_metadata.yml")
with open(metadata_path, "w") as metadata_file:
metadata_file.write(f"format:\n html: default\n pdf:\n output-file: {dirname}.pdf\n docx:\n output-file: {dirname}.docx\n")
|
Beta Was this translation helpful? Give feedback.
You can't do what you want or your post-render script will also have to modify the HTML files.
Alternatively, you can have a pre-render script that does the setup for you, i.e., setting the
output-file
, see https://quarto.org/docs/projects/scripts.html#pre-and-post-render.Below are two versions of the same script: