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 ;; This file is not part of GNU Emacs.
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
24 (unless (featurep 'org-export
)
25 (signal 'missing-test-dependency
"org-export"))
27 (defmacro org-test-with-backend
(backend &rest body
)
28 "Execute body with an export back-end defined.
30 BACKEND is the name of the back-end. BODY is the body to
31 execute. The defined back-end simply returns parsed data as Org
33 (declare (debug (form body
)) (indent 1))
34 `(let ((org-export-registered-backends
38 (let (transcode-table)
39 (dolist (type (append org-element-all-elements
40 org-element-all-objects
)
44 (lambda (obj contents info
)
46 (intern (format "org-element-%s-interpreter"
49 transcode-table
)))))))
52 (defmacro org-test-with-parsed-data
(data &rest body
)
53 "Execute body with parsed data available.
55 DATA is a string containing the data to be parsed. BODY is the
56 body to execute. Parse tree is available under the `tree'
57 variable, and communication channel under `info'.
59 This function calls `org-export-collect-tree-properties'. As
60 such, `:ignore-list' (for `org-element-map') and
61 `:parse-tree' (for `org-export-get-genealogy') properties are
62 already filled in `info'."
63 (declare (debug (form body
)) (indent 1))
64 `(org-test-with-temp-text ,data
65 (let* ((tree (org-element-parse-buffer))
66 (info (org-export-collect-tree-properties
67 tree
(org-export-get-environment))))
74 (ert-deftest test-org-export
/bind-keyword
()
75 "Test reading #+BIND: keywords."
76 ;; Test with `org-export-all-BIND' set to t.
78 (org-test-with-temp-text "#+BIND: variable value"
79 (let ((org-export-allow-BIND t
))
80 (org-export--install-letbind-maybe)
81 (eq variable
'value
))))
82 ;; Test with `org-export-all-BIND' set to nil.
84 (org-test-with-temp-text "#+BIND: variable value"
85 (let ((org-export-allow-BIND nil
))
86 (org-export--install-letbind-maybe)
88 ;; Test with `org-export-all-BIND' set to 'confirm and
89 ;; `org-export--allow-BIND-local' to t .
91 (org-test-with-temp-text "#+BIND: variable value"
92 (let ((org-export-allow-BIND 'confirm
))
93 (org-set-local 'org-export--allow-BIND-local t
)
94 (org-export--install-letbind-maybe)
95 (eq variable
'value
))))
96 ;; Test with `org-export-all-BIND' set to 'confirm and
97 ;; `org-export--allow-BIND-local' to nil.
99 (org-test-with-temp-text "#+BIND: variable value"
100 (let ((org-export-allow-BIND 'confirm
))
101 (org-set-local 'org-export--allow-BIND-local nil
)
102 (org-export--install-letbind-maybe)
103 (boundp 'variable
))))
104 ;; BIND keywords are case-insensitive.
106 (org-test-with-temp-text "#+bind: variable value"
107 (let ((org-export-allow-BIND t
))
108 (org-export--install-letbind-maybe)
109 (eq variable
'value
)))))
111 (ert-deftest test-org-export
/parse-option-keyword
()
112 "Test reading all standard #+OPTIONS: items."
115 (org-export--parse-option-keyword
116 "H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t
117 *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t inline:nil
120 1 :preserve-breaks t
:section-numbers t
:time-stamp-file t
121 :with-archived-trees t
:with-author t
:with-creator t
:with-drawers t
122 :with-email t
:with-emphasize t
:with-entities t
:with-fixed-width t
123 :with-footnotes t
:with-inlinetasks nil
:with-priority t
124 :with-special-strings t
:with-statistics-cookies t
:with-sub-superscript t
125 :with-toc t
:with-tables t
:with-tags t
:with-tasks t
:with-timestamps t
126 :with-todo-keywords t
)))
127 ;; Test some special values.
130 (org-export--parse-option-keyword
131 "arch:headline creator:comment d:(\"TEST\")
132 ^:{} toc:1 tags:not-in-toc tasks:todo num:2 <:active")
135 :with-archived-trees headline
:with-creator comment
136 :with-drawers
("TEST") :with-sub-superscript
{} :with-toc
1
137 :with-tags not-in-toc
:with-tasks todo
:with-timestamps active
))))
139 (ert-deftest test-org-export
/get-inbuffer-options
()
140 "Test reading all standard export keywords."
143 (org-test-with-temp-text "#+AUTHOR: Me, Myself and I
146 #+DESCRIPTION: Testing
147 #+DESCRIPTION: with two lines
148 #+EMAIL: some@email.org
149 #+EXCLUDE_TAGS: noexport invisible
152 #+SELECT_TAGS: export
154 #+TITLE: with spaces"
155 (org-export--get-inbuffer-options))
157 ("Me, Myself and I") :creator
"Idem" :date
("Today")
158 :description
"Testing\nwith two lines" :email
"some@email.org"
159 :exclude-tags
("noexport" "invisible") :keywords
"test" :language
"en"
160 :select-tags
("export") :title
("Some title with spaces")))))
162 (ert-deftest test-org-export
/get-subtree-options
()
163 "Test setting options from headline's properties."
165 (org-test-with-temp-text "#+TITLE: Title
168 :EXPORT_TITLE: Subtree Title
172 (should (equal (plist-get (org-export-get-environment nil t
) :title
)
173 '("Subtree Title"))))
177 (org-test-with-temp-text "#+OPTIONS: H:1
185 (= 2 (plist-get (org-export-get-environment nil t
) :headline-levels
))))
187 (org-test-with-temp-text "#+DATE: today
190 :EXPORT_DATE: 29-03-2012
194 (should (equal (plist-get (org-export-get-environment nil t
) :date
)
196 ;; Properties with `split' behaviour are stored as a list of
200 (org-test-with-temp-text "#+EXCLUDE_TAGS: noexport
203 :EXPORT_EXCLUDE_TAGS: a b
208 (plist-get (org-export-get-environment nil t
) :exclude-tags
)))))
209 ;; Handle :PROPERTY+: syntax.
212 (org-test-with-temp-text "#+EXCLUDE_TAGS: noexport
215 :EXPORT_EXCLUDE_TAGS: a
216 :EXPORT_EXCLUDE_TAGS+: b
221 (plist-get (org-export-get-environment nil t
) :exclude-tags
)))))
222 ;; Export properties are case-insensitive.
223 (org-test-with-temp-text "* Headline
225 :EXPORT_Date: 29-03-2012
228 (should (equal (plist-get (org-export-get-environment nil t
) :date
)
231 (ert-deftest test-org-export
/handle-options
()
232 "Test if export options have an impact on output."
233 ;; Test exclude tags.
234 (org-test-with-temp-text "* Head1 :noexport:"
235 (org-test-with-backend test
237 (equal (org-export-as 'test nil nil nil
'(:exclude-tags
("noexport")))
239 ;; Test include tags.
240 (org-test-with-temp-text "
243 ** Sub-Head2.1 :export:
246 (org-test-with-backend test
249 "* Head2\n** Sub-Head2.1 :export:\n*** Sub-Head2.1.1\n"
250 (let ((org-tags-column 0))
251 (org-export-as 'test nil nil nil
'(:select-tags
("export"))))))))
252 ;; Test mixing include tags and exclude tags.
253 (org-test-with-temp-text "
255 ** Sub-Head1 :noexport:
258 ** Sub-Head1 :export:"
259 (org-test-with-backend test
262 "\\* Head1[ \t]+:export:\n\\*\\* Sub-Head2\n"
265 '(:select-tags
("export") :exclude-tags
("noexport")))))))
267 (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
268 (org-test-with-temp-text "* TODO Head1"
269 (org-test-with-backend test
270 (should (equal (org-export-as 'test nil nil nil
'(:with-tasks nil
))
272 (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
273 (org-test-with-temp-text "* TODO Head1"
274 (org-test-with-backend test
275 (should (equal (org-export-as 'test nil nil nil
'(:with-tasks t
))
276 "* TODO Head1\n")))))
278 (org-test-with-temp-text "* Head1 :archive:"
279 (let ((org-archive-tag "archive"))
280 (org-test-with-backend test
282 (equal (org-export-as 'test nil nil nil
'(:with-archived-trees nil
))
284 (org-test-with-temp-text "* Head1 :archive:\nbody\n** Sub-head 2"
285 (let ((org-archive-tag "archive"))
286 (org-test-with-backend test
289 "\\* Head1[ \t]+:archive:"
290 (org-export-as 'test nil nil nil
291 '(:with-archived-trees headline
)))))))
292 (org-test-with-temp-text "* Head1 :archive:"
293 (let ((org-archive-tag "archive"))
294 (org-test-with-backend test
297 "\\`\\* Head1[ \t]+:archive:\n\\'"
298 (org-export-as 'test nil nil nil
'(:with-archived-trees t
)))))))
300 (let ((org-drawers '("TEST")))
301 (org-test-with-temp-text ":TEST:\ncontents\n:END:"
302 (org-test-with-backend test
303 (should (equal (org-export-as 'test nil nil nil
'(:with-drawers nil
))
305 (should (equal (org-export-as 'test nil nil nil
'(:with-drawers t
))
306 ":TEST:\ncontents\n:END:\n")))))
307 (let ((org-drawers '("FOO" "BAR")))
308 (org-test-with-temp-text ":FOO:\nkeep\n:END:\n:BAR:\nremove\n:END:"
309 (org-test-with-backend test
311 (equal (org-export-as 'test nil nil nil
'(:with-drawers
("FOO")))
312 ":FOO:\nkeep\n:END:\n")))))
314 (org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
315 (org-test-with-backend test
317 (equal (org-export-as 'test nil nil nil
'(:with-timestamps t
))
318 "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>\n"))
320 (equal (org-export-as 'test nil nil nil
'(:with-timestamps nil
)) ""))
322 (equal (org-export-as 'test nil nil nil
'(:with-timestamps active
))
323 "<2012-04-29 sun. 10:45>\n"))
325 (equal (org-export-as 'test nil nil nil
'(:with-timestamps inactive
))
326 "[2012-04-29 sun. 10:45]\n"))))
328 (let ((org-clock-string "CLOCK:"))
329 (org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
330 (org-test-with-backend test
332 (equal (org-export-as 'test nil nil nil
'(:with-clocks t
))
333 "CLOCK: [2012-04-29 sun. 10:45]\n"))
335 (equal (org-export-as 'test nil nil nil
'(:with-clocks nil
)) "")))))
337 (let ((org-closed-string "CLOSED:"))
338 (org-test-with-temp-text "CLOSED: [2012-04-29 sun. 10:45]"
339 (org-test-with-backend test
341 (equal (org-export-as 'test nil nil nil
'(:with-plannings t
))
342 "CLOSED: [2012-04-29 sun. 10:45]\n"))
344 (equal (org-export-as 'test nil nil nil
'(:with-plannings nil
))
347 (when (featurep 'org-inlinetask
)
350 (let ((org-inlinetask-min-level 15))
351 (org-test-with-temp-text "*************** Task"
352 (org-test-with-backend test
353 (org-export-as 'test nil nil nil
'(:with-inlinetasks nil
)))))
357 (let ((org-inlinetask-min-level 15))
358 (org-test-with-temp-text
359 "*************** Task\nContents\n*************** END"
360 (org-test-with-backend test
361 (org-export-as 'test nil nil nil
'(:with-inlinetasks nil
)))))
363 ;; Statistics cookies.
366 (org-test-with-temp-text "[0/0]"
367 (org-test-with-backend test
369 'test nil nil nil
'(:with-statistics-cookies nil
)))))))
371 (ert-deftest test-org-export
/comment-tree
()
372 "Test if export process ignores commented trees."
373 (let ((org-comment-string "COMMENT"))
374 (org-test-with-temp-text "* COMMENT Head1"
375 (org-test-with-backend test
376 (should (equal (org-export-as 'test
) ""))))))
378 (ert-deftest test-org-export
/export-scope
()
379 "Test all export scopes."
380 (org-test-with-temp-text "
385 (org-test-with-backend test
388 (should (equal (org-export-as 'test
'subtree
) "text\n*** Head3\n"))
390 (goto-char (point-min))
393 (should (equal (org-export-as 'test nil
'visible
) "* Head1\n"))
395 (goto-char (point-min))
397 (transient-mark-mode 1)
398 (push-mark (point) t t
)
399 (goto-char (point-at-eol))
400 (should (equal (org-export-as 'test
) "text\n"))))
401 ;; Subtree with a code block calling another block outside.
404 (org-test-with-temp-text "
406 #+BEGIN_SRC emacs-lisp :noweb yes :exports results
411 #+BEGIN_SRC emacs-lisp
414 (org-test-with-backend test
416 (org-export-as 'test
'subtree
)))))
418 (org-test-with-temp-text "Text"
419 (org-test-with-backend test
421 (cdr (assq 'test org-export-registered-backends
))
423 (cons (cons 'template
(lambda (body info
) (format "BEGIN\n%sEND" body
)))
424 (org-export-backend-translate-table 'test
)))
425 (should (equal (org-export-as 'test nil nil
'body-only
) "Text\n"))
426 (should (equal (org-export-as 'test
) "BEGIN\nText\nEND")))))
428 (ert-deftest test-org-export
/expand-include
()
429 "Test file inclusion in an Org buffer."
430 ;; Error when file isn't specified.
432 (org-test-with-temp-text "#+INCLUDE: dummy.org"
433 (org-export-expand-include-keyword)))
434 ;; Full insertion with recursive inclusion.
435 (org-test-with-temp-text
436 (format "#+INCLUDE: \"%s/examples/include.org\"" org-test-dir
)
437 (org-export-expand-include-keyword)
438 (should (equal (buffer-string)
439 "Small Org file with an include keyword.
441 #+BEGIN_SRC emacs-lisp :exports results\n(+ 2 1)\n#+END_SRC
447 ;; Localized insertion.
448 (org-test-with-temp-text
449 (format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\""
451 (org-export-expand-include-keyword)
452 (should (equal (buffer-string)
453 "Small Org file with an include keyword.\n")))
454 ;; Insertion with constraints on headlines level.
455 (org-test-with-temp-text
457 "* Top heading\n#+INCLUDE: \"%s/examples/include.org\" :lines \"9-\""
459 (org-export-expand-include-keyword)
460 (should (equal (buffer-string) "* Top heading\n** Heading\nbody\n")))
461 ;; Inclusion within an example block.
462 (org-test-with-temp-text
463 (format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\" example"
465 (org-export-expand-include-keyword)
469 "#+BEGIN_EXAMPLE\nSmall Org file with an include keyword.\n#+END_EXAMPLE\n")))
470 ;; Inclusion within a src-block.
471 (org-test-with-temp-text
473 "#+INCLUDE: \"%s/examples/include.org\" :lines \"4-5\" src emacs-lisp"
475 (org-export-expand-include-keyword)
476 (should (equal (buffer-string)
477 "#+BEGIN_SRC emacs-lisp\n(+ 2 1)\n#+END_SRC\n"))))
479 (ert-deftest test-org-export
/expand-macro
()
480 "Test macro expansion in an Org buffer."
481 ;; Standard macro expansion.
483 (equal "#+MACRO: macro1 value\nvalue\n"
484 (org-test-with-temp-text "#+MACRO: macro1 value\n{{{macro1}}}"
485 (org-test-with-backend test
(org-export-as 'test
)))))
486 ;; Expand specific macros.
488 (equal "me 2012-03-29 me@here Title\n"
489 (org-test-with-temp-text
495 {{{author}}} {{{date}}} {{{email}}} {{{title}}}"
496 (let ((output (org-test-with-backend test
(org-export-as 'test
))))
497 (substring output
(string-match ".*\n\\'" output
))))))
498 ;; Expand specific macros when property contained a regular macro
502 (org-test-with-temp-text "
503 #+MACRO: macro1 value
504 #+TITLE: {{{macro1}}}
506 (let ((output (org-test-with-backend test
(org-export-as 'test
))))
507 (substring output
(string-match ".*\n\\'" output
))))))
508 ;; Expand macros with templates in included files.
511 (org-test-with-temp-text
512 (format "#+INCLUDE: \"%s/examples/macro-templates.org\"
513 {{{included-macro}}}" org-test-dir
)
514 (let ((output (org-test-with-backend test
(org-export-as 'test
))))
515 (substring output
(string-match ".*\n\\'" output
)))))))
517 (ert-deftest test-org-export
/user-ignore-list
()
518 "Test if `:ignore-list' accepts user input."
519 (org-test-with-backend test
520 (flet ((skip-note-head
522 ;; Ignore headlines with the word "note" in their title.
526 (when (string-match "\\<note\\>"
527 (org-element-property :raw-value headline
))
528 (org-export-ignore-element headline info
)))
531 ;; Install function in parse tree filters.
532 (let ((org-export-filter-parse-tree-functions '(skip-note-head)))
533 (org-test-with-temp-text "* Head1\n* Head2 (note)\n"
534 (should (equal (org-export-as 'test
) "* Head1\n")))))))
536 (ert-deftest test-org-export
/before-processing-hook
()
537 "Test `org-export-before-processing-hook'."
540 "#+MACRO: mac val\nTest\n"
541 (org-test-with-backend test
542 (org-test-with-temp-text "#+MACRO: mac val\n{{{mac}}} Test"
543 (let ((org-export-before-processing-hook
545 (while (re-search-forward "{{{" nil t
)
546 (let ((object (org-element-context)))
547 (when (eq (org-element-type object
) 'macro
)
549 (org-element-property :begin object
)
550 (org-element-property :end object
)))))))))
551 (org-export-as 'test
)))))))
553 (ert-deftest test-org-export
/before-parsing-hook
()
554 "Test `org-export-before-parsing-hook'."
556 (equal "Body 1\nBody 2\n"
557 (org-test-with-backend test
558 (org-test-with-temp-text "* Headline 1\nBody 1\n* Headline 2\nBody 2"
559 (let ((org-export-before-parsing-hook
563 (delete-region (point) (progn (forward-line) (point)))))))))
564 (org-export-as 'test
)))))))
568 ;;; Affiliated Keywords
570 (ert-deftest test-org-export
/read-attribute
()
571 "Test `org-export-read-attribute' specifications."
575 (org-export-read-attribute
577 (org-test-with-temp-text "#+ATTR_HTML: :a 1 :b 2\nParagraph"
578 (org-element-at-point)))
580 ;; Return nil on empty attribute.
582 (org-export-read-attribute
584 (org-test-with-temp-text "Paragraph" (org-element-at-point)))))
586 (ert-deftest test-org-export
/get-caption
()
587 "Test `org-export-get-caption' specifications."
588 ;; Without optional argument, return long caption
592 (org-test-with-temp-text "#+CAPTION[s]: l\nPara"
593 (org-export-get-caption (org-element-at-point)))))
594 ;; With optional argument, return short caption.
598 (org-test-with-temp-text "#+CAPTION[s]: l\nPara"
599 (org-export-get-caption (org-element-at-point) t
))))
600 ;; Multiple lines are separated by white spaces.
604 (org-test-with-temp-text "#+CAPTION: a\n#+CAPTION: b\nPara"
605 (org-export-get-caption (org-element-at-point))))))
611 (ert-deftest test-org-export
/define-backend
()
612 "Test back-end definition and accessors."
615 (equal '((headline . my-headline-test
))
616 (let (org-export-registered-backends)
617 (org-export-define-backend test
((headline . my-headline-test
)))
618 (org-export-backend-translate-table 'test
))))
621 (equal '((:filter-headline . my-filter
))
622 (let (org-export-registered-backends)
623 (org-export-define-backend test
624 ((headline . my-headline-test
))
625 :filters-alist
((:filter-headline . my-filter
)))
626 (org-export-backend-filters 'test
))))
629 (equal '((:prop value
))
630 (let (org-export-registered-backends)
631 (org-export-define-backend test
632 ((headline . my-headline-test
))
633 :options-alist
((:prop value
)))
634 (org-export-backend-options 'test
))))
637 (equal '(?k
"Test Export" test
)
638 (let (org-export-registered-backends)
639 (org-export-define-backend test
640 ((headline . my-headline-test
))
641 :menu-entry
(?k
"Test Export" test
))
642 (org-export-backend-menu 'test
))))
645 (equal '(("TEST" . org-element-export-block-parser
))
646 (let (org-export-registered-backends org-element-block-name-alist
)
647 (org-export-define-backend test
648 ((headline . my-headline-test
))
649 :export-block
("test"))
650 org-element-block-name-alist
))))
652 (ert-deftest test-org-export
/define-derived-backend
()
653 "Test `org-export-define-derived-backend' specifications."
654 ;; Error when parent back-end is not defined.
656 (let (org-export-registered-backends)
657 (org-export-define-derived-backend test parent
)))
658 ;; Append translation table to parent's.
660 (equal '((:headline . test
) (:headline . parent
))
661 (let (org-export-registered-backends)
662 (org-export-define-backend parent
((:headline . parent
)))
663 (org-export-define-derived-backend test parent
664 :translate-alist
((:headline . test
)))
665 (org-export-backend-translate-table 'test
)))))
667 (ert-deftest test-org-export
/derived-backend-p
()
668 "Test `org-export-derived-backend-p' specifications."
669 ;; Non-nil with direct match.
671 (let (org-export-registered-backends)
672 (org-export-define-backend test
((headline . test
)))
673 (org-export-derived-backend-p 'test
'test
)))
675 (let (org-export-registered-backends)
676 (org-export-define-backend test
((headline . test
)))
677 (org-export-define-derived-backend test2 test
)
678 (org-export-derived-backend-p 'test2
'test2
)))
679 ;; Non-nil with a direct parent.
681 (let (org-export-registered-backends)
682 (org-export-define-backend test
((headline . test
)))
683 (org-export-define-derived-backend test2 test
)
684 (org-export-derived-backend-p 'test2
'test
)))
685 ;; Non-nil with an indirect parent.
687 (let (org-export-registered-backends)
688 (org-export-define-backend test
((headline . test
)))
689 (org-export-define-derived-backend test2 test
)
690 (org-export-define-derived-backend test3 test2
)
691 (org-export-derived-backend-p 'test3
'test
)))
694 (let (org-export-registered-backends)
695 (org-export-define-backend test
((headline . test
)))
696 (org-export-define-backend test2
((headline . test2
)))
697 (org-export-derived-backend-p 'test2
'test
)))
699 (let (org-export-registered-backends)
700 (org-export-define-backend test
((headline . test
)))
701 (org-export-define-backend test2
((headline . test2
)))
702 (org-export-define-derived-backend test3 test2
)
703 (org-export-derived-backend-p 'test3
'test
))))
705 (ert-deftest test-org-export
/with-backend
()
706 "Test `org-export-with-backend' definition."
707 ;; Error when calling an undefined back-end
709 (let (org-export-registered-backends)
710 (org-export-with-backend 'test
"Test")))
711 ;; Error when called back-end doesn't have an appropriate
714 (let (org-export-registered-backends)
715 (org-export-define-backend test
((headline . ignore
)))
716 (org-export-with-backend 'test
"Test")))
717 ;; Otherwise, export using correct transcoder
720 (let (org-export-registered-backends)
721 (org-export-define-backend test
722 ((plain-text .
(lambda (text contents info
) "Failure"))))
723 (org-export-define-backend test2
724 ((plain-text .
(lambda (text contents info
) "Success"))))
725 (org-export-with-backend 'test2
"Test")))))
731 (ert-deftest test-org-export
/export-snippet
()
732 "Test export snippets transcoding."
733 (org-test-with-temp-text "@@test:A@@@@t:B@@"
734 (org-test-with-backend test
736 (cdr (assq 'test org-export-registered-backends
))
738 (cons (cons 'export-snippet
739 (lambda (snippet contents info
)
740 (when (eq (org-export-snippet-backend snippet
) 'test
)
741 (org-element-property :value snippet
))))
742 (org-export-backend-translate-table 'test
)))
743 (let ((org-export-snippet-translation-alist nil
))
744 (should (equal (org-export-as 'test
) "A\n")))
745 (let ((org-export-snippet-translation-alist '(("t" .
"test"))))
746 (should (equal (org-export-as 'test
) "AB\n"))))))
752 (ert-deftest test-org-export
/footnotes
()
753 "Test footnotes specifications."
754 (let ((org-footnote-section nil
)
755 (org-export-with-footnotes t
))
756 ;; 1. Read every type of footnote.
759 '((1 .
"A\n") (2 .
"B") (3 .
"C") (4 .
"D"))
760 (org-test-with-parsed-data
761 "Text[fn:1] [1] [fn:label:C] [fn::D]\n\n[fn:1] A\n\n[1] B"
763 tree
'footnote-reference
765 (let ((def (org-export-get-footnote-definition ref info
)))
766 (cons (org-export-get-footnote-number ref info
)
767 (if (eq (org-element-property :type ref
) 'inline
) (car def
)
768 (car (org-element-contents
769 (car (org-element-contents def
))))))))
771 ;; 2. Test nested footnotes order.
772 (org-test-with-parsed-data
773 "Text[fn:1:A[fn:2]] [fn:3].\n\n[fn:2] B [fn:3] [fn::D].\n\n[fn:3] C."
776 '((1 .
"fn:1") (2 .
"fn:2") (3 .
"fn:3") (4))
778 tree
'footnote-reference
780 (when (org-export-footnote-first-reference-p ref info
)
781 (cons (org-export-get-footnote-number ref info
)
782 (org-element-property :label ref
))))
784 ;; 3. Test nested footnote in invisible definitions.
785 (org-test-with-temp-text "Text[1]\n\n[1] B [2]\n\n[2] C."
787 (narrow-to-region (point) (point-at-eol))
788 (let* ((tree (org-element-parse-buffer))
789 (info (org-combine-plists
791 (org-export-collect-tree-properties
792 tree
(org-export-get-environment)))))
793 ;; Both footnotes should be seen.
795 (= (length (org-export-collect-footnote-definitions tree info
)) 2))))
796 ;; 4. Test footnotes definitions collection.
797 (org-test-with-parsed-data "Text[fn:1:A[fn:2]] [fn:3].
799 \[fn:2] B [fn:3] [fn::D].
802 (should (= (length (org-export-collect-footnote-definitions tree info
))
804 ;; 5. Test export of footnotes defined outside parsing scope.
805 (org-test-with-temp-text "[fn:1] Out of scope
808 (org-test-with-backend test
810 (cdr (assq 'test org-export-registered-backends
))
812 (cons (cons 'footnote-reference
813 (lambda (fn contents info
)
814 (org-element-interpret-data
815 (org-export-get-footnote-definition fn info
))))
816 (org-export-backend-translate-table 'test
)))
818 (should (equal "ParagraphOut of scope\n"
819 (org-export-as 'test
'subtree
)))))))
823 ;;; Headlines and Inlinetasks
825 (ert-deftest test-org-export
/get-relative-level
()
826 "Test `org-export-get-relative-level' specifications."
830 (let ((org-odd-levels-only nil
))
831 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
834 (lambda (h) (org-export-get-relative-level h info
))
839 (let ((org-odd-levels-only nil
))
840 (org-test-with-parsed-data "** Headline 1\n**** Headline 2"
843 (lambda (h) (org-export-get-relative-level h info
))
846 (ert-deftest test-org-export
/low-level-p
()
847 "Test `org-export-low-level-p' specifications."
851 (let ((org-odd-levels-only nil
))
852 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
855 (lambda (h) (if (org-export-low-level-p h info
) 'yes
'no
))
856 (plist-put info
:headline-levels
1)))))))
858 (ert-deftest test-org-export
/get-headline-number
()
859 "Test `org-export-get-headline-number' specifications."
864 (let ((org-odd-levels-only nil
))
865 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
868 (lambda (h) (org-export-get-headline-number h info
))
870 ;; Missing levels are replaced with 0.
874 (let ((org-odd-levels-only nil
))
875 (org-test-with-parsed-data "* Headline 1\n*** Headline 2"
878 (lambda (h) (org-export-get-headline-number h info
))
881 (ert-deftest test-org-export
/numbered-headline-p
()
882 "Test `org-export-numbered-headline-p' specifications."
883 ;; If `:section-numbers' is nil, never number headlines.
885 (org-test-with-parsed-data "* Headline"
888 (lambda (h) (org-export-numbered-headline-p h info
))
889 (plist-put info
:section-numbers nil
))))
890 ;; If `:section-numbers' is a number, only number headlines with
891 ;; a level greater that it.
895 (org-test-with-parsed-data "* Headline 1\n** Headline 2"
898 (lambda (h) (if (org-export-numbered-headline-p h info
) 'yes
'no
))
899 (plist-put info
:section-numbers
1)))))
900 ;; Otherwise, headlines are always numbered.
902 (org-test-with-parsed-data "* Headline"
905 (lambda (h) (org-export-numbered-headline-p h info
))
906 (plist-put info
:section-numbers t
)))))
908 (ert-deftest test-org-export
/number-to-roman
()
909 "Test `org-export-number-to-roman' specifications."
910 ;; If number is negative, return it as a string.
911 (should (equal (org-export-number-to-roman -
1) "-1"))
912 ;; Otherwise, return it as a roman number.
913 (should (equal (org-export-number-to-roman 1449) "MCDXLIX")))
915 (ert-deftest test-org-export
/get-tags
()
916 "Test `org-export-get-tags' specifications."
917 (let ((org-export-exclude-tags '("noexport"))
918 (org-export-select-tags '("export")))
919 ;; Standard test: tags which are not a select tag, an exclude tag,
920 ;; or specified as optional argument shouldn't be ignored.
922 (org-test-with-parsed-data "* Headline :tag:"
923 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
925 ;; Exclude tags are removed.
927 (org-test-with-parsed-data "* Headline :noexport:"
928 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
930 ;; Select tags are removed.
932 (org-test-with-parsed-data "* Headline :export:"
933 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
938 (org-test-with-parsed-data "* Headline :tag:export:"
939 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
941 ;; Tags provided in the optional argument are also ignored.
943 (org-test-with-parsed-data "* Headline :ignore:"
944 (org-export-get-tags (org-element-map tree
'headline
'identity info t
)
946 ;; Allow tag inheritance.
950 (org-test-with-parsed-data "* Headline :tag:\n** Sub-heading"
953 (lambda (hl) (org-export-get-tags hl info nil t
)) info
))))
954 ;; Tag inheritance checks FILETAGS keywords.
958 (org-test-with-parsed-data "#+FILETAGS: :a:b:\n* Headline :tag:"
961 (lambda (hl) (org-export-get-tags hl info nil t
)) info
))))))
963 (ert-deftest test-org-export
/get-node-property
()
964 "Test`org-export-get-node-property' specifications."
968 (org-test-with-parsed-data "* Headline
972 (org-export-get-node-property
973 :prop
(org-element-map tree
'headline
'identity nil t
)))))
977 (org-test-with-parsed-data "* Parent
983 (org-export-get-node-property
984 :prop
(org-element-map tree
'paragraph
'identity nil t
) t
))))
985 ;; Cannot return a value before the first headline.
987 (org-test-with-parsed-data "Paragraph
992 (org-export-get-node-property
993 :prop
(org-element-map tree
'paragraph
'identity nil t
)))))
995 (ert-deftest test-org-export
/get-category
()
996 "Test `org-export-get-category' specifications."
1000 (org-test-with-parsed-data "* Headline
1004 (org-export-get-category
1005 (org-element-map tree
'headline
'identity nil t
) info
))))
1006 ;; Test inheritance from a parent headline.
1008 (equal '("value" "value")
1009 (org-test-with-parsed-data "* Headline1
1016 (lambda (hl) (org-export-get-category hl info
)) info
))))
1017 ;; Test inheritance from #+CATEGORY keyword
1020 (org-test-with-parsed-data "#+CATEGORY: value
1022 (org-export-get-category
1023 (org-element-map tree
'headline
'identity nil t
) info
))))
1024 ;; Test inheritance from file name.
1027 (org-test-with-parsed-data "* Headline"
1028 (let ((info (plist-put info
:input-file
"~/test.org")))
1029 (org-export-get-category
1030 (org-element-map tree
'headline
'identity nil t
) info
)))))
1034 (org-test-with-parsed-data "* Headline"
1035 (org-export-get-category
1036 (org-element-map tree
'headline
'identity nil t
) info
)))))
1038 (ert-deftest test-org-export
/first-sibling-p
()
1039 "Test `org-export-first-sibling-p' specifications."
1044 (org-test-with-parsed-data "* Headline\n** Headline 2\n** Headline 3"
1047 (lambda (h) (if (org-export-first-sibling-p h info
) 'yes
'no
))
1049 ;; Ignore headlines not exported.
1053 (let ((org-export-exclude-tags '("ignore")))
1054 (org-test-with-parsed-data "* Headline :ignore:\n* Headline 2"
1057 (lambda (h) (if (org-export-first-sibling-p h info
) 'yes
'no
))
1060 (ert-deftest test-org-export
/last-sibling-p
()
1061 "Test `org-export-last-sibling-p' specifications."
1066 (org-test-with-parsed-data "* Headline\n** Headline 2\n** Headline 3"
1069 (lambda (h) (if (org-export-last-sibling-p h info
) 'yes
'no
))
1071 ;; Ignore headlines not exported.
1075 (let ((org-export-exclude-tags '("ignore")))
1076 (org-test-with-parsed-data "* Headline\n* Headline 2 :ignore:"
1079 (lambda (h) (if (org-export-last-sibling-p h info
) 'yes
'no
))
1086 (ert-deftest test-org-export
/get-coderef-format
()
1087 "Test `org-export-get-coderef-format' specifications."
1088 ;; A link without description returns "%s"
1089 (should (equal (org-export-get-coderef-format "(ref:line)" nil
)
1091 ;; Return "%s" when path is matched within description.
1092 (should (equal (org-export-get-coderef-format "path" "desc (path)")
1094 ;; Otherwise return description.
1095 (should (equal (org-export-get-coderef-format "path" "desc")
1098 (ert-deftest test-org-export
/inline-image-p
()
1099 "Test `org-export-inline-image-p' specifications."
1101 (org-export-inline-image-p
1102 (org-test-with-temp-text "[[#id]]"
1104 (org-element-parse-buffer) 'link
'identity nil t
))
1105 '(("custom-id" .
"id")))))
1107 (ert-deftest test-org-export
/fuzzy-link
()
1108 "Test fuzzy links specifications."
1109 ;; 1. Links to invisible (keyword) targets should be ignored.
1110 (org-test-with-parsed-data
1111 "Paragraph.\n#+TARGET: Test\n[[Test]]"
1116 (org-export-get-ordinal
1117 (org-export-resolve-fuzzy-link link info
) info
)) info
)))
1118 ;; 2. Link to an headline should return headline's number.
1119 (org-test-with-parsed-data
1120 "Paragraph.\n* Head1\n* Head2\n* Head3\n[[Head2]]"
1122 ;; Note: Headline's number is in fact a list of numbers.
1127 (org-export-get-ordinal
1128 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
1129 ;; 3. Link to a target in an item should return item's number.
1130 (org-test-with-parsed-data
1131 "- Item1\n - Item11\n - <<test>>Item12\n- Item2\n\n\n[[test]]"
1133 ;; Note: Item's number is in fact a list of numbers.
1138 (org-export-get-ordinal
1139 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
1140 ;; 4. Link to a target in a footnote should return footnote's
1142 (org-test-with-parsed-data "
1143 Paragraph[1][2][fn:lbl3:C<<target>>][[test]][[target]]\n[1] A\n\n[2] <<test>>B"
1149 (org-export-get-ordinal
1150 (org-export-resolve-fuzzy-link link info
) info
)) info
))))
1151 ;; 5. Link to a named element should return sequence number of that
1153 (org-test-with-parsed-data
1154 "#+NAME: tbl1\n|1|2|\n#+NAME: tbl2\n|3|4|\n#+NAME: tbl3\n|5|6|\n[[tbl2]]"
1160 (org-export-get-ordinal
1161 (org-export-resolve-fuzzy-link link info
) info
)) info t
))))
1162 ;; 6. Link to a target not within an item, a table, a footnote
1163 ;; reference or definition should return section number.
1164 (org-test-with-parsed-data
1165 "* Head1\n* Head2\nParagraph<<target>>\n* Head3\n[[target]]"
1171 (org-export-get-ordinal
1172 (org-export-resolve-fuzzy-link link info
) info
)) info t
)))))
1174 (ert-deftest test-org-export
/resolve-coderef
()
1175 "Test `org-export-resolve-coderef' specifications."
1176 (let ((org-coderef-label-format "(ref:%s)"))
1177 ;; 1. A link to a "-n -k -r" block returns line number.
1178 (org-test-with-parsed-data
1179 "#+BEGIN_EXAMPLE -n -k -r\nText (ref:coderef)\n#+END_EXAMPLE"
1180 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
1181 (org-test-with-parsed-data
1182 "#+BEGIN_SRC emacs-lisp -n -k -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
1183 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
1184 ;; 2. A link to a "-n -r" block returns line number.
1185 (org-test-with-parsed-data
1186 "#+BEGIN_EXAMPLE -n -r\nText (ref:coderef)\n#+END_EXAMPLE"
1187 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
1188 (org-test-with-parsed-data
1189 "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
1190 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
1191 ;; 3. A link to a "-n" block returns coderef.
1192 (org-test-with-parsed-data
1193 "#+BEGIN_SRC emacs-lisp -n\n(+ 1 1) (ref:coderef)\n#+END_SRC"
1194 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
1195 (org-test-with-parsed-data
1196 "#+BEGIN_EXAMPLE -n\nText (ref:coderef)\n#+END_EXAMPLE"
1197 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
1198 ;; 4. A link to a "-r" block returns line number.
1199 (org-test-with-parsed-data
1200 "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
1201 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
1202 (org-test-with-parsed-data
1203 "#+BEGIN_EXAMPLE -r\nText (ref:coderef)\n#+END_EXAMPLE"
1204 (should (= (org-export-resolve-coderef "coderef" info
) 1)))
1205 ;; 5. A link to a block without a switch returns coderef.
1206 (org-test-with-parsed-data
1207 "#+BEGIN_SRC emacs-lisp\n(+ 1 1) (ref:coderef)\n#+END_SRC"
1208 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
1209 (org-test-with-parsed-data
1210 "#+BEGIN_EXAMPLE\nText (ref:coderef)\n#+END_EXAMPLE"
1211 (should (equal (org-export-resolve-coderef "coderef" info
) "coderef")))
1212 ;; 6. Correctly handle continued line numbers. A "+n" switch
1213 ;; should resume numbering from previous block with numbered
1214 ;; lines, ignoring blocks not numbering lines in the process.
1215 ;; A "-n" switch resets count.
1216 (org-test-with-parsed-data "
1221 #+BEGIN_SRC emacs-lisp
1225 #+BEGIN_SRC emacs-lisp +n -r
1226 \(+ 1 1) (ref:addition)
1229 #+BEGIN_EXAMPLE -n -r
1230 Another text. (ref:text)
1232 (should (= (org-export-resolve-coderef "addition" info
) 2))
1233 (should (= (org-export-resolve-coderef "text" info
) 1)))
1234 ;; 7. Recognize coderef with user-specified syntax.
1235 (org-test-with-parsed-data
1236 "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText. [ref:text]\n#+END_EXAMPLE"
1237 (should (equal (org-export-resolve-coderef "text" info
) "text")))))
1239 (ert-deftest test-org-export
/resolve-fuzzy-link
()
1240 "Test `org-export-resolve-fuzzy-link' specifications."
1241 ;; 1. Match target objects.
1242 (org-test-with-parsed-data "<<target>> [[target]]"
1244 (org-export-resolve-fuzzy-link
1245 (org-element-map tree
'link
'identity info t
) info
)))
1246 ;; 2. Match target elements.
1247 (org-test-with-parsed-data "#+TARGET: target\n[[target]]"
1249 (org-export-resolve-fuzzy-link
1250 (org-element-map tree
'link
'identity info t
) info
)))
1251 ;; 3. Match named elements.
1252 (org-test-with-parsed-data "#+NAME: target\nParagraph\n\n[[target]]"
1254 (org-export-resolve-fuzzy-link
1255 (org-element-map tree
'link
'identity info t
) info
)))
1256 ;; 4. Match exact headline's name.
1257 (org-test-with-parsed-data "* My headline\n[[My headline]]"
1259 (org-export-resolve-fuzzy-link
1260 (org-element-map tree
'link
'identity info t
) info
)))
1261 ;; 5. Targets objects have priority over named elements and headline
1263 (org-test-with-parsed-data
1264 "* target\n#+NAME: target\n<<target>>\n\n[[target]]"
1268 (org-export-resolve-fuzzy-link
1269 (org-element-map tree
'link
'identity info t
) info
)))))
1270 ;; 6. Named elements have priority over headline titles.
1271 (org-test-with-parsed-data
1272 "* target\n#+NAME: target\nParagraph\n\n[[target]]"
1276 (org-export-resolve-fuzzy-link
1277 (org-element-map tree
'link
'identity info t
) info
)))))
1278 ;; 7. If link's path starts with a "*", only match headline titles,
1280 (org-test-with-parsed-data
1281 "* target\n#+NAME: target\n<<target>>\n\n[[*target]]"
1285 (org-export-resolve-fuzzy-link
1286 (org-element-map tree
'link
'identity info t
) info
)))))
1287 ;; 8. Return nil if no match.
1288 (org-test-with-parsed-data "[[target]]"
1290 (org-export-resolve-fuzzy-link
1291 (org-element-map tree
'link
'identity info t
) info
))))
1293 (ert-deftest test-org-export
/resolve-id-link
()
1294 "Test `org-export-resolve-id-link' specifications."
1295 ;; 1. Regular test for custom-id link.
1296 (org-test-with-parsed-data "* Headline1
1303 (org-export-resolve-id-link
1304 (org-element-map tree
'link
'identity info t
) info
)))
1305 ;; 2. Failing test for custom-id link.
1306 (org-test-with-parsed-data "* Headline1
1313 (org-export-resolve-id-link
1314 (org-element-map tree
'link
'identity info t
) info
)))
1315 ;; 3. Test for internal id target.
1316 (org-test-with-parsed-data "* Headline1
1323 (org-export-resolve-id-link
1324 (org-element-map tree
'link
'identity info t
) info
)))
1325 ;; 4. Test for external id target.
1326 (org-test-with-parsed-data "[[id:aaaa]]"
1328 (org-export-resolve-id-link
1329 (org-element-map tree
'link
'identity info t
)
1330 (org-combine-plists info
'(:id-alist
(("aaaa" .
"external-file"))))))))
1332 (ert-deftest test-org-export
/resolve-radio-link
()
1333 "Test `org-export-resolve-radio-link' specifications."
1335 (org-test-with-temp-text "<<<radio>>> radio"
1336 (org-update-radio-target-regexp)
1338 (let* ((tree (org-element-parse-buffer))
1339 (info `(:parse-tree
,tree
)))
1340 (org-export-resolve-radio-link
1341 (org-element-map tree
'link
'identity info t
)
1343 ;; Radio target with objects.
1344 (org-test-with-temp-text "<<<radio \\alpha>>> radio \\alpha"
1345 (org-update-radio-target-regexp)
1347 (let* ((tree (org-element-parse-buffer))
1348 (info `(:parse-tree
,tree
)))
1349 (org-export-resolve-radio-link
1350 (org-element-map tree
'link
'identity info t
)
1355 ;;; Src-block and example-block
1357 (ert-deftest test-org-export
/unravel-code
()
1358 "Test `org-export-unravel-code' function."
1359 (let ((org-coderef-label-format "(ref:%s)"))
1360 ;; 1. Code without reference.
1361 (org-test-with-temp-text "#+BEGIN_EXAMPLE\n(+ 1 1)\n#+END_EXAMPLE"
1362 (should (equal (org-export-unravel-code (org-element-at-point))
1364 ;; 2. Code with reference.
1365 (org-test-with-temp-text
1366 "#+BEGIN_EXAMPLE\n(+ 1 1) (ref:test)\n#+END_EXAMPLE"
1367 (should (equal (org-export-unravel-code (org-element-at-point))
1368 '("(+ 1 1)\n" (1 .
"test")))))
1369 ;; 3. Code with user-defined reference.
1370 (org-test-with-temp-text
1371 "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\n(+ 1 1) [ref:test]\n#+END_EXAMPLE"
1372 (should (equal (org-export-unravel-code (org-element-at-point))
1373 '("(+ 1 1)\n" (1 .
"test")))))
1374 ;; 4. Code references keys are relative to the current block.
1375 (org-test-with-temp-text "
1384 (should (equal (org-export-unravel-code (org-element-at-point))
1385 '("(+ 2 2)\n(+ 3 3)\n" (2 .
"one")))))))
1391 (ert-deftest test-org-export
/activate-smart-quotes
()
1392 "Test `org-export-activate-smart-quotes' specifications."
1393 ;; Opening double quotes: standard test.
1396 '("some “paragraph")
1397 (let ((org-export-default-language "en"))
1398 (org-test-with-parsed-data "some \"paragraph"
1401 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1403 ;; Opening quotes: at the beginning of a paragraph.
1407 (let ((org-export-default-language "en"))
1408 (org-test-with-parsed-data "\"begin"
1411 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1413 ;; Opening quotes: after an object.
1417 (let ((org-export-default-language "en"))
1418 (org-test-with-parsed-data "=verb= \"begin"
1421 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1423 ;; Closing quotes: standard test.
1426 '("some” paragraph")
1427 (let ((org-export-default-language "en"))
1428 (org-test-with-parsed-data "some\" paragraph"
1431 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1433 ;; Closing quotes: at the end of a paragraph.
1437 (let ((org-export-default-language "en"))
1438 (org-test-with-parsed-data "end\""
1441 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1443 ;; Apostrophe: standard test.
1446 '("It shouldn’t fail")
1447 (let ((org-export-default-language "en"))
1448 (org-test-with-parsed-data "It shouldn't fail"
1451 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1453 ;; Apostrophe: before an object.
1457 (let ((org-export-default-language "en"))
1458 (org-test-with-parsed-data "a'=b="
1461 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1463 ;; Apostrophe: after an object.
1467 (let ((org-export-default-language "en"))
1468 (org-test-with-parsed-data "=code='s"
1471 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1473 ;; Special case: isolated quotes.
1475 (equal '("“" "”")
1476 (let ((org-export-default-language "en"))
1477 (org-test-with-parsed-data "\"$x$\""
1480 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1482 ;; Smart quotes in secondary strings.
1484 (equal '("“" "”")
1485 (let ((org-export-default-language "en"))
1486 (org-test-with-parsed-data "* \"$x$\""
1489 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1491 ;; Smart quotes in document keywords.
1493 (equal '("“" "”")
1494 (let ((org-export-default-language "en"))
1495 (org-test-with-parsed-data "#+TITLE: \"$x$\""
1497 (plist-get info
:title
) 'plain-text
1498 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1500 ;; Smart quotes in parsed affiliated keywords.
1502 (equal '("“" "”" "Paragraph")
1503 (let ((org-export-default-language "en"))
1504 (org-test-with-parsed-data "#+CAPTION: \"$x$\"\nParagraph"
1507 (lambda (s) (org-export-activate-smart-quotes s
:html info
))
1508 info nil nil t
))))))
1514 (ert-deftest test-org-export
/special-column
()
1515 "Test if the table's special column is properly recognized."
1516 ;; 1. First column is special if it contains only a special marking
1517 ;; characters or empty cells.
1518 (org-test-with-temp-text "
1522 (org-export-table-has-special-column-p
1524 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1525 ;; 2. If the column contains anything else, it isn't special.
1526 (org-test-with-temp-text "
1530 (org-export-table-has-special-column-p
1532 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1533 ;; 3. Special marking characters are "#", "^", "*", "_", "/", "$"
1535 (org-test-with-temp-text "
1544 (org-export-table-has-special-column-p
1546 (org-element-parse-buffer) 'table
'identity nil
'first-match
))))
1547 ;; 4. A first column with only empty cells isn't considered as
1549 (org-test-with-temp-text "
1553 (org-export-table-has-special-column-p
1555 (org-element-parse-buffer) 'table
'identity nil
'first-match
)))))
1557 (ert-deftest test-org-export
/table-row-is-special-p
()
1558 "Test `org-export-table-row-is-special-p' specifications."
1559 ;; 1. A row is special if it has a special marking character in the
1561 (org-test-with-parsed-data "| ! | 1 |"
1563 (org-export-table-row-is-special-p
1564 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1565 ;; 2. A row is special when its first field is "/"
1566 (org-test-with-parsed-data "
1570 (org-export-table-row-is-special-p
1571 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1572 ;; 3. A row only containing alignment cookies is also considered as
1574 (org-test-with-parsed-data "| <5> | | <l> | <l22> |"
1576 (org-export-table-row-is-special-p
1577 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1578 ;; 4. Everything else isn't considered as special.
1579 (org-test-with-parsed-data "| \alpha | | c |"
1581 (org-export-table-row-is-special-p
1582 (org-element-map tree
'table-row
'identity nil
'first-match
) info
)))
1583 ;; 5. Table's rules are never considered as special rows.
1584 (org-test-with-parsed-data "|---+---|"
1586 (org-export-table-row-is-special-p
1587 (org-element-map tree
'table-row
'identity nil
'first-match
) info
))))
1589 (ert-deftest test-org-export
/has-header-p
()
1590 "Test `org-export-table-has-header-p' specifications."
1591 ;; 1. With an header.
1592 (org-test-with-parsed-data "
1597 (org-export-table-has-header-p
1598 (org-element-map tree
'table
'identity info
'first-match
)
1600 ;; 2. Without an header.
1601 (org-test-with-parsed-data "
1605 (org-export-table-has-header-p
1606 (org-element-map tree
'table
'identity info
'first-match
)
1608 ;; 3. Don't get fooled with starting and ending rules.
1609 (org-test-with-parsed-data "
1615 (org-export-table-has-header-p
1616 (org-element-map tree
'table
'identity info
'first-match
)
1619 (ert-deftest test-org-export
/table-row-group
()
1620 "Test `org-export-table-row-group' specifications."
1621 ;; 1. A rule creates a new group.
1622 (org-test-with-parsed-data "
1629 (mapcar (lambda (row) (org-export-table-row-group row info
))
1630 (org-element-map tree
'table-row
'identity
)))))
1631 ;; 2. Special rows are ignored in count.
1632 (org-test-with-parsed-data "
1639 (mapcar (lambda (row) (org-export-table-row-group row info
))
1640 (org-element-map tree
'table-row
'identity
)))))
1641 ;; 3. Double rules also are ignored in count.
1642 (org-test-with-parsed-data "
1650 (mapcar (lambda (row) (org-export-table-row-group row info
))
1651 (org-element-map tree
'table-row
'identity
))))))
1653 (ert-deftest test-org-export
/table-cell-width
()
1654 "Test `org-export-table-cell-width' specifications."
1655 ;; 1. Width is primarily determined by width cookies. If no cookie
1656 ;; is found, cell's width is nil.
1657 (org-test-with-parsed-data "
1658 | / | <l> | <6> | <l7> |
1663 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1664 (org-element-map tree
'table-cell
'identity info
)))))
1665 ;; 2. The last width cookie has precedence.
1666 (org-test-with-parsed-data "
1673 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1674 (org-element-map tree
'table-cell
'identity info
)))))
1675 ;; 3. Valid width cookies must have a specific row.
1676 (org-test-with-parsed-data "| <6> | cell |"
1680 (mapcar (lambda (cell) (org-export-table-cell-width cell info
))
1681 (org-element-map tree
'table-cell
'identity
))))))
1683 (ert-deftest test-org-export
/table-cell-alignment
()
1684 "Test `org-export-table-cell-alignment' specifications."
1685 (let ((org-table-number-fraction 0.5)
1686 (org-table-number-regexp "^[0-9]+$"))
1687 ;; 1. Alignment is primarily determined by alignment cookies.
1688 (org-test-with-temp-text "| <l> | <c> | <r> |"
1689 (let* ((tree (org-element-parse-buffer))
1690 (info `(:parse-tree
,tree
)))
1693 '(left center right
)
1694 (mapcar (lambda (cell) (org-export-table-cell-alignment cell info
))
1695 (org-element-map tree
'table-cell
'identity
))))))
1696 ;; 2. The last alignment cookie has precedence.
1697 (org-test-with-parsed-data "
1703 '(right right right
)
1704 (mapcar (lambda (cell) (org-export-table-cell-alignment cell info
))
1705 (org-element-map tree
'table-cell
'identity
)))))
1706 ;; 3. If there's no cookie, cell's contents determine alignment.
1707 ;; A column mostly made of cells containing numbers will align
1708 ;; its cells to the right.
1709 (org-test-with-parsed-data "
1715 '(right right right
)
1716 (mapcar (lambda (cell)
1717 (org-export-table-cell-alignment cell info
))
1718 (org-element-map tree
'table-cell
'identity
)))))
1719 ;; 4. Otherwise, they will be aligned to the left.
1720 (org-test-with-parsed-data "
1727 (mapcar (lambda (cell)
1728 (org-export-table-cell-alignment cell info
))
1729 (org-element-map tree
'table-cell
'identity
)))))))
1731 (ert-deftest test-org-export
/table-cell-borders
()
1732 "Test `org-export-table-cell-borders' specifications."
1733 ;; 1. Recognize various column groups indicators.
1734 (org-test-with-parsed-data "| / | < | > | <> |"
1737 '((right bottom top
) (left bottom top
) (right bottom top
)
1738 (right left bottom top
))
1739 (mapcar (lambda (cell)
1740 (org-export-table-cell-borders cell info
))
1741 (org-element-map tree
'table-cell
'identity
)))))
1742 ;; 2. Accept shortcuts to define column groups.
1743 (org-test-with-parsed-data "| / | < | < |"
1746 '((right bottom top
) (right left bottom top
) (left bottom top
))
1747 (mapcar (lambda (cell)
1748 (org-export-table-cell-borders cell info
))
1749 (org-element-map tree
'table-cell
'identity
)))))
1750 ;; 3. A valid column groups row must start with a "/".
1751 (org-test-with-parsed-data "
1755 (equal '((top) (top) (bottom) (bottom))
1756 (mapcar (lambda (cell)
1757 (org-export-table-cell-borders cell info
))
1758 (org-element-map tree
'table-cell
'identity
)))))
1759 ;; 4. Take table rules into consideration.
1760 (org-test-with-parsed-data "
1765 (equal '((below top
) (bottom above
))
1766 (mapcar (lambda (cell)
1767 (org-export-table-cell-borders cell info
))
1768 (org-element-map tree
'table-cell
'identity
)))))
1769 ;; 5. Top and (resp. bottom) rules induce both `top' and `above'
1770 ;; (resp. `bottom' and `below') borders. Any special row is
1772 (org-test-with-parsed-data "
1778 (equal '((bottom below top above
))
1780 (mapcar (lambda (cell)
1781 (org-export-table-cell-borders cell info
))
1782 (org-element-map tree
'table-cell
'identity
)))))))
1784 (ert-deftest test-org-export
/table-dimensions
()
1785 "Test `org-export-table-dimensions' specifications."
1786 ;; 1. Standard test.
1787 (org-test-with-parsed-data "
1792 (org-export-table-dimensions
1793 (org-element-map tree
'table
'identity info
'first-match
) info
))))
1794 ;; 2. Ignore horizontal rules and special columns.
1795 (org-test-with-parsed-data "
1802 (org-export-table-dimensions
1803 (org-element-map tree
'table
'identity info
'first-match
) info
)))))
1805 (ert-deftest test-org-export
/table-cell-address
()
1806 "Test `org-export-table-cell-address' specifications."
1807 ;; 1. Standard test: index is 0-based.
1808 (org-test-with-parsed-data "| a | b |"
1810 (equal '((0 .
0) (0 .
1))
1813 (lambda (cell) (org-export-table-cell-address cell info
))
1815 ;; 2. Special column isn't counted, nor are special rows.
1816 (org-test-with-parsed-data "
1821 (org-export-table-cell-address
1822 (car (last (org-element-map tree
'table-cell
'identity info
)))
1824 ;; 3. Tables rules do not count either.
1825 (org-test-with-parsed-data "
1833 (org-export-table-cell-address
1834 (car (last (org-element-map tree
'table-cell
'identity info
)))
1836 ;; 4. Return nil for special cells.
1837 (org-test-with-parsed-data "| / | a |"
1839 (org-export-table-cell-address
1840 (org-element-map tree
'table-cell
'identity nil
'first-match
)
1843 (ert-deftest test-org-export
/get-table-cell-at
()
1844 "Test `org-export-get-table-cell-at' specifications."
1845 ;; 1. Address ignores special columns, special rows and rules.
1846 (org-test-with-parsed-data "
1853 (org-element-contents
1854 (org-export-get-table-cell-at
1856 (org-element-map tree
'table
'identity info
'first-match
)
1858 ;; 2. Return value for a non-existent address is nil.
1859 (org-test-with-parsed-data "| a |"
1861 (org-export-get-table-cell-at
1863 (org-element-map tree
'table
'identity info
'first-match
)
1865 (org-test-with-parsed-data "| / |"
1867 (org-export-get-table-cell-at
1869 (org-element-map tree
'table
'identity info
'first-match
)
1872 (ert-deftest test-org-export
/table-cell-starts-colgroup-p
()
1873 "Test `org-export-table-cell-starts-colgroup-p' specifications."
1874 ;; 1. A cell at a beginning of a row always starts a column group.
1875 (org-test-with-parsed-data "| a |"
1877 (org-export-table-cell-starts-colgroup-p
1878 (org-element-map tree
'table-cell
'identity info
'first-match
)
1880 ;; 2. Special column should be ignored when determining the
1881 ;; beginning of the row.
1882 (org-test-with-parsed-data "
1886 (org-export-table-cell-starts-colgroup-p
1887 (org-element-map tree
'table-cell
'identity info
'first-match
)
1889 ;; 2. Explicit column groups.
1890 (org-test-with-parsed-data "
1899 (if (org-export-table-cell-starts-colgroup-p cell info
) 'yes
'no
))
1902 (ert-deftest test-org-export
/table-cell-ends-colgroup-p
()
1903 "Test `org-export-table-cell-ends-colgroup-p' specifications."
1904 ;; 1. A cell at the end of a row always ends a column group.
1905 (org-test-with-parsed-data "| a |"
1907 (org-export-table-cell-ends-colgroup-p
1908 (org-element-map tree
'table-cell
'identity info
'first-match
)
1910 ;; 2. Special column should be ignored when determining the
1911 ;; beginning of the row.
1912 (org-test-with-parsed-data "
1916 (org-export-table-cell-ends-colgroup-p
1917 (org-element-map tree
'table-cell
'identity info
'first-match
)
1919 ;; 3. Explicit column groups.
1920 (org-test-with-parsed-data "
1929 (if (org-export-table-cell-ends-colgroup-p cell info
) 'yes
'no
))
1932 (ert-deftest test-org-export
/table-row-starts-rowgroup-p
()
1933 "Test `org-export-table-row-starts-rowgroup-p' specifications."
1934 ;; 1. A row at the beginning of a table always starts a row group.
1935 ;; So does a row following a table rule.
1936 (org-test-with-parsed-data "
1946 (if (org-export-table-row-starts-rowgroup-p row info
) 'yes
'no
))
1948 ;; 2. Special rows should be ignored when determining the beginning
1950 (org-test-with-parsed-data "
1962 (if (org-export-table-row-starts-rowgroup-p row info
) 'yes
'no
))
1965 (ert-deftest test-org-export
/table-row-ends-rowgroup-p
()
1966 "Test `org-export-table-row-ends-rowgroup-p' specifications."
1967 ;; 1. A row at the end of a table always ends a row group. So does
1968 ;; a row preceding a table rule.
1969 (org-test-with-parsed-data "
1979 (if (org-export-table-row-ends-rowgroup-p row info
) 'yes
'no
))
1981 ;; 2. Special rows should be ignored when determining the beginning
1983 (org-test-with-parsed-data "
1995 (if (org-export-table-row-ends-rowgroup-p row info
) 'yes
'no
))
1998 (ert-deftest test-org-export
/table-row-starts-header-p
()
1999 "Test `org-export-table-row-starts-header-p' specifications."
2000 ;; 1. Only the row starting the first row group starts the table
2002 (org-test-with-parsed-data "
2013 (if (org-export-table-row-starts-header-p row info
) 'yes
'no
))
2015 ;; 2. A row cannot start an header if there's no header in the
2017 (org-test-with-parsed-data "
2021 (org-export-table-row-starts-header-p
2022 (org-element-map tree
'table-row
'identity info
'first-match
)
2025 (ert-deftest test-org-export
/table-row-ends-header-p
()
2026 "Test `org-export-table-row-ends-header-p' specifications."
2027 ;; 1. Only the row starting the first row group starts the table
2029 (org-test-with-parsed-data "
2040 (if (org-export-table-row-ends-header-p row info
) 'yes
'no
))
2042 ;; 2. A row cannot start an header if there's no header in the
2044 (org-test-with-parsed-data "
2048 (org-export-table-row-ends-header-p
2049 (org-element-map tree
'table-row
'identity info
'first-match
)
2056 (ert-deftest test-org-export
/timestamp-has-time-p
()
2057 "Test `org-export-timestamp-has-time-p' specifications."
2060 (org-test-with-temp-text "<2012-03-29 Thu 16:40>"
2061 (org-export-timestamp-has-time-p (org-element-context))))
2064 (org-test-with-temp-text "<2012-03-29 Thu>"
2065 (org-export-timestamp-has-time-p (org-element-context)))))
2067 (ert-deftest test-org-export
/format-timestamp
()
2068 "Test `org-export-format-timestamp' specifications."
2073 (org-test-with-temp-text "<2012-03-29 Thu 16:40>"
2074 (org-export-format-timestamp (org-element-context) "%Y-%m-%d %R"))))
2079 (org-test-with-temp-text "[2011-07-14 Thu]--[2012-03-29 Thu]"
2080 (org-export-format-timestamp (org-element-context) "%Y-%m-%d" t
)))))
2082 (ert-deftest test-org-export
/split-timestamp-range
()
2083 "Test `org-export-split-timestamp-range' specifications."
2084 ;; Extract range start (active).
2087 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
2088 (let ((ts (org-export-split-timestamp-range (org-element-context))))
2089 (mapcar (lambda (p) (org-element-property p ts
))
2090 '(:year-end
:month-end
:day-end
))))))
2091 ;; Extract range start (inactive)
2094 (org-test-with-temp-text "[2012-03-29 Thu]--[2012-03-30 Fri]"
2095 (let ((ts (org-export-split-timestamp-range (org-element-context))))
2096 (mapcar (lambda (p) (org-element-property p ts
))
2097 '(:year-end
:month-end
:day-end
))))))
2098 ;; Extract range end (active).
2101 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
2102 (let ((ts (org-export-split-timestamp-range
2103 (org-element-context) t
)))
2104 (mapcar (lambda (p) (org-element-property p ts
))
2105 '(:year-end
:month-end
:day-end
))))))
2106 ;; Extract range end (inactive)
2109 (org-test-with-temp-text "[2012-03-29 Thu]--[2012-03-30 Fri]"
2110 (let ((ts (org-export-split-timestamp-range
2111 (org-element-context) t
)))
2112 (mapcar (lambda (p) (org-element-property p ts
))
2113 '(:year-end
:month-end
:day-end
))))))
2114 ;; Return the timestamp if not a range.
2116 (org-test-with-temp-text "[2012-03-29 Thu]"
2117 (let* ((ts-orig (org-element-context))
2118 (ts-copy (org-export-split-timestamp-range ts-orig
)))
2119 (eq ts-orig ts-copy
))))
2121 (org-test-with-temp-text "<%%(org-float t 4 2)>"
2122 (let* ((ts-orig (org-element-context))
2123 (ts-copy (org-export-split-timestamp-range ts-orig
)))
2124 (eq ts-orig ts-copy
))))
2125 ;; Check that parent is the same when a range was split.
2127 (org-test-with-temp-text "[2012-03-29 Thu]--[2012-03-30 Fri]"
2128 (let* ((ts-orig (org-element-context))
2129 (ts-copy (org-export-split-timestamp-range ts-orig
)))
2130 (eq (org-element-property :parent ts-orig
)
2131 (org-element-property :parent ts-copy
))))))
2133 (ert-deftest test-org-export
/translate-timestamp
()
2134 "Test `org-export-translate-timestamp' specifications."
2135 ;; Translate whole date range.
2138 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
2139 (let ((org-display-custom-times t
)
2140 (org-time-stamp-custom-formats '("<%d>" .
"<%d>")))
2141 (org-export-translate-timestamp (org-element-context))))))
2142 ;; Translate date range start.
2145 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
2146 (let ((org-display-custom-times t
)
2147 (org-time-stamp-custom-formats '("<%d>" .
"<%d>")))
2148 (org-export-translate-timestamp (org-element-context) 'start
)))))
2149 ;; Translate date range end.
2152 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
2153 (let ((org-display-custom-times t
)
2154 (org-time-stamp-custom-formats '("<%d>" .
"<%d>")))
2155 (org-export-translate-timestamp (org-element-context) 'end
)))))
2156 ;; Translate time range.
2159 (org-test-with-temp-text "<2012-03-29 Thu 8:30-16:40>"
2160 (let ((org-display-custom-times t
)
2161 (org-time-stamp-custom-formats '("<%d>" .
"<%H>")))
2162 (org-export-translate-timestamp (org-element-context))))))
2163 ;; Translate non-range timestamp.
2166 (org-test-with-temp-text "<2012-03-29 Thu>"
2167 (let ((org-display-custom-times t
)
2168 (org-time-stamp-custom-formats '("<%d>" .
"<%d>")))
2169 (org-export-translate-timestamp (org-element-context))))))
2170 ;; Do not change `diary' timestamps.
2172 (equal "<%%(org-float t 4 2)>"
2173 (org-test-with-temp-text "<%%(org-float t 4 2)>"
2174 (let ((org-display-custom-times t
)
2175 (org-time-stamp-custom-formats '("<%d>" .
"<%d>")))
2176 (org-export-translate-timestamp (org-element-context)))))))
2182 (ert-deftest test-org-export
/get-next-element
()
2183 "Test `org-export-get-next-element' specifications."
2187 (org-test-with-parsed-data "* Headline\n*a* b"
2188 (org-export-get-next-element
2189 (org-element-map tree
'bold
'identity info t
) info
))))
2190 ;; Return nil when no previous element.
2192 (org-test-with-parsed-data "* Headline\na *b*"
2193 (org-export-get-next-element
2194 (org-element-map tree
'bold
'identity info t
) info
)))
2195 ;; Non-exportable elements are ignored.
2197 (let ((org-export-with-timestamps nil
))
2198 (org-test-with-parsed-data "\alpha <2012-03-29 Thu>"
2199 (org-export-get-next-element
2200 (org-element-map tree
'entity
'identity info t
) info
))))
2201 ;; Find next element in secondary strings.
2204 (org-test-with-parsed-data "* a =verb="
2206 (org-export-get-next-element
2207 (org-element-map tree
'plain-text
'identity info t
) info
)))))
2208 ;; Find next element in document keywords.
2211 (org-test-with-parsed-data "#+TITLE: a =verb="
2213 (org-export-get-next-element
2215 (plist-get info
:title
) 'plain-text
'identity info t
) info
)))))
2216 ;; Find next element in parsed affiliated keywords.
2219 (org-test-with-parsed-data "#+CAPTION: a =verb=\nParagraph"
2221 (org-export-get-next-element
2222 (org-element-map tree
'plain-text
'identity info t nil t
) info
)))))
2223 ;; With optional argument N, return a list containing all the
2224 ;; following elements.
2227 '(bold code underline
)
2228 (org-test-with-parsed-data "_a_ /b/ *c* ~d~ _e_"
2230 (org-export-get-next-element
2231 (org-element-map tree
'italic
'identity info t
) info t
)))))
2232 ;; When N is a positive integer, return a list containing up to
2233 ;; N following elements.
2237 (org-test-with-parsed-data "_a_ /b/ *c* ~d~ _e_"
2239 (org-export-get-next-element
2240 (org-element-map tree
'italic
'identity info t
) info
2))))))
2242 (ert-deftest test-org-export
/get-previous-element
()
2243 "Test `org-export-get-previous-element' specifications."
2247 (org-test-with-parsed-data "* Headline\na *b*"
2248 (org-export-get-previous-element
2249 (org-element-map tree
'bold
'identity info t
) info
))))
2250 ;; Return nil when no previous element.
2252 (org-test-with-parsed-data "* Headline\n*a* b"
2253 (org-export-get-previous-element
2254 (org-element-map tree
'bold
'identity info t
) info
)))
2255 ;; Non-exportable elements are ignored.
2257 (let ((org-export-with-timestamps nil
))
2258 (org-test-with-parsed-data "<2012-03-29 Thu> \alpha"
2259 (org-export-get-previous-element
2260 (org-element-map tree
'entity
'identity info t
) info
))))
2261 ;; Find previous element in secondary strings.
2264 (org-test-with-parsed-data "* =verb= a"
2266 (org-export-get-previous-element
2267 (org-element-map tree
'plain-text
'identity info t
) info
)))))
2268 ;; Find previous element in document keywords.
2271 (org-test-with-parsed-data "#+TITLE: =verb= a"
2273 (org-export-get-previous-element
2275 (plist-get info
:title
) 'plain-text
'identity info t
) info
)))))
2276 ;; Find previous element in parsed affiliated keywords.
2279 (org-test-with-parsed-data "#+CAPTION: =verb= a\nParagraph"
2281 (org-export-get-previous-element
2282 (org-element-map tree
'plain-text
'identity info t nil t
) info
)))))
2283 ;; With optional argument N, return a list containing up to
2284 ;; N previous elements.
2286 (equal '(bold italic underline
)
2287 (org-test-with-parsed-data "_a_ /b/ *c* ~d~"
2289 (org-export-get-previous-element
2290 (org-element-map tree
'code
'identity info t
) info t
)))))
2291 ;; When N is a positive integer, return a list containing up to
2292 ;; N previous elements.
2294 (equal '(bold italic
)
2295 (org-test-with-parsed-data "_a_ /b/ *c* ~d~"
2297 (org-export-get-previous-element
2298 (org-element-map tree
'code
'identity info t
) info
2))))))
2301 (provide 'test-org-export
)
2302 ;;; test-org-export.el end here