test-org-export.el 53 KB

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