2012-02-23 10:28:13 -05:00
|
|
|
|
;;; test-org-element.el --- Tests for org-element.el
|
|
|
|
|
|
2013-01-01 10:04:24 -05:00
|
|
|
|
;; Copyright (C) 2012, 2013 Nicolas Goaziou
|
2012-02-23 10:28:13 -05:00
|
|
|
|
|
|
|
|
|
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
|
|
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2012-12-13 11:24:19 -05:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2012-02-29 12:38:54 -05:00
|
|
|
|
(unless (featurep 'org-element)
|
|
|
|
|
(signal 'missing-test-dependency "org-element"))
|
2012-02-23 10:28:13 -05:00
|
|
|
|
|
2012-04-27 11:16:17 -04:00
|
|
|
|
(defun org-test-parse-and-interpret (text)
|
|
|
|
|
"Parse TEXT as Org syntax and interpret it.
|
|
|
|
|
Return interpreted string."
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(org-mode)
|
|
|
|
|
(insert text)
|
|
|
|
|
(org-element-interpret-data (org-element-parse-buffer))))
|
|
|
|
|
|
2012-02-23 10:28:13 -05:00
|
|
|
|
|
2012-05-05 09:56:12 -04:00
|
|
|
|
|
|
|
|
|
;;; Test `org-element-map'
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/map ()
|
|
|
|
|
"Test `org-element-map'."
|
|
|
|
|
;; Can map to `plain-text' objects.
|
|
|
|
|
(should
|
|
|
|
|
(= 2
|
|
|
|
|
(org-test-with-temp-text "Some text \alpha
|
|
|
|
|
#+BEGIN_CENTER
|
|
|
|
|
Some other text
|
|
|
|
|
#+END_CENTER"
|
|
|
|
|
(let ((count 0))
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'plain-text
|
|
|
|
|
(lambda (s) (when (string-match "text" s) (incf count))))
|
|
|
|
|
count))))
|
|
|
|
|
;; Applies to secondary strings
|
|
|
|
|
(should
|
|
|
|
|
(org-element-map '("some " (bold nil "bold") "text") 'bold 'identity))
|
|
|
|
|
;; Enter secondary strings before entering contents.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"alpha"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:name
|
|
|
|
|
(org-test-with-temp-text "* Some \\alpha headline\n\\beta entity."
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'entity 'identity nil t)))))
|
|
|
|
|
;; Apply NO-RECURSION argument.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_CENTER\n\\alpha\n#+END_CENTER"
|
|
|
|
|
(org-element-map
|
2012-09-30 16:13:47 -04:00
|
|
|
|
(org-element-parse-buffer) 'entity 'identity nil nil 'center-block)))
|
|
|
|
|
;; Use WITH-AFFILIATED argument.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("a" "1" "b" "2")
|
|
|
|
|
(org-test-with-temp-text "#+CAPTION[a]: 1\n#+CAPTION[b]: 2\nParagraph"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-at-point) 'plain-text 'identity nil nil nil t)))))
|
2012-05-05 09:56:12 -04:00
|
|
|
|
|
2012-07-10 11:21:36 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Test Setters
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/put-property ()
|
|
|
|
|
"Test `org-element-put-property' specifications."
|
2012-10-25 15:33:57 -04:00
|
|
|
|
;; Standard test.
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline\n *a*"
|
|
|
|
|
(let ((tree (org-element-parse-buffer)))
|
|
|
|
|
(org-element-put-property
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t) :test 1)
|
|
|
|
|
(should (org-element-property
|
2012-10-25 15:33:57 -04:00
|
|
|
|
:test (org-element-map tree 'bold 'identity nil t)))))
|
|
|
|
|
;; Put property on a string.
|
|
|
|
|
(should
|
|
|
|
|
(org-element-property :test (org-element-put-property "Paragraph" :test t))))
|
2012-07-10 11:21:36 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/set-contents ()
|
|
|
|
|
"Test `org-element-set-contents' specifications."
|
|
|
|
|
;; Accept multiple entries.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("b" (italic nil "a"))
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline\n *a*"
|
|
|
|
|
(let ((tree (org-element-parse-buffer)))
|
|
|
|
|
(org-element-set-contents
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t) "b" '(italic nil "a"))
|
|
|
|
|
(org-element-contents
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t))))))
|
2012-07-10 11:21:36 -04:00
|
|
|
|
;; Accept atoms and elements.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("b")
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline\n *a*"
|
|
|
|
|
(let ((tree (org-element-parse-buffer)))
|
|
|
|
|
(org-element-set-contents
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t) "b")
|
|
|
|
|
(org-element-contents
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t))))))
|
2012-07-10 11:21:36 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '((italic nil "b"))
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline\n *a*"
|
|
|
|
|
(let ((tree (org-element-parse-buffer)))
|
|
|
|
|
(org-element-set-contents
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t) '(italic nil "b"))
|
|
|
|
|
(org-element-contents
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t))))))
|
2012-07-10 11:21:36 -04:00
|
|
|
|
;; Allow nil contents.
|
|
|
|
|
(should-not
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline\n *a*"
|
|
|
|
|
(let ((tree (org-element-parse-buffer)))
|
|
|
|
|
(org-element-set-contents (org-element-map tree 'bold 'identity nil t))
|
|
|
|
|
(org-element-contents (org-element-map tree 'bold 'identity nil t))))))
|
2012-07-10 11:21:36 -04:00
|
|
|
|
|
2012-07-10 11:29:13 -04:00
|
|
|
|
(ert-deftest test-org-element/set-element ()
|
|
|
|
|
"Test `org-element-set-element' specifications."
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline\n*a*"
|
|
|
|
|
(let ((tree (org-element-parse-buffer)))
|
|
|
|
|
(org-element-set-element
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t)
|
|
|
|
|
'(italic nil "b"))
|
|
|
|
|
;; Check if object is correctly replaced.
|
|
|
|
|
(should (org-element-map tree 'italic 'identity))
|
|
|
|
|
(should-not (org-element-map tree 'bold 'identity))
|
|
|
|
|
;; Check if new object's parent is correctly set.
|
|
|
|
|
(should
|
2012-07-18 05:25:29 -04:00
|
|
|
|
(eq
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-element-property :parent
|
|
|
|
|
(org-element-map tree 'italic 'identity nil t))
|
|
|
|
|
(org-element-map tree 'paragraph 'identity nil t))))))
|
2012-07-10 11:29:13 -04:00
|
|
|
|
|
2012-08-18 04:13:35 -04:00
|
|
|
|
(ert-deftest test-org-element/adopt-elements ()
|
|
|
|
|
"Test `org-element-adopt-elements' specifications."
|
2012-07-10 11:21:36 -04:00
|
|
|
|
;; Adopt an element.
|
|
|
|
|
(should
|
2012-08-18 04:13:35 -04:00
|
|
|
|
(equal '(plain-text italic)
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline\n *a*"
|
|
|
|
|
(let ((tree (org-element-parse-buffer)))
|
2012-08-18 04:13:35 -04:00
|
|
|
|
(org-element-adopt-elements
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-element-map tree 'bold 'identity nil t) '(italic nil "a"))
|
|
|
|
|
(mapcar (lambda (blob) (org-element-type blob))
|
|
|
|
|
(org-element-contents
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t)))))))
|
2012-07-10 11:21:36 -04:00
|
|
|
|
;; Adopt a string.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("a" "b")
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline\n *a*"
|
|
|
|
|
(let ((tree (org-element-parse-buffer)))
|
2012-08-18 04:13:35 -04:00
|
|
|
|
(org-element-adopt-elements
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t) "b")
|
2012-07-11 08:17:02 -04:00
|
|
|
|
(org-element-contents
|
|
|
|
|
(org-element-map tree 'bold 'identity nil t)))))))
|
2012-07-10 11:21:36 -04:00
|
|
|
|
|
|
|
|
|
|
2012-02-23 10:28:13 -05:00
|
|
|
|
|
2012-04-30 11:20:57 -04:00
|
|
|
|
;;; Test Parsers
|
2012-02-23 10:28:13 -05:00
|
|
|
|
|
2012-09-13 07:03:55 -04:00
|
|
|
|
;;;; Affiliated Keywords
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/affiliated-keywords-parser ()
|
|
|
|
|
"Test affiliated keywords parsing."
|
|
|
|
|
;; Read simple keywords.
|
|
|
|
|
(should
|
|
|
|
|
(equal "para"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:name
|
|
|
|
|
(org-test-with-temp-text "#+NAME: para\nParagraph"
|
|
|
|
|
(org-element-at-point)))))
|
2012-09-23 03:49:32 -04:00
|
|
|
|
(should
|
|
|
|
|
(= 1
|
|
|
|
|
(org-element-property
|
|
|
|
|
:begin
|
|
|
|
|
(org-test-with-temp-text "#+NAME: para\nParagraph"
|
|
|
|
|
(org-element-at-point)))))
|
2012-09-13 07:03:55 -04:00
|
|
|
|
;; Parse multiple keywords.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
'("line2" "line1")
|
2012-09-13 07:03:55 -04:00
|
|
|
|
(org-element-property
|
|
|
|
|
:attr_ascii
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+ATTR_ASCII: line1\n#+ATTR_ASCII: line2\nParagraph"
|
|
|
|
|
(org-element-at-point)))))
|
|
|
|
|
;; Parse "parsed" keywords.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2012-09-13 10:51:54 -04:00
|
|
|
|
'(("caption"))
|
2012-09-13 07:03:55 -04:00
|
|
|
|
(org-test-with-temp-text "#+CAPTION: caption\nParagraph"
|
|
|
|
|
(car (org-element-property :caption (org-element-at-point))))))
|
|
|
|
|
;; Parse dual keywords.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2012-09-13 10:51:54 -04:00
|
|
|
|
'((("long") "short"))
|
2012-09-13 07:03:55 -04:00
|
|
|
|
(org-test-with-temp-text "#+CAPTION[short]: long\nParagraph"
|
2012-09-13 10:51:54 -04:00
|
|
|
|
(org-element-property :caption (org-element-at-point)))))
|
|
|
|
|
;; Allow multiple caption keywords.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
'((("l2") "s2") (("l1") "s1"))
|
2012-09-13 10:51:54 -04:00
|
|
|
|
(org-test-with-temp-text "#+CAPTION[s1]: l1\n#+CAPTION[s2]: l2\nParagraph"
|
2012-10-28 17:43:50 -04:00
|
|
|
|
(org-element-property :caption (org-element-at-point)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'((("l1")) (nil "s1"))
|
|
|
|
|
(org-test-with-temp-text "#+CAPTION[s1]:\n#+CAPTION: l1\nParagraph"
|
2013-02-11 08:42:16 -05:00
|
|
|
|
(org-element-property :caption (org-element-at-point)))))
|
|
|
|
|
;; Corner case: orphaned keyword at the end of an element.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'keyword
|
|
|
|
|
(org-test-with-temp-text "- item\n #+name: name\nSome paragraph"
|
|
|
|
|
(progn (search-forward "name")
|
|
|
|
|
(org-element-type (org-element-at-point))))))
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "- item\n #+name: name\nSome paragraph"
|
|
|
|
|
(progn (search-forward "Some")
|
|
|
|
|
(org-element-property :name (org-element-at-point))))))
|
2012-09-13 07:03:55 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;;;; Babel Call
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/babel-call-parser ()
|
|
|
|
|
"Test `babel-call' parsing."
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Standard test.
|
2012-05-04 13:24:51 -04:00
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "#+CALL: test()"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'babel-call 'identity)))
|
|
|
|
|
;; Ignore case.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "#+call: test()"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'babel-call 'identity))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Bold
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/bold-parser ()
|
|
|
|
|
"Test `bold' parser."
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Standard test.
|
2012-05-04 13:24:51 -04:00
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(let ((org-emph-re "\\([ ('\"{]\\|^\\)\\(\\([+*/_=~]\\)\\([^
\n,\"']\\|[^
\n,\"'].*?\\(?:\n.*?\\)\\{0,1\\}[^
\n,\"']\\)\\3\\)\\([- .,:!?;'\")}\\]\\|$\\)"))
|
|
|
|
|
(org-test-with-temp-text "*bold*"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'bold 'identity nil t))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Multi-line markup.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-element-contents
|
|
|
|
|
(let ((org-emph-re "\\([ ('\"{]\\|^\\)\\(\\([+*/_=~]\\)\\([^
\n,\"']\\|[^
\n,\"'].*?\\(?:\n.*?\\)\\{0,1\\}[^
\n,\"']\\)\\3\\)\\([- .,:!?;'\")}\\]\\|$\\)"))
|
|
|
|
|
(org-test-with-temp-text "*first line\nsecond line*"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'bold 'identity nil t))))
|
|
|
|
|
'("first line\nsecond line"))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Center Block
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/center-block-parser ()
|
|
|
|
|
"Test `center-block' parser."
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Standard test.
|
2012-05-04 13:24:51 -04:00
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "#+BEGIN_CENTER\nText\n#+END_CENTER"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'center-block 'identity)))
|
|
|
|
|
;; Ignore case.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "#+begin_center\nText\n#+end_center"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'center-block 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Test folded block.
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_CENTER\nText\n#+END_CENTER"
|
|
|
|
|
(org-cycle)
|
|
|
|
|
(should
|
|
|
|
|
(org-element-property
|
|
|
|
|
:hiddenp
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'center-block 'identity nil t))))
|
|
|
|
|
;; Ignore incomplete block.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_CENTER"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'center-block 'identity nil t))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Clock
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/clock-parser ()
|
|
|
|
|
"Test `clock' parser."
|
|
|
|
|
;; Running clock.
|
2012-06-08 14:16:57 -04:00
|
|
|
|
(let* ((org-clock-string "CLOCK:")
|
|
|
|
|
(clock (org-test-with-temp-text "CLOCK: [2012-01-01 sun. 00:01]"
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(org-element-at-point))))
|
2012-06-08 14:16:57 -04:00
|
|
|
|
(should (eq (org-element-property :status clock) 'running))
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal (org-element-property :raw-value
|
|
|
|
|
(org-element-property :value clock))
|
|
|
|
|
"[2012-01-01 sun. 00:01]"))
|
|
|
|
|
(should-not (org-element-property :duration clock)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Closed clock.
|
2012-06-08 14:16:57 -04:00
|
|
|
|
(let* ((org-clock-string "CLOCK:")
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(clock
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"
|
|
|
|
|
(org-element-at-point))))
|
2012-06-08 14:16:57 -04:00
|
|
|
|
(should (eq (org-element-property :status clock) 'closed))
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(should (equal (org-element-property :raw-value
|
|
|
|
|
(org-element-property :value clock))
|
2012-06-08 14:16:57 -04:00
|
|
|
|
"[2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02]"))
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(should (equal (org-element-property :duration clock) "0:01"))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Code
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/code-parser ()
|
|
|
|
|
"Test `code' parser."
|
|
|
|
|
;; Regular test.
|
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(let ((org-emph-re "\\([ ('\"{]\\|^\\)\\(\\([+*/_=~]\\)\\([^
\n,\"']\\|[^
\n,\"'].*?\\(?:\n.*?\\)\\{0,1\\}[^
\n,\"']\\)\\3\\)\\([- .,:!?;'\")}\\]\\|$\\)"))
|
|
|
|
|
(org-test-with-temp-text "~code~"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'code 'identity))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Multi-line markup.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-element-property
|
|
|
|
|
:value
|
|
|
|
|
(let ((org-emph-re "\\([ ('\"{]\\|^\\)\\(\\([+*/_=~]\\)\\([^
\n,\"']\\|[^
\n,\"'].*?\\(?:\n.*?\\)\\{0,1\\}[^
\n,\"']\\)\\3\\)\\([- .,:!?;'\")}\\]\\|$\\)"))
|
|
|
|
|
(org-test-with-temp-text "~first line\nsecond line~"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'code 'identity nil t))))
|
|
|
|
|
"first line\nsecond line")))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Comment
|
2012-05-02 11:18:14 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/comment-parser ()
|
2012-05-04 13:24:51 -04:00
|
|
|
|
"Test `comment' parser."
|
2012-05-02 11:18:14 -04:00
|
|
|
|
;; Regular comment.
|
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "# Comment"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'comment 'identity)))
|
2012-05-02 11:18:14 -04:00
|
|
|
|
;; Inline comment.
|
|
|
|
|
(should
|
2012-07-31 19:27:27 -04:00
|
|
|
|
(org-test-with-temp-text " # Comment"
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-element-map (org-element-parse-buffer) 'comment 'identity)))
|
2012-05-02 11:18:14 -04:00
|
|
|
|
;; Preserve indentation.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-element-property
|
|
|
|
|
:value
|
2012-07-31 19:27:27 -04:00
|
|
|
|
(org-test-with-temp-text "# No blank\n# One blank"
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-element-map (org-element-parse-buffer) 'comment 'identity nil t)))
|
2012-08-02 13:47:14 -04:00
|
|
|
|
"No blank\n One blank"))
|
2012-05-02 11:18:14 -04:00
|
|
|
|
;; Comment with blank lines.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-element-property
|
|
|
|
|
:value
|
2012-07-31 19:27:27 -04:00
|
|
|
|
(org-test-with-temp-text "# First part\n# \n#\n# Second part"
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-element-map (org-element-parse-buffer) 'comment 'identity nil t)))
|
2012-05-20 10:54:45 -04:00
|
|
|
|
"First part\n\n\nSecond part"))
|
2012-08-02 13:47:14 -04:00
|
|
|
|
;; Do not mix comments and keywords.
|
|
|
|
|
(should
|
|
|
|
|
(eq 1
|
|
|
|
|
(org-test-with-temp-text "#+keyword: value\n# comment\n#+keyword: value"
|
|
|
|
|
(length (org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'comment 'identity)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "comment"
|
|
|
|
|
(org-test-with-temp-text "#+keyword: value\n# comment\n#+keyword: value"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:value
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'comment 'identity nil t))))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Comment Block
|
2012-05-02 11:18:14 -04:00
|
|
|
|
|
2012-05-04 13:24:51 -04:00
|
|
|
|
(ert-deftest test-org-element/comment-block-parser ()
|
|
|
|
|
"Test `comment-block' parser."
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Standard test.
|
2012-05-04 13:24:51 -04:00
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "#+BEGIN_COMMENT\nText\n#+END_COMMENT"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'comment-block 'identity)))
|
|
|
|
|
;; Ignore case.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "#+begin_comment\nText\n#+end_comment"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'comment-block 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Test folded block.
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_COMMENT\nText\n#+END_COMMENT"
|
|
|
|
|
(org-cycle)
|
|
|
|
|
(should
|
|
|
|
|
(org-element-property
|
|
|
|
|
:hiddenp
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'comment-block 'identity nil t))))
|
|
|
|
|
;; Ignore incomplete block.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_COMMENT"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'comment-block 'identity nil t))))
|
|
|
|
|
|
|
|
|
|
|
2012-10-27 08:23:37 -04:00
|
|
|
|
;;;; Diary Sexp
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/diary-sexp-parser ()
|
|
|
|
|
"Test `diary-sexp' parser."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'diary-sexp
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"%%(org-anniversary 1956 5 14)(2) Arthur Dent is %d years old"
|
|
|
|
|
(org-element-type (org-element-at-point)))))
|
|
|
|
|
;; Diary sexp must live at beginning of line
|
|
|
|
|
(should-not
|
|
|
|
|
(eq 'diary-sexp
|
|
|
|
|
(org-test-with-temp-text " %%(org-bbdb-anniversaries)"
|
|
|
|
|
(org-element-type (org-element-at-point))))))
|
|
|
|
|
|
|
|
|
|
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;;;; Drawer
|
2012-05-02 11:18:14 -04:00
|
|
|
|
|
2012-05-04 13:24:51 -04:00
|
|
|
|
(ert-deftest test-org-element/drawer-parser ()
|
|
|
|
|
"Test `drawer' parser."
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Standard test.
|
2012-05-04 13:24:51 -04:00
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(let ((org-drawers '("TEST")))
|
|
|
|
|
(org-test-with-temp-text ":TEST:\nText\n:END:"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'drawer 'identity))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Do not mix regular drawers and property drawers.
|
|
|
|
|
(should-not
|
|
|
|
|
(let ((org-drawers '("PROPERTIES")))
|
|
|
|
|
(org-test-with-temp-text ":PROPERTIES:\n:prop: value\n:END:"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'drawer 'identity nil t))))
|
|
|
|
|
;; Ignore incomplete drawer.
|
|
|
|
|
(should-not
|
|
|
|
|
(let ((org-drawers '("TEST")))
|
|
|
|
|
(org-test-with-temp-text ":TEST:"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'drawer 'identity nil t)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Dynamic Block
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/dynamic-block-parser ()
|
|
|
|
|
"Test `dynamic-block' parser."
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Standard test.
|
2012-05-04 13:24:51 -04:00
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+BEGIN: myblock :param1 val1 :param2 val2\nText\n#+END:"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'dynamic-block 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Folded view
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+BEGIN: myblock :param1 val1 :param2 val2\nText\n#+END:"
|
|
|
|
|
(org-cycle)
|
|
|
|
|
(should
|
|
|
|
|
(org-element-property
|
|
|
|
|
:hiddenp
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'dynamic-block 'identity nil t))))
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Ignore case.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+begin: myblock :param1 val1 :param2 val2\nText\n#+end:"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'dynamic-block 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Ignore incomplete block.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN: myblock :param1 val1 :param2 val2"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'dynamic-block 'identity nil t))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Entity
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/entity-parser ()
|
|
|
|
|
"Test `entity' parser."
|
|
|
|
|
;; Without brackets.
|
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "\\sin"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'entity 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; With brackets.
|
|
|
|
|
(should
|
|
|
|
|
(org-element-property
|
|
|
|
|
:use-brackets-p
|
|
|
|
|
(org-test-with-temp-text "\\alpha{}text"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'entity 'identity nil t))))
|
|
|
|
|
;; User-defined entity.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(org-element-property
|
|
|
|
|
:name
|
|
|
|
|
(let ((org-entities-user
|
|
|
|
|
'(("test" "test" nil "test" "test" "test" "test"))))
|
|
|
|
|
(org-test-with-temp-text "\\test"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'entity 'identity nil t))))
|
|
|
|
|
"test")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Example Block
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/example-block-parser ()
|
|
|
|
|
"Test `example-block' parser."
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Standard test.
|
2012-05-04 13:24:51 -04:00
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText\n#+END_EXAMPLE"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'example-block 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Test folded block.
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText\n#+END_EXAMPLE"
|
|
|
|
|
(org-cycle)
|
|
|
|
|
(should
|
|
|
|
|
(org-element-property
|
|
|
|
|
:hiddenp
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'example-block 'identity nil t))))
|
|
|
|
|
;; Ignore incomplete block.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE"
|
|
|
|
|
(org-element-map
|
2012-09-30 11:45:21 -04:00
|
|
|
|
(org-element-parse-buffer) 'example-block 'identity nil t)))
|
|
|
|
|
;; Properly un-escape code.
|
|
|
|
|
(should
|
|
|
|
|
(equal "* Headline\n #+keyword\nText\n"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword\nText\n#+END_EXAMPLE"
|
|
|
|
|
(org-element-property :value (org-element-at-point))))))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/block-switches ()
|
|
|
|
|
"Test `example-block' and `src-block' switches parsing."
|
|
|
|
|
(let ((org-coderef-label-format "(ref:%s)"))
|
|
|
|
|
;; 1. Test "-i" switch.
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(should-not
|
|
|
|
|
(org-element-property :preserve-indent (org-element-at-point))))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -i\n(+ 1 1)\n#+END_SRC"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(should (org-element-property :preserve-indent (org-element-at-point))))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(should-not
|
|
|
|
|
(org-element-property :preserve-indent (org-element-at-point))))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE -i\nText.\n#+END_EXAMPLE"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(should (org-element-property :preserve-indent (org-element-at-point))))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
;; 2. "-n -r -k" combination should number lines, retain labels but
|
|
|
|
|
;; not use them in coderefs.
|
2012-04-28 15:12:30 -04:00
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r -k\nText.\n#+END_EXAMPLE"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (org-element-property :number-lines element)
|
|
|
|
|
(org-element-property :retain-labels element)
|
|
|
|
|
(not (org-element-property :use-labels element))))))
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -n -r -k\n(+ 1 1)\n#+END_SRC"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (org-element-property :number-lines element)
|
|
|
|
|
(org-element-property :retain-labels element)
|
|
|
|
|
(not (org-element-property :use-labels element))))))
|
|
|
|
|
;; 3. "-n -r" combination should number-lines remove labels and not
|
|
|
|
|
;; use them in coderefs.
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r\nText.\n#+END_EXAMPLE"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (org-element-property :number-lines element)
|
|
|
|
|
(not (org-element-property :retain-labels element))
|
|
|
|
|
(not (org-element-property :use-labels element))))))
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1)\n#+END_SRC"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (org-element-property :number-lines element)
|
|
|
|
|
(not (org-element-property :retain-labels element))
|
|
|
|
|
(not (org-element-property :use-labels element))))))
|
|
|
|
|
;; 4. "-n" or "+n" should number lines, retain labels and use them
|
|
|
|
|
;; in coderefs.
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n\nText.\n#+END_EXAMPLE"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (org-element-property :number-lines element)
|
|
|
|
|
(org-element-property :retain-labels element)
|
|
|
|
|
(org-element-property :use-labels element)))))
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n\n(+ 1 1)\n#+END_SRC"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (org-element-property :number-lines element)
|
|
|
|
|
(org-element-property :retain-labels element)
|
|
|
|
|
(org-element-property :use-labels element)))))
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE +n\nText.\n#+END_EXAMPLE"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (org-element-property :number-lines element)
|
|
|
|
|
(org-element-property :retain-labels element)
|
|
|
|
|
(org-element-property :use-labels element)))))
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp +n\n(+ 1 1)\n#+END_SRC"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (org-element-property :number-lines element)
|
|
|
|
|
(org-element-property :retain-labels element)
|
|
|
|
|
(org-element-property :use-labels element)))))
|
|
|
|
|
;; 5. No switch should not number lines, but retain labels and use
|
|
|
|
|
;; them in coderefs.
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (not (org-element-property :number-lines element))
|
|
|
|
|
(org-element-property :retain-labels element)
|
|
|
|
|
(org-element-property :use-labels element)))))
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (not (org-element-property :number-lines element))
|
|
|
|
|
(org-element-property :retain-labels element)
|
|
|
|
|
(org-element-property :use-labels element)))))
|
|
|
|
|
;; 6. "-r" switch only: do not number lines, remove labels, and
|
|
|
|
|
;; don't use labels in coderefs.
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE -r\nText.\n#+END_EXAMPLE"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (not (org-element-property :number-lines element))
|
|
|
|
|
(not (org-element-property :retain-labels element))
|
|
|
|
|
(not (org-element-property :use-labels element))))))
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1)\n#+END_SRC"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should (and (not (org-element-property :number-lines element))
|
|
|
|
|
(not (org-element-property :retain-labels element))
|
|
|
|
|
(not (org-element-property :use-labels element))))))
|
|
|
|
|
;; 7. Recognize coderefs with user-defined syntax.
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText [ref:text]\n#+END_EXAMPLE"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should
|
2012-03-10 07:46:35 -05:00
|
|
|
|
(equal (org-element-property :label-fmt element) "[ref:%s]"))))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -l \"[ref:%s]\"\n(+ 1 1) [ref:text]\n#+END_SRC"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(let ((element (org-element-at-point)))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
(should
|
2012-03-10 07:46:35 -05:00
|
|
|
|
(equal (org-element-property :label-fmt element) "[ref:%s]"))))))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
|
|
|
|
|
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;;;; Export Block
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/export-block-parser ()
|
|
|
|
|
"Test `export-block' parser."
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Standard test.
|
2012-05-04 13:24:51 -04:00
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "#+BEGIN_LATEX\nText\n#+END_LATEX"
|
2012-07-23 08:06:13 -04:00
|
|
|
|
(org-element-map
|
|
|
|
|
(let ((org-element-block-name-alist
|
|
|
|
|
'(("LATEX" . org-element-export-block-parser))))
|
|
|
|
|
(org-element-parse-buffer))
|
|
|
|
|
'export-block 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Test folded block.
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_LATEX\nText\n#+END_LATEX"
|
|
|
|
|
(org-cycle)
|
|
|
|
|
(should
|
|
|
|
|
(org-element-property
|
|
|
|
|
:hiddenp
|
|
|
|
|
(org-element-map
|
2012-07-23 08:06:13 -04:00
|
|
|
|
(let ((org-element-block-name-alist
|
|
|
|
|
'(("LATEX" . org-element-export-block-parser))))
|
|
|
|
|
(org-element-parse-buffer))
|
|
|
|
|
'export-block 'identity nil t))))
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Ignore case.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "#+begin_latex\nText\n#+end_latex"
|
2012-07-23 08:06:13 -04:00
|
|
|
|
(org-element-map
|
|
|
|
|
(let ((org-element-block-name-alist
|
|
|
|
|
'(("LATEX" . org-element-export-block-parser))))
|
|
|
|
|
(org-element-parse-buffer))
|
|
|
|
|
'export-block 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Ignore incomplete block.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN_LATEX"
|
|
|
|
|
(org-element-map
|
2012-07-23 08:06:13 -04:00
|
|
|
|
(let ((org-element-block-name-alist
|
|
|
|
|
'(("LATEX" . org-element-export-block-parser))))
|
|
|
|
|
(org-element-parse-buffer))
|
|
|
|
|
'export-block 'identity nil t))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Export Snippet
|
2012-04-30 11:20:57 -04:00
|
|
|
|
|
2012-05-01 09:08:08 -04:00
|
|
|
|
(ert-deftest test-org-element/export-snippet-parser ()
|
2012-05-04 13:24:51 -04:00
|
|
|
|
"Test `export-snippet' parser."
|
2012-04-30 11:20:57 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2012-05-05 13:57:37 -04:00
|
|
|
|
'("back-end" . "contents")
|
2012-06-30 04:01:28 -04:00
|
|
|
|
(org-test-with-temp-text "@@back-end:contents@@"
|
2012-04-30 11:20:57 -04:00
|
|
|
|
(org-element-map
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-element-parse-buffer) 'export-snippet
|
|
|
|
|
(lambda (snippet) (cons (org-element-property :back-end snippet)
|
|
|
|
|
(org-element-property :value snippet)))
|
|
|
|
|
nil t)))))
|
2012-04-30 11:20:57 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;;;; Fixed Width
|
2012-05-02 11:18:14 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/fixed-width ()
|
|
|
|
|
"Test fixed-width area parsing."
|
|
|
|
|
;; Preserve indentation.
|
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text ": no blank\n: one blank"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'fixed-width 'identity)))
|
2012-05-02 11:18:14 -04:00
|
|
|
|
;; Fixed-width with empty lines.
|
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text ": first part\n:\n: \n: second part"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'fixed-width 'identity)))
|
2012-05-02 11:18:14 -04:00
|
|
|
|
;; Parse indented fixed-width markers.
|
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "Text\n : no blank\n : one blank"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'fixed-width 'identity)))
|
2012-05-02 11:18:14 -04:00
|
|
|
|
;; Distinguish fixed-width areas within a list and outside of it.
|
|
|
|
|
(should
|
|
|
|
|
(= 2
|
|
|
|
|
(length
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
- Item
|
|
|
|
|
: fixed-width inside
|
|
|
|
|
: fixed-width outside"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'fixed-width 'identity))))))
|
|
|
|
|
|
|
|
|
|
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;;;; Footnote Definition
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/footnote-definition-parser ()
|
|
|
|
|
"Test `footnote-definition' parser."
|
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "[fn:1] Definition"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'footnote-definition 'identity nil t)))
|
2012-05-04 19:38:11 -04:00
|
|
|
|
;; Footnote with more contents
|
|
|
|
|
(should
|
2013-02-21 09:30:16 -05:00
|
|
|
|
(= 29
|
2012-05-04 19:38:11 -04:00
|
|
|
|
(org-element-property
|
|
|
|
|
:end
|
2013-02-21 09:30:16 -05:00
|
|
|
|
(org-test-with-temp-text "[fn:1] Definition\n\n| a | b |"
|
2012-05-04 19:38:11 -04:00
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer)
|
2012-09-12 09:40:13 -04:00
|
|
|
|
'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))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;;;; Footnotes Reference.
|
2012-04-06 17:50:00 -04:00
|
|
|
|
|
2012-05-01 09:08:08 -04:00
|
|
|
|
(ert-deftest test-org-element/footnote-reference-parser ()
|
2012-05-04 13:24:51 -04:00
|
|
|
|
"Test `footnote-reference' parser."
|
2012-04-06 17:50:00 -04:00
|
|
|
|
;; 1. Parse a standard reference.
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "Text[fn:label]"
|
|
|
|
|
(should
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'footnote-reference 'identity)))
|
2012-04-06 17:50:00 -04:00
|
|
|
|
;; 2. Parse a normalized reference.
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "Text[1]"
|
|
|
|
|
(should
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'footnote-reference 'identity)))
|
2012-04-06 17:50:00 -04:00
|
|
|
|
;; 3. Parse an inline reference.
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "Text[fn:test:def]"
|
|
|
|
|
(should
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'footnote-reference 'identity)))
|
2012-04-06 17:50:00 -04:00
|
|
|
|
;; 4. Parse an anonymous reference.
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "Text[fn::def]"
|
|
|
|
|
(should
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'footnote-reference 'identity)))
|
2012-04-06 17:50:00 -04:00
|
|
|
|
;; 5. Parse nested footnotes.
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "Text[fn::def [fn:label]]"
|
2012-04-06 17:50:00 -04:00
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(= 2
|
|
|
|
|
(length
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'footnote-reference 'identity)))))
|
2012-04-06 17:50:00 -04:00
|
|
|
|
;; 6. Parse adjacent footnotes.
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "Text[fn:label1][fn:label2]"
|
2012-04-06 17:50:00 -04:00
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(= 2
|
|
|
|
|
(length
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'footnote-reference 'identity)))))
|
2012-04-06 17:50:00 -04:00
|
|
|
|
;; 7. Only properly closed footnotes are recognized as such.
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "Text[fn:label"
|
2012-04-06 17:50:00 -04:00
|
|
|
|
(should-not
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'footnote-reference 'identity))))
|
|
|
|
|
|
|
|
|
|
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;;;; Headline
|
2012-04-30 11:20:57 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/headline-quote-keyword ()
|
|
|
|
|
"Test QUOTE keyword recognition."
|
|
|
|
|
;; Reference test.
|
|
|
|
|
(org-test-with-temp-text "* Headline"
|
|
|
|
|
(let ((org-quote-string "QUOTE"))
|
|
|
|
|
(should-not (org-element-property :quotedp (org-element-at-point)))))
|
|
|
|
|
;; Standard position.
|
|
|
|
|
(org-test-with-temp-text "* QUOTE Headline"
|
2012-09-29 03:46:09 -04:00
|
|
|
|
(let* ((org-quote-string "QUOTE")
|
|
|
|
|
(headline (org-element-at-point)))
|
|
|
|
|
(should (org-element-property :quotedp headline))
|
|
|
|
|
;; Test removal from raw value.
|
|
|
|
|
(should (equal (org-element-property :raw-value headline) "Headline"))))
|
|
|
|
|
;; Case sensitivity.
|
|
|
|
|
(org-test-with-temp-text "* QUOTE Headline"
|
|
|
|
|
(let* ((org-quote-string "Quote")
|
|
|
|
|
(headline (org-element-at-point)))
|
|
|
|
|
(should-not (org-element-property :quotedp headline))
|
|
|
|
|
(should (equal (org-element-property :raw-value headline)
|
|
|
|
|
"QUOTE Headline"))))
|
2012-04-30 11:20:57 -04:00
|
|
|
|
;; With another keyword.
|
|
|
|
|
(org-test-with-temp-text "* TODO QUOTE Headline"
|
2012-09-29 03:46:09 -04:00
|
|
|
|
(let* ((org-quote-string "QUOTE")
|
|
|
|
|
(org-todo-keywords '((sequence "TODO" "DONE")))
|
|
|
|
|
(headline (org-element-at-point)))
|
|
|
|
|
(should (org-element-property :quotedp headline))
|
|
|
|
|
(should (equal (org-element-property :raw-value headline) "Headline"))))
|
2012-09-29 02:54:46 -04:00
|
|
|
|
;; With the keyword only.
|
|
|
|
|
(org-test-with-temp-text "* QUOTE"
|
2012-09-29 03:46:09 -04:00
|
|
|
|
(let* ((org-quote-string "QUOTE")
|
|
|
|
|
(headline (org-element-at-point)))
|
|
|
|
|
(should (org-element-property :quotedp headline))
|
|
|
|
|
(should (equal (org-element-property :raw-value headline) "")))))
|
2012-04-30 11:20:57 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/headline-comment-keyword ()
|
|
|
|
|
"Test COMMENT keyword recognition."
|
|
|
|
|
;; Reference test.
|
|
|
|
|
(org-test-with-temp-text "* Headline"
|
|
|
|
|
(let ((org-comment-string "COMMENT"))
|
|
|
|
|
(should-not (org-element-property :commentedp (org-element-at-point)))))
|
|
|
|
|
;; Standard position.
|
|
|
|
|
(org-test-with-temp-text "* COMMENT Headline"
|
2012-09-29 03:46:09 -04:00
|
|
|
|
(let ((org-comment-string "COMMENT")
|
|
|
|
|
(headline (org-element-at-point)))
|
|
|
|
|
(should (org-element-property :commentedp headline))
|
|
|
|
|
(should (equal (org-element-property :raw-value headline) "Headline"))))
|
|
|
|
|
;; Case sensitivity.
|
|
|
|
|
(org-test-with-temp-text "* COMMENT Headline"
|
|
|
|
|
(let* ((org-comment-string "Comment")
|
|
|
|
|
(headline (org-element-at-point)))
|
|
|
|
|
(should-not (org-element-property :commentedp headline))
|
|
|
|
|
(should (equal (org-element-property :raw-value headline)
|
|
|
|
|
"COMMENT Headline"))))
|
2012-04-30 11:20:57 -04:00
|
|
|
|
;; With another keyword.
|
|
|
|
|
(org-test-with-temp-text "* TODO COMMENT Headline"
|
2012-09-29 03:46:09 -04:00
|
|
|
|
(let* ((org-comment-string "COMMENT")
|
|
|
|
|
(org-todo-keywords '((sequence "TODO" "DONE")))
|
|
|
|
|
(headline (org-element-at-point)))
|
|
|
|
|
(should (org-element-property :commentedp headline))
|
|
|
|
|
(should (equal (org-element-property :raw-value headline) "Headline"))))
|
2012-09-29 02:54:46 -04:00
|
|
|
|
;; With the keyword only.
|
|
|
|
|
(org-test-with-temp-text "* COMMENT"
|
2012-09-29 03:46:09 -04:00
|
|
|
|
(let* ((org-comment-string "COMMENT")
|
|
|
|
|
(headline (org-element-at-point)))
|
|
|
|
|
(should (org-element-property :commentedp headline))
|
|
|
|
|
(should (equal (org-element-property :raw-value headline) "")))))
|
2012-04-30 11:20:57 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/headline-archive-tag ()
|
|
|
|
|
"Test ARCHIVE tag recognition."
|
|
|
|
|
;; Reference test.
|
|
|
|
|
(org-test-with-temp-text "* Headline"
|
|
|
|
|
(let ((org-archive-tag "ARCHIVE"))
|
|
|
|
|
(should-not (org-element-property :archivedp (org-element-at-point)))))
|
|
|
|
|
;; Single tag.
|
|
|
|
|
(org-test-with-temp-text "* Headline :ARCHIVE:"
|
|
|
|
|
(let ((org-archive-tag "ARCHIVE"))
|
|
|
|
|
(let ((headline (org-element-at-point)))
|
|
|
|
|
(should (org-element-property :archivedp headline))
|
|
|
|
|
;; Test tag removal.
|
|
|
|
|
(should-not (org-element-property :tags headline))))
|
|
|
|
|
(let ((org-archive-tag "Archive"))
|
|
|
|
|
(should-not (org-element-property :archivedp (org-element-at-point)))))
|
|
|
|
|
;; Multiple tags.
|
|
|
|
|
(org-test-with-temp-text "* Headline :test:ARCHIVE:"
|
|
|
|
|
(let ((org-archive-tag "ARCHIVE"))
|
|
|
|
|
(let ((headline (org-element-at-point)))
|
|
|
|
|
(should (org-element-property :archivedp headline))
|
|
|
|
|
;; Test tag removal.
|
org-element: Internally store headline/inlinetask's tags as a list of strings
* contrib/lisp/org-element.el (org-element-headline-parser,
org-element-headline-interpreter, org-element-inlinetask-parser,
org-element-inlinetask-interpreter): Store headline/inlinetask's
tags as a list of strings.
* contrib/lisp/org-export.el (org-export--selected-trees,
org-export--skip-p): Use new tag representation.
* contrib/lisp/org-e-ascii.el (org-e-ascii--build-title,
org-e-ascii-format-inlinetask-function, org-e-ascii-inlinetask): Use
new tag representation.
* contrib/lisp/org-e-html.el (org-e-html-format-headline-function,
org-e-html-format-inlinetask-function, org-e-html--tags): Use new
tag representation.
* contrib/lisp/org-e-latex.el (org-e-latex-format-headline-function,
org-e-latex-format-inlinetask-function, org-e-latex-headline,
org-e-latex-inlinetask): Use new tag representation.
* contrib/lisp/org-e-odt.el (org-e-odt-format-org-tags): Use new tag
representation.
* testing/lisp/test-org-element.el: Update test.
2012-05-01 08:10:12 -04:00
|
|
|
|
(should (equal (org-element-property :tags headline) '("test")))))))
|
2012-04-30 11:20:57 -04:00
|
|
|
|
|
2013-02-18 02:58:59 -05:00
|
|
|
|
(ert-deftest test-org-element/headline-properties ()
|
|
|
|
|
"Test properties from property drawer."
|
|
|
|
|
;; All properties from property drawer have their symbol upper
|
|
|
|
|
;; cased.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "* Headline\n:PROPERTIES:\n:foo: bar\n:END:"
|
|
|
|
|
(org-element-property :FOO (org-element-at-point))))
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "* Headline\n:PROPERTIES:\n:foo: bar\n:END:"
|
|
|
|
|
(org-element-property :foo (org-element-at-point)))))
|
|
|
|
|
|
2012-04-30 11:20:57 -04:00
|
|
|
|
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;;;; Horizontal Rule
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/horizontal-rule-parser ()
|
|
|
|
|
"Test `horizontal-rule' parser."
|
|
|
|
|
;; Standard.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "-----"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'horizontal-rule 'identity)))
|
|
|
|
|
;; Indented.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text " -----"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'horizontal-rule 'identity)))
|
|
|
|
|
;; Hyphen must be alone on the line.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "-----wrong"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'horizontal-rule 'identity)))
|
|
|
|
|
;; 4 hyphens is too small.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "----"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'horizontal-rule 'identity))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Inline Babel Call
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/inline-babel-call-parser ()
|
|
|
|
|
"Test `inline-babel-call' parser."
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "call_test()"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'inline-babel-call 'identity))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Inline Src Block
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/inline-src-block-parser ()
|
|
|
|
|
"Test `inline-src-block' parser."
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "src_emacs-lisp{(+ 1 1)}"
|
2012-09-20 13:12:39 -04:00
|
|
|
|
(org-element-map (org-element-parse-buffer) 'inline-src-block 'identity)))
|
|
|
|
|
;; Test parsing at the beginning of an item.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "- src_emacs-lisp{(+ 1 1)}"
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-element-map (org-element-parse-buffer) 'inline-src-block 'identity))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Inlinetask
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/inlinetask-parser ()
|
|
|
|
|
"Test `inlinetask' parser."
|
|
|
|
|
(when (featurep 'org-inlinetask)
|
|
|
|
|
(let ((org-inlinetask-min-level 15))
|
|
|
|
|
;; 1. Regular inlinetask.
|
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"*************** Task\nTest\n*************** END"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'inlinetask 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; 2. Degenerate inlinetask.
|
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "*************** Task"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'inlinetask 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; TODO keyword.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"TODO"
|
|
|
|
|
(let ((org-todo-keywords '((sequence "TODO" "DONE"))))
|
|
|
|
|
(org-test-with-temp-text "*************** TODO Task"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:todo-keyword
|
2013-02-18 02:58:59 -05:00
|
|
|
|
(org-element-map (org-element-parse-buffer) 'inlinetask
|
|
|
|
|
'identity nil t))))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Planning info.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"2012-03-29 thu."
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
*************** Task
|
|
|
|
|
DEADLINE: <2012-03-29 thu.>"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:deadline
|
2013-02-18 02:58:59 -05:00
|
|
|
|
(org-element-map (org-element-parse-buffer) 'inlinetask 'identity nil t)))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Priority.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
?A
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
*************** [#A] Task"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:priority
|
|
|
|
|
(org-element-map
|
2013-02-18 02:58:59 -05:00
|
|
|
|
(org-element-parse-buffer) 'inlinetask 'identity nil t)))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Tags.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("test")
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
*************** Task :test:"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:tags
|
|
|
|
|
(org-element-map
|
2013-02-18 02:58:59 -05:00
|
|
|
|
(org-element-parse-buffer) 'inlinetask 'identity nil t)))))
|
|
|
|
|
;; Regular properties are accessed through upper case keywords.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
*************** Task
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:foo: bar
|
|
|
|
|
:END:
|
|
|
|
|
*************** END"
|
|
|
|
|
(forward-line)
|
|
|
|
|
(org-element-property :FOO (org-element-at-point))))
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
*************** Task
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:foo: bar
|
|
|
|
|
:END:
|
|
|
|
|
*************** END"
|
|
|
|
|
(forward-line)
|
|
|
|
|
(org-element-property :foo (org-element-at-point)))))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;;;; Italic
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/italic-parser ()
|
|
|
|
|
"Test `italic' parser."
|
|
|
|
|
;; Regular test.
|
|
|
|
|
(should
|
|
|
|
|
(let ((org-emph-re "\\([ ('\"{]\\|^\\)\\(\\([+*/_=~]\\)\\([^
\n,\"']\\|[^
\n,\"'].*?\\(?:\n.*?\\)\\{0,1\\}[^
\n,\"']\\)\\3\\)\\([- .,:!?;'\")}\\]\\|$\\)"))
|
|
|
|
|
(org-test-with-temp-text "/italic/"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'italic 'identity nil t))))
|
|
|
|
|
;; Multi-line markup.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(org-element-contents
|
|
|
|
|
(let ((org-emph-re "\\([ ('\"{]\\|^\\)\\(\\([+*/_=~]\\)\\([^
\n,\"']\\|[^
\n,\"'].*?\\(?:\n.*?\\)\\{0,1\\}[^
\n,\"']\\)\\3\\)\\([- .,:!?;'\")}\\]\\|$\\)"))
|
|
|
|
|
(org-test-with-temp-text "/first line\nsecond line/"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'italic 'identity nil t))))
|
|
|
|
|
'("first line\nsecond line"))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Item
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/item-parser ()
|
|
|
|
|
"Test `item' parser."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
2012-05-05 13:57:37 -04:00
|
|
|
|
(org-test-with-temp-text "- item"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'item 'identity)))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Counter.
|
|
|
|
|
(should
|
|
|
|
|
(= 6
|
|
|
|
|
(org-element-property
|
|
|
|
|
:counter
|
|
|
|
|
(org-test-with-temp-text "6. [@6] item"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'item 'identity nil t)))))
|
|
|
|
|
;; Tag
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("tag")
|
|
|
|
|
(org-element-property
|
|
|
|
|
:tag
|
|
|
|
|
(org-test-with-temp-text "- tag :: description"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'item 'identity nil t)))))
|
2012-08-18 06:37:39 -04:00
|
|
|
|
;; No tags in ordered lists.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-element-property
|
|
|
|
|
:tag
|
|
|
|
|
(org-test-with-temp-text "1. tag :: description"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'item 'identity nil t))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
;; Check-boxes
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(trans on off)
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
- [-] item 1
|
|
|
|
|
- [X] item 1.1
|
|
|
|
|
- [ ] item 1.2"
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'item
|
|
|
|
|
(lambda (item) (org-element-property :checkbox item))))))
|
|
|
|
|
;; Folded state.
|
|
|
|
|
(org-test-with-temp-text "* Headline
|
|
|
|
|
- item
|
|
|
|
|
|
|
|
|
|
paragraph below"
|
|
|
|
|
(forward-line)
|
|
|
|
|
(let ((org-cycle-include-plain-lists t)) (org-cycle))
|
|
|
|
|
(should
|
|
|
|
|
(org-element-property
|
|
|
|
|
:hiddenp
|
2012-09-12 09:40:13 -04:00
|
|
|
|
(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)))))
|
2012-05-04 13:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;;;; Keyword
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/keyword-parser ()
|
|
|
|
|
"Test `keyword' parser."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "#+KEYWORD: value"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'keyword 'identity)))
|
|
|
|
|
;; Keywords are case-insensitive.
|
|
|
|
|
(should
|
2012-06-08 14:16:57 -04:00
|
|
|
|
(org-test-with-temp-text "#+keyword: value"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'keyword 'identity)))
|
2012-05-05 13:57:37 -04:00
|
|
|
|
;; Affiliated keywords are not keywords.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "#+NAME: value
|
|
|
|
|
Paragraph"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'keyword 'identity)))
|
|
|
|
|
;; Do not mix keywords with Babel calls and dynamic blocks.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "#+CALL: fun()"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'keyword 'identity)))
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-temp-text "#+BEGIN: my-fun\nBody\n#+END:"
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'keyword 'identity))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Latex Environment
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/latex-environment-parser ()
|
|
|
|
|
"Test `latex-environment' parser."
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "\\begin{equation}\ne^{i\\pi}+1=0\n\\end{equation}"
|
|
|
|
|
(org-element-map
|
2012-05-10 16:55:12 -04:00
|
|
|
|
(org-element-parse-buffer) 'latex-environment 'identity)))
|
|
|
|
|
;; Allow nested environments.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"\\begin{outer}
|
|
|
|
|
\\begin{inner}
|
|
|
|
|
e^{i\\pi}+1=0
|
|
|
|
|
\\end{inner}
|
|
|
|
|
\\end{outer}"
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
\\begin{outer}
|
|
|
|
|
\\begin{inner}
|
|
|
|
|
e^{i\\pi}+1=0
|
|
|
|
|
\\end{inner}
|
|
|
|
|
\\end{outer}"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:value
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-element-parse-buffer) 'latex-environment 'identity nil t))))))
|
2012-05-05 13:57:37 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Latex Fragment
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-element/latex-fragment-parser ()
|
|
|
|
|
"Test `latex-fragment' parser."
|
|
|
|
|
(let ((org-latex-regexps
|
|
|
|
|
'(("begin" "^[ ]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^ |