add file head section

This commit is contained in:
2025-12-30 11:29:43 +01:00
parent c4db3450a9
commit 22cb1a0e4d

View File

@@ -93,6 +93,7 @@
(?r "As reStructuredText file" org-rst-export-to-rst))) (?r "As reStructuredText file" org-rst-export-to-rst)))
:options-alist :options-alist
'((:subtitle "SUBTITLE" nil nil parse) '((:subtitle "SUBTITLE" nil nil parse)
(:rst-head "RST_HEAD" nil org-rst-head newline)
(:rst-link-use-abs-url nil "rst-link-use-abs-url" org-rst-link-use-abs-url) (:rst-link-use-abs-url nil "rst-link-use-abs-url" org-rst-link-use-abs-url)
(:rst-metadata nil "rst-metadata" org-rst-metadata) (:rst-metadata nil "rst-metadata" org-rst-metadata)
(:rst-metadata-format nil nil org-rst-metadata-format) (:rst-metadata-format nil nil org-rst-metadata-format)
@@ -138,6 +139,25 @@
:type 'string) :type 'string)
(defcustom org-rst-head ""
"Org-wide head definitions for exported RST files.
This variable can contain the file-wide metadata.
As the value of this option simply gets inserted at the top of the RST
file, you can use it to add any arbitrary text to the header.
You can set this on a per-file basis using #+RST_HEAD:,
or for publication projects using the :rst-head property.
Example:
#+RST_HEAD: :orphan:"
:group 'org-export-rst
:type 'string)
;;;###autoload
(put 'org-rst-head 'safe-local-variable 'stringp)
(defcustom org-rst-link-org-files-as-rst t (defcustom org-rst-link-org-files-as-rst t
"Non-nil means make file links to `file.org' point to `file.rst'. "Non-nil means make file links to `file.org' point to `file.rst'.
When `org-mode' is exporting an `org-mode' file to reStructuredText, When `org-mode' is exporting an `org-mode' file to reStructuredText,
@@ -605,6 +625,7 @@ INFO is a plist used as a communication channel."
(subtitle (if with-title (subtitle (if with-title
(org-export-data (plist-get info :subtitle) info) (org-export-data (plist-get info :subtitle) info)
"")) ""))
(head (org-element-normalize-string (plist-get info :rst-head)))
(spec (org-rst-format-spec info)) (spec (org-rst-format-spec info))
(metadata (plist-get info :rst-metadata)) (metadata (plist-get info :rst-metadata))
(author (and (plist-get info :with-author) (author (and (plist-get info :with-author)
@@ -625,6 +646,7 @@ INFO is a plist used as a communication channel."
subtitle "\n" subtitle "\n"
subtitleline "\n") ""))) subtitleline "\n") "")))
(concat (concat
(when head (concat head "\n"))
(unless (string= title "") (unless (string= title "")
(concat (concat
title title