ox-html.el 118 KB

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