org-element: Fix "*" itemized plain lists interpretation

* lisp/org-element.el (org-element-item-interpreter): Correctly
  interpret back plain lists with "*" items.  This fixes "This is not
  a list" error returned in this case.
* testing/lisp/test-org-element.el: Add test.
This commit is contained in:
Nicolas Goaziou 2013-07-05 21:09:23 +02:00
parent 848240c1cf
commit e5630add27
2 changed files with 18 additions and 8 deletions

View File

@ -1119,7 +1119,11 @@ Assume point is at the beginning of the item."
(defun org-element-item-interpreter (item contents)
"Interpret ITEM element as Org syntax.
CONTENTS is the contents of the element."
(let* ((bullet (org-list-bullet-string (org-element-property :bullet item)))
(let* ((bullet (let ((bullet (org-element-property :bullet item)))
(org-list-bullet-string
(cond ((not (string-match "[0-9a-zA-Z]" bullet)) "- ")
((eq org-plain-list-ordered-item-terminator ?\)) "1)")
(t "1.")))))
(checkbox (org-element-property :checkbox item))
(counter (org-element-property :counter item))
(tag (let ((tag (org-element-property :tag item)))

View File

@ -2139,30 +2139,36 @@ Outside list"
(ert-deftest test-org-element/plain-list-interpreter ()
"Test plain-list and item interpreters."
(let ((org-list-two-spaces-after-bullet-regexp nil))
;; 1. Unordered list.
;; Unordered list.
(should (equal (org-test-parse-and-interpret "- item 1") "- item 1\n"))
;; 2. Description list.
;; Description list.
(should
(equal (org-test-parse-and-interpret "- tag :: desc") "- tag :: desc\n"))
;; 3. Ordered list.
;; Ordered list.
(should
(equal (let ((org-plain-list-ordered-item-terminator t))
(org-test-parse-and-interpret "1. Item"))
"1. Item\n"))
;; 4. Ordered list with counter.
(should
(equal (let ((org-plain-list-ordered-item-terminator ?\)))
(org-test-parse-and-interpret "1) Item"))
"1) Item\n"))
;; Ordered list with counter.
(should
(equal (let ((org-plain-list-ordered-item-terminator t))
(org-test-parse-and-interpret "1. [@5] Item"))
"5. [@5] Item\n"))
;; 5. List with check-boxes.
;; List with check-boxes.
(should
(equal (org-test-parse-and-interpret
"- [-] Item 1\n - [X] Item 2\n - [ ] Item 3")
"- [-] Item 1\n - [X] Item 2\n - [ ] Item 3\n"))
;; 6. Item not starting with a paragraph.
;; Item not starting with a paragraph.
(should
(equal (org-test-parse-and-interpret "-\n | a | b |")
"- \n | a | b |\n"))))
"- \n | a | b |\n"))
;; Special case: correctly handle "*" bullets.
(should (org-test-parse-and-interpret " * item"))))
(ert-deftest test-org-element/quote-block-interpreter ()
"Test quote block interpreter."