emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 5e9953fa0e: ox.el: Refactor ID prefixes


From: ELPA Syncer
Subject: [elpa] externals/org 5e9953fa0e: ox.el: Refactor ID prefixes
Date: Wed, 5 Apr 2023 05:58:17 -0400 (EDT)

branch: externals/org
commit 5e9953fa0ea9023786e62d83e12653d4aadfa869
Author: Feraidoon Mehri <feraidoonmehri@gmail.com>
Commit: Ihor Radchenko <yantar92@posteo.net>

    ox.el: Refactor ID prefixes
    
    * lisp/ox-html.el (org-html--id-attr-prefix):
    * lisp/ox-odt.el (org-odt--id-attr-prefix): Refactor hardcoded "ID-"
    as a new private variable.
    
    * org/ox-html.el (org-html--reference): Add support for the ID
    property (previously only supported CUSTOM_ID).
    
    These changes make crossfile ID links work in the exported HTML when
    `org-html-prefer-user-labels' is not-nil.
---
 lisp/ox-html.el | 24 ++++++++++++++++--------
 lisp/ox-odt.el  |  6 +++++-
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index f1258d3850..b51718c8da 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -239,6 +239,10 @@ property on the headline itself.")
     ("\\.\\.\\." . "&#x2026;"))                ; hellip
   "Regular expressions for special string conversion.")
 
+(defvar org-html--id-attr-prefix "ID-"
+  "Prefix to use in ID attributes.
+This affects IDs that are determined from the ID property.")
+
 (defcustom org-html-scripts
   "<script>
 // @license 
magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&amp;dn=gpl-3.0.txt 
GPL-v3-or-Later
@@ -1719,18 +1723,22 @@ When NAMED-ONLY is non-nil and DATUM has no NAME 
keyword, return
 nil.  This doesn't apply to headlines, inline tasks, radio
 targets and targets."
   (let* ((type (org-element-type datum))
+        (custom-id (and (memq type '(headline inlinetask))
+                        (org-element-property :CUSTOM_ID datum)))
         (user-label
-         (org-element-property
-          (pcase type
-            ((or `headline `inlinetask) :CUSTOM_ID)
-            ((or `radio-target `target) :value)
-            (_ :name))
-          datum)))
+         (or
+          custom-id
+          (and (memq type '(radio-target target))
+               (org-element-property :value datum))
+          (org-element-property :name datum)
+          (when-let ((id (org-element-property :ID datum)))
+            (concat org-html--id-attr-prefix id)))))
+
     (cond
      ((and user-label
           (or (plist-get info :html-prefer-user-labels)
               ;; Used CUSTOM_ID property unconditionally.
-              (memq type '(headline inlinetask))))
+              custom-id))
       user-label)
      ((and named-only
           (not (memq type '(headline inlinetask radio-target target)))
@@ -3281,7 +3289,7 @@ INFO is a plist holding contextual information.  See
        (pcase (org-element-type destination)
          ;; ID link points to an external file.
          (`plain-text
-          (let ((fragment (concat "ID-" path))
+          (let ((fragment (concat org-html--id-attr-prefix path))
                 ;; Treat links to ".org" files as ".html", if needed.
                 (path (funcall link-org-files-as-html-maybe
                                destination info)))
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 2288d56369..09cd1ec584 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -148,6 +148,10 @@
 
 ;;; Internal Variables
 
+(defvar org-odt--id-attr-prefix "ID-"
+  "Prefix to use in ID attributes.
+This affects IDs that are determined from the ID property.")
+
 (defconst org-odt-lib-dir
   (file-name-directory (or load-file-name (buffer-file-name)))
   "Location of ODT exporter.
@@ -1775,7 +1779,7 @@ holding contextual information."
           ;; Extra targets.
           (extra-targets
            (let ((id (org-element-property :ID headline)))
-             (if id (org-odt--target "" (concat "ID-" id)) "")))
+             (if id (org-odt--target "" (concat org-odt--id-attr-prefix id)) 
"")))
           ;; Title.
           (anchored-title (org-odt--target full-text id)))
       (cond



reply via email to

[Prev in Thread] Current Thread [Next in Thread]