org-element: Fix parsing of objects of the same type in a single paragraph
* lisp/org-element.el (org-element--get-next-object-candidates): Fix parsing of objects of the same type in a single paragraph. * testing/lisp/test-org-element.el: Add tests.
This commit is contained in:
parent
c65abd8577
commit
b7c5cf5d44
|
@ -3886,7 +3886,13 @@ type, as a symbol.
|
||||||
|
|
||||||
OBJECTS is the previous candidates alist."
|
OBJECTS is the previous candidates alist."
|
||||||
;; Filter out any object found but not belonging to RESTRICTION.
|
;; Filter out any object found but not belonging to RESTRICTION.
|
||||||
(setq objects (org-remove-if-not (lambda (obj) (memq (car obj) restriction))
|
(setq objects
|
||||||
|
(org-remove-if-not
|
||||||
|
(lambda (obj)
|
||||||
|
(let ((type (car obj)))
|
||||||
|
(memq (or (cdr (assq type org-element-object-successor-alist))
|
||||||
|
type)
|
||||||
|
restriction)))
|
||||||
objects))
|
objects))
|
||||||
(let (next-candidates types-to-search)
|
(let (next-candidates types-to-search)
|
||||||
;; If no previous result, search every object type in RESTRICTION.
|
;; If no previous result, search every object type in RESTRICTION.
|
||||||
|
|
|
@ -1523,7 +1523,13 @@ Outside list"
|
||||||
(eq 'subscript
|
(eq 'subscript
|
||||||
(org-test-with-temp-text "- _b"
|
(org-test-with-temp-text "- _b"
|
||||||
(progn (search-forward "_")
|
(progn (search-forward "_")
|
||||||
(org-element-type (org-element-context)))))))
|
(org-element-type (org-element-context))))))
|
||||||
|
;; Multiple subscripts in a paragraph.
|
||||||
|
(should
|
||||||
|
(= 2
|
||||||
|
(org-test-with-temp-text "a_b and c_d"
|
||||||
|
(length
|
||||||
|
(org-element-map (org-element-parse-buffer) 'subscript 'identity))))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Superscript
|
;;;; Superscript
|
||||||
|
@ -1543,7 +1549,14 @@ Outside list"
|
||||||
(eq 'superscript
|
(eq 'superscript
|
||||||
(org-test-with-temp-text "- ^b"
|
(org-test-with-temp-text "- ^b"
|
||||||
(progn (search-forward "^")
|
(progn (search-forward "^")
|
||||||
(org-element-type (org-element-context)))))))
|
(org-element-type (org-element-context))))))
|
||||||
|
;; Multiple superscript in a paragraph.
|
||||||
|
(should
|
||||||
|
(= 2
|
||||||
|
(org-test-with-temp-text "a^b and c^d"
|
||||||
|
(length
|
||||||
|
(org-element-map
|
||||||
|
(org-element-parse-buffer) 'superscript 'identity))))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Table
|
;;;; Table
|
||||||
|
|
Loading…
Reference in New Issue