1 ;;; test-org-export.el --- Tests for org-export.el
3 ;; Copyright (C) 2012 Nicolas Goaziou
5 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
7 ;; Released under the GNU General Public License version 3
8 ;; see: http://www.gnu.org/licenses/gpl-3.0.html
16 (unless (featurep 'org-export
)
17 (signal 'missing-test-dependency
"org-export"))
19 (defmacro org-test-with-backend
(backend &rest body
)
20 "Execute body with an export back-end defined.
22 BACKEND is the name of the back-end. BODY is the body to
23 execute. The defined back-end simply returns parsed data as Org
25 (declare (debug (form body
)) (indent 1))
26 `(let ((,(intern (format "org-%s-translate-alist" backend
))
27 ',(let (transcode-table)
28 (dolist (type (append org-element-all-elements
29 org-element-all-objects
)
33 (lambda (obj contents info
)
35 (intern (format "org-element-%s-interpreter" type
))
40 (defmacro org-test-with-parsed-data
(data &rest body
)
41 "Execute body with parsed data available.
43 DATA is a string containing the data to be parsed. BODY is the
44 body to execute. Parse tree is available under the `tree'
45 variable, and communication channel under `info'.
47 This function calls `org-export-collect-tree-properties'. As
48 such, `:ignore-list' (for `org-element-map') and
49 `:parse-tree' (for `org-export-get-genealogy') properties are
50 already filled in `info'."
51 (declare (debug (form body
)) (indent 1))
52 `(org-test-with-temp-text ,data
53 (let* ((tree (org-element-parse-buffer))
54 (info (org-export-collect-tree-properties
55 tree
(org-export-get-environment))))
62 (ert-deftest test-org-export
/parse-option-keyword
()
63 "Test reading all standard #+OPTIONS: items."
66 (org-export--parse-option-keyword
67 "H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t
68 *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t inline:nil
71 1 :preserve-breaks t
:section-numbers t
:time-stamp-file t
72 :with-archived-trees t
:with-author t
:with-creator t
:with-drawers t
73 :with-email t
:with-emphasize t
:with-entities t
:with-fixed-width t
74 :with-footnotes t
:with-inlinetasks nil
:with-priority t
75 :with-special-strings t
:with-statistics-cookies t
:with-sub-superscript t
76 :with-toc t
:with-tables t
:with-tags t
:with-tasks t
:with-timestamps t
77 :with-todo-keywords t
)))
78 ;; Test some special values.
81 (org-export--parse-option-keyword
82 "arch:headline creator:comment d:(\"TEST\")
83 ^:{} toc:1 tags:not-in-toc tasks:todo num:2 <:active")
86 :with-archived-trees headline
:with-creator comment
87 :with-drawers
("TEST") :with-sub-superscript
{} :with-toc
1
88 :with-tags not-in-toc
:with-tasks todo
:with-timestamps active
))))
90 (ert-deftest test-org-export
/get-inbuffer-options
()
91 "Test reading all standard export keywords."
94 (org-test-with-temp-text "#+AUTHOR: Me, Myself and I
97 #+DESCRIPTION: Testing
98 #+DESCRIPTION: with two lines
99 #+EMAIL: some@email.org
100 #+EXCLUDE_TAGS: noexport invisible
103 #+SELECT_TAGS: export
105 #+TITLE: with spaces"
106 (org-export--get-inbuffer-options))
108 ("Me, Myself and I") :creator
"Idem" :date
("Today")
109 :description
"Testing\nwith two lines" :email
"some@email.org"
110 :exclude-tags
("noexport" "invisible") :keywords
"test" :language
"en"
111 :select-tags
("export") :title
("Some title with spaces")))))
113 (ert-deftest test-org-export
/get-subtree-options
()
114 "Test setting options from headline's properties."
116 (org-test-with-temp-text "#+TITLE: Title
119 :EXPORT_TITLE: Subtree Title
123 (should (equal (plist-get (org-export-get-environment nil t
) :title
)
124 '("Subtree Title"))))
128 (org-test-with-temp-text "#+OPTIONS: H:1
136 (= 2 (plist-get (org-export-get-environment nil t
) :headline-levels
))))
138 (org-test-with-temp-text "#+DATE: today
141 :EXPORT_DATE: 29-03-2012
145 (should (equal (plist-get (org-export-get-environment nil t
) :date
)
147 ;; Export properties are case-insensitive.
148 (org-test-with-temp-text "* Headline
150 :EXPORT_Date: 29-03-2012
153 (should (equal (plist-get (org-export-get-environment nil t
) :date
)
156 (ert-deftest test-org-export
/handle-options
()
157 "Test if export options have an impact on output."
158 ;; Test exclude tags.
159 (org-test-with-temp-text "* Head1 :noexport:"
160 (org-test-with-backend test
162 (equal (org-export-as 'test nil nil nil
'(:exclude-tags
("noexport")))
164 ;; Test include tags.
165 (org-test-with-temp-text "
168 ** Sub-Head2.1 :export:
171 (org-test-with-backend test
174 "* Head2\n** Sub-Head2.1 :export:\n*** Sub-Head2.1.1\n"
175 (let ((org-tags-column 0))
176 (org-export-as 'test nil nil nil
'(:select-tags
("export"))))))))
177 ;; Test mixing include tags and exclude tags.
178 (org-test-with-temp-text "
180 ** Sub-Head1 :noexport:
183 ** Sub-Head1 :export:"
184 (org-test-with-backend test
187 "\\* Head1[ \t]+:export:\n\\*\\* Sub-Head2\n"
190 '(:select-tags
("export") :exclude-tags
("noexport")))))))
192 (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
193 (org-test-with-temp-text "* TODO Head1"
194 (org-test-with-backend test
195 (should (equal (org-export-as 'test nil nil nil
'(:with-tasks nil
))
197 (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
198 (org-test-with-temp-text "* TODO Head1"
199 (org-test-with-backend test
200 (should (equal (org-export-as 'test nil nil nil
'(:with-tasks t
))
201 "* TODO Head1\n")))))
203 (org-test-with-temp-text "* Head1 :archive:"
204 (let ((org-archive-tag "archive"))
205 (org-test-with-backend test
207 (equal (org-export-as 'test nil nil nil
'(:with-archived-trees nil
))
209 (org-test-with-temp-text "* Head1 :archive:\nbody\n** Sub-head 2"
210 (let ((org-archive-tag "archive"))
211 (org-test-with-backend test
214 "\\* Head1[ \t]+:archive:"
215 (org-export-as 'test nil nil nil
216 '(:with-archived-trees headline
)))))))
217 (org-test-with-temp-text "* Head1 :archive:"
218 (let ((org-archive-tag "archive"))
219 (org-test-with-backend test
222 "\\`\\* Head1[ \t]+:archive:\n\\'"
223 (org-export-as 'test nil nil nil
'(:with-archived-trees t
)))))))
225 (let ((org-drawers '("TEST")))
226 (org-test-with-temp-text ":TEST:\ncontents\n:END:"
227 (org-test-with-backend test
228 (should (equal (org-export-as 'test nil nil nil
'(:with-drawers nil
))
230 (should (equal (org-export-as 'test nil nil nil
'(:with-drawers t
))
231 ":TEST:\ncontents\n:END:\n")))))
232 (let ((org-drawers '("FOO" "BAR")))
233 (org-test-with-temp-text ":FOO:\nkeep\n:END:\n:BAR:\nremove\n:END:"
234 (org-test-with-backend test
236 (equal (org-export-as 'test nil nil nil
'(:with-drawers
("FOO")))
237 ":FOO:\nkeep\n:END:\n")))))
239 (org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
240 (org-test-with-backend test
242 (equal (org-export-as 'test nil nil nil
'(:with-timestamps t
))
243 "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>\n"))
245 (equal (org-export-as 'test nil nil nil
'(:with-timestamps nil
)) ""))
247 (equal (org-export-as 'test nil nil nil
'(:with-timestamps active
))
248 "<2012-04-29 sun. 10:45>\n"))
250 (equal (org-export-as 'test nil nil nil
'(:with-timestamps inactive
))
251 "[2012-04-29 sun. 10:45]\n"))))
253 (let ((org-clock-string "CLOCK:"))
254 (org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
255 (org-test-with-backend test
257 (equal (org-export-as 'test nil nil nil
'(:with-clocks t
))
258 "CLOCK: [2012-04-29 sun. 10:45]\n"))
260 (equal (org-export-as 'test nil nil nil
'(:with-clocks nil
)) "")))))
262 (let ((org-closed-string "CLOSED:"))
263 (org-test-with-temp-text "CLOSED: [2012-04-29 sun. 10:45]"
264 (org-test-with-backend test
266 (equal (org-export-as 'test nil nil nil
'(:with-plannings t
))
267 "CLOSED: [2012-04-29 sun. 10:45]\n"))
269 (equal (org-export-as 'test nil nil nil
'(:with-plannings nil
))
272 (when (featurep 'org-inlinetask
)
275 (let ((org-inlinetask-min-level 15))
276 (org-test-with-temp-text "*************** Task"
277 (org-test-with-backend test
278 (org-export-as 'test nil nil nil
'(:with-inlinetasks nil
)))))
282 (let ((org-inlinetask-min-level 15))
283 (org-test-with-temp-text
284 "*************** Task\nContents\n*************** END"
285 (org-test-with-backend test
286 (org-export-as 'test nil nil nil
'(:with-inlinetasks nil
)))))
288 ;; Statistics cookies.
291 (org-test-with-temp-text "[0/0]"
292 (org-test-with-backend test
294 'test nil nil nil
'(:with-statistics-cookies nil
)))))))
296 (ert-deftest test-org-export
/comment-tree
()
297 "Test if export process ignores commented trees."
298 (let ((org-comment-string "COMMENT"))
299 (org-test-with-temp-text "* COMMENT Head1"
300 (org-test-with-backend test
301 (should (equal (org-export-as 'test
) ""))))))
303 (ert-deftest test-org-export
/export-scope
()
304 "Test all export scopes."
305 (org-test-with-temp-text "
310 (org-test-with-backend test
313 (should (equal (org-export-as 'test
'subtree
) "text\n*** Head3\n"))
315 (goto-char (point-min))
318 (should (equal (org-export-as 'test nil
'visible
) "* Head1\n"))
320 (flet ((org-test-template (body info
) (format "BEGIN\n%sEND" body
)))
321 (push '(template . org-test-template
) org-test-translate-alist
)
322 (should (equal (org-export-as 'test nil nil
'body-only
)
323 "* Head1\n** Head2\ntext\n*** Head3\n"))
324 (should (equal (org-export-as 'test
)
325 "BEGIN\n* Head1\n** Head2\ntext\n*** Head3\nEND")))
327 (goto-char (point-min))
329 (transient-mark-mode 1)
330 (push-mark (point) t t
)
331 (goto-char (point-at-eol))
332 (should (equal (org-export-as 'test
) "text\n"))))
333 ;; Subtree with a code block calling another block outside.
334 (org-test-with-temp-text "
336 #+BEGIN_SRC emacs-lisp :noweb yes :exports results
341 #+BEGIN_SRC emacs-lisp
344 (org-test-with-backend test
346 (should (equal (org-export-as 'test
'subtree
) ": 3\n")))))
348 (ert-deftest test-org-export
/expand-include
()
349 "Test file inclusion in an Org buffer."
350 ;; Full insertion with recursive inclusion.
351 (org-test-with-temp-text
352 (format "#+INCLUDE: \"%s/examples/include.org\"" org-test-dir
)
353 (org-export-expand-include-keyword)
354 (should (equal (buffer-string)
355 "Small Org file with an include keyword.
357 #+BEGIN_SRC emacs-lisp :exports results\n(+ 2 1)\n#+END_SRC
363 ;; Localized insertion.
364 (org-test-with-temp-text
365 (format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\""
367 (org-export-expand-include-keyword)
368 (should (equal (buffer-string)
369 "Small Org file with an include keyword.\n")))
370 ;; Insertion with constraints on headlines level.
371 (org-test-with-temp-text
373 "* Top heading\n#+INCLUDE: \"%s/examples/include.org\" :lines \"9-\""
375 (org-export-expand-include-keyword)
376 (should (equal (buffer-string) "* Top heading\n** Heading\nbody\n")))
377 ;; Inclusion within an example block.
378 (org-test-with-temp-text
379 (format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\" example"
381 (org-export-expand-include-keyword)
385 "#+BEGIN_EXAMPLE\nSmall Org file with an include keyword.\n#+END_EXAMPLE\n")))
386 ;; Inclusion within a src-block.
387 (org-test-with-temp-text
389 "#+INCLUDE: \"%s/examples/include.org\" :lines \"4-5\" src emacs-lisp"
391 (org-export-expand-include-keyword)
392 (should (equal (buffer-string)
393 "#+BEGIN_SRC emacs-lisp\n(+ 2 1)\n#+END_SRC\n"))))
395 (ert-deftest test-org-export
/user-ignore-list
()
396 "Test if `:ignore-list' accepts user input."
397 (org-test-with-backend test
398 (flet ((skip-note-head
400 ;; Ignore headlines with the word "note" in their title.
404 (when (string-match "\\<note\\>"
405 (org-element-property :raw-value headline
))
406 (org-export-ignore-element headline info
)))
409 ;; Install function in parse tree filters.
410 (let ((org-export-filter-parse-tree-functions '(skip-note-head)))
411 (org-test-with-temp-text "* Head1\n* Head2 (note)\n"
412 (should (equal (org-export-as 'test
) "* Head1\n")))))))
414 (ert-deftest test-org-export
/before-parsing-hook
()
415 "Test `org-export-before-parsing-hook'."
416 (org-test-with-backend test
417 (org-test-with-temp-text "* Headline 1\nBody 1\n* Headline 2\nBody 2"
418 (let ((org-export-before-parsing-hook
422 (delete-region (point) (progn (forward-line) (point)))))))))
423 (should (equal (org-export-as 'test
) "Body 1\nBody 2\n"))))))
427 ;;; Affiliated Keywords
429 (ert-deftest test-org-export
/read-attribute
()
430 "Test `org-export-read-attribute' specifications."
434 (org-export-read-attribute
436 (org-test-with-temp-text "#+ATTR_HTML: :a 1 :b 2\nParagraph"
437 (org-element-at-point)))
439 ;; Return nil on empty attribute.
441 (org-export-read-attribute
443 (org-test-with-temp-text "Paragraph" (org-element-at-point)))))
449 (ert-deftest test-org-export
/export-snippet
()
450 "Test export snippets transcoding."
451 (org-test-with-temp-text "@@test:A@@@@t:B@@"
452 (org-test-with-backend test
453 (let ((org-test-translate-alist
454 (cons (cons 'export-snippet
455 (lambda (snippet contents info
)
456 (when (eq (org-export-snippet-backend snippet
) 'test
)
457 (org-element-property :value snippet
))))
458 org-test-translate-alist
)))
459 (let ((org-export-snippet-translation-alist nil
))
460 (should (equal (org-export-as 'test
) "A\n")))
461 (let ((org-export-snippet-translation-alist '(("t" .
"test"))))
462 (should (equal (org-export-as 'test
) "AB\n")))))))
468 (ert-deftest test-org-export
/footnotes
()
469 "Test footnotes specifications."
470 (let ((org-footnote-section nil
)
471 (org-export-with-footnotes t
))
472 ;; 1. Read every type of footnote.
475 '((1 .
"A\n") (2 .
"B") (3 .
"C") (4 .
"D"))
476 (org-test-with-parsed-data
477 "Text[fn:1] [1] [fn:label:C] [fn::D]\n\n[fn:1] A\n\n[1] B"
479 tree
'footnote-reference
481 (let ((def (org-export-get-footnote-definition ref info
)))
482 (cons (org-export-get-footnote-number ref info
)
483 (if (eq (org-element-property :type ref
) 'inline
) (car def
)
484 (car (org-element-contents
485 (car (org-element-contents def
))))))))
487 ;; 2. Test nested footnotes order.
488 (org-test-with-parsed-data
489 "Text[fn:1:A[fn:2]] [fn:3].\n\n[fn:2] B [fn:3] [fn::D].\n\n[fn:3] C."
492 '((1 .
"fn:1") (2 .
"fn:2") (3 .
"fn:3") (4))
494 tree
'footnote-reference
496 (when (org-export-footnote-first-reference-p ref info
)
497 (cons (org-export-get-footnote-number ref info
)
498 (org-element-property :label ref
))))
500 ;; 3. Test nested footnote in invisible definitions.
501 (org-test-with-temp-text "Text[1]\n\n[1] B [2]\n\n[2] C."
503 (narrow-to-region (point) (point-at-eol))
504 (let* ((tree (org-element-parse-buffer))
505 (info (org-combine-plists
507 (org-export-collect-tree-properties
508 tree
(org-export-get-environment)))))
509 ;; Both footnotes should be seen.
511 (= (length (org-export-collect-footnote-definitions tree info
)) 2))))
512 ;; 4. Test footnotes definitions collection.
513 (org-test-with-parsed-data "Text[fn:1:A[fn:2]] [fn:3].
515 \[fn:2] B [fn:3] [fn::D].
518 (should (= (length (org-export-collect-footnote-definitions tree info
))
520 ;; 5. Test export of footnotes defined outside parsing scope.
521 (org-test-with-temp-text "[fn:1] Out of scope
524 (org-test-with-backend test
525 (let ((org-test-translate-alist
526 (cons (cons 'footnote-reference
527 (lambda (fn contents info
)
528 (org-element-interpret-data
529 (org-export-get-footnote-definition fn info
))))
530 org-test-translate-alist
)))
532 (should (equal "ParagraphOut of scope\n"
533 (org-export-as 'test
'subtree
))))))))
537 ;;; Headlines and Inlinetasks
539 (ert-deftest test-org-export
/get-relative-level
()
540 "Test `org-export-get-relative-level' specifications."
544 (let ((org-odd-levels-only nil
))
545 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
548 (lambda (h) (org-export-get-relative-level h info
))
553 (let ((org-odd-levels-only nil
))
554 (org-test-with-parsed-data "** Headline 1\n**** Headline 2"
557 (lambda (h) (org-export-get-relative-level h info
))
560 (ert-deftest test-org-export
/low-level-p
()
561 "Test `org-export-low-level-p' specifications."
565 (let ((org-odd-levels-only nil
))
566 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
569 (lambda (h) (if (org-export-low-level-p h info
) 'yes
'no
))
570 (plist-put info
:headline-levels
1)))))))
572 (ert-deftest test-org-export
/get-headline-number
()
573 "Test `org-export-get-headline-number' specifications."
578 (let ((org-odd-levels-only nil
))
579 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
582 (lambda (h) (org-export-get-headline-number h info
))
584 ;; Missing levels are replaced with 0.
588 (let ((org-odd-levels-only nil
))
589 (org-test-with-parsed-data "* Headline 1\n*** Headline 2"
592 (lambda (h) (org-export-get-headline-number h info
))
595 (ert-deftest test-org-export
/numbered-headline-p
()
596 "Test `org-export-numbered-headline-p' specifications."
597 ;; If `:section-numbers' is nil, never number headlines.
599 (org-test-with-parsed-data "* Headline"
602 (lambda (h) (org-export-numbered-headline-p h info
))
603 (plist-put info
:section-numbers nil
))))
604 ;; If `:section-numbers' is a number, only number headlines with
605 ;; a level greater that it.
609 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
612 (lambda (h) (if (org-export-numbered-headline-p h info
) 'yes
'no
))
613 (plist-put info
:section-numbers
1)))))
614 ;; Otherwise, headlines are always numbered.
616 (org-test-with-parsed-data "* Headline"
619 (lambda (h) (org-export-numbered-headline-p h info
))
620 (plist-put info
:section-numbers t
)))))
622 (ert-deftest test-org-export
/number-to-roman
()
623 "Test `org-export-number-to-roman' specifications."
624 ;; If number is negative, return it as a string.
625 (should (equal (org-export-number-to-roman -
1) "-1"))
626 ;; Otherwise, return it as a roman number.
627 (should (equal (org-export-number-to-roman 1449) "MCDXLIX")))
629 (ert-deftest test-org-export
/get-tags
()
630 "Test `org-export-get-tags' specifications."
631 (let ((org-export-exclude-tags '("noexport"))
632 (org-export-select-tags '("export")))
633 ;; Standard test: tags which are not a select tag, an exclude tag,
634 ;; or specified as optional argument shouldn't be ignored.
636 (org-test-with-parsed-data "* Headline :tag:"
637 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
639 ;; Exclude tags are removed.
641 (org-test-with-parsed-data "* Headline :noexport:"
642 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
644 ;; Select tags are removed.
646 (org-test-with-parsed-data "* Headline :export:"
647 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
652 (org-test-with-parsed-data "* Headline :tag:export:"
653 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
655 ;; Tags provided in the optional argument are also ignored.
657 (org-test-with-parsed-data "* Headline :ignore:"
658 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
659 info
'("ignore"))))))
661 (ert-deftest test-org-export
/first-sibling-p
()
662 "Test `org-export-first-sibling-p' specifications."
667 (org-test-with-parsed-data "* Headline\n** Headline 2\n** Headline 3"
670 (lambda (h) (if (org-export-first-sibling-p h info
) 'yes
'no
))
672 ;; Ignore headlines not exported.
676 (let ((org-export-exclude-tags '("ignore")))
677 (org-test-with-parsed-data "* Headline :ignore:\n* Headline 2"
680 (lambda (h) (if (org-export-first-sibling-p h info
) 'yes
'no
))
683 (ert-deftest test-org-export
/last-sibling-p
()
684 "Test `org-export-last-sibling-p' specifications."
689 (org-test-with-parsed-data "* Headline\n** Headline 2\n** Headline 3"
692 (lambda (h) (if (org-export-last-sibling-p h info
) 'yes
'no
))
694 ;; Ignore headlines not exported.
698 (let ((org-export-exclude-tags '("ignore")))
699 (org-test-with-parsed-data "* Headline\n* Headline 2 :ignore:"
702 (lambda (h) (if (org-export-last-sibling-p h info
) 'yes
'no
))
709 (ert-deftest test-org-export
/get-coderef-format
()
710 "Test `org-export-get-coderef-format' specifications."
711 ;; A link without description returns "%s"
712 (should (equal (org-export-get-coderef-format "(ref:line)" nil
)
714 ;; Return "%s" when path is matched within description.
715 (should (equal (org-export-get-coderef-format "path" "desc (path)")
717 ;; Otherwise return description.
718 (should (equal (org-export-get-coderef-format "path" "desc")
721 (ert-deftest test-org-export
/inline-image-p
()
722 "Test `org-export-inline-image-p' specifications."
724 (org-export-inline-image-p
725 (org-test-with-temp-text "[[#id]]"
727 (org-element-parse-buffer) 'link
'identity nil t
))
728 '(("custom-id" .
"id")))))
730 (ert-deftest test-org-export
/fuzzy-link
()
731 "Test fuzzy links specifications."
732 ;; 1. Links to invisible (keyword) targets should be ignored.
733 (org-test-with-parsed-data
734 "Paragraph.\n#+TARGET: Test\n[[Test]]"
739 (org-export-get-ordinal
740 (org-export-resolve-fuzzy-link link info
) info
)) info
)))
741 ;; 2. Link to an headline should return headline's number.
742 (org-test-with-parsed-data
743 "Paragraph.\n* Head1\n* Head2\n* Head3\n[[Head2]]"
745 ;; Note: Headline's number is in fact a list of numbers.
750 (org-export-get-ordinal
751 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
752 ;; 3. Link to a target in an item should return item's number.
753 (org-test-with-parsed-data
754 "- Item1\n - Item11\n - <<test>>Item12\n- Item2\n\n\n[[test]]"
756 ;; Note: Item's number is in fact a list of numbers.
761 (org-export-get-ordinal
762 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
763 ;; 4. Link to a target in a footnote should return footnote's
765 (org-test-with-parsed-data "
766 Paragraph[1][2][fn:lbl3:C<<target>>][[test]][[target]]\n[1] A\n\n[2] <<test>>B"
772 (org-export-get-ordinal
773 (org-export-resolve-fuzzy-link link info
) info
)) info
))))
774 ;; 5. Link to a named element should return sequence number of that
776 (org-test-with-parsed-data
777 "#+NAME: tbl1\n|1|2|\n#+NAME: tbl2\n|3|4|\n#+NAME: tbl3\n|5|6|\n[[tbl2]]"
783 (org-export-get-ordinal
784 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
785 ;; 6. Link to a target not within an item, a table, a footnote
786 ;; reference or definition should return section number.
787 (org-test-with-parsed-data
788 "* Head1\n* Head2\nParagraph<<target>>\n* Head3\n[[target]]"
794 (org-export-get-ordinal
795 (org-export-resolve-fuzzy-link link info
) info
)) info t
)))))
797 (ert-deftest test-org-export
/resolve-coderef
()
798 "Test `org-export-resolve-coderef' specifications."
799 (let ((org-coderef-label-format "(ref:%s)"))
800 ;; 1. A link to a "-n -k -r" block returns line number.
801 (org-test-with-parsed-data
802 "#+BEGIN_EXAMPLE -n -k -r\nText (ref:coderef)\n#+END_EXAMPLE"
803 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
804 (org-test-with-parsed-data
805 "#+BEGIN_SRC emacs-lisp -n -k -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
806 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
807 ;; 2. A link to a "-n -r" block returns line number.
808 (org-test-with-parsed-data
809 "#+BEGIN_EXAMPLE -n -r\nText (ref:coderef)\n#+END_EXAMPLE"
810 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
811 (org-test-with-parsed-data
812 "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
813 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
814 ;; 3. A link to a "-n" block returns coderef.
815 (org-test-with-parsed-data
816 "#+BEGIN_SRC emacs-lisp -n\n(+ 1 1) (ref:coderef)\n#+END_SRC"
817 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
818 (org-test-with-parsed-data
819 "#+BEGIN_EXAMPLE -n\nText (ref:coderef)\n#+END_EXAMPLE"
820 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
821 ;; 4. A link to a "-r" block returns line number.
822 (org-test-with-parsed-data
823 "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
824 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
825 (org-test-with-parsed-data
826 "#+BEGIN_EXAMPLE -r\nText (ref:coderef)\n#+END_EXAMPLE"
827 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
828 ;; 5. A link to a block without a switch returns coderef.
829 (org-test-with-parsed-data
830 "#+BEGIN_SRC emacs-lisp\n(+ 1 1) (ref:coderef)\n#+END_SRC"
831 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
832 (org-test-with-parsed-data
833 "#+BEGIN_EXAMPLE\nText (ref:coderef)\n#+END_EXAMPLE"
834 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
835 ;; 6. Correctly handle continued line numbers. A "+n" switch
836 ;; should resume numbering from previous block with numbered
837 ;; lines, ignoring blocks not numbering lines in the process.
838 ;; A "-n" switch resets count.
839 (org-test-with-parsed-data "
844 #+BEGIN_SRC emacs-lisp
848 #+BEGIN_SRC emacs-lisp +n -r
849 \(+ 1 1) (ref:addition)
852 #+BEGIN_EXAMPLE -n -r
853 Another text. (ref:text)
855 (should (= (org-export-resolve-coderef "addition" info
) 2))
856 (should (= (org-export-resolve-coderef "text" info
) 1)))
857 ;; 7. Recognize coderef with user-specified syntax.
858 (org-test-with-parsed-data
859 "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText. [ref:text]\n#+END_EXAMPLE"
860 (should (equal (org-export-resolve-coderef "text" info
) "text")))))
862 (ert-deftest test-org-export
/resolve-fuzzy-link
()
863 "Test `org-export-resolve-fuzzy-link' specifications."
864 ;; 1. Match target objects.
865 (org-test-with-parsed-data "<<target>> [[target]]"
867 (org-export-resolve-fuzzy-link
868 (org-element-map tree
'link
'identity info t
) info
)))
869 ;; 2. Match target elements.
870 (org-test-with-parsed-data "#+TARGET: target\n[[target]]"
872 (org-export-resolve-fuzzy-link
873 (org-element-map tree
'link
'identity info t
) info
)))
874 ;; 3. Match named elements.
875 (org-test-with-parsed-data "#+NAME: target\nParagraph\n\n[[target]]"
877 (org-export-resolve-fuzzy-link
878 (org-element-map tree
'link
'identity info t
) info
)))
879 ;; 4. Match exact headline's name.
880 (org-test-with-parsed-data "* My headline\n[[My headline]]"
882 (org-export-resolve-fuzzy-link
883 (org-element-map tree
'link
'identity info t
) info
)))
884 ;; 5. Targets objects have priority over named elements and headline
886 (org-test-with-parsed-data
887 "* target\n#+NAME: target\n<<target>>\n\n[[target]]"
891 (org-export-resolve-fuzzy-link
892 (org-element-map tree
'link
'identity info t
) info
)))))
893 ;; 6. Named elements have priority over headline titles.
894 (org-test-with-parsed-data
895 "* target\n#+NAME: target\nParagraph\n\n[[target]]"
899 (org-export-resolve-fuzzy-link
900 (org-element-map tree
'link
'identity info t
) info
)))))
901 ;; 7. If link's path starts with a "*", only match headline titles,
903 (org-test-with-parsed-data
904 "* target\n#+NAME: target\n<<target>>\n\n[[*target]]"
908 (org-export-resolve-fuzzy-link
909 (org-element-map tree
'link
'identity info t
) info
)))))
910 ;; 8. Return nil if no match.
911 (org-test-with-parsed-data "[[target]]"
913 (org-export-resolve-fuzzy-link
914 (org-element-map tree
'link
'identity info t
) info
))))
916 (ert-deftest test-org-export
/resolve-id-link
()
917 "Test `org-export-resolve-id-link' specifications."
918 ;; 1. Regular test for custom-id link.
919 (org-test-with-parsed-data "* Headline1
926 (org-export-resolve-id-link
927 (org-element-map tree
'link
'identity info t
) info
)))
928 ;; 2. Failing test for custom-id link.
929 (org-test-with-parsed-data "* Headline1
936 (org-export-resolve-id-link
937 (org-element-map tree
'link
'identity info t
) info
)))
938 ;; 3. Test for internal id target.
939 (org-test-with-parsed-data "* Headline1
946 (org-export-resolve-id-link
947 (org-element-map tree
'link
'identity info t
) info
)))
948 ;; 4. Test for external id target.
949 (org-test-with-parsed-data "[[id:aaaa]]"
951 (org-export-resolve-id-link
952 (org-element-map tree
'link
'identity info t
)
953 (org-combine-plists info
'(:id-alist
(("aaaa" .
"external-file"))))))))
955 (ert-deftest test-org-export
/resolve-radio-link
()
956 "Test `org-export-resolve-radio-link' specifications."
958 (org-test-with-temp-text "<<<radio>>> radio"
959 (org-update-radio-target-regexp)
961 (let* ((tree (org-element-parse-buffer))
962 (info `(:parse-tree
,tree
)))
963 (org-export-resolve-radio-link
964 (org-element-map tree
'link
'identity info t
)
966 ;; Radio target with objects.
967 (org-test-with-temp-text "<<<radio \\alpha>>> radio \\alpha"
968 (org-update-radio-target-regexp)
970 (let* ((tree (org-element-parse-buffer))
971 (info `(:parse-tree
,tree
)))
972 (org-export-resolve-radio-link
973 (org-element-map tree
'link
'identity info t
)
978 ;;; Src-block and example-block
980 (ert-deftest test-org-export
/unravel-code
()
981 "Test `org-export-unravel-code' function."
982 (let ((org-coderef-label-format "(ref:%s)"))
983 ;; 1. Code without reference.
984 (org-test-with-temp-text "#+BEGIN_EXAMPLE\n(+ 1 1)\n#+END_EXAMPLE"
985 (should (equal (org-export-unravel-code (org-element-at-point))
987 ;; 2. Code with reference.
988 (org-test-with-temp-text
989 "#+BEGIN_EXAMPLE\n(+ 1 1) (ref:test)\n#+END_EXAMPLE"
990 (should (equal (org-export-unravel-code (org-element-at-point))
991 '("(+ 1 1)\n" (1 .
"test")))))
992 ;; 3. Code with user-defined reference.
993 (org-test-with-temp-text
994 "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\n(+ 1 1) [ref:test]\n#+END_EXAMPLE"
995 (should (equal (org-export-unravel-code (org-element-at-point))
996 '("(+ 1 1)\n" (1 .
"test")))))
997 ;; 4. Code references keys are relative to the current block.
998 (org-test-with-temp-text "
1007 (should (equal (org-export-unravel-code (org-element-at-point))
1008 '("(+ 2 2)\n(+ 3 3)\n" (2 .
"one")))))
1009 ;; 5. Free up comma-protected lines.
1011 ;; 5.1. In an Org source block, every line is protected.
1012 (org-test-with-temp-text
1013 "#+BEGIN_SRC org\n,* Test\n,# comment\n,Text\n#+END_SRC"
1014 (should (equal (org-export-unravel-code (org-element-at-point))
1015 '("* Test\n# comment\nText\n"))))
1016 ;; 5.2. In other blocks, only headlines, comments and keywords are
1018 (org-test-with-temp-text
1019 "#+BEGIN_EXAMPLE\n,* Headline\n, * Not headline\n,Keep\n#+END_EXAMPLE"
1020 (should (equal (org-export-unravel-code (org-element-at-point))
1021 '("* Headline\n, * Not headline\n,Keep\n"))))))
1027 (ert-deftest test-org-export
/special-column
()
1028 "Test if the table's special column is properly recognized."
1029 ;; 1. First column is special if it contains only a special marking
1030 ;; characters or empty cells.
1031 (org-test-with-temp-text "
1035 (org-export-table-has-special-column-p
1037 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1038 ;; 2. If the column contains anything else, it isn't special.
1039 (org-test-with-temp-text "
1043 (org-export-table-has-special-column-p
1045 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1046 ;; 3. Special marking characters are "#", "^", "*", "_", "/", "$"
1048 (org-test-with-temp-text "
1057 (org-export-table-has-special-column-p
1059 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1060 ;; 4. A first column with only empty cells isn't considered as
1062 (org-test-with-temp-text "
1066 (org-export-table-has-special-column-p
1068 (org-element-parse-buffer) 'table
'identity nil
'first-match
)))))
1070 (ert-deftest test-org-export
/table-row-is-special-p
()
1071 "Test `org-export-table-row-is-special-p' specifications."
1072 ;; 1. A row is special if it has a special marking character in the
1074 (org-test-with-parsed-data "| ! | 1 |"
1076 (org-export-table-row-is-special-p
1077 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1078 ;; 2. A row is special when its first field is "/"
1079 (org-test-with-parsed-data "
1083 (org-export-table-row-is-special-p
1084 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1085 ;; 3. A row only containing alignment cookies is also considered as
1087 (org-test-with-parsed-data "| <5> | | <l> | <l22> |"
1089 (org-export-table-row-is-special-p
1090 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1091 ;; 4. Everything else isn't considered as special.
1092 (org-test-with-parsed-data "| \alpha | | c |"
1094 (org-export-table-row-is-special-p
1095 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1096 ;; 5. Table's rules are never considered as special rows.
1097 (org-test-with-parsed-data "|---+---|"
1099 (org-export-table-row-is-special-p
1100 (org-element-map tree
'table-row
'identity nil
'first-match
) info
))))
1102 (ert-deftest test-org-export
/has-header-p
()
1103 "Test `org-export-table-has-header-p' specifications."
1104 ;; 1. With an header.
1105 (org-test-with-parsed-data "
1110 (org-export-table-has-header-p
1111 (org-element-map tree
'table
'identity info
'first-match
)
1113 ;; 2. Without an header.
1114 (org-test-with-parsed-data "
1118 (org-export-table-has-header-p
1119 (org-element-map tree
'table
'identity info
'first-match
)
1121 ;; 3. Don't get fooled with starting and ending rules.
1122 (org-test-with-parsed-data "
1128 (org-export-table-has-header-p
1129 (org-element-map tree
'table
'identity info
'first-match
)
1132 (ert-deftest test-org-export
/table-row-group
()
1133 "Test `org-export-table-row-group' specifications."
1134 ;; 1. A rule creates a new group.
1135 (org-test-with-parsed-data "
1142 (mapcar (lambda (row) (org-export-table-row-group row info
))
1143 (org-element-map tree
'table-row
'identity
)))))
1144 ;; 2. Special rows are ignored in count.
1145 (org-test-with-parsed-data "
1152 (mapcar (lambda (row) (org-export-table-row-group row info
))
1153 (org-element-map tree
'table-row
'identity
)))))
1154 ;; 3. Double rules also are ignored in count.
1155 (org-test-with-parsed-data "
1163 (mapcar (lambda (row) (org-export-table-row-group row info
))
1164 (org-element-map tree
'table-row
'identity
))))))
1166 (ert-deftest test-org-export
/table-cell-width
()
1167 "Test `org-export-table-cell-width' specifications."
1168 ;; 1. Width is primarily determined by width cookies. If no cookie
1169 ;; is found, cell's width is nil.
1170 (org-test-with-parsed-data "
1171 | / | <l> | <6> | <l7> |
1176 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1177 (org-element-map tree
'table-cell
'identity info
)))))
1178 ;; 2. The last width cookie has precedence.
1179 (org-test-with-parsed-data "
1186 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1187 (org-element-map tree
'table-cell
'identity info
)))))
1188 ;; 3. Valid width cookies must have a specific row.
1189 (org-test-with-parsed-data "| <6> | cell |"
1193 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1194 (org-element-map tree
'table-cell
'identity
))))))
1196 (ert-deftest test-org-export
/table-cell-alignment
()
1197 "Test `org-export-table-cell-alignment' specifications."
1198 (let ((org-table-number-fraction 0.5)
1199 (org-table-number-regexp "^[0-9]+$"))
1200 ;; 1. Alignment is primarily determined by alignment cookies.
1201 (org-test-with-temp-text "| <l> | <c> | <r> |"
1202 (let* ((tree (org-element-parse-buffer))
1203 (info `(:parse-tree
,tree
)))
1206 '(left center right
)
1207 (mapcar (lambda (cell) (org-export-table-cell-alignment cell info
))
1208 (org-element-map tree
'table-cell
'identity
))))))
1209 ;; 2. The last alignment cookie has precedence.
1210 (org-test-with-parsed-data "
1216 '(right right right
)
1217 (mapcar (lambda (cell) (org-export-table-cell-alignment cell info
))
1218 (org-element-map tree
'table-cell
'identity
)))))
1219 ;; 3. If there's no cookie, cell's contents determine alignment.
1220 ;; A column mostly made of cells containing numbers will align
1221 ;; its cells to the right.
1222 (org-test-with-parsed-data "
1228 '(right right right
)
1229 (mapcar (lambda (cell)
1230 (org-export-table-cell-alignment cell info
))
1231 (org-element-map tree
'table-cell
'identity
)))))
1232 ;; 4. Otherwise, they will be aligned to the left.
1233 (org-test-with-parsed-data "
1240 (mapcar (lambda (cell)
1241 (org-export-table-cell-alignment cell info
))
1242 (org-element-map tree
'table-cell
'identity
)))))))
1244 (ert-deftest test-org-export
/table-cell-borders
()
1245 "Test `org-export-table-cell-borders' specifications."
1246 ;; 1. Recognize various column groups indicators.
1247 (org-test-with-parsed-data "| / | < | > | <> |"
1250 '((right bottom top
) (left bottom top
) (right bottom top
)
1251 (right left bottom top
))
1252 (mapcar (lambda (cell)
1253 (org-export-table-cell-borders cell info
))
1254 (org-element-map tree
'table-cell
'identity
)))))
1255 ;; 2. Accept shortcuts to define column groups.
1256 (org-test-with-parsed-data "| / | < | < |"
1259 '((right bottom top
) (right left bottom top
) (left bottom top
))
1260 (mapcar (lambda (cell)
1261 (org-export-table-cell-borders cell info
))
1262 (org-element-map tree
'table-cell
'identity
)))))
1263 ;; 3. A valid column groups row must start with a "/".
1264 (org-test-with-parsed-data "
1268 (equal '((top) (top) (bottom) (bottom))
1269 (mapcar (lambda (cell)
1270 (org-export-table-cell-borders cell info
))
1271 (org-element-map tree
'table-cell
'identity
)))))
1272 ;; 4. Take table rules into consideration.
1273 (org-test-with-parsed-data "
1278 (equal '((below top
) (bottom above
))
1279 (mapcar (lambda (cell)
1280 (org-export-table-cell-borders cell info
))
1281 (org-element-map tree
'table-cell
'identity
)))))
1282 ;; 5. Top and (resp. bottom) rules induce both `top' and `above'
1283 ;; (resp. `bottom' and `below') borders. Any special row is
1285 (org-test-with-parsed-data "
1291 (equal '((bottom below top above
))
1293 (mapcar (lambda (cell)
1294 (org-export-table-cell-borders cell info
))
1295 (org-element-map tree
'table-cell
'identity
)))))))
1297 (ert-deftest test-org-export
/table-dimensions
()
1298 "Test `org-export-table-dimensions' specifications."
1299 ;; 1. Standard test.
1300 (org-test-with-parsed-data "
1305 (org-export-table-dimensions
1306 (org-element-map tree
'table
'identity info
'first-match
) info
))))
1307 ;; 2. Ignore horizontal rules and special columns.
1308 (org-test-with-parsed-data "
1315 (org-export-table-dimensions
1316 (org-element-map tree
'table
'identity info
'first-match
) info
)))))
1318 (ert-deftest test-org-export
/table-cell-address
()
1319 "Test `org-export-table-cell-address' specifications."
1320 ;; 1. Standard test: index is 0-based.
1321 (org-test-with-parsed-data "| a | b |"
1323 (equal '((0 .
0) (0 .
1))
1326 (lambda (cell) (org-export-table-cell-address cell info
))
1328 ;; 2. Special column isn't counted, nor are special rows.
1329 (org-test-with-parsed-data "
1334 (org-export-table-cell-address
1335 (car (last (org-element-map tree
'table-cell
'identity info
)))
1337 ;; 3. Tables rules do not count either.
1338 (org-test-with-parsed-data "
1346 (org-export-table-cell-address
1347 (car (last (org-element-map tree
'table-cell
'identity info
)))
1349 ;; 4. Return nil for special cells.
1350 (org-test-with-parsed-data "| / | a |"
1352 (org-export-table-cell-address
1353 (org-element-map tree
'table-cell
'identity nil
'first-match
)
1356 (ert-deftest test-org-export
/get-table-cell-at
()
1357 "Test `org-export-get-table-cell-at' specifications."
1358 ;; 1. Address ignores special columns, special rows and rules.
1359 (org-test-with-parsed-data "
1366 (org-element-contents
1367 (org-export-get-table-cell-at
1369 (org-element-map tree
'table
'identity info
'first-match
)
1371 ;; 2. Return value for a non-existent address is nil.
1372 (org-test-with-parsed-data "| a |"
1374 (org-export-get-table-cell-at
1376 (org-element-map tree
'table
'identity info
'first-match
)
1378 (org-test-with-parsed-data "| / |"
1380 (org-export-get-table-cell-at
1382 (org-element-map tree
'table
'identity info
'first-match
)
1385 (ert-deftest test-org-export
/table-cell-starts-colgroup-p
()
1386 "Test `org-export-table-cell-starts-colgroup-p' specifications."
1387 ;; 1. A cell at a beginning of a row always starts a column group.
1388 (org-test-with-parsed-data "| a |"
1390 (org-export-table-cell-starts-colgroup-p
1391 (org-element-map tree
'table-cell
'identity info
'first-match
)
1393 ;; 2. Special column should be ignored when determining the
1394 ;; beginning of the row.
1395 (org-test-with-parsed-data "
1399 (org-export-table-cell-starts-colgroup-p
1400 (org-element-map tree
'table-cell
'identity info
'first-match
)
1402 ;; 2. Explicit column groups.
1403 (org-test-with-parsed-data "
1412 (if (org-export-table-cell-starts-colgroup-p cell info
) 'yes
'no
))
1415 (ert-deftest test-org-export
/table-cell-ends-colgroup-p
()
1416 "Test `org-export-table-cell-ends-colgroup-p' specifications."
1417 ;; 1. A cell at the end of a row always ends a column group.
1418 (org-test-with-parsed-data "| a |"
1420 (org-export-table-cell-ends-colgroup-p
1421 (org-element-map tree
'table-cell
'identity info
'first-match
)
1423 ;; 2. Special column should be ignored when determining the
1424 ;; beginning of the row.
1425 (org-test-with-parsed-data "
1429 (org-export-table-cell-ends-colgroup-p
1430 (org-element-map tree
'table-cell
'identity info
'first-match
)
1432 ;; 3. Explicit column groups.
1433 (org-test-with-parsed-data "
1442 (if (org-export-table-cell-ends-colgroup-p cell info
) 'yes
'no
))
1445 (ert-deftest test-org-export
/table-row-starts-rowgroup-p
()
1446 "Test `org-export-table-row-starts-rowgroup-p' specifications."
1447 ;; 1. A row at the beginning of a table always starts a row group.
1448 ;; So does a row following a table rule.
1449 (org-test-with-parsed-data "
1459 (if (org-export-table-row-starts-rowgroup-p row info
) 'yes
'no
))
1461 ;; 2. Special rows should be ignored when determining the beginning
1463 (org-test-with-parsed-data "
1475 (if (org-export-table-row-starts-rowgroup-p row info
) 'yes
'no
))
1478 (ert-deftest test-org-export
/table-row-ends-rowgroup-p
()
1479 "Test `org-export-table-row-ends-rowgroup-p' specifications."
1480 ;; 1. A row at the end of a table always ends a row group. So does
1481 ;; a row preceding a table rule.
1482 (org-test-with-parsed-data "
1492 (if (org-export-table-row-ends-rowgroup-p row info
) 'yes
'no
))
1494 ;; 2. Special rows should be ignored when determining the beginning
1496 (org-test-with-parsed-data "
1508 (if (org-export-table-row-ends-rowgroup-p row info
) 'yes
'no
))
1511 (ert-deftest test-org-export
/table-row-starts-header-p
()
1512 "Test `org-export-table-row-starts-header-p' specifications."
1513 ;; 1. Only the row starting the first row group starts the table
1515 (org-test-with-parsed-data "
1526 (if (org-export-table-row-starts-header-p row info
) 'yes
'no
))
1528 ;; 2. A row cannot start an header if there's no header in the
1530 (org-test-with-parsed-data "
1534 (org-export-table-row-starts-header-p
1535 (org-element-map tree
'table-row
'identity info
'first-match
)
1538 (ert-deftest test-org-export
/table-row-ends-header-p
()
1539 "Test `org-export-table-row-ends-header-p' specifications."
1540 ;; 1. Only the row starting the first row group starts the table
1542 (org-test-with-parsed-data "
1553 (if (org-export-table-row-ends-header-p row info
) 'yes
'no
))
1555 ;; 2. A row cannot start an header if there's no header in the
1557 (org-test-with-parsed-data "
1561 (org-export-table-row-ends-header-p
1562 (org-element-map tree
'table-row
'identity info
'first-match
)
1569 (ert-deftest test-org-export
/get-next-element
()
1570 "Test `org-export-get-next-element' specifications."
1574 (org-test-with-parsed-data "* Headline\n*a* b"
1575 (org-export-get-next-element
1576 (org-element-map tree
'bold
'identity info t
) info
))))
1577 ;; Return nil when no previous element.
1579 (org-test-with-parsed-data "* Headline\na *b*"
1580 (org-export-get-next-element
1581 (org-element-map tree
'bold
'identity info t
) info
)))
1582 ;; Non-exportable elements are ignored.
1584 (let ((org-export-with-timestamps nil
))
1585 (org-test-with-parsed-data "\alpha <2012-03-29 Thu>"
1586 (org-export-get-next-element
1587 (org-element-map tree
'entity
'identity info t
) info
)))))
1589 (ert-deftest test-org-export
/get-previous-element
()
1590 "Test `org-export-get-previous-element' specifications."
1594 (org-test-with-parsed-data "* Headline\na *b*"
1595 (org-export-get-previous-element
1596 (org-element-map tree
'bold
'identity info t
) info
))))
1597 ;; Return nil when no previous element.
1599 (org-test-with-parsed-data "* Headline\n*a* b"
1600 (org-export-get-previous-element
1601 (org-element-map tree
'bold
'identity info t
) info
)))
1602 ;; Non-exportable elements are ignored.
1604 (let ((org-export-with-timestamps nil
))
1605 (org-test-with-parsed-data "<2012-03-29 Thu> \alpha"
1606 (org-export-get-previous-element
1607 (org-element-map tree
'entity
'identity info t
) info
)))))
1610 (provide 'test-org-export
)
1611 ;;; test-org-export.el end here