ox-html.el 118 KB

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