Browse Source

org-element: Fix export of LaTeX math in headlines

* lisp/org-element.el (org-element-class): Find pseudo-objects in
  secondary strings.
* testing/lisp/test-org-element.el (test-org-element/class): Add test.

This bug was introduced in 1a88cf920e5090c311f77ba3f74183aa51253fb5.

Reported-by: Stefanos Carlström <stefanos.carlstrom@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/109922>
Nicolas Goaziou 2 years ago
parent
commit
4f9ec1adeb
2 changed files with 8 additions and 1 deletions
  1. 1 0
      lisp/org-element.el
  2. 7 1
      testing/lisp/test-org-element.el

+ 1 - 0
lisp/org-element.el

@@ -539,6 +539,7 @@ value of DATUM `:parent' property."
       (let ((parent-type (org-element-type parent)))
 	(cond ((not parent-type) 'object)
 	      ((memq parent-type org-element-object-containers) 'object)
+	      ((org-element-secondary-p datum) 'object)
 	      (t 'element)))))))
 
 (defsubst org-element-adopt-elements (parent &rest children)

+ 7 - 1
testing/lisp/test-org-element.el

@@ -156,7 +156,13 @@ Some other text
   ;; Pseudo objects.
   (should (eq 'object (org-element-class '(foo nil) '(bold nil))))
   (should (eq 'object (org-element-class '(foo nil) '(paragraph nil))))
-  (should (eq 'object (org-element-class '(foo nil) '("secondary")))))
+  (should (eq 'object (org-element-class '(foo nil) '("secondary"))))
+  (should
+   (eq 'object
+       (let* ((datum '(foo nil))
+	      (headline `(headline (:title (,datum)))))
+	 (org-element-put-property datum :parent headline)
+	 (org-element-class datum)))))
 
 (ert-deftest test-org-element/adopt-elements ()
   "Test `org-element-adopt-elements' specifications."