[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Org-publish and attachment links
From: |
Sébastien Gendre |
Subject: |
Org-publish and attachment links |
Date: |
Sun, 11 Aug 2024 04:40:21 +0200 |
User-agent: |
mu4e 1.12.1; emacs 29.4 |
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
signature.asc
Description: PGP signature
- Org-publish and attachment links,
Sébastien Gendre <=