OliverBalfour / obsidian-pandoc

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

pandoc cannot recognize image path #198

Open Anber55 opened 10 months ago

Anber55 commented 10 months ago

Currently, my Pandoc can export Word (with pictures) But there is a very critical problem. All my local pictures are placed in ./Documents/${filename} I don’t know what’s going on. Pandoc can’t find this directory, causing the picture to fail to be exported. But when I put the picture in the root directory, Pandoc can recognize it and export the Word with the picture successfully. I tried putting the image in a folder in the root directory but it still doesn't work. You can only put the image directly in the root directory, which is very inconvenient. Please give me some advice on how to make Pandoc recognize local images in other directories in i Cloud. Thanks.

FeralFlora commented 10 months ago

Where is the note you are exporting located?

rm20killer commented 10 months ago

I was also getting this issue. I have my note in ./20.0 Final Year Project/20.1 project stuff/Documents/First Deliverable/manuscript.md and have my images in ./20.0 Final Year Project/images/

aarontimo commented 10 months ago

I am experiencing a similar issue. When trying to export an advanced slides presentation to powerpoint I get the following error: image If I delete all images, the export works successfully.

davideriboli commented 10 months ago

Same here, but if I switch the Export files from HTML or markdown option from "markdown" (default value) to "HTML", images are back again.

aarontimo commented 9 months ago

I found converting the ![[name_of_image.png]] to worked for me.

northben commented 9 months ago

I encountered the issue as well, though I found a simple workaround.

change the image link from

![[Pasted image 20231213092700.png]]

to include the full path in your vault, like so

![[foo/bar/Pasted image 20231213092700.png]]

I am now able to export to docx format and it's beautiful. Thank you everyone!!

AlexLJordan commented 9 months ago

I have the same issue and am not willing to change my links from relative to absolute as northben suggests.

davideriboli's workaround of switching form "markdown" to "HTML" also did not work.

Hope this can be resolved sometime soon. Either way, thanks for the awesome plugin!

FeralFlora commented 9 months ago

I have the same issue and am not willing to change my links from relative to absolute as northben suggests.

davideriboli's workaround of switching form "markdown" to "HTML" also did not work.

Hope this can be resolved sometime soon. Either way, thanks for the awesome plugin!

It has been resolved since version 3.1.7 of Pandoc. To export wikilink images with Pandoc, you just need to:

  1. Add an extension to the input format
    1. The trick is to add the wikilinks_title_after_pipe extension, so it becomes: -f markdown+wikilinks_title_after_pipe
      1. (Optionally), you can also add mark extension to support ==markdown highligths==.
      2. And (optionally) the lists_without_preceding_blankline extension to support what it sounds like.
      3. Altogether, it becomes: -f markdown+wikilinks_title_after_pipe+mark+lists_without_preceding_blankline
  2. Specify the resource path to your attachment folder like so:
    1. --resource-path=Absolute/Path/To/Attachment/Folder

You add these arguments to the Extra arguments field of the Pandoc plugin.

A caveat is that you can't use link attributes to specify the image size on wikilink images, as you can with markdown linked images. If you would like to see this supported, add your voice here: https://github.com/jgm/pandoc/issues/9048

In any case, I would advise people to migrate away from the Pandoc plugin to the Enhancing export plugin, which also integrates Pandoc. Unlike the Pandoc plugin, it's not abandoned and buggy. It should be easier and more reliable to set this up there.

northben commented 9 months ago

the Enhancing Export plugin looks nice but for me it didn't export images at all, it just exported the markdown format for the image links. The .docx file has "![[the filename.docx]]" where it should have an image.

notuntoward commented 6 months ago

My work computer is Mac and my home computer is Windows, so absolute paths to images aren't usable. And, even if I was on the same OS everywhere, I have images stored in the attachments folders under each obsidian folder -- I can't set a global path to images. Individually hand coding image paths, etc., just drives me to skip Obsidian, and to simply use Latex, PowerPoint, Word or whatever.

But doesn't Pandoc Plugin have the info needed to handle image paths automatically? Obsidian itself can find those images with no user intervention, and so can Obsidian's built-in Export to PDF command.

InnocenseYu commented 5 months ago

I have the same issue and am not willing to change my links from relative to absolute as northben suggests. davideriboli's workaround of switching form "markdown" to "HTML" also did not work. Hope this can be resolved sometime soon. Either way, thanks for the awesome plugin!

It has been resolved since version 3.1.7 of Pandoc. To export wikilink images with Pandoc, you just need to:

1. Add an extension to the input format

   1. The trick is to add the `wikilinks_title_after_pipe` [extension](https://pandoc.org/MANUAL.html#extension-wikilinks_title_after_pipe), so it becomes:
      `-f markdown+wikilinks_title_after_pipe`
   2. (Optionally), you can also add `mark` [extension](https://pandoc.org/MANUAL.html#extension-mark) to support ==markdown highligths==.
   3. And (optionally) the `lists_without_preceding_blankline` [extension](https://pandoc.org/MANUAL.html#extension-mark) to support what it sounds like.
   4. Altogether, it becomes:
      `-f markdown+wikilinks_title_after_pipe+mark+lists_without_preceding_blankline`

2. Specify the resource path to your attachment folder like so:

   1. `--resource-path=Absolute/Path/To/Attachment/Folder`

You add these arguments to the Extra arguments field of the Pandoc plugin.

A caveat is that you can't use link attributes to specify the image size on wikilink images, as you can with markdown linked images. If you would like to see this supported, add your voice here: jgm/pandoc#9048

In any case, I would advise people to migrate away from the Pandoc plugin to the Enhancing export plugin, which also integrates Pandoc. Unlike the Pandoc plugin, it's not abandoned and buggy. It should be easier and more reliable to set this up there.

I have the same issue and am not willing to change my links from relative to absolute as northben suggests. davideriboli's workaround of switching form "markdown" to "HTML" also did not work. Hope this can be resolved sometime soon. Either way, thanks for the awesome plugin!

It has been resolved since version 3.1.7 of Pandoc. To export wikilink images with Pandoc, you just need to:

1. Add an extension to the input format

   1. The trick is to add the `wikilinks_title_after_pipe` [extension](https://pandoc.org/MANUAL.html#extension-wikilinks_title_after_pipe), so it becomes:
      `-f markdown+wikilinks_title_after_pipe`
   2. (Optionally), you can also add `mark` [extension](https://pandoc.org/MANUAL.html#extension-mark) to support ==markdown highligths==.
   3. And (optionally) the `lists_without_preceding_blankline` [extension](https://pandoc.org/MANUAL.html#extension-mark) to support what it sounds like.
   4. Altogether, it becomes:
      `-f markdown+wikilinks_title_after_pipe+mark+lists_without_preceding_blankline`

2. Specify the resource path to your attachment folder like so:

   1. `--resource-path=Absolute/Path/To/Attachment/Folder`

You add these arguments to the Extra arguments field of the Pandoc plugin.

A caveat is that you can't use link attributes to specify the image size on wikilink images, as you can with markdown linked images. If you would like to see this supported, add your voice here: jgm/pandoc#9048

In any case, I would advise people to migrate away from the Pandoc plugin to the Enhancing export plugin, which also integrates Pandoc. Unlike the Pandoc plugin, it's not abandoned and buggy. It should be easier and more reliable to set this up there.

Thank you for your detailed guidance. The setting of --resource-path parameter can normally export the picture, tables can be numbered normally, but pictures cannot, there is an error message: Undefined cross-reference: fig: figure2

image

as shown in the figure, the system runs the panrun command, it seems that the wikilinks_title_after_pipe extension does not work. Is there a conflict where extensions are disabled

here is my yaml file:

output:
  docx:
    standalone: true
    embed-resources: true
    from: markdown+wikilinks_title_after_pipe+mark+autolink_bare_uris+lists_without_preceding_blankline
    to: docx
    output: output.docx
    lua-filter: 
      - image.lua
      - codeblock.lua
      - math.lua
      - link.lua
    filter: pandoc-crossref
    citeproc: true
    top-level-division: chapter
    toc: true
linkReferences: true
codeBlockCaptions: true
chapters: true
chapDelim: '-'
numberSections: true
sectionsDepth: 3
titleDelim: ' '
figPrefixTemplate: |
  $$p$$ -$$i$$
tableTemplate: |
  *$$tableTitle$$$$i$$*$$titleDelim$$$$t$$
figureTemplate: |
  $$figureTitle$$$$i$$$$titleDelim$$$$t$$
reference-doc: reference.docx
bibliography: ref.bib
csl: xxx.csl
link-citations: true
reference-section-title: xxx
toc-title: xxx
abstract-title: |
  xxx
abstract: |
  xxx

wikilinks method of use: [[url|title]] and ![[picture_name.jpg|title]]

command run in powershell 5: panrun test\input.md --resource-path='test;meta\attachment\input

pandoc --version:

pandoc.exe 3.1.12.3
Features: +server +lua
Scripting engine: Lua 5.4

pandoc-crossref --version:

pandoc-crossref v0.3.17.0 git commit 2dfb0d554dddbe66b2253f10d0978adb13435d82 (HEAD) built with Pandoc v3.1.12.3, pandoc-types v1.23.1 and GHC 9.6.4
afganrasulov commented 1 month ago

Found the solution

I had the same problem, and I think I found the solution. I recorded a video to help you out. Here is the link: https://youtu.be/pKawg6mPWE4

42Willow commented 1 month ago

Found the solution

I had the same problem, and I think I found the solution. I recorded a video to help you out. Here is the link: https://youtu.be/pKawg6mPWE4

@afganrasulov Thanks for the video, find and replace is ctrl + h by the way