summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-09-12 15:40:13 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2012-09-12 15:45:10 +0200
commitf969e24a4317eac2f3a7c14c565ae260f2877e3a (patch)
tree3e88eae19edb70556cb177cae6dc4ee4b059e351
parentcdc1db5fda8427ecc5eead1a1be99571f71bb71f (diff)
downloadorg-mode-f969e24a4317eac2f3a7c14c565ae260f2877e3a.tar.gz
org-element: Fix parsing for items/footnote definitions starting with special syntax
* lisp/org-element.el (org-element--current-element): At the very beginning of a footnote definition or an item, next element is always a paragraph. * testing/lisp/test-org-element.el: Add tests. This patch fixes parsing for following cases: - - text or [fn:1] # Some text
-rw-r--r--lisp/org-element.el3
-rw-r--r--testing/lisp/test-org-element.el14
2 files changed, 15 insertions, 2 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 456ed15..3c6bbe5 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3348,6 +3348,9 @@ element it has to parse."
(org-element-section-parser
(or (save-excursion (org-with-limited-levels (outline-next-heading)))
limit)))
+ ;; When not at bol, point is at the beginning of an item or
+ ;; a footnote definition: next item is always a paragraph.
+ ((not (bolp)) (org-element-paragraph-parser limit))
;; Planning and Clock.
((and (looking-at org-planning-or-clock-line-re))
(if (equal (match-string 1) org-clock-string)
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index eb0578d..8aa24b2 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -631,7 +631,11 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"
(org-test-with-temp-text "[fn:1] Definition\n| a | b |"
(org-element-map
(org-element-parse-buffer)
- 'footnote-definition 'identity nil t))))))
+ 'footnote-definition 'identity nil t)))))
+ ;; Footnote starting with special syntax.
+ (should-not
+ (org-test-with-temp-text "[fn:1] - no item"
+ (org-element-map (org-element-parse-buffer) 'item 'identity))))
;;;; Footnotes Reference.
@@ -917,7 +921,13 @@ DEADLINE: <2012-03-29 thu.>"
(should
(org-element-property
:hiddenp
- (org-element-map (org-element-parse-buffer) 'item 'identity nil t)))))
+ (org-element-map (org-element-parse-buffer) 'item 'identity nil t))))
+ ;; Item starting with special syntax.
+ (should
+ (equal '(("- item"))
+ (org-test-with-temp-text "- - item"
+ (org-element-map
+ (org-element-parse-buffer) 'paragraph 'org-element-contents)))))
;;;; Keyword