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 #+EXCLUDE_TAGS: noexport invisible
105 #+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
/get-subtree-options
()
116 "Test setting options from headline's properties."
118 (org-test-with-temp-text "#+TITLE: Title
121 :EXPORT_TITLE: Subtree Title
125 (should (equal (plist-get (org-export-get-environment nil t
) :title
)
126 '("Subtree Title"))))
130 (org-test-with-temp-text "#+OPTIONS: H:1
138 (= 2 (plist-get (org-export-get-environment nil t
) :headline-levels
))))
140 (org-test-with-temp-text "#+DATE: today
143 :EXPORT_DATE: 29-03-2012
147 (should (equal (plist-get (org-export-get-environment nil t
) :date
)
150 (ert-deftest test-org-export
/handle-options
()
151 "Test if export options have an impact on output."
152 ;; Test exclude tags.
153 (org-test-with-temp-text "* Head1 :noexport:"
154 (org-test-with-backend test
156 (equal (org-export-as 'test nil nil nil
'(:exclude-tags
("noexport")))
158 ;; Test include tags.
159 (org-test-with-temp-text "
162 ** Sub-Head2.1 :export:
165 (org-test-with-backend test
168 "* Head2\n** Sub-Head2.1 :export:\n*** Sub-Head2.1.1\n"
169 (let ((org-tags-column 0))
170 (org-export-as 'test nil nil nil
'(:select-tags
("export"))))))))
171 ;; Test mixing include tags and exclude tags.
172 (org-test-with-temp-text "
174 ** Sub-Head1 :noexport:
177 ** Sub-Head1 :export:"
178 (org-test-with-backend test
181 "\\* Head1[ \t]+:export:\n\\*\\* Sub-Head2\n"
184 '(:select-tags
("export") :exclude-tags
("noexport")))))))
186 (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
187 (org-test-with-temp-text "* TODO Head1"
188 (org-test-with-backend test
189 (should (equal (org-export-as 'test nil nil nil
'(:with-tasks nil
))
191 (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
192 (org-test-with-temp-text "* TODO Head1"
193 (org-test-with-backend test
194 (should (equal (org-export-as 'test nil nil nil
'(:with-tasks t
))
195 "* TODO Head1\n")))))
197 (org-test-with-temp-text "* Head1 :archive:"
198 (let ((org-archive-tag "archive"))
199 (org-test-with-backend test
201 (equal (org-export-as 'test nil nil nil
'(:with-archived-trees nil
))
203 (org-test-with-temp-text "* Head1 :archive:\nbody\n** Sub-head 2"
204 (let ((org-archive-tag "archive"))
205 (org-test-with-backend test
208 "\\* Head1[ \t]+:archive:"
209 (org-export-as 'test nil nil nil
210 '(:with-archived-trees headline
)))))))
211 (org-test-with-temp-text "* Head1 :archive:"
212 (let ((org-archive-tag "archive"))
213 (org-test-with-backend test
216 "\\`\\* Head1[ \t]+:archive:\n\\'"
217 (org-export-as 'test nil nil nil
'(:with-archived-trees t
)))))))
219 (let ((org-drawers '("TEST")))
220 (org-test-with-temp-text ":TEST:\ncontents\n:END:"
221 (org-test-with-backend test
222 (should (equal (org-export-as 'test nil nil nil
'(:with-drawers nil
))
224 (should (equal (org-export-as 'test nil nil nil
'(:with-drawers t
))
225 ":TEST:\ncontents\n:END:\n")))))
226 (let ((org-drawers '("FOO" "BAR")))
227 (org-test-with-temp-text ":FOO:\nkeep\n:END:\n:BAR:\nremove\n:END:"
228 (org-test-with-backend test
230 (equal (org-export-as 'test nil nil nil
'(:with-drawers
("FOO")))
231 ":FOO:\nkeep\n:END:\n")))))
233 (org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
234 (org-test-with-backend test
236 (equal (org-export-as 'test nil nil nil
'(:with-timestamps t
))
237 "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>\n"))
239 (equal (org-export-as 'test nil nil nil
'(:with-timestamps nil
)) ""))
241 (equal (org-export-as 'test nil nil nil
'(:with-timestamps active
))
242 "<2012-04-29 sun. 10:45>\n"))
244 (equal (org-export-as 'test nil nil nil
'(:with-timestamps inactive
))
245 "[2012-04-29 sun. 10:45]\n"))))
247 (let ((org-clock-string "CLOCK:"))
248 (org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
249 (org-test-with-backend test
251 (equal (org-export-as 'test nil nil nil
'(:with-clocks t
))
252 "CLOCK: [2012-04-29 sun. 10:45]\n"))
254 (equal (org-export-as 'test nil nil nil
'(:with-clocks nil
)) "")))))
256 (let ((org-closed-string "CLOSED:"))
257 (org-test-with-temp-text "CLOSED: [2012-04-29 sun. 10:45]"
258 (org-test-with-backend test
260 (equal (org-export-as 'test nil nil nil
'(:with-plannings t
))
261 "CLOSED: [2012-04-29 sun. 10:45]\n"))
263 (equal (org-export-as 'test nil nil nil
'(:with-plannings nil
))
266 (ert-deftest test-org-export
/comment-tree
()
267 "Test if export process ignores commented trees."
268 (let ((org-comment-string "COMMENT"))
269 (org-test-with-temp-text "* COMMENT Head1"
270 (org-test-with-backend test
271 (should (equal (org-export-as 'test
) ""))))))
273 (ert-deftest test-org-export
/export-scope
()
274 "Test all export scopes."
275 (org-test-with-temp-text "
280 (org-test-with-backend test
283 (should (equal (org-export-as 'test
'subtree
) "text\n*** Head3\n"))
285 (goto-char (point-min))
288 (should (equal (org-export-as 'test nil
'visible
) "* Head1\n"))
290 (flet ((org-test-template (body info
) (format "BEGIN\n%sEND" body
)))
291 (push '(template . org-test-template
) org-test-translate-alist
)
292 (should (equal (org-export-as 'test nil nil
'body-only
)
293 "* Head1\n** Head2\ntext\n*** Head3\n"))
294 (should (equal (org-export-as 'test
)
295 "BEGIN\n* Head1\n** Head2\ntext\n*** Head3\nEND")))
297 (goto-char (point-min))
299 (transient-mark-mode 1)
300 (push-mark (point) t t
)
301 (goto-char (point-at-eol))
302 (should (equal (org-export-as 'test
) "text\n"))))
303 ;; Subtree with a code block calling another block outside.
304 (org-test-with-temp-text "
306 #+BEGIN_SRC emacs-lisp :noweb yes :exports results
311 #+BEGIN_SRC emacs-lisp
314 (org-test-with-backend test
316 (should (equal (org-export-as 'test
'subtree
) ": 3\n")))))
318 (ert-deftest test-org-export
/expand-include
()
319 "Test file inclusion in an Org buffer."
320 ;; Full insertion with recursive inclusion.
321 (org-test-with-temp-text
322 (format "#+INCLUDE: \"%s/examples/include.org\"" org-test-dir
)
323 (org-export-expand-include-keyword)
324 (should (equal (buffer-string)
325 "Small Org file with an include keyword.
327 #+BEGIN_SRC emacs-lisp :exports results\n(+ 2 1)\n#+END_SRC
333 ;; Localized insertion.
334 (org-test-with-temp-text
335 (format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\""
337 (org-export-expand-include-keyword)
338 (should (equal (buffer-string)
339 "Small Org file with an include keyword.\n")))
340 ;; Insertion with constraints on headlines level.
341 (org-test-with-temp-text
343 "* Top heading\n#+INCLUDE: \"%s/examples/include.org\" :lines \"9-\""
345 (org-export-expand-include-keyword)
346 (should (equal (buffer-string) "* Top heading\n** Heading\nbody\n")))
347 ;; Inclusion within an example block.
348 (org-test-with-temp-text
349 (format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\" example"
351 (org-export-expand-include-keyword)
355 "#+BEGIN_EXAMPLE\nSmall Org file with an include keyword.\n#+END_EXAMPLE\n")))
356 ;; Inclusion within a src-block.
357 (org-test-with-temp-text
359 "#+INCLUDE: \"%s/examples/include.org\" :lines \"4-5\" src emacs-lisp"
361 (org-export-expand-include-keyword)
362 (should (equal (buffer-string)
363 "#+BEGIN_SRC emacs-lisp\n(+ 2 1)\n#+END_SRC\n"))))
365 (ert-deftest test-org-export
/user-ignore-list
()
366 "Test if `:ignore-list' accepts user input."
367 (org-test-with-backend test
368 (flet ((skip-note-head
370 ;; Ignore headlines with the word "note" in their title.
374 (when (string-match "\\<note\\>"
375 (org-element-property :raw-value headline
))
376 (org-export-ignore-element headline info
)))
379 ;; Install function in parse tree filters.
380 (let ((org-export-filter-parse-tree-functions '(skip-note-head)))
381 (org-test-with-temp-text "* Head1\n* Head2 (note)\n"
382 (should (equal (org-export-as 'test
) "* Head1\n")))))))
384 (ert-deftest test-org-export
/before-parsing-hook
()
385 "Test `org-export-before-parsing-hook'."
386 (org-test-with-backend test
387 (org-test-with-temp-text "* Headline 1\nBody 1\n* Headline 2\nBody 2"
388 (let ((org-export-before-parsing-hook
392 (delete-region (point) (progn (forward-line) (point)))))))))
393 (should (equal (org-export-as 'test
) "Body 1\nBody 2\n"))))))
397 ;;; Affiliated Keywords
399 (ert-deftest test-org-export
/read-attribute
()
400 "Test `org-export-read-attribute' specifications."
404 (org-export-read-attribute
406 (org-test-with-temp-text "#+ATTR_HTML: :a 1 :b 2\nParagraph"
407 (org-element-current-element)))
409 ;; Return nil on empty attribute.
411 (org-export-read-attribute
413 (org-test-with-temp-text "Paragraph" (org-element-current-element)))))
419 (ert-deftest test-org-export
/export-snippet
()
420 "Test export snippets transcoding."
421 (org-test-with-temp-text "@@test:A@@@@t:B@@"
422 (org-test-with-backend test
423 (flet ((org-test-export-snippet
424 (snippet contents info
)
425 (when (eq (org-export-snippet-backend snippet
) 'test
)
426 (org-element-property :value snippet
))))
427 (let ((org-export-snippet-translation-alist nil
))
428 (should (equal (org-export-as 'test
) "A\n")))
429 (let ((org-export-snippet-translation-alist '(("t" .
"test"))))
430 (should (equal (org-export-as 'test
) "AB\n")))))))
436 (ert-deftest test-org-export
/footnotes
()
437 "Test footnotes specifications."
438 (let ((org-footnote-section nil
)
439 (org-export-with-footnotes t
))
440 ;; 1. Read every type of footnote.
441 (org-test-with-parsed-data
442 "Text[fn:1] [1] [fn:label:C] [fn::D]\n\n[fn:1] A\n\n[1] B"
445 '((1 .
"A") (2 .
"B") (3 .
"C") (4 .
"D"))
447 tree
'footnote-reference
449 (let ((def (org-export-get-footnote-definition ref info
)))
450 (cons (org-export-get-footnote-number ref info
)
451 (if (eq (org-element-property :type ref
) 'inline
) (car def
)
452 (car (org-element-contents
453 (car (org-element-contents def
))))))))
455 ;; 2. Test nested footnotes order.
456 (org-test-with-parsed-data
457 "Text[fn:1:A[fn:2]] [fn:3].\n\n[fn:2] B [fn:3] [fn::D].\n\n[fn:3] C."
460 '((1 .
"fn:1") (2 .
"fn:2") (3 .
"fn:3") (4))
462 tree
'footnote-reference
464 (when (org-export-footnote-first-reference-p ref info
)
465 (cons (org-export-get-footnote-number ref info
)
466 (org-element-property :label ref
))))
468 ;; 3. Test nested footnote in invisible definitions.
469 (org-test-with-temp-text "Text[1]\n\n[1] B [2]\n\n[2] C."
471 (narrow-to-region (point) (point-at-eol))
472 (let* ((tree (org-element-parse-buffer))
473 (info (org-combine-plists
475 (org-export-collect-tree-properties
476 tree
(org-export-get-environment)))))
477 ;; Both footnotes should be seen.
479 (= (length (org-export-collect-footnote-definitions tree info
)) 2))))
480 ;; 4. Test footnotes definitions collection.
481 (org-test-with-parsed-data "Text[fn:1:A[fn:2]] [fn:3].
483 \[fn:2] B [fn:3] [fn::D].
486 (should (= (length (org-export-collect-footnote-definitions tree info
))
488 ;; 5. Test export of footnotes defined outside parsing scope.
489 (org-test-with-temp-text "[fn:1] Out of scope
492 (org-test-with-backend test
493 (flet ((org-test-footnote-reference
494 (fn-ref contents info
)
495 (org-element-interpret-data
496 (org-export-get-footnote-definition fn-ref info
))))
498 (should (equal "ParagraphOut of scope\n"
499 (org-export-as 'test
'subtree
))))))))
503 ;;; Headlines and Inlinetasks
505 (ert-deftest test-org-export
/get-relative-level
()
506 "Test `org-export-get-relative-level' specifications."
510 (let ((org-odd-levels-only nil
))
511 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
514 (lambda (h) (org-export-get-relative-level h info
))
519 (let ((org-odd-levels-only nil
))
520 (org-test-with-parsed-data "** Headline 1\n**** Headline 2"
523 (lambda (h) (org-export-get-relative-level h info
))
526 (ert-deftest test-org-export
/low-level-p
()
527 "Test `org-export-low-level-p' specifications."
531 (let ((org-odd-levels-only nil
))
532 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
535 (lambda (h) (if (org-export-low-level-p h info
) 'yes
'no
))
536 (plist-put info
:headline-levels
1)))))))
538 (ert-deftest test-org-export
/get-headline-number
()
539 "Test `org-export-get-headline-number' 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-headline-number h info
))
550 ;; Missing levels are replaced with 0.
554 (let ((org-odd-levels-only nil
))
555 (org-test-with-parsed-data "* Headline 1\n*** Headline 2"
558 (lambda (h) (org-export-get-headline-number h info
))
561 (ert-deftest test-org-export
/numbered-headline-p
()
562 "Test `org-export-numbered-headline-p' specifications."
563 ;; If `:section-numbers' is nil, never number headlines.
565 (org-test-with-parsed-data "* Headline"
568 (lambda (h) (org-export-numbered-headline-p h info
))
569 (plist-put info
:section-numbers nil
))))
570 ;; If `:section-numbers' is a number, only number headlines with
571 ;; a level greater that it.
575 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
578 (lambda (h) (if (org-export-numbered-headline-p h info
) 'yes
'no
))
579 (plist-put info
:section-numbers
1)))))
580 ;; Otherwise, headlines are always numbered.
582 (org-test-with-parsed-data "* Headline"
585 (lambda (h) (org-export-numbered-headline-p h info
))
586 (plist-put info
:section-numbers t
)))))
588 (ert-deftest test-org-export
/number-to-roman
()
589 "Test `org-export-number-to-roman' specifications."
590 ;; If number is negative, return it as a string.
591 (should (equal (org-export-number-to-roman -
1) "-1"))
592 ;; Otherwise, return it as a roman number.
593 (should (equal (org-export-number-to-roman 1449) "MCDXLIX")))
595 (ert-deftest test-org-export
/get-tags
()
596 "Test `org-export-get-tags' specifications."
597 (let ((org-export-exclude-tags '("noexport"))
598 (org-export-select-tags '("export")))
599 ;; Standard test: tags which are not a select tag, an exclude tag,
600 ;; or specified as optional argument shouldn't be ignored.
602 (org-test-with-parsed-data "* Headline :tag:"
603 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
605 ;; Exclude tags are removed.
607 (org-test-with-parsed-data "* Headline :noexport:"
608 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
610 ;; Select tags are removed.
612 (org-test-with-parsed-data "* Headline :export:"
613 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
618 (org-test-with-parsed-data "* Headline :tag:export:"
619 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
621 ;; Tags provided in the optional argument are also ignored.
623 (org-test-with-parsed-data "* Headline :ignore:"
624 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
625 info
'("ignore"))))))
627 (ert-deftest test-org-export
/first-sibling-p
()
628 "Test `org-export-first-sibling-p' specifications."
632 (org-test-with-temp-text "* Headline\n** Headline 2\n** Headline 3"
634 (org-element-parse-buffer) 'headline
635 (lambda (h) (if (org-export-first-sibling-p h
) 'yes
'no
)))))))
637 (ert-deftest test-org-export
/last-sibling-p
()
638 "Test `org-export-last-sibling-p' specifications."
642 (org-test-with-temp-text "* Headline\n** Headline 2\n** Headline 3"
644 (org-element-parse-buffer) 'headline
645 (lambda (h) (if (org-export-last-sibling-p h
) 'yes
'no
)))))))
651 (ert-deftest test-org-export
/get-coderef-format
()
652 "Test `org-export-get-coderef-format' specifications."
653 ;; A link without description returns "%s"
654 (should (equal (org-export-get-coderef-format "(ref:line)" nil
)
656 ;; Return "%s" when path is matched within description.
657 (should (equal (org-export-get-coderef-format "path" "desc (path)")
659 ;; Otherwise return description.
660 (should (equal (org-export-get-coderef-format "path" "desc")
663 (ert-deftest test-org-export
/inline-image-p
()
664 "Test `org-export-inline-image-p' specifications."
666 (org-export-inline-image-p
667 (org-test-with-temp-text "[[#id]]"
669 (org-element-parse-buffer) 'link
'identity nil t
))
670 '(("custom-id" .
"id")))))
672 (ert-deftest test-org-export
/fuzzy-link
()
673 "Test fuzzy links specifications."
674 ;; 1. Links to invisible (keyword) targets should be ignored.
675 (org-test-with-parsed-data
676 "Paragraph.\n#+TARGET: Test\n[[Test]]"
681 (org-export-get-ordinal
682 (org-export-resolve-fuzzy-link link info
) info
)) info
)))
683 ;; 2. Link to an headline should return headline's number.
684 (org-test-with-parsed-data
685 "Paragraph.\n* Head1\n* Head2\n* Head3\n[[Head2]]"
687 ;; Note: Headline's number is in fact a list of numbers.
692 (org-export-get-ordinal
693 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
694 ;; 3. Link to a target in an item should return item's number.
695 (org-test-with-parsed-data
696 "- Item1\n - Item11\n - <<test>>Item12\n- Item2\n\n\n[[test]]"
698 ;; Note: Item's number is in fact a list of numbers.
703 (org-export-get-ordinal
704 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
705 ;; 4. Link to a target in a footnote should return footnote's
707 (org-test-with-parsed-data "
708 Paragraph[1][2][fn:lbl3:C<<target>>][[test]][[target]]\n[1] A\n\n[2] <<test>>B"
714 (org-export-get-ordinal
715 (org-export-resolve-fuzzy-link link info
) info
)) info
))))
716 ;; 5. Link to a named element should return sequence number of that
718 (org-test-with-parsed-data
719 "#+NAME: tbl1\n|1|2|\n#+NAME: tbl2\n|3|4|\n#+NAME: tbl3\n|5|6|\n[[tbl2]]"
725 (org-export-get-ordinal
726 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
727 ;; 6. Link to a target not within an item, a table, a footnote
728 ;; reference or definition should return section number.
729 (org-test-with-parsed-data
730 "* Head1\n* Head2\nParagraph<<target>>\n* Head3\n[[target]]"
736 (org-export-get-ordinal
737 (org-export-resolve-fuzzy-link link info
) info
)) info t
)))))
739 (ert-deftest test-org-export
/resolve-coderef
()
740 "Test `org-export-resolve-coderef' specifications."
741 (let ((org-coderef-label-format "(ref:%s)"))
742 ;; 1. A link to a "-n -k -r" block returns line number.
743 (org-test-with-parsed-data
744 "#+BEGIN_EXAMPLE -n -k -r\nText (ref:coderef)\n#+END_EXAMPLE"
745 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
746 (org-test-with-parsed-data
747 "#+BEGIN_SRC emacs-lisp -n -k -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
748 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
749 ;; 2. A link to a "-n -r" block returns line number.
750 (org-test-with-parsed-data
751 "#+BEGIN_EXAMPLE -n -r\nText (ref:coderef)\n#+END_EXAMPLE"
752 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
753 (org-test-with-parsed-data
754 "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
755 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
756 ;; 3. A link to a "-n" block returns coderef.
757 (org-test-with-parsed-data
758 "#+BEGIN_SRC emacs-lisp -n\n(+ 1 1) (ref:coderef)\n#+END_SRC"
759 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
760 (org-test-with-parsed-data
761 "#+BEGIN_EXAMPLE -n\nText (ref:coderef)\n#+END_EXAMPLE"
762 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
763 ;; 4. A link to a "-r" block returns line number.
764 (org-test-with-parsed-data
765 "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
766 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
767 (org-test-with-parsed-data
768 "#+BEGIN_EXAMPLE -r\nText (ref:coderef)\n#+END_EXAMPLE"
769 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
770 ;; 5. A link to a block without a switch returns coderef.
771 (org-test-with-parsed-data
772 "#+BEGIN_SRC emacs-lisp\n(+ 1 1) (ref:coderef)\n#+END_SRC"
773 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
774 (org-test-with-parsed-data
775 "#+BEGIN_EXAMPLE\nText (ref:coderef)\n#+END_EXAMPLE"
776 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
777 ;; 6. Correctly handle continued line numbers. A "+n" switch
778 ;; should resume numbering from previous block with numbered
779 ;; lines, ignoring blocks not numbering lines in the process.
780 ;; A "-n" switch resets count.
781 (org-test-with-parsed-data "
786 #+BEGIN_SRC emacs-lisp
790 #+BEGIN_SRC emacs-lisp +n -r
791 \(+ 1 1) (ref:addition)
794 #+BEGIN_EXAMPLE -n -r
795 Another text. (ref:text)
797 (should (= (org-export-resolve-coderef "addition" info
) 2))
798 (should (= (org-export-resolve-coderef "text" info
) 1)))
799 ;; 7. Recognize coderef with user-specified syntax.
800 (org-test-with-parsed-data
801 "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText. [ref:text]\n#+END_EXAMPLE"
802 (should (equal (org-export-resolve-coderef "text" info
) "text")))))
804 (ert-deftest test-org-export
/resolve-fuzzy-link
()
805 "Test `org-export-resolve-fuzzy-link' specifications."
806 ;; 1. Match target objects.
807 (org-test-with-parsed-data "<<target>> [[target]]"
809 (org-export-resolve-fuzzy-link
810 (org-element-map tree
'link
'identity info t
) info
)))
811 ;; 2. Match target elements.
812 (org-test-with-parsed-data "#+TARGET: target\n[[target]]"
814 (org-export-resolve-fuzzy-link
815 (org-element-map tree
'link
'identity info t
) info
)))
816 ;; 3. Match named elements.
817 (org-test-with-parsed-data "#+NAME: target\nParagraph\n\n[[target]]"
819 (org-export-resolve-fuzzy-link
820 (org-element-map tree
'link
'identity info t
) info
)))
821 ;; 4. Match exact headline's name.
822 (org-test-with-parsed-data "* My headline\n[[My headline]]"
824 (org-export-resolve-fuzzy-link
825 (org-element-map tree
'link
'identity info t
) info
)))
826 ;; 5. Targets objects have priority over named elements and headline
828 (org-test-with-parsed-data
829 "* target\n#+NAME: target\n<<target>>\n\n[[target]]"
833 (org-export-resolve-fuzzy-link
834 (org-element-map tree
'link
'identity info t
) info
)))))
835 ;; 6. Named elements have priority over headline titles.
836 (org-test-with-parsed-data
837 "* target\n#+NAME: target\nParagraph\n\n[[target]]"
841 (org-export-resolve-fuzzy-link
842 (org-element-map tree
'link
'identity info t
) info
)))))
843 ;; 7. If link's path starts with a "*", only match headline titles,
845 (org-test-with-parsed-data
846 "* target\n#+NAME: target\n<<target>>\n\n[[*target]]"
850 (org-export-resolve-fuzzy-link
851 (org-element-map tree
'link
'identity info t
) info
)))))
852 ;; 8. Return nil if no match.
853 (org-test-with-parsed-data "[[target]]"
855 (org-export-resolve-fuzzy-link
856 (org-element-map tree
'link
'identity info t
) info
))))
858 (ert-deftest test-org-export
/resolve-id-link
()
859 "Test `org-export-resolve-id-link' specifications."
860 ;; 1. Regular test for custom-id link.
861 (org-test-with-parsed-data "* Headline1
868 (org-export-resolve-id-link
869 (org-element-map tree
'link
'identity info t
) info
)))
870 ;; 2. Failing test for custom-id link.
871 (org-test-with-parsed-data "* Headline1
878 (org-export-resolve-id-link
879 (org-element-map tree
'link
'identity info t
) info
)))
880 ;; 3. Test for internal id target.
881 (org-test-with-parsed-data "* Headline1
888 (org-export-resolve-id-link
889 (org-element-map tree
'link
'identity info t
) info
)))
890 ;; 4. Test for external id target.
891 (org-test-with-parsed-data "[[id:aaaa]]"
893 (org-export-resolve-id-link
894 (org-element-map tree
'link
'identity info t
)
895 (org-combine-plists info
'(:id-alist
(("aaaa" .
"external-file"))))))))
897 (ert-deftest test-org-export
/resolve-radio-link
()
898 "Test `org-export-resolve-radio-link' specifications."
900 (org-test-with-temp-text "<<<radio>>> radio"
901 (org-update-radio-target-regexp)
903 (let* ((tree (org-element-parse-buffer))
904 (info `(:parse-tree
,tree
)))
905 (org-export-resolve-radio-link
906 (org-element-map tree
'link
'identity info t
)
908 ;; Radio target with objects.
909 (org-test-with-temp-text "<<<radio \\alpha>>> radio \\alpha"
910 (org-update-radio-target-regexp)
912 (let* ((tree (org-element-parse-buffer))
913 (info `(:parse-tree
,tree
)))
914 (org-export-resolve-radio-link
915 (org-element-map tree
'link
'identity info t
)
922 (ert-deftest test-org-export
/define-macro
()
923 "Try defining various Org macro using in-buffer #+MACRO: keyword."
925 (should (equal (org-test-with-temp-text "#+MACRO: one 1"
926 (org-export-get-inbuffer-options))
927 '(:macro-one
("1"))))
929 (should (equal (org-test-with-temp-text "#+MACRO: two (eval (+ 1 1))"
930 (org-export-get-inbuffer-options))
931 '(:macro-two
("(eval (+ 1 1))"))))
933 (should-not (org-test-with-temp-text "#+MACRO: three"
934 (org-export-get-inbuffer-options)))
935 ;; Macro with newline character.
936 (should (equal (org-test-with-temp-text "#+MACRO: four a\\nb"
937 (org-export-get-inbuffer-options))
938 '(:macro-four
("a\nb"))))
939 ;; Macro with protected newline character.
940 (should (equal (org-test-with-temp-text "#+MACRO: five a\\\\nb"
941 (org-export-get-inbuffer-options))
942 '(:macro-five
("a\\nb"))))
944 (org-test-with-temp-text "#+MACRO: six 6\n#+MACRO: seven 1 + {{{six}}}"
947 (org-export-get-inbuffer-options)
951 ("1 + " (macro (:key
"six" :value
"{{{six}}}" :args nil
:begin
5 :end
14
952 :post-blank
0 :parent nil
))))))))
954 (ert-deftest test-org-export
/expand-macro
()
955 "Test `org-export-expand-macro' specifications."
960 (org-test-with-parsed-data "#+MACRO: macro some text\n{{{macro}}}"
961 (org-export-expand-macro
962 (org-element-map tree
'macro
'identity info t
) info
))))
963 ;; Macro with arguments.
967 (org-test-with-parsed-data "#+MACRO: macro $1 $2\n{{{macro(some,text)}}}"
968 (org-export-expand-macro
969 (org-element-map tree
'macro
'identity info t
) info
))))
974 (org-test-with-parsed-data "#+MACRO: add (eval (+ $1 $2))\n{{{add(1,2)}}}"
975 (org-export-expand-macro
976 (org-element-map tree
'macro
'identity info t
) info
))))
981 (org-test-with-parsed-data
982 "#+MACRO: in inner\n#+MACRO: out {{{in}}} outer\n{{{out}}}"
983 (flet ((translate-macro (macro contents info
)
984 (org-export-expand-macro macro info
)))
985 (org-export-expand-macro
986 (org-element-map tree
'macro
'identity info t
)
988 info
`(:translate-alist
((macro . translate-macro
))))))))))
992 ;;; Src-block and example-block
994 (ert-deftest test-org-export
/unravel-code
()
995 "Test `org-export-unravel-code' function."
996 (let ((org-coderef-label-format "(ref:%s)"))
997 ;; 1. Code without reference.
998 (org-test-with-temp-text "#+BEGIN_EXAMPLE\n(+ 1 1)\n#+END_EXAMPLE"
999 (should (equal (org-export-unravel-code (org-element-current-element))
1001 ;; 2. Code with reference.
1002 (org-test-with-temp-text
1003 "#+BEGIN_EXAMPLE\n(+ 1 1) (ref:test)\n#+END_EXAMPLE"
1004 (should (equal (org-export-unravel-code (org-element-current-element))
1005 '("(+ 1 1)\n" (1 .
"test")))))
1006 ;; 3. Code with user-defined reference.
1007 (org-test-with-temp-text
1008 "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\n(+ 1 1) [ref:test]\n#+END_EXAMPLE"
1009 (should (equal (org-export-unravel-code (org-element-current-element))
1010 '("(+ 1 1)\n" (1 .
"test")))))
1011 ;; 4. Code references keys are relative to the current block.
1012 (org-test-with-temp-text "
1021 (should (equal (org-export-unravel-code (org-element-current-element))
1022 '("(+ 2 2)\n(+ 3 3)\n" (2 .
"one")))))
1023 ;; 5. Free up comma-protected lines.
1025 ;; 5.1. In an Org source block, every line is protected.
1026 (org-test-with-temp-text
1027 "#+BEGIN_SRC org\n,* Test\n,# comment\n,Text\n#+END_SRC"
1028 (should (equal (org-export-unravel-code (org-element-current-element))
1029 '("* Test\n# comment\nText\n"))))
1030 ;; 5.2. In other blocks, only headlines, comments and keywords are
1032 (org-test-with-temp-text
1033 "#+BEGIN_EXAMPLE\n,* Headline\n, * Not headline\n,Keep\n#+END_EXAMPLE"
1034 (should (equal (org-export-unravel-code (org-element-current-element))
1035 '("* Headline\n, * Not headline\n,Keep\n"))))))
1041 (ert-deftest test-org-export
/special-column
()
1042 "Test if the table's special column is properly recognized."
1043 ;; 1. First column is special if it contains only a special marking
1044 ;; characters or empty cells.
1045 (org-test-with-temp-text "
1049 (org-export-table-has-special-column-p
1051 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1052 ;; 2. If the column contains anything else, it isn't special.
1053 (org-test-with-temp-text "
1057 (org-export-table-has-special-column-p
1059 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1060 ;; 3. Special marking characters are "#", "^", "*", "_", "/", "$"
1062 (org-test-with-temp-text "
1071 (org-export-table-has-special-column-p
1073 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1074 ;; 4. A first column with only empty cells isn't considered as
1076 (org-test-with-temp-text "
1080 (org-export-table-has-special-column-p
1082 (org-element-parse-buffer) 'table
'identity nil
'first-match
)))))
1084 (ert-deftest test-org-export
/table-row-is-special-p
()
1085 "Test `org-export-table-row-is-special-p' specifications."
1086 ;; 1. A row is special if it has a special marking character in the
1088 (org-test-with-parsed-data "| ! | 1 |"
1090 (org-export-table-row-is-special-p
1091 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1092 ;; 2. A row is special when its first field is "/"
1093 (org-test-with-parsed-data "
1097 (org-export-table-row-is-special-p
1098 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1099 ;; 3. A row only containing alignment cookies is also considered as
1101 (org-test-with-parsed-data "| <5> | | <l> | <l22> |"
1103 (org-export-table-row-is-special-p
1104 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1105 ;; 4. Everything else isn't considered as special.
1106 (org-test-with-parsed-data "| \alpha | | c |"
1108 (org-export-table-row-is-special-p
1109 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1110 ;; 5. Table's rules are never considered as special rows.
1111 (org-test-with-parsed-data "|---+---|"
1113 (org-export-table-row-is-special-p
1114 (org-element-map tree
'table-row
'identity nil
'first-match
) info
))))
1116 (ert-deftest test-org-export
/has-header-p
()
1117 "Test `org-export-table-has-header-p' specifications."
1118 ;; 1. With an header.
1119 (org-test-with-parsed-data "
1124 (org-export-table-has-header-p
1125 (org-element-map tree
'table
'identity info
'first-match
)
1127 ;; 2. Without an header.
1128 (org-test-with-parsed-data "
1132 (org-export-table-has-header-p
1133 (org-element-map tree
'table
'identity info
'first-match
)
1135 ;; 3. Don't get fooled with starting and ending rules.
1136 (org-test-with-parsed-data "
1142 (org-export-table-has-header-p
1143 (org-element-map tree
'table
'identity info
'first-match
)
1146 (ert-deftest test-org-export
/table-row-group
()
1147 "Test `org-export-table-row-group' specifications."
1148 ;; 1. A rule creates a new group.
1149 (org-test-with-parsed-data "
1156 (mapcar (lambda (row) (org-export-table-row-group row info
))
1157 (org-element-map tree
'table-row
'identity
)))))
1158 ;; 2. Special rows are ignored in count.
1159 (org-test-with-parsed-data "
1166 (mapcar (lambda (row) (org-export-table-row-group row info
))
1167 (org-element-map tree
'table-row
'identity
)))))
1168 ;; 3. Double rules also are ignored in count.
1169 (org-test-with-parsed-data "
1177 (mapcar (lambda (row) (org-export-table-row-group row info
))
1178 (org-element-map tree
'table-row
'identity
))))))
1180 (ert-deftest test-org-export
/table-cell-width
()
1181 "Test `org-export-table-cell-width' specifications."
1182 ;; 1. Width is primarily determined by width cookies. If no cookie
1183 ;; is found, cell's width is nil.
1184 (org-test-with-parsed-data "
1185 | / | <l> | <6> | <l7> |
1190 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1191 (org-element-map tree
'table-cell
'identity info
)))))
1192 ;; 2. The last width cookie has precedence.
1193 (org-test-with-parsed-data "
1200 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1201 (org-element-map tree
'table-cell
'identity info
)))))
1202 ;; 3. Valid width cookies must have a specific row.
1203 (org-test-with-parsed-data "| <6> | cell |"
1207 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1208 (org-element-map tree
'table-cell
'identity
))))))
1210 (ert-deftest test-org-export
/table-cell-alignment
()
1211 "Test `org-export-table-cell-alignment' specifications."
1212 (let ((org-table-number-fraction 0.5)
1213 (org-table-number-regexp "^[0-9]+$"))
1214 ;; 1. Alignment is primarily determined by alignment cookies.
1215 (org-test-with-temp-text "| <l> | <c> | <r> |"
1216 (let* ((tree (org-element-parse-buffer))
1217 (info `(:parse-tree
,tree
)))
1220 '(left center right
)
1221 (mapcar (lambda (cell) (org-export-table-cell-alignment cell info
))
1222 (org-element-map tree
'table-cell
'identity
))))))
1223 ;; 2. The last alignment cookie has precedence.
1224 (org-test-with-parsed-data "
1230 '(right right right
)
1231 (mapcar (lambda (cell) (org-export-table-cell-alignment cell info
))
1232 (org-element-map tree
'table-cell
'identity
)))))
1233 ;; 3. If there's no cookie, cell's contents determine alignment.
1234 ;; A column mostly made of cells containing numbers will align
1235 ;; its cells to the right.
1236 (org-test-with-parsed-data "
1242 '(right right right
)
1243 (mapcar (lambda (cell)
1244 (org-export-table-cell-alignment cell info
))
1245 (org-element-map tree
'table-cell
'identity
)))))
1246 ;; 4. Otherwise, they will be aligned to the left.
1247 (org-test-with-parsed-data "
1254 (mapcar (lambda (cell)
1255 (org-export-table-cell-alignment cell info
))
1256 (org-element-map tree
'table-cell
'identity
)))))))
1258 (ert-deftest test-org-export
/table-cell-borders
()
1259 "Test `org-export-table-cell-borders' specifications."
1260 ;; 1. Recognize various column groups indicators.
1261 (org-test-with-parsed-data "| / | < | > | <> |"
1264 '((right bottom top
) (left bottom top
) (right bottom top
)
1265 (right left bottom top
))
1266 (mapcar (lambda (cell)
1267 (org-export-table-cell-borders cell info
))
1268 (org-element-map tree
'table-cell
'identity
)))))
1269 ;; 2. Accept shortcuts to define column groups.
1270 (org-test-with-parsed-data "| / | < | < |"
1273 '((right bottom top
) (right left bottom top
) (left bottom top
))
1274 (mapcar (lambda (cell)
1275 (org-export-table-cell-borders cell info
))
1276 (org-element-map tree
'table-cell
'identity
)))))
1277 ;; 3. A valid column groups row must start with a "/".
1278 (org-test-with-parsed-data "
1282 (equal '((top) (top) (bottom) (bottom))
1283 (mapcar (lambda (cell)
1284 (org-export-table-cell-borders cell info
))
1285 (org-element-map tree
'table-cell
'identity
)))))
1286 ;; 4. Take table rules into consideration.
1287 (org-test-with-parsed-data "
1292 (equal '((below top
) (bottom above
))
1293 (mapcar (lambda (cell)
1294 (org-export-table-cell-borders cell info
))
1295 (org-element-map tree
'table-cell
'identity
)))))
1296 ;; 5. Top and (resp. bottom) rules induce both `top' and `above'
1297 ;; (resp. `bottom' and `below') borders. Any special row is
1299 (org-test-with-parsed-data "
1305 (equal '((bottom below top above
))
1307 (mapcar (lambda (cell)
1308 (org-export-table-cell-borders cell info
))
1309 (org-element-map tree
'table-cell
'identity
)))))))
1311 (ert-deftest test-org-export
/table-dimensions
()
1312 "Test `org-export-table-dimensions' specifications."
1313 ;; 1. Standard test.
1314 (org-test-with-parsed-data "
1319 (org-export-table-dimensions
1320 (org-element-map tree
'table
'identity info
'first-match
) info
))))
1321 ;; 2. Ignore horizontal rules and special columns.
1322 (org-test-with-parsed-data "
1329 (org-export-table-dimensions
1330 (org-element-map tree
'table
'identity info
'first-match
) info
)))))
1332 (ert-deftest test-org-export
/table-cell-address
()
1333 "Test `org-export-table-cell-address' specifications."
1334 ;; 1. Standard test: index is 0-based.
1335 (org-test-with-parsed-data "| a | b |"
1337 (equal '((0 .
0) (0 .
1))
1340 (lambda (cell) (org-export-table-cell-address cell info
))
1342 ;; 2. Special column isn't counted, nor are special rows.
1343 (org-test-with-parsed-data "
1348 (org-export-table-cell-address
1349 (car (last (org-element-map tree
'table-cell
'identity info
)))
1351 ;; 3. Tables rules do not count either.
1352 (org-test-with-parsed-data "
1360 (org-export-table-cell-address
1361 (car (last (org-element-map tree
'table-cell
'identity info
)))
1363 ;; 4. Return nil for special cells.
1364 (org-test-with-parsed-data "| / | a |"
1366 (org-export-table-cell-address
1367 (org-element-map tree
'table-cell
'identity nil
'first-match
)
1370 (ert-deftest test-org-export
/get-table-cell-at
()
1371 "Test `org-export-get-table-cell-at' specifications."
1372 ;; 1. Address ignores special columns, special rows and rules.
1373 (org-test-with-parsed-data "
1380 (org-element-contents
1381 (org-export-get-table-cell-at
1383 (org-element-map tree
'table
'identity info
'first-match
)
1385 ;; 2. Return value for a non-existent address is nil.
1386 (org-test-with-parsed-data "| a |"
1388 (org-export-get-table-cell-at
1390 (org-element-map tree
'table
'identity info
'first-match
)
1392 (org-test-with-parsed-data "| / |"
1394 (org-export-get-table-cell-at
1396 (org-element-map tree
'table
'identity info
'first-match
)
1399 (ert-deftest test-org-export
/table-cell-starts-colgroup-p
()
1400 "Test `org-export-table-cell-starts-colgroup-p' specifications."
1401 ;; 1. A cell at a beginning of a row always starts a column group.
1402 (org-test-with-parsed-data "| a |"
1404 (org-export-table-cell-starts-colgroup-p
1405 (org-element-map tree
'table-cell
'identity info
'first-match
)
1407 ;; 2. Special column should be ignored when determining the
1408 ;; beginning of the row.
1409 (org-test-with-parsed-data "
1413 (org-export-table-cell-starts-colgroup-p
1414 (org-element-map tree
'table-cell
'identity info
'first-match
)
1416 ;; 2. Explicit column groups.
1417 (org-test-with-parsed-data "
1426 (if (org-export-table-cell-starts-colgroup-p cell info
) 'yes
'no
))
1429 (ert-deftest test-org-export
/table-cell-ends-colgroup-p
()
1430 "Test `org-export-table-cell-ends-colgroup-p' specifications."
1431 ;; 1. A cell at the end of a row always ends a column group.
1432 (org-test-with-parsed-data "| a |"
1434 (org-export-table-cell-ends-colgroup-p
1435 (org-element-map tree
'table-cell
'identity info
'first-match
)
1437 ;; 2. Special column should be ignored when determining the
1438 ;; beginning of the row.
1439 (org-test-with-parsed-data "
1443 (org-export-table-cell-ends-colgroup-p
1444 (org-element-map tree
'table-cell
'identity info
'first-match
)
1446 ;; 3. Explicit column groups.
1447 (org-test-with-parsed-data "
1456 (if (org-export-table-cell-ends-colgroup-p cell info
) 'yes
'no
))
1459 (ert-deftest test-org-export
/table-row-starts-rowgroup-p
()
1460 "Test `org-export-table-row-starts-rowgroup-p' specifications."
1461 ;; 1. A row at the beginning of a table always starts a row group.
1462 ;; So does a row following a table rule.
1463 (org-test-with-parsed-data "
1473 (if (org-export-table-row-starts-rowgroup-p row info
) 'yes
'no
))
1475 ;; 2. Special rows should be ignored when determining the beginning
1477 (org-test-with-parsed-data "
1489 (if (org-export-table-row-starts-rowgroup-p row info
) 'yes
'no
))
1492 (ert-deftest test-org-export
/table-row-ends-rowgroup-p
()
1493 "Test `org-export-table-row-ends-rowgroup-p' specifications."
1494 ;; 1. A row at the end of a table always ends a row group. So does
1495 ;; a row preceding a table rule.
1496 (org-test-with-parsed-data "
1506 (if (org-export-table-row-ends-rowgroup-p row info
) 'yes
'no
))
1508 ;; 2. Special rows should be ignored when determining the beginning
1510 (org-test-with-parsed-data "
1522 (if (org-export-table-row-ends-rowgroup-p row info
) 'yes
'no
))
1525 (ert-deftest test-org-export
/table-row-starts-header-p
()
1526 "Test `org-export-table-row-starts-header-p' specifications."
1527 ;; 1. Only the row starting the first row group starts the table
1529 (org-test-with-parsed-data "
1540 (if (org-export-table-row-starts-header-p row info
) 'yes
'no
))
1542 ;; 2. A row cannot start an header if there's no header in the
1544 (org-test-with-parsed-data "
1548 (org-export-table-row-starts-header-p
1549 (org-element-map tree
'table-row
'identity info
'first-match
)
1552 (ert-deftest test-org-export
/table-row-ends-header-p
()
1553 "Test `org-export-table-row-ends-header-p' specifications."
1554 ;; 1. Only the row starting the first row group starts the table
1556 (org-test-with-parsed-data "
1567 (if (org-export-table-row-ends-header-p row info
) 'yes
'no
))
1569 ;; 2. A row cannot start an header if there's no header in the
1571 (org-test-with-parsed-data "
1575 (org-export-table-row-ends-header-p
1576 (org-element-map tree
'table-row
'identity info
'first-match
)
1580 (provide 'test-org-export
)
1581 ;;; test-org-export.el end here