ox-html.el 118 KB

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