emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 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

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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).