Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra Pandoc Arguments do not recognise " or ' and mess up with directory paths and export fails. #136

Open
vasilisniaouris opened this issue Aug 31, 2022 · 2 comments · May be fixed by #211

Comments

@vasilisniaouris
Copy link

vasilisniaouris commented Aug 31, 2022

Hello! First off I would like to thank you for this plugin, it has been of great use to me and so many others.

In the plugin settings, when you type Extra Pandoc Arguments, the conversion between the string and the actual command (line ~310 in the main.js file) is faulty. The " and ' are not applied properly, and the spaces essentially separate a single command in two.

I will give an example from your examples. Let's say we typed --bibliography "Zotero Exports\My Library.json". This would run
--bibliography "Zotero which does not exist, and the export will fail.

I found a work around for myself, and since I do not know any Java Script, I do think there are better ways of doing this. Specifically, I changed:

if (extraParams) {
    extraParams = extraParams.flatMap(x => x.split(' ')).filter(x => x.length);
    args.push(...extraParams);
}

to:

if (extraParams) {
    for (let i = 0; i < extraParams.length; i++) {
        let extraParam = extraParams[i].split('=');
        args.push(extraParam[0], extraParam[1]);
              }
}

This way you can only add arguments as --template=letter.tex (so the = is mandatory) and separate them by new lines, not spaces. Now you do not have a problem with --bibliography=Zotero Exports\My Library.json, meaning that even in a weird format, you get the full functionality of the argument settings.

I am hoping that with this issue report, we will eventually find a better work around on the main topic of " and '.

P.S. For extra ease, when calling pandoc, instead of passing the extra arguments as (line ~ 11280) this.settings.extraArguments.split('\n'), I pass them as this.settings.extraArguments.replace('$VAULT_PATH$', this.vaultBasePath()).split('\n'), allowing me to use the vault path, without writing it out. It would be a cool feature to add to later releases. This way I can define a new --data-dir=$VAULT_PATH\.pandoc for pandoc, which will be saved in the local vault folder and better reflects Obsidian's mentality of having everything local and in the same folder. I am sorry for getting slightly off topic with this.

@luoxiaobatman
Copy link

same issue here. Arguments parser doesn't respect " or '.

@kitchokly
Copy link

I'm having the same issue. Would love to see this fixed. Thanks for the workaround in the meanwhile!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants