hunyadi / md2conf

Publish Markdown files to Confluence wiki
MIT License
56 stars 31 forks source link

I don't get the right URL after conversion #72

Closed kpallade closed 1 week ago

kpallade commented 1 week ago

Hello,

I'm trying to convert a markdown file with this code:

test.md:

<!-- confluence-page-id: 000000 -->
# Logo

![Wikipedia logo](https://fr.wikipedia.org/static/images/icons/wikipedia.png "Wikipedia logo")

I use this command to generate the .csf file locally:

python3 -m md2conf --no-generated-by --local test.md

And I get this result:

test.csf:

<h1>Logo</h1><ac:image ac:align="center" ac:layout="center"><ri:attachment ri:filename="https___fr.wikipedia.org_static_images_icons_wikipedia.png"/><ac:caption><p>Wikipedia logo</p></ac:caption></ac:image>

In the file url, the ":" and "/" has been replaced with "_". So the image does not appear in my confluence page :(

Do someone has encounter this issue and find a way to solved it ?

Thank you.

My environment: Python version: 3.10.12 md2conf version: 0.2.5

hunyadi commented 1 week ago

As far as I am aware, the element ac:image in Confluence wiki has a limitation that you can reference images uploaded as attachments but can't reference remote images on the public web. (The inner element ri:attachment hints at this behavior. ri:filename expects a file name without a path, which is why the directory separator / is replaced with _.) As such, md2conf automatically uploads referenced images it finds in the same directory or directory hierarchy where the Markdown source is found. Unfortunately, it cannot currently download images from the web, and then upload them to Confluence as an attachment, partly as a security precaution. You must download the image manually, and reference the image in the Markdown file with a relative URL, e.g.

![Wikipedia logo](wikipedia.png "Wikipedia logo")
hunyadi commented 1 week ago

More robust error handling and more informative exception text has been added in md2conf version 0.2.6 to ensure that image files in Markdown are referenced with relative URLs when they are to be published to Confluence wiki.

hunyadi commented 5 days ago

Linking to images hosted externally via a full URL is now possible with either of the following syntaxes:

![External image](http://confluence.atlassian.com/images/logo/confluence_48_trans.png)

<img src="http://confluence.atlassian.com/images/logo/confluence_48_trans.png" width="24" height="24" />