ox-html.el 119 KB

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