mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-23 07:18:53 +00:00
org-export: Fix previous/next element finding in secondary strings
* contrib/lisp/org-export.el (org-export-get-previous-element, org-export-get-next-element): Correctly retrieve previous and next object, if any, in secondary strings. * testing/lisp/test-org-export.el: Add tests.
This commit is contained in:
parent
32a6bae7c0
commit
32c3456020
@ -4463,7 +4463,19 @@ object, a string, or nil."
|
||||
(cond ((eq obj blob) (throw 'exit prev))
|
||||
((memq obj (plist-get info :ignore-list)))
|
||||
(t (setq prev obj))))
|
||||
(org-element-contents (org-export-get-parent blob))))))
|
||||
;; An object can belong to the contents of its parent or
|
||||
;; to a secondary string. We check the latter option
|
||||
;; first.
|
||||
(let ((parent (org-export-get-parent blob)))
|
||||
(or (and (not (memq (org-element-type blob)
|
||||
org-element-all-elements))
|
||||
(let ((sec-value
|
||||
(org-element-property
|
||||
(cdr (assq (org-element-type parent)
|
||||
org-element-secondary-value-alist))
|
||||
parent)))
|
||||
(and (memq blob sec-value) sec-value)))
|
||||
(org-element-contents parent)))))))
|
||||
|
||||
(defun org-export-get-next-element (blob info)
|
||||
"Return next element or object.
|
||||
@ -4474,7 +4486,18 @@ object, a string, or nil."
|
||||
(mapc (lambda (obj)
|
||||
(unless (memq obj (plist-get info :ignore-list))
|
||||
(throw 'found obj)))
|
||||
(cdr (memq blob (org-element-contents (org-export-get-parent blob)))))
|
||||
;; An object can belong to the contents of its parent or to
|
||||
;; a secondary string. We check the latter option first.
|
||||
(let ((parent (org-export-get-parent blob)))
|
||||
(or (and (not (memq (org-element-type blob)
|
||||
org-element-all-objects))
|
||||
(let ((sec-value
|
||||
(org-element-property
|
||||
(cdr (assq (org-element-type parent)
|
||||
org-element-secondary-value-alist))
|
||||
parent)))
|
||||
(cdr (memq blob sec-value))))
|
||||
(cdr (memq blob (org-element-contents parent))))))
|
||||
nil))
|
||||
|
||||
|
||||
|
@ -1251,7 +1251,34 @@ Another text. (ref:text)
|
||||
(org-element-map
|
||||
tree 'plain-text
|
||||
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
||||
info))))))
|
||||
info)))))
|
||||
;; Smart quotes in secondary strings.
|
||||
(should
|
||||
(equal '("“" "”")
|
||||
(let ((org-export-default-language "en"))
|
||||
(org-test-with-parsed-data "* \"$x$\""
|
||||
(org-element-map
|
||||
tree 'plain-text
|
||||
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
||||
info)))))
|
||||
;; Smart quotes in document keywords.
|
||||
(should
|
||||
(equal '("“" "”")
|
||||
(let ((org-export-default-language "en"))
|
||||
(org-test-with-parsed-data "#+TITLE: \"$x$\""
|
||||
(org-element-map
|
||||
(plist-get info :title) 'plain-text
|
||||
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
||||
info)))))
|
||||
;; Smart quotes in parsed affiliated keywords.
|
||||
(should
|
||||
(equal '("“" "”" "Paragraph")
|
||||
(let ((org-export-default-language "en"))
|
||||
(org-test-with-parsed-data "#+CAPTION: \"$x$\"\nParagraph"
|
||||
(org-element-map
|
||||
tree 'plain-text
|
||||
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
||||
info nil nil t))))))
|
||||
|
||||
|
||||
|
||||
@ -1817,7 +1844,29 @@ Another text. (ref:text)
|
||||
(let ((org-export-with-timestamps nil))
|
||||
(org-test-with-parsed-data "\alpha <2012-03-29 Thu>"
|
||||
(org-export-get-next-element
|
||||
(org-element-map tree 'entity 'identity info t) info)))))
|
||||
(org-element-map tree 'entity 'identity info t) info))))
|
||||
;; Find next element in secondary strings.
|
||||
(should
|
||||
(eq 'verbatim
|
||||
(org-test-with-parsed-data "* a =verb="
|
||||
(org-element-type
|
||||
(org-export-get-next-element
|
||||
(org-element-map tree 'plain-text 'identity info t) info)))))
|
||||
;; Find next element in document keywords.
|
||||
(should
|
||||
(eq 'verbatim
|
||||
(org-test-with-parsed-data "#+TITLE: a =verb="
|
||||
(org-element-type
|
||||
(org-export-get-next-element
|
||||
(org-element-map
|
||||
(plist-get info :title) 'plain-text 'identity info t) info)))))
|
||||
;; Find next element in parsed affiliated keywords.
|
||||
(should
|
||||
(eq 'verbatim
|
||||
(org-test-with-parsed-data "#+CAPTION: a =verb=\nParagraph"
|
||||
(org-element-type
|
||||
(org-export-get-next-element
|
||||
(org-element-map tree 'plain-text 'identity info t nil t) info))))))
|
||||
|
||||
(ert-deftest test-org-export/get-previous-element ()
|
||||
"Test `org-export-get-previous-element' specifications."
|
||||
@ -1837,7 +1886,29 @@ Another text. (ref:text)
|
||||
(let ((org-export-with-timestamps nil))
|
||||
(org-test-with-parsed-data "<2012-03-29 Thu> \alpha"
|
||||
(org-export-get-previous-element
|
||||
(org-element-map tree 'entity 'identity info t) info)))))
|
||||
(org-element-map tree 'entity 'identity info t) info))))
|
||||
;; Find previous element in secondary strings.
|
||||
(should
|
||||
(eq 'verbatim
|
||||
(org-test-with-parsed-data "* =verb= a"
|
||||
(org-element-type
|
||||
(org-export-get-previous-element
|
||||
(org-element-map tree 'plain-text 'identity info t) info)))))
|
||||
;; Find previous element in document keywords.
|
||||
(should
|
||||
(eq 'verbatim
|
||||
(org-test-with-parsed-data "#+TITLE: =verb= a"
|
||||
(org-element-type
|
||||
(org-export-get-previous-element
|
||||
(org-element-map
|
||||
(plist-get info :title) 'plain-text 'identity info t) info)))))
|
||||
;; Find previous element in parsed affiliated keywords.
|
||||
(should
|
||||
(eq 'verbatim
|
||||
(org-test-with-parsed-data "#+CAPTION: =verb= a\nParagraph"
|
||||
(org-element-type
|
||||
(org-export-get-previous-element
|
||||
(org-element-map tree 'plain-text 'identity info t nil t) info))))))
|
||||
|
||||
|
||||
(provide 'test-org-export)
|
||||
|
Loading…
Reference in New Issue
Block a user