ox-html.el 118 KB

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