ox-html.el 118 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289
  1. ;;; ox-html.el --- HTML Back-End for Org Export Engine
  2. ;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
  3. ;; Author: Jambunathan K <kjambunathan at gmail dot com>
  4. ;; Keywords: outlines, hypermedia, calendar, wp
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;; This library implements a HTML back-end for Org generic exporter.
  17. ;; To test it, run:
  18. ;;
  19. ;; M-x org-export-as-html
  20. ;;
  21. ;; in an Org mode buffer. See ox.el for more details on how this
  22. ;; exporter works.
  23. ;;; Code:
  24. ;;; Dependencies
  25. (require 'ox)
  26. (require 'ox-publish)
  27. (require 'format-spec)
  28. (eval-when-compile (require 'cl) (require 'table))
  29. ;;; Function Declarations
  30. (declare-function org-id-find-id-file "org-id" (id))
  31. (declare-function htmlize-region "ext:htmlize" (beg end))
  32. (declare-function org-pop-to-buffer-same-window
  33. "org-compat" (&optional buffer-or-name norecord label))
  34. (declare-function mm-url-decode-entities "mm-url" ())
  35. ;;; Define Back-End
  36. (org-export-define-backend 'html
  37. '((bold . org-html-bold)
  38. (center-block . org-html-center-block)
  39. (clock . org-html-clock)
  40. (code . org-html-code)
  41. (drawer . org-html-drawer)
  42. (dynamic-block . org-html-dynamic-block)
  43. (entity . org-html-entity)
  44. (example-block . org-html-example-block)
  45. (export-block . org-html-export-block)
  46. (export-snippet . org-html-export-snippet)
  47. (fixed-width . org-html-fixed-width)
  48. (footnote-definition . org-html-footnote-definition)
  49. (footnote-reference . org-html-footnote-reference)
  50. (headline . org-html-headline)
  51. (horizontal-rule . org-html-horizontal-rule)
  52. (inline-src-block . org-html-inline-src-block)
  53. (inlinetask . org-html-inlinetask)
  54. (inner-template . org-html-inner-template)
  55. (italic . org-html-italic)
  56. (item . org-html-item)
  57. (keyword . org-html-keyword)
  58. (latex-environment . org-html-latex-environment)
  59. (latex-fragment . org-html-latex-fragment)
  60. (line-break . org-html-line-break)
  61. (link . org-html-link)
  62. (paragraph . org-html-paragraph)
  63. (plain-list . org-html-plain-list)
  64. (plain-text . org-html-plain-text)
  65. (planning . org-html-planning)
  66. (property-drawer . org-html-property-drawer)
  67. (quote-block . org-html-quote-block)
  68. (quote-section . org-html-quote-section)
  69. (radio-target . org-html-radio-target)
  70. (section . org-html-section)
  71. (special-block . org-html-special-block)
  72. (src-block . org-html-src-block)
  73. (statistics-cookie . org-html-statistics-cookie)
  74. (strike-through . org-html-strike-through)
  75. (subscript . org-html-subscript)
  76. (superscript . org-html-superscript)
  77. (table . org-html-table)
  78. (table-cell . org-html-table-cell)
  79. (table-row . org-html-table-row)
  80. (target . org-html-target)
  81. (template . org-html-template)
  82. (timestamp . org-html-timestamp)
  83. (underline . org-html-underline)
  84. (verbatim . org-html-verbatim)
  85. (verse-block . org-html-verse-block))
  86. :export-block "HTML"
  87. :filters-alist '((:filter-options . org-html-infojs-install-script)
  88. (:filter-final-output . org-html-final-function))
  89. :menu-entry
  90. '(?h "Export to HTML"
  91. ((?H "As HTML buffer" org-html-export-as-html)
  92. (?h "As HTML file" org-html-export-to-html)
  93. (?o "As HTML file and open"
  94. (lambda (a s v b)
  95. (if a (org-html-export-to-html t s v b)
  96. (org-open-file (org-html-export-to-html nil s v b)))))))
  97. :options-alist
  98. '((:html-extension nil nil org-html-extension)
  99. (:html-doctype "HTML_DOCTYPE" nil org-html-doctype)
  100. (:html-container "HTML_CONTAINER" nil org-html-container-element)
  101. (:html-link-home "HTML_LINK_HOME" nil org-html-link-home)
  102. (:html-link-up "HTML_LINK_UP" nil org-html-link-up)
  103. (:html-mathjax "HTML_MATHJAX" nil "" space)
  104. (:html-postamble nil "html-postamble" org-html-postamble)
  105. (:html-preamble nil "html-preamble" org-html-preamble)
  106. (:html-head "HTML_HEAD" nil org-html-head newline)
  107. (:html-head-extra "HTML_HEAD_EXTRA" nil org-html-head-extra newline)
  108. (:html-head-include-default-style "HTML_INCLUDE_STYLE" nil org-html-head-include-default-style newline)
  109. (:html-head-include-scripts "HTML_INCLUDE_SCRIPTS" nil org-html-head-include-scripts newline)
  110. (:html-table-tag nil nil org-html-table-tag)
  111. ;; Redefine regular options.
  112. (:creator "CREATOR" nil org-html-creator-string)
  113. (:with-latex nil "tex" org-html-with-latex)
  114. ;; Leave room for "ox-infojs.el" extension.
  115. (:infojs-opt "INFOJS_OPT" nil nil)))
  116. ;;; Internal Variables
  117. (defvar org-html-format-table-no-css)
  118. (defvar htmlize-buffer-places) ; from htmlize.el
  119. (defvar org-html--timestamp-format "%Y-%m-%d %a %H:%M"
  120. "FORMAT used by `format-time-string' for timestamps in
  121. preamble, postamble and metadata.")
  122. (defvar org-html--pre/postamble-class "status"
  123. "CSS class used for pre/postamble")
  124. (defconst org-html-special-string-regexps
  125. '(("\\\\-" . "&#x00ad;") ; shy
  126. ("---\\([^-]\\)" . "&#x2014;\\1") ; mdash
  127. ("--\\([^-]\\)" . "&#x2013;\\1") ; ndash
  128. ("\\.\\.\\." . "&#x2026;")) ; hellip
  129. "Regular expressions for special string conversion.")
  130. (defconst org-html-scripts
  131. "<script type=\"text/javascript\">
  132. /*
  133. @licstart The following is the entire license notice for the
  134. JavaScript code in this tag.
  135. Copyright (C) 2012 Free Software Foundation, Inc.
  136. The JavaScript code in this tag is free software: you can
  137. redistribute it and/or modify it under the terms of the GNU
  138. General Public License (GNU GPL) as published by the Free Software
  139. Foundation, either version 3 of the License, or (at your option)
  140. any later version. The code is distributed WITHOUT ANY WARRANTY;
  141. without even the implied warranty of MERCHANTABILITY or FITNESS
  142. FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
  143. As additional permission under GNU GPL version 3 section 7, you
  144. may distribute non-source (e.g., minimized or compacted) forms of
  145. that code without the copy of the GNU GPL normally required by
  146. section 4, provided you include this license notice and a URL
  147. through which recipients can access the Corresponding Source.
  148. @licend The above is the entire license notice
  149. for the JavaScript code in this tag.
  150. */
  151. <!--/*--><![CDATA[/*><!--*/
  152. function CodeHighlightOn(elem, id)
  153. {
  154. var target = document.getElementById(id);
  155. if(null != target) {
  156. elem.cacheClassElem = elem.className;
  157. elem.cacheClassTarget = target.className;
  158. target.className = \"code-highlighted\";
  159. elem.className = \"code-highlighted\";
  160. }
  161. }
  162. function CodeHighlightOff(elem, id)
  163. {
  164. var target = document.getElementById(id);
  165. if(elem.cacheClassElem)
  166. elem.className = elem.cacheClassElem;
  167. if(elem.cacheClassTarget)
  168. target.className = elem.cacheClassTarget;
  169. }
  170. /*]]>*///-->
  171. </script>"
  172. "Basic JavaScript that is needed by HTML files produced by Org mode.")
  173. (defconst org-html-style-default
  174. "<style type=\"text/css\">
  175. <!--/*--><![CDATA[/*><!--*/
  176. .title { text-align: center; }
  177. .todo { font-family: monospace; color: red; }
  178. .done { color: green; }
  179. .tag { background-color: #eee; font-family: monospace;
  180. padding: 2px; font-size: 80%; font-weight: normal; }
  181. .timestamp { color: #bebebe; }
  182. .timestamp-kwd { color: #5f9ea0; }
  183. .right { margin-left: auto; margin-right: 0px; text-align: right; }
  184. .left { margin-left: 0px; margin-right: auto; text-align: left; }
  185. .center { margin-left: auto; margin-right: auto; text-align: center; }
  186. .underline { text-decoration: underline; }
  187. #postamble p, #preamble p { font-size: 90%; margin: .2em; }
  188. p.verse { margin-left: 3%; }
  189. pre {
  190. border: 1px solid #ccc;
  191. box-shadow: 3px 3px 3px #eee;
  192. padding: 8pt;
  193. font-family: monospace;
  194. overflow: auto;
  195. margin: 1.2em;
  196. }
  197. pre.src {
  198. position: relative;
  199. overflow: visible;
  200. padding-top: 1.2em;
  201. }
  202. pre.src:before {
  203. display: none;
  204. position: absolute;
  205. background-color: white;
  206. top: -10px;
  207. right: 10px;
  208. padding: 3px;
  209. border: 1px solid black;
  210. }
  211. pre.src:hover:before { display: inline;}
  212. pre.src-sh:before { content: 'sh'; }
  213. pre.src-bash:before { content: 'sh'; }
  214. pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
  215. pre.src-R:before { content: 'R'; }
  216. pre.src-perl:before { content: 'Perl'; }
  217. pre.src-java:before { content: 'Java'; }
  218. pre.src-sql:before { content: 'SQL'; }
  219. table { border-collapse:collapse; }
  220. td, th { vertical-align:top; }
  221. th.right { text-align: center; }
  222. th.left { text-align: center; }
  223. th.center { text-align: center; }
  224. td.right { text-align: right; }
  225. td.left { text-align: left; }
  226. td.center { text-align: center; }
  227. dt { font-weight: bold; }
  228. .footpara:nth-child(2) { display: inline; }
  229. .footpara { display: block; }
  230. .footdef { margin-bottom: 1em; }
  231. .figure { padding: 1em; }
  232. .figure p { text-align: center; }
  233. .inlinetask {
  234. padding: 10px;
  235. border: 2px solid gray;
  236. margin: 10px;
  237. background: #ffffcc;
  238. }
  239. #org-div-home-and-up
  240. { text-align: right; font-size: 70%; white-space: nowrap; }
  241. textarea { overflow-x: auto; }
  242. .linenr { font-size: smaller }
  243. .code-highlighted { background-color: #ffff00; }
  244. .org-info-js_info-navigation { border-style: none; }
  245. #org-info-js_console-label
  246. { font-size: 10px; font-weight: bold; white-space: nowrap; }
  247. .org-info-js_search-highlight
  248. { background-color: #ffff00; color: #000000; font-weight: bold; }
  249. /*]]>*/-->
  250. </style>"
  251. "The default style specification for exported HTML files.
  252. You can use `org-html-head' and `org-html-head-extra' to add to
  253. this style. If you don't want to include this default style,
  254. customize `org-html-head-include-default-style'.")
  255. ;;; User Configuration Variables
  256. (defgroup org-export-html nil
  257. "Options for exporting Org mode files to HTML."
  258. :tag "Org Export HTML"
  259. :group 'org-export)
  260. ;;;; Handle infojs
  261. (defvar org-html-infojs-opts-table
  262. '((path PATH "http://orgmode.org/org-info.js")
  263. (view VIEW "info")
  264. (toc TOC :with-toc)
  265. (ftoc FIXED_TOC "0")
  266. (tdepth TOC_DEPTH "max")
  267. (sdepth SECTION_DEPTH "max")
  268. (mouse MOUSE_HINT "underline")
  269. (buttons VIEW_BUTTONS "0")
  270. (ltoc LOCAL_TOC "1")
  271. (up LINK_UP :html-link-up)
  272. (home LINK_HOME :html-link-home))
  273. "JavaScript options, long form for script, default values.")
  274. (defcustom org-html-use-infojs 'when-configured
  275. "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
  276. This option can be nil or t to never or always use the script.
  277. It can also be the symbol `when-configured', meaning that the
  278. script will be linked into the export file if and only if there
  279. is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
  280. `org-html-infojs-options'."
  281. :group 'org-export-html
  282. :version "24.4"
  283. :package-version '(Org . "8.0")
  284. :type '(choice
  285. (const :tag "Never" nil)
  286. (const :tag "When configured in buffer" when-configured)
  287. (const :tag "Always" t)))
  288. (defcustom org-html-infojs-options
  289. (mapcar (lambda (x) (cons (car x) (nth 2 x))) org-html-infojs-opts-table)
  290. "Options settings for the INFOJS JavaScript.
  291. Each of the options must have an entry in `org-html-infojs-opts-table'.
  292. The value can either be a string that will be passed to the script, or
  293. a property. This property is then assumed to be a property that is defined
  294. by the Export/Publishing setup of Org.
  295. The `sdepth' and `tdepth' parameters can also be set to \"max\", which
  296. means to use the maximum value consistent with other options."
  297. :group 'org-export-html
  298. :version "24.4"
  299. :package-version '(Org . "8.0")
  300. :type
  301. `(set :greedy t :inline t
  302. ,@(mapcar
  303. (lambda (x)
  304. (list 'cons (list 'const (car x))
  305. '(choice
  306. (symbol :tag "Publishing/Export property")
  307. (string :tag "Value"))))
  308. org-html-infojs-opts-table)))
  309. (defcustom org-html-infojs-template
  310. "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
  311. /**
  312. *
  313. * @source: %SCRIPT_PATH
  314. *
  315. * @licstart The following is the entire license notice for the
  316. * JavaScript code in %SCRIPT_PATH.
  317. *
  318. * Copyright (C) 2012-2013 Sebastian Rose
  319. *
  320. *
  321. * The JavaScript code in this tag is free software: you can
  322. * redistribute it and/or modify it under the terms of the GNU
  323. * General Public License (GNU GPL) as published by the Free Software
  324. * Foundation, either version 3 of the License, or (at your option)
  325. * any later version. The code is distributed WITHOUT ANY WARRANTY;
  326. * without even the implied warranty of MERCHANTABILITY or FITNESS
  327. * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
  328. *
  329. * As additional permission under GNU GPL version 3 section 7, you
  330. * may distribute non-source (e.g., minimized or compacted) forms of
  331. * that code without the copy of the GNU GPL normally required by
  332. * section 4, provided you include this license notice and a URL
  333. * through which recipients can access the Corresponding Source.
  334. *
  335. * @licend The above is the entire license notice
  336. * for the JavaScript code in %SCRIPT_PATH.
  337. *
  338. */
  339. </script>
  340. <script type=\"text/javascript\">
  341. /*
  342. @licstart The following is the entire license notice for the
  343. JavaScript code in this tag.
  344. Copyright (C) 2012-2013 Free Software Foundation, Inc.
  345. The JavaScript code in this tag is free software: you can
  346. redistribute it and/or modify it under the terms of the GNU
  347. General Public License (GNU GPL) as published by the Free Software
  348. Foundation, either version 3 of the License, or (at your option)
  349. any later version. The code is distributed WITHOUT ANY WARRANTY;
  350. without even the implied warranty of MERCHANTABILITY or FITNESS
  351. FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
  352. As additional permission under GNU GPL version 3 section 7, you
  353. may distribute non-source (e.g., minimized or compacted) forms of
  354. that code without the copy of the GNU GPL normally required by
  355. section 4, provided you include this license notice and a URL
  356. through which recipients can access the Corresponding Source.
  357. @licend The above is the entire license notice
  358. for the JavaScript code in this tag.
  359. */
  360. <!--/*--><![CDATA[/*><!--*/
  361. %MANAGER_OPTIONS
  362. org_html_manager.setup(); // activate after the parameters are set
  363. /*]]>*///-->
  364. </script>"
  365. "The template for the export style additions when org-info.js is used.
  366. Option settings will replace the %MANAGER-OPTIONS cookie."
  367. :group 'org-export-html
  368. :version "24.4"
  369. :package-version '(Org . "8.0")
  370. :type 'string)
  371. (defun org-html-infojs-install-script (exp-plist backend)
  372. "Install script in export options when appropriate.
  373. EXP-PLIST is a plist containing export options. BACKEND is the
  374. export back-end currently used."
  375. (unless (or (memq 'body-only (plist-get exp-plist :export-options))
  376. (not org-html-use-infojs)
  377. (and (eq org-html-use-infojs 'when-configured)
  378. (or (not (plist-get exp-plist :infojs-opt))
  379. (string-match "\\<view:nil\\>"
  380. (plist-get exp-plist :infojs-opt)))))
  381. (let* ((template org-html-infojs-template)
  382. (ptoc (plist-get exp-plist :with-toc))
  383. (hlevels (plist-get exp-plist :headline-levels))
  384. (sdepth hlevels)
  385. (tdepth (if (integerp ptoc) (min ptoc hlevels) hlevels))
  386. (options (plist-get exp-plist :infojs-opt))
  387. (table org-html-infojs-opts-table)
  388. style)
  389. (dolist (entry table)
  390. (let* ((opt (car entry))
  391. (var (nth 1 entry))
  392. ;; Compute default values for script option OPT from
  393. ;; `org-html-infojs-options' variable.
  394. (default
  395. (let ((default (cdr (assq opt org-html-infojs-options))))
  396. (if (and (symbolp default) (not (memq default '(t nil))))
  397. (plist-get exp-plist default)
  398. default)))
  399. ;; Value set through INFOJS_OPT keyword has precedence
  400. ;; over the default one.
  401. (val (if (and options
  402. (string-match (format "\\<%s:\\(\\S-+\\)" opt)
  403. options))
  404. (match-string 1 options)
  405. default)))
  406. (case opt
  407. (path (setq template
  408. (replace-regexp-in-string
  409. "%SCRIPT_PATH" val template t t)))
  410. (sdepth (when (integerp (read val))
  411. (setq sdepth (min (read val) sdepth))))
  412. (tdepth (when (integerp (read val))
  413. (setq tdepth (min (read val) tdepth))))
  414. (otherwise (setq val
  415. (cond
  416. ((or (eq val t) (equal val "t")) "1")
  417. ((or (eq val nil) (equal val "nil")) "0")
  418. ((stringp val) val)
  419. (t (format "%s" val))))
  420. (push (cons var val) style)))))
  421. ;; Now we set the depth of the *generated* TOC to SDEPTH,
  422. ;; because the toc will actually determine the splitting. How
  423. ;; much of the toc will actually be displayed is governed by the
  424. ;; TDEPTH option.
  425. (setq exp-plist (plist-put exp-plist :with-toc sdepth))
  426. ;; The table of contents should not show more sections than we
  427. ;; generate.
  428. (setq tdepth (min tdepth sdepth))
  429. (push (cons "TOC_DEPTH" tdepth) style)
  430. ;; Build style string.
  431. (setq style (mapconcat
  432. (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
  433. (car x)
  434. (cdr x)))
  435. style "\n"))
  436. (when (and style (> (length style) 0))
  437. (and (string-match "%MANAGER_OPTIONS" template)
  438. (setq style (replace-match style t t template))
  439. (setq exp-plist
  440. (plist-put
  441. exp-plist :html-head-extra
  442. (concat (or (plist-get exp-plist :html-head-extra) "")
  443. "\n"
  444. style)))))
  445. ;; This script absolutely needs the table of contents, so we
  446. ;; change that setting.
  447. (unless (plist-get exp-plist :with-toc)
  448. (setq exp-plist (plist-put exp-plist :with-toc t)))
  449. ;; Return the modified property list.
  450. exp-plist)))
  451. ;;;; Bold, etc.
  452. (defcustom org-html-text-markup-alist
  453. '((bold . "<b>%s</b>")
  454. (code . "<code>%s</code>")
  455. (italic . "<i>%s</i>")
  456. (strike-through . "<del>%s</del>")
  457. (underline . "<span class=\"underline\">%s</span>")
  458. (verbatim . "<code>%s</code>"))
  459. "Alist of HTML expressions to convert text markup.
  460. The key must be a symbol among `bold', `code', `italic',
  461. `strike-through', `underline' and `verbatim'. The value is
  462. a formatting string to wrap fontified text with.
  463. If no association can be found for a given markup, text will be
  464. returned as-is."
  465. :group 'org-export-html
  466. :type '(alist :key-type (symbol :tag "Markup type")
  467. :value-type (string :tag "Format string"))
  468. :options '(bold code italic strike-through underline verbatim))
  469. (defcustom org-html-indent nil
  470. "Non-nil means to indent the generated HTML.
  471. Warning: non-nil may break indentation of source code blocks."
  472. :group 'org-export-html
  473. :version "24.4"
  474. :package-version '(Org . "8.0")
  475. :type 'boolean)
  476. (defcustom org-html-use-unicode-chars nil
  477. "Non-nil means to use unicode characters instead of HTML entities."
  478. :group 'org-export-html
  479. :version "24.4"
  480. :package-version '(Org . "8.0")
  481. :type 'boolean)
  482. ;;;; Drawers
  483. (defcustom org-html-format-drawer-function nil
  484. "Function called to format a drawer in HTML code.
  485. The function must accept two parameters:
  486. NAME the drawer name, like \"LOGBOOK\"
  487. CONTENTS the contents of the drawer.
  488. The function should return the string to be exported.
  489. For example, the variable could be set to the following function
  490. in order to mimic default behaviour:
  491. \(defun org-html-format-drawer-default \(name contents\)
  492. \"Format a drawer element for HTML export.\"
  493. contents\)"
  494. :group 'org-export-html
  495. :type 'function)
  496. ;;;; Footnotes
  497. (defcustom org-html-footnotes-section "<div id=\"footnotes\">
  498. <h2 class=\"footnotes\">%s: </h2>
  499. <div id=\"text-footnotes\">
  500. %s
  501. </div>
  502. </div>"
  503. "Format for the footnotes section.
  504. Should contain a two instances of %s. The first will be replaced with the
  505. language-specific word for \"Footnotes\", the second one will be replaced
  506. by the footnotes themselves."
  507. :group 'org-export-html
  508. :type 'string)
  509. (defcustom org-html-footnote-format "<sup>%s</sup>"
  510. "The format for the footnote reference.
  511. %s will be replaced by the footnote reference itself."
  512. :group 'org-export-html
  513. :type 'string)
  514. (defcustom org-html-footnote-separator "<sup>, </sup>"
  515. "Text used to separate footnotes."
  516. :group 'org-export-html
  517. :type 'string)
  518. ;;;; Headline
  519. (defcustom org-html-toplevel-hlevel 2
  520. "The <H> level for level 1 headings in HTML export.
  521. This is also important for the classes that will be wrapped around headlines
  522. and outline structure. If this variable is 1, the top-level headlines will
  523. be <h1>, and the corresponding classes will be outline-1, section-number-1,
  524. and outline-text-1. If this is 2, all of these will get a 2 instead.
  525. The default for this variable is 2, because we use <h1> for formatting the
  526. document title."
  527. :group 'org-export-html
  528. :type 'integer)
  529. (defcustom org-html-format-headline-function nil
  530. "Function to format headline text.
  531. This function will be called with 5 arguments:
  532. TODO the todo keyword (string or nil).
  533. TODO-TYPE the type of todo (symbol: `todo', `done', nil)
  534. PRIORITY the priority of the headline (integer or nil)
  535. TEXT the main headline text (string).
  536. TAGS the tags (string or nil).
  537. The function result will be used in the section format string."
  538. :group 'org-export-html
  539. :type 'function)
  540. ;;;; HTML-specific
  541. (defcustom org-html-allow-name-attribute-in-anchors t
  542. "When nil, do not set \"name\" attribute in anchors.
  543. By default, anchors are formatted with both \"id\" and \"name\"
  544. attributes, when appropriate."
  545. :group 'org-export-html
  546. :version "24.4"
  547. :package-version '(Org . "8.0")
  548. :type 'boolean)
  549. ;;;; Inlinetasks
  550. (defcustom org-html-format-inlinetask-function nil
  551. "Function called to format an inlinetask in HTML code.
  552. The function must accept six parameters:
  553. TODO the todo keyword, as a string
  554. TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
  555. PRIORITY the inlinetask priority, as a string
  556. NAME the inlinetask name, as a string.
  557. TAGS the inlinetask tags, as a list of strings.
  558. CONTENTS the contents of the inlinetask, as a string.
  559. The function should return the string to be exported."
  560. :group 'org-export-html
  561. :type 'function)
  562. ;;;; LaTeX
  563. (defcustom org-html-with-latex org-export-with-latex
  564. "Non-nil means process LaTeX math snippets.
  565. When set, the exporter will process LaTeX environments and
  566. fragments.
  567. This option can also be set with the +OPTIONS line,
  568. e.g. \"tex:mathjax\". Allowed values are:
  569. nil Ignore math snippets.
  570. `verbatim' Keep everything in verbatim
  571. `dvipng' Process the LaTeX fragments to images. This will also
  572. include processing of non-math environments.
  573. `imagemagick' Convert the LaTeX fragments to pdf files and use
  574. imagemagick to convert pdf files to png files.
  575. `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
  576. be loaded.
  577. t Synonym for `mathjax'."
  578. :group 'org-export-html
  579. :version "24.4"
  580. :package-version '(Org . "8.0")
  581. :type '(choice
  582. (const :tag "Do not process math in any way" nil)
  583. (const :tag "Use dvipng to make images" dvipng)
  584. (const :tag "Use imagemagick to make images" imagemagick)
  585. (const :tag "Use MathJax to display math" mathjax)
  586. (const :tag "Leave math verbatim" verbatim)))
  587. ;;;; Links :: Generic
  588. (defcustom org-html-link-org-files-as-html t
  589. "Non-nil means make file links to `file.org' point to `file.html'.
  590. When `org-mode' is exporting an `org-mode' file to HTML, links to
  591. non-html files are directly put into a href tag in HTML.
  592. However, links to other Org-mode files (recognized by the
  593. extension `.org.) should become links to the corresponding html
  594. file, assuming that the linked `org-mode' file will also be
  595. converted to HTML.
  596. When nil, the links still point to the plain `.org' file."
  597. :group 'org-export-html
  598. :type 'boolean)
  599. ;;;; Links :: Inline images
  600. (defcustom org-html-inline-images 'maybe
  601. "Non-nil means inline images into exported HTML pages.
  602. This is done using an <img> tag. When nil, an anchor with href is used to
  603. link to the image. If this option is `maybe', then images in links with
  604. an empty description will be inlined, while images with a description will
  605. be linked only."
  606. :group 'org-export-html
  607. :type '(choice (const :tag "Never" nil)
  608. (const :tag "Always" t)
  609. (const :tag "When there is no description" maybe)))
  610. (defcustom org-html-inline-image-rules
  611. '(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
  612. ("http" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
  613. ("https" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
  614. "Rules characterizing image files that can be inlined into HTML.
  615. A rule consists in an association whose key is the type of link
  616. to consider, and value is a regexp that will be matched against
  617. link's path.
  618. Note that, by default, the image extension *actually* allowed
  619. depend on the way the HTML file is processed. When used with
  620. pdflatex, pdf, jpg and png images are OK. When processing
  621. through dvi to Postscript, only ps and eps are allowed. The
  622. default we use here encompasses both."
  623. :group 'org-export-html
  624. :version "24.4"
  625. :package-version '(Org . "8.0")
  626. :type '(alist :key-type (string :tag "Type")
  627. :value-type (regexp :tag "Path")))
  628. ;;;; Plain Text
  629. (defcustom org-html-protect-char-alist
  630. '(("&" . "&amp;")
  631. ("<" . "&lt;")
  632. (">" . "&gt;"))
  633. "Alist of characters to be converted by `org-html-protect'."
  634. :group 'org-export-html
  635. :type '(repeat (cons (string :tag "Character")
  636. (string :tag "HTML equivalent"))))
  637. ;;;; Src Block
  638. (defcustom org-html-htmlize-output-type 'inline-css
  639. "Output type to be used by htmlize when formatting code snippets.
  640. Choices are `css', to export the CSS selectors only, or `inline-css', to
  641. export the CSS attribute values inline in the HTML. We use as default
  642. `inline-css', in order to make the resulting HTML self-containing.
  643. However, this will fail when using Emacs in batch mode for export, because
  644. then no rich font definitions are in place. It will also not be good if
  645. people with different Emacs setup contribute HTML files to a website,
  646. because the fonts will represent the individual setups. In these cases,
  647. it is much better to let Org/Htmlize assign classes only, and to use
  648. a style file to define the look of these classes.
  649. To get a start for your css file, start Emacs session and make sure that
  650. all the faces you are interested in are defined, for example by loading files
  651. in all modes you want. Then, use the command
  652. \\[org-html-htmlize-generate-css] to extract class definitions."
  653. :group 'org-export-html
  654. :type '(choice (const css) (const inline-css)))
  655. (defcustom org-html-htmlize-font-prefix "org-"
  656. "The prefix for CSS class names for htmlize font specifications."
  657. :group 'org-export-html
  658. :type 'string)
  659. ;;;; Table
  660. (defcustom org-html-table-tag
  661. "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
  662. "The HTML tag that is used to start a table.
  663. This must be a <table> tag, but you may change the options like
  664. borders and spacing."
  665. :group 'org-export-html
  666. :type 'string)
  667. (defcustom org-html-table-header-tags '("<th scope=\"%s\"%s>" . "</th>")
  668. "The opening tag for table header fields.
  669. This is customizable so that alignment options can be specified.
  670. The first %s will be filled with the scope of the field, either row or col.
  671. The second %s will be replaced by a style entry to align the field.
  672. See also the variable `org-html-table-use-header-tags-for-first-column'.
  673. See also the variable `org-html-table-align-individual-fields'."
  674. :group 'org-export-html
  675. :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
  676. (defcustom org-html-table-data-tags '("<td%s>" . "</td>")
  677. "The opening tag for table data fields.
  678. This is customizable so that alignment options can be specified.
  679. The first %s will be filled with the scope of the field, either row or col.
  680. The second %s will be replaced by a style entry to align the field.
  681. See also the variable `org-html-table-align-individual-fields'."
  682. :group 'org-export-html
  683. :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
  684. (defcustom org-html-table-row-tags '("<tr>" . "</tr>")
  685. "The opening tag for table data fields.
  686. This is customizable so that alignment options can be specified.
  687. Instead of strings, these can be Lisp forms that will be evaluated
  688. for each row in order to construct the table row tags. During evaluation,
  689. the variable `head' will be true when this is a header line, nil when this
  690. is a body line. And the variable `nline' will contain the line number,
  691. starting from 1 in the first header line. For example
  692. (setq org-html-table-row-tags
  693. (cons '(if head
  694. \"<tr>\"
  695. (if (= (mod nline 2) 1)
  696. \"<tr class=\\\"tr-odd\\\">\"
  697. \"<tr class=\\\"tr-even\\\">\"))
  698. \"</tr>\"))
  699. will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
  700. :group 'org-export-html
  701. :type '(cons
  702. (choice :tag "Opening tag"
  703. (string :tag "Specify")
  704. (sexp))
  705. (choice :tag "Closing tag"
  706. (string :tag "Specify")
  707. (sexp))))
  708. (defcustom org-html-table-align-individual-fields t
  709. "Non-nil means attach style attributes for alignment to each table field.
  710. When nil, alignment will only be specified in the column tags, but this
  711. is ignored by some browsers (like Firefox, Safari). Opera does it right
  712. though."
  713. :group 'org-export-html
  714. :type 'boolean)
  715. (defcustom org-html-table-use-header-tags-for-first-column nil
  716. "Non-nil means format column one in tables with header tags.
  717. When nil, also column one will use data tags."
  718. :group 'org-export-html
  719. :type 'boolean)
  720. (defcustom org-html-table-caption-above t
  721. "When non-nil, place caption string at the beginning of the table.
  722. Otherwise, place it near the end."
  723. :group 'org-export-html
  724. :type 'boolean)
  725. ;;;; Tags
  726. (defcustom org-html-tag-class-prefix ""
  727. "Prefix to class names for TODO keywords.
  728. Each tag gets a class given by the tag itself, with this prefix.
  729. The default prefix is empty because it is nice to just use the keyword
  730. as a class name. But if you get into conflicts with other, existing
  731. CSS classes, then this prefix can be very useful."
  732. :group 'org-export-html
  733. :type 'string)
  734. ;;;; Template :: Generic
  735. (defcustom org-html-extension "html"
  736. "The extension for exported HTML files."
  737. :group 'org-export-html
  738. :type 'string)
  739. (defcustom org-html-xml-declaration
  740. '(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
  741. ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
  742. "The extension for exported HTML files.
  743. %s will be replaced with the charset of the exported file.
  744. This may be a string, or an alist with export extensions
  745. and corresponding declarations."
  746. :group 'org-export-html
  747. :type '(choice
  748. (string :tag "Single declaration")
  749. (repeat :tag "Dependent on extension"
  750. (cons (string :tag "Extension")
  751. (string :tag "Declaration")))))
  752. (defcustom org-html-coding-system 'utf-8
  753. "Coding system for HTML export.
  754. Use utf-8 as the default value."
  755. :group 'org-export-html
  756. :version "24.4"
  757. :package-version '(Org . "8.0")
  758. :type 'coding-system)
  759. (defcustom org-html-doctype
  760. "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
  761. \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
  762. "Document type definition to use for exported HTML files.
  763. Can be set with the in-buffer HTML_DOCTYPE property or for
  764. publishing, with :html-doctype."
  765. :group 'org-export-html
  766. :version "24.4"
  767. :package-version '(Org . "8.0")
  768. :type 'string)
  769. (defcustom org-html-container-element "div"
  770. "HTML element to use for wrapping top level sections.
  771. Can be set with the in-buffer HTML_CONTAINER property or for
  772. publishing, with :html-container.
  773. Note that changing the default will prevent you from using
  774. org-info.js for your website."
  775. :group 'org-export-html
  776. :version "24.4"
  777. :package-version '(Org . "8.0")
  778. :type 'string)
  779. (defcustom org-html-divs
  780. '((preamble "div" "preamble")
  781. (content "div" "content")
  782. (postamble "div" "postamble"))
  783. "Alist of the threed section elements for HTML export.
  784. The car of each entry is one of 'preamble, 'content or 'postamble.
  785. The cdrs of each entry are the ELEMENT_TYPE and ID for each
  786. section of the exported document.
  787. Note that changing the default will prevent you from using
  788. org-info.js for your website."
  789. :group 'org-export-html
  790. :version "24.4"
  791. :package-version '(Org . "8.0")
  792. :type '(list :greedy t
  793. (list :tag "Preamble"
  794. (const :format "" preamble)
  795. (string :tag "element") (string :tag " id"))
  796. (list :tag "Content"
  797. (const :format "" content)
  798. (string :tag "element") (string :tag " id"))
  799. (list :tag "Postamble" (const :format "" postamble)
  800. (string :tag " id") (string :tag "element"))))
  801. ;;;; Template :: Mathjax
  802. (defcustom org-html-mathjax-options
  803. '((path "http://orgmode.org/mathjax/MathJax.js")
  804. (scale "100")
  805. (align "center")
  806. (indent "2em")
  807. (mathml nil))
  808. "Options for MathJax setup.
  809. path The path where to find MathJax
  810. scale Scaling for the HTML-CSS backend, usually between 100 and 133
  811. align How to align display math: left, center, or right
  812. indent If align is not center, how far from the left/right side?
  813. mathml Should a MathML player be used if available?
  814. This is faster and reduces bandwidth use, but currently
  815. sometimes has lower spacing quality. Therefore, the default is
  816. nil. When browsers get better, this switch can be flipped.
  817. You can also customize this for each buffer, using something like
  818. #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
  819. :group 'org-export-html
  820. :type '(list :greedy t
  821. (list :tag "path (the path from where to load MathJax.js)"
  822. (const :format " " path) (string))
  823. (list :tag "scale (scaling for the displayed math)"
  824. (const :format " " scale) (string))
  825. (list :tag "align (alignment of displayed equations)"
  826. (const :format " " align) (string))
  827. (list :tag "indent (indentation with left or right alignment)"
  828. (const :format " " indent) (string))
  829. (list :tag "mathml (should MathML display be used is possible)"
  830. (const :format " " mathml) (boolean))))
  831. (defcustom org-html-mathjax-template
  832. "<script type=\"text/javascript\" src=\"%PATH\">
  833. <!--/*--><![CDATA[/*><!--*/
  834. MathJax.Hub.Config({
  835. // Only one of the two following lines, depending on user settings
  836. // First allows browser-native MathML display, second forces HTML/CSS
  837. :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
  838. :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
  839. extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
  840. \"TeX/noUndefined.js\"],
  841. tex2jax: {
  842. inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
  843. displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
  844. skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
  845. ignoreClass: \"tex2jax_ignore\",
  846. processEscapes: false,
  847. processEnvironments: true,
  848. preview: \"TeX\"
  849. },
  850. showProcessingMessages: true,
  851. displayAlign: \"%ALIGN\",
  852. displayIndent: \"%INDENT\",
  853. \"HTML-CSS\": {
  854. scale: %SCALE,
  855. availableFonts: [\"STIX\",\"TeX\"],
  856. preferredFont: \"TeX\",
  857. webFont: \"TeX\",
  858. imageFont: \"TeX\",
  859. showMathMenu: true,
  860. },
  861. MMLorHTML: {
  862. prefer: {
  863. MSIE: \"MML\",
  864. Firefox: \"MML\",
  865. Opera: \"HTML\",
  866. other: \"HTML\"
  867. }
  868. }
  869. });
  870. /*]]>*///-->
  871. </script>"
  872. "The MathJax setup for XHTML files."
  873. :group 'org-export-html
  874. :type 'string)
  875. ;;;; Template :: Postamble
  876. (defcustom org-html-postamble 'auto
  877. "Non-nil means insert a postamble in HTML export.
  878. When set to 'auto, check against the
  879. `org-export-with-author/email/creator/date' variables to set the
  880. content of the postamble. When set to a string, use this string
  881. as the postamble. When t, insert a string as defined by the
  882. formatting string in `org-html-postamble-format'.
  883. When set to a function, apply this function and insert the
  884. returned string. The function takes the property list of export
  885. options as its only argument.
  886. Setting :html-postamble in publishing projects will take
  887. precedence over this variable."
  888. :group 'org-export-html
  889. :type '(choice (const :tag "No postamble" nil)
  890. (const :tag "Auto postamble" 'auto)
  891. (const :tag "Default formatting string" t)
  892. (string :tag "Custom formatting string")
  893. (function :tag "Function (must return a string)")))
  894. (defcustom org-html-postamble-format
  895. '(("en" "<p class=\"author\">Author: %a (%e)</p>
  896. <p class=\"date\">Date: %d</p>
  897. <p class=\"creator\">%c</p>
  898. <p class=\"xhtml-validation\">%v</p>"))
  899. "Alist of languages and format strings for the HTML postamble.
  900. The first element of each list is the language code, as used for
  901. the LANGUAGE keyword. See `org-export-default-language'
  902. The second element of each list is a format string to format the
  903. postamble itself. This format string can contain these elements:
  904. %t stands for the title.
  905. %a stands for the author's name.
  906. %e stands for the author's email.
  907. %d stands for the date.
  908. %c will be replaced by creator information. See
  909. `org-html-creator-string'.
  910. %v will be replaced by `org-html-validation-link'.
  911. %T will be replaced by the creation time of the HTML file.
  912. If you need to use a \"%\" character, you need to escape it
  913. like that: \"%%\"."
  914. :group 'org-export-html
  915. :type '(alist :key-type (string :tag "Language")
  916. :value-type (string :tag "Format string")))
  917. (defcustom org-html-validation-link
  918. "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
  919. "Link to HTML validation service."
  920. :group 'org-export-html
  921. :type 'string)
  922. (defcustom org-html-creator-string
  923. (format "Generated by <a href=\"http://orgmode.org\">Org</a> mode %s in <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s."
  924. (if (fboundp 'org-version) (org-version) "(Unknown)")
  925. emacs-version)
  926. "Information about the creator of the HTML document.
  927. This option can also be set on with the CREATOR keyword."
  928. :group 'org-export-html
  929. :type '(string :tag "Creator string"))
  930. ;;;; Template :: Preamble
  931. (defcustom org-html-preamble t
  932. "Non-nil means insert a preamble in HTML export.
  933. When t, insert a string as defined by the formatting string in
  934. `org-html-preamble-format'. When set to a string, use this
  935. formatting string instead (see `org-html-postamble-format' for an
  936. example of such a formatting string).
  937. When set to a function, apply this function and insert the
  938. returned string. The function takes the property list of export
  939. options as its only argument.
  940. Setting :html-preamble in publishing projects will take
  941. precedence over this variable."
  942. :group 'org-export-html
  943. :type '(choice (const :tag "No preamble" nil)
  944. (const :tag "Default preamble" t)
  945. (string :tag "Custom formatting string")
  946. (function :tag "Function (must return a string)")))
  947. (defcustom org-html-preamble-format '(("en" ""))
  948. "Alist of languages and format strings for the HTML preamble.
  949. The first element of each list is the language code, as used for
  950. the #+LANGUAGE keyword.
  951. The second element of each list is a format string to format the
  952. preamble itself. This format string can contain these elements:
  953. %t stands for the title.
  954. %a stands for the author's name.
  955. %e stands for the author's email.
  956. %d stands for the date.
  957. %c will be replaced by information about Org/Emacs versions.
  958. %v will be replaced by `org-html-validation-link'.
  959. %T will be replace by the creation time of the file.
  960. If you need to use a \"%\" character, you need to escape it
  961. like that: \"%%\".
  962. See the default value of `org-html-postamble-format' for an
  963. example."
  964. :group 'org-export-html
  965. :type '(alist :key-type (string :tag "Language")
  966. :value-type (string :tag "Format string")))
  967. (defcustom org-html-link-up ""
  968. "Where should the \"UP\" link of exported HTML pages lead?"
  969. :group 'org-export-html
  970. :type '(string :tag "File or URL"))
  971. (defcustom org-html-link-home ""
  972. "Where should the \"HOME\" link of exported HTML pages lead?"
  973. :group 'org-export-html
  974. :type '(string :tag "File or URL"))
  975. (defcustom org-html-home/up-format
  976. "<div id=\"org-div-home-and-up\">
  977. <a accesskey=\"h\" href=\"%s\"> UP </a>
  978. |
  979. <a accesskey=\"H\" href=\"%s\"> HOME </a>
  980. </div>"
  981. "Snippet used to insert the HOME and UP links.
  982. This is a format string, the first %s will receive the UP link,
  983. the second the HOME link. If both `org-html-link-up' and
  984. `org-html-link-home' are empty, the entire snippet will be
  985. ignored."
  986. :group 'org-export-html
  987. :type 'string)
  988. ;;;; Template :: Scripts
  989. (define-obsolete-variable-alias
  990. 'org-html-style-include-scripts 'org-html-head-include-scripts "24.4")
  991. (defcustom org-html-head-include-scripts t
  992. "Non-nil means include the JavaScript snippets in exported HTML files.
  993. The actual script is defined in `org-html-scripts' and should
  994. not be modified."
  995. :group 'org-export-html
  996. :version "24.4"
  997. :package-version '(Org . "8.0")
  998. :type 'boolean)
  999. ;;;; Template :: Styles
  1000. (define-obsolete-variable-alias
  1001. 'org-html-style-include-default 'org-html-head-include-default-style "24.4")
  1002. (defcustom org-html-head-include-default-style t
  1003. "Non-nil means include the default style in exported HTML files.
  1004. The actual style is defined in `org-html-style-default' and
  1005. should not be modified. Use `org-html-head' to use your own
  1006. style information."
  1007. :group 'org-export-html
  1008. :version "24.4"
  1009. :package-version '(Org . "8.0")
  1010. :type 'boolean)
  1011. ;;;###autoload
  1012. (put 'org-html-head-include-default-style 'safe-local-variable 'booleanp)
  1013. (define-obsolete-variable-alias 'org-html-style 'org-html-head "24.4")
  1014. (defcustom org-html-head ""
  1015. "Org-wide head definitions for exported HTML files.
  1016. This variable can contain the full HTML structure to provide a
  1017. style, including the surrounding HTML tags. You can consider
  1018. including definitions for the following classes: title, todo,
  1019. done, timestamp, timestamp-kwd, tag, target.
  1020. For example, a valid value would be:
  1021. <style type=\"text/css\">
  1022. <![CDATA[
  1023. p { font-weight: normal; color: gray; }
  1024. h1 { color: black; }
  1025. .title { text-align: center; }
  1026. .todo, .timestamp-kwd { color: red; }
  1027. .done { color: green; }
  1028. ]]>
  1029. </style>
  1030. If you want to refer to an external style, use something like
  1031. <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
  1032. As the value of this option simply gets inserted into the HTML
  1033. <head> header, you can use it to add any arbitrary text to the
  1034. header.
  1035. You can set this on a per-file basis using #+HTML_HEAD:,
  1036. or for publication projects using the :html-head property."
  1037. :group 'org-export-html
  1038. :version "24.4"
  1039. :package-version '(Org . "8.0")
  1040. :type 'string)
  1041. ;;;###autoload
  1042. (put 'org-html-head 'safe-local-variable 'stringp)
  1043. (defcustom org-html-head-extra ""
  1044. "More head information to add in the HTML output.
  1045. You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
  1046. or for publication projects using the :html-head-extra property."
  1047. :group 'org-export-html
  1048. :version "24.4"
  1049. :package-version '(Org . "8.0")
  1050. :type 'string)
  1051. ;;;###autoload
  1052. (put 'org-html-head-extra 'safe-local-variable 'stringp)
  1053. ;;;; Todos
  1054. (defcustom org-html-todo-kwd-class-prefix ""
  1055. "Prefix to class names for TODO keywords.
  1056. Each TODO keyword gets a class given by the keyword itself, with this prefix.
  1057. The default prefix is empty because it is nice to just use the keyword
  1058. as a class name. But if you get into conflicts with other, existing
  1059. CSS classes, then this prefix can be very useful."
  1060. :group 'org-export-html
  1061. :type 'string)
  1062. ;;; Internal Functions
  1063. (defun org-html-format-inline-image (src &optional
  1064. caption label attr standalone-p)
  1065. "Format an inline image from SRC.
  1066. CAPTION, LABEL and ATTR are optional arguments providing the
  1067. caption, the label and the attribute of the image.
  1068. When STANDALONE-P is t, wrap the <img.../> into a <div>...</div>."
  1069. (let* ((id (if (not label) ""
  1070. (format " id=\"%s\"" (org-export-solidify-link-text label))))
  1071. (attr (concat attr
  1072. (cond
  1073. ((string-match "\\<alt=" (or attr "")) "")
  1074. ((string-match "^ltxpng/" src)
  1075. (format " alt=\"%s\""
  1076. (org-html-encode-plain-text
  1077. (org-find-text-property-in-string
  1078. 'org-latex-src src))))
  1079. (t (format " alt=\"%s\""
  1080. (file-name-nondirectory src)))))))
  1081. (cond
  1082. (standalone-p
  1083. (let ((img (format "<img src=\"%s\" %s/>" src attr)))
  1084. (format "\n<div%s class=\"figure\">%s%s\n</div>"
  1085. id (format "\n<p>%s</p>" img)
  1086. (if (and caption (not (string= caption "")))
  1087. (format "\n<p>%s</p>" caption) ""))))
  1088. (t (format "<img src=\"%s\" %s/>" src (concat attr id))))))
  1089. (defun org-html--textarea-block (element)
  1090. "Transcode ELEMENT into a textarea block.
  1091. ELEMENT is either a src block or an example block."
  1092. (let* ((code (car (org-export-unravel-code element)))
  1093. (attr (org-export-read-attribute :attr_html element)))
  1094. (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
  1095. (or (plist-get attr :width) 80)
  1096. (or (plist-get attr :height) (org-count-lines code))
  1097. code)))
  1098. ;;;; Bibliography
  1099. (defun org-html-bibliography ()
  1100. "Find bibliography, cut it out and return it."
  1101. (catch 'exit
  1102. (let (beg end (cnt 1) bib)
  1103. (save-excursion
  1104. (goto-char (point-min))
  1105. (when (re-search-forward
  1106. "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t)
  1107. (setq beg (match-beginning 0))
  1108. (while (re-search-forward "</?div\\>" nil t)
  1109. (setq cnt (+ cnt (if (string= (match-string 0) "<div") +1 -1)))
  1110. (when (= cnt 0)
  1111. (and (looking-at ">") (forward-char 1))
  1112. (setq bib (buffer-substring beg (point)))
  1113. (delete-region beg (point))
  1114. (throw 'exit bib))))
  1115. nil))))
  1116. ;;;; Table
  1117. (defun org-html-splice-attributes (tag attributes)
  1118. "Return a HTML TAG edited wrt ATTRIBUTES."
  1119. (if (not attributes)
  1120. tag
  1121. (let (oldatt newatt)
  1122. (setq oldatt (org-extract-attributes-from-string tag)
  1123. tag (pop oldatt)
  1124. newatt (cdr (org-extract-attributes-from-string attributes)))
  1125. (while newatt
  1126. (setq oldatt (plist-put oldatt (pop newatt) (pop newatt))))
  1127. (if (string-match ">" tag)
  1128. (setq tag
  1129. (replace-match (concat (org-attributes-to-string oldatt) ">")
  1130. t t tag)))
  1131. tag)))
  1132. (defun org-export-splice-style (style extra)
  1133. "Return STYLE updated wrt EXTRA."
  1134. (if (and (stringp extra)
  1135. (string-match "\\S-" extra)
  1136. (string-match "</style>" style))
  1137. (concat (substring style 0 (match-beginning 0))
  1138. "\n" extra "\n"
  1139. (substring style (match-beginning 0)))
  1140. style))
  1141. (defun org-html-htmlize-region-for-paste (beg end)
  1142. "Convert the region between BEG and END to HTML, using htmlize.el.
  1143. This is much like `htmlize-region-for-paste', only that it uses
  1144. the settings define in the org-... variables."
  1145. (let* ((htmlize-output-type org-html-htmlize-output-type)
  1146. (htmlize-css-name-prefix org-html-htmlize-font-prefix)
  1147. (htmlbuf (htmlize-region beg end)))
  1148. (unwind-protect
  1149. (with-current-buffer htmlbuf
  1150. (buffer-substring (plist-get htmlize-buffer-places 'content-start)
  1151. (plist-get htmlize-buffer-places 'content-end)))
  1152. (kill-buffer htmlbuf))))
  1153. ;;;###autoload
  1154. (defun org-html-htmlize-generate-css ()
  1155. "Create the CSS for all font definitions in the current Emacs session.
  1156. Use this to create face definitions in your CSS style file that can then
  1157. be used by code snippets transformed by htmlize.
  1158. This command just produces a buffer that contains class definitions for all
  1159. faces used in the current Emacs session. You can copy and paste the ones you
  1160. need into your CSS file.
  1161. If you then set `org-html-htmlize-output-type' to `css', calls
  1162. to the function `org-html-htmlize-region-for-paste' will
  1163. produce code that uses these same face definitions."
  1164. (interactive)
  1165. (require 'htmlize)
  1166. (and (get-buffer "*html*") (kill-buffer "*html*"))
  1167. (with-temp-buffer
  1168. (let ((fl (face-list))
  1169. (htmlize-css-name-prefix "org-")
  1170. (htmlize-output-type 'css)
  1171. f i)
  1172. (while (setq f (pop fl)
  1173. i (and f (face-attribute f :inherit)))
  1174. (when (and (symbolp f) (or (not i) (not (listp i))))
  1175. (insert (org-add-props (copy-sequence "1") nil 'face f))))
  1176. (htmlize-region (point-min) (point-max))))
  1177. (org-pop-to-buffer-same-window "*html*")
  1178. (goto-char (point-min))
  1179. (if (re-search-forward "<style" nil t)
  1180. (delete-region (point-min) (match-beginning 0)))
  1181. (if (re-search-forward "</style>" nil t)
  1182. (delete-region (1+ (match-end 0)) (point-max)))
  1183. (beginning-of-line 1)
  1184. (if (looking-at " +") (replace-match ""))
  1185. (goto-char (point-min)))
  1186. (defun org-html--make-string (n string)
  1187. "Build a string by concatenating N times STRING."
  1188. (let (out) (dotimes (i n out) (setq out (concat string out)))))
  1189. (defun org-html-fix-class-name (kwd) ; audit callers of this function
  1190. "Turn todo keyword KWD into a valid class name.
  1191. Replaces invalid characters with \"_\"."
  1192. (save-match-data
  1193. (while (string-match "[^a-zA-Z0-9_]" kwd)
  1194. (setq kwd (replace-match "_" t t kwd))))
  1195. kwd)
  1196. (defun org-html-format-footnote-reference (n def refcnt)
  1197. "Format footnote reference N with definition DEF into HTML."
  1198. (let ((extra (if (= refcnt 1) "" (format ".%d" refcnt))))
  1199. (format org-html-footnote-format
  1200. (let* ((id (format "fnr.%s%s" n extra))
  1201. (href (format " href=\"#fn.%s\"" n))
  1202. (attributes (concat " class=\"footref\"" href)))
  1203. (org-html--anchor id n attributes)))))
  1204. (defun org-html-format-footnotes-section (section-name definitions)
  1205. "Format footnotes section SECTION-NAME."
  1206. (if (not definitions) ""
  1207. (format org-html-footnotes-section section-name definitions)))
  1208. (defun org-html-format-footnote-definition (fn)
  1209. "Format the footnote definition FN."
  1210. (let ((n (car fn)) (def (cdr fn)))
  1211. (format
  1212. "<div class=\"footdef\">%s %s</div>\n"
  1213. (format org-html-footnote-format
  1214. (let* ((id (format "fn.%s" n))
  1215. (href (format " href=\"#fnr.%s\"" n))
  1216. (attributes (concat " class=\"footnum\"" href)))
  1217. (org-html--anchor id n attributes)))
  1218. def)))
  1219. (defun org-html-footnote-section (info)
  1220. "Format the footnote section.
  1221. INFO is a plist used as a communication channel."
  1222. (let* ((fn-alist (org-export-collect-footnote-definitions
  1223. (plist-get info :parse-tree) info))
  1224. (fn-alist
  1225. (loop for (n type raw) in fn-alist collect
  1226. (cons n (if (eq (org-element-type raw) 'org-data)
  1227. (org-trim (org-export-data raw info))
  1228. (format "<p>%s</p>"
  1229. (org-trim (org-export-data raw info))))))))
  1230. (when fn-alist
  1231. (org-html-format-footnotes-section
  1232. (org-html--translate "Footnotes" info)
  1233. (format
  1234. "\n%s\n"
  1235. (mapconcat 'org-html-format-footnote-definition fn-alist "\n"))))))
  1236. ;;; Template
  1237. (defun org-html--build-meta-info (info)
  1238. "Return meta tags for exported document.
  1239. INFO is a plist used as a communication channel."
  1240. (let* ((title (org-export-data (plist-get info :title) info))
  1241. (author (and (plist-get info :with-author)
  1242. (let ((auth (plist-get info :author)))
  1243. (and auth (org-export-data auth info)))))
  1244. (description (plist-get info :description))
  1245. (keywords (plist-get info :keywords)))
  1246. (concat
  1247. (format "<title>%s</title>\n" title)
  1248. (format
  1249. (when :time-stamp-file
  1250. (format-time-string
  1251. (concat "<!-- " org-html--timestamp-format " -->\n"))))
  1252. (format
  1253. "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>\n"
  1254. (or (and org-html-coding-system
  1255. (fboundp 'coding-system-get)
  1256. (coding-system-get org-html-coding-system 'mime-charset))
  1257. "iso-8859-1"))
  1258. (format "<meta name=\"generator\" content=\"Org-mode\"/>\n")
  1259. (and author (format "<meta name=\"author\" content=\"%s\"/>\n" author))
  1260. (and description
  1261. (format "<meta name=\"description\" content=\"%s\"/>\n" description))
  1262. (and keywords
  1263. (format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords)))))
  1264. (defun org-html--build-head (info)
  1265. "Return information for the <head>..</head> of the HTML output.
  1266. INFO is a plist used as a communication channel."
  1267. (org-element-normalize-string
  1268. (concat
  1269. (when (plist-get info :html-head-include-default-style)
  1270. (org-element-normalize-string org-html-style-default))
  1271. (org-element-normalize-string (plist-get info :html-head))
  1272. (org-element-normalize-string (plist-get info :html-head-extra))
  1273. (when (and (plist-get info :html-htmlized-css-url)
  1274. (eq org-html-htmlize-output-type 'css))
  1275. (format "<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\" />\n"
  1276. (plist-get info :html-htmlized-css-url)))
  1277. (when (plist-get info :html-head-include-scripts) org-html-scripts))))
  1278. (defun org-html--build-mathjax-config (info)
  1279. "Insert the user setup into the mathjax template.
  1280. INFO is a plist used as a communication channel."
  1281. (when (and (memq (plist-get info :with-latex) '(mathjax t))
  1282. (org-element-map (plist-get info :parse-tree)
  1283. '(latex-fragment latex-environment) 'identity info t))
  1284. (let ((template org-html-mathjax-template)
  1285. (options org-html-mathjax-options)
  1286. (in-buffer (or (plist-get info :html-mathjax) ""))
  1287. name val (yes " ") (no "// ") x)
  1288. (mapc
  1289. (lambda (e)
  1290. (setq name (car e) val (nth 1 e))
  1291. (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
  1292. (setq val (car (read-from-string
  1293. (substring in-buffer (match-end 0))))))
  1294. (if (not (stringp val)) (setq val (format "%s" val)))
  1295. (if (string-match (concat "%" (upcase (symbol-name name))) template)
  1296. (setq template (replace-match val t t template))))
  1297. options)
  1298. (setq val (nth 1 (assq 'mathml options)))
  1299. (if (string-match (concat "\\<mathml:") in-buffer)
  1300. (setq val (car (read-from-string
  1301. (substring in-buffer (match-end 0))))))
  1302. ;; Exchange prefixes depending on mathml setting.
  1303. (if (not val) (setq x yes yes no no x))
  1304. ;; Replace cookies to turn on or off the config/jax lines.
  1305. (if (string-match ":MMLYES:" template)
  1306. (setq template (replace-match yes t t template)))
  1307. (if (string-match ":MMLNO:" template)
  1308. (setq template (replace-match no t t template)))
  1309. ;; Return the modified template.
  1310. (org-element-normalize-string template))))
  1311. (defun org-html-format-spec (info)
  1312. "Return format specification for elements that can be
  1313. used in the preamble or postamble."
  1314. `((?t . ,(org-export-data (plist-get info :title) info))
  1315. (?d . ,(org-export-data (org-export-get-date info) info))
  1316. (?T . ,(format-time-string org-html--timestamp-format))
  1317. (?a . ,(org-export-data (plist-get info :author) info))
  1318. (?e . ,(mapconcat
  1319. (lambda (e)
  1320. (format "<a href=\"mailto:%s\">%s</a>" e e))
  1321. (split-string (plist-get info :email) ",+ *")
  1322. ", "))
  1323. (?c . ,(plist-get info :creator))
  1324. (?v . ,(or org-html-validation-link ""))))
  1325. (defun org-html--build-pre/postamble (type info)
  1326. "Return document preamble or postamble as a string, or nil.
  1327. TYPE is either 'preamble or 'postamble, INFO is a plist used as a
  1328. communication channel."
  1329. (let ((section (plist-get info (intern (format ":html-%s" type))))
  1330. (spec (org-html-format-spec info)))
  1331. (when section
  1332. (let ((section-contents
  1333. (if (functionp section) (funcall section info)
  1334. (cond
  1335. ((stringp section) (format-spec section spec))
  1336. ((eq section 'auto)
  1337. (let ((date (cdr (assq ?d spec)))
  1338. (author (cdr (assq ?a spec)))
  1339. (email (cdr (assq ?e spec)))
  1340. (creator (cdr (assq ?c spec)))
  1341. (timestamp (cdr (assq ?T spec)))
  1342. (validation-link (cdr (assq ?v spec))))
  1343. (concat
  1344. (when (and (plist-get info :with-date)
  1345. (org-string-nw-p date))
  1346. (format "<p class=\"date\">%s: %s</p>\n"
  1347. (org-html--translate "Date" info)
  1348. date))
  1349. (when (and (plist-get info :with-author)
  1350. (org-string-nw-p author))
  1351. (format "<p class=\"author\">%s: %s</p>\n"
  1352. (org-html--translate "Author" info)
  1353. author))
  1354. (when (and (plist-get info :with-email)
  1355. (org-string-nw-p email))
  1356. (format "<p class=\"email\">%s: %s</p>\n"
  1357. (org-html--translate "Email" info)
  1358. email))
  1359. (when (plist-get info :time-stamp-file)
  1360. (format
  1361. "<p class=\"date\">%s: %s</p>\n"
  1362. (org-html--translate "Created" info)
  1363. (format-time-string org-html--timestamp-format)))
  1364. (when (plist-get info :with-creator)
  1365. (format "<p class=\"creator\">%s</p>\n"
  1366. creator))
  1367. (format "<p class=\"xhtml-validation\">%s</p>\n"
  1368. validation-link))))
  1369. (t (format-spec
  1370. (or (cadr (assoc
  1371. (plist-get info :language)
  1372. (eval (intern
  1373. (format "org-html-%s-format" type)))))
  1374. (cadr
  1375. (assoc
  1376. "en"
  1377. (eval
  1378. (intern (format "org-html-%s-format" type))))))
  1379. spec))))))
  1380. (when (org-string-nw-p section-contents)
  1381. (concat
  1382. (format "<%s id=\"%s\" class=\"%s\">\n"
  1383. (nth 1 (assq type org-html-divs))
  1384. (nth 2 (assq type org-html-divs))
  1385. org-html--pre/postamble-class)
  1386. (org-element-normalize-string section-contents)
  1387. (format "</%s>\n" (nth 1 (assq type org-html-divs)))))))))
  1388. (defun org-html-inner-template (contents info)
  1389. "Return body of document string after HTML conversion.
  1390. CONTENTS is the transcoded contents string. INFO is a plist
  1391. holding export options."
  1392. (concat
  1393. ;; Table of contents.
  1394. (let ((depth (plist-get info :with-toc)))
  1395. (when depth (org-html-toc depth info)))
  1396. ;; Document contents.
  1397. contents
  1398. ;; Footnotes section.
  1399. (org-html-footnote-section info)
  1400. ;; Bibliography.
  1401. (org-html-bibliography)))
  1402. (defun org-html-template (contents info)
  1403. "Return complete document string after HTML conversion.
  1404. CONTENTS is the transcoded contents string. INFO is a plist
  1405. holding export options."
  1406. (concat
  1407. (format
  1408. (or (and (stringp org-html-xml-declaration)
  1409. org-html-xml-declaration)
  1410. (cdr (assoc (plist-get info :html-extension)
  1411. org-html-xml-declaration))
  1412. (cdr (assoc "html" org-html-xml-declaration))
  1413. "")
  1414. (or (and org-html-coding-system
  1415. (fboundp 'coding-system-get)
  1416. (coding-system-get org-html-coding-system 'mime-charset))
  1417. "iso-8859-1"))
  1418. "\n"
  1419. (plist-get info :html-doctype)
  1420. "\n"
  1421. (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n"
  1422. (plist-get info :language) (plist-get info :language))
  1423. "<head>\n"
  1424. (org-html--build-meta-info info)
  1425. (org-html--build-head info)
  1426. (org-html--build-mathjax-config info)
  1427. "</head>\n"
  1428. "<body>\n"
  1429. (let ((link-up (org-trim (plist-get info :html-link-up)))
  1430. (link-home (org-trim (plist-get info :html-link-home))))
  1431. (unless (and (string= link-up "") (string= link-up ""))
  1432. (format org-html-home/up-format
  1433. (or link-up link-home)
  1434. (or link-home link-up))))
  1435. ;; Preamble.
  1436. (org-html--build-pre/postamble 'preamble info)
  1437. ;; Document contents.
  1438. (format "<%s id=\"%s\">\n"
  1439. (nth 1 (assq 'content org-html-divs))
  1440. (nth 2 (assq 'content org-html-divs)))
  1441. ;; Document title.
  1442. (let ((title (plist-get info :title)))
  1443. (format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title "") info)))
  1444. contents
  1445. (format "</%s>\n"
  1446. (nth 1 (assq 'content org-html-divs)))
  1447. ;; Postamble.
  1448. (org-html--build-pre/postamble 'postamble info)
  1449. ;; Closing document.
  1450. "</body>\n</html>"))
  1451. (defun org-html--translate (s info)
  1452. "Translate string S according to specified language.
  1453. INFO is a plist used as a communication channel."
  1454. (org-export-translate s :html info))
  1455. ;;;; Anchor
  1456. (defun org-html--anchor (&optional id desc attributes)
  1457. "Format a HTML anchor."
  1458. (let* ((name (and org-html-allow-name-attribute-in-anchors id))
  1459. (attributes (concat (and id (format " id=\"%s\"" id))
  1460. (and name (format " name=\"%s\"" name))
  1461. attributes)))
  1462. (format "<a%s>%s</a>" attributes (or desc ""))))
  1463. ;;;; Todo
  1464. (defun org-html--todo (todo)
  1465. "Format TODO keywords into HTML."
  1466. (when todo
  1467. (format "<span class=\"%s %s%s\">%s</span>"
  1468. (if (member todo org-done-keywords) "done" "todo")
  1469. org-html-todo-kwd-class-prefix (org-html-fix-class-name todo)
  1470. todo)))
  1471. ;;;; Tags
  1472. (defun org-html--tags (tags)
  1473. "Format TAGS into HTML."
  1474. (when tags
  1475. (format "<span class=\"tag\">%s</span>"
  1476. (mapconcat
  1477. (lambda (tag)
  1478. (format "<span class=\"%s\">%s</span>"
  1479. (concat org-html-tag-class-prefix
  1480. (org-html-fix-class-name tag))
  1481. tag))
  1482. tags "&#xa0;"))))
  1483. ;;;; Headline
  1484. (defun* org-html-format-headline
  1485. (todo todo-type priority text tags
  1486. &key level section-number headline-label &allow-other-keys)
  1487. "Format a headline in HTML."
  1488. (let ((section-number
  1489. (when section-number
  1490. (format "<span class=\"section-number-%d\">%s</span> "
  1491. level section-number)))
  1492. (todo (org-html--todo todo))
  1493. (tags (org-html--tags tags)))
  1494. (concat section-number todo (and todo " ") text
  1495. (and tags "&#xa0;&#xa0;&#xa0;") tags)))
  1496. ;;;; Src Code
  1497. (defun org-html-fontify-code (code lang)
  1498. "Color CODE with htmlize library.
  1499. CODE is a string representing the source code to colorize. LANG
  1500. is the language used for CODE, as a string, or nil."
  1501. (when code
  1502. (cond
  1503. ;; Case 1: No lang. Possibly an example block.
  1504. ((not lang)
  1505. ;; Simple transcoding.
  1506. (org-html-encode-plain-text code))
  1507. ;; Case 2: No htmlize or an inferior version of htmlize
  1508. ((not (and (require 'htmlize nil t) (fboundp 'htmlize-region-for-paste)))
  1509. ;; Emit a warning.
  1510. (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
  1511. ;; Simple transcoding.
  1512. (org-html-encode-plain-text code))
  1513. (t
  1514. ;; Map language
  1515. (setq lang (or (assoc-default lang org-src-lang-modes) lang))
  1516. (let* ((lang-mode (and lang (intern (format "%s-mode" lang)))))
  1517. (cond
  1518. ;; Case 1: Language is not associated with any Emacs mode
  1519. ((not (functionp lang-mode))
  1520. ;; Simple transcoding.
  1521. (org-html-encode-plain-text code))
  1522. ;; Case 2: Default. Fontify code.
  1523. (t
  1524. ;; htmlize
  1525. (setq code (with-temp-buffer
  1526. ;; Switch to language-specific mode.
  1527. (funcall lang-mode)
  1528. (insert code)
  1529. ;; Fontify buffer.
  1530. (font-lock-fontify-buffer)
  1531. ;; Remove formatting on newline characters.
  1532. (save-excursion
  1533. (let ((beg (point-min))
  1534. (end (point-max)))
  1535. (goto-char beg)
  1536. (while (progn (end-of-line) (< (point) end))
  1537. (put-text-property (point) (1+ (point)) 'face nil)
  1538. (forward-char 1))))
  1539. (org-src-mode)
  1540. (set-buffer-modified-p nil)
  1541. ;; Htmlize region.
  1542. (org-html-htmlize-region-for-paste
  1543. (point-min) (point-max))))
  1544. ;; Strip any enclosing <pre></pre> tags.
  1545. (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code) (match-end 0)))
  1546. (end (and beg (string-match "</pre>\\'" code))))
  1547. (if (and beg end) (substring code beg end) code)))))))))
  1548. (defun org-html-do-format-code
  1549. (code &optional lang refs retain-labels num-start)
  1550. "Format CODE string as source code.
  1551. Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
  1552. respectively, the language of the source code, as a string, an
  1553. alist between line numbers and references (as returned by
  1554. `org-export-unravel-code'), a boolean specifying if labels should
  1555. appear in the source code, and the number associated to the first
  1556. line of code."
  1557. (let* ((code-lines (org-split-string code "\n"))
  1558. (code-length (length code-lines))
  1559. (num-fmt
  1560. (and num-start
  1561. (format "%%%ds: "
  1562. (length (number-to-string (+ code-length num-start))))))
  1563. (code (org-html-fontify-code code lang)))
  1564. (org-export-format-code
  1565. code
  1566. (lambda (loc line-num ref)
  1567. (setq loc
  1568. (concat
  1569. ;; Add line number, if needed.
  1570. (when num-start
  1571. (format "<span class=\"linenr\">%s</span>"
  1572. (format num-fmt line-num)))
  1573. ;; Transcoded src line.
  1574. loc
  1575. ;; Add label, if needed.
  1576. (when (and ref retain-labels) (format " (%s)" ref))))
  1577. ;; Mark transcoded line as an anchor, if needed.
  1578. (if (not ref) loc
  1579. (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
  1580. ref loc)))
  1581. num-start refs)))
  1582. (defun org-html-format-code (element info)
  1583. "Format contents of ELEMENT as source code.
  1584. ELEMENT is either an example block or a src block. INFO is
  1585. a plist used as a communication channel."
  1586. (let* ((lang (org-element-property :language element))
  1587. ;; Extract code and references.
  1588. (code-info (org-export-unravel-code element))
  1589. (code (car code-info))
  1590. (refs (cdr code-info))
  1591. ;; Does the src block contain labels?
  1592. (retain-labels (org-element-property :retain-labels element))
  1593. ;; Does it have line numbers?
  1594. (num-start (case (org-element-property :number-lines element)
  1595. (continued (org-export-get-loc element info))
  1596. (new 0))))
  1597. (org-html-do-format-code code lang refs retain-labels num-start)))
  1598. ;;; Tables of Contents
  1599. (defun org-html-toc (depth info)
  1600. "Build a table of contents.
  1601. DEPTH is an integer specifying the depth of the table. INFO is a
  1602. plist used as a communication channel. Return the table of
  1603. contents as a string, or nil if it is empty."
  1604. (let ((toc-entries
  1605. (mapcar (lambda (headline)
  1606. (cons (org-html--format-toc-headline headline info)
  1607. (org-export-get-relative-level headline info)))
  1608. (org-export-collect-headlines info depth))))
  1609. (when toc-entries
  1610. (concat "<div id=\"table-of-contents\">\n"
  1611. (format "<h%d>%s</h%d>\n"
  1612. org-html-toplevel-hlevel
  1613. (org-html--translate "Table of Contents" info)
  1614. org-html-toplevel-hlevel)
  1615. "<div id=\"text-table-of-contents\">"
  1616. (org-html--toc-text toc-entries)
  1617. "</div>\n"
  1618. "</div>\n"))))
  1619. (defun org-html--toc-text (toc-entries)
  1620. "Return innards of a table of contents, as a string.
  1621. TOC-ENTRIES is an alist where key is an entry title, as a string,
  1622. and value is its relative level, as an integer."
  1623. (let* ((prev-level (1- (cdar toc-entries)))
  1624. (start-level prev-level))
  1625. (concat
  1626. (mapconcat
  1627. (lambda (entry)
  1628. (let ((headline (car entry))
  1629. (level (cdr entry)))
  1630. (concat
  1631. (let* ((cnt (- level prev-level))
  1632. (times (if (> cnt 0) (1- cnt) (- cnt)))
  1633. rtn)
  1634. (setq prev-level level)
  1635. (concat
  1636. (org-html--make-string
  1637. times (cond ((> cnt 0) "\n<ul>\n<li>")
  1638. ((< cnt 0) "</li>\n</ul>\n")))
  1639. (if (> cnt 0) "\n<ul>\n<li>" "</li>\n<li>")))
  1640. headline)))
  1641. toc-entries "")
  1642. (org-html--make-string (- prev-level start-level) "</li>\n</ul>\n"))))
  1643. (defun org-html--format-toc-headline (headline info)
  1644. "Return an appropriate table of contents entry for HEADLINE.
  1645. INFO is a plist used as a communication channel."
  1646. (let* ((headline-number (org-export-get-headline-number headline info))
  1647. (section-number
  1648. (and (not (org-export-low-level-p headline info))
  1649. (org-export-numbered-headline-p headline info)
  1650. (concat (mapconcat 'number-to-string headline-number ".") ". ")))
  1651. (tags (and (eq (plist-get info :with-tags) t)
  1652. (org-export-get-tags headline info))))
  1653. (format "<a href=\"#%s\">%s</a>"
  1654. ;; Label.
  1655. (org-export-solidify-link-text
  1656. (or (org-element-property :CUSTOM_ID headline)
  1657. (concat "sec-" (mapconcat 'number-to-string
  1658. headline-number "-"))))
  1659. ;; Body.
  1660. (concat section-number
  1661. (org-export-data-with-translations
  1662. (org-export-get-alt-title headline info)
  1663. ;; Ignore any footnote-reference, link,
  1664. ;; radio-target and target in table of contents.
  1665. (append
  1666. '((footnote-reference . ignore)
  1667. (link . (lambda (link desc i) desc))
  1668. (radio-target . (lambda (radio desc i) desc))
  1669. (target . ignore))
  1670. (org-export-backend-translate-table 'html))
  1671. info)
  1672. (and tags "&#xa0;&#xa0;&#xa0;") (org-html--tags tags)))))
  1673. (defun org-html-list-of-listings (info)
  1674. "Build a list of listings.
  1675. INFO is a plist used as a communication channel. Return the list
  1676. of listings as a string, or nil if it is empty."
  1677. (let ((lol-entries (org-export-collect-listings info)))
  1678. (when lol-entries
  1679. (concat "<div id=\"list-of-listings\">\n"
  1680. (format "<h%d>%s</h%d>\n"
  1681. org-html-toplevel-hlevel
  1682. (org-html--translate "List of Listings" info)
  1683. org-html-toplevel-hlevel)
  1684. "<div id=\"text-list-of-listings\">\n<ul>\n"
  1685. (let ((count 0)
  1686. (initial-fmt (org-html--translate "Listing %d:" info)))
  1687. (mapconcat
  1688. (lambda (entry)
  1689. (let ((label (org-element-property :name entry))
  1690. (title (org-trim
  1691. (org-export-data
  1692. (or (org-export-get-caption entry t)
  1693. (org-export-get-caption entry))
  1694. info))))
  1695. (concat
  1696. "<li>"
  1697. (if (not label)
  1698. (concat (format initial-fmt (incf count)) " " title)
  1699. (format "<a href=\"#%s\">%s %s</a>"
  1700. (org-export-solidify-link-text label)
  1701. (format initial-fmt (incf count))
  1702. title))
  1703. "</li>")))
  1704. lol-entries "\n"))
  1705. "\n</ul>\n</div>\n</div>"))))
  1706. (defun org-html-list-of-tables (info)
  1707. "Build a list of tables.
  1708. INFO is a plist used as a communication channel. Return the list
  1709. of tables as a string, or nil if it is empty."
  1710. (let ((lol-entries (org-export-collect-tables info)))
  1711. (when lol-entries
  1712. (concat "<div id=\"list-of-tables\">\n"
  1713. (format "<h%d>%s</h%d>\n"
  1714. org-html-toplevel-hlevel
  1715. (org-html--translate "List of Tables" info)
  1716. org-html-toplevel-hlevel)
  1717. "<div id=\"text-list-of-tables\">\n<ul>\n"
  1718. (let ((count 0)
  1719. (initial-fmt (org-html--translate "Table %d:" info)))
  1720. (mapconcat
  1721. (lambda (entry)
  1722. (let ((label (org-element-property :name entry))
  1723. (title (org-trim
  1724. (org-export-data
  1725. (or (org-export-get-caption entry t)
  1726. (org-export-get-caption entry))
  1727. info))))
  1728. (concat
  1729. "<li>"
  1730. (if (not label)
  1731. (concat (format initial-fmt (incf count)) " " title)
  1732. (format "<a href=\"#%s\">%s %s</a>"
  1733. (org-export-solidify-link-text label)
  1734. (format initial-fmt (incf count))
  1735. title))
  1736. "</li>")))
  1737. lol-entries "\n"))
  1738. "\n</ul>\n</div>\n</div>"))))
  1739. ;;; Transcode Functions
  1740. ;;;; Bold
  1741. (defun org-html-bold (bold contents info)
  1742. "Transcode BOLD from Org to HTML.
  1743. CONTENTS is the text with bold markup. INFO is a plist holding
  1744. contextual information."
  1745. (format (or (cdr (assq 'bold org-html-text-markup-alist)) "%s")
  1746. contents))
  1747. ;;;; Center Block
  1748. (defun org-html-center-block (center-block contents info)
  1749. "Transcode a CENTER-BLOCK element from Org to HTML.
  1750. CONTENTS holds the contents of the block. INFO is a plist
  1751. holding contextual information."
  1752. (format "<div class=\"center\">\n%s</div>" contents))
  1753. ;;;; Clock
  1754. (defun org-html-clock (clock contents info)
  1755. "Transcode a CLOCK element from Org to HTML.
  1756. CONTENTS is nil. INFO is a plist used as a communication
  1757. channel."
  1758. (format "<p>
  1759. <span class=\"timestamp-wrapper\">
  1760. <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
  1761. </span>
  1762. </p>"
  1763. org-clock-string
  1764. (org-translate-time
  1765. (org-element-property :raw-value
  1766. (org-element-property :value clock)))
  1767. (let ((time (org-element-property :duration clock)))
  1768. (and time (format " <span class=\"timestamp\">(%s)</span>" time)))))
  1769. ;;;; Code
  1770. (defun org-html-code (code contents info)
  1771. "Transcode CODE from Org to HTML.
  1772. CONTENTS is nil. INFO is a plist holding contextual
  1773. information."
  1774. (format (or (cdr (assq 'code org-html-text-markup-alist)) "%s")
  1775. (org-html-plain-text (org-element-property :value code) info)))
  1776. ;;;; Drawer
  1777. (defun org-html-drawer (drawer contents info)
  1778. "Transcode a DRAWER element from Org to HTML.
  1779. CONTENTS holds the contents of the block. INFO is a plist
  1780. holding contextual information."
  1781. (if (functionp org-html-format-drawer-function)
  1782. (funcall org-html-format-drawer-function
  1783. (org-element-property :drawer-name drawer)
  1784. contents)
  1785. ;; If there's no user defined function: simply
  1786. ;; display contents of the drawer.
  1787. contents))
  1788. ;;;; Dynamic Block
  1789. (defun org-html-dynamic-block (dynamic-block contents info)
  1790. "Transcode a DYNAMIC-BLOCK element from Org to HTML.
  1791. CONTENTS holds the contents of the block. INFO is a plist
  1792. holding contextual information. See `org-export-data'."
  1793. contents)
  1794. ;;;; Entity
  1795. (defun org-html-entity (entity contents info)
  1796. "Transcode an ENTITY object from Org to HTML.
  1797. CONTENTS are the definition itself. INFO is a plist holding
  1798. contextual information."
  1799. (org-element-property :html entity))
  1800. ;;;; Example Block
  1801. (defun org-html-example-block (example-block contents info)
  1802. "Transcode a EXAMPLE-BLOCK element from Org to HTML.
  1803. CONTENTS is nil. INFO is a plist holding contextual
  1804. information."
  1805. (if (org-export-read-attribute :attr_html example-block :textarea)
  1806. (org-html--textarea-block example-block)
  1807. (format "<pre class=\"example\">\n%s</pre>"
  1808. (org-html-format-code example-block info))))
  1809. ;;;; Export Snippet
  1810. (defun org-html-export-snippet (export-snippet contents info)
  1811. "Transcode a EXPORT-SNIPPET object from Org to HTML.
  1812. CONTENTS is nil. INFO is a plist holding contextual
  1813. information."
  1814. (when (eq (org-export-snippet-backend export-snippet) 'html)
  1815. (org-element-property :value export-snippet)))
  1816. ;;;; Export Block
  1817. (defun org-html-export-block (export-block contents info)
  1818. "Transcode a EXPORT-BLOCK element from Org to HTML.
  1819. CONTENTS is nil. INFO is a plist holding contextual information."
  1820. (when (string= (org-element-property :type export-block) "HTML")
  1821. (org-remove-indentation (org-element-property :value export-block))))
  1822. ;;;; Fixed Width
  1823. (defun org-html-fixed-width (fixed-width contents info)
  1824. "Transcode a FIXED-WIDTH element from Org to HTML.
  1825. CONTENTS is nil. INFO is a plist holding contextual information."
  1826. (format "<pre class=\"example\">\n%s</pre>"
  1827. (org-html-do-format-code
  1828. (org-remove-indentation
  1829. (org-element-property :value fixed-width)))))
  1830. ;;;; Footnote Reference
  1831. (defun org-html-footnote-reference (footnote-reference contents info)
  1832. "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
  1833. CONTENTS is nil. INFO is a plist holding contextual information."
  1834. (concat
  1835. ;; Insert separator between two footnotes in a row.
  1836. (let ((prev (org-export-get-previous-element footnote-reference info)))
  1837. (when (eq (org-element-type prev) 'footnote-reference)
  1838. org-html-footnote-separator))
  1839. (cond
  1840. ((not (org-export-footnote-first-reference-p footnote-reference info))
  1841. (org-html-format-footnote-reference
  1842. (org-export-get-footnote-number footnote-reference info)
  1843. "IGNORED" 100))
  1844. ;; Inline definitions are secondary strings.
  1845. ((eq (org-element-property :type footnote-reference) 'inline)
  1846. (org-html-format-footnote-reference
  1847. (org-export-get-footnote-number footnote-reference info)
  1848. "IGNORED" 1))
  1849. ;; Non-inline footnotes definitions are full Org data.
  1850. (t (org-html-format-footnote-reference
  1851. (org-export-get-footnote-number footnote-reference info)
  1852. "IGNORED" 1)))))
  1853. ;;;; Headline
  1854. (defun org-html-format-headline--wrap
  1855. (headline info &optional format-function &rest extra-keys)
  1856. "Transcode a HEADLINE element from Org to HTML.
  1857. CONTENTS holds the contents of the headline. INFO is a plist
  1858. holding contextual information."
  1859. (let* ((level (+ (org-export-get-relative-level headline info)
  1860. (1- org-html-toplevel-hlevel)))
  1861. (headline-number (org-export-get-headline-number headline info))
  1862. (section-number (and (not (org-export-low-level-p headline info))
  1863. (org-export-numbered-headline-p headline info)
  1864. (mapconcat 'number-to-string
  1865. headline-number ".")))
  1866. (todo (and (plist-get info :with-todo-keywords)
  1867. (let ((todo (org-element-property :todo-keyword headline)))
  1868. (and todo (org-export-data todo info)))))
  1869. (todo-type (and todo (org-element-property :todo-type headline)))
  1870. (priority (and (plist-get info :with-priority)
  1871. (org-element-property :priority headline)))
  1872. (text (org-export-data (org-element-property :title headline) info))
  1873. (tags (and (plist-get info :with-tags)
  1874. (org-export-get-tags headline info)))
  1875. (headline-label (or (org-element-property :CUSTOM_ID headline)
  1876. (concat "sec-" (mapconcat 'number-to-string
  1877. headline-number "-"))))
  1878. (format-function (cond
  1879. ((functionp format-function) format-function)
  1880. ((functionp org-html-format-headline-function)
  1881. (function*
  1882. (lambda (todo todo-type priority text tags
  1883. &allow-other-keys)
  1884. (funcall org-html-format-headline-function
  1885. todo todo-type priority text tags))))
  1886. (t 'org-html-format-headline))))
  1887. (apply format-function
  1888. todo todo-type priority text tags
  1889. :headline-label headline-label :level level
  1890. :section-number section-number extra-keys)))
  1891. (defun org-html-headline (headline contents info)
  1892. "Transcode a HEADLINE element from Org to HTML.
  1893. CONTENTS holds the contents of the headline. INFO is a plist
  1894. holding contextual information."
  1895. ;; Empty contents?
  1896. (setq contents (or contents ""))
  1897. (let* ((numberedp (org-export-numbered-headline-p headline info))
  1898. (level (org-export-get-relative-level headline info))
  1899. (text (org-export-data (org-element-property :title headline) info))
  1900. (todo (and (plist-get info :with-todo-keywords)
  1901. (let ((todo (org-element-property :todo-keyword headline)))
  1902. (and todo (org-export-data todo info)))))
  1903. (todo-type (and todo (org-element-property :todo-type headline)))
  1904. (tags (and (plist-get info :with-tags)
  1905. (org-export-get-tags headline info)))
  1906. (priority (and (plist-get info :with-priority)
  1907. (org-element-property :priority headline)))
  1908. (section-number (and (org-export-numbered-headline-p headline info)
  1909. (mapconcat 'number-to-string
  1910. (org-export-get-headline-number
  1911. headline info) ".")))
  1912. ;; Create the headline text.
  1913. (full-text (org-html-format-headline--wrap headline info)))
  1914. (cond
  1915. ;; Case 1: This is a footnote section: ignore it.
  1916. ((org-element-property :footnote-section-p headline) nil)
  1917. ;; Case 2. This is a deep sub-tree: export it as a list item.
  1918. ;; Also export as items headlines for which no section
  1919. ;; format has been found.
  1920. ((org-export-low-level-p headline info)
  1921. ;; Build the real contents of the sub-tree.
  1922. (let* ((type (if numberedp 'ordered 'unordered))
  1923. (itemized-body (org-html-format-list-item
  1924. contents type nil nil full-text)))
  1925. (concat
  1926. (and (org-export-first-sibling-p headline info)
  1927. (org-html-begin-plain-list type))
  1928. itemized-body
  1929. (and (org-export-last-sibling-p headline info)
  1930. (org-html-end-plain-list type)))))
  1931. ;; Case 3. Standard headline. Export it as a section.
  1932. (t
  1933. (let* ((section-number (mapconcat 'number-to-string
  1934. (org-export-get-headline-number
  1935. headline info) "-"))
  1936. (ids (remove 'nil
  1937. (list (org-element-property :CUSTOM_ID headline)
  1938. (concat "sec-" section-number)
  1939. (org-element-property :ID headline))))
  1940. (preferred-id (car ids))
  1941. (extra-ids (cdr ids))
  1942. (extra-class (org-element-property :HTML_CONTAINER_CLASS headline))
  1943. (level1 (+ level (1- org-html-toplevel-hlevel)))
  1944. (first-content (car (org-element-contents headline))))
  1945. (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
  1946. (if (= 1 (org-export-get-relative-level headline info))
  1947. (plist-get info :html-container)
  1948. "div")
  1949. (format "outline-container-%s"
  1950. (or (org-element-property :CUSTOM_ID headline)
  1951. section-number))
  1952. (concat (format "outline-%d" level1) (and extra-class " ")
  1953. extra-class)
  1954. (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
  1955. level1
  1956. preferred-id
  1957. (mapconcat
  1958. (lambda (x)
  1959. (let ((id (org-export-solidify-link-text
  1960. (if (org-uuidgen-p x) (concat "ID-" x)
  1961. x))))
  1962. (org-html--anchor id)))
  1963. extra-ids "")
  1964. full-text
  1965. level1)
  1966. ;; When there is no section, pretend there is an empty
  1967. ;; one to get the correct <div class="outline- ...>
  1968. ;; which is needed by `org-info.js'.
  1969. (if (not (eq (org-element-type first-content) 'section))
  1970. (concat (org-html-section first-content "" info)
  1971. contents)
  1972. contents)
  1973. (if (= 1 (org-export-get-relative-level headline info))
  1974. (plist-get info :html-container)
  1975. "div")))))))
  1976. ;;;; Horizontal Rule
  1977. (defun org-html-horizontal-rule (horizontal-rule contents info)
  1978. "Transcode an HORIZONTAL-RULE object from Org to HTML.
  1979. CONTENTS is nil. INFO is a plist holding contextual information."
  1980. "<hr/>")
  1981. ;;;; Inline Src Block
  1982. (defun org-html-inline-src-block (inline-src-block contents info)
  1983. "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
  1984. CONTENTS holds the contents of the item. INFO is a plist holding
  1985. contextual information."
  1986. (let* ((org-lang (org-element-property :language inline-src-block))
  1987. (code (org-element-property :value inline-src-block)))
  1988. (error "Cannot export inline src block")))
  1989. ;;;; Inlinetask
  1990. (defun org-html-format-section (text class &optional id)
  1991. "Format a section with TEXT into a HTML div with CLASS and ID."
  1992. (let ((extra (concat (when id (format " id=\"%s\"" id)))))
  1993. (concat (format "<div class=\"%s\"%s>\n" class extra) text "</div>\n")))
  1994. (defun org-html-inlinetask (inlinetask contents info)
  1995. "Transcode an INLINETASK element from Org to HTML.
  1996. CONTENTS holds the contents of the block. INFO is a plist
  1997. holding contextual information."
  1998. (cond
  1999. ;; If `org-html-format-inlinetask-function' is provided, call it
  2000. ;; with appropriate arguments.
  2001. ((functionp org-html-format-inlinetask-function)
  2002. (let ((format-function
  2003. (function*
  2004. (lambda (todo todo-type priority text tags
  2005. &key contents &allow-other-keys)
  2006. (funcall org-html-format-inlinetask-function
  2007. todo todo-type priority text tags contents)))))
  2008. (org-html-format-headline--wrap
  2009. inlinetask info format-function :contents contents)))
  2010. ;; Otherwise, use a default template.
  2011. (t (format "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>"
  2012. (org-html-format-headline--wrap inlinetask info)
  2013. contents))))
  2014. ;;;; Italic
  2015. (defun org-html-italic (italic contents info)
  2016. "Transcode ITALIC from Org to HTML.
  2017. CONTENTS is the text with italic markup. INFO is a plist holding
  2018. contextual information."
  2019. (format (or (cdr (assq 'italic org-html-text-markup-alist)) "%s") contents))
  2020. ;;;; Item
  2021. (defun org-html-checkbox (checkbox)
  2022. "Format CHECKBOX into HTML."
  2023. (case checkbox (on "<code>[X]</code>")
  2024. (off "<code>[&#xa0;]</code>")
  2025. (trans "<code>[-]</code>")
  2026. (t "")))
  2027. (defun org-html-format-list-item (contents type checkbox
  2028. &optional term-counter-id
  2029. headline)
  2030. "Format a list item into HTML."
  2031. (let ((checkbox (concat (org-html-checkbox checkbox) (and checkbox " "))))
  2032. (concat
  2033. (case type
  2034. (ordered
  2035. (let* ((counter term-counter-id)
  2036. (extra (if counter (format " value=\"%s\"" counter) "")))
  2037. (concat
  2038. (format "<li%s>" extra)
  2039. (when headline (concat headline "<br/>")))))
  2040. (unordered
  2041. (let* ((id term-counter-id)
  2042. (extra (if id (format " id=\"%s\"" id) "")))
  2043. (concat
  2044. (format "<li%s>" extra)
  2045. (when headline (concat headline "<br/>")))))
  2046. (descriptive
  2047. (let* ((term term-counter-id))
  2048. (setq term (or term "(no term)"))
  2049. ;; Check-boxes in descriptive lists are associated to tag.
  2050. (concat (format "<dt> %s </dt>"
  2051. (concat checkbox term))
  2052. "<dd>"))))
  2053. (unless (eq type 'descriptive) checkbox)
  2054. contents
  2055. (case type
  2056. (ordered "</li>")
  2057. (unordered "</li>")
  2058. (descriptive "</dd>")))))
  2059. (defun org-html-item (item contents info)
  2060. "Transcode an ITEM element from Org to HTML.
  2061. CONTENTS holds the contents of the item. INFO is a plist holding
  2062. contextual information."
  2063. (let* ((plain-list (org-export-get-parent item))
  2064. (type (org-element-property :type plain-list))
  2065. (counter (org-element-property :counter item))
  2066. (checkbox (org-element-property :checkbox item))
  2067. (tag (let ((tag (org-element-property :tag item)))
  2068. (and tag (org-export-data tag info)))))
  2069. (org-html-format-list-item
  2070. contents type checkbox (or tag counter))))
  2071. ;;;; Keyword
  2072. (defun org-html-keyword (keyword contents info)
  2073. "Transcode a KEYWORD element from Org to HTML.
  2074. CONTENTS is nil. INFO is a plist holding contextual information."
  2075. (let ((key (org-element-property :key keyword))
  2076. (value (org-element-property :value keyword)))
  2077. (cond
  2078. ((string= key "HTML") value)
  2079. ((string= key "TOC")
  2080. (let ((value (downcase value)))
  2081. (cond
  2082. ((string-match "\\<headlines\\>" value)
  2083. (let ((depth (or (and (string-match "[0-9]+" value)
  2084. (string-to-number (match-string 0 value)))
  2085. (plist-get info :with-toc))))
  2086. (org-html-toc depth info)))
  2087. ((string= "listings" value) (org-html-list-of-listings info))
  2088. ((string= "tables" value) (org-html-list-of-tables info))))))))
  2089. ;;;; Latex Environment
  2090. (defun org-html-format-latex (latex-frag processing-type)
  2091. "Format the LaTeX fragment LATEX-FRAG into HTML."
  2092. (let ((cache-relpath "") (cache-dir "") bfn)
  2093. (unless (eq processing-type 'mathjax)
  2094. (setq bfn (buffer-file-name)
  2095. cache-relpath
  2096. (concat "ltxpng/"
  2097. (file-name-sans-extension
  2098. (file-name-nondirectory bfn)))
  2099. cache-dir (file-name-directory bfn)))
  2100. (with-temp-buffer
  2101. (insert latex-frag)
  2102. (org-format-latex cache-relpath cache-dir nil "Creating LaTeX Image..."
  2103. nil nil processing-type)
  2104. (buffer-string))))
  2105. (defun org-html-latex-environment (latex-environment contents info)
  2106. "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
  2107. CONTENTS is nil. INFO is a plist holding contextual information."
  2108. (let ((processing-type (plist-get info :with-latex))
  2109. (latex-frag (org-remove-indentation
  2110. (org-element-property :value latex-environment)))
  2111. (caption (org-export-data
  2112. (org-export-get-caption latex-environment) info))
  2113. (attr nil) ; FIXME
  2114. (label (org-element-property :name latex-environment)))
  2115. (cond
  2116. ((memq processing-type '(t mathjax))
  2117. (org-html-format-latex latex-frag 'mathjax))
  2118. ((eq processing-type 'dvipng)
  2119. (let* ((formula-link (org-html-format-latex
  2120. latex-frag processing-type)))
  2121. (when (and formula-link
  2122. (string-match "file:\\([^]]*\\)" formula-link))
  2123. (org-html-format-inline-image
  2124. (match-string 1 formula-link) caption label attr t))))
  2125. (t latex-frag))))
  2126. ;;;; Latex Fragment
  2127. (defun org-html-latex-fragment (latex-fragment contents info)
  2128. "Transcode a LATEX-FRAGMENT object from Org to HTML.
  2129. CONTENTS is nil. INFO is a plist holding contextual information."
  2130. (let ((latex-frag (org-element-property :value latex-fragment))
  2131. (processing-type (plist-get info :with-latex)))
  2132. (case processing-type
  2133. ((t mathjax)
  2134. (org-html-format-latex latex-frag 'mathjax))
  2135. (dvipng
  2136. (let* ((formula-link (org-html-format-latex
  2137. latex-frag processing-type)))
  2138. (when (and formula-link
  2139. (string-match "file:\\([^]]*\\)" formula-link))
  2140. (org-html-format-inline-image
  2141. (match-string 1 formula-link)))))
  2142. (t latex-frag))))
  2143. ;;;; Line Break
  2144. (defun org-html-line-break (line-break contents info)
  2145. "Transcode a LINE-BREAK object from Org to HTML.
  2146. CONTENTS is nil. INFO is a plist holding contextual information."
  2147. "<br/>\n")
  2148. ;;;; Link
  2149. (defun org-html-link--inline-image (link desc info)
  2150. "Return HTML code for an inline image.
  2151. LINK is the link pointing to the inline image. INFO is a plist
  2152. used as a communication channel.
  2153. Inline images can have these attributes:
  2154. #+ATTR_HTML: :width 100px :height 100px :alt \"Alt description\"."
  2155. (let* ((type (org-element-property :type link))
  2156. (raw-path (org-element-property :path link))
  2157. (path (cond ((member type '("http" "https"))
  2158. (concat type ":" raw-path))
  2159. ((file-name-absolute-p raw-path)
  2160. (expand-file-name raw-path))
  2161. (t raw-path)))
  2162. (parent (org-export-get-parent-element link))
  2163. (caption (org-export-data (org-export-get-caption parent) info))
  2164. (label (org-element-property :name parent))
  2165. (attrs (org-export-read-attribute :attr_html parent))
  2166. (alt (plist-get attrs :alt))
  2167. (width (plist-get attrs :width))
  2168. (height (plist-get attrs :height))
  2169. (options (plist-get attrs :options)))
  2170. ;; Return proper string, depending on DISPOSITION.
  2171. (org-html-format-inline-image
  2172. path caption label
  2173. (mapconcat 'identity
  2174. (delq nil (list (if width (format "width=\"%s\"" width))
  2175. (if alt (format "alt=\"%s\"" alt))
  2176. (if height (format "height=\"%s\"" height))
  2177. options)) " ")
  2178. (org-html-standalone-image-p link info))))
  2179. (defvar org-html-standalone-image-predicate)
  2180. (defun org-html-standalone-image-p (element info &optional predicate)
  2181. "Test if ELEMENT is a standalone image for the purpose HTML export.
  2182. INFO is a plist holding contextual information.
  2183. Return non-nil, if ELEMENT is of type paragraph and it's sole
  2184. content, save for whitespaces, is a link that qualifies as an
  2185. inline image.
  2186. Return non-nil, if ELEMENT is of type link and it's containing
  2187. paragraph has no other content save for leading and trailing
  2188. whitespaces.
  2189. Return nil, otherwise.
  2190. Bind `org-html-standalone-image-predicate' to constrain
  2191. paragraph further. For example, to check for only captioned
  2192. standalone images, do the following.
  2193. \(setq org-html-standalone-image-predicate
  2194. \(lambda \(paragraph\)
  2195. \(org-element-property :caption paragraph\)\)\)"
  2196. (let ((paragraph (case (org-element-type element)
  2197. (paragraph element)
  2198. (link (and (org-export-inline-image-p
  2199. element org-html-inline-image-rules)
  2200. (org-export-get-parent element)))
  2201. (t nil))))
  2202. (when (eq (org-element-type paragraph) 'paragraph)
  2203. (when (or (not (and (boundp 'org-html-standalone-image-predicate)
  2204. (functionp org-html-standalone-image-predicate)))
  2205. (funcall org-html-standalone-image-predicate paragraph))
  2206. (let ((contents (org-element-contents paragraph)))
  2207. (loop for x in contents
  2208. with inline-image-count = 0
  2209. always (cond
  2210. ((eq (org-element-type x) 'plain-text)
  2211. (not (org-string-nw-p x)))
  2212. ((eq (org-element-type x) 'link)
  2213. (when (org-export-inline-image-p
  2214. x org-html-inline-image-rules)
  2215. (= (incf inline-image-count) 1)))
  2216. (t nil))))))))
  2217. (defun org-html-link (link desc info)
  2218. "Transcode a LINK object from Org to HTML.
  2219. DESC is the description part of the link, or the empty string.
  2220. INFO is a plist holding contextual information. See
  2221. `org-export-data'."
  2222. (let* ((link-org-files-as-html-maybe
  2223. (function
  2224. (lambda (raw-path info)
  2225. "Treat links to `file.org' as links to `file.html', if needed.
  2226. See `org-html-link-org-files-as-html'."
  2227. (cond
  2228. ((and org-html-link-org-files-as-html
  2229. (string= ".org"
  2230. (downcase (file-name-extension raw-path "."))))
  2231. (concat (file-name-sans-extension raw-path) "."
  2232. (plist-get info :html-extension)))
  2233. (t raw-path)))))
  2234. (type (org-element-property :type link))
  2235. (raw-path (org-element-property :path link))
  2236. ;; Ensure DESC really exists, or set it to nil.
  2237. (desc (and (not (string= desc "")) desc))
  2238. (path
  2239. (cond
  2240. ((member type '("http" "https" "ftp" "mailto"))
  2241. (concat type ":" raw-path))
  2242. ((string= type "file")
  2243. ;; Treat links to ".org" files as ".html", if needed.
  2244. (setq raw-path
  2245. (funcall link-org-files-as-html-maybe raw-path info))
  2246. ;; If file path is absolute, prepend it with protocol
  2247. ;; component - "file://".
  2248. (when (file-name-absolute-p raw-path)
  2249. (setq raw-path
  2250. (concat "file://" (expand-file-name raw-path))))
  2251. ;; Add search option, if any. A search option can be
  2252. ;; relative to a custom-id or a headline title. Any other
  2253. ;; option is ignored.
  2254. (let ((option (org-element-property :search-option link)))
  2255. (cond ((not option) raw-path)
  2256. ((eq (aref option 0) ?#) (concat raw-path option))
  2257. ;; External fuzzy link: try to resolve it if path
  2258. ;; belongs to current project, if any.
  2259. ((eq (aref option 0) ?*)
  2260. (concat
  2261. raw-path
  2262. (let ((numbers
  2263. (org-publish-resolve-external-fuzzy-link
  2264. (org-element-property :path link) option)))
  2265. (and numbers (concat "#sec-"
  2266. (mapconcat 'number-to-string
  2267. numbers "-"))))))
  2268. (t raw-path))))
  2269. (t raw-path)))
  2270. attributes protocol)
  2271. ;; Extract attributes from parent's paragraph. HACK: Only do this
  2272. ;; for the first link in parent. This is needed as long as
  2273. ;; attributes cannot be set on a per link basis.
  2274. (and (setq attributes
  2275. (let ((parent (org-export-get-parent-element link)))
  2276. (if (not (eq (org-element-map parent 'link 'identity info t)
  2277. link))
  2278. ""
  2279. (let ((att (org-export-read-attribute :attr_html parent :options)))
  2280. (unless (and desc att (string-match (regexp-quote att) desc))
  2281. (or att ""))))))
  2282. (unless (string= attributes "")
  2283. (setq attributes (concat " " attributes))))
  2284. (cond
  2285. ;; Image file.
  2286. ((and (or (eq t org-html-inline-images)
  2287. (and org-html-inline-images (not desc)))
  2288. (org-export-inline-image-p link org-html-inline-image-rules))
  2289. (org-html-link--inline-image link desc info))
  2290. ;; Radio target: Transcode target's contents and use them as
  2291. ;; link's description.
  2292. ((string= type "radio")
  2293. (let ((destination (org-export-resolve-radio-link link info)))
  2294. (when destination
  2295. (format "<a href=\"#%s\"%s>%s</a>"
  2296. (org-export-solidify-link-text path)
  2297. attributes
  2298. (org-export-data (org-element-contents destination) info)))))
  2299. ;; Links pointing to a headline: Find destination and build
  2300. ;; appropriate referencing command.
  2301. ((member type '("custom-id" "fuzzy" "id"))
  2302. (let ((destination (if (string= type "fuzzy")
  2303. (org-export-resolve-fuzzy-link link info)
  2304. (org-export-resolve-id-link link info))))
  2305. (case (org-element-type destination)
  2306. ;; ID link points to an external file.
  2307. (plain-text
  2308. (let ((fragment (concat "ID-" path))
  2309. ;; Treat links to ".org" files as ".html", if needed.
  2310. (path (funcall link-org-files-as-html-maybe
  2311. destination info)))
  2312. (format "<a href=\"%s#%s\"%s>%s</a>"
  2313. path fragment attributes (or desc destination))))
  2314. ;; Fuzzy link points nowhere.
  2315. ((nil)
  2316. (format "<i>%s</i>"
  2317. (or desc
  2318. (org-export-data
  2319. (org-element-property :raw-link link) info))))
  2320. ;; Fuzzy link points to an invisible target.
  2321. (keyword nil)
  2322. ;; Link points to a headline.
  2323. (headline
  2324. (let ((href
  2325. ;; What href to use?
  2326. (cond
  2327. ;; Case 1: Headline is linked via it's CUSTOM_ID
  2328. ;; property. Use CUSTOM_ID.
  2329. ((string= type "custom-id")
  2330. (org-element-property :CUSTOM_ID destination))
  2331. ;; Case 2: Headline is linked via it's ID property
  2332. ;; or through other means. Use the default href.
  2333. ((member type '("id" "fuzzy"))
  2334. (format "sec-%s"
  2335. (mapconcat 'number-to-string
  2336. (org-export-get-headline-number
  2337. destination info) "-")))
  2338. (t (error "Shouldn't reach here"))))
  2339. ;; What description to use?
  2340. (desc
  2341. ;; Case 1: Headline is numbered and LINK has no
  2342. ;; description or LINK's description matches
  2343. ;; headline's title. Display section number.
  2344. (if (and (org-export-numbered-headline-p destination info)
  2345. (or (not desc)
  2346. (string= desc (org-element-property
  2347. :raw-value destination))))
  2348. (mapconcat 'number-to-string
  2349. (org-export-get-headline-number
  2350. destination info) ".")
  2351. ;; Case 2: Either the headline is un-numbered or
  2352. ;; LINK has a custom description. Display LINK's
  2353. ;; description or headline's title.
  2354. (or desc (org-export-data (org-element-property
  2355. :title destination) info)))))
  2356. (format "<a href=\"#%s\"%s>%s</a>"
  2357. (org-export-solidify-link-text href) attributes desc)))
  2358. ;; Fuzzy link points to a target. Do as above.
  2359. (t
  2360. (let ((path (org-export-solidify-link-text path)) number)
  2361. (unless desc
  2362. (setq number (cond
  2363. ((org-html-standalone-image-p destination info)
  2364. (org-export-get-ordinal
  2365. (assoc 'link (org-element-contents destination))
  2366. info 'link 'org-html-standalone-image-p))
  2367. (t (org-export-get-ordinal destination info))))
  2368. (setq desc (when number
  2369. (if (atom number) (number-to-string number)
  2370. (mapconcat 'number-to-string number ".")))))
  2371. (format "<a href=\"#%s\"%s>%s</a>"
  2372. path attributes (or desc "No description for this link")))))))
  2373. ;; Coderef: replace link with the reference name or the
  2374. ;; equivalent line number.
  2375. ((string= type "coderef")
  2376. (let ((fragment (concat "coderef-" path)))
  2377. (format "<a href=\"#%s\"%s%s>%s</a>"
  2378. fragment
  2379. (org-trim
  2380. (format (concat "class=\"coderef\""
  2381. " onmouseover=\"CodeHighlightOn(this, '%s');\""
  2382. " onmouseout=\"CodeHighlightOff(this, '%s');\"")
  2383. fragment fragment))
  2384. attributes
  2385. (format (org-export-get-coderef-format path desc)
  2386. (org-export-resolve-coderef path info)))))
  2387. ;; Link type is handled by a special function.
  2388. ((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
  2389. (funcall protocol (org-link-unescape path) desc 'html))
  2390. ;; External link with a description part.
  2391. ((and path desc) (format "<a href=\"%s\"%s>%s</a>" path attributes desc))
  2392. ;; External link without a description part.
  2393. (path (format "<a href=\"%s\"%s>%s</a>" path attributes path))
  2394. ;; No path, only description. Try to do something useful.
  2395. (t (format "<i>%s</i>" desc)))))
  2396. ;;;; Paragraph
  2397. (defun org-html-paragraph (paragraph contents info)
  2398. "Transcode a PARAGRAPH element from Org to HTML.
  2399. CONTENTS is the contents of the paragraph, as a string. INFO is
  2400. the plist used as a communication channel."
  2401. (let* ((parent (org-export-get-parent paragraph))
  2402. (parent-type (org-element-type parent))
  2403. (style '((footnote-definition " class=\"footpara\"")))
  2404. (extra (or (cadr (assoc parent-type style)) "")))
  2405. (cond
  2406. ((and (eq (org-element-type parent) 'item)
  2407. (= (org-element-property :begin paragraph)
  2408. (org-element-property :contents-begin parent)))
  2409. ;; leading paragraph in a list item have no tags
  2410. contents)
  2411. ((org-html-standalone-image-p paragraph info)
  2412. ;; standalone image
  2413. contents)
  2414. (t (format "<p%s>\n%s</p>" extra contents)))))
  2415. ;;;; Plain List
  2416. ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
  2417. ;; the correct value for the item counter
  2418. (defun org-html-begin-plain-list (type &optional arg1)
  2419. "Insert the beginning of the HTML list depending on TYPE.
  2420. When ARG1 is a string, use it as the start parameter for ordered
  2421. lists."
  2422. (case type
  2423. (ordered
  2424. (format "<ol class=\"org-ol\"%s>"
  2425. (if arg1 (format " start=\"%d\"" arg1) "")))
  2426. (unordered "<ul class=\"org-ul\">")
  2427. (descriptive "<dl class=\"org-dl\">")))
  2428. (defun org-html-end-plain-list (type)
  2429. "Insert the end of the HTML list depending on TYPE."
  2430. (case type
  2431. (ordered "</ol>")
  2432. (unordered "</ul>")
  2433. (descriptive "</dl>")))
  2434. (defun org-html-plain-list (plain-list contents info)
  2435. "Transcode a PLAIN-LIST element from Org to HTML.
  2436. CONTENTS is the contents of the list. INFO is a plist holding
  2437. contextual information."
  2438. (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
  2439. (type (org-element-property :type plain-list)))
  2440. (format "%s\n%s%s"
  2441. (org-html-begin-plain-list type)
  2442. contents (org-html-end-plain-list type))))
  2443. ;;;; Plain Text
  2444. (defun org-html-convert-special-strings (string)
  2445. "Convert special characters in STRING to HTML."
  2446. (let ((all org-html-special-string-regexps)
  2447. e a re rpl start)
  2448. (while (setq a (pop all))
  2449. (setq re (car a) rpl (cdr a) start 0)
  2450. (while (string-match re string start)
  2451. (setq string (replace-match rpl t nil string))))
  2452. string))
  2453. (defun org-html-encode-plain-text (text)
  2454. "Convert plain text characters from TEXT to HTML equivalent.
  2455. Possible conversions are set in `org-html-protect-char-alist'."
  2456. (mapc
  2457. (lambda (pair)
  2458. (setq text (replace-regexp-in-string (car pair) (cdr pair) text t t)))
  2459. org-html-protect-char-alist)
  2460. text)
  2461. (defun org-html-plain-text (text info)
  2462. "Transcode a TEXT string from Org to HTML.
  2463. TEXT is the string to transcode. INFO is a plist holding
  2464. contextual information."
  2465. (let ((output text))
  2466. ;; Protect following characters: <, >, &.
  2467. (setq output (org-html-encode-plain-text output))
  2468. ;; Handle smart quotes. Be sure to provide original string since
  2469. ;; OUTPUT may have been modified.
  2470. (when (plist-get info :with-smart-quotes)
  2471. (setq output (org-export-activate-smart-quotes output :html info text)))
  2472. ;; Handle special strings.
  2473. (when (plist-get info :with-special-strings)
  2474. (setq output (org-html-convert-special-strings output)))
  2475. ;; Handle break preservation if required.
  2476. (when (plist-get info :preserve-breaks)
  2477. (setq output
  2478. (replace-regexp-in-string
  2479. "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output)))
  2480. ;; Return value.
  2481. output))
  2482. ;; Planning
  2483. (defun org-html-planning (planning contents info)
  2484. "Transcode a PLANNING element from Org to HTML.
  2485. CONTENTS is nil. INFO is a plist used as a communication
  2486. channel."
  2487. (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
  2488. (format
  2489. "<p><span class=\"timestamp-wrapper\">%s</span></p>"
  2490. (mapconcat
  2491. 'identity
  2492. (delq nil
  2493. (list
  2494. (let ((closed (org-element-property :closed planning)))
  2495. (when closed
  2496. (format span-fmt org-closed-string
  2497. (org-translate-time
  2498. (org-element-property :raw-value closed)))))
  2499. (let ((deadline (org-element-property :deadline planning)))
  2500. (when deadline
  2501. (format span-fmt org-deadline-string
  2502. (org-translate-time
  2503. (org-element-property :raw-value deadline)))))
  2504. (let ((scheduled (org-element-property :scheduled planning)))
  2505. (when scheduled
  2506. (format span-fmt org-scheduled-string
  2507. (org-translate-time
  2508. (org-element-property :raw-value scheduled)))))))
  2509. " "))))
  2510. ;;;; Property Drawer
  2511. (defun org-html-property-drawer (property-drawer contents info)
  2512. "Transcode a PROPERTY-DRAWER element from Org to HTML.
  2513. CONTENTS is nil. INFO is a plist holding contextual
  2514. information."
  2515. ;; The property drawer isn't exported but we want separating blank
  2516. ;; lines nonetheless.
  2517. "")
  2518. ;;;; Quote Block
  2519. (defun org-html-quote-block (quote-block contents info)
  2520. "Transcode a QUOTE-BLOCK element from Org to HTML.
  2521. CONTENTS holds the contents of the block. INFO is a plist
  2522. holding contextual information."
  2523. (format "<blockquote>\n%s</blockquote>" contents))
  2524. ;;;; Quote Section
  2525. (defun org-html-quote-section (quote-section contents info)
  2526. "Transcode a QUOTE-SECTION element from Org to HTML.
  2527. CONTENTS is nil. INFO is a plist holding contextual information."
  2528. (let ((value (org-remove-indentation
  2529. (org-element-property :value quote-section))))
  2530. (when value (format "<pre>\n%s</pre>" value))))
  2531. ;;;; Section
  2532. (defun org-html-section (section contents info)
  2533. "Transcode a SECTION element from Org to HTML.
  2534. CONTENTS holds the contents of the section. INFO is a plist
  2535. holding contextual information."
  2536. (let ((parent (org-export-get-parent-headline section)))
  2537. ;; Before first headline: no container, just return CONTENTS.
  2538. (if (not parent) contents
  2539. ;; Get div's class and id references.
  2540. (let* ((class-num (+ (org-export-get-relative-level parent info)
  2541. (1- org-html-toplevel-hlevel)))
  2542. (section-number
  2543. (mapconcat
  2544. 'number-to-string
  2545. (org-export-get-headline-number parent info) "-")))
  2546. ;; Build return value.
  2547. (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
  2548. class-num
  2549. (or (org-element-property :CUSTOM_ID parent) section-number)
  2550. contents)))))
  2551. ;;;; Radio Target
  2552. (defun org-html-radio-target (radio-target text info)
  2553. "Transcode a RADIO-TARGET object from Org to HTML.
  2554. TEXT is the text of the target. INFO is a plist holding
  2555. contextual information."
  2556. (let ((id (org-export-solidify-link-text
  2557. (org-element-property :value radio-target))))
  2558. (org-html--anchor id text)))
  2559. ;;;; Special Block
  2560. (defun org-html-special-block (special-block contents info)
  2561. "Transcode a SPECIAL-BLOCK element from Org to HTML.
  2562. CONTENTS holds the contents of the block. INFO is a plist
  2563. holding contextual information."
  2564. (format "<div class=\"%s\">\n%s\n</div>"
  2565. (downcase (org-element-property :type special-block))
  2566. contents))
  2567. ;;;; Src Block
  2568. (defun org-html-src-block (src-block contents info)
  2569. "Transcode a SRC-BLOCK element from Org to HTML.
  2570. CONTENTS holds the contents of the item. INFO is a plist holding
  2571. contextual information."
  2572. (if (org-export-read-attribute :attr_html src-block :textarea)
  2573. (org-html--textarea-block src-block)
  2574. (let ((lang (org-element-property :language src-block))
  2575. (caption (org-export-get-caption src-block))
  2576. (code (org-html-format-code src-block info))
  2577. (label (let ((lbl (org-element-property :name src-block)))
  2578. (if (not lbl) ""
  2579. (format " id=\"%s\""
  2580. (org-export-solidify-link-text lbl))))))
  2581. (if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
  2582. (format
  2583. "<div class=\"org-src-container\">\n%s%s\n</div>"
  2584. (if (not caption) ""
  2585. (format "<label class=\"org-src-name\">%s</label>"
  2586. (org-export-data caption info)))
  2587. (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code))))))
  2588. ;;;; Statistics Cookie
  2589. (defun org-html-statistics-cookie (statistics-cookie contents info)
  2590. "Transcode a STATISTICS-COOKIE object from Org to HTML.
  2591. CONTENTS is nil. INFO is a plist holding contextual information."
  2592. (let ((cookie-value (org-element-property :value statistics-cookie)))
  2593. (format "<code>%s</code>" cookie-value)))
  2594. ;;;; Strike-Through
  2595. (defun org-html-strike-through (strike-through contents info)
  2596. "Transcode STRIKE-THROUGH from Org to HTML.
  2597. CONTENTS is the text with strike-through markup. INFO is a plist
  2598. holding contextual information."
  2599. (format (or (cdr (assq 'strike-through org-html-text-markup-alist)) "%s")
  2600. contents))
  2601. ;;;; Subscript
  2602. (defun org-html-subscript (subscript contents info)
  2603. "Transcode a SUBSCRIPT object from Org to HTML.
  2604. CONTENTS is the contents of the object. INFO is a plist holding
  2605. contextual information."
  2606. (format "<sub>%s</sub>" contents))
  2607. ;;;; Superscript
  2608. (defun org-html-superscript (superscript contents info)
  2609. "Transcode a SUPERSCRIPT object from Org to HTML.
  2610. CONTENTS is the contents of the object. INFO is a plist holding
  2611. contextual information."
  2612. (format "<sup>%s</sup>" contents))
  2613. ;;;; Tabel Cell
  2614. (defun org-html-table-cell (table-cell contents info)
  2615. "Transcode a TABLE-CELL element from Org to HTML.
  2616. CONTENTS is nil. INFO is a plist used as a communication
  2617. channel."
  2618. (let* ((table-row (org-export-get-parent table-cell))
  2619. (table (org-export-get-parent-table table-cell))
  2620. (cell-attrs
  2621. (if (not org-html-table-align-individual-fields) ""
  2622. (format (if (and (boundp 'org-html-format-table-no-css)
  2623. org-html-format-table-no-css)
  2624. " align=\"%s\"" " class=\"%s\"")
  2625. (org-export-table-cell-alignment table-cell info)))))
  2626. (when (or (not contents) (string= "" (org-trim contents)))
  2627. (setq contents "&#xa0;"))
  2628. (cond
  2629. ((and (org-export-table-has-header-p table info)
  2630. (= 1 (org-export-table-row-group table-row info)))
  2631. (concat "\n" (format (car org-html-table-header-tags) "col" cell-attrs)
  2632. contents (cdr org-html-table-header-tags)))
  2633. ((and org-html-table-use-header-tags-for-first-column
  2634. (zerop (cdr (org-export-table-cell-address table-cell info))))
  2635. (concat "\n" (format (car org-html-table-header-tags) "row" cell-attrs)
  2636. contents (cdr org-html-table-header-tags)))
  2637. (t (concat "\n" (format (car org-html-table-data-tags) cell-attrs)
  2638. contents (cdr org-html-table-data-tags))))))
  2639. ;;;; Table Row
  2640. (defun org-html-table-row (table-row contents info)
  2641. "Transcode a TABLE-ROW element from Org to HTML.
  2642. CONTENTS is the contents of the row. INFO is a plist used as a
  2643. communication channel."
  2644. ;; Rules are ignored since table separators are deduced from
  2645. ;; borders of the current row.
  2646. (when (eq (org-element-property :type table-row) 'standard)
  2647. (let* ((first-rowgroup-p (= 1 (org-export-table-row-group table-row info)))
  2648. (rowgroup-tags
  2649. (cond
  2650. ;; Case 1: Row belongs to second or subsequent rowgroups.
  2651. ((not (= 1 (org-export-table-row-group table-row info)))
  2652. '("<tbody>" . "\n</tbody>"))
  2653. ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
  2654. ((org-export-table-has-header-p
  2655. (org-export-get-parent-table table-row) info)
  2656. '("<thead>" . "\n</thead>"))
  2657. ;; Case 2: Row is from first and only row group.
  2658. (t '("<tbody>" . "\n</tbody>")))))
  2659. (concat
  2660. ;; Begin a rowgroup?
  2661. (when (org-export-table-row-starts-rowgroup-p table-row info)
  2662. (car rowgroup-tags))
  2663. ;; Actual table row
  2664. (concat "\n" (eval (car org-html-table-row-tags))
  2665. contents
  2666. "\n"
  2667. (eval (cdr org-html-table-row-tags)))
  2668. ;; End a rowgroup?
  2669. (when (org-export-table-row-ends-rowgroup-p table-row info)
  2670. (cdr rowgroup-tags))))))
  2671. ;;;; Table
  2672. (defun org-html-table-first-row-data-cells (table info)
  2673. "Transcode the first row of TABLE.
  2674. INFO is a plist used as a communication channel."
  2675. (let ((table-row
  2676. (org-element-map table 'table-row
  2677. (lambda (row)
  2678. (unless (eq (org-element-property :type row) 'rule) row))
  2679. info 'first-match))
  2680. (special-column-p (org-export-table-has-special-column-p table)))
  2681. (if (not special-column-p) (org-element-contents table-row)
  2682. (cdr (org-element-contents table-row)))))
  2683. (defun org-html-table--table.el-table (table info)
  2684. "Format table.el tables into HTML.
  2685. INFO is a plist used as a communication channel."
  2686. (when (eq (org-element-property :type table) 'table.el)
  2687. (require 'table)
  2688. (let ((outbuf (with-current-buffer
  2689. (get-buffer-create "*org-export-table*")
  2690. (erase-buffer) (current-buffer))))
  2691. (with-temp-buffer
  2692. (insert (org-element-property :value table))
  2693. (goto-char 1)
  2694. (re-search-forward "^[ \t]*|[^|]" nil t)
  2695. (table-generate-source 'html outbuf))
  2696. (with-current-buffer outbuf
  2697. (prog1 (org-trim (buffer-string))
  2698. (kill-buffer) )))))
  2699. (defun org-html-table (table contents info)
  2700. "Transcode a TABLE element from Org to HTML.
  2701. CONTENTS is the contents of the table. INFO is a plist holding
  2702. contextual information."
  2703. (case (org-element-property :type table)
  2704. ;; Case 1: table.el table. Convert it using appropriate tools.
  2705. (table.el (org-html-table--table.el-table table info))
  2706. ;; Case 2: Standard table.
  2707. (t
  2708. (let* ((label (org-element-property :name table))
  2709. (caption (org-export-get-caption table))
  2710. (attributes
  2711. (org-export-read-attribute :attr_html table :options))
  2712. (alignspec
  2713. (if (and (boundp 'org-html-format-table-no-css)
  2714. org-html-format-table-no-css)
  2715. "align=\"%s\"" "class=\"%s\""))
  2716. (table-column-specs
  2717. (function
  2718. (lambda (table info)
  2719. (mapconcat
  2720. (lambda (table-cell)
  2721. (let ((alignment (org-export-table-cell-alignment
  2722. table-cell info)))
  2723. (concat
  2724. ;; Begin a colgroup?
  2725. (when (org-export-table-cell-starts-colgroup-p
  2726. table-cell info)
  2727. "\n<colgroup>")
  2728. ;; Add a column. Also specify it's alignment.
  2729. (format "\n<col %s/>" (format alignspec alignment))
  2730. ;; End a colgroup?
  2731. (when (org-export-table-cell-ends-colgroup-p
  2732. table-cell info)
  2733. "\n</colgroup>"))))
  2734. (org-html-table-first-row-data-cells table info) "\n"))))
  2735. (table-attributes
  2736. (let ((table-tag (plist-get info :html-table-tag)))
  2737. (concat
  2738. (and (string-match "<table\\(.*\\)>" table-tag)
  2739. (match-string 1 table-tag))
  2740. (and label (format " id=\"%s\""
  2741. (org-export-solidify-link-text label)))
  2742. (unless (string= attributes "")
  2743. (concat " " attributes))))))
  2744. ;; Remove last blank line.
  2745. (setq contents (substring contents 0 -1))
  2746. (format "<table%s>\n%s\n%s\n%s\n</table>"
  2747. table-attributes
  2748. (if (not caption) ""
  2749. (format "<caption>%s</caption>"
  2750. (org-export-data caption info)))
  2751. (funcall table-column-specs table info)
  2752. contents)))))
  2753. ;;;; Target
  2754. (defun org-html-target (target contents info)
  2755. "Transcode a TARGET object from Org to HTML.
  2756. CONTENTS is nil. INFO is a plist holding contextual
  2757. information."
  2758. (let ((id (org-export-solidify-link-text
  2759. (org-element-property :value target))))
  2760. (org-html--anchor id)))
  2761. ;;;; Timestamp
  2762. (defun org-html-timestamp (timestamp contents info)
  2763. "Transcode a TIMESTAMP object from Org to HTML.
  2764. CONTENTS is nil. INFO is a plist holding contextual
  2765. information."
  2766. (let ((value (org-html-plain-text
  2767. (org-timestamp-translate timestamp) info)))
  2768. (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
  2769. (replace-regexp-in-string "--" "&#x2013;" value))))
  2770. ;;;; Underline
  2771. (defun org-html-underline (underline contents info)
  2772. "Transcode UNDERLINE from Org to HTML.
  2773. CONTENTS is the text with underline markup. INFO is a plist
  2774. holding contextual information."
  2775. (format (or (cdr (assq 'underline org-html-text-markup-alist)) "%s")
  2776. contents))
  2777. ;;;; Verbatim
  2778. (defun org-html-verbatim (verbatim contents info)
  2779. "Transcode VERBATIM from Org to HTML.
  2780. CONTENTS is nil. INFO is a plist holding contextual
  2781. information."
  2782. (format (or (cdr (assq 'verbatim org-html-text-markup-alist)) "%s")
  2783. (org-html-plain-text (org-element-property :value verbatim) info)))
  2784. ;;;; Verse Block
  2785. (defun org-html-verse-block (verse-block contents info)
  2786. "Transcode a VERSE-BLOCK element from Org to HTML.
  2787. CONTENTS is verse block contents. INFO is a plist holding
  2788. contextual information."
  2789. ;; Replace each newline character with line break. Also replace
  2790. ;; each blank line with a line break.
  2791. (setq contents (replace-regexp-in-string
  2792. "^ *\\\\\\\\$" "<br/>\n"
  2793. (replace-regexp-in-string
  2794. "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents)))
  2795. ;; Replace each white space at beginning of a line with a
  2796. ;; non-breaking space.
  2797. (while (string-match "^[ \t]+" contents)
  2798. (let* ((num-ws (length (match-string 0 contents)))
  2799. (ws (let (out) (dotimes (i num-ws out)
  2800. (setq out (concat out "&#xa0;"))))))
  2801. (setq contents (replace-match ws nil t contents))))
  2802. (format "<p class=\"verse\">\n%s</p>" contents))
  2803. ;;; Filter Functions
  2804. (defun org-html-final-function (contents backend info)
  2805. "Filter to indent the HTML and convert HTML entities."
  2806. (with-temp-buffer
  2807. (insert contents)
  2808. (set-auto-mode t)
  2809. (if org-html-indent
  2810. (indent-region (point-min) (point-max)))
  2811. (when org-html-use-unicode-chars
  2812. (require 'mm-url)
  2813. (mm-url-decode-entities))
  2814. (buffer-substring-no-properties (point-min) (point-max))))
  2815. ;;; End-user functions
  2816. ;;;###autoload
  2817. (defun org-html-export-as-html
  2818. (&optional async subtreep visible-only body-only ext-plist)
  2819. "Export current buffer to an HTML buffer.
  2820. If narrowing is active in the current buffer, only export its
  2821. narrowed part.
  2822. If a region is active, export that region.
  2823. A non-nil optional argument ASYNC means the process should happen
  2824. asynchronously. The resulting buffer should be accessible
  2825. through the `org-export-stack' interface.
  2826. When optional argument SUBTREEP is non-nil, export the sub-tree
  2827. at point, extracting information from the headline properties
  2828. first.
  2829. When optional argument VISIBLE-ONLY is non-nil, don't export
  2830. contents of hidden elements.
  2831. When optional argument BODY-ONLY is non-nil, only write code
  2832. between \"<body>\" and \"</body>\" tags.
  2833. EXT-PLIST, when provided, is a property list with external
  2834. parameters overriding Org default settings, but still inferior to
  2835. file-local settings.
  2836. Export is done in a buffer named \"*Org HTML Export*\", which
  2837. will be displayed when `org-export-show-temporary-export-buffer'
  2838. is non-nil."
  2839. (interactive)
  2840. (if async
  2841. (org-export-async-start
  2842. (lambda (output)
  2843. (with-current-buffer (get-buffer-create "*Org HTML Export*")
  2844. (erase-buffer)
  2845. (insert output)
  2846. (goto-char (point-min))
  2847. (set-auto-mode t)
  2848. (org-export-add-to-stack (current-buffer) 'html)))
  2849. `(org-export-as 'html ,subtreep ,visible-only ,body-only ',ext-plist))
  2850. (let ((outbuf (org-export-to-buffer
  2851. 'html "*Org HTML Export*"
  2852. subtreep visible-only body-only ext-plist)))
  2853. ;; Set major mode.
  2854. (with-current-buffer outbuf (set-auto-mode t))
  2855. (when org-export-show-temporary-export-buffer
  2856. (switch-to-buffer-other-window outbuf)))))
  2857. ;;;###autoload
  2858. (defun org-html-convert-region-to-html ()
  2859. "Assume the current region has org-mode syntax, and convert it to HTML.
  2860. This can be used in any buffer. For example, you can write an
  2861. itemized list in org-mode syntax in an HTML buffer and use this
  2862. command to convert it."
  2863. (interactive)
  2864. (org-export-replace-region-by 'html))
  2865. ;;;###autoload
  2866. (defun org-html-export-to-html
  2867. (&optional async subtreep visible-only body-only ext-plist)
  2868. "Export current buffer to a HTML file.
  2869. If narrowing is active in the current buffer, only export its
  2870. narrowed part.
  2871. If a region is active, export that region.
  2872. A non-nil optional argument ASYNC means the process should happen
  2873. asynchronously. The resulting file should be accessible through
  2874. the `org-export-stack' interface.
  2875. When optional argument SUBTREEP is non-nil, export the sub-tree
  2876. at point, extracting information from the headline properties
  2877. first.
  2878. When optional argument VISIBLE-ONLY is non-nil, don't export
  2879. contents of hidden elements.
  2880. When optional argument BODY-ONLY is non-nil, only write code
  2881. between \"<body>\" and \"</body>\" tags.
  2882. EXT-PLIST, when provided, is a property list with external
  2883. parameters overriding Org default settings, but still inferior to
  2884. file-local settings.
  2885. Return output file's name."
  2886. (interactive)
  2887. (let* ((extension (concat "." org-html-extension))
  2888. (file (org-export-output-file-name extension subtreep))
  2889. (org-export-coding-system org-html-coding-system))
  2890. (if async
  2891. (org-export-async-start
  2892. (lambda (f) (org-export-add-to-stack f 'html))
  2893. (let ((org-export-coding-system org-html-coding-system))
  2894. `(expand-file-name
  2895. (org-export-to-file
  2896. 'html ,file ,subtreep ,visible-only ,body-only ',ext-plist))))
  2897. (let ((org-export-coding-system org-html-coding-system))
  2898. (org-export-to-file
  2899. 'html file subtreep visible-only body-only ext-plist)))))
  2900. ;;;###autoload
  2901. (defun org-html-publish-to-html (plist filename pub-dir)
  2902. "Publish an org file to HTML.
  2903. FILENAME is the filename of the Org file to be published. PLIST
  2904. is the property list for the given project. PUB-DIR is the
  2905. publishing directory.
  2906. Return output file name."
  2907. (org-publish-org-to 'html filename
  2908. (concat "." (or (plist-get plist :html-extension)
  2909. org-html-extension "html"))
  2910. plist pub-dir))
  2911. ;;; FIXME
  2912. ;;;; org-format-table-html
  2913. ;;;; org-format-org-table-html
  2914. ;;;; org-format-table-table-html
  2915. ;;;; org-table-number-fraction
  2916. ;;;; org-table-number-regexp
  2917. ;;;; org-html-table-caption-above
  2918. ;;;; org-html-inline-image-extensions
  2919. ;;;; org-export-preferred-target-alist
  2920. ;;;; class for anchors
  2921. ;;;; org-export-with-section-numbers, body-only
  2922. ;;;; org-export-mark-todo-in-toc
  2923. ;;;; org-html-format-org-link
  2924. ;;;; (caption (and caption (org-xml-encode-org-text caption)))
  2925. ;;;; alt = (file-name-nondirectory path)
  2926. (provide 'ox-html)
  2927. ;; Local variables:
  2928. ;; generated-autoload-file: "org-loaddefs.el"
  2929. ;; End:
  2930. ;;; ox-html.el ends here