ox-html.el 119 KB

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