Skip to content

Commit

Permalink
Adding ability to specify additional pandoc arguments in the frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
jvsteiner committed May 15, 2024
1 parent 68ff9e3 commit 9976ed3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ export default class PandocPlugin extends Plugin {

async startPandocExport(inputFile: string, format: OutputFormat, extension: string, shortName: string) {
new Notice(`Exporting ${inputFile} to ${shortName}`);

const noteFile = this.app.workspace.getActiveFile();
let fm = this.app.metadataCache.getFileCache(noteFile)?.frontmatter;
let extraArguments = [];
if (fm && fm["additional-pandoc-arguments"]) {
extraArguments.push(...fm["additional-pandoc-arguments"]);
}
extraArguments.push(...this.settings.extraArguments.split("\n"));

// Instead of using Pandoc to process the raw Markdown, we use Obsidian's
// internal markdown renderer, and process the HTML it generates instead.
// This allows us to more easily deal with Obsidian specific Markdown syntax.
Expand Down Expand Up @@ -123,7 +130,7 @@ export default class PandocPlugin extends Plugin {
directory: path.dirname(inputFile),
},
{ file: outputFile, format },
this.settings.extraArguments.split('\n')
extraArguments
);
error = result.error;
command = result.command;
Expand All @@ -138,7 +145,7 @@ export default class PandocPlugin extends Plugin {
directory: path.dirname(inputFile),
},
{ file: outputFile, format },
this.settings.extraArguments.split('\n')
extraArguments
);
error = result.error;
command = result.command;
Expand Down

0 comments on commit 9976ed3

Please sign in to comment.