ox-html.el 119 KB

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