OliverBalfour / obsidian-pandoc

Pandoc document export plugin for Obsidian (https://obsidian.md)
MIT License
717 stars 60 forks source link

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

Open naive231 opened 2 years ago

naive231 commented 2 years ago

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.

nanotubing commented 1 year ago

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

naive231 commented 1 year ago

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.😀

kevinpolisano commented 1 year ago

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...

naive231 commented 1 year ago

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.

ParkerRobb commented 1 year ago

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.

derKlinke commented 1 year ago

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 :)

naive231 commented 1 year ago

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: @.***>

GittyBruce commented 1 year ago

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.

naive231 commented 1 year ago

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: @.***>

MengjiaHe commented 1 year ago

Same issue with icloud path!

ParkerRobb commented 8 months ago

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

ParkerRobb commented 7 months ago

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 \.