ox: Fix next/previous element getters

* lisp/ox.el (org-export-get-previous-element,
  org-export-get-next-element): Fix return value for non plain text
  objects in a secondary string.
* testing/lisp/test-ox.el: Add tests.
This commit is contained in:
Nicolas Goaziou 2013-11-11 01:54:01 +01:00
parent ede82ccf93
commit 6cc028bf74
2 changed files with 22 additions and 16 deletions

View File

@ -5151,14 +5151,11 @@ all of them."
;; to a secondary string. We check the latter option ;; to a secondary string. We check the latter option
;; first. ;; first.
(let ((parent (org-export-get-parent blob))) (let ((parent (org-export-get-parent blob)))
(or (and (not (memq (org-element-type blob) (or (let ((sec-value (org-element-property
org-element-all-elements)) (cdr (assq (org-element-type parent)
(let ((sec-value org-element-secondary-value-alist))
(org-element-property parent)))
(cdr (assq (org-element-type parent) (and (memq blob sec-value) sec-value))
org-element-secondary-value-alist))
parent)))
(and (memq blob sec-value) sec-value)))
(org-element-contents parent)))) (org-element-contents parent))))
prev) prev)
(catch 'exit (catch 'exit
@ -5186,14 +5183,11 @@ them."
;; An object can belong to the contents of its parent or to ;; An object can belong to the contents of its parent or to
;; a secondary string. We check the latter option first. ;; a secondary string. We check the latter option first.
(let ((parent (org-export-get-parent blob))) (let ((parent (org-export-get-parent blob)))
(or (and (not (memq (org-element-type blob) (or (let ((sec-value (org-element-property
org-element-all-objects)) (cdr (assq (org-element-type parent)
(let ((sec-value org-element-secondary-value-alist))
(org-element-property parent)))
(cdr (assq (org-element-type parent) (cdr (memq blob sec-value)))
org-element-secondary-value-alist))
parent)))
(cdr (memq blob sec-value))))
(cdr (memq blob (org-element-contents parent)))))) (cdr (memq blob (org-element-contents parent))))))
next) next)
(catch 'exit (catch 'exit

View File

@ -2723,6 +2723,12 @@ Another text. (ref:text)
(org-element-type (org-element-type
(org-export-get-next-element (org-export-get-next-element
(org-element-map tree 'plain-text 'identity info t) info))))) (org-element-map tree 'plain-text 'identity info t) info)))))
(should
(eq 'verbatim
(org-test-with-parsed-data "* /italic/ =verb="
(org-element-type
(org-export-get-next-element
(org-element-map tree 'italic 'identity info t) info)))))
;; Find next element in document keywords. ;; Find next element in document keywords.
(should (should
(eq 'verbatim (eq 'verbatim
@ -2783,6 +2789,12 @@ Another text. (ref:text)
(org-element-type (org-element-type
(org-export-get-previous-element (org-export-get-previous-element
(org-element-map tree 'plain-text 'identity info t) info))))) (org-element-map tree 'plain-text 'identity info t) info)))))
(should
(eq 'verbatim
(org-test-with-parsed-data "* =verb= /italic/"
(org-element-type
(org-export-get-previous-element
(org-element-map tree 'italic 'identity info t) info)))))
;; Find previous element in document keywords. ;; Find previous element in document keywords.
(should (should
(eq 'verbatim (eq 'verbatim