org-exp.el 114 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088
  1. ;;; org-exp.el --- ASCII, HTML, XOXO and iCalendar export for Org-mode
  2. ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
  3. ;; Free Software Foundation, Inc.
  4. ;; Author: Carsten Dominik <carsten at orgmode dot org>
  5. ;; Keywords: outlines, hypermedia, calendar, wp
  6. ;; Homepage: http://orgmode.org
  7. ;; Version: 7.5
  8. ;;
  9. ;; This file is part of GNU Emacs.
  10. ;;
  11. ;; GNU Emacs is free software: you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation, either version 3 of the License, or
  14. ;; (at your option) any later version.
  15. ;; GNU Emacs is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;; GNU General Public License for more details.
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  21. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  22. ;;
  23. ;;; Commentary:
  24. ;;; Code:
  25. (require 'org)
  26. (require 'org-macs)
  27. (require 'org-agenda)
  28. (require 'org-exp-blocks)
  29. (require 'ob-exp)
  30. (require 'org-src)
  31. (eval-when-compile
  32. (require 'cl))
  33. (declare-function org-export-latex-preprocess "org-latex" (parameters))
  34. (declare-function org-export-ascii-preprocess "org-ascii" (parameters))
  35. (declare-function org-export-html-preprocess "org-html" (parameters))
  36. (declare-function org-export-docbook-preprocess "org-docbook" (parameters))
  37. (declare-function org-infojs-options-inbuffer-template "org-jsinfo" ())
  38. (declare-function org-export-htmlize-region-for-paste "org-html" (beg end))
  39. (declare-function htmlize-buffer "ext:htmlize" (&optional buffer))
  40. (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
  41. (declare-function org-table-cookie-line-p "org-table" (line))
  42. (declare-function org-table-colgroup-line-p "org-table" (line))
  43. (autoload 'org-export-generic "org-export-generic" "Export using the generic exporter" t)
  44. (defgroup org-export nil
  45. "Options for exporting org-listings."
  46. :tag "Org Export"
  47. :group 'org)
  48. (defgroup org-export-general nil
  49. "General options for exporting Org-mode files."
  50. :tag "Org Export General"
  51. :group 'org-export)
  52. (defcustom org-export-allow-BIND 'confirm
  53. "Non-nil means allow #+BIND to define local variable values for export.
  54. This is a potential security risk, which is why the user must confirm the
  55. use of these lines."
  56. :group 'org-export-general
  57. :type '(choice
  58. (const :tag "Never" nil)
  59. (const :tag "Always" t)
  60. (const :tag "Make the user confirm for each file" confirm)))
  61. ;; FIXME
  62. (defvar org-export-publishing-directory nil)
  63. (defcustom org-export-show-temporary-export-buffer t
  64. "Non-nil means show buffer after exporting to temp buffer.
  65. When Org exports to a file, the buffer visiting that file is ever
  66. shown, but remains buried. However, when exporting to a temporary
  67. buffer, that buffer is popped up in a second window. When this variable
  68. is nil, the buffer remains buried also in these cases."
  69. :group 'org-export-general
  70. :type 'boolean)
  71. (defcustom org-export-copy-to-kill-ring t
  72. "Non-nil means exported stuff will also be pushed onto the kill ring."
  73. :group 'org-export-general
  74. :type 'boolean)
  75. (defcustom org-export-kill-product-buffer-when-displayed nil
  76. "Non-nil means kill the product buffer if it is displayed immediately.
  77. This applied to the commands `org-export-as-html-and-open' and
  78. `org-export-as-pdf-and-open'."
  79. :group 'org-export-general
  80. :type 'boolean)
  81. (defcustom org-export-run-in-background nil
  82. "Non-nil means export and publishing commands will run in background.
  83. This works by starting up a separate Emacs process visiting the same file
  84. and doing the export from there.
  85. Not all export commands are affected by this - only the ones which
  86. actually write to a file, and that do not depend on the buffer state.
  87. \\<org-mode-map>
  88. If this option is nil, you can still get background export by calling
  89. `org-export' with a double prefix arg: \
  90. \\[universal-argument] \\[universal-argument] \\[org-export].
  91. If this option is t, the double prefix can be used to exceptionally
  92. force an export command into the current process."
  93. :group 'org-export-general
  94. :type 'boolean)
  95. (defcustom org-export-initial-scope 'buffer
  96. "The initial scope when exporting with `org-export'.
  97. This variable can be either set to 'buffer or 'subtree."
  98. :group 'org-export-general
  99. :type '(choice
  100. (const :tag "Export current buffer" 'buffer)
  101. (const :tag "Export current subtree" 'subtree)))
  102. (defcustom org-export-select-tags '("export")
  103. "Tags that select a tree for export.
  104. If any such tag is found in a buffer, all trees that do not carry one
  105. of these tags will be deleted before export.
  106. Inside trees that are selected like this, you can still deselect a
  107. subtree by tagging it with one of the `org-export-exclude-tags'."
  108. :group 'org-export-general
  109. :type '(repeat (string :tag "Tag")))
  110. (defcustom org-export-exclude-tags '("noexport")
  111. "Tags that exclude a tree from export.
  112. All trees carrying any of these tags will be excluded from export.
  113. This is without condition, so even subtrees inside that carry one of the
  114. `org-export-select-tags' will be removed."
  115. :group 'org-export-general
  116. :type '(repeat (string :tag "Tag")))
  117. ;; FIXME: rename, this is a general variable
  118. (defcustom org-export-html-expand t
  119. "Non-nil means for HTML export, treat @<...> as HTML tag.
  120. When nil, these tags will be exported as plain text and therefore
  121. not be interpreted by a browser.
  122. This option can also be set with the +OPTIONS line, e.g. \"@:nil\"."
  123. :group 'org-export-html
  124. :group 'org-export-general
  125. :type 'boolean)
  126. (defcustom org-export-with-special-strings t
  127. "Non-nil means interpret \"\-\", \"--\" and \"---\" for export.
  128. When this option is turned on, these strings will be exported as:
  129. Org HTML LaTeX
  130. -----+----------+--------
  131. \\- &shy; \\-
  132. -- &ndash; --
  133. --- &mdash; ---
  134. ... &hellip; \ldots
  135. This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
  136. :group 'org-export-translation
  137. :type 'boolean)
  138. (defcustom org-export-html-link-up ""
  139. "Where should the \"UP\" link of exported HTML pages lead?"
  140. :group 'org-export-html
  141. :group 'org-export-general
  142. :type '(string :tag "File or URL"))
  143. (defcustom org-export-html-link-home ""
  144. "Where should the \"HOME\" link of exported HTML pages lead?"
  145. :group 'org-export-html
  146. :group 'org-export-general
  147. :type '(string :tag "File or URL"))
  148. (defcustom org-export-language-setup
  149. '(("en" "Author" "Date" "Table of Contents" "Footnotes")
  150. ("ca" "Autor" "Data" "&Iacute;ndex" "Peus de p&agrave;gina")
  151. ("cs" "Autor" "Datum" "Obsah" "Pozn\xe1mky pod carou")
  152. ("da" "Ophavsmand" "Dato" "Indhold" "Fodnoter")
  153. ("de" "Autor" "Datum" "Inhaltsverzeichnis" "Fu&szlig;noten")
  154. ("eo" "A&#365;toro" "Dato" "Enhavo" "Piednotoj")
  155. ("es" "Autor" "Fecha" "&Iacute;ndice" "Pies de p&aacute;gina")
  156. ("fi" "Tekij&auml;" "P&auml;iv&auml;m&auml;&auml;r&auml;" "Sis&auml;llysluettelo" "Alaviitteet")
  157. ("fr" "Auteur" "Date" "Table des mati&egrave;res" "Notes de bas de page")
  158. ("hu" "Szerz&otilde;" "D&aacute;tum" "Tartalomjegyz&eacute;k" "L&aacute;bjegyzet")
  159. ("is" "H&ouml;fundur" "Dagsetning" "Efnisyfirlit" "Aftanm&aacute;lsgreinar")
  160. ("it" "Autore" "Data" "Indice" "Note a pi&egrave; di pagina")
  161. ("nl" "Auteur" "Datum" "Inhoudsopgave" "Voetnoten")
  162. ("no" "Forfatter" "Dato" "Innhold" "Fotnoter")
  163. ("nb" "Forfatter" "Dato" "Innhold" "Fotnoter") ;; nb = Norsk (bokm.l)
  164. ("nn" "Forfattar" "Dato" "Innhald" "Fotnotar") ;; nn = Norsk (nynorsk)
  165. ("pl" "Autor" "Data" "Spis tre&#x015b;ci" "Przypis")
  166. ("sv" "F&ouml;rfattare" "Datum" "Inneh&aring;ll" "Fotnoter"))
  167. "Terms used in export text, translated to different languages.
  168. Use the variable `org-export-default-language' to set the language,
  169. or use the +OPTION lines for a per-file setting."
  170. :group 'org-export-general
  171. :type '(repeat
  172. (list
  173. (string :tag "HTML language tag")
  174. (string :tag "Author")
  175. (string :tag "Date")
  176. (string :tag "Table of Contents")
  177. (string :tag "Footnotes"))))
  178. (defcustom org-export-default-language "en"
  179. "The default language for export and clocktable translations, as a string.
  180. This should have an association in `org-export-language-setup'
  181. and in `org-clock-clocktable-language-setup'."
  182. :group 'org-export-general
  183. :type 'string)
  184. (defvar org-export-page-description ""
  185. "The page description, for the XHTML meta tag.
  186. This is best set with the #+DESCRIPTION line in a file, it does not make
  187. sense to set this globally.")
  188. (defvar org-export-page-keywords ""
  189. "The page description, for the XHTML meta tag.
  190. This is best set with the #+KEYWORDS line in a file, it does not make
  191. sense to set this globally.")
  192. (defcustom org-export-skip-text-before-1st-heading nil
  193. "Non-nil means skip all text before the first headline when exporting.
  194. When nil, that text is exported as well."
  195. :group 'org-export-general
  196. :type 'boolean)
  197. (defcustom org-export-headline-levels 3
  198. "The last level which is still exported as a headline.
  199. Inferior levels will produce itemize lists when exported.
  200. Note that a numeric prefix argument to an exporter function overrides
  201. this setting.
  202. This option can also be set with the +OPTIONS line, e.g. \"H:2\"."
  203. :group 'org-export-general
  204. :type 'integer)
  205. (defcustom org-export-with-section-numbers t
  206. "Non-nil means add section numbers to headlines when exporting.
  207. This option can also be set with the +OPTIONS line, e.g. \"num:t\"."
  208. :group 'org-export-general
  209. :type 'boolean)
  210. (defcustom org-export-section-number-format '((("1" ".")) . "")
  211. "Format of section numbers for export.
  212. The variable has two components.
  213. 1. A list of lists, each indicating a counter type and a separator.
  214. The counter type can be any of \"1\", \"A\", \"a\", \"I\", or \"i\".
  215. It causes causes numeric, alphabetic, or roman counters, respectively.
  216. The separator is only used if another counter for a subsection is being
  217. added.
  218. If there are more numbered section levels than entries in this lists,
  219. then the last entry will be reused.
  220. 2. A terminator string that will be added after the entire
  221. section number."
  222. :group 'org-export-general
  223. :type '(cons
  224. (repeat
  225. (list
  226. (string :tag "Counter Type")
  227. (string :tag "Separator ")))
  228. (string :tag "Terminator")))
  229. (defcustom org-export-with-toc t
  230. "Non-nil means create a table of contents in exported files.
  231. The TOC contains headlines with levels up to`org-export-headline-levels'.
  232. When an integer, include levels up to N in the toc, this may then be
  233. different from `org-export-headline-levels', but it will not be allowed
  234. to be larger than the number of headline levels.
  235. When nil, no table of contents is made.
  236. Headlines which contain any TODO items will be marked with \"(*)\" in
  237. ASCII export, and with red color in HTML output, if the option
  238. `org-export-mark-todo-in-toc' is set.
  239. In HTML output, the TOC will be clickable.
  240. This option can also be set with the +OPTIONS line, e.g. \"toc:nil\"
  241. or \"toc:3\"."
  242. :group 'org-export-general
  243. :type '(choice
  244. (const :tag "No Table of Contents" nil)
  245. (const :tag "Full Table of Contents" t)
  246. (integer :tag "TOC to level")))
  247. (defcustom org-export-mark-todo-in-toc nil
  248. "Non-nil means mark TOC lines that contain any open TODO items."
  249. :group 'org-export-general
  250. :type 'boolean)
  251. (defcustom org-export-with-todo-keywords t
  252. "Non-nil means include TODO keywords in export.
  253. When nil, remove all these keywords from the export."
  254. :group 'org-export-general
  255. :type 'boolean)
  256. (defcustom org-export-with-priority nil
  257. "Non-nil means include priority cookies in export.
  258. When nil, remove priority cookies for export."
  259. :group 'org-export-general
  260. :type 'boolean)
  261. (defcustom org-export-preserve-breaks nil
  262. "Non-nil means preserve all line breaks when exporting.
  263. Normally, in HTML output paragraphs will be reformatted. In ASCII
  264. export, line breaks will always be preserved, regardless of this variable.
  265. This option can also be set with the +OPTIONS line, e.g. \"\\n:t\"."
  266. :group 'org-export-general
  267. :type 'boolean)
  268. (defcustom org-export-with-archived-trees 'headline
  269. "Whether subtrees with the ARCHIVE tag should be exported.
  270. This can have three different values
  271. nil Do not export, pretend this tree is not present
  272. t Do export the entire tree
  273. headline Only export the headline, but skip the tree below it."
  274. :group 'org-export-general
  275. :group 'org-archive
  276. :type '(choice
  277. (const :tag "not at all" nil)
  278. (const :tag "headline only" 'headline)
  279. (const :tag "entirely" t)))
  280. (defcustom org-export-author-info t
  281. "Non-nil means insert author name and email into the exported file.
  282. This option can also be set with the +OPTIONS line,
  283. e.g. \"author:nil\"."
  284. :group 'org-export-general
  285. :type 'boolean)
  286. (defcustom org-export-email-info nil
  287. "Non-nil means insert author name and email into the exported file.
  288. This option can also be set with the +OPTIONS line,
  289. e.g. \"email:t\"."
  290. :group 'org-export-general
  291. :type 'boolean)
  292. (defcustom org-export-creator-info t
  293. "Non-nil means the postamble should contain a creator sentence.
  294. This sentence is \"HTML generated by org-mode XX in emacs XXX\"."
  295. :group 'org-export-general
  296. :type 'boolean)
  297. (defcustom org-export-time-stamp-file t
  298. "Non-nil means insert a time stamp into the exported file.
  299. The time stamp shows when the file was created.
  300. This option can also be set with the +OPTIONS line,
  301. e.g. \"timestamp:nil\"."
  302. :group 'org-export-general
  303. :type 'boolean)
  304. (defcustom org-export-with-timestamps t
  305. "If nil, do not export time stamps and associated keywords."
  306. :group 'org-export-general
  307. :type 'boolean)
  308. (defcustom org-export-remove-timestamps-from-toc t
  309. "If t, remove timestamps from the table of contents entries."
  310. :group 'org-export-general
  311. :type 'boolean)
  312. (defcustom org-export-with-tags 'not-in-toc
  313. "If nil, do not export tags, just remove them from headlines.
  314. If this is the symbol `not-in-toc', tags will be removed from table of
  315. contents entries, but still be shown in the headlines of the document.
  316. This option can also be set with the +OPTIONS line, e.g. \"tags:nil\"."
  317. :group 'org-export-general
  318. :type '(choice
  319. (const :tag "Off" nil)
  320. (const :tag "Not in TOC" not-in-toc)
  321. (const :tag "On" t)))
  322. (defcustom org-export-with-drawers nil
  323. "Non-nil means export with drawers like the property drawer.
  324. When t, all drawers are exported. This may also be a list of
  325. drawer names to export."
  326. :group 'org-export-general
  327. :type '(choice
  328. (const :tag "All drawers" t)
  329. (const :tag "None" nil)
  330. (repeat :tag "Selected drawers"
  331. (string :tag "Drawer name"))))
  332. (defvar org-export-first-hook nil
  333. "Hook called as the first thing in each exporter.
  334. Point will be still in the original buffer.
  335. Good for general initialization")
  336. (defvar org-export-preprocess-hook nil
  337. "Hook for preprocessing an export buffer.
  338. Pretty much the first thing when exporting is running this hook.
  339. Point will be in a temporary buffer that contains a copy of
  340. the original buffer, or of the section that is being exported.
  341. All the other hooks in the org-export-preprocess... category
  342. also work in that temporary buffer, already modified by various
  343. stages of the processing.")
  344. (defvar org-export-preprocess-after-include-files-hook nil
  345. "Hook for preprocessing an export buffer.
  346. This is run after the contents of included files have been inserted.")
  347. (defvar org-export-preprocess-after-tree-selection-hook nil
  348. "Hook for preprocessing an export buffer.
  349. This is run after selection of trees to be exported has happened.
  350. This selection includes tags-based selection, as well as removal
  351. of commented and archived trees.")
  352. (defvar org-export-preprocess-after-headline-targets-hook nil
  353. "Hook for preprocessing export buffer.
  354. This is run just after the headline targets have been defined and
  355. the target-alist has been set up.")
  356. (defvar org-export-preprocess-before-selecting-backend-code-hook nil
  357. "Hook for preprocessing an export buffer.
  358. This is run just before backend-specific blocks get selected.")
  359. (defvar org-export-preprocess-after-blockquote-hook nil
  360. "Hook for preprocessing an export buffer.
  361. This is run after blockquote/quote/verse/center have been marked
  362. with cookies.")
  363. (defvar org-export-preprocess-after-radio-targets-hook nil
  364. "Hook for preprocessing an export buffer.
  365. This is run after radio target processing.")
  366. (defvar org-export-preprocess-before-normalizing-links-hook nil
  367. "Hook for preprocessing an export buffer.
  368. This hook is run before links are normalized.")
  369. (defvar org-export-preprocess-before-backend-specifics-hook nil
  370. "Hook run before backend-specific functions are called during preprocessing.")
  371. (defvar org-export-preprocess-final-hook nil
  372. "Hook for preprocessing an export buffer.
  373. This is run as the last thing in the preprocessing buffer, just before
  374. returning the buffer string to the backend.")
  375. (defgroup org-export-translation nil
  376. "Options for translating special ascii sequences for the export backends."
  377. :tag "Org Export Translation"
  378. :group 'org-export)
  379. (defcustom org-export-with-emphasize t
  380. "Non-nil means interpret *word*, /word/, and _word_ as emphasized text.
  381. If the export target supports emphasizing text, the word will be
  382. typeset in bold, italic, or underlined, respectively. Works only for
  383. single words, but you can say: I *really* *mean* *this*.
  384. Not all export backends support this.
  385. This option can also be set with the +OPTIONS line, e.g. \"*:nil\"."
  386. :group 'org-export-translation
  387. :type 'boolean)
  388. (defcustom org-export-with-footnotes t
  389. "If nil, export [1] as a footnote marker.
  390. Lines starting with [1] will be formatted as footnotes.
  391. This option can also be set with the +OPTIONS line, e.g. \"f:nil\"."
  392. :group 'org-export-translation
  393. :type 'boolean)
  394. (defcustom org-export-with-TeX-macros t
  395. "Non-nil means interpret simple TeX-like macros when exporting.
  396. For example, HTML export converts \\alpha to &alpha; and \\AA to &Aring;.
  397. Not only real TeX macros will work here, but the standard HTML entities
  398. for math can be used as macro names as well. For a list of supported
  399. names in HTML export, see the constant `org-entities' and the user option
  400. `org-entities-user'.
  401. Not all export backends support this.
  402. This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"."
  403. :group 'org-export-translation
  404. :group 'org-export-latex
  405. :type 'boolean)
  406. (defcustom org-export-with-LaTeX-fragments t
  407. "Non-nil means process LaTeX math fragments for HTML display.
  408. When set, the exporter will find and process LaTeX environments if the
  409. \\begin line is the first non-white thing on a line. It will also find
  410. and process the math delimiters like $a=b$ and \\( a=b \\) for inline math,
  411. $$a=b$$ and \\=\\[ a=b \\] for display math.
  412. This option can also be set with the +OPTIONS line, e.g. \"LaTeX:mathjax\".
  413. Allowed values are:
  414. nil Don't do anything.
  415. verbatim Keep everything in verbatim
  416. dvipng Process the LaTeX fragments to images.
  417. This will also include processing of non-math environments.
  418. t Do MathJax preprocessing if there is at least on math snippet,
  419. and arrange for MathJax.js to be loaded.
  420. The default is nil, because this option needs the `dvipng' program which
  421. is not available on all systems."
  422. :group 'org-export-translation
  423. :group 'org-export-latex
  424. :type '(choice
  425. (const :tag "Do not process math in any way" nil)
  426. (const :tag "Obsolete, use dvipng setting" t)
  427. (const :tag "Use dvipng to make images" dvipng)
  428. (const :tag "Use MathJax to display math" mathjax)
  429. (const :tag "Leave math verbatim" verbatim)))
  430. (defcustom org-export-with-fixed-width t
  431. "Non-nil means lines starting with \":\" will be in fixed width font.
  432. This can be used to have pre-formatted text, fragments of code etc. For
  433. example:
  434. : ;; Some Lisp examples
  435. : (while (defc cnt)
  436. : (ding))
  437. will be looking just like this in also HTML. See also the QUOTE keyword.
  438. Not all export backends support this.
  439. This option can also be set with the +OPTIONS line, e.g. \"::nil\"."
  440. :group 'org-export-translation
  441. :type 'boolean)
  442. (defgroup org-export-tables nil
  443. "Options for exporting tables in Org-mode."
  444. :tag "Org Export Tables"
  445. :group 'org-export)
  446. (defcustom org-export-with-tables t
  447. "If non-nil, lines starting with \"|\" define a table.
  448. For example:
  449. | Name | Address | Birthday |
  450. |-------------+----------+-----------|
  451. | Arthur Dent | England | 29.2.2100 |
  452. Not all export backends support this.
  453. This option can also be set with the +OPTIONS line, e.g. \"|:nil\"."
  454. :group 'org-export-tables
  455. :type 'boolean)
  456. (defcustom org-export-highlight-first-table-line t
  457. "Non-nil means highlight the first table line.
  458. In HTML export, this means use <th> instead of <td>.
  459. In tables created with table.el, this applies to the first table line.
  460. In Org-mode tables, all lines before the first horizontal separator
  461. line will be formatted with <th> tags."
  462. :group 'org-export-tables
  463. :type 'boolean)
  464. (defcustom org-export-table-remove-special-lines t
  465. "Remove special lines and marking characters in calculating tables.
  466. This removes the special marking character column from tables that are set
  467. up for spreadsheet calculations. It also removes the entire lines
  468. marked with `!', `_', or `^'. The lines with `$' are kept, because
  469. the values of constants may be useful to have."
  470. :group 'org-export-tables
  471. :type 'boolean)
  472. (defcustom org-export-table-remove-empty-lines t
  473. "Remove empty lines when exporting tables.
  474. This is the global equivalent of the :remove-nil-lines option
  475. when locally sending a table with #+ORGTBL."
  476. :group 'org-export-tables
  477. :type 'boolean)
  478. (defcustom org-export-prefer-native-exporter-for-tables nil
  479. "Non-nil means always export tables created with table.el natively.
  480. Natively means use the HTML code generator in table.el.
  481. When nil, Org-mode's own HTML generator is used when possible (i.e. if
  482. the table does not use row- or column-spanning). This has the
  483. advantage, that the automatic HTML conversions for math symbols and
  484. sub/superscripts can be applied. Org-mode's HTML generator is also
  485. much faster. The LaTeX exporter always use the native exporter for
  486. table.el tables."
  487. :group 'org-export-tables
  488. :type 'boolean)
  489. (defgroup org-export-xml nil
  490. "Options specific for XML export of Org-mode files."
  491. :tag "Org Export XML"
  492. :group 'org-export)
  493. ;;;; Exporting
  494. ;;; Variables, constants, and parameter plists
  495. (defconst org-level-max 20)
  496. (defvar org-export-current-backend nil
  497. "During export, this will be bound to a symbol such as 'html,
  498. 'latex, 'docbook, 'ascii, etc, indicating which of the export
  499. backends is in use. Otherwise it has the value nil. Users
  500. should not attempt to change the value of this variable
  501. directly, but it can be used in code to test whether export is
  502. in progress, and if so, what the backend is.")
  503. (defvar org-current-export-file nil) ; dynamically scoped parameter
  504. (defvar org-current-export-dir nil) ; dynamically scoped parameter
  505. (defvar org-export-opt-plist nil
  506. "Contains the current option plist.")
  507. (defvar org-last-level nil) ; dynamically scoped variable
  508. (defvar org-min-level nil) ; dynamically scoped variable
  509. (defvar org-levels-open nil) ; dynamically scoped parameter
  510. (defconst org-export-plist-vars
  511. '((:link-up nil org-export-html-link-up)
  512. (:link-home nil org-export-html-link-home)
  513. (:language nil org-export-default-language)
  514. (:keywords nil org-export-page-keywords)
  515. (:description nil org-export-page-description)
  516. (:customtime nil org-display-custom-times)
  517. (:headline-levels "H" org-export-headline-levels)
  518. (:section-numbers "num" org-export-with-section-numbers)
  519. (:section-number-format nil org-export-section-number-format)
  520. (:table-of-contents "toc" org-export-with-toc)
  521. (:preserve-breaks "\\n" org-export-preserve-breaks)
  522. (:archived-trees nil org-export-with-archived-trees)
  523. (:emphasize "*" org-export-with-emphasize)
  524. (:sub-superscript "^" org-export-with-sub-superscripts)
  525. (:special-strings "-" org-export-with-special-strings)
  526. (:footnotes "f" org-export-with-footnotes)
  527. (:drawers "d" org-export-with-drawers)
  528. (:tags "tags" org-export-with-tags)
  529. (:todo-keywords "todo" org-export-with-todo-keywords)
  530. (:priority "pri" org-export-with-priority)
  531. (:TeX-macros "TeX" org-export-with-TeX-macros)
  532. (:LaTeX-fragments "LaTeX" org-export-with-LaTeX-fragments)
  533. (:latex-listings nil org-export-latex-listings)
  534. (:skip-before-1st-heading "skip" org-export-skip-text-before-1st-heading)
  535. (:fixed-width ":" org-export-with-fixed-width)
  536. (:timestamps "<" org-export-with-timestamps)
  537. (:author nil user-full-name)
  538. (:email nil user-mail-address)
  539. (:author-info "author" org-export-author-info)
  540. (:email-info "email" org-export-email-info)
  541. (:creator-info "creator" org-export-creator-info)
  542. (:time-stamp-file "timestamp" org-export-time-stamp-file)
  543. (:tables "|" org-export-with-tables)
  544. (:table-auto-headline nil org-export-highlight-first-table-line)
  545. (:style-include-default nil org-export-html-style-include-default)
  546. (:style-include-scripts nil org-export-html-style-include-scripts)
  547. (:style nil org-export-html-style)
  548. (:style-extra nil org-export-html-style-extra)
  549. (:agenda-style nil org-agenda-export-html-style)
  550. (:convert-org-links nil org-export-html-link-org-files-as-html)
  551. (:inline-images nil org-export-html-inline-images)
  552. (:html-extension nil org-export-html-extension)
  553. (:html-preamble nil org-export-html-preamble)
  554. (:html-postamble nil org-export-html-postamble)
  555. (:xml-declaration nil org-export-html-xml-declaration)
  556. (:html-table-tag nil org-export-html-table-tag)
  557. (:expand-quoted-html "@" org-export-html-expand)
  558. (:timestamp nil org-export-html-with-timestamp)
  559. (:publishing-directory nil org-export-publishing-directory)
  560. (:select-tags nil org-export-select-tags)
  561. (:exclude-tags nil org-export-exclude-tags)
  562. (:latex-image-options nil org-export-latex-image-default-option))
  563. "List of properties that represent export/publishing variables.
  564. Each element is a list of 3 items:
  565. 1. The property that is used internally, and also for org-publish-project-alist
  566. 2. The string that can be used in the OPTION lines to set this option,
  567. or nil if this option cannot be changed in this way
  568. 3. The customization variable that sets the default for this option."
  569. )
  570. (defun org-default-export-plist ()
  571. "Return the property list with default settings for the export variables."
  572. (let* ((infile (org-infile-export-plist))
  573. (letbind (plist-get infile :let-bind))
  574. (l org-export-plist-vars) rtn e s v)
  575. (while (setq e (pop l))
  576. (setq s (nth 2 e)
  577. v (cond
  578. ((assq s letbind) (nth 1 (assq s letbind)))
  579. ((boundp s) (symbol-value s))
  580. (t nil))
  581. rtn (cons (car e) (cons v rtn))))
  582. rtn))
  583. (defvar org-export-inbuffer-options-extra nil
  584. "List of additional in-buffer options that should be detected.
  585. Just before export, the buffer is scanned for options like #+TITLE, #+EMAIL,
  586. etc. Extensions can add to this list to get their options detected, and they
  587. can then add a function to `org-export-options-filters' to process these
  588. options.
  589. Each element in this list must be a list, with the in-buffer keyword as car,
  590. and a property (a symbol) as the next element. All occurrences of the
  591. keyword will be found, the values concatenated with a space character
  592. in between, and the result stored in the export options property list.")
  593. (defvar org-export-options-filters nil
  594. "Functions to be called to finalize the export/publishing options.
  595. All these options are stored in a property list, and each of the functions
  596. in this hook gets a chance to modify this property list. Each function
  597. must accept the property list as an argument, and must return the (possibly
  598. modified) list.")
  599. ;; FIXME: should we fold case here?
  600. (defun org-infile-export-plist ()
  601. "Return the property list with file-local settings for export."
  602. (save-excursion
  603. (save-restriction
  604. (widen)
  605. (goto-char (point-min))
  606. (let ((re (org-make-options-regexp
  607. (append
  608. '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
  609. "MATHJAX"
  610. "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE"
  611. "LATEX_HEADER" "LATEX_CLASS"
  612. "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS"
  613. "KEYWORDS" "DESCRIPTION" "MACRO" "BIND" "XSLT")
  614. (mapcar 'car org-export-inbuffer-options-extra))))
  615. (case-fold-search t)
  616. p key val text options mathjax a pr style
  617. latex-header latex-class macros letbind
  618. ext-setup-or-nil setup-contents (start 0))
  619. (while (or (and ext-setup-or-nil
  620. (string-match re ext-setup-or-nil start)
  621. (setq start (match-end 0)))
  622. (and (setq ext-setup-or-nil nil start 0)
  623. (re-search-forward re nil t)))
  624. (setq key (upcase (org-match-string-no-properties 1 ext-setup-or-nil))
  625. val (org-match-string-no-properties 2 ext-setup-or-nil))
  626. (cond
  627. ((setq a (assoc key org-export-inbuffer-options-extra))
  628. (setq pr (nth 1 a))
  629. (setq p (plist-put p pr (concat (plist-get p pr) " " val))))
  630. ((string-equal key "TITLE") (setq p (plist-put p :title val)))
  631. ((string-equal key "AUTHOR")(setq p (plist-put p :author val)))
  632. ((string-equal key "EMAIL") (setq p (plist-put p :email val)))
  633. ((string-equal key "DATE") (setq p (plist-put p :date val)))
  634. ((string-equal key "KEYWORDS") (setq p (plist-put p :keywords val)))
  635. ((string-equal key "DESCRIPTION")
  636. (setq p (plist-put p :description val)))
  637. ((string-equal key "LANGUAGE") (setq p (plist-put p :language val)))
  638. ((string-equal key "STYLE")
  639. (setq style (concat style "\n" val)))
  640. ((string-equal key "LATEX_HEADER")
  641. (setq latex-header (concat latex-header "\n" val)))
  642. ((string-equal key "LATEX_CLASS")
  643. (setq latex-class val))
  644. ((string-equal key "TEXT")
  645. (setq text (if text (concat text "\n" val) val)))
  646. ((string-equal key "OPTIONS")
  647. (setq options (concat val " " options)))
  648. ((string-equal key "MATHJAX")
  649. (setq mathjax (concat val " " mathjax)))
  650. ((string-equal key "BIND")
  651. (push (read (concat "(" val ")")) letbind))
  652. ((string-equal key "XSLT")
  653. (setq p (plist-put p :xslt val)))
  654. ((string-equal key "LINK_UP")
  655. (setq p (plist-put p :link-up val)))
  656. ((string-equal key "LINK_HOME")
  657. (setq p (plist-put p :link-home val)))
  658. ((string-equal key "EXPORT_SELECT_TAGS")
  659. (setq p (plist-put p :select-tags (org-split-string val))))
  660. ((string-equal key "EXPORT_EXCLUDE_TAGS")
  661. (setq p (plist-put p :exclude-tags (org-split-string val))))
  662. ((string-equal key "MACRO")
  663. (push val macros))
  664. ((equal key "SETUPFILE")
  665. (setq setup-contents (org-file-contents
  666. (expand-file-name
  667. (org-remove-double-quotes
  668. (org-trim val)))
  669. 'noerror))
  670. (if (not ext-setup-or-nil)
  671. (setq ext-setup-or-nil setup-contents start 0)
  672. (setq ext-setup-or-nil
  673. (concat (substring ext-setup-or-nil 0 start)
  674. "\n" setup-contents "\n"
  675. (substring ext-setup-or-nil start)))))))
  676. (setq p (plist-put p :text text))
  677. (when (and letbind (org-export-confirm-letbind))
  678. (setq p (plist-put p :let-bind letbind)))
  679. (when style (setq p (plist-put p :style-extra style)))
  680. (when latex-header
  681. (setq p (plist-put p :latex-header-extra (substring latex-header 1))))
  682. (when latex-class
  683. (setq p (plist-put p :latex-class latex-class)))
  684. (when options
  685. (setq p (org-export-add-options-to-plist p options)))
  686. (when mathjax
  687. (setq p (plist-put p :mathjax mathjax)))
  688. ;; Add macro definitions
  689. (setq p (plist-put p :macro-date "(eval (format-time-string \"$1\"))"))
  690. (setq p (plist-put p :macro-time "(eval (format-time-string \"$1\"))"))
  691. (setq p (plist-put p :macro-property "(eval (org-entry-get nil \"$1\" 'selective))"))
  692. (setq p (plist-put
  693. p :macro-modification-time
  694. (and (buffer-file-name)
  695. (file-exists-p (buffer-file-name))
  696. (concat
  697. "(eval (format-time-string \"$1\" '"
  698. (prin1-to-string (nth 5 (file-attributes
  699. (buffer-file-name))))
  700. "))"))))
  701. (setq p (plist-put p :macro-input-file (and (buffer-file-name)
  702. (file-name-nondirectory
  703. (buffer-file-name)))))
  704. (while (setq val (pop macros))
  705. (when (string-match "^\\([-a-zA-Z0-9_]+\\)[ \t]+\\(.*?[ \t]*$\\)" val)
  706. (setq p (plist-put
  707. p (intern
  708. (concat ":macro-" (downcase (match-string 1 val))))
  709. (org-export-interpolate-newlines (match-string 2 val))))))
  710. p))))
  711. (defun org-export-interpolate-newlines (s)
  712. (while (string-match "\\\\n" s)
  713. (setq s (replace-match "\n" t t s)))
  714. s)
  715. (defvar org-export-allow-BIND-local nil)
  716. (defun org-export-confirm-letbind ()
  717. "Can we use #+BIND values during export?
  718. By default this will ask for confirmation by the user, to divert possible
  719. security risks."
  720. (cond
  721. ((not org-export-allow-BIND) nil)
  722. ((eq org-export-allow-BIND t) t)
  723. ((local-variable-p 'org-export-allow-BIND-local (current-buffer))
  724. org-export-allow-BIND-local)
  725. (t (org-set-local 'org-export-allow-BIND-local
  726. (yes-or-no-p "Allow BIND values in this buffer? ")))))
  727. (defun org-install-letbind ()
  728. "Install the values from #+BIND lines as local variables."
  729. (let ((letbind (plist-get org-export-opt-plist :let-bind))
  730. pair)
  731. (while (setq pair (pop letbind))
  732. (org-set-local (car pair) (nth 1 pair)))))
  733. (defun org-export-add-options-to-plist (p options)
  734. "Parse an OPTIONS line and set values in the property list P."
  735. (let (o)
  736. (when options
  737. (let ((op org-export-plist-vars))
  738. (while (setq o (pop op))
  739. (if (and (nth 1 o)
  740. (string-match (concat "\\<" (regexp-quote (nth 1 o))
  741. ":\\([^ \t\n\r;,.]*\\)")
  742. options))
  743. (setq p (plist-put p (car o)
  744. (car (read-from-string
  745. (match-string 1 options))))))))))
  746. p)
  747. (defun org-export-add-subtree-options (p pos)
  748. "Add options in subtree at position POS to property list P."
  749. (save-excursion
  750. (goto-char pos)
  751. (when (org-at-heading-p)
  752. (let (a)
  753. ;; This is actually read in `org-export-get-title-from-subtree'
  754. ;; (when (setq a (org-entry-get pos "EXPORT_TITLE"))
  755. ;; (setq p (plist-put p :title a)))
  756. (when (setq a (org-entry-get pos "EXPORT_TEXT"))
  757. (setq p (plist-put p :text a)))
  758. (when (setq a (org-entry-get pos "EXPORT_AUTHOR"))
  759. (setq p (plist-put p :author a)))
  760. (when (setq a (org-entry-get pos "EXPORT_DATE"))
  761. (setq p (plist-put p :date a)))
  762. (when (setq a (org-entry-get pos "EXPORT_OPTIONS"))
  763. (setq p (org-export-add-options-to-plist p a)))))
  764. p))
  765. (defun org-export-directory (type plist)
  766. (let* ((val (plist-get plist :publishing-directory))
  767. (dir (if (listp val)
  768. (or (cdr (assoc type val)) ".")
  769. val)))
  770. dir))
  771. (defun org-export-process-option-filters (plist)
  772. (let ((functions org-export-options-filters) f)
  773. (while (setq f (pop functions))
  774. (setq plist (funcall f plist))))
  775. plist)
  776. ;;;###autoload
  777. (defun org-export (&optional arg)
  778. "Export dispatcher for Org-mode.
  779. When `org-export-run-in-background' is non-nil, try to run the command
  780. in the background. This will be done only for commands that write
  781. to a file. For details see the docstring of `org-export-run-in-background'.
  782. The prefix argument ARG will be passed to the exporter. However, if
  783. ARG is a double universal prefix \\[universal-argument] \\[universal-argument], \
  784. that means to inverse the
  785. value of `org-export-run-in-background'.
  786. If `org-export-initial-scope' is set to 'subtree, try to export
  787. the current subtree, otherwise try to export the whole buffer.
  788. Pressing `1' will switch between these two options."
  789. (interactive "P")
  790. (let* ((bg (org-xor (equal arg '(16)) org-export-run-in-background))
  791. (subtree-p (or (org-region-active-p)
  792. (eq org-export-initial-scope 'subtree)))
  793. (help "[t] insert the export option template
  794. \[v] limit export to visible part of outline tree
  795. \[1] switch buffer/subtree export
  796. \[SPC] publish enclosing subtree (with LaTeX_CLASS or EXPORT_FILE_NAME prop)
  797. \[a/n/u] export as ASCII/Latin-1/UTF-8 [A/N/U] to temporary buffer
  798. \[h] export as HTML [H] to temporary buffer [R] export region
  799. \[b] export as HTML and open in browser
  800. \[l] export as LaTeX [L] to temporary buffer
  801. \[p] export as LaTeX and process to PDF [d] ... and open PDF file
  802. \[D] export as DocBook [V] export as DocBook, process to PDF, and open
  803. \[j] export as TaskJuggler [J] ... and open
  804. \[m] export as Freemind mind map
  805. \[x] export as XOXO
  806. \[g] export using Wes Hardaker's generic exporter
  807. \[i] export current file as iCalendar file
  808. \[I] export all agenda files as iCalendar files [c] ...as one combined file
  809. \[F] publish current file [P] publish current project
  810. \[X] publish a project... [E] publish every projects")
  811. (cmds
  812. '((?t org-insert-export-options-template nil)
  813. (?v org-export-visible nil)
  814. (?a org-export-as-ascii t)
  815. (?A org-export-as-ascii-to-buffer t)
  816. (?n org-export-as-latin1 t)
  817. (?N org-export-as-latin1-to-buffer t)
  818. (?u org-export-as-utf8 t)
  819. (?U org-export-as-utf8-to-buffer t)
  820. (?h org-export-as-html t)
  821. (?b org-export-as-html-and-open t)
  822. (?H org-export-as-html-to-buffer nil)
  823. (?R org-export-region-as-html nil)
  824. (?x org-export-as-xoxo t)
  825. (?g org-export-generic t)
  826. (?D org-export-as-docbook t)
  827. (?V org-export-as-docbook-pdf-and-open t)
  828. (?j org-export-as-taskjuggler t)
  829. (?J org-export-as-taskjuggler-and-open t)
  830. (?m org-export-as-freemind t)
  831. (?l org-export-as-latex t)
  832. (?p org-export-as-pdf t)
  833. (?d org-export-as-pdf-and-open t)
  834. (?L org-export-as-latex-to-buffer nil)
  835. (?i org-export-icalendar-this-file t)
  836. (?I org-export-icalendar-all-agenda-files t)
  837. (?c org-export-icalendar-combine-agenda-files t)
  838. (?F org-publish-current-file t)
  839. (?P org-publish-current-project t)
  840. (?X org-publish t)
  841. (?E org-publish-all t)))
  842. r1 r2 ass
  843. (cpos (point)) (cbuf (current-buffer)) bpos)
  844. (save-excursion
  845. (save-window-excursion
  846. (if subtree-p
  847. (message "Export subtree: ")
  848. (message "Export buffer: "))
  849. (delete-other-windows)
  850. (with-output-to-temp-buffer "*Org Export/Publishing Help*"
  851. (princ help))
  852. (org-fit-window-to-buffer (get-buffer-window
  853. "*Org Export/Publishing Help*"))
  854. (while (eq (setq r1 (read-char-exclusive)) ?1)
  855. (cond (subtree-p
  856. (setq subtree-p nil)
  857. (message "Export buffer: "))
  858. ((not subtree-p)
  859. (setq subtree-p t)
  860. (message "Export subtree: "))))
  861. (when (eq r1 ?\ )
  862. (let ((case-fold-search t))
  863. (if (re-search-backward
  864. "^[ \t]+\\(:latex_class:\\|:export_title:\\)[ \t]+\\S-"
  865. nil t)
  866. (progn
  867. (org-back-to-heading t)
  868. (setq subtree-p t)
  869. (setq bpos (point))
  870. (message "Select command (for subtree): ")
  871. (setq r1 (read-char-exclusive)))
  872. (error "No enclosing node with LaTeX_CLASS or EXPORT_FILE_NAME")
  873. )))))
  874. (redisplay)
  875. (and bpos (goto-char bpos))
  876. (setq r2 (if (< r1 27) (+ r1 96) r1))
  877. (unless (setq ass (assq r2 cmds))
  878. (error "No command associated with key %c" r1))
  879. (if (and bg (nth 2 ass)
  880. (not (buffer-base-buffer))
  881. (not (org-region-active-p)))
  882. ;; execute in background
  883. (let ((p (start-process
  884. (concat "Exporting " (file-name-nondirectory (buffer-file-name)))
  885. "*Org Processes*"
  886. (expand-file-name invocation-name invocation-directory)
  887. "-batch"
  888. "-l" user-init-file
  889. "--eval" "(require 'org-exp)"
  890. "--eval" "(setq org-wait .2)"
  891. (buffer-file-name)
  892. "-f" (symbol-name (nth 1 ass)))))
  893. (set-process-sentinel p 'org-export-process-sentinel)
  894. (message "Background process \"%s\": started" p))
  895. ;; background processing not requested, or not possible
  896. (if subtree-p (progn (org-mark-subtree) (activate-mark)))
  897. (call-interactively (nth 1 ass))
  898. (when (and bpos (get-buffer-window cbuf))
  899. (let ((cw (selected-window)))
  900. (select-window (get-buffer-window cbuf))
  901. (goto-char cpos)
  902. (deactivate-mark)
  903. (select-window cw))))))
  904. (defun org-export-process-sentinel (process status)
  905. (if (string-match "\n+\\'" status)
  906. (setq status (substring status 0 -1)))
  907. (message "Background process \"%s\": %s" process status))
  908. ;;; General functions for all backends
  909. (defvar org-export-target-aliases nil
  910. "Alist of targets with invisible aliases.")
  911. (defvar org-export-preferred-target-alist nil
  912. "Alist of section id's with preferred aliases.")
  913. (defvar org-export-id-target-alist nil
  914. "Alist of section id's with preferred aliases.")
  915. (defvar org-export-code-refs nil
  916. "Alist of code references and line numbers.")
  917. (defun org-export-preprocess-string (string &rest parameters)
  918. "Cleanup STRING so that that the true exported has a more consistent source.
  919. This function takes STRING, which should be a buffer-string of an org-file
  920. to export. It then creates a temporary buffer where it does its job.
  921. The result is then again returned as a string, and the exporter works
  922. on this string to produce the exported version."
  923. (interactive)
  924. (let* ((org-export-current-backend (plist-get parameters :for-backend))
  925. (archived-trees (plist-get parameters :archived-trees))
  926. (inhibit-read-only t)
  927. (drawers org-drawers)
  928. (outline-regexp "\\*+ ")
  929. (source-buffer (current-buffer))
  930. target-alist rtn)
  931. (setq org-export-target-aliases nil
  932. org-export-preferred-target-alist nil
  933. org-export-id-target-alist nil
  934. org-export-code-refs nil)
  935. (with-current-buffer (get-buffer-create " org-mode-tmp")
  936. (erase-buffer)
  937. (insert string)
  938. (setq case-fold-search t)
  939. (let ((inhibit-read-only t))
  940. (remove-text-properties (point-min) (point-max)
  941. '(read-only t)))
  942. ;; Remove license-to-kill stuff
  943. ;; The caller marks some stuff for killing, stuff that has been
  944. ;; used to create the page title, for example.
  945. (org-export-kill-licensed-text)
  946. (let ((org-inhibit-startup t)) (org-mode))
  947. (setq case-fold-search t)
  948. (org-clone-local-variables source-buffer "^\\(org-\\|orgtbl-\\)")
  949. (org-install-letbind)
  950. ;; Call the hook
  951. (run-hooks 'org-export-preprocess-hook)
  952. ;; Process the macros
  953. (org-export-preprocess-apply-macros)
  954. (run-hooks 'org-export-preprocess-after-macros-hook)
  955. (untabify (point-min) (point-max))
  956. ;; Handle include files, and call a hook
  957. (org-export-handle-include-files-recurse)
  958. (run-hooks 'org-export-preprocess-after-include-files-hook)
  959. ;; Get rid of archived trees
  960. (org-export-remove-archived-trees archived-trees)
  961. ;; Remove comment environment and comment subtrees
  962. (org-export-remove-comment-blocks-and-subtrees)
  963. ;; Get rid of excluded trees, and call a hook
  964. (org-export-handle-export-tags (plist-get parameters :select-tags)
  965. (plist-get parameters :exclude-tags))
  966. (run-hooks 'org-export-preprocess-after-tree-selection-hook)
  967. ;; Change lists ending. Other parts of export may insert blank
  968. ;; lines and lists' structure could be altered.
  969. (org-export-mark-list-end)
  970. ;; Export code blocks
  971. (org-export-blocks-preprocess)
  972. ;; Mark lists with properties
  973. (org-export-mark-list-properties)
  974. ;; Handle source code snippets
  975. (org-export-replace-src-segments-and-examples)
  976. ;; Protect short examples marked by a leading colon
  977. (org-export-protect-colon-examples)
  978. ;; Protected spaces
  979. (org-export-convert-protected-spaces)
  980. ;; Normalize footnotes
  981. (when (plist-get parameters :footnotes)
  982. (org-footnote-normalize nil t))
  983. ;; Find all headings and compute the targets for them
  984. (setq target-alist (org-export-define-heading-targets target-alist))
  985. (run-hooks 'org-export-preprocess-after-headline-targets-hook)
  986. ;; Find HTML special classes for headlines
  987. (org-export-remember-html-container-classes)
  988. ;; Get rid of drawers
  989. (org-export-remove-or-extract-drawers
  990. drawers (plist-get parameters :drawers))
  991. ;; Get the correct stuff before the first headline
  992. (when (plist-get parameters :skip-before-1st-heading)
  993. (goto-char (point-min))
  994. (when (re-search-forward "^\\(#.*\n\\)?\\*+[ \t]" nil t)
  995. (delete-region (point-min) (match-beginning 0))
  996. (goto-char (point-min))
  997. (insert "\n")))
  998. (when (plist-get parameters :add-text)
  999. (goto-char (point-min))
  1000. (insert (plist-get parameters :add-text) "\n"))
  1001. ;; Remove todo-keywords before exporting, if the user has requested so
  1002. (org-export-remove-headline-metadata parameters)
  1003. ;; Find targets in comments and move them out of comments,
  1004. ;; but mark them as targets that should be invisible
  1005. (setq target-alist (org-export-handle-invisible-targets target-alist))
  1006. ;; Select and protect backend specific stuff, throw away stuff
  1007. ;; that is specific for other backends
  1008. (run-hooks 'org-export-preprocess-before-selecting-backend-code-hook)
  1009. (org-export-select-backend-specific-text)
  1010. ;; Protect quoted subtrees
  1011. (org-export-protect-quoted-subtrees)
  1012. ;; Remove clock lines
  1013. (org-export-remove-clock-lines)
  1014. ;; Protect verbatim elements
  1015. (org-export-protect-verbatim)
  1016. ;; Blockquotes, verse, and center
  1017. (org-export-mark-blockquote-verse-center)
  1018. (run-hooks 'org-export-preprocess-after-blockquote-hook)
  1019. ;; Remove timestamps, if the user has requested so
  1020. (unless (plist-get parameters :timestamps)
  1021. (org-export-remove-timestamps))
  1022. ;; Attach captions to the correct object
  1023. (setq target-alist (org-export-attach-captions-and-attributes target-alist))
  1024. ;; Find matches for radio targets and turn them into internal links
  1025. (org-export-mark-radio-links)
  1026. (run-hooks 'org-export-preprocess-after-radio-targets-hook)
  1027. ;; Find all links that contain a newline and put them into a single line
  1028. (org-export-concatenate-multiline-links)
  1029. ;; Normalize links: Convert angle and plain links into bracket links
  1030. ;; and expand link abbreviations
  1031. (run-hooks 'org-export-preprocess-before-normalizing-links-hook)
  1032. (org-export-normalize-links)
  1033. ;; Find all internal links. If they have a fuzzy match (i.e. not
  1034. ;; a *dedicated* target match, let the link point to the
  1035. ;; corresponding section.
  1036. (org-export-target-internal-links target-alist)
  1037. ;; Find multiline emphasis and put them into single line
  1038. (when (plist-get parameters :emph-multiline)
  1039. (org-export-concatenate-multiline-emphasis))
  1040. ;; Remove special table lines, and store alignment information
  1041. (org-store-forced-table-alignment)
  1042. (when org-export-table-remove-special-lines
  1043. (org-export-remove-special-table-lines))
  1044. ;; Another hook
  1045. (run-hooks 'org-export-preprocess-before-backend-specifics-hook)
  1046. ;; Backend-specific preprocessing
  1047. (let* ((backend-name (symbol-name org-export-current-backend))
  1048. (f (intern (format "org-export-%s-preprocess" backend-name))))
  1049. (require (intern (concat "org-" backend-name)) nil)
  1050. (funcall f parameters))
  1051. ;; Remove or replace comments
  1052. (org-export-handle-comments (plist-get parameters :comments))
  1053. ;; Remove #+TBLFM and #+TBLNAME lines
  1054. (org-export-handle-table-metalines)
  1055. ;; Run the final hook
  1056. (run-hooks 'org-export-preprocess-final-hook)
  1057. (setq rtn (buffer-string)))
  1058. (kill-buffer " org-mode-tmp")
  1059. rtn))
  1060. (defun org-export-kill-licensed-text ()
  1061. "Remove all text that is marked with a :org-license-to-kill property."
  1062. (let (p)
  1063. (while (setq p (text-property-any (point-min) (point-max)
  1064. :org-license-to-kill t))
  1065. (delete-region
  1066. p (or (next-single-property-change p :org-license-to-kill)
  1067. (point-max))))))
  1068. (defvar org-export-define-heading-targets-headline-hook nil
  1069. "Hook that is run when a headline was matched during target search.
  1070. This is part of the preprocessing for export.")
  1071. (defun org-export-define-heading-targets (target-alist)
  1072. "Find all headings and define the targets for them.
  1073. The new targets are added to TARGET-ALIST, which is also returned.
  1074. Also find all ID and CUSTOM_ID properties and store them."
  1075. (goto-char (point-min))
  1076. (org-init-section-numbers)
  1077. (let ((re (concat "^" org-outline-regexp
  1078. "\\|"
  1079. "^[ \t]*:\\(ID\\|CUSTOM_ID\\):[ \t]*\\([^ \t\r\n]+\\)"))
  1080. level target last-section-target a id)
  1081. (while (re-search-forward re nil t)
  1082. (org-if-unprotected-at (match-beginning 0)
  1083. (if (match-end 2)
  1084. (progn
  1085. (setq id (org-match-string-no-properties 2))
  1086. (push (cons id target) target-alist)
  1087. (setq a (or (assoc last-section-target org-export-target-aliases)
  1088. (progn
  1089. (push (list last-section-target)
  1090. org-export-target-aliases)
  1091. (car org-export-target-aliases))))
  1092. (push (caar target-alist) (cdr a))
  1093. (when (equal (match-string 1) "CUSTOM_ID")
  1094. (if (not (assoc last-section-target
  1095. org-export-preferred-target-alist))
  1096. (push (cons last-section-target id)
  1097. org-export-preferred-target-alist)))
  1098. (when (equal (match-string 1) "ID")
  1099. (if (not (assoc last-section-target
  1100. org-export-id-target-alist))
  1101. (push (cons last-section-target (concat "ID-" id))
  1102. org-export-id-target-alist))))
  1103. (setq level (org-reduced-level
  1104. (save-excursion (goto-char (point-at-bol))
  1105. (org-outline-level))))
  1106. (setq target (org-solidify-link-text
  1107. (format "sec-%s" (replace-regexp-in-string
  1108. "\\." "_"
  1109. (org-section-number level)))))
  1110. (setq last-section-target target)
  1111. (push (cons target target) target-alist)
  1112. (add-text-properties
  1113. (point-at-bol) (point-at-eol)
  1114. (list 'target target))
  1115. (run-hooks 'org-export-define-heading-targets-headline-hook)))))
  1116. target-alist)
  1117. (defun org-export-handle-invisible-targets (target-alist)
  1118. "Find targets in comments and move them out of comments.
  1119. Mark them as invisible targets."
  1120. (let (target tmp a)
  1121. (goto-char (point-min))
  1122. (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t)
  1123. ;; Check if the line before or after is a headline with a target
  1124. (if (setq target (or (get-text-property (point-at-bol 0) 'target)
  1125. (get-text-property (point-at-bol 2) 'target)))
  1126. (progn
  1127. ;; use the existing target in a neighboring line
  1128. (setq tmp (match-string 2))
  1129. (replace-match "")
  1130. (and (looking-at "\n") (delete-char 1))
  1131. (push (cons (setq tmp (org-solidify-link-text tmp)) target)
  1132. target-alist)
  1133. (setq a (or (assoc target org-export-target-aliases)
  1134. (progn
  1135. (push (list target) org-export-target-aliases)
  1136. (car org-export-target-aliases))))
  1137. (push tmp (cdr a)))
  1138. ;; Make an invisible target
  1139. (replace-match "\\1(INVISIBLE)"))))
  1140. target-alist)
  1141. (defun org-export-target-internal-links (target-alist)
  1142. "Find all internal links and assign targets to them.
  1143. If a link has a fuzzy match (i.e. not a *dedicated* target match),
  1144. let the link point to the corresponding section.
  1145. This function also handles the id links, if they have a match in
  1146. the current file."
  1147. (goto-char (point-min))
  1148. (while (re-search-forward org-bracket-link-regexp nil t)
  1149. (org-if-unprotected-at (1+ (match-beginning 0))
  1150. (let* ((org-link-search-must-match-exact-headline t)
  1151. (md (match-data))
  1152. (desc (match-end 2))
  1153. (link (org-link-unescape (match-string 1)))
  1154. (slink (org-solidify-link-text link))
  1155. found props pos cref
  1156. (target
  1157. (cond
  1158. ((= (string-to-char link) ?#)
  1159. ;; user wants exactly this link
  1160. link)
  1161. ((cdr (assoc slink target-alist))
  1162. (or (cdr (assoc (assoc slink target-alist)
  1163. org-export-preferred-target-alist))
  1164. (cdr (assoc slink target-alist))))
  1165. ((and (string-match "^id:" link)
  1166. (cdr (assoc (substring link 3) target-alist))))
  1167. ((string-match "^(\\(.*\\))$" link)
  1168. (setq cref (match-string 1 link))
  1169. (concat "coderef:" cref))
  1170. ((string-match org-link-types-re link) nil)
  1171. ((or (file-name-absolute-p link)
  1172. (string-match "^\\." link))
  1173. nil)
  1174. (t
  1175. (let ((org-link-search-inhibit-query t))
  1176. (save-excursion
  1177. (setq found (condition-case nil (org-link-search link)
  1178. (error nil)))
  1179. (when (and found
  1180. (or (org-on-heading-p)
  1181. (not (eq found 'dedicated))))
  1182. (or (get-text-property (point) 'target)
  1183. (get-text-property
  1184. (max (point-min)
  1185. (1- (or (previous-single-property-change
  1186. (point) 'target) 0)))
  1187. 'target)))))))))
  1188. (when target
  1189. (set-match-data md)
  1190. (goto-char (match-beginning 1))
  1191. (setq props (text-properties-at (point)))
  1192. (delete-region (match-beginning 1) (match-end 1))
  1193. (setq pos (point))
  1194. (insert target)
  1195. (unless desc (insert "][" link))
  1196. (add-text-properties pos (point) props))))))
  1197. (defun org-export-remember-html-container-classes ()
  1198. "Store the HTML_CONTAINER_CLASS properties in a text property."
  1199. (goto-char (point-min))
  1200. (let (class)
  1201. (while (re-search-forward
  1202. "^[ \t]*:HTML_CONTAINER_CLASS:[ \t]+\\(.+\\)$" nil t)
  1203. (setq class (match-string 1))
  1204. (save-excursion
  1205. (org-back-to-heading t)
  1206. (put-text-property (point-at-bol) (point-at-eol) 'html-container-class class)))))
  1207. (defvar org-export-format-drawer-function nil
  1208. "Function to be called to format the contents of a drawer.
  1209. The function must accept three parameters:
  1210. NAME the drawer name, like \"PROPERTIES\"
  1211. CONTENT the content of the drawer.
  1212. You can check the export backend through `org-export-current-backend'.
  1213. The function should return the text to be inserted into the buffer.
  1214. If this is nil, `org-export-format-drawer' is used as a default.")
  1215. (defun org-export-remove-or-extract-drawers (all-drawers exp-drawers)
  1216. "Remove drawers, or extract and format the content.
  1217. ALL-DRAWERS is a list of all drawer names valid in the current buffer.
  1218. EXP-DRAWERS can be t to keep all drawer contents, or a list of drawers
  1219. whose content to keep. Any drawers that are in ALL-DRAWERS but not in
  1220. EXP-DRAWERS will be removed."
  1221. (goto-char (point-min))
  1222. (let ((re (concat "^[ \t]*:\\("
  1223. (mapconcat 'identity all-drawers "\\|")
  1224. "\\):[ \t]*$"))
  1225. name beg beg-content eol content)
  1226. (while (re-search-forward re nil t)
  1227. (org-if-unprotected
  1228. (setq name (match-string 1))
  1229. (setq beg (match-beginning 0)
  1230. beg-content (1+ (point-at-eol))
  1231. eol (point-at-eol))
  1232. (if (not (and (re-search-forward
  1233. "^\\([ \t]*:END:[ \t]*\n?\\)\\|^\\*+[ \t]" nil t)
  1234. (match-end 1)))
  1235. (goto-char eol)
  1236. (goto-char (match-beginning 0))
  1237. (and (looking-at ".*\n?") (replace-match ""))
  1238. (setq content (buffer-substring beg-content (point)))
  1239. (delete-region beg (point))
  1240. (when (or (eq exp-drawers t)
  1241. (member name exp-drawers))
  1242. (setq content (funcall (or org-export-format-drawer-function
  1243. 'org-export-format-drawer)
  1244. name content))
  1245. (insert content)))))))
  1246. (defun org-export-format-drawer (name content)
  1247. "Format the content of a drawer as a colon example."
  1248. (if (string-match "[ \t]+\\'" content)
  1249. (setq content (substring content (match-beginning 0))))
  1250. (while (string-match "\\`[ \t]*\n" content)
  1251. (setq content (substring content (match-end 0))))
  1252. (setq content (org-remove-indentation content))
  1253. (setq content (concat ": " (mapconcat 'identity
  1254. (org-split-string content "\n")
  1255. "\n: ")
  1256. "\n"))
  1257. (setq content (concat " : " (upcase name) "\n" content))
  1258. (org-add-props content nil 'org-protected t))
  1259. (defun org-export-handle-export-tags (select-tags exclude-tags)
  1260. "Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS.
  1261. Both arguments are lists of tags.
  1262. If any of SELECT-TAGS is found, all trees not marked by a SELECT-TAG
  1263. will be removed.
  1264. After that, all subtrees that are marked by EXCLUDE-TAGS will be
  1265. removed as well."
  1266. (remove-text-properties (point-min) (point-max) '(:org-delete t))
  1267. (let* ((re-sel (concat ":\\(" (mapconcat 'regexp-quote
  1268. select-tags "\\|")
  1269. "\\):"))
  1270. (re-excl (concat ":\\(" (mapconcat 'regexp-quote
  1271. exclude-tags "\\|")
  1272. "\\):"))
  1273. beg end cont)
  1274. (goto-char (point-min))
  1275. (when (and select-tags
  1276. (re-search-forward
  1277. (concat "^\\*+[ \t].*" re-sel "[^ \t\n]*[ \t]*$") nil t))
  1278. ;; At least one tree is marked for export, this means
  1279. ;; all the unmarked stuff needs to go.
  1280. ;; Dig out the trees that should be exported
  1281. (goto-char (point-min))
  1282. (outline-next-heading)
  1283. (setq beg (point))
  1284. (put-text-property beg (point-max) :org-delete t)
  1285. (while (re-search-forward re-sel nil t)
  1286. (when (org-on-heading-p)
  1287. (org-back-to-heading)
  1288. (remove-text-properties
  1289. (max (1- (point)) (point-min))
  1290. (setq cont (save-excursion (org-end-of-subtree t t)))
  1291. '(:org-delete t))
  1292. (while (and (org-up-heading-safe)
  1293. (get-text-property (point) :org-delete))
  1294. (remove-text-properties (max (1- (point)) (point-min))
  1295. (point-at-eol) '(:org-delete t)))
  1296. (goto-char cont))))
  1297. ;; Remove the trees explicitly marked for noexport
  1298. (when exclude-tags
  1299. (goto-char (point-min))
  1300. (while (re-search-forward re-excl nil t)
  1301. (when (org-at-heading-p)
  1302. (org-back-to-heading t)
  1303. (setq beg (point))
  1304. (org-end-of-subtree t t)
  1305. (delete-region beg (point))
  1306. (when (featurep 'org-inlinetask)
  1307. (org-inlinetask-remove-END-maybe)))))
  1308. ;; Remove everything that is now still marked for deletion
  1309. (goto-char (point-min))
  1310. (while (setq beg (text-property-any (point-min) (point-max) :org-delete t))
  1311. (setq end (or (next-single-property-change beg :org-delete)
  1312. (point-max)))
  1313. (delete-region beg end))))
  1314. (defun org-export-remove-archived-trees (export-archived-trees)
  1315. "Remove archived trees.
  1316. When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported.
  1317. When it is t, the entire archived tree will be exported.
  1318. When it is nil the entire tree including the headline will be removed
  1319. from the buffer."
  1320. (let ((re-archive (concat ":" org-archive-tag ":"))
  1321. a b)
  1322. (when (not (eq export-archived-trees t))
  1323. (goto-char (point-min))
  1324. (while (re-search-forward re-archive nil t)
  1325. (if (not (org-on-heading-p t))
  1326. (goto-char (point-at-eol))
  1327. (beginning-of-line 1)
  1328. (setq a (if export-archived-trees
  1329. (1+ (point-at-eol)) (point))
  1330. b (org-end-of-subtree t))
  1331. (if (> b a) (delete-region a b)))))))
  1332. (defun org-export-remove-headline-metadata (opts)
  1333. "Remove meta data from the headline, according to user options."
  1334. (let ((re org-complex-heading-regexp)
  1335. (todo (plist-get opts :todo-keywords))
  1336. (tags (plist-get opts :tags))
  1337. (pri (plist-get opts :priority))
  1338. (elts '(1 2 3 4 5))
  1339. (case-fold-search nil)
  1340. rpl)
  1341. (setq elts (delq nil (list 1 (if todo 2) (if pri 3) 4 (if tags 5))))
  1342. (when (or (not todo) (not tags) (not pri))
  1343. (goto-char (point-min))
  1344. (while (re-search-forward re nil t)
  1345. (org-if-unprotected
  1346. (setq rpl (mapconcat (lambda (i) (if (match-end i) (match-string i) ""))
  1347. elts " "))
  1348. (replace-match rpl t t))))))
  1349. (defun org-export-remove-timestamps ()
  1350. "Remove timestamps and keywords for export."
  1351. (goto-char (point-min))
  1352. (while (re-search-forward org-maybe-keyword-time-regexp nil t)
  1353. (backward-char 1)
  1354. (org-if-unprotected
  1355. (unless (save-match-data (org-at-table-p))
  1356. (replace-match "")
  1357. (beginning-of-line 1)
  1358. (if (looking-at "[- \t]*\\(=>[- \t0-9:]*\\)?[ \t]*\n")
  1359. (replace-match ""))))))
  1360. (defun org-export-remove-clock-lines ()
  1361. "Remove clock lines for export."
  1362. (goto-char (point-min))
  1363. (let ((re (concat "^[ \t]*" org-clock-string ".*\n?")))
  1364. (while (re-search-forward re nil t)
  1365. (org-if-unprotected
  1366. (replace-match "")))))
  1367. (defun org-export-protect-quoted-subtrees ()
  1368. "Mark quoted subtrees with the protection property."
  1369. (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>")))
  1370. (goto-char (point-min))
  1371. (while (re-search-forward re-quote nil t)
  1372. (goto-char (match-beginning 0))
  1373. (end-of-line 1)
  1374. (add-text-properties (point) (org-end-of-subtree t)
  1375. '(org-protected t)))))
  1376. (defun org-export-convert-protected-spaces ()
  1377. "Convert strings like \\____ to protected spaces in all backends."
  1378. (goto-char (point-min))
  1379. (while (re-search-forward "\\\\__+" nil t)
  1380. (org-if-unprotected-1
  1381. (replace-match
  1382. (org-add-props
  1383. (cond
  1384. ((eq org-export-current-backend 'latex)
  1385. (format "\\hspace{%dex}" (- (match-end 0) (match-beginning 0))))
  1386. ((eq org-export-current-backend 'html)
  1387. (org-add-props (match-string 0) nil
  1388. 'org-whitespace (- (match-end 0) (match-beginning 0))))
  1389. ;; ((eq org-export-current-backend 'docbook))
  1390. ((eq org-export-current-backend 'ascii)
  1391. (org-add-props (match-string 0) '(org-whitespace t)))
  1392. (t (make-string (- (match-end 0) (match-beginning 0)) ?\ )))
  1393. '(org-protected t))
  1394. t t))))
  1395. (defun org-export-protect-verbatim ()
  1396. "Mark verbatim snippets with the protection property."
  1397. (goto-char (point-min))
  1398. (while (re-search-forward org-verbatim-re nil t)
  1399. (org-if-unprotected
  1400. (add-text-properties (match-beginning 4) (match-end 4)
  1401. '(org-protected t org-verbatim-emph t))
  1402. (goto-char (1+ (match-end 4))))))
  1403. (defun org-export-protect-colon-examples ()
  1404. "Protect lines starting with a colon."
  1405. (goto-char (point-min))
  1406. (let ((re "^[ \t]*:\\([ \t]\\|$\\)") beg)
  1407. (while (re-search-forward re nil t)
  1408. (beginning-of-line 1)
  1409. (setq beg (point))
  1410. (while (looking-at re)
  1411. (end-of-line 1)
  1412. (or (eobp) (forward-char 1)))
  1413. (add-text-properties beg (if (bolp) (1- (point)) (point))
  1414. '(org-protected t)))))
  1415. (defun org-export-select-backend-specific-text ()
  1416. (let ((formatters
  1417. '((docbook "DOCBOOK" "BEGIN_DOCBOOK" "END_DOCBOOK")
  1418. (html "HTML" "BEGIN_HTML" "END_HTML")
  1419. (beamer "BEAMER" "BEGIN_BEAMER" "END_BEAMER")
  1420. (ascii "ASCII" "BEGIN_ASCII" "END_ASCII")
  1421. (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
  1422. (case-fold-search t)
  1423. fmt beg beg-content end end-content ind)
  1424. (while formatters
  1425. (setq fmt (pop formatters))
  1426. ;; Handle #+backend: stuff
  1427. (goto-char (point-min))
  1428. (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" (cadr fmt)
  1429. ":[ \t]*\\(.*\\)") nil t)
  1430. (if (not (eq (car fmt) org-export-current-backend))
  1431. (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
  1432. (replace-match "\\1\\2" t)
  1433. (add-text-properties
  1434. (point-at-bol) (min (1+ (point-at-eol)) (point-max))
  1435. `(org-protected t original-indentation ,ind))))
  1436. ;; Delete #+attr_Backend: stuff of another backend. Those
  1437. ;; matching the current backend will be taken care of by
  1438. ;; `org-export-attach-captions-and-attributes'
  1439. (goto-char (point-min))
  1440. (while (re-search-forward (concat "^\\([ \t]*\\)#\\+attr_" (cadr fmt)
  1441. ":[ \t]*\\(.*\\)") nil t)
  1442. (setq ind (org-get-indentation))
  1443. (when (not (eq (car fmt) org-export-current-backend))
  1444. (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
  1445. ;; Handle #+begin_backend and #+end_backend stuff
  1446. (goto-char (point-min))
  1447. (while (re-search-forward (concat "^[ \t]*#\\+" (caddr fmt) "\\>.*\n?")
  1448. nil t)
  1449. (setq beg (match-beginning 0) beg-content (match-end 0))
  1450. (setq ind (save-excursion (goto-char beg) (org-get-indentation)))
  1451. (when (re-search-forward (concat "^[ \t]*#\\+" (cadddr fmt) "\\>.*\n?")
  1452. nil t)
  1453. (setq end (match-end 0) end-content (match-beginning 0))
  1454. (if (eq (car fmt) org-export-current-backend)
  1455. ;; yes, keep this
  1456. (progn
  1457. (add-text-properties
  1458. beg-content end-content
  1459. `(org-protected t original-indentation ,ind))
  1460. (delete-region (match-beginning 0) (match-end 0))
  1461. (save-excursion
  1462. (goto-char beg)
  1463. (delete-region (point) (1+ (point-at-eol)))))
  1464. ;; No, this is for a different backend, kill it
  1465. (delete-region beg end)))))))
  1466. (defun org-export-mark-blockquote-verse-center ()
  1467. "Mark block quote and verse environments with special cookies.
  1468. These special cookies will later be interpreted by the backend."
  1469. ;; Blockquotes
  1470. (let (type t1 ind beg end beg1 end1 content)
  1471. (goto-char (point-min))
  1472. (while (re-search-forward
  1473. "^\\([ \t]*\\)#\\+\\(begin_\\(\\(block\\)?quote\\|verse\\|center\\)\\>.*\\)"
  1474. nil t)
  1475. (setq ind (length (match-string 1))
  1476. type (downcase (match-string 3))
  1477. t1 (if (equal type "quote") "blockquote" type))
  1478. (setq beg (match-beginning 0)
  1479. beg1 (1+ (match-end 0)))
  1480. (when (re-search-forward (concat "^[ \t]*#\\+end_" type "\\>.*") nil t)
  1481. (setq end1 (1- (match-beginning 0))
  1482. end (+ (point-at-eol) (if (looking-at "\n$") 1 0)))
  1483. (setq content (org-remove-indentation (buffer-substring beg1 end1)))
  1484. (setq content (concat "ORG-" (upcase t1) "-START\n"
  1485. content "\n"
  1486. "ORG-" (upcase t1) "-END\n"))
  1487. (delete-region beg end)
  1488. (insert (org-add-props content nil 'original-indentation ind))))))
  1489. (defun org-export-mark-list-end ()
  1490. "Mark all list endings with a special string."
  1491. (unless (eq org-export-current-backend 'ascii)
  1492. (mapc
  1493. (lambda (e)
  1494. ;; For each type allowing list export, find every list, remove
  1495. ;; ending regexp if needed, and insert org-list-end.
  1496. (goto-char (point-min))
  1497. (while (re-search-forward (org-item-beginning-re) nil t)
  1498. (when (eq (nth 2 (org-list-context)) e)
  1499. (let* ((struct (org-list-struct))
  1500. (bottom (org-list-get-bottom-point struct))
  1501. (top (point-at-bol))
  1502. (top-ind (org-list-get-ind top struct)))
  1503. (goto-char bottom)
  1504. (when (and (not (eq org-list-ending-method 'indent))
  1505. (looking-at org-list-end-re))
  1506. (replace-match ""))
  1507. (unless (bolp) (insert "\n"))
  1508. ;; As org-list-end is inserted at column 0, it would end
  1509. ;; by indentation any list. It can be problematic when
  1510. ;; there are lists within lists: the inner list end would
  1511. ;; also become the outer list end. To avoid this, text
  1512. ;; property `original-indentation' is added, as
  1513. ;; `org-list-struct' pays attention to it when reading a
  1514. ;; list.
  1515. (insert (org-add-props
  1516. "ORG-LIST-END-MARKER\n"
  1517. (list 'original-indentation top-ind)))))))
  1518. (cons nil org-list-export-context))))
  1519. (defun org-export-mark-list-properties ()
  1520. "Mark list with special properties.
  1521. These special properties will later be interpreted by the backend."
  1522. (let ((mark-list
  1523. (function
  1524. ;; Mark a list with 3 properties: `list-item' which is
  1525. ;; position at beginning of line, `list-struct' which is
  1526. ;; list structure, and `list-prevs' which is the alist of
  1527. ;; item and its predecessor. Leave point at list ending.
  1528. (lambda (ctxt)
  1529. (let* ((struct (org-list-struct))
  1530. (top (org-list-get-top-point struct))
  1531. (bottom (org-list-get-bottom-point struct))
  1532. (prevs (org-list-prevs-alist struct))
  1533. poi)
  1534. ;; Get every item and ending position, without dups and
  1535. ;; without bottom point of list.
  1536. (mapc (lambda (e)
  1537. (let ((pos (car e))
  1538. (end (nth 6 e)))
  1539. (unless (memq pos poi)
  1540. (push pos poi))
  1541. (unless (or (= end bottom) (memq end poi))
  1542. (push end poi))))
  1543. struct)
  1544. (setq poi (sort poi '<))
  1545. ;; For every point of interest, mark the whole line with
  1546. ;; its position in list.
  1547. (mapc
  1548. (lambda (e)
  1549. (goto-char e)
  1550. (add-text-properties (point-at-bol) (point-at-eol)
  1551. (list 'list-item (point-at-bol)
  1552. 'list-struct struct
  1553. 'list-prevs prevs)))
  1554. poi)
  1555. ;; Take care of bottom point. As babel may have inserted
  1556. ;; a new list in buffer, list ending isn't always
  1557. ;; marked. Now mark every list ending and add properties
  1558. ;; useful to line processing exporters.
  1559. (goto-char bottom)
  1560. (when (or (looking-at "^ORG-LIST-END-MARKER\n")
  1561. (and (not (eq org-list-ending-method 'indent))
  1562. (looking-at org-list-end-re)))
  1563. (replace-match ""))
  1564. (unless (bolp) (insert "\n"))
  1565. (insert
  1566. (org-add-props "ORG-LIST-END-MARKER\n" (list 'list-item bottom
  1567. 'list-struct struct
  1568. 'list-prevs prevs)))
  1569. ;; Following property is used by LaTeX exporter.
  1570. (add-text-properties top (point) (list 'list-context ctxt)))))))
  1571. ;; Mark lists except for backends not interpreting them.
  1572. (unless (eq org-export-current-backend 'ascii)
  1573. (let ((org-list-end-re "^ORG-LIST-END-MARKER\n"))
  1574. (mapc
  1575. (lambda (e)
  1576. (goto-char (point-min))
  1577. (while (re-search-forward (org-item-beginning-re) nil t)
  1578. (when (eq (nth 2 (org-list-context)) e) (funcall mark-list e))))
  1579. (cons nil org-list-export-context))))))
  1580. (defun org-export-attach-captions-and-attributes (target-alist)
  1581. "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties.
  1582. If the next thing following is a table, add the text properties to the first
  1583. table line. If it is a link, add it to the line containing the link."
  1584. (goto-char (point-min))
  1585. (remove-text-properties (point-min) (point-max)
  1586. '(org-caption nil org-attributes nil))
  1587. (let ((case-fold-search t)
  1588. (re (concat "^[ \t]*#\\+caption:[ \t]+\\(.*\\)"
  1589. "\\|"
  1590. "^[ \t]*#\\+attr_" (symbol-name org-export-current-backend) ":[ \t]+\\(.*\\)"
  1591. "\\|"
  1592. "^[ \t]*#\\+label:[ \t]+\\(.*\\)"
  1593. "\\|"
  1594. "^[ \t]*\\(|[^-]\\)"
  1595. "\\|"
  1596. "^[ \t]*\\[\\[.*\\]\\][ \t]*$"))
  1597. cap shortn attr label end)
  1598. (while (re-search-forward re nil t)
  1599. (cond
  1600. ;; there is a caption
  1601. ((match-end 1)
  1602. (progn
  1603. (setq cap (concat cap (if cap " " "") (org-trim (match-string 1))))
  1604. (when (string-match "\\[\\(.*\\)\\]{\\(.*\\)}" cap)
  1605. (setq shortn (match-string 1 cap)
  1606. cap (match-string 2 cap)))
  1607. (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
  1608. ;; there is an attribute
  1609. ((match-end 2)
  1610. (progn
  1611. (setq attr (concat attr (if attr " " "") (org-trim (match-string 2))))
  1612. (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
  1613. ;; there is a label
  1614. ((match-end 3)
  1615. (progn
  1616. (setq label (org-trim (match-string 3)))
  1617. (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
  1618. (t
  1619. (setq end (if (match-end 4)
  1620. (let ((ee (org-table-end)))
  1621. (prog1 (1- (marker-position ee)) (move-marker ee nil)))
  1622. (point-at-eol)))
  1623. (add-text-properties (point-at-bol) end
  1624. (list 'org-caption cap
  1625. 'org-caption-shortn shortn
  1626. 'org-attributes attr
  1627. 'org-label label))
  1628. (if label (push (cons label label) target-alist))
  1629. (goto-char end)
  1630. (setq cap nil attr nil label nil)))))
  1631. target-alist)
  1632. (defun org-export-remove-comment-blocks-and-subtrees ()
  1633. "Remove the comment environment, and also commented subtrees."
  1634. (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>"))
  1635. case-fold-search)
  1636. ;; Remove comment environment
  1637. (goto-char (point-min))
  1638. (setq case-fold-search t)
  1639. (while (re-search-forward
  1640. "^#\\+begin_comment[ \t]*\n[^\000]*?^#\\+end_comment\\>.*" nil t)
  1641. (replace-match "" t t))
  1642. ;; Remove subtrees that are commented
  1643. (goto-char (point-min))
  1644. (setq case-fold-search nil)
  1645. (while (re-search-forward re-commented nil t)
  1646. (goto-char (match-beginning 0))
  1647. (delete-region (point) (org-end-of-subtree t)))))
  1648. (defun org-export-handle-comments (commentsp)
  1649. "Remove comments, or convert to backend-specific format.
  1650. COMMENTSP can be a format string for publishing comments.
  1651. When it is nil, all comments will be removed."
  1652. (let ((re "^\\(#\\|[ \t]*#\\+ \\)\\(.*\n?\\)")
  1653. pos)
  1654. (goto-char (point-min))
  1655. (while (or (looking-at re)
  1656. (re-search-forward re nil t))
  1657. (setq pos (match-beginning 0))
  1658. (if (get-text-property pos 'org-protected)
  1659. (goto-char (1+ pos))
  1660. (if (and commentsp
  1661. (not (equal (char-before (match-end 1)) ?+)))
  1662. (progn (add-text-properties
  1663. (match-beginning 0) (match-end 0) '(org-protected t))
  1664. (replace-match (format commentsp (match-string 2)) t t))
  1665. (goto-char (1+ pos))
  1666. (replace-match "")
  1667. (goto-char (max (point-min) (1- pos))))))))
  1668. (defun org-export-handle-table-metalines ()
  1669. "Remove table specific metalines #+TBLNAME: and #+TBLFM:."
  1670. (let ((re "^[ \t]*#\\+TBL\\(NAME\\|FM\\):\\(.*\n?\\)")
  1671. pos)
  1672. (goto-char (point-min))
  1673. (while (or (looking-at re)
  1674. (re-search-forward re nil t))
  1675. (setq pos (match-beginning 0))
  1676. (if (get-text-property (match-beginning 1) 'org-protected)
  1677. (goto-char (1+ pos))
  1678. (goto-char (1+ pos))
  1679. (replace-match "")
  1680. (goto-char (max (point-min) (1- pos)))))))
  1681. (defun org-export-mark-radio-links ()
  1682. "Find all matches for radio targets and turn them into internal links."
  1683. (let ((re-radio (and org-target-link-regexp
  1684. (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)"))))
  1685. (goto-char (point-min))
  1686. (when re-radio
  1687. (while (re-search-forward re-radio nil t)
  1688. (unless
  1689. (save-match-data
  1690. (or (org-in-regexp org-bracket-link-regexp)
  1691. (org-in-regexp org-plain-link-re)
  1692. (org-in-regexp "<<[^<>]+>>")))
  1693. (org-if-unprotected
  1694. (replace-match "\\1[[\\2]]")))))))
  1695. (defun org-store-forced-table-alignment ()
  1696. "Find table lines which force alignment, store the results in properties."
  1697. (let (line cnt aligns)
  1698. (goto-char (point-min))
  1699. (while (re-search-forward "|[ \t]*<[lrc][0-9]*>[ \t]*|" nil t)
  1700. ;; OK, this looks like a table line with an alignment cookie
  1701. (org-if-unprotected
  1702. (setq line (buffer-substring (point-at-bol) (point-at-eol)))
  1703. (when (and (org-at-table-p)
  1704. (org-table-cookie-line-p line))
  1705. (setq cnt 0 aligns nil)
  1706. (mapc
  1707. (lambda (x)
  1708. (setq cnt (1+ cnt))
  1709. (if (string-match "\\`<\\([lrc]\\)" x)
  1710. (push (cons cnt (downcase (match-string 1 x))) aligns)))
  1711. (org-split-string line "[ \t]*|[ \t]*"))
  1712. (add-text-properties (org-table-begin) (org-table-end)
  1713. (list 'org-forced-aligns aligns))))
  1714. (goto-char (point-at-eol)))))
  1715. (defun org-export-remove-special-table-lines ()
  1716. "Remove tables lines that are used for internal purposes.
  1717. Also, store forced alignment information found in such lines."
  1718. (goto-char (point-min))
  1719. (while (re-search-forward "^[ \t]*|" nil t)
  1720. (org-if-unprotected-at (1- (point))
  1721. (beginning-of-line 1)
  1722. (if (or (looking-at "[ \t]*| *[!_^] *|")
  1723. (not
  1724. (memq
  1725. nil
  1726. (mapcar
  1727. (lambda (f)
  1728. (or (and org-export-table-remove-empty-lines (= (length f) 0))
  1729. (string-match
  1730. "\\`<\\([0-9]\\|[lrc]\\|[lrc][0-9]+\\)>\\'" f)))
  1731. (org-split-string ;; FIXME, can't we do without splitting???
  1732. (buffer-substring (point-at-bol) (point-at-eol))
  1733. "[ \t]*|[ \t]*")))))
  1734. (delete-region (max (point-min) (1- (point-at-bol)))
  1735. (point-at-eol))
  1736. (end-of-line 1)))))
  1737. (defun org-export-protect-sub-super (s)
  1738. (save-match-data
  1739. (while (string-match "\\([^\\\\]\\)\\([_^]\\)" s)
  1740. (setq s (replace-match "\\1\\\\\\2" nil nil s)))
  1741. s))
  1742. (defun org-export-normalize-links ()
  1743. "Convert all links to bracket links, and expand link abbreviations."
  1744. (let ((re-plain-link (concat "\\([^[<]\\)" org-plain-link-re))
  1745. (re-angle-link (concat "\\([^[]\\)" org-angle-link-re))
  1746. nodesc)
  1747. (goto-char (point-min))
  1748. (while (re-search-forward re-plain-link nil t)
  1749. (unless (org-string-match-p
  1750. "\\[\\[\\S-+:\\S-*?\\<"
  1751. (buffer-substring (point-at-bol) (match-beginning 0)))
  1752. (goto-char (1- (match-end 0)))
  1753. (org-if-unprotected-at (1+ (match-beginning 0))
  1754. (let* ((s (concat (match-string 1)
  1755. "[[" (match-string 2) ":" (match-string 3)
  1756. "][" (match-string 2) ":" (org-export-protect-sub-super
  1757. (match-string 3))
  1758. "]]")))
  1759. ;; added 'org-link face to links
  1760. (put-text-property 0 (length s) 'face 'org-link s)
  1761. (replace-match s t t)))))
  1762. (goto-char (point-min))
  1763. (while (re-search-forward re-angle-link nil t)
  1764. (goto-char (1- (match-end 0)))
  1765. (org-if-unprotected
  1766. (let* ((s (concat (match-string 1)
  1767. "[[" (match-string 2) ":" (match-string 3)
  1768. "][" (match-string 2) ":" (org-export-protect-sub-super
  1769. (match-string 3))
  1770. "]]")))
  1771. (put-text-property 0 (length s) 'face 'org-link s)
  1772. (replace-match s t t))))
  1773. (goto-char (point-min))
  1774. (while (re-search-forward org-bracket-link-regexp nil t)
  1775. (goto-char (1- (match-end 0)))
  1776. (setq nodesc (not (match-end 3)))
  1777. (org-if-unprotected
  1778. (let* ((xx (save-match-data
  1779. (org-translate-link
  1780. (org-link-expand-abbrev (match-string 1)))))
  1781. (s (concat
  1782. "[[" (org-add-props (copy-sequence xx)
  1783. nil 'org-protected t 'org-no-description nodesc)
  1784. "]"
  1785. (if (match-end 3)
  1786. (match-string 2)
  1787. (concat "[" (copy-sequence xx)
  1788. "]"))
  1789. "]")))
  1790. (put-text-property 0 (length s) 'face 'org-link s)
  1791. (replace-match s t t))))))
  1792. (defun org-export-concatenate-multiline-links ()
  1793. "Find multi-line links and put it all into a single line.
  1794. This is to make sure that the line-processing export backends
  1795. can work correctly."
  1796. (goto-char (point-min))
  1797. (while (re-search-forward "\\(\\(\\[\\|\\]\\)\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\(\\[\\|\\]\\)\\)" nil t)
  1798. (org-if-unprotected-at (match-beginning 1)
  1799. (replace-match "\\1 \\3")
  1800. (goto-char (match-beginning 0)))))
  1801. (defun org-export-concatenate-multiline-emphasis ()
  1802. "Find multi-line emphasis and put it all into a single line.
  1803. This is to make sure that the line-processing export backends
  1804. can work correctly."
  1805. (goto-char (point-min))
  1806. (while (re-search-forward org-emph-re nil t)
  1807. (if (and (not (= (char-after (match-beginning 3))
  1808. (char-after (match-beginning 4))))
  1809. (save-excursion (goto-char (match-beginning 0))
  1810. (save-match-data
  1811. (and (not (org-at-table-p))
  1812. (not (org-at-heading-p))))))
  1813. (org-if-unprotected
  1814. (subst-char-in-region (match-beginning 0) (match-end 0)
  1815. ?\n ?\ t)
  1816. (goto-char (1- (match-end 0))))
  1817. (goto-char (1+ (match-beginning 0))))))
  1818. (defun org-export-grab-title-from-buffer ()
  1819. "Get a title for the current document, from looking at the buffer."
  1820. (let ((inhibit-read-only t))
  1821. (save-excursion
  1822. (goto-char (point-min))
  1823. (let ((end (if (looking-at org-outline-regexp)
  1824. (point)
  1825. (save-excursion (outline-next-heading) (point)))))
  1826. (when (re-search-forward "^[ \t]*[^|# \t\r\n].*\n" end t)
  1827. ;; Mark the line so that it will not be exported as normal text.
  1828. (org-unmodified
  1829. (add-text-properties (match-beginning 0) (match-end 0)
  1830. (list :org-license-to-kill t)))
  1831. ;; Return the title string
  1832. (org-trim (match-string 0)))))))
  1833. (defun org-export-get-title-from-subtree ()
  1834. "Return subtree title and exclude it from export."
  1835. (let ((rbeg (region-beginning)) (rend (region-end))
  1836. (inhibit-read-only t) title)
  1837. (save-excursion
  1838. (goto-char rbeg)
  1839. (when (and (org-at-heading-p)
  1840. (>= (org-end-of-subtree t t) rend))
  1841. ;; This is a subtree, we take the title from the first heading
  1842. (goto-char rbeg)
  1843. (looking-at org-todo-line-regexp)
  1844. (setq title (match-string 3))
  1845. (org-unmodified
  1846. (add-text-properties (point) (1+ (point-at-eol))
  1847. (list :org-license-to-kill t)))
  1848. (setq title (or (org-entry-get nil "EXPORT_TITLE") title))))
  1849. title))
  1850. (defun org-solidify-link-text (s &optional alist)
  1851. "Take link text and make a safe target out of it."
  1852. (save-match-data
  1853. (let* ((rtn
  1854. (mapconcat
  1855. 'identity
  1856. (org-split-string s "[^a-zA-Z0-9_\\.-]+") "--"))
  1857. (a (assoc rtn alist)))
  1858. (or (cdr a) rtn))))
  1859. (defun org-get-min-level (lines &optional offset)
  1860. "Get the minimum level in LINES."
  1861. (let ((re "^\\(\\*+\\) ") l)
  1862. (catch 'exit
  1863. (while (setq l (pop lines))
  1864. (if (string-match re l)
  1865. (throw 'exit (org-tr-level (- (length (match-string 1 l))
  1866. (or offset 0))))))
  1867. 1)))
  1868. ;; Variable holding the vector with section numbers
  1869. (defvar org-section-numbers (make-vector org-level-max 0))
  1870. (defun org-init-section-numbers ()
  1871. "Initialize the vector for the section numbers."
  1872. (let* ((level -1)
  1873. (numbers (nreverse (org-split-string "" "\\.")))
  1874. (depth (1- (length org-section-numbers)))
  1875. (i depth) number-string)
  1876. (while (>= i 0)
  1877. (if (> i level)
  1878. (aset org-section-numbers i 0)
  1879. (setq number-string (or (car numbers) "0"))
  1880. (if (string-match "\\`[A-Z]\\'" number-string)
  1881. (aset org-section-numbers i
  1882. (- (string-to-char number-string) ?A -1))
  1883. (aset org-section-numbers i (string-to-number number-string)))
  1884. (pop numbers))
  1885. (setq i (1- i)))))
  1886. (defun org-section-number (&optional level)
  1887. "Return a string with the current section number.
  1888. When LEVEL is non-nil, increase section numbers on that level."
  1889. (let* ((depth (1- (length org-section-numbers)))
  1890. (string "")
  1891. (fmts (car org-export-section-number-format))
  1892. (term (cdr org-export-section-number-format))
  1893. (sep "")
  1894. ctype fmt idx n)
  1895. (when level
  1896. (when (> level -1)
  1897. (aset org-section-numbers
  1898. level (1+ (aref org-section-numbers level))))
  1899. (setq idx (1+ level))
  1900. (while (<= idx depth)
  1901. (if (not (= idx 1))
  1902. (aset org-section-numbers idx 0))
  1903. (setq idx (1+ idx))))
  1904. (setq idx 0)
  1905. (while (<= idx depth)
  1906. (when (> (aref org-section-numbers idx) 0)
  1907. (setq fmt (or (pop fmts) fmt)
  1908. ctype (car fmt)
  1909. n (aref org-section-numbers idx)
  1910. string (if (> n 0)
  1911. (concat string sep (org-number-to-counter n ctype))
  1912. (concat string ".0"))
  1913. sep (nth 1 fmt)))
  1914. (setq idx (1+ idx)))
  1915. (save-match-data
  1916. (if (string-match "\\`\\([@0]\\.\\)+" string)
  1917. (setq string (replace-match "" t nil string)))
  1918. (if (string-match "\\(\\.0\\)+\\'" string)
  1919. (setq string (replace-match "" t nil string))))
  1920. (concat string term)))
  1921. (defun org-number-to-counter (n type)
  1922. "Concert number N to a string counter, according to TYPE.
  1923. TYPE must be a string, any of:
  1924. 1 number
  1925. A A,B,....
  1926. a a,b,....
  1927. I upper case roman numeral
  1928. i lower case roman numeral"
  1929. (cond
  1930. ((equal type "1") (number-to-string n))
  1931. ((equal type "A") (char-to-string (+ ?A n -1)))
  1932. ((equal type "a") (char-to-string (+ ?a n -1)))
  1933. ((equal type "I") (org-number-to-roman n))
  1934. ((equal type "i") (downcase (org-number-to-roman n)))
  1935. (t (error "Invalid counter type `%s'" type))))
  1936. (defun org-number-to-roman (n)
  1937. "Convert integer N into a roman numeral."
  1938. (let ((roman '((1000 . "M") (900 . "CM") (500 . "D") (400 . "CD")
  1939. ( 100 . "C") ( 90 . "XC") ( 50 . "L") ( 40 . "XL")
  1940. ( 10 . "X") ( 9 . "IX") ( 5 . "V") ( 4 . "IV")
  1941. ( 1 . "I")))
  1942. (res ""))
  1943. (if (<= n 0)
  1944. (number-to-string n)
  1945. (while roman
  1946. (if (>= n (caar roman))
  1947. (setq n (- n (caar roman))
  1948. res (concat res (cdar roman)))
  1949. (pop roman)))
  1950. res)))
  1951. ;;; Macros
  1952. (defun org-export-preprocess-apply-macros ()
  1953. "Replace macro references."
  1954. (goto-char (point-min))
  1955. (let (sy val key args args2 s n)
  1956. (while (re-search-forward
  1957. "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\(([ \t\n]*\\([^\000]*?\\))\\)?}}}"
  1958. nil t)
  1959. (unless (save-match-data
  1960. (save-excursion
  1961. (goto-char (point-at-bol))
  1962. (looking-at "[ \t]*#\\+macro")))
  1963. (setq key (downcase (match-string 1))
  1964. args (match-string 3))
  1965. (when (setq val (or (plist-get org-export-opt-plist
  1966. (intern (concat ":macro-" key)))
  1967. (plist-get org-export-opt-plist
  1968. (intern (concat ":" key)))))
  1969. (save-match-data
  1970. (when args
  1971. (setq args (org-split-string args ",") args2 nil)
  1972. (while args
  1973. (while (string-match "\\\\\\'" (car args))
  1974. ;; repair bad splits
  1975. (setcar (cdr args) (concat (substring (car args) 0 -1)
  1976. "," (nth 1 args)))
  1977. (pop args))
  1978. (push (pop args) args2))
  1979. (setq args (mapcar 'org-trim (nreverse args2)))
  1980. (setq s 0)
  1981. (while (string-match "\\$\\([0-9]+\\)" val s)
  1982. (setq s (1+ (match-beginning 0))
  1983. n (string-to-number (match-string 1 val)))
  1984. (and (>= (length args) n)
  1985. (setq val (replace-match (nth (1- n) args) t t val)))))
  1986. (when (string-match "\\`(eval\\>" val)
  1987. (setq val (eval (read val))))
  1988. (if (and val (not (stringp val)))
  1989. (setq val (format "%s" val))))
  1990. (and (stringp val)
  1991. (prog1 (replace-match val t t)
  1992. (goto-char (match-beginning 0)))))))))
  1993. (defun org-export-apply-macros-in-string (s)
  1994. "Apply the macros in string S."
  1995. (when s
  1996. (with-temp-buffer
  1997. (insert s)
  1998. (org-export-preprocess-apply-macros)
  1999. (buffer-string))))
  2000. ;;; Include files
  2001. (defun org-export-handle-include-files ()
  2002. "Include the contents of include files, with proper formatting."
  2003. (let ((case-fold-search t)
  2004. params file markup lang start end prefix prefix1 switches all minlevel lines)
  2005. (goto-char (point-min))
  2006. (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t)
  2007. (setq params (read (concat "(" (match-string 1) ")"))
  2008. prefix (org-get-and-remove-property 'params :prefix)
  2009. prefix1 (org-get-and-remove-property 'params :prefix1)
  2010. minlevel (org-get-and-remove-property 'params :minlevel)
  2011. lines (org-get-and-remove-property 'params :lines)
  2012. file (org-symname-or-string (pop params))
  2013. markup (org-symname-or-string (pop params))
  2014. lang (and (member markup '("src" "SRC"))
  2015. (org-symname-or-string (pop params)))
  2016. switches (mapconcat '(lambda (x) (format "%s" x)) params " ")
  2017. start nil end nil)
  2018. (delete-region (match-beginning 0) (match-end 0))
  2019. (if (or (not file)
  2020. (not (file-exists-p file))
  2021. (not (file-readable-p file)))
  2022. (insert (format "CANNOT INCLUDE FILE %s" file))
  2023. (setq all (cons file all))
  2024. (when markup
  2025. (if (equal (downcase markup) "src")
  2026. (setq start (format "#+begin_src %s %s\n"
  2027. (or lang "fundamental")
  2028. (or switches ""))
  2029. end "#+end_src")
  2030. (setq start (format "#+begin_%s %s\n" markup switches)
  2031. end (format "#+end_%s" markup))))
  2032. (insert (or start ""))
  2033. (insert (org-get-file-contents (expand-file-name file)
  2034. prefix prefix1 markup minlevel lines))
  2035. (or (bolp) (newline))
  2036. (insert (or end ""))))
  2037. all))
  2038. (defun org-export-handle-include-files-recurse ()
  2039. "Recursively include files aborting on circular inclusion."
  2040. (let ((now (list org-current-export-file)) all)
  2041. (while now
  2042. (setq all (append now all))
  2043. (setq now (org-export-handle-include-files))
  2044. (let ((intersection
  2045. (delq nil
  2046. (mapcar (lambda (el) (when (member el all) el)) now))))
  2047. (when intersection
  2048. (error "Recursive #+INCLUDE: %S" intersection))))))
  2049. (defun org-get-file-contents (file &optional prefix prefix1 markup minlevel lines)
  2050. "Get the contents of FILE and return them as a string.
  2051. If PREFIX is a string, prepend it to each line. If PREFIX1
  2052. is a string, prepend it to the first line instead of PREFIX.
  2053. If MARKUP, don't protect org-like lines, the exporter will
  2054. take care of the block they are in. If LINES is a string
  2055. specifying a range of lines, include only those lines ."
  2056. (if (stringp markup) (setq markup (downcase markup)))
  2057. (with-temp-buffer
  2058. (insert-file-contents file)
  2059. (when lines
  2060. (let* ((lines (split-string lines "-"))
  2061. (lbeg (string-to-number (car lines)))
  2062. (lend (string-to-number (cadr lines)))
  2063. (beg (if (zerop lbeg) (point-min)
  2064. (goto-char (point-min))
  2065. (forward-line (1- lbeg))
  2066. (point)))
  2067. (end (if (zerop lend) (point-max)
  2068. (goto-char (point-min))
  2069. (forward-line (1- lend))
  2070. (point))))
  2071. (narrow-to-region beg end)))
  2072. (when (or prefix prefix1)
  2073. (goto-char (point-min))
  2074. (while (not (eobp))
  2075. (insert (or prefix1 prefix))
  2076. (setq prefix1 "")
  2077. (beginning-of-line 2)))
  2078. (buffer-string)
  2079. (when (member markup '("src" "example"))
  2080. (goto-char (point-min))
  2081. (while (re-search-forward "^\\([*#]\\|[ \t]*#\\+\\)" nil t)
  2082. (goto-char (match-beginning 0))
  2083. (insert ",")
  2084. (end-of-line 1)))
  2085. (when minlevel
  2086. (dotimes (lvl minlevel)
  2087. (org-map-region 'org-demote (point-min) (point-max))))
  2088. (buffer-string)))
  2089. (defun org-get-and-remove-property (listvar prop)
  2090. "Check if the value of LISTVAR contains PROP as a property.
  2091. If yes, return the value of that property (i.e. the element following
  2092. in the list) and remove property and value from the list in LISTVAR."
  2093. (let ((list (symbol-value listvar)) m v)
  2094. (when (setq m (member prop list))
  2095. (setq v (nth 1 m))
  2096. (if (equal (car list) prop)
  2097. (set listvar (cddr list))
  2098. (setcdr (nthcdr (- (length list) (length m) 1) list)
  2099. (cddr m))
  2100. (set listvar list)))
  2101. v))
  2102. (defun org-symname-or-string (s)
  2103. (if (symbolp s)
  2104. (if s (symbol-name s) s)
  2105. s))
  2106. ;;; Fontification and line numbers for code examples
  2107. (defvar org-export-last-code-line-counter-value 0)
  2108. (defun org-export-replace-src-segments-and-examples ()
  2109. "Replace source code segments with special code for export."
  2110. (setq org-export-last-code-line-counter-value 0)
  2111. (let ((case-fold-search t)
  2112. lang code trans opts indent caption)
  2113. (goto-char (point-min))
  2114. (while (re-search-forward
  2115. "\\(^\\([ \t]*\\)#\\+BEGIN_SRC:?\\([ \t]+\\([^ \t\n]+\\)\\)?\\(.*\\)\n\\([^\000]+?\n\\)[ \t]*#\\+END_SRC.*\n?\\)\\|\\(^\\([ \t]*\\)#\\+BEGIN_EXAMPLE:?\\(?:[ \t]+\\(.*\\)\\)?\n\\([^\000]+?\n\\)[ \t]*#\\+END_EXAMPLE.*\n?\\)"
  2116. nil t)
  2117. (if (match-end 1)
  2118. (if (not (match-string 4))
  2119. (error "Source block missing language specification: %s"
  2120. (let* ((body (match-string 6))
  2121. (nothing (message "body:%s" body))
  2122. (preview (or (and (string-match
  2123. "^[ \t]*\\([^\n\r]*\\)" body)
  2124. (match-string 1 body)) body)))
  2125. (if (> (length preview) 35)
  2126. (concat (substring preview 0 32) "...")
  2127. preview)))
  2128. ;; src segments
  2129. (setq lang (match-string 4)
  2130. opts (match-string 5)
  2131. code (match-string 6)
  2132. indent (length (match-string 2))
  2133. caption (get-text-property 0 'org-caption (match-string 0))))
  2134. (setq lang nil
  2135. opts (match-string 9)
  2136. code (match-string 10)
  2137. indent (length (match-string 8))
  2138. caption (get-text-property 0 'org-caption (match-string 0))))
  2139. (setq trans (org-export-format-source-code-or-example
  2140. lang code opts indent caption))
  2141. (replace-match trans t t))))
  2142. (defvar org-export-latex-verbatim-wrap) ;; defined in org-latex.el
  2143. (defvar org-export-latex-listings) ;; defined in org-latex.el
  2144. (defvar org-export-latex-listings-langs) ;; defined in org-latex.el
  2145. (defvar org-export-latex-listings-w-names) ;; defined in org-latex.el
  2146. (defvar org-export-latex-minted-langs) ;; defined in org-latex.el
  2147. (defvar org-export-latex-custom-lang-environments) ;; defined in org-latex.el
  2148. (defvar org-export-latex-listings-options) ;; defined in org-latex.el
  2149. (defvar org-export-latex-minted-options) ;; defined in org-latex.el
  2150. (defun org-export-format-source-code-or-example
  2151. (lang code &optional opts indent caption)
  2152. "Format CODE from language LANG and return it formatted for export.
  2153. If LANG is nil, do not add any fontification.
  2154. OPTS contains formatting options, like `-n' for triggering numbering lines,
  2155. and `+n' for continuing previous numbering.
  2156. Code formatting according to language currently only works for HTML.
  2157. Numbering lines works for all three major backends (html, latex, and ascii).
  2158. INDENT was the original indentation of the block."
  2159. (save-match-data
  2160. (let (num cont rtn rpllbl keepp textareap preserve-indentp cols rows fmt)
  2161. (setq opts (or opts "")
  2162. num (string-match "[-+]n\\>" opts)
  2163. cont (string-match "\\+n\\>" opts)
  2164. rpllbl (string-match "-r\\>" opts)
  2165. keepp (string-match "-k\\>" opts)
  2166. textareap (string-match "-t\\>" opts)
  2167. preserve-indentp (or org-src-preserve-indentation
  2168. (string-match "-i\\>" opts))
  2169. cols (if (string-match "-w[ \t]+\\([0-9]+\\)" opts)
  2170. (string-to-number (match-string 1 opts))
  2171. 80)
  2172. rows (if (string-match "-h[ \t]+\\([0-9]+\\)" opts)
  2173. (string-to-number (match-string 1 opts))
  2174. (org-count-lines code))
  2175. fmt (if (string-match "-l[ \t]+\"\\([^\"\n]+\\)\"" opts)
  2176. (match-string 1 opts)))
  2177. (when (and textareap (eq org-export-current-backend 'html))
  2178. ;; we cannot use numbering or highlighting.
  2179. (setq num nil cont nil lang nil))
  2180. (if keepp (setq rpllbl 'keep))
  2181. (setq rtn (if preserve-indentp code (org-remove-indentation code)))
  2182. (when (string-match "^," rtn)
  2183. (setq rtn (with-temp-buffer
  2184. (insert rtn)
  2185. ;; Free up the protected lines
  2186. (goto-char (point-min))
  2187. (while (re-search-forward "^," nil t)
  2188. (if (or (equal lang "org")
  2189. (save-match-data
  2190. (looking-at "\\([*#]\\|[ \t]*#\\+\\)")))
  2191. (replace-match ""))
  2192. (end-of-line 1))
  2193. (buffer-string))))
  2194. ;; Now backend-specific coding
  2195. (setq rtn
  2196. (cond
  2197. ((eq org-export-current-backend 'docbook)
  2198. (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
  2199. (concat "\n#+BEGIN_DOCBOOK\n"
  2200. (org-add-props (concat "<programlisting><![CDATA["
  2201. rtn
  2202. "]]></programlisting>\n")
  2203. '(org-protected t org-example t))
  2204. "#+END_DOCBOOK\n"))
  2205. ((eq org-export-current-backend 'html)
  2206. ;; We are exporting to HTML
  2207. (when lang
  2208. (if (featurep 'xemacs)
  2209. (require 'htmlize)
  2210. (require 'htmlize nil t))
  2211. (when (not (fboundp 'htmlize-region-for-paste))
  2212. ;; we do not have htmlize.el, or an old version of it
  2213. (setq lang nil)
  2214. (message
  2215. "htmlize.el 1.34 or later is needed for source code formatting")))
  2216. (if lang
  2217. (let* ((lang-m (when lang
  2218. (or (cdr (assoc lang org-src-lang-modes))
  2219. lang)))
  2220. (mode (and lang-m (intern
  2221. (concat
  2222. (if (symbolp lang-m)
  2223. (symbol-name lang-m)
  2224. lang-m)
  2225. "-mode"))))
  2226. (org-inhibit-startup t)
  2227. (org-startup-folded nil))
  2228. (setq rtn
  2229. (with-temp-buffer
  2230. (insert rtn)
  2231. (if (functionp mode)
  2232. (funcall mode)
  2233. (fundamental-mode))
  2234. (font-lock-fontify-buffer)
  2235. (org-src-mode)
  2236. (set-buffer-modified-p nil)
  2237. (org-export-htmlize-region-for-paste
  2238. (point-min) (point-max))))
  2239. (if (string-match "<pre\\([^>]*\\)>\n*" rtn)
  2240. (setq rtn
  2241. (concat
  2242. (if caption
  2243. (concat
  2244. "<div class=\"org-src-container\">"
  2245. (format
  2246. "<label class=\"org-src-name\">%s</label>"
  2247. caption))
  2248. "")
  2249. (replace-match
  2250. (format "<pre class=\"src src-%s\">\n" lang)
  2251. t t rtn)
  2252. (if caption "</div>" "")))))
  2253. (if textareap
  2254. (setq rtn (concat
  2255. (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">"
  2256. cols rows)
  2257. rtn "</textarea>\n</p>\n"))
  2258. (with-temp-buffer
  2259. (insert rtn)
  2260. (goto-char (point-min))
  2261. (while (re-search-forward "[<>&]" nil t)
  2262. (replace-match (cdr (assq (char-before)
  2263. '((?&."&amp;")(?<."&lt;")(?>."&gt;"))))
  2264. t t))
  2265. (setq rtn (buffer-string)))
  2266. (setq rtn (concat "<pre class=\"example\">\n" rtn "</pre>\n"))))
  2267. (unless textareap
  2268. (setq rtn (org-export-number-lines rtn 1 1 num cont rpllbl fmt)))
  2269. (if (string-match "\\(\\`<[^>]*>\\)\n" rtn)
  2270. (setq rtn (replace-match "\\1" t nil rtn)))
  2271. (concat "\n#+BEGIN_HTML\n" (org-add-props rtn '(org-protected t org-example t)) "\n#+END_HTML\n\n"))
  2272. ((eq org-export-current-backend 'latex)
  2273. (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
  2274. (concat
  2275. "#+BEGIN_LaTeX\n"
  2276. (org-add-props
  2277. (cond
  2278. ((and lang org-export-latex-listings)
  2279. (flet ((make-option-string
  2280. (pair)
  2281. (concat (first pair)
  2282. (if (> (length (second pair)) 0)
  2283. (concat "=" (second pair))))))
  2284. (let* ((lang-sym (intern lang))
  2285. (minted-p (eq org-export-latex-listings 'minted))
  2286. (listings-p (not minted-p))
  2287. (backend-lang
  2288. (or (cadr
  2289. (assq
  2290. lang-sym
  2291. (cond
  2292. (minted-p org-export-latex-minted-langs)
  2293. (listings-p org-export-latex-listings-langs))))
  2294. lang))
  2295. (custom-environment
  2296. (cadr
  2297. (assq
  2298. lang-sym
  2299. org-export-latex-custom-lang-environments))))
  2300. (concat
  2301. (when (and listings-p (not custom-environment))
  2302. (format
  2303. "\\lstset{%s}\n"
  2304. (mapconcat
  2305. #'make-option-string
  2306. (append org-export-latex-listings-options
  2307. `(("language" ,backend-lang))) ",")))
  2308. (when (and caption org-export-latex-listings-w-names)
  2309. (format
  2310. "\n%s $\\equiv$ \n"
  2311. (replace-regexp-in-string "_" "\\\\_" caption)))
  2312. (cond
  2313. (custom-environment
  2314. (format "\\begin{%s}\n%s\\end{%s}\n"
  2315. custom-environment rtn custom-environment))
  2316. (listings-p
  2317. (format "\\begin{%s}\n%s\\end{%s}\n"
  2318. "lstlisting" rtn "lstlisting"))
  2319. (minted-p
  2320. (format
  2321. "\\begin{minted}[%s]{%s}\n%s\\end{minted}\n"
  2322. (mapconcat #'make-option-string
  2323. org-export-latex-minted-options ",")
  2324. backend-lang rtn)))))))
  2325. (t (concat (car org-export-latex-verbatim-wrap)
  2326. rtn (cdr org-export-latex-verbatim-wrap))))
  2327. '(org-protected t org-example t))
  2328. "#+END_LaTeX\n"))
  2329. ((eq org-export-current-backend 'ascii)
  2330. ;; This is not HTML or LaTeX, so just make it an example.
  2331. (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
  2332. (concat caption "\n"
  2333. "#+BEGIN_ASCII\n"
  2334. (org-add-props
  2335. (concat
  2336. (mapconcat
  2337. (lambda (l) (concat " " l))
  2338. (org-split-string rtn "\n")
  2339. "\n")
  2340. "\n")
  2341. '(org-protected t org-example t))
  2342. "#+END_ASCII\n"))))
  2343. (org-add-props rtn nil 'original-indentation indent))))
  2344. (defun org-export-number-lines (text &optional skip1 skip2 number cont
  2345. replace-labels label-format)
  2346. (setq skip1 (or skip1 0) skip2 (or skip2 0))
  2347. (if (not cont) (setq org-export-last-code-line-counter-value 0))
  2348. (with-temp-buffer
  2349. (insert text)
  2350. (goto-char (point-max))
  2351. (skip-chars-backward " \t\n\r")
  2352. (delete-region (point) (point-max))
  2353. (beginning-of-line (- 1 skip2))
  2354. (let* ((last (org-current-line))
  2355. (n org-export-last-code-line-counter-value)
  2356. (nmax (+ n (- last skip1)))
  2357. (fmt (format "%%%dd: " (length (number-to-string nmax))))
  2358. (fm
  2359. (cond
  2360. ((eq org-export-current-backend 'html) (format "<span class=\"linenr\">%s</span>"
  2361. fmt))
  2362. ((eq org-export-current-backend 'ascii) fmt)
  2363. ((eq org-export-current-backend 'latex) fmt)
  2364. ((eq org-export-current-backend 'docbook) fmt)
  2365. (t "")))
  2366. (label-format (or label-format org-coderef-label-format))
  2367. (label-pre (if (string-match "%s" label-format)
  2368. (substring label-format 0 (match-beginning 0))
  2369. label-format))
  2370. (label-post (if (string-match "%s" label-format)
  2371. (substring label-format (match-end 0))
  2372. ""))
  2373. (lbl-re
  2374. (concat
  2375. ".*?\\S-.*?\\([ \t]*\\("
  2376. (regexp-quote label-pre)
  2377. "\\([-a-zA-Z0-9_ ]+\\)"
  2378. (regexp-quote label-post)
  2379. "\\)\\)"))
  2380. ref)
  2381. (org-goto-line (1+ skip1))
  2382. (while (and (re-search-forward "^" nil t) (not (eobp)) (< n nmax))
  2383. (if number
  2384. (insert (format fm (incf n)))
  2385. (forward-char 1))
  2386. (when (looking-at lbl-re)
  2387. (setq ref (match-string 3))
  2388. (cond ((numberp replace-labels)
  2389. ;; remove labels; use numbers for references when lines
  2390. ;; are numbered, use labels otherwise
  2391. (delete-region (match-beginning 1) (match-end 1))
  2392. (push (cons ref (if (> n 0) n ref)) org-export-code-refs))
  2393. ((eq replace-labels 'keep)
  2394. ;; don't remove labels; use numbers for references when
  2395. ;; lines are numbered, use labels otherwise
  2396. (goto-char (match-beginning 2))
  2397. (delete-region (match-beginning 2) (match-end 2))
  2398. (insert "(" ref ")")
  2399. (push (cons ref (if (> n 0) n (concat "(" ref ")")))
  2400. org-export-code-refs))
  2401. (t
  2402. ;; don't remove labels and don't use numbers for
  2403. ;; references
  2404. (goto-char (match-beginning 2))
  2405. (delete-region (match-beginning 2) (match-end 2))
  2406. (insert "(" ref ")")
  2407. (push (cons ref (concat "(" ref ")")) org-export-code-refs)))
  2408. (when (eq org-export-current-backend 'html)
  2409. (save-excursion
  2410. (beginning-of-line 1)
  2411. (insert (format "<span id=\"coderef-%s\" class=\"coderef-off\">"
  2412. ref))
  2413. (end-of-line 1)
  2414. (insert "</span>")))))
  2415. (setq org-export-last-code-line-counter-value n)
  2416. (goto-char (point-max))
  2417. (newline)
  2418. (buffer-string))))
  2419. (defun org-search-todo-below (line lines level)
  2420. "Search the subtree below LINE for any TODO entries."
  2421. (let ((rest (cdr (memq line lines)))
  2422. (re org-todo-line-regexp)
  2423. line lv todo)
  2424. (catch 'exit
  2425. (while (setq line (pop rest))
  2426. (if (string-match re line)
  2427. (progn
  2428. (setq lv (- (match-end 1) (match-beginning 1))
  2429. todo (and (match-beginning 2)
  2430. (not (member (match-string 2 line)
  2431. org-done-keywords))))
  2432. ; TODO, not DONE
  2433. (if (<= lv level) (throw 'exit nil))
  2434. (if todo (throw 'exit t))))))))
  2435. ;;;###autoload
  2436. (defun org-export-visible (type arg)
  2437. "Create a copy of the visible part of the current buffer, and export it.
  2438. The copy is created in a temporary buffer and removed after use.
  2439. TYPE is the final key (as a string) that also selects the export command in
  2440. the \\<org-mode-map>\\[org-export] export dispatcher.
  2441. As a special case, if the you type SPC at the prompt, the temporary
  2442. org-mode file will not be removed but presented to you so that you can
  2443. continue to use it. The prefix arg ARG is passed through to the exporting
  2444. command."
  2445. (interactive
  2446. (list (progn
  2447. (message "Export visible: [a]SCII [h]tml [b]rowse HTML [H/R]buffer with HTML [D]ocBook [l]atex [p]df [d]view pdf [L]atex buffer [x]OXO [ ]keep buffer")
  2448. (read-char-exclusive))
  2449. current-prefix-arg))
  2450. (if (not (member type '(?a ?n ?u ?\C-a ?b ?\C-b ?h ?D ?x ?\ ?l ?p ?d ?L ?H ?R)))
  2451. (error "Invalid export key"))
  2452. (let* ((binding (cdr (assoc type
  2453. '(
  2454. (?a . org-export-as-ascii)
  2455. (?A . org-export-as-ascii-to-buffer)
  2456. (?n . org-export-as-latin1)
  2457. (?N . org-export-as-latin1-to-buffer)
  2458. (?u . org-export-as-utf8)
  2459. (?U . org-export-as-utf8-to-buffer)
  2460. (?\C-a . org-export-as-ascii)
  2461. (?b . org-export-as-html-and-open)
  2462. (?\C-b . org-export-as-html-and-open)
  2463. (?h . org-export-as-html)
  2464. (?H . org-export-as-html-to-buffer)
  2465. (?R . org-export-region-as-html)
  2466. (?D . org-export-as-docbook)
  2467. (?l . org-export-as-latex)
  2468. (?p . org-export-as-pdf)
  2469. (?d . org-export-as-pdf-and-open)
  2470. (?L . org-export-as-latex-to-buffer)
  2471. (?x . org-export-as-xoxo)))))
  2472. (keepp (equal type ?\ ))
  2473. (file buffer-file-name)
  2474. (buffer (get-buffer-create "*Org Export Visible*"))
  2475. s e)
  2476. ;; Need to hack the drawers here.
  2477. (save-excursion
  2478. (goto-char (point-min))
  2479. (while (re-search-forward org-drawer-regexp nil t)
  2480. (goto-char (match-beginning 1))
  2481. (or (outline-invisible-p) (org-flag-drawer nil))))
  2482. (with-current-buffer buffer (erase-buffer))
  2483. (save-excursion
  2484. (setq s (goto-char (point-min)))
  2485. (while (not (= (point) (point-max)))
  2486. (goto-char (org-find-invisible))
  2487. (append-to-buffer buffer s (point))
  2488. (setq s (goto-char (org-find-visible))))
  2489. (org-cycle-hide-drawers 'all)
  2490. (goto-char (point-min))
  2491. (unless keepp
  2492. ;; Copy all comment lines to the end, to make sure #+ settings are
  2493. ;; still available for the second export step. Kind of a hack, but
  2494. ;; does do the trick.
  2495. (if (looking-at "#[^\r\n]*")
  2496. (append-to-buffer buffer (match-beginning 0) (1+ (match-end 0))))
  2497. (when (re-search-forward "^\\*+[ \t]+" nil t)
  2498. (while (re-search-backward "[\n\r]#[^\n\r]*" nil t)
  2499. (append-to-buffer buffer (1+ (match-beginning 0))
  2500. (min (point-max) (1+ (match-end 0)))))))
  2501. (set-buffer buffer)
  2502. (let ((buffer-file-name file)
  2503. (org-inhibit-startup t))
  2504. (org-mode)
  2505. (show-all)
  2506. (unless keepp (funcall binding arg))))
  2507. (if (not keepp)
  2508. (kill-buffer buffer)
  2509. (switch-to-buffer-other-window buffer)
  2510. (goto-char (point-min)))))
  2511. (defun org-find-visible ()
  2512. (let ((s (point)))
  2513. (while (and (not (= (point-max) (setq s (next-overlay-change s))))
  2514. (get-char-property s 'invisible)))
  2515. s))
  2516. (defun org-find-invisible ()
  2517. (let ((s (point)))
  2518. (while (and (not (= (point-max) (setq s (next-overlay-change s))))
  2519. (not (get-char-property s 'invisible))))
  2520. s))
  2521. (defvar org-export-htmlized-org-css-url) ;; defined in org-html.el
  2522. (defun org-export-string (string fmt &optional dir)
  2523. "Export STRING to FMT using existing export facilities.
  2524. During export STRING is saved to a temporary file whose location
  2525. could vary. Optional argument DIR can be used to force the
  2526. directory in which the temporary file is created during export
  2527. which can be useful for resolving relative paths. Dir defaults
  2528. to the value of `temporary-file-directory'."
  2529. (let ((temporary-file-directory (or dir temporary-file-directory))
  2530. (tmp-file (make-temp-file "org-")))
  2531. (unwind-protect
  2532. (with-temp-buffer
  2533. (insert string)
  2534. (write-file tmp-file)
  2535. (org-load-modules-maybe)
  2536. (unless org-local-vars
  2537. (setq org-local-vars (org-get-local-variables)))
  2538. (eval ;; convert to fmt -- mimicing `org-run-like-in-org-mode'
  2539. (list 'let org-local-vars
  2540. (list (intern (format "org-export-as-%s" fmt))
  2541. nil nil nil ''string t))))
  2542. (delete-file tmp-file))))
  2543. ;;;###autoload
  2544. (defun org-export-as-org (arg &optional hidden ext-plist
  2545. to-buffer body-only pub-dir)
  2546. "Make a copy with not-exporting stuff removed.
  2547. The purpose of this function is to provide a way to export the source
  2548. Org file of a webpage in Org format, but with sensitive and/or irrelevant
  2549. stuff removed. This command will remove the following:
  2550. - archived trees (if the variable `org-export-with-archived-trees' is nil)
  2551. - comment blocks and trees starting with the COMMENT keyword
  2552. - only trees that are consistent with `org-export-select-tags'
  2553. and `org-export-exclude-tags'.
  2554. The only arguments that will be used are EXT-PLIST and PUB-DIR,
  2555. all the others will be ignored (but are present so that the general
  2556. mechanism to call publishing functions will work).
  2557. EXT-PLIST is a property list with external parameters overriding
  2558. org-mode's default settings, but still inferior to file-local
  2559. settings. When PUB-DIR is set, use this as the publishing
  2560. directory."
  2561. (interactive "P")
  2562. (let* ((opt-plist (org-combine-plists (org-default-export-plist)
  2563. ext-plist
  2564. (org-infile-export-plist)))
  2565. (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
  2566. (filename (concat (file-name-as-directory
  2567. (or pub-dir
  2568. (org-export-directory :org opt-plist)))
  2569. (file-name-sans-extension
  2570. (file-name-nondirectory bfname))
  2571. ".org"))
  2572. (filename (and filename
  2573. (if (equal (file-truename filename)
  2574. (file-truename bfname))
  2575. (concat (file-name-sans-extension filename)
  2576. "-source."
  2577. (file-name-extension filename))
  2578. filename)))
  2579. (backup-inhibited t)
  2580. (buffer (find-file-noselect filename))
  2581. (region (buffer-string))
  2582. str-ret)
  2583. (save-excursion
  2584. (switch-to-buffer buffer)
  2585. (erase-buffer)
  2586. (insert region)
  2587. (let ((org-inhibit-startup t)) (org-mode))
  2588. (org-install-letbind)
  2589. ;; Get rid of archived trees
  2590. (org-export-remove-archived-trees (plist-get opt-plist :archived-trees))
  2591. ;; Remove comment environment and comment subtrees
  2592. (org-export-remove-comment-blocks-and-subtrees)
  2593. ;; Get rid of excluded trees
  2594. (org-export-handle-export-tags (plist-get opt-plist :select-tags)
  2595. (plist-get opt-plist :exclude-tags))
  2596. (when (or (plist-get opt-plist :plain-source)
  2597. (not (or (plist-get opt-plist :plain-source)
  2598. (plist-get opt-plist :htmlized-source))))
  2599. ;; Either nothing special is requested (default call)
  2600. ;; or the plain source is explicitly requested
  2601. ;; so: save it
  2602. (save-buffer))
  2603. (when (plist-get opt-plist :htmlized-source)
  2604. ;; Make the htmlized version
  2605. (require 'htmlize)
  2606. (require 'org-html)
  2607. (font-lock-fontify-buffer)
  2608. (let* ((htmlize-output-type 'css)
  2609. (newbuf (htmlize-buffer)))
  2610. (with-current-buffer newbuf
  2611. (when org-export-htmlized-org-css-url
  2612. (goto-char (point-min))
  2613. (and (re-search-forward
  2614. "<style type=\"text/css\">[^\000]*?\n[ \t]*</style>.*"
  2615. nil t)
  2616. (replace-match
  2617. (format
  2618. "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"
  2619. org-export-htmlized-org-css-url)
  2620. t t)))
  2621. (write-file (concat filename ".html")))
  2622. (kill-buffer newbuf)))
  2623. (set-buffer-modified-p nil)
  2624. (if (equal to-buffer 'string)
  2625. (progn (setq str-ret (buffer-string))
  2626. (kill-buffer (current-buffer))
  2627. str-ret)
  2628. (kill-buffer (current-buffer))))))
  2629. (defvar org-archive-location) ;; gets loaded with the org-archive require.
  2630. (defun org-get-current-options ()
  2631. "Return a string with current options as keyword options.
  2632. Does include HTML export options as well as TODO and CATEGORY stuff."
  2633. (require 'org-archive)
  2634. (format
  2635. "#+TITLE: %s
  2636. #+AUTHOR: %s
  2637. #+EMAIL: %s
  2638. #+DATE: %s
  2639. #+DESCRIPTION:
  2640. #+KEYWORDS:
  2641. #+LANGUAGE: %s
  2642. #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s <:%s
  2643. #+OPTIONS: TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s
  2644. %s
  2645. #+EXPORT_SELECT_TAGS: %s
  2646. #+EXPORT_EXCLUDE_TAGS: %s
  2647. #+LINK_UP: %s
  2648. #+LINK_HOME: %s
  2649. #+XSLT:
  2650. #+CATEGORY: %s
  2651. #+SEQ_TODO: %s
  2652. #+TYP_TODO: %s
  2653. #+PRIORITIES: %c %c %c
  2654. #+DRAWERS: %s
  2655. #+STARTUP: %s %s %s %s %s
  2656. #+TAGS: %s
  2657. #+FILETAGS: %s
  2658. #+ARCHIVE: %s
  2659. #+LINK: %s
  2660. "
  2661. (buffer-name) (user-full-name) user-mail-address
  2662. (format-time-string (substring (car org-time-stamp-formats) 1 -1))
  2663. org-export-default-language
  2664. org-export-headline-levels
  2665. org-export-with-section-numbers
  2666. org-export-with-toc
  2667. org-export-preserve-breaks
  2668. org-export-html-expand
  2669. org-export-with-fixed-width
  2670. org-export-with-tables
  2671. org-export-with-sub-superscripts
  2672. org-export-with-special-strings
  2673. org-export-with-footnotes
  2674. org-export-with-emphasize
  2675. org-export-with-timestamps
  2676. org-export-with-TeX-macros
  2677. org-export-with-LaTeX-fragments
  2678. org-export-skip-text-before-1st-heading
  2679. org-export-with-drawers
  2680. org-export-with-todo-keywords
  2681. org-export-with-priority
  2682. org-export-with-tags
  2683. (if (featurep 'org-jsinfo) (org-infojs-options-inbuffer-template) "")
  2684. (mapconcat 'identity org-export-select-tags " ")
  2685. (mapconcat 'identity org-export-exclude-tags " ")
  2686. org-export-html-link-up
  2687. org-export-html-link-home
  2688. (or (ignore-errors
  2689. (file-name-sans-extension
  2690. (file-name-nondirectory (buffer-file-name (buffer-base-buffer)))))
  2691. "NOFILENAME")
  2692. "TODO FEEDBACK VERIFY DONE"
  2693. "Me Jason Marie DONE"
  2694. org-highest-priority org-lowest-priority org-default-priority
  2695. (mapconcat 'identity org-drawers " ")
  2696. (cdr (assoc org-startup-folded
  2697. '((nil . "showall") (t . "overview") (content . "content"))))
  2698. (if org-odd-levels-only "odd" "oddeven")
  2699. (if org-hide-leading-stars "hidestars" "showstars")
  2700. (if org-startup-align-all-tables "align" "noalign")
  2701. (cond ((eq org-log-done t) "logdone")
  2702. ((equal org-log-done 'note) "lognotedone")
  2703. ((not org-log-done) "nologdone"))
  2704. (or (mapconcat (lambda (x)
  2705. (cond
  2706. ((equal :startgroup (car x)) "{")
  2707. ((equal :endgroup (car x)) "}")
  2708. ((equal :newline (car x)) "")
  2709. ((cdr x) (format "%s(%c)" (car x) (cdr x)))
  2710. (t (car x))))
  2711. (or org-tag-alist (org-get-buffer-tags)) " ") "")
  2712. (mapconcat 'identity org-file-tags " ")
  2713. org-archive-location
  2714. "org file:~/org/%s.org"
  2715. ))
  2716. ;;;###autoload
  2717. (defun org-insert-export-options-template ()
  2718. "Insert into the buffer a template with information for exporting."
  2719. (interactive)
  2720. (if (not (bolp)) (newline))
  2721. (let ((s (org-get-current-options)))
  2722. (and (string-match "#\\+CATEGORY" s)
  2723. (setq s (substring s 0 (match-beginning 0))))
  2724. (insert s)))
  2725. (defvar org-table-colgroup-info nil)
  2726. (defun org-table-clean-before-export (lines &optional maybe-quoted)
  2727. "Check if the table has a marking column.
  2728. If yes remove the column and the special lines."
  2729. (setq org-table-colgroup-info nil)
  2730. (if (memq nil
  2731. (mapcar
  2732. (lambda (x) (or (string-match "^[ \t]*|-" x)
  2733. (string-match
  2734. (if maybe-quoted
  2735. "^[ \t]*| *\\\\?\\([\#!$*_^ /]\\) *|"
  2736. "^[ \t]*| *\\([\#!$*_^ /]\\) *|")
  2737. x)))
  2738. lines))
  2739. ;; No special marking column
  2740. (progn
  2741. (setq org-table-clean-did-remove-column nil)
  2742. (delq nil
  2743. (mapcar
  2744. (lambda (x)
  2745. (cond
  2746. ((org-table-colgroup-line-p x)
  2747. ;; This line contains colgroup info, extract it
  2748. ;; and then discard the line
  2749. (setq org-table-colgroup-info
  2750. (mapcar (lambda (x)
  2751. (cond ((member x '("<" "&lt;")) :start)
  2752. ((member x '(">" "&gt;")) :end)
  2753. ((member x '("<>" "&lt;&gt;")) :startend)
  2754. (t nil)))
  2755. (org-split-string x "[ \t]*|[ \t]*")))
  2756. nil)
  2757. ((org-table-cookie-line-p x)
  2758. ;; This line contains formatting cookies, discard it
  2759. nil)
  2760. (t x)))
  2761. lines)))
  2762. ;; there is a special marking column
  2763. (setq org-table-clean-did-remove-column t)
  2764. (delq nil
  2765. (mapcar
  2766. (lambda (x)
  2767. (cond
  2768. ((org-table-colgroup-line-p x)
  2769. ;; This line contains colgroup info, extract it
  2770. ;; and then discard the line
  2771. (setq org-table-colgroup-info
  2772. (mapcar (lambda (x)
  2773. (cond ((member x '("<" "&lt;")) :start)
  2774. ((member x '(">" "&gt;")) :end)
  2775. ((member x '("<>" "&lt;&gt;")) :startend)
  2776. (t nil)))
  2777. (cdr (org-split-string x "[ \t]*|[ \t]*"))))
  2778. nil)
  2779. ((org-table-cookie-line-p x)
  2780. ;; This line contains formatting cookies, discard it
  2781. nil)
  2782. ((string-match "^[ \t]*| *[!_^/] *|" x)
  2783. ;; ignore this line
  2784. nil)
  2785. ((or (string-match "^\\([ \t]*\\)|-+\\+" x)
  2786. (string-match "^\\([ \t]*\\)|[^|]*|" x))
  2787. ;; remove the first column
  2788. (replace-match "\\1|" t nil x))))
  2789. lines))))
  2790. (defun org-export-cleanup-toc-line (s)
  2791. "Remove tags and timestamps from lines going into the toc."
  2792. (when (memq org-export-with-tags '(not-in-toc nil))
  2793. (if (string-match (org-re " +:[[:alnum:]_@#%:]+: *$") s)
  2794. (setq s (replace-match "" t t s))))
  2795. (when org-export-remove-timestamps-from-toc
  2796. (while (string-match org-maybe-keyword-time-regexp s)
  2797. (setq s (replace-match "" t t s))))
  2798. (while (string-match org-bracket-link-regexp s)
  2799. (setq s (replace-match (match-string (if (match-end 3) 3 1) s)
  2800. t t s)))
  2801. (while (string-match "\\[\\([0-9]\\|fn:[^]]*\\)\\]" s)
  2802. (setq s (replace-match "" t t s)))
  2803. s)
  2804. (defun org-get-text-property-any (pos prop &optional object)
  2805. (or (get-text-property pos prop object)
  2806. (and (setq pos (next-single-property-change pos prop object))
  2807. (get-text-property pos prop object))))
  2808. (defun org-export-get-coderef-format (path desc)
  2809. (save-match-data
  2810. (if (and desc (string-match
  2811. (regexp-quote (concat "(" path ")"))
  2812. desc))
  2813. (replace-match "%s" t t desc)
  2814. (or desc "%s"))))
  2815. (defun org-export-push-to-kill-ring (format)
  2816. "Push buffer content to kill ring.
  2817. The depends on the variable `org-export-copy-to-kill'."
  2818. (when org-export-copy-to-kill-ring
  2819. (org-kill-new (buffer-string))
  2820. (when (fboundp 'x-set-selection)
  2821. (ignore-errors (x-set-selection 'PRIMARY (buffer-string)))
  2822. (ignore-errors (x-set-selection 'CLIPBOARD (buffer-string))))
  2823. (message "%s export done, pushed to kill ring and clipboard" format)))
  2824. (provide 'org-exp)
  2825. ;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
  2826. ;;; org-exp.el ends here