branch: externals/org
commit a1beb4028df42f8a468f918c7caf49359c4bfecb
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>

    ox: Respect all the markup filters in ALT_TITLE
    
    * lisp/ox.el (org-export--annotate-info): Parse ALT_TITLE properties
    inside the tree before we pass everything through the tree filters and
    account for :with-* export options.  Previously, ALT_TITLE were parsed
    during the runtime, making it ignore backend-specific
    filters (e.g. `org-latex-math-block-tree-filter') and global
    :with-emphasize/:with-entities/etc options.
    (org-export-get-alt-title): Account for :ALT_TITLE being guaranteed to
    be parsed.
    * testing/lisp/test-ox.el (org-test-with-parsed-data): Use
    `org-export--annotate-info' rather than re-creating its effects
    ad-hoc.  This macro has been written before relevant processing has
    been factored out into `org-export--anotate-info'.  Now, we can simply
    re-use it.
    
    Reported-by: Trevor Murphy <[email protected]>
    Link: 
https://orgmode.org/list/CA+MaCJfR0S8rWEhu_2NK+Jf0T=c-mtm9js+obs_+wr2nudp...@mail.gmail.com
---
 lisp/ox.el              | 17 +++++++++++++----
 testing/lisp/test-ox.el | 17 +++++++----------
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index b3e698ba5c..fe5157aed6 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3162,6 +3162,17 @@ still inferior to file-local settings."
           (when result (setq info result)))))
     ;; Parse buffer.
     (setq tree (org-element-parse-buffer nil visible-only 'defer))
+    ;; Force parsing ALT_TITLE property of headlines.
+    (org-element-map tree '(headline inlinetask)
+      (lambda (h)
+        (when-let* ((alt-title (org-element-property :ALT_TITLE h)))
+          (org-element-put-property
+           h :ALT_TITLE
+           (org-element-parse-secondary-string
+           alt-title (org-element-restriction 'headline) h))
+          (org-element-put-property
+           h :secondary
+           (cons :ALT_TITLE (org-element-property :secondary h))))))
     ;; Prune tree from non-exported elements and transform
     ;; uninterpreted elements or objects in both parse tree and
     ;; communication channel.
@@ -4252,10 +4263,8 @@ fail, the fall-back value is \"???\"."
 (defun org-export-get-alt-title (headline _)
   "Return alternative title for HEADLINE, as a secondary string.
 If no optional title is defined, fall-back to the regular title."
-  (let ((alt (org-element-property :ALT_TITLE headline)))
-    (if alt (org-element-parse-secondary-string
-            alt (org-element-restriction 'headline) headline)
-      (org-element-property :title headline))))
+  (or (org-element-property :ALT_TITLE headline)
+      (org-element-property :title headline)))
 
 (defun org-export-first-sibling-p (blob info)
   "Non-nil when BLOB is the first sibling in its parent.
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index 6a2b46943b..e9d9a06f7e 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -45,17 +45,14 @@ body to execute.  Parse tree is available under the `tree'
 variable, and communication channel under `info'."
   (declare (debug (form body)) (indent 1))
   `(org-test-with-temp-text ,data
-     (org-export--delete-comment-trees)
-     (let* ((tree (org-element-parse-buffer))
-           (info (org-combine-plists
+     (let* ((org-export-process-citations nil) ; implict assumption in some 
tests
+            (info (org-combine-plists
                   (org-export--get-export-attributes)
-                  (org-export-get-environment))))
-       (org-export--prune-tree tree info)
-       (org-export--remove-uninterpreted-data tree info)
-       (let ((info (org-combine-plists
-                   info (org-export--collect-tree-properties tree info))))
-        (ignore info) ;; Don't warn if the var is unused.
-        ,@body))))
+                  (org-export--get-buffer-attributes)))
+            (info (org-export--annotate-info (org-export-create-backend) info))
+            (tree (plist-get info :parse-tree)))
+       (ignore tree) ;; Don't warn if the var is unused.
+       ,@body)))
 
 
 

Reply via email to