ox-html.el 118 KB

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