test-org-export.el 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657
  1. ;;; test-org-export.el --- Tests for org-export.el
  2. ;; Copyright (C) 2012 Nicolas Goaziou
  3. ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
  4. ;; Released under the GNU General Public License version 3
  5. ;; see: http://www.gnu.org/licenses/gpl-3.0.html
  6. ;;;; Comments
  7. ;;; Code:
  8. (unless (featurep 'org-export)
  9. (signal 'missing-test-dependency "org-export"))
  10. (defmacro org-test-with-backend (backend &rest body)
  11. "Execute body with an export back-end defined.
  12. BACKEND is the name of the back-end. BODY is the body to
  13. execute. The defined back-end simply returns parsed data as Org
  14. syntax."
  15. (declare (debug (form body)) (indent 1))
  16. `(let ((,(intern (format "org-%s-translate-alist" backend))
  17. ',(let (transcode-table)
  18. (dolist (type (append org-element-all-elements
  19. org-element-all-objects)
  20. transcode-table)
  21. (push
  22. (cons type
  23. (lambda (obj contents info)
  24. (funcall
  25. (intern (format "org-element-%s-interpreter" type))
  26. obj contents)))
  27. transcode-table)))))
  28. (progn ,@body)))
  29. (defmacro org-test-with-parsed-data (data &rest body)
  30. "Execute body with parsed data available.
  31. DATA is a string containing the data to be parsed. BODY is the
  32. body to execute. Parse tree is available under the `tree'
  33. variable, and communication channel under `info'.
  34. This function calls `org-export-collect-tree-properties'. As
  35. such, `:ignore-list' (for `org-element-map') and
  36. `:parse-tree' (for `org-export-get-genealogy') properties are
  37. already filled in `info'."
  38. (declare (debug (form body)) (indent 1))
  39. `(org-test-with-temp-text ,data
  40. (let* ((tree (org-element-parse-buffer))
  41. (info (org-export-collect-tree-properties
  42. tree (org-export-get-environment))))
  43. ,@body)))
  44. ;;; Tests
  45. (ert-deftest test-org-export/parse-option-keyword ()
  46. "Test reading all standard #+OPTIONS: items."
  47. (should
  48. (equal
  49. (org-export--parse-option-keyword
  50. "H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t
  51. *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t")
  52. '(:headline-levels
  53. 1 :preserve-breaks t :section-numbers t :time-stamp-file t
  54. :with-archived-trees t :with-author t :with-creator t :with-drawers t
  55. :with-email t :with-emphasize t :with-entities t :with-fixed-width t
  56. :with-footnotes t :with-priority t :with-special-strings t
  57. :with-sub-superscript t :with-toc t :with-tables t :with-tags t
  58. :with-tasks t :with-timestamps t :with-todo-keywords t)))
  59. ;; Test some special values.
  60. (should
  61. (equal
  62. (org-export--parse-option-keyword
  63. "arch:headline creator:comment d:(\"TEST\")
  64. ^:{} toc:1 tags:not-in-toc tasks:todo num:2 <:active")
  65. '( :section-numbers
  66. 2
  67. :with-archived-trees headline :with-creator comment
  68. :with-drawers ("TEST") :with-sub-superscript {} :with-toc 1
  69. :with-tags not-in-toc :with-tasks todo :with-timestamps active))))
  70. (ert-deftest test-org-export/get-inbuffer-options ()
  71. "Test reading all standard export keywords."
  72. (should
  73. (equal
  74. (org-test-with-temp-text "#+AUTHOR: Me, Myself and I
  75. #+CREATOR: Idem
  76. #+DATE: Today
  77. #+DESCRIPTION: Testing
  78. #+DESCRIPTION: with two lines
  79. #+EMAIL: some@email.org
  80. #+EXCLUDE_TAGS: noexport invisible
  81. #+KEYWORDS: test
  82. #+LANGUAGE: en
  83. #+SELECT_TAGS: export
  84. #+TITLE: Some title
  85. #+TITLE: with spaces"
  86. (org-export--get-inbuffer-options))
  87. '(:author
  88. ("Me, Myself and I") :creator "Idem" :date ("Today")
  89. :description "Testing\nwith two lines" :email "some@email.org"
  90. :exclude-tags ("noexport" "invisible") :keywords "test" :language "en"
  91. :select-tags ("export") :title ("Some title with spaces")))))
  92. (ert-deftest test-org-export/get-subtree-options ()
  93. "Test setting options from headline's properties."
  94. ;; EXPORT_TITLE.
  95. (org-test-with-temp-text "#+TITLE: Title
  96. * Headline
  97. :PROPERTIES:
  98. :EXPORT_TITLE: Subtree Title
  99. :END:
  100. Paragraph"
  101. (forward-line)
  102. (should (equal (plist-get (org-export-get-environment nil t) :title)
  103. '("Subtree Title"))))
  104. :title
  105. '("subtree-title")
  106. ;; EXPORT_OPTIONS.
  107. (org-test-with-temp-text "#+OPTIONS: H:1
  108. * Headline
  109. :PROPERTIES:
  110. :EXPORT_OPTIONS: H:2
  111. :END:
  112. Paragraph"
  113. (forward-line)
  114. (should
  115. (= 2 (plist-get (org-export-get-environment nil t) :headline-levels))))
  116. ;; EXPORT_DATE.
  117. (org-test-with-temp-text "#+DATE: today
  118. * Headline
  119. :PROPERTIES:
  120. :EXPORT_DATE: 29-03-2012
  121. :END:
  122. Paragraph"
  123. (forward-line)
  124. (should (equal (plist-get (org-export-get-environment nil t) :date)
  125. '("29-03-2012"))))
  126. ;; Export properties are case-insensitive.
  127. (org-test-with-temp-text "* Headline
  128. :PROPERTIES:
  129. :EXPORT_Date: 29-03-2012
  130. :END:
  131. Paragraph"
  132. (should (equal (plist-get (org-export-get-environment nil t) :date)
  133. '("29-03-2012")))))
  134. (ert-deftest test-org-export/handle-options ()
  135. "Test if export options have an impact on output."
  136. ;; Test exclude tags.
  137. (org-test-with-temp-text "* Head1 :noexport:"
  138. (org-test-with-backend test
  139. (should
  140. (equal (org-export-as 'test nil nil nil '(:exclude-tags ("noexport")))
  141. ""))))
  142. ;; Test include tags.
  143. (org-test-with-temp-text "
  144. * Head1
  145. * Head2
  146. ** Sub-Head2.1 :export:
  147. *** Sub-Head2.1.1
  148. * Head2"
  149. (org-test-with-backend test
  150. (should
  151. (equal
  152. "* Head2\n** Sub-Head2.1 :export:\n*** Sub-Head2.1.1\n"
  153. (let ((org-tags-column 0))
  154. (org-export-as 'test nil nil nil '(:select-tags ("export"))))))))
  155. ;; Test mixing include tags and exclude tags.
  156. (org-test-with-temp-text "
  157. * Head1 :export:
  158. ** Sub-Head1 :noexport:
  159. ** Sub-Head2
  160. * Head2 :noexport:
  161. ** Sub-Head1 :export:"
  162. (org-test-with-backend test
  163. (should
  164. (string-match
  165. "\\* Head1[ \t]+:export:\n\\*\\* Sub-Head2\n"
  166. (org-export-as
  167. 'test nil nil nil
  168. '(:select-tags ("export") :exclude-tags ("noexport")))))))
  169. ;; Ignore tasks.
  170. (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
  171. (org-test-with-temp-text "* TODO Head1"
  172. (org-test-with-backend test
  173. (should (equal (org-export-as 'test nil nil nil '(:with-tasks nil))
  174. "")))))
  175. (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
  176. (org-test-with-temp-text "* TODO Head1"
  177. (org-test-with-backend test
  178. (should (equal (org-export-as 'test nil nil nil '(:with-tasks t))
  179. "* TODO Head1\n")))))
  180. ;; Archived tree.
  181. (org-test-with-temp-text "* Head1 :archive:"
  182. (let ((org-archive-tag "archive"))
  183. (org-test-with-backend test
  184. (should
  185. (equal (org-export-as 'test nil nil nil '(:with-archived-trees nil))
  186. "")))))
  187. (org-test-with-temp-text "* Head1 :archive:\nbody\n** Sub-head 2"
  188. (let ((org-archive-tag "archive"))
  189. (org-test-with-backend test
  190. (should
  191. (string-match
  192. "\\* Head1[ \t]+:archive:"
  193. (org-export-as 'test nil nil nil
  194. '(:with-archived-trees headline)))))))
  195. (org-test-with-temp-text "* Head1 :archive:"
  196. (let ((org-archive-tag "archive"))
  197. (org-test-with-backend test
  198. (should
  199. (string-match
  200. "\\`\\* Head1[ \t]+:archive:\n\\'"
  201. (org-export-as 'test nil nil nil '(:with-archived-trees t)))))))
  202. ;; Drawers.
  203. (let ((org-drawers '("TEST")))
  204. (org-test-with-temp-text ":TEST:\ncontents\n:END:"
  205. (org-test-with-backend test
  206. (should (equal (org-export-as 'test nil nil nil '(:with-drawers nil))
  207. ""))
  208. (should (equal (org-export-as 'test nil nil nil '(:with-drawers t))
  209. ":TEST:\ncontents\n:END:\n")))))
  210. (let ((org-drawers '("FOO" "BAR")))
  211. (org-test-with-temp-text ":FOO:\nkeep\n:END:\n:BAR:\nremove\n:END:"
  212. (org-test-with-backend test
  213. (should
  214. (equal (org-export-as 'test nil nil nil '(:with-drawers ("FOO")))
  215. ":FOO:\nkeep\n:END:\n")))))
  216. ;; Timestamps.
  217. (org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
  218. (org-test-with-backend test
  219. (should
  220. (equal (org-export-as 'test nil nil nil '(:with-timestamps t))
  221. "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>\n"))
  222. (should
  223. (equal (org-export-as 'test nil nil nil '(:with-timestamps nil)) ""))
  224. (should
  225. (equal (org-export-as 'test nil nil nil '(:with-timestamps active))
  226. "<2012-04-29 sun. 10:45>\n"))
  227. (should
  228. (equal (org-export-as 'test nil nil nil '(:with-timestamps inactive))
  229. "[2012-04-29 sun. 10:45]\n"))))
  230. ;; Clocks.
  231. (let ((org-clock-string "CLOCK:"))
  232. (org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
  233. (org-test-with-backend test
  234. (should
  235. (equal (org-export-as 'test nil nil nil '(:with-clocks t))
  236. "CLOCK: [2012-04-29 sun. 10:45]\n"))
  237. (should
  238. (equal (org-export-as 'test nil nil nil '(:with-clocks nil)) "")))))
  239. ;; Plannings.
  240. (let ((org-closed-string "CLOSED:"))
  241. (org-test-with-temp-text "CLOSED: [2012-04-29 sun. 10:45]"
  242. (org-test-with-backend test
  243. (should
  244. (equal (org-export-as 'test nil nil nil '(:with-plannings t))
  245. "CLOSED: [2012-04-29 sun. 10:45]\n"))
  246. (should
  247. (equal (org-export-as 'test nil nil nil '(:with-plannings nil))
  248. ""))))))
  249. (ert-deftest test-org-export/comment-tree ()
  250. "Test if export process ignores commented trees."
  251. (let ((org-comment-string "COMMENT"))
  252. (org-test-with-temp-text "* COMMENT Head1"
  253. (org-test-with-backend test
  254. (should (equal (org-export-as 'test) ""))))))
  255. (ert-deftest test-org-export/export-scope ()
  256. "Test all export scopes."
  257. (org-test-with-temp-text "
  258. * Head1
  259. ** Head2
  260. text
  261. *** Head3"
  262. (org-test-with-backend test
  263. ;; Subtree.
  264. (forward-line 3)
  265. (should (equal (org-export-as 'test 'subtree) "text\n*** Head3\n"))
  266. ;; Visible.
  267. (goto-char (point-min))
  268. (forward-line)
  269. (org-cycle)
  270. (should (equal (org-export-as 'test nil 'visible) "* Head1\n"))
  271. ;; Body only.
  272. (flet ((org-test-template (body info) (format "BEGIN\n%sEND" body)))
  273. (push '(template . org-test-template) org-test-translate-alist)
  274. (should (equal (org-export-as 'test nil nil 'body-only)
  275. "* Head1\n** Head2\ntext\n*** Head3\n"))
  276. (should (equal (org-export-as 'test)
  277. "BEGIN\n* Head1\n** Head2\ntext\n*** Head3\nEND")))
  278. ;; Region.
  279. (goto-char (point-min))
  280. (forward-line 3)
  281. (transient-mark-mode 1)
  282. (push-mark (point) t t)
  283. (goto-char (point-at-eol))
  284. (should (equal (org-export-as 'test) "text\n"))))
  285. ;; Subtree with a code block calling another block outside.
  286. (org-test-with-temp-text "
  287. * Head1
  288. #+BEGIN_SRC emacs-lisp :noweb yes :exports results
  289. <<test>>
  290. #+END_SRC
  291. * Head2
  292. #+NAME: test
  293. #+BEGIN_SRC emacs-lisp
  294. \(+ 1 2)
  295. #+END_SRC"
  296. (org-test-with-backend test
  297. (forward-line 1)
  298. (should (equal (org-export-as 'test 'subtree) ": 3\n")))))
  299. (ert-deftest test-org-export/expand-include ()
  300. "Test file inclusion in an Org buffer."
  301. ;; Full insertion with recursive inclusion.
  302. (org-test-with-temp-text
  303. (format "#+INCLUDE: \"%s/examples/include.org\"" org-test-dir)
  304. (org-export-expand-include-keyword)
  305. (should (equal (buffer-string)
  306. "Small Org file with an include keyword.
  307. #+BEGIN_SRC emacs-lisp :exports results\n(+ 2 1)\n#+END_SRC
  308. Success!
  309. * Heading
  310. body\n")))
  311. ;; Localized insertion.
  312. (org-test-with-temp-text
  313. (format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\""
  314. org-test-dir)
  315. (org-export-expand-include-keyword)
  316. (should (equal (buffer-string)
  317. "Small Org file with an include keyword.\n")))
  318. ;; Insertion with constraints on headlines level.
  319. (org-test-with-temp-text
  320. (format
  321. "* Top heading\n#+INCLUDE: \"%s/examples/include.org\" :lines \"9-\""
  322. org-test-dir)
  323. (org-export-expand-include-keyword)
  324. (should (equal (buffer-string) "* Top heading\n** Heading\nbody\n")))
  325. ;; Inclusion within an example block.
  326. (org-test-with-temp-text
  327. (format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\" example"
  328. org-test-dir)
  329. (org-export-expand-include-keyword)
  330. (should
  331. (equal
  332. (buffer-string)
  333. "#+BEGIN_EXAMPLE\nSmall Org file with an include keyword.\n#+END_EXAMPLE\n")))
  334. ;; Inclusion within a src-block.
  335. (org-test-with-temp-text
  336. (format
  337. "#+INCLUDE: \"%s/examples/include.org\" :lines \"4-5\" src emacs-lisp"
  338. org-test-dir)
  339. (org-export-expand-include-keyword)
  340. (should (equal (buffer-string)
  341. "#+BEGIN_SRC emacs-lisp\n(+ 2 1)\n#+END_SRC\n"))))
  342. (ert-deftest test-org-export/user-ignore-list ()
  343. "Test if `:ignore-list' accepts user input."
  344. (org-test-with-backend test
  345. (flet ((skip-note-head
  346. (data backend info)
  347. ;; Ignore headlines with the word "note" in their title.
  348. (org-element-map
  349. data 'headline
  350. (lambda (headline)
  351. (when (string-match "\\<note\\>"
  352. (org-element-property :raw-value headline))
  353. (org-export-ignore-element headline info)))
  354. info)
  355. data))
  356. ;; Install function in parse tree filters.
  357. (let ((org-export-filter-parse-tree-functions '(skip-note-head)))
  358. (org-test-with-temp-text "* Head1\n* Head2 (note)\n"
  359. (should (equal (org-export-as 'test) "* Head1\n")))))))
  360. (ert-deftest test-org-export/before-parsing-hook ()
  361. "Test `org-export-before-parsing-hook'."
  362. (org-test-with-backend test
  363. (org-test-with-temp-text "* Headline 1\nBody 1\n* Headline 2\nBody 2"
  364. (let ((org-export-before-parsing-hook
  365. '((lambda ()
  366. (org-map-entries
  367. (lambda ()
  368. (delete-region (point) (progn (forward-line) (point)))))))))
  369. (should (equal (org-export-as 'test) "Body 1\nBody 2\n"))))))
  370. ;;; Affiliated Keywords
  371. (ert-deftest test-org-export/read-attribute ()
  372. "Test `org-export-read-attribute' specifications."
  373. ;; Standard test.
  374. (should
  375. (equal
  376. (org-export-read-attribute
  377. :attr_html
  378. (org-test-with-temp-text "#+ATTR_HTML: :a 1 :b 2\nParagraph"
  379. (org-element-at-point)))
  380. '(:a 1 :b 2)))
  381. ;; Return nil on empty attribute.
  382. (should-not
  383. (org-export-read-attribute
  384. :attr_html
  385. (org-test-with-temp-text "Paragraph" (org-element-at-point)))))
  386. ;;; Export Snippets
  387. (ert-deftest test-org-export/export-snippet ()
  388. "Test export snippets transcoding."
  389. (org-test-with-temp-text "@@test:A@@@@t:B@@"
  390. (org-test-with-backend test
  391. (let ((org-test-translate-alist
  392. (cons (cons 'export-snippet
  393. (lambda (snippet contents info)
  394. (when (eq (org-export-snippet-backend snippet) 'test)
  395. (org-element-property :value snippet))))
  396. org-test-translate-alist)))
  397. (let ((org-export-snippet-translation-alist nil))
  398. (should (equal (org-export-as 'test) "A\n")))
  399. (let ((org-export-snippet-translation-alist '(("t" . "test"))))
  400. (should (equal (org-export-as 'test) "AB\n")))))))
  401. ;;; Footnotes
  402. (ert-deftest test-org-export/footnotes ()
  403. "Test footnotes specifications."
  404. (let ((org-footnote-section nil)
  405. (org-export-with-footnotes t))
  406. ;; 1. Read every type of footnote.
  407. (should
  408. (equal
  409. '((1 . "A\n") (2 . "B") (3 . "C") (4 . "D"))
  410. (org-test-with-parsed-data
  411. "Text[fn:1] [1] [fn:label:C] [fn::D]\n\n[fn:1] A\n\n[1] B"
  412. (org-element-map
  413. tree 'footnote-reference
  414. (lambda (ref)
  415. (let ((def (org-export-get-footnote-definition ref info)))
  416. (cons (org-export-get-footnote-number ref info)
  417. (if (eq (org-element-property :type ref) 'inline) (car def)
  418. (car (org-element-contents
  419. (car (org-element-contents def))))))))
  420. info))))
  421. ;; 2. Test nested footnotes order.
  422. (org-test-with-parsed-data
  423. "Text[fn:1:A[fn:2]] [fn:3].\n\n[fn:2] B [fn:3] [fn::D].\n\n[fn:3] C."
  424. (should
  425. (equal
  426. '((1 . "fn:1") (2 . "fn:2") (3 . "fn:3") (4))
  427. (org-element-map
  428. tree 'footnote-reference
  429. (lambda (ref)
  430. (when (org-export-footnote-first-reference-p ref info)
  431. (cons (org-export-get-footnote-number ref info)
  432. (org-element-property :label ref))))
  433. info))))
  434. ;; 3. Test nested footnote in invisible definitions.
  435. (org-test-with-temp-text "Text[1]\n\n[1] B [2]\n\n[2] C."
  436. ;; Hide definitions.
  437. (narrow-to-region (point) (point-at-eol))
  438. (let* ((tree (org-element-parse-buffer))
  439. (info (org-combine-plists
  440. `(:parse-tree ,tree)
  441. (org-export-collect-tree-properties
  442. tree (org-export-get-environment)))))
  443. ;; Both footnotes should be seen.
  444. (should
  445. (= (length (org-export-collect-footnote-definitions tree info)) 2))))
  446. ;; 4. Test footnotes definitions collection.
  447. (org-test-with-parsed-data "Text[fn:1:A[fn:2]] [fn:3].
  448. \[fn:2] B [fn:3] [fn::D].
  449. \[fn:3] C."
  450. (should (= (length (org-export-collect-footnote-definitions tree info))
  451. 4)))
  452. ;; 5. Test export of footnotes defined outside parsing scope.
  453. (org-test-with-temp-text "[fn:1] Out of scope
  454. * Title
  455. Paragraph[fn:1]"
  456. (org-test-with-backend test
  457. (let ((org-test-translate-alist
  458. (cons (cons 'footnote-reference
  459. (lambda (fn contents info)
  460. (org-element-interpret-data
  461. (org-export-get-footnote-definition fn info))))
  462. org-test-translate-alist)))
  463. (forward-line)
  464. (should (equal "ParagraphOut of scope\n"
  465. (org-export-as 'test 'subtree))))))))
  466. ;;; Headlines and Inlinetasks
  467. (ert-deftest test-org-export/get-relative-level ()
  468. "Test `org-export-get-relative-level' specifications."
  469. ;; Standard test.
  470. (should
  471. (equal '(1 2)
  472. (let ((org-odd-levels-only nil))
  473. (org-test-with-parsed-data "* Headline 1\n** Headline 2"
  474. (org-element-map
  475. tree 'headline
  476. (lambda (h) (org-export-get-relative-level h info))
  477. info)))))
  478. ;; Missing levels
  479. (should
  480. (equal '(1 3)
  481. (let ((org-odd-levels-only nil))
  482. (org-test-with-parsed-data "** Headline 1\n**** Headline 2"
  483. (org-element-map
  484. tree 'headline
  485. (lambda (h) (org-export-get-relative-level h info))
  486. info))))))
  487. (ert-deftest test-org-export/low-level-p ()
  488. "Test `org-export-low-level-p' specifications."
  489. (should
  490. (equal
  491. '(no yes)
  492. (let ((org-odd-levels-only nil))
  493. (org-test-with-parsed-data "* Headline 1\n** Headline 2"
  494. (org-element-map
  495. tree 'headline
  496. (lambda (h) (if (org-export-low-level-p h info) 'yes 'no))
  497. (plist-put info :headline-levels 1)))))))
  498. (ert-deftest test-org-export/get-headline-number ()
  499. "Test `org-export-get-headline-number' specifications."
  500. ;; Standard test.
  501. (should
  502. (equal
  503. '((1) (1 1))
  504. (let ((org-odd-levels-only nil))
  505. (org-test-with-parsed-data "* Headline 1\n** Headline 2"
  506. (org-element-map
  507. tree 'headline
  508. (lambda (h) (org-export-get-headline-number h info))
  509. info)))))
  510. ;; Missing levels are replaced with 0.
  511. (should
  512. (equal
  513. '((1) (1 0 1))
  514. (let ((org-odd-levels-only nil))
  515. (org-test-with-parsed-data "* Headline 1\n*** Headline 2"
  516. (org-element-map
  517. tree 'headline
  518. (lambda (h) (org-export-get-headline-number h info))
  519. info))))))
  520. (ert-deftest test-org-export/numbered-headline-p ()
  521. "Test `org-export-numbered-headline-p' specifications."
  522. ;; If `:section-numbers' is nil, never number headlines.
  523. (should-not
  524. (org-test-with-parsed-data "* Headline"
  525. (org-element-map
  526. tree 'headline
  527. (lambda (h) (org-export-numbered-headline-p h info))
  528. (plist-put info :section-numbers nil))))
  529. ;; If `:section-numbers' is a number, only number headlines with
  530. ;; a level greater that it.
  531. (should
  532. (equal
  533. '(yes no)
  534. (org-test-with-parsed-data "* Headline 1\n** Headline 2"
  535. (org-element-map
  536. tree 'headline
  537. (lambda (h) (if (org-export-numbered-headline-p h info) 'yes 'no))
  538. (plist-put info :section-numbers 1)))))
  539. ;; Otherwise, headlines are always numbered.
  540. (should
  541. (org-test-with-parsed-data "* Headline"
  542. (org-element-map
  543. tree 'headline
  544. (lambda (h) (org-export-numbered-headline-p h info))
  545. (plist-put info :section-numbers t)))))
  546. (ert-deftest test-org-export/number-to-roman ()
  547. "Test `org-export-number-to-roman' specifications."
  548. ;; If number is negative, return it as a string.
  549. (should (equal (org-export-number-to-roman -1) "-1"))
  550. ;; Otherwise, return it as a roman number.
  551. (should (equal (org-export-number-to-roman 1449) "MCDXLIX")))
  552. (ert-deftest test-org-export/get-tags ()
  553. "Test `org-export-get-tags' specifications."
  554. (let ((org-export-exclude-tags '("noexport"))
  555. (org-export-select-tags '("export")))
  556. ;; Standard test: tags which are not a select tag, an exclude tag,
  557. ;; or specified as optional argument shouldn't be ignored.
  558. (should
  559. (org-test-with-parsed-data "* Headline :tag:"
  560. (org-export-get-tags (org-element-map tree 'headline 'identity info t)
  561. info)))
  562. ;; Exclude tags are removed.
  563. (should-not
  564. (org-test-with-parsed-data "* Headline :noexport:"
  565. (org-export-get-tags (org-element-map tree 'headline 'identity info t)
  566. info)))
  567. ;; Select tags are removed.
  568. (should-not
  569. (org-test-with-parsed-data "* Headline :export:"
  570. (org-export-get-tags (org-element-map tree 'headline 'identity info t)
  571. info)))
  572. (should
  573. (equal
  574. '("tag")
  575. (org-test-with-parsed-data "* Headline :tag:export:"
  576. (org-export-get-tags (org-element-map tree 'headline 'identity info t)
  577. info))))
  578. ;; Tags provided in the optional argument are also ignored.
  579. (should-not
  580. (org-test-with-parsed-data "* Headline :ignore:"
  581. (org-export-get-tags (org-element-map tree 'headline 'identity info t)
  582. info '("ignore"))))))
  583. (ert-deftest test-org-export/first-sibling-p ()
  584. "Test `org-export-first-sibling-p' specifications."
  585. ;; Standard test.
  586. (should
  587. (equal
  588. '(yes yes no)
  589. (org-test-with-parsed-data "* Headline\n** Headline 2\n** Headline 3"
  590. (org-element-map
  591. tree 'headline
  592. (lambda (h) (if (org-export-first-sibling-p h info) 'yes 'no))
  593. info))))
  594. ;; Ignore headlines not exported.
  595. (should
  596. (equal
  597. '(yes)
  598. (let ((org-export-exclude-tags '("ignore")))
  599. (org-test-with-parsed-data "* Headline :ignore:\n* Headline 2"
  600. (org-element-map
  601. tree 'headline
  602. (lambda (h) (if (org-export-first-sibling-p h info) 'yes 'no))
  603. info))))))
  604. (ert-deftest test-org-export/last-sibling-p ()
  605. "Test `org-export-last-sibling-p' specifications."
  606. ;; Standard test.
  607. (should
  608. (equal
  609. '(yes no yes)
  610. (org-test-with-parsed-data "* Headline\n** Headline 2\n** Headline 3"
  611. (org-element-map
  612. tree 'headline
  613. (lambda (h) (if (org-export-last-sibling-p h info) 'yes 'no))
  614. info))))
  615. ;; Ignore headlines not exported.
  616. (should
  617. (equal
  618. '(yes)
  619. (let ((org-export-exclude-tags '("ignore")))
  620. (org-test-with-parsed-data "* Headline\n* Headline 2 :ignore:"
  621. (org-element-map
  622. tree 'headline
  623. (lambda (h) (if (org-export-last-sibling-p h info) 'yes 'no))
  624. info))))))
  625. ;;; Links
  626. (ert-deftest test-org-export/get-coderef-format ()
  627. "Test `org-export-get-coderef-format' specifications."
  628. ;; A link without description returns "%s"
  629. (should (equal (org-export-get-coderef-format "(ref:line)" nil)
  630. "%s"))
  631. ;; Return "%s" when path is matched within description.
  632. (should (equal (org-export-get-coderef-format "path" "desc (path)")
  633. "desc %s"))
  634. ;; Otherwise return description.
  635. (should (equal (org-export-get-coderef-format "path" "desc")
  636. "desc")))
  637. (ert-deftest test-org-export/inline-image-p ()
  638. "Test `org-export-inline-image-p' specifications."
  639. (should
  640. (org-export-inline-image-p
  641. (org-test-with-temp-text "[[#id]]"
  642. (org-element-map
  643. (org-element-parse-buffer) 'link 'identity nil t))
  644. '(("custom-id" . "id")))))
  645. (ert-deftest test-org-export/fuzzy-link ()
  646. "Test fuzzy links specifications."
  647. ;; 1. Links to invisible (keyword) targets should be ignored.
  648. (org-test-with-parsed-data
  649. "Paragraph.\n#+TARGET: Test\n[[Test]]"
  650. (should-not
  651. (org-element-map
  652. tree 'link
  653. (lambda (link)
  654. (org-export-get-ordinal
  655. (org-export-resolve-fuzzy-link link info) info)) info)))
  656. ;; 2. Link to an headline should return headline's number.
  657. (org-test-with-parsed-data
  658. "Paragraph.\n* Head1\n* Head2\n* Head3\n[[Head2]]"
  659. (should
  660. ;; Note: Headline's number is in fact a list of numbers.
  661. (equal '(2)
  662. (org-element-map
  663. tree 'link
  664. (lambda (link)
  665. (org-export-get-ordinal
  666. (org-export-resolve-fuzzy-link link info) info)) info t))))
  667. ;; 3. Link to a target in an item should return item's number.
  668. (org-test-with-parsed-data
  669. "- Item1\n - Item11\n - <<test>>Item12\n- Item2\n\n\n[[test]]"
  670. (should
  671. ;; Note: Item's number is in fact a list of numbers.
  672. (equal '(1 2)
  673. (org-element-map
  674. tree 'link
  675. (lambda (link)
  676. (org-export-get-ordinal
  677. (org-export-resolve-fuzzy-link link info) info)) info t))))
  678. ;; 4. Link to a target in a footnote should return footnote's
  679. ;; number.
  680. (org-test-with-parsed-data "
  681. Paragraph[1][2][fn:lbl3:C<<target>>][[test]][[target]]\n[1] A\n\n[2] <<test>>B"
  682. (should
  683. (equal '(2 3)
  684. (org-element-map
  685. tree 'link
  686. (lambda (link)
  687. (org-export-get-ordinal
  688. (org-export-resolve-fuzzy-link link info) info)) info))))
  689. ;; 5. Link to a named element should return sequence number of that
  690. ;; element.
  691. (org-test-with-parsed-data
  692. "#+NAME: tbl1\n|1|2|\n#+NAME: tbl2\n|3|4|\n#+NAME: tbl3\n|5|6|\n[[tbl2]]"
  693. (should
  694. (= 2
  695. (org-element-map
  696. tree 'link
  697. (lambda (link)
  698. (org-export-get-ordinal
  699. (org-export-resolve-fuzzy-link link info) info)) info t))))
  700. ;; 6. Link to a target not within an item, a table, a footnote
  701. ;; reference or definition should return section number.
  702. (org-test-with-parsed-data
  703. "* Head1\n* Head2\nParagraph<<target>>\n* Head3\n[[target]]"
  704. (should
  705. (equal '(2)
  706. (org-element-map
  707. tree 'link
  708. (lambda (link)
  709. (org-export-get-ordinal
  710. (org-export-resolve-fuzzy-link link info) info)) info t)))))
  711. (ert-deftest test-org-export/resolve-coderef ()
  712. "Test `org-export-resolve-coderef' specifications."
  713. (let ((org-coderef-label-format "(ref:%s)"))
  714. ;; 1. A link to a "-n -k -r" block returns line number.
  715. (org-test-with-parsed-data
  716. "#+BEGIN_EXAMPLE -n -k -r\nText (ref:coderef)\n#+END_EXAMPLE"
  717. (should (= (org-export-resolve-coderef "coderef" info) 1)))
  718. (org-test-with-parsed-data
  719. "#+BEGIN_SRC emacs-lisp -n -k -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
  720. (should (= (org-export-resolve-coderef "coderef" info) 1)))
  721. ;; 2. A link to a "-n -r" block returns line number.
  722. (org-test-with-parsed-data
  723. "#+BEGIN_EXAMPLE -n -r\nText (ref:coderef)\n#+END_EXAMPLE"
  724. (should (= (org-export-resolve-coderef "coderef" info) 1)))
  725. (org-test-with-parsed-data
  726. "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
  727. (should (= (org-export-resolve-coderef "coderef" info) 1)))
  728. ;; 3. A link to a "-n" block returns coderef.
  729. (org-test-with-parsed-data
  730. "#+BEGIN_SRC emacs-lisp -n\n(+ 1 1) (ref:coderef)\n#+END_SRC"
  731. (should (equal (org-export-resolve-coderef "coderef" info) "coderef")))
  732. (org-test-with-parsed-data
  733. "#+BEGIN_EXAMPLE -n\nText (ref:coderef)\n#+END_EXAMPLE"
  734. (should (equal (org-export-resolve-coderef "coderef" info) "coderef")))
  735. ;; 4. A link to a "-r" block returns line number.
  736. (org-test-with-parsed-data
  737. "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
  738. (should (= (org-export-resolve-coderef "coderef" info) 1)))
  739. (org-test-with-parsed-data
  740. "#+BEGIN_EXAMPLE -r\nText (ref:coderef)\n#+END_EXAMPLE"
  741. (should (= (org-export-resolve-coderef "coderef" info) 1)))
  742. ;; 5. A link to a block without a switch returns coderef.
  743. (org-test-with-parsed-data
  744. "#+BEGIN_SRC emacs-lisp\n(+ 1 1) (ref:coderef)\n#+END_SRC"
  745. (should (equal (org-export-resolve-coderef "coderef" info) "coderef")))
  746. (org-test-with-parsed-data
  747. "#+BEGIN_EXAMPLE\nText (ref:coderef)\n#+END_EXAMPLE"
  748. (should (equal (org-export-resolve-coderef "coderef" info) "coderef")))
  749. ;; 6. Correctly handle continued line numbers. A "+n" switch
  750. ;; should resume numbering from previous block with numbered
  751. ;; lines, ignoring blocks not numbering lines in the process.
  752. ;; A "-n" switch resets count.
  753. (org-test-with-parsed-data "
  754. #+BEGIN_EXAMPLE -n
  755. Text.
  756. #+END_EXAMPLE
  757. #+BEGIN_SRC emacs-lisp
  758. \(- 1 1)
  759. #+END_SRC
  760. #+BEGIN_SRC emacs-lisp +n -r
  761. \(+ 1 1) (ref:addition)
  762. #+END_SRC
  763. #+BEGIN_EXAMPLE -n -r
  764. Another text. (ref:text)
  765. #+END_EXAMPLE"
  766. (should (= (org-export-resolve-coderef "addition" info) 2))
  767. (should (= (org-export-resolve-coderef "text" info) 1)))
  768. ;; 7. Recognize coderef with user-specified syntax.
  769. (org-test-with-parsed-data
  770. "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText. [ref:text]\n#+END_EXAMPLE"
  771. (should (equal (org-export-resolve-coderef "text" info) "text")))))
  772. (ert-deftest test-org-export/resolve-fuzzy-link ()
  773. "Test `org-export-resolve-fuzzy-link' specifications."
  774. ;; 1. Match target objects.
  775. (org-test-with-parsed-data "<<target>> [[target]]"
  776. (should
  777. (org-export-resolve-fuzzy-link
  778. (org-element-map tree 'link 'identity info t) info)))
  779. ;; 2. Match target elements.
  780. (org-test-with-parsed-data "#+TARGET: target\n[[target]]"
  781. (should
  782. (org-export-resolve-fuzzy-link
  783. (org-element-map tree 'link 'identity info t) info)))
  784. ;; 3. Match named elements.
  785. (org-test-with-parsed-data "#+NAME: target\nParagraph\n\n[[target]]"
  786. (should
  787. (org-export-resolve-fuzzy-link
  788. (org-element-map tree 'link 'identity info t) info)))
  789. ;; 4. Match exact headline's name.
  790. (org-test-with-parsed-data "* My headline\n[[My headline]]"
  791. (should
  792. (org-export-resolve-fuzzy-link
  793. (org-element-map tree 'link 'identity info t) info)))
  794. ;; 5. Targets objects have priority over named elements and headline
  795. ;; titles.
  796. (org-test-with-parsed-data
  797. "* target\n#+NAME: target\n<<target>>\n\n[[target]]"
  798. (should
  799. (eq 'target
  800. (org-element-type
  801. (org-export-resolve-fuzzy-link
  802. (org-element-map tree 'link 'identity info t) info)))))
  803. ;; 6. Named elements have priority over headline titles.
  804. (org-test-with-parsed-data
  805. "* target\n#+NAME: target\nParagraph\n\n[[target]]"
  806. (should
  807. (eq 'paragraph
  808. (org-element-type
  809. (org-export-resolve-fuzzy-link
  810. (org-element-map tree 'link 'identity info t) info)))))
  811. ;; 7. If link's path starts with a "*", only match headline titles,
  812. ;; though.
  813. (org-test-with-parsed-data
  814. "* target\n#+NAME: target\n<<target>>\n\n[[*target]]"
  815. (should
  816. (eq 'headline
  817. (org-element-type
  818. (org-export-resolve-fuzzy-link
  819. (org-element-map tree 'link 'identity info t) info)))))
  820. ;; 8. Return nil if no match.
  821. (org-test-with-parsed-data "[[target]]"
  822. (should-not
  823. (org-export-resolve-fuzzy-link
  824. (org-element-map tree 'link 'identity info t) info))))
  825. (ert-deftest test-org-export/resolve-id-link ()
  826. "Test `org-export-resolve-id-link' specifications."
  827. ;; 1. Regular test for custom-id link.
  828. (org-test-with-parsed-data "* Headline1
  829. :PROPERTIES:
  830. :CUSTOM-ID: test
  831. :END:
  832. * Headline 2
  833. \[[#test]]"
  834. (should
  835. (org-export-resolve-id-link
  836. (org-element-map tree 'link 'identity info t) info)))
  837. ;; 2. Failing test for custom-id link.
  838. (org-test-with-parsed-data "* Headline1
  839. :PROPERTIES:
  840. :CUSTOM-ID: test
  841. :END:
  842. * Headline 2
  843. \[[#no-match]]"
  844. (should-not
  845. (org-export-resolve-id-link
  846. (org-element-map tree 'link 'identity info t) info)))
  847. ;; 3. Test for internal id target.
  848. (org-test-with-parsed-data "* Headline1
  849. :PROPERTIES:
  850. :ID: aaaa
  851. :END:
  852. * Headline 2
  853. \[[id:aaaa]]"
  854. (should
  855. (org-export-resolve-id-link
  856. (org-element-map tree 'link 'identity info t) info)))
  857. ;; 4. Test for external id target.
  858. (org-test-with-parsed-data "[[id:aaaa]]"
  859. (should
  860. (org-export-resolve-id-link
  861. (org-element-map tree 'link 'identity info t)
  862. (org-combine-plists info '(:id-alist (("aaaa" . "external-file"))))))))
  863. (ert-deftest test-org-export/resolve-radio-link ()
  864. "Test `org-export-resolve-radio-link' specifications."
  865. ;; Standard test.
  866. (org-test-with-temp-text "<<<radio>>> radio"
  867. (org-update-radio-target-regexp)
  868. (should
  869. (let* ((tree (org-element-parse-buffer))
  870. (info `(:parse-tree ,tree)))
  871. (org-export-resolve-radio-link
  872. (org-element-map tree 'link 'identity info t)
  873. info))))
  874. ;; Radio target with objects.
  875. (org-test-with-temp-text "<<<radio \\alpha>>> radio \\alpha"
  876. (org-update-radio-target-regexp)
  877. (should
  878. (let* ((tree (org-element-parse-buffer))
  879. (info `(:parse-tree ,tree)))
  880. (org-export-resolve-radio-link
  881. (org-element-map tree 'link 'identity info t)
  882. info)))))
  883. ;;; Macro
  884. (ert-deftest test-org-export/define-macro ()
  885. "Try defining various Org macro using in-buffer #+MACRO: keyword."
  886. ;; Parsed macro.
  887. (should (equal (org-test-with-temp-text "#+MACRO: one 1"
  888. (org-export--get-inbuffer-options))
  889. '(:macro-one ("1"))))
  890. ;; Evaled macro.
  891. (should (equal (org-test-with-temp-text "#+MACRO: two (eval (+ 1 1))"
  892. (org-export--get-inbuffer-options))
  893. '(:macro-two ("(eval (+ 1 1))"))))
  894. ;; Incomplete macro.
  895. (should-not (org-test-with-temp-text "#+MACRO: three"
  896. (org-export--get-inbuffer-options)))
  897. ;; Macro with newline character.
  898. (should (equal (org-test-with-temp-text "#+MACRO: four a\\nb"
  899. (org-export--get-inbuffer-options))
  900. '(:macro-four ("a\nb"))))
  901. ;; Macro with protected newline character.
  902. (should (equal (org-test-with-temp-text "#+MACRO: five a\\\\nb"
  903. (org-export--get-inbuffer-options))
  904. '(:macro-five ("a\\nb"))))
  905. ;; Recursive macro.
  906. (org-test-with-temp-text "#+MACRO: six 6\n#+MACRO: seven 1 + {{{six}}}"
  907. (should
  908. (equal
  909. (org-export--get-inbuffer-options)
  910. '(:macro-six
  911. ("6")
  912. :macro-seven
  913. ("1 + " (macro (:key "six" :value "{{{six}}}" :args nil :begin 5 :end 14
  914. :post-blank 0 :parent nil))))))))
  915. (ert-deftest test-org-export/expand-macro ()
  916. "Test `org-export-expand-macro' specifications."
  917. ;; Standard test.
  918. (should
  919. (equal
  920. "some text"
  921. (org-test-with-parsed-data "#+MACRO: macro some text\n{{{macro}}}"
  922. (org-export-expand-macro
  923. (org-element-map tree 'macro 'identity info t) info))))
  924. ;; Macro with arguments.
  925. (should
  926. (equal
  927. "some text"
  928. (org-test-with-parsed-data "#+MACRO: macro $1 $2\n{{{macro(some,text)}}}"
  929. (org-export-expand-macro
  930. (org-element-map tree 'macro 'identity info t) info))))
  931. ;; Macro with "eval"
  932. (should
  933. (equal
  934. "3"
  935. (org-test-with-parsed-data "#+MACRO: add (eval (+ $1 $2))\n{{{add(1,2)}}}"
  936. (org-export-expand-macro
  937. (org-element-map tree 'macro 'identity info t) info))))
  938. ;; Nested macros.
  939. (should
  940. (equal
  941. "inner outer"
  942. (org-test-with-parsed-data
  943. "#+MACRO: in inner\n#+MACRO: out {{{in}}} outer\n{{{out}}}"
  944. (flet ((translate-macro (macro contents info)
  945. (org-export-expand-macro macro info)))
  946. (org-export-expand-macro
  947. (org-element-map tree 'macro 'identity info t)
  948. (org-combine-plists
  949. info `(:translate-alist ((macro . translate-macro))))))))))
  950. ;;; Src-block and example-block
  951. (ert-deftest test-org-export/unravel-code ()
  952. "Test `org-export-unravel-code' function."
  953. (let ((org-coderef-label-format "(ref:%s)"))
  954. ;; 1. Code without reference.
  955. (org-test-with-temp-text "#+BEGIN_EXAMPLE\n(+ 1 1)\n#+END_EXAMPLE"
  956. (should (equal (org-export-unravel-code (org-element-at-point))
  957. '("(+ 1 1)\n"))))
  958. ;; 2. Code with reference.
  959. (org-test-with-temp-text
  960. "#+BEGIN_EXAMPLE\n(+ 1 1) (ref:test)\n#+END_EXAMPLE"
  961. (should (equal (org-export-unravel-code (org-element-at-point))
  962. '("(+ 1 1)\n" (1 . "test")))))
  963. ;; 3. Code with user-defined reference.
  964. (org-test-with-temp-text
  965. "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\n(+ 1 1) [ref:test]\n#+END_EXAMPLE"
  966. (should (equal (org-export-unravel-code (org-element-at-point))
  967. '("(+ 1 1)\n" (1 . "test")))))
  968. ;; 4. Code references keys are relative to the current block.
  969. (org-test-with-temp-text "
  970. #+BEGIN_EXAMPLE -n
  971. \(+ 1 1)
  972. #+END_EXAMPLE
  973. #+BEGIN_EXAMPLE +n
  974. \(+ 2 2)
  975. \(+ 3 3) (ref:one)
  976. #+END_EXAMPLE"
  977. (goto-line 5)
  978. (should (equal (org-export-unravel-code (org-element-at-point))
  979. '("(+ 2 2)\n(+ 3 3)\n" (2 . "one")))))
  980. ;; 5. Free up comma-protected lines.
  981. ;;
  982. ;; 5.1. In an Org source block, every line is protected.
  983. (org-test-with-temp-text
  984. "#+BEGIN_SRC org\n,* Test\n,# comment\n,Text\n#+END_SRC"
  985. (should (equal (org-export-unravel-code (org-element-at-point))
  986. '("* Test\n# comment\nText\n"))))
  987. ;; 5.2. In other blocks, only headlines, comments and keywords are
  988. ;; protected.
  989. (org-test-with-temp-text
  990. "#+BEGIN_EXAMPLE\n,* Headline\n, * Not headline\n,Keep\n#+END_EXAMPLE"
  991. (should (equal (org-export-unravel-code (org-element-at-point))
  992. '("* Headline\n, * Not headline\n,Keep\n"))))))
  993. ;;; Tables
  994. (ert-deftest test-org-export/special-column ()
  995. "Test if the table's special column is properly recognized."
  996. ;; 1. First column is special if it contains only a special marking
  997. ;; characters or empty cells.
  998. (org-test-with-temp-text "
  999. | ! | 1 |
  1000. | | 2 |"
  1001. (should
  1002. (org-export-table-has-special-column-p
  1003. (org-element-map
  1004. (org-element-parse-buffer) 'table 'identity nil 'first-match))))
  1005. ;; 2. If the column contains anything else, it isn't special.
  1006. (org-test-with-temp-text "
  1007. | ! | 1 |
  1008. | b | 2 |"
  1009. (should-not
  1010. (org-export-table-has-special-column-p
  1011. (org-element-map
  1012. (org-element-parse-buffer) 'table 'identity nil 'first-match))))
  1013. ;; 3. Special marking characters are "#", "^", "*", "_", "/", "$"
  1014. ;; and "!".
  1015. (org-test-with-temp-text "
  1016. | # | 1 |
  1017. | ^ | 2 |
  1018. | * | 3 |
  1019. | _ | 4 |
  1020. | / | 5 |
  1021. | $ | 6 |
  1022. | ! | 7 |"
  1023. (should
  1024. (org-export-table-has-special-column-p
  1025. (org-element-map
  1026. (org-element-parse-buffer) 'table 'identity nil 'first-match))))
  1027. ;; 4. A first column with only empty cells isn't considered as
  1028. ;; special.
  1029. (org-test-with-temp-text "
  1030. | | 1 |
  1031. | | 2 |"
  1032. (should-not
  1033. (org-export-table-has-special-column-p
  1034. (org-element-map
  1035. (org-element-parse-buffer) 'table 'identity nil 'first-match)))))
  1036. (ert-deftest test-org-export/table-row-is-special-p ()
  1037. "Test `org-export-table-row-is-special-p' specifications."
  1038. ;; 1. A row is special if it has a special marking character in the
  1039. ;; special column.
  1040. (org-test-with-parsed-data "| ! | 1 |"
  1041. (should
  1042. (org-export-table-row-is-special-p
  1043. (org-element-map tree 'table-row 'identity nil 'first-match) info)))
  1044. ;; 2. A row is special when its first field is "/"
  1045. (org-test-with-parsed-data "
  1046. | / | 1 |
  1047. | a | b |"
  1048. (should
  1049. (org-export-table-row-is-special-p
  1050. (org-element-map tree 'table-row 'identity nil 'first-match) info)))
  1051. ;; 3. A row only containing alignment cookies is also considered as
  1052. ;; special.
  1053. (org-test-with-parsed-data "| <5> | | <l> | <l22> |"
  1054. (should
  1055. (org-export-table-row-is-special-p
  1056. (org-element-map tree 'table-row 'identity nil 'first-match) info)))
  1057. ;; 4. Everything else isn't considered as special.
  1058. (org-test-with-parsed-data "| \alpha | | c |"
  1059. (should-not
  1060. (org-export-table-row-is-special-p
  1061. (org-element-map tree 'table-row 'identity nil 'first-match) info)))
  1062. ;; 5. Table's rules are never considered as special rows.
  1063. (org-test-with-parsed-data "|---+---|"
  1064. (should-not
  1065. (org-export-table-row-is-special-p
  1066. (org-element-map tree 'table-row 'identity nil 'first-match) info))))
  1067. (ert-deftest test-org-export/has-header-p ()
  1068. "Test `org-export-table-has-header-p' specifications."
  1069. ;; 1. With an header.
  1070. (org-test-with-parsed-data "
  1071. | a | b |
  1072. |---+---|
  1073. | c | d |"
  1074. (should
  1075. (org-export-table-has-header-p
  1076. (org-element-map tree 'table 'identity info 'first-match)
  1077. info)))
  1078. ;; 2. Without an header.
  1079. (org-test-with-parsed-data "
  1080. | a | b |
  1081. | c | d |"
  1082. (should-not
  1083. (org-export-table-has-header-p
  1084. (org-element-map tree 'table 'identity info 'first-match)
  1085. info)))
  1086. ;; 3. Don't get fooled with starting and ending rules.
  1087. (org-test-with-parsed-data "
  1088. |---+---|
  1089. | a | b |
  1090. | c | d |
  1091. |---+---|"
  1092. (should-not
  1093. (org-export-table-has-header-p
  1094. (org-element-map tree 'table 'identity info 'first-match)
  1095. info))))
  1096. (ert-deftest test-org-export/table-row-group ()
  1097. "Test `org-export-table-row-group' specifications."
  1098. ;; 1. A rule creates a new group.
  1099. (org-test-with-parsed-data "
  1100. | a | b |
  1101. |---+---|
  1102. | 1 | 2 |"
  1103. (should
  1104. (equal
  1105. '(1 nil 2)
  1106. (mapcar (lambda (row) (org-export-table-row-group row info))
  1107. (org-element-map tree 'table-row 'identity)))))
  1108. ;; 2. Special rows are ignored in count.
  1109. (org-test-with-parsed-data "
  1110. | / | < | > |
  1111. |---|---+---|
  1112. | | 1 | 2 |"
  1113. (should
  1114. (equal
  1115. '(nil nil 1)
  1116. (mapcar (lambda (row) (org-export-table-row-group row info))
  1117. (org-element-map tree 'table-row 'identity)))))
  1118. ;; 3. Double rules also are ignored in count.
  1119. (org-test-with-parsed-data "
  1120. | a | b |
  1121. |---+---|
  1122. |---+---|
  1123. | 1 | 2 |"
  1124. (should
  1125. (equal
  1126. '(1 nil nil 2)
  1127. (mapcar (lambda (row) (org-export-table-row-group row info))
  1128. (org-element-map tree 'table-row 'identity))))))
  1129. (ert-deftest test-org-export/table-cell-width ()
  1130. "Test `org-export-table-cell-width' specifications."
  1131. ;; 1. Width is primarily determined by width cookies. If no cookie
  1132. ;; is found, cell's width is nil.
  1133. (org-test-with-parsed-data "
  1134. | / | <l> | <6> | <l7> |
  1135. | | a | b | c |"
  1136. (should
  1137. (equal
  1138. '(nil 6 7)
  1139. (mapcar (lambda (cell) (org-export-table-cell-width cell info))
  1140. (org-element-map tree 'table-cell 'identity info)))))
  1141. ;; 2. The last width cookie has precedence.
  1142. (org-test-with-parsed-data "
  1143. | <6> |
  1144. | <7> |
  1145. | a |"
  1146. (should
  1147. (equal
  1148. '(7)
  1149. (mapcar (lambda (cell) (org-export-table-cell-width cell info))
  1150. (org-element-map tree 'table-cell 'identity info)))))
  1151. ;; 3. Valid width cookies must have a specific row.
  1152. (org-test-with-parsed-data "| <6> | cell |"
  1153. (should
  1154. (equal
  1155. '(nil nil)
  1156. (mapcar (lambda (cell) (org-export-table-cell-width cell info))
  1157. (org-element-map tree 'table-cell 'identity))))))
  1158. (ert-deftest test-org-export/table-cell-alignment ()
  1159. "Test `org-export-table-cell-alignment' specifications."
  1160. (let ((org-table-number-fraction 0.5)
  1161. (org-table-number-regexp "^[0-9]+$"))
  1162. ;; 1. Alignment is primarily determined by alignment cookies.
  1163. (org-test-with-temp-text "| <l> | <c> | <r> |"
  1164. (let* ((tree (org-element-parse-buffer))
  1165. (info `(:parse-tree ,tree)))
  1166. (should
  1167. (equal
  1168. '(left center right)
  1169. (mapcar (lambda (cell) (org-export-table-cell-alignment cell info))
  1170. (org-element-map tree 'table-cell 'identity))))))
  1171. ;; 2. The last alignment cookie has precedence.
  1172. (org-test-with-parsed-data "
  1173. | <l8> |
  1174. | cell |
  1175. | <r9> |"
  1176. (should
  1177. (equal
  1178. '(right right right)
  1179. (mapcar (lambda (cell) (org-export-table-cell-alignment cell info))
  1180. (org-element-map tree 'table-cell 'identity)))))
  1181. ;; 3. If there's no cookie, cell's contents determine alignment.
  1182. ;; A column mostly made of cells containing numbers will align
  1183. ;; its cells to the right.
  1184. (org-test-with-parsed-data "
  1185. | 123 |
  1186. | some text |
  1187. | 12345 |"
  1188. (should
  1189. (equal
  1190. '(right right right)
  1191. (mapcar (lambda (cell)
  1192. (org-export-table-cell-alignment cell info))
  1193. (org-element-map tree 'table-cell 'identity)))))
  1194. ;; 4. Otherwise, they will be aligned to the left.
  1195. (org-test-with-parsed-data "
  1196. | text |
  1197. | some text |
  1198. | \alpha |"
  1199. (should
  1200. (equal
  1201. '(left left left)
  1202. (mapcar (lambda (cell)
  1203. (org-export-table-cell-alignment cell info))
  1204. (org-element-map tree 'table-cell 'identity)))))))
  1205. (ert-deftest test-org-export/table-cell-borders ()
  1206. "Test `org-export-table-cell-borders' specifications."
  1207. ;; 1. Recognize various column groups indicators.
  1208. (org-test-with-parsed-data "| / | < | > | <> |"
  1209. (should
  1210. (equal
  1211. '((right bottom top) (left bottom top) (right bottom top)
  1212. (right left bottom top))
  1213. (mapcar (lambda (cell)
  1214. (org-export-table-cell-borders cell info))
  1215. (org-element-map tree 'table-cell 'identity)))))
  1216. ;; 2. Accept shortcuts to define column groups.
  1217. (org-test-with-parsed-data "| / | < | < |"
  1218. (should
  1219. (equal
  1220. '((right bottom top) (right left bottom top) (left bottom top))
  1221. (mapcar (lambda (cell)
  1222. (org-export-table-cell-borders cell info))
  1223. (org-element-map tree 'table-cell 'identity)))))
  1224. ;; 3. A valid column groups row must start with a "/".
  1225. (org-test-with-parsed-data "
  1226. | | < |
  1227. | a | b |"
  1228. (should
  1229. (equal '((top) (top) (bottom) (bottom))
  1230. (mapcar (lambda (cell)
  1231. (org-export-table-cell-borders cell info))
  1232. (org-element-map tree 'table-cell 'identity)))))
  1233. ;; 4. Take table rules into consideration.
  1234. (org-test-with-parsed-data "
  1235. | 1 |
  1236. |---|
  1237. | 2 |"
  1238. (should
  1239. (equal '((below top) (bottom above))
  1240. (mapcar (lambda (cell)
  1241. (org-export-table-cell-borders cell info))
  1242. (org-element-map tree 'table-cell 'identity)))))
  1243. ;; 5. Top and (resp. bottom) rules induce both `top' and `above'
  1244. ;; (resp. `bottom' and `below') borders. Any special row is
  1245. ;; ignored.
  1246. (org-test-with-parsed-data "
  1247. |---+----|
  1248. | / | |
  1249. | | 1 |
  1250. |---+----|"
  1251. (should
  1252. (equal '((bottom below top above))
  1253. (last
  1254. (mapcar (lambda (cell)
  1255. (org-export-table-cell-borders cell info))
  1256. (org-element-map tree 'table-cell 'identity)))))))
  1257. (ert-deftest test-org-export/table-dimensions ()
  1258. "Test `org-export-table-dimensions' specifications."
  1259. ;; 1. Standard test.
  1260. (org-test-with-parsed-data "
  1261. | 1 | 2 | 3 |
  1262. | 4 | 5 | 6 |"
  1263. (should
  1264. (equal '(2 . 3)
  1265. (org-export-table-dimensions
  1266. (org-element-map tree 'table 'identity info 'first-match) info))))
  1267. ;; 2. Ignore horizontal rules and special columns.
  1268. (org-test-with-parsed-data "
  1269. | / | < | > |
  1270. | 1 | 2 | 3 |
  1271. |---+---+---|
  1272. | 4 | 5 | 6 |"
  1273. (should
  1274. (equal '(2 . 3)
  1275. (org-export-table-dimensions
  1276. (org-element-map tree 'table 'identity info 'first-match) info)))))
  1277. (ert-deftest test-org-export/table-cell-address ()
  1278. "Test `org-export-table-cell-address' specifications."
  1279. ;; 1. Standard test: index is 0-based.
  1280. (org-test-with-parsed-data "| a | b |"
  1281. (should
  1282. (equal '((0 . 0) (0 . 1))
  1283. (org-element-map
  1284. tree 'table-cell
  1285. (lambda (cell) (org-export-table-cell-address cell info))
  1286. info))))
  1287. ;; 2. Special column isn't counted, nor are special rows.
  1288. (org-test-with-parsed-data "
  1289. | / | <> |
  1290. | | c |"
  1291. (should
  1292. (equal '(0 . 0)
  1293. (org-export-table-cell-address
  1294. (car (last (org-element-map tree 'table-cell 'identity info)))
  1295. info))))
  1296. ;; 3. Tables rules do not count either.
  1297. (org-test-with-parsed-data "
  1298. | a |
  1299. |---|
  1300. | b |
  1301. |---|
  1302. | c |"
  1303. (should
  1304. (equal '(2 . 0)
  1305. (org-export-table-cell-address
  1306. (car (last (org-element-map tree 'table-cell 'identity info)))
  1307. info))))
  1308. ;; 4. Return nil for special cells.
  1309. (org-test-with-parsed-data "| / | a |"
  1310. (should-not
  1311. (org-export-table-cell-address
  1312. (org-element-map tree 'table-cell 'identity nil 'first-match)
  1313. info))))
  1314. (ert-deftest test-org-export/get-table-cell-at ()
  1315. "Test `org-export-get-table-cell-at' specifications."
  1316. ;; 1. Address ignores special columns, special rows and rules.
  1317. (org-test-with-parsed-data "
  1318. | / | <> |
  1319. | | a |
  1320. |---+----|
  1321. | | b |"
  1322. (should
  1323. (equal '("b")
  1324. (org-element-contents
  1325. (org-export-get-table-cell-at
  1326. '(1 . 0)
  1327. (org-element-map tree 'table 'identity info 'first-match)
  1328. info)))))
  1329. ;; 2. Return value for a non-existent address is nil.
  1330. (org-test-with-parsed-data "| a |"
  1331. (should-not
  1332. (org-export-get-table-cell-at
  1333. '(2 . 2)
  1334. (org-element-map tree 'table 'identity info 'first-match)
  1335. info)))
  1336. (org-test-with-parsed-data "| / |"
  1337. (should-not
  1338. (org-export-get-table-cell-at
  1339. '(0 . 0)
  1340. (org-element-map tree 'table 'identity info 'first-match)
  1341. info))))
  1342. (ert-deftest test-org-export/table-cell-starts-colgroup-p ()
  1343. "Test `org-export-table-cell-starts-colgroup-p' specifications."
  1344. ;; 1. A cell at a beginning of a row always starts a column group.
  1345. (org-test-with-parsed-data "| a |"
  1346. (should
  1347. (org-export-table-cell-starts-colgroup-p
  1348. (org-element-map tree 'table-cell 'identity info 'first-match)
  1349. info)))
  1350. ;; 2. Special column should be ignored when determining the
  1351. ;; beginning of the row.
  1352. (org-test-with-parsed-data "
  1353. | / | |
  1354. | | a |"
  1355. (should
  1356. (org-export-table-cell-starts-colgroup-p
  1357. (org-element-map tree 'table-cell 'identity info 'first-match)
  1358. info)))
  1359. ;; 2. Explicit column groups.
  1360. (org-test-with-parsed-data "
  1361. | / | | < |
  1362. | a | b | c |"
  1363. (should
  1364. (equal
  1365. '(yes no yes)
  1366. (org-element-map
  1367. tree 'table-cell
  1368. (lambda (cell)
  1369. (if (org-export-table-cell-starts-colgroup-p cell info) 'yes 'no))
  1370. info)))))
  1371. (ert-deftest test-org-export/table-cell-ends-colgroup-p ()
  1372. "Test `org-export-table-cell-ends-colgroup-p' specifications."
  1373. ;; 1. A cell at the end of a row always ends a column group.
  1374. (org-test-with-parsed-data "| a |"
  1375. (should
  1376. (org-export-table-cell-ends-colgroup-p
  1377. (org-element-map tree 'table-cell 'identity info 'first-match)
  1378. info)))
  1379. ;; 2. Special column should be ignored when determining the
  1380. ;; beginning of the row.
  1381. (org-test-with-parsed-data "
  1382. | / | |
  1383. | | a |"
  1384. (should
  1385. (org-export-table-cell-ends-colgroup-p
  1386. (org-element-map tree 'table-cell 'identity info 'first-match)
  1387. info)))
  1388. ;; 3. Explicit column groups.
  1389. (org-test-with-parsed-data "
  1390. | / | < | |
  1391. | a | b | c |"
  1392. (should
  1393. (equal
  1394. '(yes no yes)
  1395. (org-element-map
  1396. tree 'table-cell
  1397. (lambda (cell)
  1398. (if (org-export-table-cell-ends-colgroup-p cell info) 'yes 'no))
  1399. info)))))
  1400. (ert-deftest test-org-export/table-row-starts-rowgroup-p ()
  1401. "Test `org-export-table-row-starts-rowgroup-p' specifications."
  1402. ;; 1. A row at the beginning of a table always starts a row group.
  1403. ;; So does a row following a table rule.
  1404. (org-test-with-parsed-data "
  1405. | a |
  1406. |---|
  1407. | b |"
  1408. (should
  1409. (equal
  1410. '(yes no yes)
  1411. (org-element-map
  1412. tree 'table-row
  1413. (lambda (row)
  1414. (if (org-export-table-row-starts-rowgroup-p row info) 'yes 'no))
  1415. info))))
  1416. ;; 2. Special rows should be ignored when determining the beginning
  1417. ;; of the row.
  1418. (org-test-with-parsed-data "
  1419. | / | < |
  1420. | | a |
  1421. |---+---|
  1422. | / | < |
  1423. | | b |"
  1424. (should
  1425. (equal
  1426. '(yes no yes)
  1427. (org-element-map
  1428. tree 'table-row
  1429. (lambda (row)
  1430. (if (org-export-table-row-starts-rowgroup-p row info) 'yes 'no))
  1431. info)))))
  1432. (ert-deftest test-org-export/table-row-ends-rowgroup-p ()
  1433. "Test `org-export-table-row-ends-rowgroup-p' specifications."
  1434. ;; 1. A row at the end of a table always ends a row group. So does
  1435. ;; a row preceding a table rule.
  1436. (org-test-with-parsed-data "
  1437. | a |
  1438. |---|
  1439. | b |"
  1440. (should
  1441. (equal
  1442. '(yes no yes)
  1443. (org-element-map
  1444. tree 'table-row
  1445. (lambda (row)
  1446. (if (org-export-table-row-ends-rowgroup-p row info) 'yes 'no))
  1447. info))))
  1448. ;; 2. Special rows should be ignored when determining the beginning
  1449. ;; of the row.
  1450. (org-test-with-parsed-data "
  1451. | | a |
  1452. | / | < |
  1453. |---+---|
  1454. | | b |
  1455. | / | < |"
  1456. (should
  1457. (equal
  1458. '(yes no yes)
  1459. (org-element-map
  1460. tree 'table-row
  1461. (lambda (row)
  1462. (if (org-export-table-row-ends-rowgroup-p row info) 'yes 'no))
  1463. info)))))
  1464. (ert-deftest test-org-export/table-row-starts-header-p ()
  1465. "Test `org-export-table-row-starts-header-p' specifications."
  1466. ;; 1. Only the row starting the first row group starts the table
  1467. ;; header.
  1468. (org-test-with-parsed-data "
  1469. | a |
  1470. | b |
  1471. |---|
  1472. | c |"
  1473. (should
  1474. (equal
  1475. '(yes no no no)
  1476. (org-element-map
  1477. tree 'table-row
  1478. (lambda (row)
  1479. (if (org-export-table-row-starts-header-p row info) 'yes 'no))
  1480. info))))
  1481. ;; 2. A row cannot start an header if there's no header in the
  1482. ;; table.
  1483. (org-test-with-parsed-data "
  1484. | a |
  1485. |---|"
  1486. (should-not
  1487. (org-export-table-row-starts-header-p
  1488. (org-element-map tree 'table-row 'identity info 'first-match)
  1489. info))))
  1490. (ert-deftest test-org-export/table-row-ends-header-p ()
  1491. "Test `org-export-table-row-ends-header-p' specifications."
  1492. ;; 1. Only the row starting the first row group starts the table
  1493. ;; header.
  1494. (org-test-with-parsed-data "
  1495. | a |
  1496. | b |
  1497. |---|
  1498. | c |"
  1499. (should
  1500. (equal
  1501. '(no yes no no)
  1502. (org-element-map
  1503. tree 'table-row
  1504. (lambda (row)
  1505. (if (org-export-table-row-ends-header-p row info) 'yes 'no))
  1506. info))))
  1507. ;; 2. A row cannot start an header if there's no header in the
  1508. ;; table.
  1509. (org-test-with-parsed-data "
  1510. | a |
  1511. |---|"
  1512. (should-not
  1513. (org-export-table-row-ends-header-p
  1514. (org-element-map tree 'table-row 'identity info 'first-match)
  1515. info))))
  1516. ;;; Topology
  1517. (ert-deftest test-org-export/get-next-element ()
  1518. "Test `org-export-get-next-element' specifications."
  1519. ;; Standard test.
  1520. (should
  1521. (equal "b"
  1522. (org-test-with-parsed-data "* Headline\n*a* b"
  1523. (org-export-get-next-element
  1524. (org-element-map tree 'bold 'identity info t) info))))
  1525. ;; Return nil when no previous element.
  1526. (should-not
  1527. (org-test-with-parsed-data "* Headline\na *b*"
  1528. (org-export-get-next-element
  1529. (org-element-map tree 'bold 'identity info t) info)))
  1530. ;; Non-exportable elements are ignored.
  1531. (should-not
  1532. (let ((org-export-with-timestamps nil))
  1533. (org-test-with-parsed-data "\alpha <2012-03-29 Thu>"
  1534. (org-export-get-next-element
  1535. (org-element-map tree 'entity 'identity info t) info)))))
  1536. (ert-deftest test-org-export/get-previous-element ()
  1537. "Test `org-export-get-previous-element' specifications."
  1538. ;; Standard test.
  1539. (should
  1540. (equal "a "
  1541. (org-test-with-parsed-data "* Headline\na *b*"
  1542. (org-export-get-previous-element
  1543. (org-element-map tree 'bold 'identity info t) info))))
  1544. ;; Return nil when no previous element.
  1545. (should-not
  1546. (org-test-with-parsed-data "* Headline\n*a* b"
  1547. (org-export-get-previous-element
  1548. (org-element-map tree 'bold 'identity info t) info)))
  1549. ;; Non-exportable elements are ignored.
  1550. (should-not
  1551. (let ((org-export-with-timestamps nil))
  1552. (org-test-with-parsed-data "<2012-03-29 Thu> \alpha"
  1553. (org-export-get-previous-element
  1554. (org-element-map tree 'entity 'identity info t) info)))))
  1555. (provide 'test-org-export)
  1556. ;;; test-org-export.el end here