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
)
31 (push (cons type
(intern (format "org-%s-%s" backend type
)))
33 (flet ,(let (transcoders)
34 (dolist (type (append org-element-all-elements
35 org-element-all-objects
)
37 (push `(,(intern (format "org-%s-%s" backend type
))
39 (,(intern (format "org-element-%s-interpreter" type
))
44 (defmacro org-test-with-parsed-data
(data &rest body
)
45 "Execute body with parsed data available.
47 DATA is a string containing the data to be parsed. BODY is the
48 body to execute. Parse tree is available under the `tree'
49 variable, and communication channel under `info'.
51 This function calls `org-export-collect-tree-properties'. As
52 such, `:ignore-list' (for `org-element-map') and
53 `:parse-tree' (for `org-export-get-genealogy') properties are
54 already filled in `info'."
55 (declare (debug (form body
)) (indent 1))
56 `(org-test-with-temp-text ,data
57 (let* ((tree (org-element-parse-buffer))
58 (info (org-export-collect-tree-properties
59 tree
(org-export-get-environment))))
66 (ert-deftest test-org-export
/parse-option-keyword
()
67 "Test reading all standard #+OPTIONS: items."
70 (org-export-parse-option-keyword
71 "H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t
72 *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t")
74 1 :preserve-breaks t
:section-numbers t
:time-stamp-file t
75 :with-archived-trees t
:with-author t
:with-creator t
:with-drawers t
76 :with-email t
:with-emphasize t
:with-entities t
:with-fixed-width t
77 :with-footnotes t
:with-priority t
:with-special-strings t
78 :with-sub-superscript t
:with-toc t
:with-tables t
:with-tags t
79 :with-tasks t
:with-timestamps t
:with-todo-keywords t
)))
80 ;; Test some special values.
83 (org-export-parse-option-keyword
84 "arch:headline creator:comment d:(\"TEST\")
85 ^:{} toc:1 tags:not-in-toc tasks:todo num:2 <:active")
88 :with-archived-trees headline
:with-creator comment
89 :with-drawers
("TEST") :with-sub-superscript
{} :with-toc
1
90 :with-tags not-in-toc
:with-tasks todo
:with-timestamps active
))))
92 (ert-deftest test-org-export
/get-inbuffer-options
()
93 "Test reading all standard export keywords."
96 (org-test-with-temp-text "#+AUTHOR: Me, Myself and I
99 #+DESCRIPTION: Testing
100 #+DESCRIPTION: with two lines
101 #+EMAIL: some@email.org
102 #+EXPORT_EXCLUDE_TAGS: noexport invisible
105 #+EXPORT_SELECT_TAGS: export
107 #+TITLE: with spaces"
108 (org-export-get-inbuffer-options))
110 ("Me, Myself and I") :creator
"Idem" :date
("Today")
111 :description
"Testing\nwith two lines" :email
"some@email.org"
112 :exclude-tags
("noexport" "invisible") :keywords
"test" :language
"en"
113 :select-tags
("export") :title
("Some title with spaces")))))
115 (ert-deftest test-org-export
/handle-options
()
116 "Test if export options have an impact on output."
117 ;; Test exclude tags.
118 (org-test-with-temp-text "* Head1 :noexport:"
119 (org-test-with-backend test
121 (equal (org-export-as 'test nil nil nil
'(:exclude-tags
("noexport")))
123 ;; Test include tags.
124 (org-test-with-temp-text "
127 ** Sub-Head2.1 :export:
130 (org-test-with-backend test
133 "* Head2\n** Sub-Head2.1 :export:\n*** Sub-Head2.1.1\n"
134 (let ((org-tags-column 0))
135 (org-export-as 'test nil nil nil
'(:select-tags
("export"))))))))
136 ;; Test mixing include tags and exclude tags.
137 (org-test-with-temp-text "
139 ** Sub-Head1 :noexport:
142 ** Sub-Head1 :export:"
143 (org-test-with-backend test
146 "\\* Head1[ \t]+:export:\n\\*\\* Sub-Head2\n"
149 '(:select-tags
("export") :exclude-tags
("noexport")))))))
151 (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
152 (org-test-with-temp-text "* TODO Head1"
153 (org-test-with-backend test
154 (should (equal (org-export-as 'test nil nil nil
'(:with-tasks nil
))
156 (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
157 (org-test-with-temp-text "* TODO Head1"
158 (org-test-with-backend test
159 (should (equal (org-export-as 'test nil nil nil
'(:with-tasks t
))
160 "* TODO Head1\n")))))
162 (org-test-with-temp-text "* Head1 :archive:"
163 (let ((org-archive-tag "archive"))
164 (org-test-with-backend test
166 (equal (org-export-as 'test nil nil nil
'(:with-archived-trees nil
))
168 (org-test-with-temp-text "* Head1 :archive:\nbody\n** Sub-head 2"
169 (let ((org-archive-tag "archive"))
170 (org-test-with-backend test
173 "\\* Head1[ \t]+:archive:"
174 (org-export-as 'test nil nil nil
175 '(:with-archived-trees headline
)))))))
176 (org-test-with-temp-text "* Head1 :archive:"
177 (let ((org-archive-tag "archive"))
178 (org-test-with-backend test
181 "\\`\\* Head1[ \t]+:archive:\n\\'"
182 (org-export-as 'test nil nil nil
'(:with-archived-trees t
)))))))
184 (let ((org-drawers '("TEST")))
185 (org-test-with-temp-text ":TEST:\ncontents\n:END:"
186 (org-test-with-backend test
187 (should (equal (org-export-as 'test nil nil nil
'(:with-drawers nil
))
189 (should (equal (org-export-as 'test nil nil nil
'(:with-drawers t
))
190 ":TEST:\ncontents\n:END:\n")))))
191 (let ((org-drawers '("FOO" "BAR")))
192 (org-test-with-temp-text ":FOO:\nkeep\n:END:\n:BAR:\nremove\n:END:"
193 (org-test-with-backend test
195 (equal (org-export-as 'test nil nil nil
'(:with-drawers
("FOO")))
196 ":FOO:\nkeep\n:END:\n")))))
198 (org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
199 (org-test-with-backend test
201 (equal (org-export-as 'test nil nil nil
'(:with-timestamps t
))
202 "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>\n"))
204 (equal (org-export-as 'test nil nil nil
'(:with-timestamps nil
)) ""))
206 (equal (org-export-as 'test nil nil nil
'(:with-timestamps active
))
207 "<2012-04-29 sun. 10:45>\n"))
209 (equal (org-export-as 'test nil nil nil
'(:with-timestamps inactive
))
210 "[2012-04-29 sun. 10:45]\n"))))
212 (let ((org-clock-string "CLOCK:"))
213 (org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
214 (org-test-with-backend test
216 (equal (org-export-as 'test nil nil nil
'(:with-clocks t
))
217 "CLOCK: [2012-04-29 sun. 10:45]\n"))
219 (equal (org-export-as 'test nil nil nil
'(:with-clocks nil
)) "")))))
221 (let ((org-closed-string "CLOSED:"))
222 (org-test-with-temp-text "CLOSED: [2012-04-29 sun. 10:45]"
223 (org-test-with-backend test
225 (equal (org-export-as 'test nil nil nil
'(:with-plannings t
))
226 "CLOSED: [2012-04-29 sun. 10:45]\n"))
228 (equal (org-export-as 'test nil nil nil
'(:with-plannings nil
))
231 (ert-deftest test-org-export
/comment-tree
()
232 "Test if export process ignores commented trees."
233 (let ((org-comment-string "COMMENT"))
234 (org-test-with-temp-text "* COMMENT Head1"
235 (org-test-with-backend test
236 (should (equal (org-export-as 'test
) ""))))))
238 (ert-deftest test-org-export
/export-scope
()
239 "Test all export scopes."
240 (org-test-with-temp-text "
245 (org-test-with-backend test
248 (should (equal (org-export-as 'test
'subtree
) "text\n*** Head3\n"))
250 (goto-char (point-min))
253 (should (equal (org-export-as 'test nil
'visible
) "* Head1\n"))
255 (flet ((org-test-template (body info
) (format "BEGIN\n%sEND" body
)))
256 (push '(template . org-test-template
) org-test-translate-alist
)
257 (should (equal (org-export-as 'test nil nil
'body-only
)
258 "* Head1\n** Head2\ntext\n*** Head3\n"))
259 (should (equal (org-export-as 'test
)
260 "BEGIN\n* Head1\n** Head2\ntext\n*** Head3\nEND")))
262 (goto-char (point-min))
264 (transient-mark-mode 1)
265 (push-mark (point) t t
)
266 (goto-char (point-at-eol))
267 (should (equal (org-export-as 'test
) "text\n"))))
268 ;; Subtree with a code block calling another block outside.
269 (org-test-with-temp-text "
271 #+BEGIN_SRC emacs-lisp :noweb yes :exports results
276 #+BEGIN_SRC emacs-lisp
279 (org-test-with-backend test
281 (should (equal (org-export-as 'test
'subtree
) ": 3\n"))))
282 ;; Subtree's EXPORT_TITLE property.
285 (plist-get (org-test-with-temp-text "* Headline
287 :EXPORT_TITLE: subtree-title
290 (org-export-get-environment nil t
))
293 ;; Subtree's EXPORT_TITLE property.
294 (org-test-with-temp-text "#+OPTIONS: H:1
302 (= 2 (plist-get (org-export-get-environment nil t
) :headline-levels
)))))
304 (ert-deftest test-org-export
/export-snippet
()
305 "Test export snippets transcoding."
306 (org-test-with-temp-text "@@test:A@@@@t:B@@"
307 (org-test-with-backend test
308 (flet ((org-test-export-snippet
309 (snippet contents info
)
310 (when (eq (org-export-snippet-backend snippet
) 'test
)
311 (org-element-property :value snippet
))))
312 (let ((org-export-snippet-translation-alist nil
))
313 (should (equal (org-export-as 'test
) "A\n")))
314 (let ((org-export-snippet-translation-alist '(("t" .
"test"))))
315 (should (equal (org-export-as 'test
) "AB\n")))))))
317 (ert-deftest test-org-export
/expand-include
()
318 "Test file inclusion in an Org buffer."
319 ;; Full insertion with recursive inclusion.
320 (org-test-with-temp-text
321 (format "#+INCLUDE: \"%s/examples/include.org\"" org-test-dir
)
322 (org-export-expand-include-keyword)
323 (should (equal (buffer-string)
324 "Small Org file with an include keyword.
326 #+BEGIN_SRC emacs-lisp :exports results\n(+ 2 1)\n#+END_SRC
332 ;; Localized insertion.
333 (org-test-with-temp-text
334 (format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\""
336 (org-export-expand-include-keyword)
337 (should (equal (buffer-string)
338 "Small Org file with an include keyword.\n")))
339 ;; Insertion with constraints on headlines level.
340 (org-test-with-temp-text
342 "* Top heading\n#+INCLUDE: \"%s/examples/include.org\" :lines \"9-\""
344 (org-export-expand-include-keyword)
345 (should (equal (buffer-string) "* Top heading\n** Heading\nbody\n")))
346 ;; Inclusion within an example block.
347 (org-test-with-temp-text
348 (format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\" example"
350 (org-export-expand-include-keyword)
354 "#+BEGIN_EXAMPLE\nSmall Org file with an include keyword.\n#+END_EXAMPLE\n")))
355 ;; Inclusion within a src-block.
356 (org-test-with-temp-text
358 "#+INCLUDE: \"%s/examples/include.org\" :lines \"4-5\" src emacs-lisp"
360 (org-export-expand-include-keyword)
361 (should (equal (buffer-string)
362 "#+BEGIN_SRC emacs-lisp\n(+ 2 1)\n#+END_SRC\n"))))
364 (ert-deftest test-org-export
/user-ignore-list
()
365 "Test if `:ignore-list' accepts user input."
366 (org-test-with-backend test
367 (flet ((skip-note-head
369 ;; Ignore headlines with the word "note" in their title.
373 (when (string-match "\\<note\\>"
374 (org-element-property :raw-value headline
))
375 (org-export-ignore-element headline info
)))
378 ;; Install function in parse tree filters.
379 (let ((org-export-filter-parse-tree-functions '(skip-note-head)))
380 (org-test-with-temp-text "* Head1\n* Head2 (note)\n"
381 (should (equal (org-export-as 'test
) "* Head1\n")))))))
383 (ert-deftest test-org-export
/before-parsing-hook
()
384 "Test `org-export-before-parsing-hook'."
385 (org-test-with-backend test
386 (org-test-with-temp-text "* Headline 1\nBody 1\n* Headline 2\nBody 2"
387 (let ((org-export-before-parsing-hook
391 (delete-region (point) (progn (forward-line) (point)))))))))
392 (should (equal (org-export-as 'test
) "Body 1\nBody 2\n"))))))
394 (ert-deftest test-org-export
/set-element
()
395 "Test `org-export-set-element' specifications."
396 (org-test-with-parsed-data "* Headline\n*a*"
397 (org-export-set-element
398 (org-element-map tree
'bold
'identity nil t
)
400 ;; Check if object is correctly replaced.
401 (should (org-element-map tree
'italic
'identity
))
402 (should-not (org-element-map tree
'bold
'identity
))
403 ;; Check if new object's parent is correctly set.
406 (org-element-property :parent
407 (org-element-map tree
'italic
'identity nil t
))
408 (org-element-map tree
'paragraph
'identity nil t
)))))
412 ;;; Affiliated Keywords
414 (ert-deftest test-org-export
/read-attribute
()
415 "Test `org-export-read-attribute' specifications."
419 (org-export-read-attribute
421 (org-test-with-temp-text "#+ATTR_HTML: :a 1 :b 2\nParagraph"
422 (org-element-current-element)))
424 ;; Return nil on empty attribute.
426 (org-export-read-attribute
428 (org-test-with-temp-text "Paragraph" (org-element-current-element)))))
433 (ert-deftest test-org-export
/footnotes
()
434 "Test footnotes specifications."
435 (let ((org-footnote-section nil
)
436 (org-export-with-footnotes t
))
437 ;; 1. Read every type of footnote.
438 (org-test-with-parsed-data
439 "Text[fn:1] [1] [fn:label:C] [fn::D]\n\n[fn:1] A\n\n[1] B"
442 '((1 .
"A") (2 .
"B") (3 .
"C") (4 .
"D"))
444 tree
'footnote-reference
446 (let ((def (org-export-get-footnote-definition ref info
)))
447 (cons (org-export-get-footnote-number ref info
)
448 (if (eq (org-element-property :type ref
) 'inline
) (car def
)
449 (car (org-element-contents
450 (car (org-element-contents def
))))))))
452 ;; 2. Test nested footnotes order.
453 (org-test-with-parsed-data
454 "Text[fn:1:A[fn:2]] [fn:3].\n\n[fn:2] B [fn:3] [fn::D].\n\n[fn:3] C."
457 '((1 .
"fn:1") (2 .
"fn:2") (3 .
"fn:3") (4))
459 tree
'footnote-reference
461 (when (org-export-footnote-first-reference-p ref info
)
462 (cons (org-export-get-footnote-number ref info
)
463 (org-element-property :label ref
))))
465 ;; 3. Test nested footnote in invisible definitions.
466 (org-test-with-temp-text "Text[1]\n\n[1] B [2]\n\n[2] C."
468 (narrow-to-region (point) (point-at-eol))
469 (let* ((tree (org-element-parse-buffer))
470 (info (org-combine-plists
472 (org-export-collect-tree-properties
473 tree
(org-export-get-environment)))))
474 ;; Both footnotes should be seen.
476 (= (length (org-export-collect-footnote-definitions tree info
)) 2))))
477 ;; 4. Test footnotes definitions collection.
478 (org-test-with-parsed-data "Text[fn:1:A[fn:2]] [fn:3].
480 \[fn:2] B [fn:3] [fn::D].
483 (should (= (length (org-export-collect-footnote-definitions tree info
))
485 ;; 5. Test export of footnotes defined outside parsing scope.
486 (org-test-with-temp-text "[fn:1] Out of scope
489 (org-test-with-backend test
490 (flet ((org-test-footnote-reference
491 (fn-ref contents info
)
492 (org-element-interpret-data
493 (org-export-get-footnote-definition fn-ref info
))))
495 (should (equal "ParagraphOut of scope\n"
496 (org-export-as 'test
'subtree
))))))))
500 ;;; Headlines and Inlinetasks
502 (ert-deftest test-org-export
/get-relative-level
()
503 "Test `org-export-get-relative-level' specifications."
507 (let ((org-odd-levels-only nil
))
508 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
511 (lambda (h) (org-export-get-relative-level h info
))
516 (let ((org-odd-levels-only nil
))
517 (org-test-with-parsed-data "** Headline 1\n**** Headline 2"
520 (lambda (h) (org-export-get-relative-level h info
))
523 (ert-deftest test-org-export
/low-level-p
()
524 "Test `org-export-low-level-p' specifications."
528 (let ((org-odd-levels-only nil
))
529 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
532 (lambda (h) (if (org-export-low-level-p h info
) 'yes
'no
))
533 (plist-put info
:headline-levels
1)))))))
535 (ert-deftest test-org-export
/get-headline-number
()
536 "Test `org-export-get-headline-number' specifications."
541 (let ((org-odd-levels-only nil
))
542 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
545 (lambda (h) (org-export-get-headline-number h info
))
547 ;; Missing levels are replaced with 0.
551 (let ((org-odd-levels-only nil
))
552 (org-test-with-parsed-data "* Headline 1\n*** Headline 2"
555 (lambda (h) (org-export-get-headline-number h info
))
558 (ert-deftest test-org-export
/numbered-headline-p
()
559 "Test `org-export-numbered-headline-p' specifications."
560 ;; If `:section-numbers' is nil, never number headlines.
562 (org-test-with-parsed-data "* Headline"
565 (lambda (h) (org-export-numbered-headline-p h info
))
566 (plist-put info
:section-numbers nil
))))
567 ;; If `:section-numbers' is a number, only number headlines with
568 ;; a level greater that it.
572 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
575 (lambda (h) (if (org-export-numbered-headline-p h info
) 'yes
'no
))
576 (plist-put info
:section-numbers
1)))))
577 ;; Otherwise, headlines are always numbered.
579 (org-test-with-parsed-data "* Headline"
582 (lambda (h) (org-export-numbered-headline-p h info
))
583 (plist-put info
:section-numbers t
)))))
585 (ert-deftest test-org-export
/number-to-roman
()
586 "Test `org-export-number-to-roman' specifications."
587 ;; If number is negative, return it as a string.
588 (should (equal (org-export-number-to-roman -
1) "-1"))
589 ;; Otherwise, return it as a roman number.
590 (should (equal (org-export-number-to-roman 1449) "MCDXLIX")))
592 (ert-deftest test-org-export
/get-tags
()
593 "Test `org-export-get-tags' specifications."
594 (let ((org-export-exclude-tags '("noexport"))
595 (org-export-select-tags '("export")))
596 ;; Standard test: tags which are not a select tag, an exclude tag,
597 ;; or specified as optional argument shouldn't be ignored.
599 (org-test-with-parsed-data "* Headline :tag:"
600 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
602 ;; Exclude tags are removed.
604 (org-test-with-parsed-data "* Headline :noexport:"
605 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
607 ;; Select tags are removed.
609 (org-test-with-parsed-data "* Headline :export:"
610 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
615 (org-test-with-parsed-data "* Headline :tag:export:"
616 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
618 ;; Tags provided in the optional argument are also ignored.
620 (org-test-with-parsed-data "* Headline :ignore:"
621 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
622 info
'("ignore"))))))
624 (ert-deftest test-org-export
/first-sibling-p
()
625 "Test `org-export-first-sibling-p' specifications."
629 (org-test-with-temp-text "* Headline\n** Headline 2\n** Headline 3"
631 (org-element-parse-buffer) 'headline
632 (lambda (h) (if (org-export-first-sibling-p h
) 'yes
'no
)))))))
634 (ert-deftest test-org-export
/last-sibling-p
()
635 "Test `org-export-last-sibling-p' specifications."
639 (org-test-with-temp-text "* Headline\n** Headline 2\n** Headline 3"
641 (org-element-parse-buffer) 'headline
642 (lambda (h) (if (org-export-last-sibling-p h
) 'yes
'no
)))))))
648 (ert-deftest test-org-export
/get-coderef-format
()
649 "Test `org-export-get-coderef-format' specifications."
650 ;; A link without description returns "%s"
651 (should (equal (org-export-get-coderef-format "(ref:line)" nil
)
653 ;; Return "%s" when path is matched within description.
654 (should (equal (org-export-get-coderef-format "path" "desc (path)")
656 ;; Otherwise return description.
657 (should (equal (org-export-get-coderef-format "path" "desc")
660 (ert-deftest test-org-export
/inline-image-p
()
661 "Test `org-export-inline-image-p' specifications."
663 (org-export-inline-image-p
664 (org-test-with-temp-text "[[#id]]"
666 (org-element-parse-buffer) 'link
'identity nil t
))
667 '(("custom-id" .
"id")))))
669 (ert-deftest test-org-export
/fuzzy-link
()
670 "Test fuzzy links specifications."
671 ;; 1. Links to invisible (keyword) targets should be ignored.
672 (org-test-with-parsed-data
673 "Paragraph.\n#+TARGET: Test\n[[Test]]"
678 (org-export-get-ordinal
679 (org-export-resolve-fuzzy-link link info
) info
)) info
)))
680 ;; 2. Link to an headline should return headline's number.
681 (org-test-with-parsed-data
682 "Paragraph.\n* Head1\n* Head2\n* Head3\n[[Head2]]"
684 ;; Note: Headline's number is in fact a list of numbers.
689 (org-export-get-ordinal
690 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
691 ;; 3. Link to a target in an item should return item's number.
692 (org-test-with-parsed-data
693 "- Item1\n - Item11\n - <<test>>Item12\n- Item2\n\n\n[[test]]"
695 ;; Note: Item's number is in fact a list of numbers.
700 (org-export-get-ordinal
701 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
702 ;; 4. Link to a target in a footnote should return footnote's
704 (org-test-with-parsed-data "
705 Paragraph[1][2][fn:lbl3:C<<target>>][[test]][[target]]\n[1] A\n\n[2] <<test>>B"
711 (org-export-get-ordinal
712 (org-export-resolve-fuzzy-link link info
) info
)) info
))))
713 ;; 5. Link to a named element should return sequence number of that
715 (org-test-with-parsed-data
716 "#+NAME: tbl1\n|1|2|\n#+NAME: tbl2\n|3|4|\n#+NAME: tbl3\n|5|6|\n[[tbl2]]"
722 (org-export-get-ordinal
723 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
724 ;; 6. Link to a target not within an item, a table, a footnote
725 ;; reference or definition should return section number.
726 (org-test-with-parsed-data
727 "* Head1\n* Head2\nParagraph<<target>>\n* Head3\n[[target]]"
733 (org-export-get-ordinal
734 (org-export-resolve-fuzzy-link link info
) info
)) info t
)))))
736 (ert-deftest test-org-export
/resolve-coderef
()
737 "Test `org-export-resolve-coderef' specifications."
738 (let ((org-coderef-label-format "(ref:%s)"))
739 ;; 1. A link to a "-n -k -r" block returns line number.
740 (org-test-with-parsed-data
741 "#+BEGIN_EXAMPLE -n -k -r\nText (ref:coderef)\n#+END_EXAMPLE"
742 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
743 (org-test-with-parsed-data
744 "#+BEGIN_SRC emacs-lisp -n -k -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
745 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
746 ;; 2. A link to a "-n -r" block returns line number.
747 (org-test-with-parsed-data
748 "#+BEGIN_EXAMPLE -n -r\nText (ref:coderef)\n#+END_EXAMPLE"
749 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
750 (org-test-with-parsed-data
751 "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
752 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
753 ;; 3. A link to a "-n" block returns coderef.
754 (org-test-with-parsed-data
755 "#+BEGIN_SRC emacs-lisp -n\n(+ 1 1) (ref:coderef)\n#+END_SRC"
756 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
757 (org-test-with-parsed-data
758 "#+BEGIN_EXAMPLE -n\nText (ref:coderef)\n#+END_EXAMPLE"
759 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
760 ;; 4. A link to a "-r" block returns line number.
761 (org-test-with-parsed-data
762 "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
763 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
764 (org-test-with-parsed-data
765 "#+BEGIN_EXAMPLE -r\nText (ref:coderef)\n#+END_EXAMPLE"
766 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
767 ;; 5. A link to a block without a switch returns coderef.
768 (org-test-with-parsed-data
769 "#+BEGIN_SRC emacs-lisp\n(+ 1 1) (ref:coderef)\n#+END_SRC"
770 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
771 (org-test-with-parsed-data
772 "#+BEGIN_EXAMPLE\nText (ref:coderef)\n#+END_EXAMPLE"
773 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
774 ;; 6. Correctly handle continued line numbers. A "+n" switch
775 ;; should resume numbering from previous block with numbered
776 ;; lines, ignoring blocks not numbering lines in the process.
777 ;; A "-n" switch resets count.
778 (org-test-with-parsed-data "
783 #+BEGIN_SRC emacs-lisp
787 #+BEGIN_SRC emacs-lisp +n -r
788 \(+ 1 1) (ref:addition)
791 #+BEGIN_EXAMPLE -n -r
792 Another text. (ref:text)
794 (should (= (org-export-resolve-coderef "addition" info
) 2))
795 (should (= (org-export-resolve-coderef "text" info
) 1)))
796 ;; 7. Recognize coderef with user-specified syntax.
797 (org-test-with-parsed-data
798 "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText. [ref:text]\n#+END_EXAMPLE"
799 (should (equal (org-export-resolve-coderef "text" info
) "text")))))
801 (ert-deftest test-org-export
/resolve-fuzzy-link
()
802 "Test `org-export-resolve-fuzzy-link' specifications."
803 ;; 1. Match target objects.
804 (org-test-with-parsed-data "<<target>> [[target]]"
806 (org-export-resolve-fuzzy-link
807 (org-element-map tree
'link
'identity info t
) info
)))
808 ;; 2. Match target elements.
809 (org-test-with-parsed-data "#+TARGET: target\n[[target]]"
811 (org-export-resolve-fuzzy-link
812 (org-element-map tree
'link
'identity info t
) info
)))
813 ;; 3. Match named elements.
814 (org-test-with-parsed-data "#+NAME: target\nParagraph\n\n[[target]]"
816 (org-export-resolve-fuzzy-link
817 (org-element-map tree
'link
'identity info t
) info
)))
818 ;; 4. Match exact headline's name.
819 (org-test-with-parsed-data "* My headline\n[[My headline]]"
821 (org-export-resolve-fuzzy-link
822 (org-element-map tree
'link
'identity info t
) info
)))
823 ;; 5. Targets objects have priority over named elements and headline
825 (org-test-with-parsed-data
826 "* target\n#+NAME: target\n<<target>>\n\n[[target]]"
830 (org-export-resolve-fuzzy-link
831 (org-element-map tree
'link
'identity info t
) info
)))))
832 ;; 6. Named elements have priority over headline titles.
833 (org-test-with-parsed-data
834 "* target\n#+NAME: target\nParagraph\n\n[[target]]"
838 (org-export-resolve-fuzzy-link
839 (org-element-map tree
'link
'identity info t
) info
)))))
840 ;; 7. If link's path starts with a "*", only match headline titles,
842 (org-test-with-parsed-data
843 "* target\n#+NAME: target\n<<target>>\n\n[[*target]]"
847 (org-export-resolve-fuzzy-link
848 (org-element-map tree
'link
'identity info t
) info
)))))
849 ;; 8. Return nil if no match.
850 (org-test-with-parsed-data "[[target]]"
852 (org-export-resolve-fuzzy-link
853 (org-element-map tree
'link
'identity info t
) info
))))
855 (ert-deftest test-org-export
/resolve-id-link
()
856 "Test `org-export-resolve-id-link' specifications."
857 ;; 1. Regular test for custom-id link.
858 (org-test-with-parsed-data "* Headline1
865 (org-export-resolve-id-link
866 (org-element-map tree
'link
'identity info t
) info
)))
867 ;; 2. Failing test for custom-id link.
868 (org-test-with-parsed-data "* Headline1
875 (org-export-resolve-id-link
876 (org-element-map tree
'link
'identity info t
) info
)))
877 ;; 3. Test for internal id target.
878 (org-test-with-parsed-data "* Headline1
885 (org-export-resolve-id-link
886 (org-element-map tree
'link
'identity info t
) info
)))
887 ;; 4. Test for external id target.
888 (org-test-with-parsed-data "[[id:aaaa]]"
890 (org-export-resolve-id-link
891 (org-element-map tree
'link
'identity info t
)
892 (org-combine-plists info
'(:id-alist
(("aaaa" .
"external-file"))))))))
894 (ert-deftest test-org-export
/resolve-radio-link
()
895 "Test `org-export-resolve-radio-link' specifications."
897 (org-test-with-temp-text "<<<radio>>> radio"
898 (org-update-radio-target-regexp)
900 (let* ((tree (org-element-parse-buffer))
901 (info `(:parse-tree
,tree
)))
902 (org-export-resolve-radio-link
903 (org-element-map tree
'link
'identity info t
)
905 ;; Radio target with objects.
906 (org-test-with-temp-text "<<<radio \\alpha>>> radio \\alpha"
907 (org-update-radio-target-regexp)
909 (let* ((tree (org-element-parse-buffer))
910 (info `(:parse-tree
,tree
)))
911 (org-export-resolve-radio-link
912 (org-element-map tree
'link
'identity info t
)
919 (ert-deftest test-org-export
/define-macro
()
920 "Try defining various Org macro using in-buffer #+MACRO: keyword."
922 (should (equal (org-test-with-temp-text "#+MACRO: one 1"
923 (org-export-get-inbuffer-options))
924 '(:macro-one
("1"))))
926 (should (equal (org-test-with-temp-text "#+MACRO: two (eval (+ 1 1))"
927 (org-export-get-inbuffer-options))
928 '(:macro-two
("(eval (+ 1 1))"))))
930 (should-not (org-test-with-temp-text "#+MACRO: three"
931 (org-export-get-inbuffer-options)))
932 ;; Macro with newline character.
933 (should (equal (org-test-with-temp-text "#+MACRO: four a\\nb"
934 (org-export-get-inbuffer-options))
935 '(:macro-four
("a\nb"))))
936 ;; Macro with protected newline character.
937 (should (equal (org-test-with-temp-text "#+MACRO: five a\\\\nb"
938 (org-export-get-inbuffer-options))
939 '(:macro-five
("a\\nb"))))
941 (org-test-with-temp-text "#+MACRO: six 6\n#+MACRO: seven 1 + {{{six}}}"
944 (org-export-get-inbuffer-options)
948 ("1 + " (macro (:key
"six" :value
"{{{six}}}" :args nil
:begin
5 :end
14
949 :post-blank
0 :parent nil
))))))))
951 (ert-deftest test-org-export
/expand-macro
()
952 "Test `org-export-expand-macro' specifications."
957 (org-test-with-parsed-data "#+MACRO: macro some text\n{{{macro}}}"
958 (org-export-expand-macro
959 (org-element-map tree
'macro
'identity info t
) info
))))
960 ;; Macro with arguments.
964 (org-test-with-parsed-data "#+MACRO: macro $1 $2\n{{{macro(some,text)}}}"
965 (org-export-expand-macro
966 (org-element-map tree
'macro
'identity info t
) info
))))
971 (org-test-with-parsed-data "#+MACRO: add (eval (+ $1 $2))\n{{{add(1,2)}}}"
972 (org-export-expand-macro
973 (org-element-map tree
'macro
'identity info t
) info
))))
978 (org-test-with-parsed-data
979 "#+MACRO: in inner\n#+MACRO: out {{{in}}} outer\n{{{out}}}"
980 (flet ((translate-macro (macro contents info
)
981 (org-export-expand-macro macro info
)))
982 (org-export-expand-macro
983 (org-element-map tree
'macro
'identity info t
)
985 info
`(:translate-alist
((macro . translate-macro
))))))))))
989 ;;; Src-block and example-block
991 (ert-deftest test-org-export
/unravel-code
()
992 "Test `org-export-unravel-code' function."
993 (let ((org-coderef-label-format "(ref:%s)"))
994 ;; 1. Code without reference.
995 (org-test-with-temp-text "#+BEGIN_EXAMPLE\n(+ 1 1)\n#+END_EXAMPLE"
996 (should (equal (org-export-unravel-code (org-element-current-element))
998 ;; 2. Code with reference.
999 (org-test-with-temp-text
1000 "#+BEGIN_EXAMPLE\n(+ 1 1) (ref:test)\n#+END_EXAMPLE"
1001 (should (equal (org-export-unravel-code (org-element-current-element))
1002 '("(+ 1 1)\n" (1 .
"test")))))
1003 ;; 3. Code with user-defined reference.
1004 (org-test-with-temp-text
1005 "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\n(+ 1 1) [ref:test]\n#+END_EXAMPLE"
1006 (should (equal (org-export-unravel-code (org-element-current-element))
1007 '("(+ 1 1)\n" (1 .
"test")))))
1008 ;; 4. Code references keys are relative to the current block.
1009 (org-test-with-temp-text "
1018 (should (equal (org-export-unravel-code (org-element-current-element))
1019 '("(+ 2 2)\n(+ 3 3)\n" (2 .
"one")))))
1020 ;; 5. Free up comma-protected lines.
1022 ;; 5.1. In an Org source block, every line is protected.
1023 (org-test-with-temp-text
1024 "#+BEGIN_SRC org\n,* Test\n,# comment\n,Text\n#+END_SRC"
1025 (should (equal (org-export-unravel-code (org-element-current-element))
1026 '("* Test\n# comment\nText\n"))))
1027 ;; 5.2. In other blocks, only headlines, comments and keywords are
1029 (org-test-with-temp-text
1030 "#+BEGIN_EXAMPLE\n,* Headline\n, * Not headline\n,Keep\n#+END_EXAMPLE"
1031 (should (equal (org-export-unravel-code (org-element-current-element))
1032 '("* Headline\n, * Not headline\n,Keep\n"))))))
1038 (ert-deftest test-org-export
/special-column
()
1039 "Test if the table's special column is properly recognized."
1040 ;; 1. First column is special if it contains only a special marking
1041 ;; characters or empty cells.
1042 (org-test-with-temp-text "
1046 (org-export-table-has-special-column-p
1048 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1049 ;; 2. If the column contains anything else, it isn't special.
1050 (org-test-with-temp-text "
1054 (org-export-table-has-special-column-p
1056 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1057 ;; 3. Special marking characters are "#", "^", "*", "_", "/", "$"
1059 (org-test-with-temp-text "
1068 (org-export-table-has-special-column-p
1070 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1071 ;; 4. A first column with only empty cells isn't considered as
1073 (org-test-with-temp-text "
1077 (org-export-table-has-special-column-p
1079 (org-element-parse-buffer) 'table
'identity nil
'first-match
)))))
1081 (ert-deftest test-org-export
/table-row-is-special-p
()
1082 "Test `org-export-table-row-is-special-p' specifications."
1083 ;; 1. A row is special if it has a special marking character in the
1085 (org-test-with-parsed-data "| ! | 1 |"
1087 (org-export-table-row-is-special-p
1088 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1089 ;; 2. A row is special when its first field is "/"
1090 (org-test-with-parsed-data "
1094 (org-export-table-row-is-special-p
1095 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1096 ;; 3. A row only containing alignment cookies is also considered as
1098 (org-test-with-parsed-data "| <5> | | <l> | <l22> |"
1100 (org-export-table-row-is-special-p
1101 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1102 ;; 4. Everything else isn't considered as special.
1103 (org-test-with-parsed-data "| \alpha | | c |"
1105 (org-export-table-row-is-special-p
1106 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1107 ;; 5. Table's rules are never considered as special rows.
1108 (org-test-with-parsed-data "|---+---|"
1110 (org-export-table-row-is-special-p
1111 (org-element-map tree
'table-row
'identity nil
'first-match
) info
))))
1113 (ert-deftest test-org-export
/has-header-p
()
1114 "Test `org-export-table-has-header-p' specifications."
1115 ;; 1. With an header.
1116 (org-test-with-parsed-data "
1121 (org-export-table-has-header-p
1122 (org-element-map tree
'table
'identity info
'first-match
)
1124 ;; 2. Without an header.
1125 (org-test-with-parsed-data "
1129 (org-export-table-has-header-p
1130 (org-element-map tree
'table
'identity info
'first-match
)
1132 ;; 3. Don't get fooled with starting and ending rules.
1133 (org-test-with-parsed-data "
1139 (org-export-table-has-header-p
1140 (org-element-map tree
'table
'identity info
'first-match
)
1143 (ert-deftest test-org-export
/table-row-group
()
1144 "Test `org-export-table-row-group' specifications."
1145 ;; 1. A rule creates a new group.
1146 (org-test-with-parsed-data "
1153 (mapcar (lambda (row) (org-export-table-row-group row info
))
1154 (org-element-map tree
'table-row
'identity
)))))
1155 ;; 2. Special rows are ignored in count.
1156 (org-test-with-parsed-data "
1163 (mapcar (lambda (row) (org-export-table-row-group row info
))
1164 (org-element-map tree
'table-row
'identity
)))))
1165 ;; 3. Double rules also are ignored in count.
1166 (org-test-with-parsed-data "
1174 (mapcar (lambda (row) (org-export-table-row-group row info
))
1175 (org-element-map tree
'table-row
'identity
))))))
1177 (ert-deftest test-org-export
/table-cell-width
()
1178 "Test `org-export-table-cell-width' specifications."
1179 ;; 1. Width is primarily determined by width cookies. If no cookie
1180 ;; is found, cell's width is nil.
1181 (org-test-with-parsed-data "
1182 | / | <l> | <6> | <l7> |
1187 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1188 (org-element-map tree
'table-cell
'identity info
)))))
1189 ;; 2. The last width cookie has precedence.
1190 (org-test-with-parsed-data "
1197 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1198 (org-element-map tree
'table-cell
'identity info
)))))
1199 ;; 3. Valid width cookies must have a specific row.
1200 (org-test-with-parsed-data "| <6> | cell |"
1204 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1205 (org-element-map tree
'table-cell
'identity
))))))
1207 (ert-deftest test-org-export
/table-cell-alignment
()
1208 "Test `org-export-table-cell-alignment' specifications."
1209 (let ((org-table-number-fraction 0.5)
1210 (org-table-number-regexp "^[0-9]+$"))
1211 ;; 1. Alignment is primarily determined by alignment cookies.
1212 (org-test-with-temp-text "| <l> | <c> | <r> |"
1213 (let* ((tree (org-element-parse-buffer))
1214 (info `(:parse-tree
,tree
)))
1217 '(left center right
)
1218 (mapcar (lambda (cell) (org-export-table-cell-alignment cell info
))
1219 (org-element-map tree
'table-cell
'identity
))))))
1220 ;; 2. The last alignment cookie has precedence.
1221 (org-test-with-parsed-data "
1227 '(right right right
)
1228 (mapcar (lambda (cell) (org-export-table-cell-alignment cell info
))
1229 (org-element-map tree
'table-cell
'identity
)))))
1230 ;; 3. If there's no cookie, cell's contents determine alignment.
1231 ;; A column mostly made of cells containing numbers will align
1232 ;; its cells to the right.
1233 (org-test-with-parsed-data "
1239 '(right right right
)
1240 (mapcar (lambda (cell)
1241 (org-export-table-cell-alignment cell info
))
1242 (org-element-map tree
'table-cell
'identity
)))))
1243 ;; 4. Otherwise, they will be aligned to the left.
1244 (org-test-with-parsed-data "
1251 (mapcar (lambda (cell)
1252 (org-export-table-cell-alignment cell info
))
1253 (org-element-map tree
'table-cell
'identity
)))))))
1255 (ert-deftest test-org-export
/table-cell-borders
()
1256 "Test `org-export-table-cell-borders' specifications."
1257 ;; 1. Recognize various column groups indicators.
1258 (org-test-with-parsed-data "| / | < | > | <> |"
1261 '((right bottom top
) (left bottom top
) (right bottom top
)
1262 (right left bottom top
))
1263 (mapcar (lambda (cell)
1264 (org-export-table-cell-borders cell info
))
1265 (org-element-map tree
'table-cell
'identity
)))))
1266 ;; 2. Accept shortcuts to define column groups.
1267 (org-test-with-parsed-data "| / | < | < |"
1270 '((right bottom top
) (right left bottom top
) (left bottom top
))
1271 (mapcar (lambda (cell)
1272 (org-export-table-cell-borders cell info
))
1273 (org-element-map tree
'table-cell
'identity
)))))
1274 ;; 3. A valid column groups row must start with a "/".
1275 (org-test-with-parsed-data "
1279 (equal '((top) (top) (bottom) (bottom))
1280 (mapcar (lambda (cell)
1281 (org-export-table-cell-borders cell info
))
1282 (org-element-map tree
'table-cell
'identity
)))))
1283 ;; 4. Take table rules into consideration.
1284 (org-test-with-parsed-data "
1289 (equal '((below top
) (bottom above
))
1290 (mapcar (lambda (cell)
1291 (org-export-table-cell-borders cell info
))
1292 (org-element-map tree
'table-cell
'identity
)))))
1293 ;; 5. Top and (resp. bottom) rules induce both `top' and `above'
1294 ;; (resp. `bottom' and `below') borders. Any special row is
1296 (org-test-with-parsed-data "
1302 (equal '((bottom below top above
))
1304 (mapcar (lambda (cell)
1305 (org-export-table-cell-borders cell info
))
1306 (org-element-map tree
'table-cell
'identity
)))))))
1308 (ert-deftest test-org-export
/table-dimensions
()
1309 "Test `org-export-table-dimensions' specifications."
1310 ;; 1. Standard test.
1311 (org-test-with-parsed-data "
1316 (org-export-table-dimensions
1317 (org-element-map tree
'table
'identity info
'first-match
) info
))))
1318 ;; 2. Ignore horizontal rules and special columns.
1319 (org-test-with-parsed-data "
1326 (org-export-table-dimensions
1327 (org-element-map tree
'table
'identity info
'first-match
) info
)))))
1329 (ert-deftest test-org-export
/table-cell-address
()
1330 "Test `org-export-table-cell-address' specifications."
1331 ;; 1. Standard test: index is 0-based.
1332 (org-test-with-parsed-data "| a | b |"
1334 (equal '((0 .
0) (0 .
1))
1337 (lambda (cell) (org-export-table-cell-address cell info
))
1339 ;; 2. Special column isn't counted, nor are special rows.
1340 (org-test-with-parsed-data "
1345 (org-export-table-cell-address
1346 (car (last (org-element-map tree
'table-cell
'identity info
)))
1348 ;; 3. Tables rules do not count either.
1349 (org-test-with-parsed-data "
1357 (org-export-table-cell-address
1358 (car (last (org-element-map tree
'table-cell
'identity info
)))
1360 ;; 4. Return nil for special cells.
1361 (org-test-with-parsed-data "| / | a |"
1363 (org-export-table-cell-address
1364 (org-element-map tree
'table-cell
'identity nil
'first-match
)
1367 (ert-deftest test-org-export
/get-table-cell-at
()
1368 "Test `org-export-get-table-cell-at' specifications."
1369 ;; 1. Address ignores special columns, special rows and rules.
1370 (org-test-with-parsed-data "
1377 (org-element-contents
1378 (org-export-get-table-cell-at
1380 (org-element-map tree
'table
'identity info
'first-match
)
1382 ;; 2. Return value for a non-existent address is nil.
1383 (org-test-with-parsed-data "| a |"
1385 (org-export-get-table-cell-at
1387 (org-element-map tree
'table
'identity info
'first-match
)
1389 (org-test-with-parsed-data "| / |"
1391 (org-export-get-table-cell-at
1393 (org-element-map tree
'table
'identity info
'first-match
)
1396 (ert-deftest test-org-export
/table-cell-starts-colgroup-p
()
1397 "Test `org-export-table-cell-starts-colgroup-p' specifications."
1398 ;; 1. A cell at a beginning of a row always starts a column group.
1399 (org-test-with-parsed-data "| a |"
1401 (org-export-table-cell-starts-colgroup-p
1402 (org-element-map tree
'table-cell
'identity info
'first-match
)
1404 ;; 2. Special column should be ignored when determining the
1405 ;; beginning of the row.
1406 (org-test-with-parsed-data "
1410 (org-export-table-cell-starts-colgroup-p
1411 (org-element-map tree
'table-cell
'identity info
'first-match
)
1413 ;; 2. Explicit column groups.
1414 (org-test-with-parsed-data "
1423 (if (org-export-table-cell-starts-colgroup-p cell info
) 'yes
'no
))
1426 (ert-deftest test-org-export
/table-cell-ends-colgroup-p
()
1427 "Test `org-export-table-cell-ends-colgroup-p' specifications."
1428 ;; 1. A cell at the end of a row always ends a column group.
1429 (org-test-with-parsed-data "| a |"
1431 (org-export-table-cell-ends-colgroup-p
1432 (org-element-map tree
'table-cell
'identity info
'first-match
)
1434 ;; 2. Special column should be ignored when determining the
1435 ;; beginning of the row.
1436 (org-test-with-parsed-data "
1440 (org-export-table-cell-ends-colgroup-p
1441 (org-element-map tree
'table-cell
'identity info
'first-match
)
1443 ;; 3. Explicit column groups.
1444 (org-test-with-parsed-data "
1453 (if (org-export-table-cell-ends-colgroup-p cell info
) 'yes
'no
))
1456 (ert-deftest test-org-export
/table-row-starts-rowgroup-p
()
1457 "Test `org-export-table-row-starts-rowgroup-p' specifications."
1458 ;; 1. A row at the beginning of a table always starts a row group.
1459 ;; So does a row following a table rule.
1460 (org-test-with-parsed-data "
1470 (if (org-export-table-row-starts-rowgroup-p row info
) 'yes
'no
))
1472 ;; 2. Special rows should be ignored when determining the beginning
1474 (org-test-with-parsed-data "
1486 (if (org-export-table-row-starts-rowgroup-p row info
) 'yes
'no
))
1489 (ert-deftest test-org-export
/table-row-ends-rowgroup-p
()
1490 "Test `org-export-table-row-ends-rowgroup-p' specifications."
1491 ;; 1. A row at the end of a table always ends a row group. So does
1492 ;; a row preceding a table rule.
1493 (org-test-with-parsed-data "
1503 (if (org-export-table-row-ends-rowgroup-p row info
) 'yes
'no
))
1505 ;; 2. Special rows should be ignored when determining the beginning
1507 (org-test-with-parsed-data "
1519 (if (org-export-table-row-ends-rowgroup-p row info
) 'yes
'no
))
1522 (ert-deftest test-org-export
/table-row-starts-header-p
()
1523 "Test `org-export-table-row-starts-header-p' specifications."
1524 ;; 1. Only the row starting the first row group starts the table
1526 (org-test-with-parsed-data "
1537 (if (org-export-table-row-starts-header-p row info
) 'yes
'no
))
1539 ;; 2. A row cannot start an header if there's no header in the
1541 (org-test-with-parsed-data "
1545 (org-export-table-row-starts-header-p
1546 (org-element-map tree
'table-row
'identity info
'first-match
)
1549 (ert-deftest test-org-export
/table-row-ends-header-p
()
1550 "Test `org-export-table-row-ends-header-p' specifications."
1551 ;; 1. Only the row starting the first row group starts the table
1553 (org-test-with-parsed-data "
1564 (if (org-export-table-row-ends-header-p row info
) 'yes
'no
))
1566 ;; 2. A row cannot start an header if there's no header in the
1568 (org-test-with-parsed-data "
1572 (org-export-table-row-ends-header-p
1573 (org-element-map tree
'table-row
'identity info
'first-match
)
1577 (provide 'test-org-export
)
1578 ;;; test-org-export.el end here