Hello,

I have attached, to this e-mail, the corrected patch that include your requests.


Ihor Radchenko <yanta...@posteo.net> writes:

> This makes sense.
> In fact, it may be a good idea to go through all the built-in backends
> and provide OPTIONS/KEYWORD values for more export options.

I could do that, at least for the HTML backend. And maybe the LaTeX one.

Is it possible for an option to have an OPTIONS and a KEYWORD ?

For example the preamble. It already have an OPTION, but it's mostly to
enable/disable it with `t' or `nil'. And maybe set it to a function
name. But if a user want to set a preamble as a multi-lines string, it
could be difficult with an OPTION.

Maybe I can modify the preamble option to accept a file as a value. Like
`(file "./preamble.html")'. If the file is an HTML, it's content is used
in the preamble. If the file is an Org-mode file, it's body only is
exported as HTML and then it is inserted as the preamble. And same with
the postamble. What do you think.


PS: I am still working on the search engine support for Org-publish to
HTML. But I wanted to understand more how the Export/Pubilsh work
before.

From ea9e592445714e00e4e57fe28bc2c144b6c3234c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gendre?= <s...@k-7.ch>
Date: Fri, 18 Apr 2025 18:18:12 +0200
Subject: [PATCH] lisp/ox-html.el: Add file level option to manage headlines
 self link

* lisp/ox-html.el (html): In the backend options-alist, add an OPTION
name to the option key `:html-self-link-headlines'.  The new OPITON
name is `html-self-link-headlines'.

* doc/org-manual.org (Headlines in HTML export): Update this manual
section to talk about the new file level option
`html-self-link-headlines'.  Rewrite the paragraph.

* etc/ORG-NEWS (New and changed options): Add a sub-section to talk
about the new file level option `html-self-link-headlines'.

TINYCHANGE
---
 doc/org-manual.org | 14 +++++++++++---
 etc/ORG-NEWS       | 10 ++++++++++
 lisp/ox-html.el    |  2 +-
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 360260149..d9a9beb21 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -13617,9 +13617,17 @@ Headlines are exported to =<h1>=, =<h2>=, etc.  Each headline gets the
 see [[*Internal Links]].
 
 #+vindex: org-html-self-link-headlines
-When ~org-html-self-link-headlines~ is set to a non-~nil~ value, the
-text of the headlines is also wrapped in =<a>= tags.  These tags have
-a =href= attribute making the headlines link to themselves.
+Headlines can contain a link to themselves.  To enable it, you have 2 ways:
+
+- Set the variable ~org-html-self-link-headlines~ to a non-~nil~ value
+- In an org-mode file, use an =#+OPTIONS= line to set
+  ~html-self-link-headlines~ to a non-~nil~ value
+
+
+#+texinfo: @noindent
+When enabled, the text of the headlines is wrapped in =<a>= tags.
+These tags have a =href= attribute making the headlines link to
+themselves.
 
 *** Links in HTML export
 :PROPERTIES:
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 982bac4e9..37d7db68b 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -313,6 +313,16 @@ slide to specific animation steps.
 This text will be displayed on animation step 2 and later.
 #+END_SRC
 
+*** ox-html: Headline self links can be enabled from an Org-mode file
+
+Previously HTML export could add, to each headline, a link to itself.
+To enable it, you had to use the variable
+~org-html-self-link-headlines~.
+
+Now, it's also possible to enable it per Org-mode file by adding:
+: #+OPTIONS: html-self-link-headlines:t
+
+
 *** ox-latex: Table of contents generation has been fixed and augmented
 
 The LaTeX exporter differs from other exporters in that it *does not*
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 2f4ec12e2..026a93735 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -161,7 +161,7 @@
     (:html-postamble-format nil nil org-html-postamble-format)
     (:html-preamble-format nil nil org-html-preamble-format)
     (:html-prefer-user-labels nil nil org-html-prefer-user-labels)
-    (:html-self-link-headlines nil nil org-html-self-link-headlines)
+    (:html-self-link-headlines nil "html-self-link-headlines" org-html-self-link-headlines)
     (:html-table-align-individual-fields
      nil nil org-html-table-align-individual-fields)
     (:html-table-caption-above nil nil org-html-table-caption-above)
-- 
2.49.0

Attachment: signature.asc
Description: PGP signature

Reply via email to