ox-html.el 117 KB

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