obsidian-pandoc icon indicating copy to clipboard operation
obsidian-pandoc copied to clipboard

Spaces in the path of the source file(or destination) should be escaped

Open naive231 opened this issue 2 years ago • 12 comments

It reports failure like this:

Exporting /Users/zhounaihong/Library/Mobile Documents/iCloud~md~obsidian/Documents2nd_brain/note/2022-11-18.md to Word
Pandoc export failed: pandoc: /Users/naive231/Desktop/2022-11-18.docx: openBinaryFile: does not exist (No such file or directory)

I'm pretty sure that pandoc executive is in system path and I can convert the same document if I call pandoc in shell.

After some investigation, I figured out that the error is coming from the space in the path of the source file:

/Users/zhounaihong/Library/Mobile Documents/iCloud~md~obsidian/Documents2nd_brain/note/2022-11-18.md

If the space in Mobile and Docuemnts isn't escaped with \, pandoc in shell will result to the same error reported in obsidian.

Hope this bug can be fixed in next release, thanks in advanced.

naive231 avatar Nov 18 '22 05:11 naive231

I just ran into the same issue. Let me know if I can provide any information to help

nanotubing avatar Dec 02 '22 22:12 nanotubing

I just ran into the same issue. Let me know if I can provide any information to help

Yes, you can help to ask the author to fix it, just place the \ in front of his path variable or place additional " surround with his path variable in his source.😀

naive231 avatar Dec 03 '22 01:12 naive231

I have the same issue, since they said in Obsidian-Pandoc-Citations:

Note: it's also possible to put --metadata bibliography=/path/to/report.bib (without any quotes) on a new line in the Extra Pandoc arguments setting to save typing.

But without quotes we cannot escape spaces...

kevinpolisano avatar Dec 22 '22 17:12 kevinpolisano

Note: it's also possible to put --metadata bibliography=/path/to/report.bib (without any quotes) on a new line in the Extra Pandoc arguments setting to save typing.

I don't really understand what it means. What the metadata or bibliography options for? @OliverBalfour I think we just want an option to let us specified my own output path can solve this problem, and I think you don't need to spent too much efforts to dealt with the "space" problem at all. Maybe you should give this a shot.

naive231 avatar Dec 23 '22 00:12 naive231

I have the same problem. It appears that spaces cannot be escaped when entered in "Extra Pandoc arguments", meaning no filepaths can have spaces. I tried it on a filepath with no spaces and it works fine.

ParkerRobb avatar Jan 13 '23 22:01 ParkerRobb

I am having the same issue. As a temporary workaround, I created a symbolic link to my .bib file in my User folder and pass it to Pandoc. It would be cool though if this will be fixed in the future :)

derKlinke avatar Jan 26 '23 11:01 derKlinke

If I need to create a symbolic link to the file, I rather call pandoc directly to do its job. 😅

Fabian S. Klinke @.***> 於 2023年1月26日 週四 下午7:13寫道:

I am having the same issue. As a temporary workaround, I created a symbolic link to my .bib file in my User folder and pass it to Pandoc. It would be cool though if this will be fixed in the future :)

— Reply to this email directly, view it on GitHub https://github.com/OliverBalfour/obsidian-pandoc/issues/159#issuecomment-1404860753, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE6W6ZZHV4D7AYPZ35KDALWUJL55ANCNFSM6AAAAAASED5EBM . You are receiving this because you authored the thread.Message ID: @.***>

naive231 avatar Jan 26 '23 11:01 naive231

On Line 3356 of main.js, replace: extraParams = extraParams.flatMap((x) => x.split(" ")).filter((x) => x.length); with extraParams = extraParams.flatMap((x) => x).filter((x) => x.length);

And it'll work. Not sure why the the extraparameters value was being split at spaces anyways.

GittyBruce avatar May 02 '23 03:05 GittyBruce

I modified this .js: $vault_dir/plugins/obsidian-pandoc/main.js I don't actually confirm if that is right. And found following codes:

    // The metadata title is needed for ePub and standalone HTML formats
    // We use a metadata file to avoid being vulnerable to command

injection if (input.metadataFile) args.push('--metadata-file', input.metadataFile); // Extra parameters if (extraParams) { extraParams = extraParams.flatMap(x => x.split(' ')).filter(x => x.length); args.push(...extraParams); }

So, I replace this:

extraParams = extraParams.flatMap(x => x.split(' ')).filter(x => x.length);

with this:

extraParams = extraParams.flatMap((x) => x).filter((x) => x.length);

And then I restart the Obsidian to make sure everything should be reloaded. But I invoke "Pandoc Plugin: Export an Word Document (.docx)":

[image: image.png]

It still can't read my .md:

[image: image.png]

I don't know if anything else I should change?

On Tue, May 2, 2023 at 11:52 AM GittyBruce @.***> wrote:

On Line 3356, replace: extraParams = extraParams.flatMap((x) => x.split(" ")).filter((x) => x.length); with extraParams = extraParams.flatMap((x) => x).filter((x) => x.length);

And it'll work. Not sure why the the extraparameters value was being split at spaces anyways.

— Reply to this email directly, view it on GitHub https://github.com/OliverBalfour/obsidian-pandoc/issues/159#issuecomment-1530833336, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE6W66KYYNPY3KK55XPNMDXECAIRANCNFSM6AAAAAASED5EBM . You are receiving this because you authored the thread.Message ID: @.***>

naive231 avatar May 21 '23 09:05 naive231

Same issue with icloud path!

MengjiaHe avatar Oct 07 '23 14:10 MengjiaHe

Looks like #136, #113, #86, #77 all reference the same problem. Some of them provide workarounds.

ParkerRobb avatar Mar 28 '24 02:03 ParkerRobb

I modified this .js: $vault_dir/plugins/obsidian-pandoc/main.js I don't actually confirm if that is right. And found following codes: // The metadata title is needed for ePub and standalone HTML formats // We use a metadata file to avoid being vulnerable to command injection if (input.metadataFile) args.push('--metadata-file', input.metadataFile); // Extra parameters if (extraParams) { extraParams = extraParams.flatMap(x => x.split(' ')).filter(x => x.length); args.push(...extraParams); } So, I replace this: extraParams = extraParams.flatMap(x => x.split(' ')).filter(x => x.length); with this: extraParams = extraParams.flatMap((x) => x).filter((x) => x.length); And then I restart the Obsidian to make sure everything should be reloaded. But I invoke "Pandoc Plugin: Export an Word Document (.docx)": [image: image.png] It still can't read my .md: [image: image.png] I don't know if anything else I should change? On Tue, May 2, 2023 at 11:52 AM GittyBruce @.> wrote: On Line 3356, replace: extraParams = extraParams.flatMap((x) => x.split(" ")).filter((x) => x.length); with extraParams = extraParams.flatMap((x) => x).filter((x) => x.length); And it'll work. Not sure why the the extraparameters value was being split at spaces anyways. — Reply to this email directly, view it on GitHub <#159 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE6W66KYYNPY3KK55XPNMDXECAIRANCNFSM6AAAAAASED5EBM . You are receiving this because you authored the thread.Message ID: @.>

@naive231 I found that after making the modification suggested by GittyBruce, using the following form for the Extra Pandoc arguments works:

--defaults=/file path/with spaces/defaults.yaml

Note that there are no quote marks and the spaces are not escaped with \.

ParkerRobb avatar Apr 03 '24 02:04 ParkerRobb