* Org-publish and attachment links
@ 2024-08-11 2:40 Sébastien Gendre
2024-08-11 15:24 ` Ihor Radchenko
0 siblings, 1 reply; 5+ messages in thread
From: Sébastien Gendre @ 2024-08-11 2:40 UTC (permalink / raw)
To: General discussions about Org-mode
[-- Attachment #1: Type: text/plain, Size: 3711 bytes --]
Hello,
# TL;DR
When I export Org-mode documents with org-publish, it cannot resolve
links in format "[[attachment:image.png]]".
But when I export manually the same document with the export dispatcher,
the export work correctly and the attachment link is correctly resolved.
I don't know if it's a bug, or if it's planned to work like this and a
feature suggestion is needed. So, I post a message here.
# Context
I plan to write a little web documentation with Org-mode.
The documentation is split into multiple Org-mode files that I put into
a "./Pages/" folder.
Each org-mode document are converted to HTML with org-publish and the
function `org-html-publish-to-html`. The result is written into the
"./Public" folder.
And there is 2 kind of statics files:
* The ones needed on each pages, like the website logo or the CSS
* The files related to a specific page, like a screenshot
For the first kind, I have a "./Static/" folder which content is copied
to "./Public/static/" with org-publish and the function
`org-publish-attachment`.
For the second type, I use the Org-mode feature "attachment" to attach
each files into an Org-mode heading and (in my Org document) I write an
attachment link like these: [[attachment:image.png]]
[[attachment:code_template.tar.gz][Template of code]]
To publish these files, I also use org-publish and the function
`org-publish-attachment`. This time, from the folder "./Pages" to the
folder "./Public".
# How to replicate this problem
For this, I skip the CSS+JS folder.
1) Create directory called "test_documentation".
2) In "test_documentation/", create 1 directory:
* "Pages"
3) In "Page/", create 1 file named "Example.org"
4) In "Example.org", create a heading, attach a image file to it and
make an attachment link to this file (like "[[attachment:image.png]]")
5) In "test_documentation/", create a file named "publish.el" and write
this content in it:
;; Publish script for the website
;; Package load and configuration
;; Use org
(use-package org)
;; Use ox-publish
(use-package ox-publish)
;; Set publication configuration
(setq org-publish-project-alist
'(("pages-org"
:base-directory "./Pages/"
:base-extension "org"
:publishing-function org-html-publish-to-html
:publishing-directory "./public/")
("pages-attachment"
:base-directory "./Pages/"
:base-extension "jpg\\|png\\|gif\\|svg\\|zip"
:recursive t
:publishing-directory "./public/"
:publishing-function org-publish-attachment)))
;; Do the publication
(org-publish-all t)
6) Run this publish script with this command:
emacs -q --script publish.el
# What did I get
An error message:
Error: user-error ("Unable to resolve link: \"attachment:image.png\"")
mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode 0x181658ba93aef0da>))
debug-early-backtrace()
debug-early(error (user-error "Unable to resolve link: \"attachment:image.png\""))
user-error("Unable to resolve link: %S" "attachment:image.png")
org-export-data…
I cut from the org-export-data, because it is amazingly long and didn't
add any useful info.
# What did I expected
Attachment link would be resolved like with manual HTML export.
# Versions
* Emacs: 29.4
* Org-mode: 9.6.15
Best regards
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 849 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Org-publish and attachment links
2024-08-11 2:40 Org-publish and attachment links Sébastien Gendre
@ 2024-08-11 15:24 ` Ihor Radchenko
2024-08-11 19:52 ` Sébastien Gendre
0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2024-08-11 15:24 UTC (permalink / raw)
To: Sébastien Gendre; +Cc: General discussions about Org-mode
Sébastien Gendre <seb@k-7.ch> writes:
> # TL;DR
>
> When I export Org-mode documents with org-publish, it cannot resolve
> links in format "[[attachment:image.png]]".
>
> But when I export manually the same document with the export dispatcher,
> the export work correctly and the attachment link is correctly resolved.
>
> I don't know if it's a bug, or if it's planned to work like this and a
> feature suggestion is needed. So, I post a message here.
In your script, you do not load org-attach library. So, attachment:
links are simply not recognized.
> ;; Package load and configuration
>
> ;; Use org
> (use-package org)
>
> ;; Use ox-publish
> (use-package ox-publish)
Add (require 'org-attach) here.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Org-publish and attachment links
2024-08-11 15:24 ` Ihor Radchenko
@ 2024-08-11 19:52 ` Sébastien Gendre
2024-08-13 18:12 ` Ihor Radchenko
0 siblings, 1 reply; 5+ messages in thread
From: Sébastien Gendre @ 2024-08-11 19:52 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: General discussions about Org-mode
[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]
It work. Thank you very much.
I didn't know that org-attach have it's own library and that it was not
loaded with org. I found nothing about it in the Org-attach section of
the manual.
Ihor Radchenko <yantar92@posteo.net> writes:
> Sébastien Gendre <seb@k-7.ch> writes:
>
>> # TL;DR
>>
>> When I export Org-mode documents with org-publish, it cannot resolve
>> links in format "[[attachment:image.png]]".
>>
>> But when I export manually the same document with the export dispatcher,
>> the export work correctly and the attachment link is correctly resolved.
>>
>> I don't know if it's a bug, or if it's planned to work like this and a
>> feature suggestion is needed. So, I post a message here.
>
> In your script, you do not load org-attach library. So, attachment:
> links are simply not recognized.
>
>> ;; Package load and configuration
>>
>> ;; Use org
>> (use-package org)
>>
>> ;; Use ox-publish
>> (use-package ox-publish)
>
> Add (require 'org-attach) here.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 849 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Org-publish and attachment links
2024-08-11 19:52 ` Sébastien Gendre
@ 2024-08-13 18:12 ` Ihor Radchenko
2024-08-14 8:25 ` Sébastien Gendre
0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2024-08-13 18:12 UTC (permalink / raw)
To: Sébastien Gendre; +Cc: General discussions about Org-mode
Sébastien Gendre <seb@k-7.ch> writes:
> It work. Thank you very much.
>
> I didn't know that org-attach have it's own library and that it was not
> loaded with org. I found nothing about it in the Org-attach section of
> the manual.
Right. It is indeed confusing.
I now made export load org-attach by default.
Fixed, on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e52858fdb4
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Org-publish and attachment links
2024-08-13 18:12 ` Ihor Radchenko
@ 2024-08-14 8:25 ` Sébastien Gendre
0 siblings, 0 replies; 5+ messages in thread
From: Sébastien Gendre @ 2024-08-14 8:25 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: General discussions about Org-mode
[-- Attachment #1: Type: text/plain, Size: 510 bytes --]
Thank you very much.
Ihor Radchenko <yantar92@posteo.net> writes:
> Sébastien Gendre <seb@k-7.ch> writes:
>
>> It work. Thank you very much.
>>
>> I didn't know that org-attach have it's own library and that it was not
>> loaded with org. I found nothing about it in the Org-attach section of
>> the manual.
>
> Right. It is indeed confusing.
> I now made export load org-attach by default.
>
> Fixed, on bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e52858fdb4
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 849 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-08-14 8:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-11 2:40 Org-publish and attachment links Sébastien Gendre
2024-08-11 15:24 ` Ihor Radchenko
2024-08-11 19:52 ` Sébastien Gendre
2024-08-13 18:12 ` Ihor Radchenko
2024-08-14 8:25 ` Sébastien Gendre
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.