crossnote
crossnote copied to clipboard
Feature Request: Specify output directory
Perhaps this is already a feature somewhere that I've overlooked, but is it possible to specify the output directory and filename when running the various engine.export functions?
Right now it seems to put the output file in the same directory as the input file. In my case, the situation is something like this:
const engine = new mume.MarkdownEngine({
filePath: "/some/directory/file.md",
config: config
});
const result = await engine.htmlExport({ offline: false, runAllCodeChunks: true });
// Produces "/some/directory/file.html"
There's probably no option to configure this at the moment. @shd101wyy have I missed something too?
No it is not possible to specify the output directory (path) now. But we will support it in the future.
I may be able to help with this somehow - am I correct in thinking that it would just require passing in a filename and setting the dest
parameter at the bottom here? https://github.com/shd101wyy/mume/blob/95533b5f4e671e9011231e4359544866f18d7584/src/markdown-engine.ts#L1517-L1545
Like perhaps something like this instead?
public async htmlExport({
offline = false,
runAllCodeChunks = false,
outputDirectory = null // Changed
}): Promise<string> {
const inputString = await utility.readFile(this.filePath, {
encoding: "utf-8",
});
let html;
let yamlConfig;
({ html, yamlConfig } = await this.parseMD(inputString, {
useRelativeFilePath: true,
hideFrontMatter: true,
isForPreview: false,
runAllCodeChunks,
}));
const htmlConfig = yamlConfig["html"] || {};
if ("offline" in htmlConfig) {
offline = htmlConfig["offline"];
}
const embedLocalImages = htmlConfig["embed_local_images"]; // <= embedLocalImages is disabled by default.
let embedSVG = true; // <= embedSvg is enabled by default.
if ("embed_svg" in htmlConfig) {
embedSVG = htmlConfig["embed_svg"];
}
let dest = outputDirectory || this.filePath; // Changed
const extname = path.extname(dest);
dest = dest.replace(new RegExp(extname + "$"), ".html");
With the intended use just being something like
await engine.htmlExport({
offline: false,
runAllCodeChunks: true,
outputDirectory: "/home/someuser/somedirectory"
});
Hi @dzackgarza yes you are correct. But dest
should be the path of file, not directory.
It would be great if someone could could submit a pull request, as I am super busy recently :(
+1
@shd101wyy
Hi @dzackgarza yes you are correct. But dest should be the path of file, not directory. It would be great if someone could could submit a pull request, as I am super busy recently :(
I think it's time to consider the scan of the entire directory and the output of the entire directory. The input and output path of a single file does not make much sense.
@dzackgarza was doing great.
This is working when using the following front-matter in your md file:
---
export_on_save:
markdown: true
markdown:
path: your_file_name.md
absolute_image_path: false
---