ox-html.el 119 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312
  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-tag nil nil org-html-table-tag)
  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-tag
  656. "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
  657. "The HTML tag that is used to start a table.
  658. This must be a <table> tag, but you may change the options like
  659. borders and spacing."
  660. :group 'org-export-html
  661. :type 'string)
  662. (defcustom org-html-table-header-tags '("<th scope=\"%s\"%s>" . "</th>")
  663. "The opening tag for table header fields.
  664. This is customizable so that alignment options can be specified.
  665. The first %s will be filled with the scope of the field, either row or col.
  666. The second %s will be replaced by a style entry to align the field.
  667. See also the variable `org-html-table-use-header-tags-for-first-column'.
  668. See also the variable `org-html-table-align-individual-fields'."
  669. :group 'org-export-html
  670. :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
  671. (defcustom org-html-table-data-tags '("<td%s>" . "</td>")
  672. "The opening tag for table data fields.
  673. This is customizable so that alignment options can be specified.
  674. The first %s will be filled with the scope of the field, either row or col.
  675. The second %s will be replaced by a style entry to align the field.
  676. See also the variable `org-html-table-align-individual-fields'."
  677. :group 'org-export-html
  678. :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
  679. (defcustom org-html-table-row-tags '("<tr>" . "</tr>")
  680. "The opening and ending tags for table rows.
  681. This is customizable so that alignment options can be specified.
  682. Instead of strings, these can be Lisp forms that will be
  683. evaluated for each row in order to construct the table row tags.
  684. During evaluation, these variables will be dynamically bound so that
  685. you can reuse them:
  686. `row-number': row number (0 is the first row)
  687. `rowgroup-number': group number of current row
  688. `start-rowgroup-p': non-nil means the row starts a group
  689. `end-rowgroup-p': non-nil means the row ends a group
  690. `top-row-p': non-nil means this is the top row
  691. `bottom-row-p': non-nil means this is the bottom row
  692. For example:
  693. \(setq org-html-table-row-tags
  694. (cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
  695. (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
  696. (t (if (= (mod row-number 2) 1)
  697. \"<tr class=\\\"tr-odd\\\">\"
  698. \"<tr class=\\\"tr-even\\\">\")))
  699. \"</tr>\"))
  700. will use the \"tr-top\" and \"tr-bottom\" classes for the top row
  701. and the bottom row, and otherwise alternate between \"tr-odd\" and
  702. \"tr-even\" for odd and even rows."
  703. :group 'org-export-html
  704. :type '(cons
  705. (choice :tag "Opening tag"
  706. (string :tag "Specify")
  707. (sexp))
  708. (choice :tag "Closing tag"
  709. (string :tag "Specify")
  710. (sexp))))
  711. (defcustom org-html-table-align-individual-fields t
  712. "Non-nil means attach style attributes for alignment to each table field.
  713. When nil, alignment will only be specified in the column tags, but this
  714. is ignored by some browsers (like Firefox, Safari). Opera does it right
  715. though."
  716. :group 'org-export-html
  717. :type 'boolean)
  718. (defcustom org-html-table-use-header-tags-for-first-column nil
  719. "Non-nil means format column one in tables with header tags.
  720. When nil, also column one will use data tags."
  721. :group 'org-export-html
  722. :type 'boolean)
  723. (defcustom org-html-table-caption-above t
  724. "When non-nil, place caption string at the beginning of the table.
  725. Otherwise, place it near the end."
  726. :group 'org-export-html
  727. :type 'boolean)
  728. ;;;; Tags
  729. (defcustom org-html-tag-class-prefix ""
  730. "Prefix to class names for TODO keywords.
  731. Each tag gets a class given by the tag itself, with this prefix.
  732. The default prefix is empty because it is nice to just use the keyword
  733. as a class name. But if you get into conflicts with other, existing
  734. CSS classes, then this prefix can be very useful."
  735. :group 'org-export-html
  736. :type 'string)
  737. ;;;; Template :: Generic
  738. (defcustom org-html-extension "html"
  739. "The extension for exported HTML files."
  740. :group 'org-export-html
  741. :type 'string)
  742. (defcustom org-html-xml-declaration
  743. '(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
  744. ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
  745. "The extension for exported HTML files.
  746. %s will be replaced with the charset of the exported file.
  747. This may be a string, or an alist with export extensions
  748. and corresponding declarations."
  749. :group 'org-export-html
  750. :type '(choice
  751. (string :tag "Single declaration")
  752. (repeat :tag "Dependent on extension"
  753. (cons (string :tag "Extension")
  754. (string :tag "Declaration")))))
  755. (defcustom org-html-coding-system 'utf-8
  756. "Coding system for HTML export.
  757. Use utf-8 as the default value."
  758. :group 'org-export-html
  759. :version "24.4"
  760. :package-version '(Org . "8.0")
  761. :type 'coding-system)
  762. (defcustom org-html-doctype
  763. "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
  764. "Document type definition to use for exported HTML files.
  765. Can be set with the in-buffer HTML_DOCTYPE property or for
  766. publishing, with :html-doctype."
  767. :group 'org-export-html
  768. :version "24.4"
  769. :package-version '(Org . "8.0")
  770. :type 'string)
  771. (defcustom org-html-container-element "div"
  772. "HTML element to use for wrapping top level sections.
  773. Can be set with the in-buffer HTML_CONTAINER property or for
  774. publishing, with :html-container.
  775. Note that changing the default will prevent you from using
  776. org-info.js for your website."
  777. :group 'org-export-html
  778. :version "24.4"
  779. :package-version '(Org . "8.0")
  780. :type 'string)
  781. (defcustom org-html-divs
  782. '((preamble "div" "preamble")
  783. (content "div" "content")
  784. (postamble "div" "postamble"))
  785. "Alist of the three section elements for HTML export.
  786. The car of each entry is one of 'preamble, 'content or 'postamble.
  787. The cdrs of each entry are the ELEMENT_TYPE and ID for each
  788. section of the exported document.
  789. Note that changing the default will prevent you from using
  790. org-info.js for your website."
  791. :group 'org-export-html
  792. :version "24.4"
  793. :package-version '(Org . "8.0")
  794. :type '(list :greedy t
  795. (list :tag "Preamble"
  796. (const :format "" preamble)
  797. (string :tag "element") (string :tag " id"))
  798. (list :tag "Content"
  799. (const :format "" content)
  800. (string :tag "element") (string :tag " id"))
  801. (list :tag "Postamble" (const :format "" postamble)
  802. (string :tag " id") (string :tag "element"))))
  803. (defcustom org-html-metadata-timestamp-format "%Y-%m-%d %a %H:%M"
  804. "Format used for timestamps in preamble, postamble and metadata.
  805. See `format-time-string' for more information on its components."
  806. :group 'org-export-html
  807. :version "24.4"
  808. :package-version '(Org . "8.0")
  809. :type 'string)
  810. ;;;; Template :: Mathjax
  811. (defcustom org-html-mathjax-options
  812. '((path "http://orgmode.org/mathjax/MathJax.js")
  813. (scale "100")
  814. (align "center")
  815. (indent "2em")
  816. (mathml nil))
  817. "Options for MathJax setup.
  818. path The path where to find MathJax
  819. scale Scaling for the HTML-CSS backend, usually between 100 and 133
  820. align How to align display math: left, center, or right
  821. indent If align is not center, how far from the left/right side?
  822. mathml Should a MathML player be used if available?
  823. This is faster and reduces bandwidth use, but currently
  824. sometimes has lower spacing quality. Therefore, the default is
  825. nil. When browsers get better, this switch can be flipped.
  826. You can also customize this for each buffer, using something like
  827. #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
  828. :group 'org-export-html
  829. :type '(list :greedy t
  830. (list :tag "path (the path from where to load MathJax.js)"
  831. (const :format " " path) (string))
  832. (list :tag "scale (scaling for the displayed math)"
  833. (const :format " " scale) (string))
  834. (list :tag "align (alignment of displayed equations)"
  835. (const :format " " align) (string))
  836. (list :tag "indent (indentation with left or right alignment)"
  837. (const :format " " indent) (string))
  838. (list :tag "mathml (should MathML display be used is possible)"
  839. (const :format " " mathml) (boolean))))
  840. (defcustom org-html-mathjax-template
  841. "<script type=\"text/javascript\" src=\"%PATH\">
  842. <!--/*--><![CDATA[/*><!--*/
  843. MathJax.Hub.Config({
  844. // Only one of the two following lines, depending on user settings
  845. // First allows browser-native MathML display, second forces HTML/CSS
  846. :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
  847. :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
  848. extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
  849. \"TeX/noUndefined.js\"],
  850. tex2jax: {
  851. inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
  852. displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
  853. skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
  854. ignoreClass: \"tex2jax_ignore\",
  855. processEscapes: false,
  856. processEnvironments: true,
  857. preview: \"TeX\"
  858. },
  859. showProcessingMessages: true,
  860. displayAlign: \"%ALIGN\",
  861. displayIndent: \"%INDENT\",
  862. \"HTML-CSS\": {
  863. scale: %SCALE,
  864. availableFonts: [\"STIX\",\"TeX\"],
  865. preferredFont: \"TeX\",
  866. webFont: \"TeX\",
  867. imageFont: \"TeX\",
  868. showMathMenu: true,
  869. },
  870. MMLorHTML: {
  871. prefer: {
  872. MSIE: \"MML\",
  873. Firefox: \"MML\",
  874. Opera: \"HTML\",
  875. other: \"HTML\"
  876. }
  877. }
  878. });
  879. /*]]>*///-->
  880. </script>"
  881. "The MathJax setup for XHTML files."
  882. :group 'org-export-html
  883. :type 'string)
  884. ;;;; Template :: Postamble
  885. (defcustom org-html-postamble 'auto
  886. "Non-nil means insert a postamble in HTML export.
  887. When set to 'auto, check against the
  888. `org-export-with-author/email/creator/date' variables to set the
  889. content of the postamble. When set to a string, use this string
  890. as the postamble. When t, insert a string as defined by the
  891. formatting string in `org-html-postamble-format'.
  892. When set to a function, apply this function and insert the
  893. returned string. The function takes the property list of export
  894. options as its only argument.
  895. Setting :html-postamble in publishing projects will take
  896. precedence over this variable."
  897. :group 'org-export-html
  898. :type '(choice (const :tag "No postamble" nil)
  899. (const :tag "Auto postamble" 'auto)
  900. (const :tag "Default formatting string" t)
  901. (string :tag "Custom formatting string")
  902. (function :tag "Function (must return a string)")))
  903. (defcustom org-html-postamble-format
  904. '(("en" "<p class=\"author\">Author: %a (%e)</p>
  905. <p class=\"date\">Date: %d</p>
  906. <p class=\"creator\">%c</p>
  907. <p class=\"xhtml-validation\">%v</p>"))
  908. "Alist of languages and format strings for the HTML postamble.
  909. The first element of each list is the language code, as used for
  910. the LANGUAGE keyword. See `org-export-default-language'.
  911. The second element of each list is a format string to format the
  912. postamble itself. This format string can contain these elements:
  913. %t stands for the title.
  914. %a stands for the author's name.
  915. %e stands for the author's email.
  916. %d stands for the date.
  917. %c will be replaced by `org-html-creator-string'.
  918. %v will be replaced by `org-html-validation-link'.
  919. %T will be replaced by the export time.
  920. %C will be replaced by the last modification time.
  921. If you need to use a \"%\" character, you need to escape it
  922. like that: \"%%\"."
  923. :group 'org-export-html
  924. :type '(alist :key-type (string :tag "Language")
  925. :value-type (string :tag "Format string")))
  926. (defcustom org-html-validation-link
  927. "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
  928. "Link to HTML validation service."
  929. :group 'org-export-html
  930. :type 'string)
  931. (defcustom org-html-creator-string
  932. (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
  933. emacs-version
  934. (if (fboundp 'org-version) (org-version) "unknown version"))
  935. "Information about the creator of the HTML document.
  936. This option can also be set on with the CREATOR keyword."
  937. :group 'org-export-html
  938. :type '(string :tag "Creator string"))
  939. ;;;; Template :: Preamble
  940. (defcustom org-html-preamble t
  941. "Non-nil means insert a preamble in HTML export.
  942. When t, insert a string as defined by the formatting string in
  943. `org-html-preamble-format'. When set to a string, use this
  944. formatting string instead (see `org-html-postamble-format' for an
  945. example of such a formatting string).
  946. When set to a function, apply this function and insert the
  947. returned string. The function takes the property list of export
  948. options as its only argument.
  949. Setting :html-preamble in publishing projects will take
  950. precedence over this variable."
  951. :group 'org-export-html
  952. :type '(choice (const :tag "No preamble" nil)
  953. (const :tag "Default preamble" t)
  954. (string :tag "Custom formatting string")
  955. (function :tag "Function (must return a string)")))
  956. (defcustom org-html-preamble-format '(("en" ""))
  957. "Alist of languages and format strings for the HTML preamble.
  958. The first element of each list is the language code, as used for
  959. the LANGUAGE keyword. See `org-export-default-language'.
  960. The second element of each list is a format string to format the
  961. preamble itself. This format string can contain these elements:
  962. %t stands for the title.
  963. %a stands for the author's name.
  964. %e stands for the author's email.
  965. %d stands for the date.
  966. %c will be replaced by `org-html-creator-string'.
  967. %v will be replaced by `org-html-validation-link'.
  968. %T will be replaced by the export time.
  969. %C will be replaced by the last modification time.
  970. If you need to use a \"%\" character, you need to escape it
  971. like that: \"%%\".
  972. See the default value of `org-html-postamble-format' for an
  973. example."
  974. :group 'org-export-html
  975. :type '(alist :key-type (string :tag "Language")
  976. :value-type (string :tag "Format string")))
  977. (defcustom org-html-link-up ""
  978. "Where should the \"UP\" link of exported HTML pages lead?"
  979. :group 'org-export-html
  980. :type '(string :tag "File or URL"))
  981. (defcustom org-html-link-home ""
  982. "Where should the \"HOME\" link of exported HTML pages lead?"
  983. :group 'org-export-html
  984. :type '(string :tag "File or URL"))
  985. (defcustom org-html-home/up-format
  986. "<div id=\"org-div-home-and-up\">
  987. <a accesskey=\"h\" href=\"%s\"> UP </a>
  988. |
  989. <a accesskey=\"H\" href=\"%s\"> HOME </a>
  990. </div>"
  991. "Snippet used to insert the HOME and UP links.
  992. This is a format string, the first %s will receive the UP link,
  993. the second the HOME link. If both `org-html-link-up' and
  994. `org-html-link-home' are empty, the entire snippet will be
  995. ignored."
  996. :group 'org-export-html
  997. :type 'string)
  998. ;;;; Template :: Scripts
  999. (define-obsolete-variable-alias
  1000. 'org-html-style-include-scripts 'org-html-head-include-scripts "24.4")
  1001. (defcustom org-html-head-include-scripts t
  1002. "Non-nil means include the JavaScript snippets in exported HTML files.
  1003. The actual script is defined in `org-html-scripts' and should
  1004. not be modified."
  1005. :group 'org-export-html
  1006. :version "24.4"
  1007. :package-version '(Org . "8.0")
  1008. :type 'boolean)
  1009. ;;;; Template :: Styles
  1010. (define-obsolete-variable-alias
  1011. 'org-html-style-include-default 'org-html-head-include-default-style "24.4")
  1012. (defcustom org-html-head-include-default-style t
  1013. "Non-nil means include the default style in exported HTML files.
  1014. The actual style is defined in `org-html-style-default' and
  1015. should not be modified. Use `org-html-head' to use your own
  1016. style information."
  1017. :group 'org-export-html
  1018. :version "24.4"
  1019. :package-version '(Org . "8.0")
  1020. :type 'boolean)
  1021. ;;;###autoload
  1022. (put 'org-html-head-include-default-style 'safe-local-variable 'booleanp)
  1023. (define-obsolete-variable-alias 'org-html-style 'org-html-head "24.4")
  1024. (defcustom org-html-head ""
  1025. "Org-wide head definitions for exported HTML files.
  1026. This variable can contain the full HTML structure to provide a
  1027. style, including the surrounding HTML tags. You can consider
  1028. including definitions for the following classes: title, todo,
  1029. done, timestamp, timestamp-kwd, tag, target.
  1030. For example, a valid value would be:
  1031. <style type=\"text/css\">
  1032. <![CDATA[
  1033. p { font-weight: normal; color: gray; }
  1034. h1 { color: black; }
  1035. .title { text-align: center; }
  1036. .todo, .timestamp-kwd { color: red; }
  1037. .done { color: green; }
  1038. ]]>
  1039. </style>
  1040. If you want to refer to an external style, use something like
  1041. <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
  1042. As the value of this option simply gets inserted into the HTML
  1043. <head> header, you can use it to add any arbitrary text to the
  1044. header.
  1045. You can set this on a per-file basis using #+HTML_HEAD:,
  1046. or for publication projects using the :html-head property."
  1047. :group 'org-export-html
  1048. :version "24.4"
  1049. :package-version '(Org . "8.0")
  1050. :type 'string)
  1051. ;;;###autoload
  1052. (put 'org-html-head 'safe-local-variable 'stringp)
  1053. (defcustom org-html-head-extra ""
  1054. "More head information to add in the HTML output.
  1055. You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
  1056. or for publication projects using the :html-head-extra property."
  1057. :group 'org-export-html
  1058. :version "24.4"
  1059. :package-version '(Org . "8.0")
  1060. :type 'string)
  1061. ;;;###autoload
  1062. (put 'org-html-head-extra 'safe-local-variable 'stringp)
  1063. ;;;; Todos
  1064. (defcustom org-html-todo-kwd-class-prefix ""
  1065. "Prefix to class names for TODO keywords.
  1066. Each TODO keyword gets a class given by the keyword itself, with this prefix.
  1067. The default prefix is empty because it is nice to just use the keyword
  1068. as a class name. But if you get into conflicts with other, existing
  1069. CSS classes, then this prefix can be very useful."
  1070. :group 'org-export-html
  1071. :type 'string)
  1072. ;;; Internal Functions
  1073. (defun org-html-format-inline-image (src &optional
  1074. caption label attr standalone-p)
  1075. "Format an inline image from SRC.
  1076. CAPTION, LABEL and ATTR are optional arguments providing the
  1077. caption, the label and the attribute of the image.
  1078. When STANDALONE-P is t, wrap the <img.../> into a <div>...</div>."
  1079. (let* ((id (if (not label) ""
  1080. (format " id=\"%s\"" (org-export-solidify-link-text label))))
  1081. (attr (concat attr
  1082. (cond
  1083. ((string-match "\\<alt=" (or attr "")) "")
  1084. ((string-match "^ltxpng/" src)
  1085. (format " alt=\"%s\""
  1086. (org-html-encode-plain-text
  1087. (org-find-text-property-in-string
  1088. 'org-latex-src src))))
  1089. (t (format " alt=\"%s\""
  1090. (file-name-nondirectory src)))))))
  1091. (cond
  1092. (standalone-p
  1093. (let ((img (format "<img src=\"%s\" %s/>" src attr)))
  1094. (format "\n<div%s class=\"figure\">%s%s\n</div>"
  1095. id (format "\n<p>%s</p>" img)
  1096. (if (and caption (not (string= caption "")))
  1097. (format "\n<p>%s</p>" caption) ""))))
  1098. (t (format "<img src=\"%s\" %s/>" src (concat attr id))))))
  1099. (defun org-html--textarea-block (element)
  1100. "Transcode ELEMENT into a textarea block.
  1101. ELEMENT is either a src block or an example block."
  1102. (let* ((code (car (org-export-unravel-code element)))
  1103. (attr (org-export-read-attribute :attr_html element)))
  1104. (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
  1105. (or (plist-get attr :width) 80)
  1106. (or (plist-get attr :height) (org-count-lines code))
  1107. code)))
  1108. ;;;; Bibliography
  1109. (defun org-html-bibliography ()
  1110. "Find bibliography, cut it out and return it."
  1111. (catch 'exit
  1112. (let (beg end (cnt 1) bib)
  1113. (save-excursion
  1114. (goto-char (point-min))
  1115. (when (re-search-forward
  1116. "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t)
  1117. (setq beg (match-beginning 0))
  1118. (while (re-search-forward "</?div\\>" nil t)
  1119. (setq cnt (+ cnt (if (string= (match-string 0) "<div") +1 -1)))
  1120. (when (= cnt 0)
  1121. (and (looking-at ">") (forward-char 1))
  1122. (setq bib (buffer-substring beg (point)))
  1123. (delete-region beg (point))
  1124. (throw 'exit bib))))
  1125. nil))))
  1126. ;;;; Table
  1127. (defun org-html-splice-attributes (tag attributes)
  1128. "Return a HTML TAG edited wrt ATTRIBUTES."
  1129. (if (not attributes)
  1130. tag
  1131. (let (oldatt newatt)
  1132. (setq oldatt (org-extract-attributes-from-string tag)
  1133. tag (pop oldatt)
  1134. newatt (cdr (org-extract-attributes-from-string attributes)))
  1135. (while newatt
  1136. (setq oldatt (plist-put oldatt (pop newatt) (pop newatt))))
  1137. (if (string-match ">" tag)
  1138. (setq tag
  1139. (replace-match (concat (org-attributes-to-string oldatt) ">")
  1140. t t tag)))
  1141. tag)))
  1142. (defun org-export-splice-style (style extra)
  1143. "Return STYLE updated wrt EXTRA."
  1144. (if (and (stringp extra)
  1145. (string-match "\\S-" extra)
  1146. (string-match "</style>" style))
  1147. (concat (substring style 0 (match-beginning 0))
  1148. "\n" extra "\n"
  1149. (substring style (match-beginning 0)))
  1150. style))
  1151. (defun org-html-htmlize-region-for-paste (beg end)
  1152. "Convert the region between BEG and END to HTML, using htmlize.el.
  1153. This is much like `htmlize-region-for-paste', only that it uses
  1154. the settings define in the org-... variables."
  1155. (let* ((htmlize-output-type org-html-htmlize-output-type)
  1156. (htmlize-css-name-prefix org-html-htmlize-font-prefix)
  1157. (htmlbuf (htmlize-region beg end)))
  1158. (unwind-protect
  1159. (with-current-buffer htmlbuf
  1160. (buffer-substring (plist-get htmlize-buffer-places 'content-start)
  1161. (plist-get htmlize-buffer-places 'content-end)))
  1162. (kill-buffer htmlbuf))))
  1163. ;;;###autoload
  1164. (defun org-html-htmlize-generate-css ()
  1165. "Create the CSS for all font definitions in the current Emacs session.
  1166. Use this to create face definitions in your CSS style file that can then
  1167. be used by code snippets transformed by htmlize.
  1168. This command just produces a buffer that contains class definitions for all
  1169. faces used in the current Emacs session. You can copy and paste the ones you
  1170. need into your CSS file.
  1171. If you then set `org-html-htmlize-output-type' to `css', calls
  1172. to the function `org-html-htmlize-region-for-paste' will
  1173. produce code that uses these same face definitions."
  1174. (interactive)
  1175. (require 'htmlize)
  1176. (and (get-buffer "*html*") (kill-buffer "*html*"))
  1177. (with-temp-buffer
  1178. (let ((fl (face-list))
  1179. (htmlize-css-name-prefix "org-")
  1180. (htmlize-output-type 'css)
  1181. f i)
  1182. (while (setq f (pop fl)
  1183. i (and f (face-attribute f :inherit)))
  1184. (when (and (symbolp f) (or (not i) (not (listp i))))
  1185. (insert (org-add-props (copy-sequence "1") nil 'face f))))
  1186. (htmlize-region (point-min) (point-max))))
  1187. (org-pop-to-buffer-same-window "*html*")
  1188. (goto-char (point-min))
  1189. (if (re-search-forward "<style" nil t)
  1190. (delete-region (point-min) (match-beginning 0)))
  1191. (if (re-search-forward "</style>" nil t)
  1192. (delete-region (1+ (match-end 0)) (point-max)))
  1193. (beginning-of-line 1)
  1194. (if (looking-at " +") (replace-match ""))
  1195. (goto-char (point-min)))
  1196. (defun org-html--make-string (n string)
  1197. "Build a string by concatenating N times STRING."
  1198. (let (out) (dotimes (i n out) (setq out (concat string out)))))
  1199. (defun org-html-fix-class-name (kwd) ; audit callers of this function
  1200. "Turn todo keyword KWD into a valid class name.
  1201. Replaces invalid characters with \"_\"."
  1202. (save-match-data
  1203. (while (string-match "[^a-zA-Z0-9_]" kwd)
  1204. (setq kwd (replace-match "_" t t kwd))))
  1205. kwd)
  1206. (defun org-html-format-footnote-reference (n def refcnt)
  1207. "Format footnote reference N with definition DEF into HTML."
  1208. (let ((extra (if (= refcnt 1) "" (format ".%d" refcnt))))
  1209. (format org-html-footnote-format
  1210. (let* ((id (format "fnr.%s%s" n extra))
  1211. (href (format " href=\"#fn.%s\"" n))
  1212. (attributes (concat " class=\"footref\"" href)))
  1213. (org-html--anchor id n attributes)))))
  1214. (defun org-html-format-footnotes-section (section-name definitions)
  1215. "Format footnotes section SECTION-NAME."
  1216. (if (not definitions) ""
  1217. (format org-html-footnotes-section section-name definitions)))
  1218. (defun org-html-format-footnote-definition (fn)
  1219. "Format the footnote definition FN."
  1220. (let ((n (car fn)) (def (cdr fn)))
  1221. (format
  1222. "<div class=\"footdef\">%s %s</div>\n"
  1223. (format org-html-footnote-format
  1224. (let* ((id (format "fn.%s" n))
  1225. (href (format " href=\"#fnr.%s\"" n))
  1226. (attributes (concat " class=\"footnum\"" href)))
  1227. (org-html--anchor id n attributes)))
  1228. def)))
  1229. (defun org-html-footnote-section (info)
  1230. "Format the footnote section.
  1231. INFO is a plist used as a communication channel."
  1232. (let* ((fn-alist (org-export-collect-footnote-definitions
  1233. (plist-get info :parse-tree) info))
  1234. (fn-alist
  1235. (loop for (n type raw) in fn-alist collect
  1236. (cons n (if (eq (org-element-type raw) 'org-data)
  1237. (org-trim (org-export-data raw info))
  1238. (format "<p>%s</p>"
  1239. (org-trim (org-export-data raw info))))))))
  1240. (when fn-alist
  1241. (org-html-format-footnotes-section
  1242. (org-html--translate "Footnotes" info)
  1243. (format
  1244. "\n%s\n"
  1245. (mapconcat 'org-html-format-footnote-definition fn-alist "\n"))))))
  1246. ;;; Template
  1247. (defun org-html--build-meta-info (info)
  1248. "Return meta tags for exported document.
  1249. INFO is a plist used as a communication channel."
  1250. (let* ((title (org-export-data (plist-get info :title) info))
  1251. (author (and (plist-get info :with-author)
  1252. (let ((auth (plist-get info :author)))
  1253. (and auth (org-export-data auth info)))))
  1254. (description (plist-get info :description))
  1255. (keywords (plist-get info :keywords)))
  1256. (concat
  1257. (format "<title>%s</title>\n" title)
  1258. (format
  1259. (when :time-stamp-file
  1260. (format-time-string
  1261. (concat "<!-- " org-html-metadata-timestamp-format " -->\n"))))
  1262. (format
  1263. "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>\n"
  1264. (or (and org-html-coding-system
  1265. (fboundp 'coding-system-get)
  1266. (coding-system-get org-html-coding-system 'mime-charset))
  1267. "iso-8859-1"))
  1268. (format "<meta name=\"generator\" content=\"Org-mode\"/>\n")
  1269. (and author (format "<meta name=\"author\" content=\"%s\"/>\n" author))
  1270. (and description
  1271. (format "<meta name=\"description\" content=\"%s\"/>\n" description))
  1272. (and keywords
  1273. (format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords)))))
  1274. (defun org-html--build-head (info)
  1275. "Return information for the <head>..</head> of the HTML output.
  1276. INFO is a plist used as a communication channel."
  1277. (org-element-normalize-string
  1278. (concat
  1279. (when (plist-get info :html-head-include-default-style)
  1280. (org-element-normalize-string org-html-style-default))
  1281. (org-element-normalize-string (plist-get info :html-head))
  1282. (org-element-normalize-string (plist-get info :html-head-extra))
  1283. (when (and (plist-get info :html-htmlized-css-url)
  1284. (eq org-html-htmlize-output-type 'css))
  1285. (format "<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\" />\n"
  1286. (plist-get info :html-htmlized-css-url)))
  1287. (when (plist-get info :html-head-include-scripts) org-html-scripts))))
  1288. (defun org-html--build-mathjax-config (info)
  1289. "Insert the user setup into the mathjax template.
  1290. INFO is a plist used as a communication channel."
  1291. (when (and (memq (plist-get info :with-latex) '(mathjax t))
  1292. (org-element-map (plist-get info :parse-tree)
  1293. '(latex-fragment latex-environment) 'identity info t))
  1294. (let ((template org-html-mathjax-template)
  1295. (options org-html-mathjax-options)
  1296. (in-buffer (or (plist-get info :html-mathjax) ""))
  1297. name val (yes " ") (no "// ") x)
  1298. (mapc
  1299. (lambda (e)
  1300. (setq name (car e) val (nth 1 e))
  1301. (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
  1302. (setq val (car (read-from-string
  1303. (substring in-buffer (match-end 0))))))
  1304. (if (not (stringp val)) (setq val (format "%s" val)))
  1305. (if (string-match (concat "%" (upcase (symbol-name name))) template)
  1306. (setq template (replace-match val t t template))))
  1307. options)
  1308. (setq val (nth 1 (assq 'mathml options)))
  1309. (if (string-match (concat "\\<mathml:") in-buffer)
  1310. (setq val (car (read-from-string
  1311. (substring in-buffer (match-end 0))))))
  1312. ;; Exchange prefixes depending on mathml setting.
  1313. (if (not val) (setq x yes yes no no x))
  1314. ;; Replace cookies to turn on or off the config/jax lines.
  1315. (if (string-match ":MMLYES:" template)
  1316. (setq template (replace-match yes t t template)))
  1317. (if (string-match ":MMLNO:" template)
  1318. (setq template (replace-match no t t template)))
  1319. ;; Return the modified template.
  1320. (org-element-normalize-string template))))
  1321. (defun org-html-format-spec (info)
  1322. "Return format specification for elements that can be
  1323. used in the preamble or postamble."
  1324. `((?t . ,(org-export-data (plist-get info :title) info))
  1325. (?d . ,(org-export-data (org-export-get-date info) info))
  1326. (?T . ,(format-time-string org-html-metadata-timestamp-format))
  1327. (?a . ,(org-export-data (plist-get info :author) info))
  1328. (?e . ,(mapconcat
  1329. (lambda (e)
  1330. (format "<a href=\"mailto:%s\">%s</a>" e e))
  1331. (split-string (plist-get info :email) ",+ *")
  1332. ", "))
  1333. (?c . ,(plist-get info :creator))
  1334. (?C . ,(let ((file (plist-get info :input-file)))
  1335. (format-time-string org-html-metadata-timestamp-format
  1336. (if file (nth 5 (file-attributes file))
  1337. (current-time)))))
  1338. (?v . ,(or org-html-validation-link ""))))
  1339. (defun org-html--build-pre/postamble (type info)
  1340. "Return document preamble or postamble as a string, or nil.
  1341. TYPE is either 'preamble or 'postamble, INFO is a plist used as a
  1342. communication channel."
  1343. (let ((section (plist-get info (intern (format ":html-%s" type))))
  1344. (spec (org-html-format-spec info)))
  1345. (when section
  1346. (let ((section-contents
  1347. (if (functionp section) (funcall section info)
  1348. (cond
  1349. ((stringp section) (format-spec section spec))
  1350. ((eq section 'auto)
  1351. (let ((date (cdr (assq ?d spec)))
  1352. (author (cdr (assq ?a spec)))
  1353. (email (cdr (assq ?e spec)))
  1354. (creator (cdr (assq ?c spec)))
  1355. (timestamp (cdr (assq ?T spec)))
  1356. (validation-link (cdr (assq ?v spec))))
  1357. (concat
  1358. (when (and (plist-get info :with-date)
  1359. (org-string-nw-p date))
  1360. (format "<p class=\"date\">%s: %s</p>\n"
  1361. (org-html--translate "Date" info)
  1362. date))
  1363. (when (and (plist-get info :with-author)
  1364. (org-string-nw-p author))
  1365. (format "<p class=\"author\">%s: %s</p>\n"
  1366. (org-html--translate "Author" info)
  1367. author))
  1368. (when (and (plist-get info :with-email)
  1369. (org-string-nw-p email))
  1370. (format "<p class=\"email\">%s: %s</p>\n"
  1371. (org-html--translate "Email" info)
  1372. email))
  1373. (when (plist-get info :time-stamp-file)
  1374. (format
  1375. "<p class=\"date\">%s: %s</p>\n"
  1376. (org-html--translate "Created" info)
  1377. (format-time-string org-html-metadata-timestamp-format)))
  1378. (when (plist-get info :with-creator)
  1379. (format "<p class=\"creator\">%s</p>\n" creator))
  1380. (format "<p class=\"xhtml-validation\">%s</p>\n"
  1381. validation-link))))
  1382. (t (format-spec
  1383. (or (cadr (assoc
  1384. (plist-get info :language)
  1385. (eval (intern
  1386. (format "org-html-%s-format" type)))))
  1387. (cadr
  1388. (assoc
  1389. "en"
  1390. (eval
  1391. (intern (format "org-html-%s-format" type))))))
  1392. spec))))))
  1393. (when (org-string-nw-p section-contents)
  1394. (concat
  1395. (format "<%s id=\"%s\" class=\"%s\">\n"
  1396. (nth 1 (assq type org-html-divs))
  1397. (nth 2 (assq type org-html-divs))
  1398. org-html--pre/postamble-class)
  1399. (org-element-normalize-string section-contents)
  1400. (format "</%s>\n" (nth 1 (assq type org-html-divs)))))))))
  1401. (defun org-html-inner-template (contents info)
  1402. "Return body of document string after HTML conversion.
  1403. CONTENTS is the transcoded contents string. INFO is a plist
  1404. holding export options."
  1405. (concat
  1406. ;; Table of contents.
  1407. (let ((depth (plist-get info :with-toc)))
  1408. (when depth (org-html-toc depth info)))
  1409. ;; Document contents.
  1410. contents
  1411. ;; Footnotes section.
  1412. (org-html-footnote-section info)
  1413. ;; Bibliography.
  1414. (org-html-bibliography)))
  1415. (defun org-html-template (contents info)
  1416. "Return complete document string after HTML conversion.
  1417. CONTENTS is the transcoded contents string. INFO is a plist
  1418. holding export options."
  1419. (concat
  1420. (format
  1421. (or (and (stringp org-html-xml-declaration)
  1422. org-html-xml-declaration)
  1423. (cdr (assoc (plist-get info :html-extension)
  1424. org-html-xml-declaration))
  1425. (cdr (assoc "html" org-html-xml-declaration))
  1426. "")
  1427. (or (and org-html-coding-system
  1428. (fboundp 'coding-system-get)
  1429. (coding-system-get org-html-coding-system 'mime-charset))
  1430. "iso-8859-1"))
  1431. "\n"
  1432. (plist-get info :html-doctype)
  1433. "\n"
  1434. (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n"
  1435. (plist-get info :language) (plist-get info :language))
  1436. "<head>\n"
  1437. (org-html--build-meta-info info)
  1438. (org-html--build-head info)
  1439. (org-html--build-mathjax-config info)
  1440. "</head>\n"
  1441. "<body>\n"
  1442. (let ((link-up (org-trim (plist-get info :html-link-up)))
  1443. (link-home (org-trim (plist-get info :html-link-home))))
  1444. (unless (and (string= link-up "") (string= link-up ""))
  1445. (format org-html-home/up-format
  1446. (or link-up link-home)
  1447. (or link-home link-up))))
  1448. ;; Preamble.
  1449. (org-html--build-pre/postamble 'preamble info)
  1450. ;; Document contents.
  1451. (format "<%s id=\"%s\">\n"
  1452. (nth 1 (assq 'content org-html-divs))
  1453. (nth 2 (assq 'content org-html-divs)))
  1454. ;; Document title.
  1455. (let ((title (plist-get info :title)))
  1456. (format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title "") info)))
  1457. contents
  1458. (format "</%s>\n"
  1459. (nth 1 (assq 'content org-html-divs)))
  1460. ;; Postamble.
  1461. (org-html--build-pre/postamble 'postamble info)
  1462. ;; Closing document.
  1463. "</body>\n</html>"))
  1464. (defun org-html--translate (s info)
  1465. "Translate string S according to specified language.
  1466. INFO is a plist used as a communication channel."
  1467. (org-export-translate s :html info))
  1468. ;;;; Anchor
  1469. (defun org-html--anchor (&optional id desc attributes)
  1470. "Format a HTML anchor."
  1471. (let* ((name (and org-html-allow-name-attribute-in-anchors id))
  1472. (attributes (concat (and id (format " id=\"%s\"" id))
  1473. (and name (format " name=\"%s\"" name))
  1474. attributes)))
  1475. (format "<a%s>%s</a>" attributes (or desc ""))))
  1476. ;;;; Todo
  1477. (defun org-html--todo (todo)
  1478. "Format TODO keywords into HTML."
  1479. (when todo
  1480. (format "<span class=\"%s %s%s\">%s</span>"
  1481. (if (member todo org-done-keywords) "done" "todo")
  1482. org-html-todo-kwd-class-prefix (org-html-fix-class-name todo)
  1483. todo)))
  1484. ;;;; Tags
  1485. (defun org-html--tags (tags)
  1486. "Format TAGS into HTML."
  1487. (when tags
  1488. (format "<span class=\"tag\">%s</span>"
  1489. (mapconcat
  1490. (lambda (tag)
  1491. (format "<span class=\"%s\">%s</span>"
  1492. (concat org-html-tag-class-prefix
  1493. (org-html-fix-class-name tag))
  1494. tag))
  1495. tags "&#xa0;"))))
  1496. ;;;; Headline
  1497. (defun* org-html-format-headline
  1498. (todo todo-type priority text tags
  1499. &key level section-number headline-label &allow-other-keys)
  1500. "Format a headline in HTML."
  1501. (let ((section-number
  1502. (when section-number
  1503. (format "<span class=\"section-number-%d\">%s</span> "
  1504. level section-number)))
  1505. (todo (org-html--todo todo))
  1506. (tags (org-html--tags tags)))
  1507. (concat section-number todo (and todo " ") text
  1508. (and tags "&#xa0;&#xa0;&#xa0;") tags)))
  1509. ;;;; Src Code
  1510. (defun org-html-fontify-code (code lang)
  1511. "Color CODE with htmlize library.
  1512. CODE is a string representing the source code to colorize. LANG
  1513. is the language used for CODE, as a string, or nil."
  1514. (when code
  1515. (cond
  1516. ;; Case 1: No lang. Possibly an example block.
  1517. ((not lang)
  1518. ;; Simple transcoding.
  1519. (org-html-encode-plain-text code))
  1520. ;; Case 2: No htmlize or an inferior version of htmlize
  1521. ((not (and (require 'htmlize nil t) (fboundp 'htmlize-region-for-paste)))
  1522. ;; Emit a warning.
  1523. (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
  1524. ;; Simple transcoding.
  1525. (org-html-encode-plain-text code))
  1526. (t
  1527. ;; Map language
  1528. (setq lang (or (assoc-default lang org-src-lang-modes) lang))
  1529. (let* ((lang-mode (and lang (intern (format "%s-mode" lang)))))
  1530. (cond
  1531. ;; Case 1: Language is not associated with any Emacs mode
  1532. ((not (functionp lang-mode))
  1533. ;; Simple transcoding.
  1534. (org-html-encode-plain-text code))
  1535. ;; Case 2: Default. Fontify code.
  1536. (t
  1537. ;; htmlize
  1538. (setq code (with-temp-buffer
  1539. ;; Switch to language-specific mode.
  1540. (funcall lang-mode)
  1541. (insert code)
  1542. ;; Fontify buffer.
  1543. (font-lock-fontify-buffer)
  1544. ;; Remove formatting on newline characters.
  1545. (save-excursion
  1546. (let ((beg (point-min))
  1547. (end (point-max)))
  1548. (goto-char beg)
  1549. (while (progn (end-of-line) (< (point) end))
  1550. (put-text-property (point) (1+ (point)) 'face nil)
  1551. (forward-char 1))))
  1552. (org-src-mode)
  1553. (set-buffer-modified-p nil)
  1554. ;; Htmlize region.
  1555. (org-html-htmlize-region-for-paste
  1556. (point-min) (point-max))))
  1557. ;; Strip any enclosing <pre></pre> tags.
  1558. (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code) (match-end 0)))
  1559. (end (and beg (string-match "</pre>\\'" code))))
  1560. (if (and beg end) (substring code beg end) code)))))))))
  1561. (defun org-html-do-format-code
  1562. (code &optional lang refs retain-labels num-start)
  1563. "Format CODE string as source code.
  1564. Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
  1565. respectively, the language of the source code, as a string, an
  1566. alist between line numbers and references (as returned by
  1567. `org-export-unravel-code'), a boolean specifying if labels should
  1568. appear in the source code, and the number associated to the first
  1569. line of code."
  1570. (let* ((code-lines (org-split-string code "\n"))
  1571. (code-length (length code-lines))
  1572. (num-fmt
  1573. (and num-start
  1574. (format "%%%ds: "
  1575. (length (number-to-string (+ code-length num-start))))))
  1576. (code (org-html-fontify-code code lang)))
  1577. (org-export-format-code
  1578. code
  1579. (lambda (loc line-num ref)
  1580. (setq loc
  1581. (concat
  1582. ;; Add line number, if needed.
  1583. (when num-start
  1584. (format "<span class=\"linenr\">%s</span>"
  1585. (format num-fmt line-num)))
  1586. ;; Transcoded src line.
  1587. loc
  1588. ;; Add label, if needed.
  1589. (when (and ref retain-labels) (format " (%s)" ref))))
  1590. ;; Mark transcoded line as an anchor, if needed.
  1591. (if (not ref) loc
  1592. (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
  1593. ref loc)))
  1594. num-start refs)))
  1595. (defun org-html-format-code (element info)
  1596. "Format contents of ELEMENT as source code.
  1597. ELEMENT is either an example block or a src block. INFO is
  1598. a plist used as a communication channel."
  1599. (let* ((lang (org-element-property :language element))
  1600. ;; Extract code and references.
  1601. (code-info (org-export-unravel-code element))
  1602. (code (car code-info))
  1603. (refs (cdr code-info))
  1604. ;; Does the src block contain labels?
  1605. (retain-labels (org-element-property :retain-labels element))
  1606. ;; Does it have line numbers?
  1607. (num-start (case (org-element-property :number-lines element)
  1608. (continued (org-export-get-loc element info))
  1609. (new 0))))
  1610. (org-html-do-format-code code lang refs retain-labels num-start)))
  1611. ;;; Tables of Contents
  1612. (defun org-html-toc (depth info)
  1613. "Build a table of contents.
  1614. DEPTH is an integer specifying the depth of the table. INFO is a
  1615. plist used as a communication channel. Return the table of
  1616. contents as a string, or nil if it is empty."
  1617. (let ((toc-entries
  1618. (mapcar (lambda (headline)
  1619. (cons (org-html--format-toc-headline headline info)
  1620. (org-export-get-relative-level headline info)))
  1621. (org-export-collect-headlines info depth))))
  1622. (when toc-entries
  1623. (concat "<div id=\"table-of-contents\">\n"
  1624. (format "<h%d>%s</h%d>\n"
  1625. org-html-toplevel-hlevel
  1626. (org-html--translate "Table of Contents" info)
  1627. org-html-toplevel-hlevel)
  1628. "<div id=\"text-table-of-contents\">"
  1629. (org-html--toc-text toc-entries)
  1630. "</div>\n"
  1631. "</div>\n"))))
  1632. (defun org-html--toc-text (toc-entries)
  1633. "Return innards of a table of contents, as a string.
  1634. TOC-ENTRIES is an alist where key is an entry title, as a string,
  1635. and value is its relative level, as an integer."
  1636. (let* ((prev-level (1- (cdar toc-entries)))
  1637. (start-level prev-level))
  1638. (concat
  1639. (mapconcat
  1640. (lambda (entry)
  1641. (let ((headline (car entry))
  1642. (level (cdr entry)))
  1643. (concat
  1644. (let* ((cnt (- level prev-level))
  1645. (times (if (> cnt 0) (1- cnt) (- cnt)))
  1646. rtn)
  1647. (setq prev-level level)
  1648. (concat
  1649. (org-html--make-string
  1650. times (cond ((> cnt 0) "\n<ul>\n<li>")
  1651. ((< cnt 0) "</li>\n</ul>\n")))
  1652. (if (> cnt 0) "\n<ul>\n<li>" "</li>\n<li>")))
  1653. headline)))
  1654. toc-entries "")
  1655. (org-html--make-string (- prev-level start-level) "</li>\n</ul>\n"))))
  1656. (defun org-html--format-toc-headline (headline info)
  1657. "Return an appropriate table of contents entry for HEADLINE.
  1658. INFO is a plist used as a communication channel."
  1659. (let* ((headline-number (org-export-get-headline-number headline info))
  1660. (section-number
  1661. (and (not (org-export-low-level-p headline info))
  1662. (org-export-numbered-headline-p headline info)
  1663. (concat (mapconcat 'number-to-string headline-number ".") ". ")))
  1664. (tags (and (eq (plist-get info :with-tags) t)
  1665. (org-export-get-tags headline info))))
  1666. (format "<a href=\"#%s\">%s</a>"
  1667. ;; Label.
  1668. (org-export-solidify-link-text
  1669. (or (org-element-property :CUSTOM_ID headline)
  1670. (concat "sec-" (mapconcat 'number-to-string
  1671. headline-number "-"))))
  1672. ;; Body.
  1673. (concat section-number
  1674. (org-export-data-with-translations
  1675. (org-export-get-alt-title headline info)
  1676. ;; Ignore any footnote-reference, link,
  1677. ;; radio-target and target in table of contents.
  1678. (append
  1679. '((footnote-reference . ignore)
  1680. (link . (lambda (link desc i) desc))
  1681. (radio-target . (lambda (radio desc i) desc))
  1682. (target . ignore))
  1683. (org-export-backend-translate-table 'html))
  1684. info)
  1685. (and tags "&#xa0;&#xa0;&#xa0;") (org-html--tags tags)))))
  1686. (defun org-html-list-of-listings (info)
  1687. "Build a list of listings.
  1688. INFO is a plist used as a communication channel. Return the list
  1689. of listings as a string, or nil if it is empty."
  1690. (let ((lol-entries (org-export-collect-listings info)))
  1691. (when lol-entries
  1692. (concat "<div id=\"list-of-listings\">\n"
  1693. (format "<h%d>%s</h%d>\n"
  1694. org-html-toplevel-hlevel
  1695. (org-html--translate "List of Listings" info)
  1696. org-html-toplevel-hlevel)
  1697. "<div id=\"text-list-of-listings\">\n<ul>\n"
  1698. (let ((count 0)
  1699. (initial-fmt (org-html--translate "Listing %d:" info)))
  1700. (mapconcat
  1701. (lambda (entry)
  1702. (let ((label (org-element-property :name entry))
  1703. (title (org-trim
  1704. (org-export-data
  1705. (or (org-export-get-caption entry t)
  1706. (org-export-get-caption entry))
  1707. info))))
  1708. (concat
  1709. "<li>"
  1710. (if (not label)
  1711. (concat (format initial-fmt (incf count)) " " title)
  1712. (format "<a href=\"#%s\">%s %s</a>"
  1713. (org-export-solidify-link-text label)
  1714. (format initial-fmt (incf count))
  1715. title))
  1716. "</li>")))
  1717. lol-entries "\n"))
  1718. "\n</ul>\n</div>\n</div>"))))
  1719. (defun org-html-list-of-tables (info)
  1720. "Build a list of tables.
  1721. INFO is a plist used as a communication channel. Return the list
  1722. of tables as a string, or nil if it is empty."
  1723. (let ((lol-entries (org-export-collect-tables info)))
  1724. (when lol-entries
  1725. (concat "<div id=\"list-of-tables\">\n"
  1726. (format "<h%d>%s</h%d>\n"
  1727. org-html-toplevel-hlevel
  1728. (org-html--translate "List of Tables" info)
  1729. org-html-toplevel-hlevel)
  1730. "<div id=\"text-list-of-tables\">\n<ul>\n"
  1731. (let ((count 0)
  1732. (initial-fmt (org-html--translate "Table %d:" info)))
  1733. (mapconcat
  1734. (lambda (entry)
  1735. (let ((label (org-element-property :name entry))
  1736. (title (org-trim
  1737. (org-export-data
  1738. (or (org-export-get-caption entry t)
  1739. (org-export-get-caption entry))
  1740. info))))
  1741. (concat
  1742. "<li>"
  1743. (if (not label)
  1744. (concat (format initial-fmt (incf count)) " " title)
  1745. (format "<a href=\"#%s\">%s %s</a>"
  1746. (org-export-solidify-link-text label)
  1747. (format initial-fmt (incf count))
  1748. title))
  1749. "</li>")))
  1750. lol-entries "\n"))
  1751. "\n</ul>\n</div>\n</div>"))))
  1752. ;;; Transcode Functions
  1753. ;;;; Bold
  1754. (defun org-html-bold (bold contents info)
  1755. "Transcode BOLD from Org to HTML.
  1756. CONTENTS is the text with bold markup. INFO is a plist holding
  1757. contextual information."
  1758. (format (or (cdr (assq 'bold org-html-text-markup-alist)) "%s")
  1759. contents))
  1760. ;;;; Center Block
  1761. (defun org-html-center-block (center-block contents info)
  1762. "Transcode a CENTER-BLOCK element from Org to HTML.
  1763. CONTENTS holds the contents of the block. INFO is a plist
  1764. holding contextual information."
  1765. (format "<div class=\"center\">\n%s</div>" contents))
  1766. ;;;; Clock
  1767. (defun org-html-clock (clock contents info)
  1768. "Transcode a CLOCK element from Org to HTML.
  1769. CONTENTS is nil. INFO is a plist used as a communication
  1770. channel."
  1771. (format "<p>
  1772. <span class=\"timestamp-wrapper\">
  1773. <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
  1774. </span>
  1775. </p>"
  1776. org-clock-string
  1777. (org-translate-time
  1778. (org-element-property :raw-value
  1779. (org-element-property :value clock)))
  1780. (let ((time (org-element-property :duration clock)))
  1781. (and time (format " <span class=\"timestamp\">(%s)</span>" time)))))
  1782. ;;;; Code
  1783. (defun org-html-code (code contents info)
  1784. "Transcode CODE from Org to HTML.
  1785. CONTENTS is nil. INFO is a plist holding contextual
  1786. information."
  1787. (format (or (cdr (assq 'code org-html-text-markup-alist)) "%s")
  1788. (org-html-plain-text (org-element-property :value code) info)))
  1789. ;;;; Drawer
  1790. (defun org-html-drawer (drawer contents info)
  1791. "Transcode a DRAWER element from Org to HTML.
  1792. CONTENTS holds the contents of the block. INFO is a plist
  1793. holding contextual information."
  1794. (if (functionp org-html-format-drawer-function)
  1795. (funcall org-html-format-drawer-function
  1796. (org-element-property :drawer-name drawer)
  1797. contents)
  1798. ;; If there's no user defined function: simply
  1799. ;; display contents of the drawer.
  1800. contents))
  1801. ;;;; Dynamic Block
  1802. (defun org-html-dynamic-block (dynamic-block contents info)
  1803. "Transcode a DYNAMIC-BLOCK element from Org to HTML.
  1804. CONTENTS holds the contents of the block. INFO is a plist
  1805. holding contextual information. See `org-export-data'."
  1806. contents)
  1807. ;;;; Entity
  1808. (defun org-html-entity (entity contents info)
  1809. "Transcode an ENTITY object from Org to HTML.
  1810. CONTENTS are the definition itself. INFO is a plist holding
  1811. contextual information."
  1812. (org-element-property :html entity))
  1813. ;;;; Example Block
  1814. (defun org-html-example-block (example-block contents info)
  1815. "Transcode a EXAMPLE-BLOCK element from Org to HTML.
  1816. CONTENTS is nil. INFO is a plist holding contextual
  1817. information."
  1818. (if (org-export-read-attribute :attr_html example-block :textarea)
  1819. (org-html--textarea-block example-block)
  1820. (format "<pre class=\"example\">\n%s</pre>"
  1821. (org-html-format-code example-block info))))
  1822. ;;;; Export Snippet
  1823. (defun org-html-export-snippet (export-snippet contents info)
  1824. "Transcode a EXPORT-SNIPPET object from Org to HTML.
  1825. CONTENTS is nil. INFO is a plist holding contextual
  1826. information."
  1827. (when (eq (org-export-snippet-backend export-snippet) 'html)
  1828. (org-element-property :value export-snippet)))
  1829. ;;;; Export Block
  1830. (defun org-html-export-block (export-block contents info)
  1831. "Transcode a EXPORT-BLOCK element from Org to HTML.
  1832. CONTENTS is nil. INFO is a plist holding contextual information."
  1833. (when (string= (org-element-property :type export-block) "HTML")
  1834. (org-remove-indentation (org-element-property :value export-block))))
  1835. ;;;; Fixed Width
  1836. (defun org-html-fixed-width (fixed-width contents info)
  1837. "Transcode a FIXED-WIDTH element from Org to HTML.
  1838. CONTENTS is nil. INFO is a plist holding contextual information."
  1839. (format "<pre class=\"example\">\n%s</pre>"
  1840. (org-html-do-format-code
  1841. (org-remove-indentation
  1842. (org-element-property :value fixed-width)))))
  1843. ;;;; Footnote Reference
  1844. (defun org-html-footnote-reference (footnote-reference contents info)
  1845. "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
  1846. CONTENTS is nil. INFO is a plist holding contextual information."
  1847. (concat
  1848. ;; Insert separator between two footnotes in a row.
  1849. (let ((prev (org-export-get-previous-element footnote-reference info)))
  1850. (when (eq (org-element-type prev) 'footnote-reference)
  1851. org-html-footnote-separator))
  1852. (cond
  1853. ((not (org-export-footnote-first-reference-p footnote-reference info))
  1854. (org-html-format-footnote-reference
  1855. (org-export-get-footnote-number footnote-reference info)
  1856. "IGNORED" 100))
  1857. ;; Inline definitions are secondary strings.
  1858. ((eq (org-element-property :type footnote-reference) 'inline)
  1859. (org-html-format-footnote-reference
  1860. (org-export-get-footnote-number footnote-reference info)
  1861. "IGNORED" 1))
  1862. ;; Non-inline footnotes definitions are full Org data.
  1863. (t (org-html-format-footnote-reference
  1864. (org-export-get-footnote-number footnote-reference info)
  1865. "IGNORED" 1)))))
  1866. ;;;; Headline
  1867. (defun org-html-format-headline--wrap
  1868. (headline info &optional format-function &rest extra-keys)
  1869. "Transcode a HEADLINE element from Org to HTML.
  1870. CONTENTS holds the contents of the headline. INFO is a plist
  1871. holding contextual information."
  1872. (let* ((level (+ (org-export-get-relative-level headline info)
  1873. (1- org-html-toplevel-hlevel)))
  1874. (headline-number (org-export-get-headline-number headline info))
  1875. (section-number (and (not (org-export-low-level-p headline info))
  1876. (org-export-numbered-headline-p headline info)
  1877. (mapconcat 'number-to-string
  1878. headline-number ".")))
  1879. (todo (and (plist-get info :with-todo-keywords)
  1880. (let ((todo (org-element-property :todo-keyword headline)))
  1881. (and todo (org-export-data todo info)))))
  1882. (todo-type (and todo (org-element-property :todo-type headline)))
  1883. (priority (and (plist-get info :with-priority)
  1884. (org-element-property :priority headline)))
  1885. (text (org-export-data (org-element-property :title headline) info))
  1886. (tags (and (plist-get info :with-tags)
  1887. (org-export-get-tags headline info)))
  1888. (headline-label (or (org-element-property :CUSTOM_ID headline)
  1889. (concat "sec-" (mapconcat 'number-to-string
  1890. headline-number "-"))))
  1891. (format-function (cond
  1892. ((functionp format-function) format-function)
  1893. ((functionp org-html-format-headline-function)
  1894. (function*
  1895. (lambda (todo todo-type priority text tags
  1896. &allow-other-keys)
  1897. (funcall org-html-format-headline-function
  1898. todo todo-type priority text tags))))
  1899. (t 'org-html-format-headline))))
  1900. (apply format-function
  1901. todo todo-type priority text tags
  1902. :headline-label headline-label :level level
  1903. :section-number section-number extra-keys)))
  1904. (defun org-html-headline (headline contents info)
  1905. "Transcode a HEADLINE element from Org to HTML.
  1906. CONTENTS holds the contents of the headline. INFO is a plist
  1907. holding contextual information."
  1908. ;; Empty contents?
  1909. (setq contents (or contents ""))
  1910. (let* ((numberedp (org-export-numbered-headline-p headline info))
  1911. (level (org-export-get-relative-level headline info))
  1912. (text (org-export-data (org-element-property :title headline) info))
  1913. (todo (and (plist-get info :with-todo-keywords)
  1914. (let ((todo (org-element-property :todo-keyword headline)))
  1915. (and todo (org-export-data todo info)))))
  1916. (todo-type (and todo (org-element-property :todo-type headline)))
  1917. (tags (and (plist-get info :with-tags)
  1918. (org-export-get-tags headline info)))
  1919. (priority (and (plist-get info :with-priority)
  1920. (org-element-property :priority headline)))
  1921. (section-number (and (org-export-numbered-headline-p headline info)
  1922. (mapconcat 'number-to-string
  1923. (org-export-get-headline-number
  1924. headline info) ".")))
  1925. ;; Create the headline text.
  1926. (full-text (org-html-format-headline--wrap headline info)))
  1927. (cond
  1928. ;; Case 1: This is a footnote section: ignore it.
  1929. ((org-element-property :footnote-section-p headline) nil)
  1930. ;; Case 2. This is a deep sub-tree: export it as a list item.
  1931. ;; Also export as items headlines for which no section
  1932. ;; format has been found.
  1933. ((org-export-low-level-p headline info)
  1934. ;; Build the real contents of the sub-tree.
  1935. (let* ((type (if numberedp 'ordered 'unordered))
  1936. (itemized-body (org-html-format-list-item
  1937. contents type nil nil full-text)))
  1938. (concat
  1939. (and (org-export-first-sibling-p headline info)
  1940. (org-html-begin-plain-list type))
  1941. itemized-body
  1942. (and (org-export-last-sibling-p headline info)
  1943. (org-html-end-plain-list type)))))
  1944. ;; Case 3. Standard headline. Export it as a section.
  1945. (t
  1946. (let* ((section-number (mapconcat 'number-to-string
  1947. (org-export-get-headline-number
  1948. headline info) "-"))
  1949. (ids (remove 'nil
  1950. (list (org-element-property :CUSTOM_ID headline)
  1951. (concat "sec-" section-number)
  1952. (org-element-property :ID headline))))
  1953. (preferred-id (car ids))
  1954. (extra-ids (cdr ids))
  1955. (extra-class (org-element-property :HTML_CONTAINER_CLASS headline))
  1956. (level1 (+ level (1- org-html-toplevel-hlevel)))
  1957. (first-content (car (org-element-contents headline))))
  1958. (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
  1959. (if (= 1 (org-export-get-relative-level headline info))
  1960. (plist-get info :html-container)
  1961. "div")
  1962. (format "outline-container-%s"
  1963. (or (org-element-property :CUSTOM_ID headline)
  1964. (concat "sec-" section-number)))
  1965. (concat (format "outline-%d" level1) (and extra-class " ")
  1966. extra-class)
  1967. (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
  1968. level1
  1969. preferred-id
  1970. (mapconcat
  1971. (lambda (x)
  1972. (let ((id (org-export-solidify-link-text
  1973. (if (org-uuidgen-p x) (concat "ID-" x)
  1974. x))))
  1975. (org-html--anchor id)))
  1976. extra-ids "")
  1977. full-text
  1978. level1)
  1979. ;; When there is no section, pretend there is an empty
  1980. ;; one to get the correct <div class="outline- ...>
  1981. ;; which is needed by `org-info.js'.
  1982. (if (not (eq (org-element-type first-content) 'section))
  1983. (concat (org-html-section first-content "" info)
  1984. contents)
  1985. contents)
  1986. (if (= 1 (org-export-get-relative-level headline info))
  1987. (plist-get info :html-container)
  1988. "div")))))))
  1989. ;;;; Horizontal Rule
  1990. (defun org-html-horizontal-rule (horizontal-rule contents info)
  1991. "Transcode an HORIZONTAL-RULE object from Org to HTML.
  1992. CONTENTS is nil. INFO is a plist holding contextual information."
  1993. "<hr/>")
  1994. ;;;; Inline Src Block
  1995. (defun org-html-inline-src-block (inline-src-block contents info)
  1996. "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
  1997. CONTENTS holds the contents of the item. INFO is a plist holding
  1998. contextual information."
  1999. (let* ((org-lang (org-element-property :language inline-src-block))
  2000. (code (org-element-property :value inline-src-block)))
  2001. (error "Cannot export inline src block")))
  2002. ;;;; Inlinetask
  2003. (defun org-html-format-section (text class &optional id)
  2004. "Format a section with TEXT into a HTML div with CLASS and ID."
  2005. (let ((extra (concat (when id (format " id=\"%s\"" id)))))
  2006. (concat (format "<div class=\"%s\"%s>\n" class extra) text "</div>\n")))
  2007. (defun org-html-inlinetask (inlinetask contents info)
  2008. "Transcode an INLINETASK element from Org to HTML.
  2009. CONTENTS holds the contents of the block. INFO is a plist
  2010. holding contextual information."
  2011. (cond
  2012. ;; If `org-html-format-inlinetask-function' is provided, call it
  2013. ;; with appropriate arguments.
  2014. ((functionp org-html-format-inlinetask-function)
  2015. (let ((format-function
  2016. (function*
  2017. (lambda (todo todo-type priority text tags
  2018. &key contents &allow-other-keys)
  2019. (funcall org-html-format-inlinetask-function
  2020. todo todo-type priority text tags contents)))))
  2021. (org-html-format-headline--wrap
  2022. inlinetask info format-function :contents contents)))
  2023. ;; Otherwise, use a default template.
  2024. (t (format "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>"
  2025. (org-html-format-headline--wrap inlinetask info)
  2026. contents))))
  2027. ;;;; Italic
  2028. (defun org-html-italic (italic contents info)
  2029. "Transcode ITALIC from Org to HTML.
  2030. CONTENTS is the text with italic markup. INFO is a plist holding
  2031. contextual information."
  2032. (format (or (cdr (assq 'italic org-html-text-markup-alist)) "%s") contents))
  2033. ;;;; Item
  2034. (defun org-html-checkbox (checkbox)
  2035. "Format CHECKBOX into HTML."
  2036. (case checkbox (on "<code>[X]</code>")
  2037. (off "<code>[&#xa0;]</code>")
  2038. (trans "<code>[-]</code>")
  2039. (t "")))
  2040. (defun org-html-format-list-item (contents type checkbox
  2041. &optional term-counter-id
  2042. headline)
  2043. "Format a list item into HTML."
  2044. (let ((checkbox (concat (org-html-checkbox checkbox) (and checkbox " "))))
  2045. (concat
  2046. (case type
  2047. (ordered
  2048. (let* ((counter term-counter-id)
  2049. (extra (if counter (format " value=\"%s\"" counter) "")))
  2050. (concat
  2051. (format "<li%s>" extra)
  2052. (when headline (concat headline "<br/>")))))
  2053. (unordered
  2054. (let* ((id term-counter-id)
  2055. (extra (if id (format " id=\"%s\"" id) "")))
  2056. (concat
  2057. (format "<li%s>" extra)
  2058. (when headline (concat headline "<br/>")))))
  2059. (descriptive
  2060. (let* ((term term-counter-id))
  2061. (setq term (or term "(no term)"))
  2062. ;; Check-boxes in descriptive lists are associated to tag.
  2063. (concat (format "<dt> %s </dt>"
  2064. (concat checkbox term))
  2065. "<dd>"))))
  2066. (unless (eq type 'descriptive) checkbox)
  2067. contents
  2068. (case type
  2069. (ordered "</li>")
  2070. (unordered "</li>")
  2071. (descriptive "</dd>")))))
  2072. (defun org-html-item (item contents info)
  2073. "Transcode an ITEM element from Org to HTML.
  2074. CONTENTS holds the contents of the item. INFO is a plist holding
  2075. contextual information."
  2076. (let* ((plain-list (org-export-get-parent item))
  2077. (type (org-element-property :type plain-list))
  2078. (counter (org-element-property :counter item))
  2079. (checkbox (org-element-property :checkbox item))
  2080. (tag (let ((tag (org-element-property :tag item)))
  2081. (and tag (org-export-data tag info)))))
  2082. (org-html-format-list-item
  2083. contents type checkbox (or tag counter))))
  2084. ;;;; Keyword
  2085. (defun org-html-keyword (keyword contents info)
  2086. "Transcode a KEYWORD element from Org to HTML.
  2087. CONTENTS is nil. INFO is a plist holding contextual information."
  2088. (let ((key (org-element-property :key keyword))
  2089. (value (org-element-property :value keyword)))
  2090. (cond
  2091. ((string= key "HTML") value)
  2092. ((string= key "TOC")
  2093. (let ((value (downcase value)))
  2094. (cond
  2095. ((string-match "\\<headlines\\>" value)
  2096. (let ((depth (or (and (string-match "[0-9]+" value)
  2097. (string-to-number (match-string 0 value)))
  2098. (plist-get info :with-toc))))
  2099. (org-html-toc depth info)))
  2100. ((string= "listings" value) (org-html-list-of-listings info))
  2101. ((string= "tables" value) (org-html-list-of-tables info))))))))
  2102. ;;;; Latex Environment
  2103. (defun org-html-format-latex (latex-frag processing-type)
  2104. "Format the LaTeX fragment LATEX-FRAG into HTML."
  2105. (let ((cache-relpath "") (cache-dir "") bfn)
  2106. (unless (eq processing-type 'mathjax)
  2107. (setq bfn (buffer-file-name)
  2108. cache-relpath
  2109. (concat "ltxpng/"
  2110. (file-name-sans-extension
  2111. (file-name-nondirectory bfn)))
  2112. cache-dir (file-name-directory bfn)))
  2113. (with-temp-buffer
  2114. (insert latex-frag)
  2115. (org-format-latex cache-relpath cache-dir nil "Creating LaTeX Image..."
  2116. nil nil processing-type)
  2117. (buffer-string))))
  2118. (defun org-html-latex-environment (latex-environment contents info)
  2119. "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
  2120. CONTENTS is nil. INFO is a plist holding contextual information."
  2121. (let ((processing-type (plist-get info :with-latex))
  2122. (latex-frag (org-remove-indentation
  2123. (org-element-property :value latex-environment)))
  2124. (caption (org-export-data
  2125. (org-export-get-caption latex-environment) info))
  2126. (attr nil) ; FIXME
  2127. (label (org-element-property :name latex-environment)))
  2128. (cond
  2129. ((memq processing-type '(t mathjax))
  2130. (org-html-format-latex latex-frag 'mathjax))
  2131. ((eq processing-type 'dvipng)
  2132. (let* ((formula-link (org-html-format-latex
  2133. latex-frag processing-type)))
  2134. (when (and formula-link
  2135. (string-match "file:\\([^]]*\\)" formula-link))
  2136. (org-html-format-inline-image
  2137. (match-string 1 formula-link) caption label attr t))))
  2138. (t latex-frag))))
  2139. ;;;; Latex Fragment
  2140. (defun org-html-latex-fragment (latex-fragment contents info)
  2141. "Transcode a LATEX-FRAGMENT object from Org to HTML.
  2142. CONTENTS is nil. INFO is a plist holding contextual information."
  2143. (let ((latex-frag (org-element-property :value latex-fragment))
  2144. (processing-type (plist-get info :with-latex)))
  2145. (case processing-type
  2146. ((t mathjax)
  2147. (org-html-format-latex latex-frag 'mathjax))
  2148. (dvipng
  2149. (let* ((formula-link (org-html-format-latex
  2150. latex-frag processing-type)))
  2151. (when (and formula-link
  2152. (string-match "file:\\([^]]*\\)" formula-link))
  2153. (org-html-format-inline-image
  2154. (match-string 1 formula-link)))))
  2155. (t latex-frag))))
  2156. ;;;; Line Break
  2157. (defun org-html-line-break (line-break contents info)
  2158. "Transcode a LINE-BREAK object from Org to HTML.
  2159. CONTENTS is nil. INFO is a plist holding contextual information."
  2160. "<br/>\n")
  2161. ;;;; Link
  2162. (defun org-html-link--inline-image (link desc info)
  2163. "Return HTML code for an inline image.
  2164. LINK is the link pointing to the inline image. INFO is a plist
  2165. used as a communication channel.
  2166. Inline images can have these attributes:
  2167. #+ATTR_HTML: :width 100px :height 100px :alt \"Alt description\"."
  2168. (let* ((type (org-element-property :type link))
  2169. (raw-path (org-element-property :path link))
  2170. (path (cond ((member type '("http" "https"))
  2171. (concat type ":" raw-path))
  2172. ((file-name-absolute-p raw-path)
  2173. (expand-file-name raw-path))
  2174. (t raw-path)))
  2175. (parent (org-export-get-parent-element link))
  2176. (caption (org-export-data (org-export-get-caption parent) info))
  2177. (label (org-element-property :name parent))
  2178. (attrs (org-export-read-attribute :attr_html parent))
  2179. (alt (plist-get attrs :alt))
  2180. (width (plist-get attrs :width))
  2181. (height (plist-get attrs :height))
  2182. (options (plist-get attrs :options)))
  2183. ;; Return proper string, depending on DISPOSITION.
  2184. (org-html-format-inline-image
  2185. path caption label
  2186. (mapconcat 'identity
  2187. (delq nil (list (if width (format "width=\"%s\"" width))
  2188. (if alt (format "alt=\"%s\"" alt))
  2189. (if height (format "height=\"%s\"" height))
  2190. options)) " ")
  2191. (org-html-standalone-image-p link info))))
  2192. (defvar org-html-standalone-image-predicate)
  2193. (defun org-html-standalone-image-p (element info &optional predicate)
  2194. "Test if ELEMENT is a standalone image for the purpose HTML export.
  2195. INFO is a plist holding contextual information.
  2196. Return non-nil, if ELEMENT is of type paragraph and it's sole
  2197. content, save for whitespaces, is a link that qualifies as an
  2198. inline image.
  2199. Return non-nil, if ELEMENT is of type link and it's containing
  2200. paragraph has no other content save for leading and trailing
  2201. whitespaces.
  2202. Return nil, otherwise.
  2203. Bind `org-html-standalone-image-predicate' to constrain
  2204. paragraph further. For example, to check for only captioned
  2205. standalone images, do the following.
  2206. \(setq org-html-standalone-image-predicate
  2207. \(lambda \(paragraph\)
  2208. \(org-element-property :caption paragraph\)\)\)"
  2209. (let ((paragraph (case (org-element-type element)
  2210. (paragraph element)
  2211. (link (and (org-export-inline-image-p
  2212. element org-html-inline-image-rules)
  2213. (org-export-get-parent element)))
  2214. (t nil))))
  2215. (when (eq (org-element-type paragraph) 'paragraph)
  2216. (when (or (not (and (boundp 'org-html-standalone-image-predicate)
  2217. (functionp org-html-standalone-image-predicate)))
  2218. (funcall org-html-standalone-image-predicate paragraph))
  2219. (let ((contents (org-element-contents paragraph)))
  2220. (loop for x in contents
  2221. with inline-image-count = 0
  2222. always (cond
  2223. ((eq (org-element-type x) 'plain-text)
  2224. (not (org-string-nw-p x)))
  2225. ((eq (org-element-type x) 'link)
  2226. (when (org-export-inline-image-p
  2227. x org-html-inline-image-rules)
  2228. (= (incf inline-image-count) 1)))
  2229. (t nil))))))))
  2230. (defun org-html-link (link desc info)
  2231. "Transcode a LINK object from Org to HTML.
  2232. DESC is the description part of the link, or the empty string.
  2233. INFO is a plist holding contextual information. See
  2234. `org-export-data'."
  2235. (let* ((link-org-files-as-html-maybe
  2236. (function
  2237. (lambda (raw-path info)
  2238. "Treat links to `file.org' as links to `file.html', if needed.
  2239. See `org-html-link-org-files-as-html'."
  2240. (cond
  2241. ((and org-html-link-org-files-as-html
  2242. (string= ".org"
  2243. (downcase (file-name-extension raw-path "."))))
  2244. (concat (file-name-sans-extension raw-path) "."
  2245. (plist-get info :html-extension)))
  2246. (t raw-path)))))
  2247. (type (org-element-property :type link))
  2248. (raw-path (org-element-property :path link))
  2249. ;; Ensure DESC really exists, or set it to nil.
  2250. (desc (and (not (string= desc "")) desc))
  2251. (path
  2252. (cond
  2253. ((member type '("http" "https" "ftp" "mailto"))
  2254. (concat type ":" raw-path))
  2255. ((string= type "file")
  2256. ;; Treat links to ".org" files as ".html", if needed.
  2257. (setq raw-path
  2258. (funcall link-org-files-as-html-maybe raw-path info))
  2259. ;; If file path is absolute, prepend it with protocol
  2260. ;; component - "file://".
  2261. (when (file-name-absolute-p raw-path)
  2262. (setq raw-path
  2263. (concat "file://" (expand-file-name raw-path))))
  2264. ;; Add search option, if any. A search option can be
  2265. ;; relative to a custom-id or a headline title. Any other
  2266. ;; option is ignored.
  2267. (let ((option (org-element-property :search-option link)))
  2268. (cond ((not option) raw-path)
  2269. ((eq (aref option 0) ?#) (concat raw-path option))
  2270. ;; External fuzzy link: try to resolve it if path
  2271. ;; belongs to current project, if any.
  2272. ((eq (aref option 0) ?*)
  2273. (concat
  2274. raw-path
  2275. (let ((numbers
  2276. (org-publish-resolve-external-fuzzy-link
  2277. (org-element-property :path link) option)))
  2278. (and numbers (concat "#sec-"
  2279. (mapconcat 'number-to-string
  2280. numbers "-"))))))
  2281. (t raw-path))))
  2282. (t raw-path)))
  2283. attributes protocol)
  2284. ;; Extract attributes from parent's paragraph. HACK: Only do this
  2285. ;; for the first link in parent. This is needed as long as
  2286. ;; attributes cannot be set on a per link basis.
  2287. (and (setq attributes
  2288. (let ((parent (org-export-get-parent-element link)))
  2289. (if (not (eq (org-element-map parent 'link 'identity info t)
  2290. link))
  2291. ""
  2292. (let ((att (org-export-read-attribute :attr_html parent :options)))
  2293. (unless (and desc att (string-match (regexp-quote att) desc))
  2294. (or att ""))))))
  2295. (unless (string= attributes "")
  2296. (setq attributes (concat " " attributes))))
  2297. (cond
  2298. ;; Image file.
  2299. ((and (or (eq t org-html-inline-images)
  2300. (and org-html-inline-images (not desc)))
  2301. (org-export-inline-image-p link org-html-inline-image-rules))
  2302. (org-html-link--inline-image link desc info))
  2303. ;; Radio target: Transcode target's contents and use them as
  2304. ;; link's description.
  2305. ((string= type "radio")
  2306. (let ((destination (org-export-resolve-radio-link link info)))
  2307. (when destination
  2308. (format "<a href=\"#%s\"%s>%s</a>"
  2309. (org-export-solidify-link-text path)
  2310. attributes
  2311. (org-export-data (org-element-contents destination) info)))))
  2312. ;; Links pointing to a headline: Find destination and build
  2313. ;; appropriate referencing command.
  2314. ((member type '("custom-id" "fuzzy" "id"))
  2315. (let ((destination (if (string= type "fuzzy")
  2316. (org-export-resolve-fuzzy-link link info)
  2317. (org-export-resolve-id-link link info))))
  2318. (case (org-element-type destination)
  2319. ;; ID link points to an external file.
  2320. (plain-text
  2321. (let ((fragment (concat "ID-" path))
  2322. ;; Treat links to ".org" files as ".html", if needed.
  2323. (path (funcall link-org-files-as-html-maybe
  2324. destination info)))
  2325. (format "<a href=\"%s#%s\"%s>%s</a>"
  2326. path fragment attributes (or desc destination))))
  2327. ;; Fuzzy link points nowhere.
  2328. ((nil)
  2329. (format "<i>%s</i>"
  2330. (or desc
  2331. (org-export-data
  2332. (org-element-property :raw-link link) info))))
  2333. ;; Fuzzy link points to an invisible target.
  2334. (keyword nil)
  2335. ;; Link points to a headline.
  2336. (headline
  2337. (let ((href
  2338. ;; What href to use?
  2339. (cond
  2340. ;; Case 1: Headline is linked via it's CUSTOM_ID
  2341. ;; property. Use CUSTOM_ID.
  2342. ((string= type "custom-id")
  2343. (org-element-property :CUSTOM_ID destination))
  2344. ;; Case 2: Headline is linked via it's ID property
  2345. ;; or through other means. Use the default href.
  2346. ((member type '("id" "fuzzy"))
  2347. (format "sec-%s"
  2348. (mapconcat 'number-to-string
  2349. (org-export-get-headline-number
  2350. destination info) "-")))
  2351. (t (error "Shouldn't reach here"))))
  2352. ;; What description to use?
  2353. (desc
  2354. ;; Case 1: Headline is numbered and LINK has no
  2355. ;; description or LINK's description matches
  2356. ;; headline's title. Display section number.
  2357. (if (and (org-export-numbered-headline-p destination info)
  2358. (or (not desc)
  2359. (string= desc (org-element-property
  2360. :raw-value destination))))
  2361. (mapconcat 'number-to-string
  2362. (org-export-get-headline-number
  2363. destination info) ".")
  2364. ;; Case 2: Either the headline is un-numbered or
  2365. ;; LINK has a custom description. Display LINK's
  2366. ;; description or headline's title.
  2367. (or desc (org-export-data (org-element-property
  2368. :title destination) info)))))
  2369. (format "<a href=\"#%s\"%s>%s</a>"
  2370. (org-export-solidify-link-text href) attributes desc)))
  2371. ;; Fuzzy link points to a target. Do as above.
  2372. (t
  2373. (let ((path (org-export-solidify-link-text path)) number)
  2374. (unless desc
  2375. (setq number (cond
  2376. ((org-html-standalone-image-p destination info)
  2377. (org-export-get-ordinal
  2378. (assoc 'link (org-element-contents destination))
  2379. info 'link 'org-html-standalone-image-p))
  2380. (t (org-export-get-ordinal destination info))))
  2381. (setq desc (when number
  2382. (if (atom number) (number-to-string number)
  2383. (mapconcat 'number-to-string number ".")))))
  2384. (format "<a href=\"#%s\"%s>%s</a>"
  2385. path attributes (or desc "No description for this link")))))))
  2386. ;; Coderef: replace link with the reference name or the
  2387. ;; equivalent line number.
  2388. ((string= type "coderef")
  2389. (let ((fragment (concat "coderef-" path)))
  2390. (format "<a href=\"#%s\"%s%s>%s</a>"
  2391. fragment
  2392. (org-trim
  2393. (format (concat "class=\"coderef\""
  2394. " onmouseover=\"CodeHighlightOn(this, '%s');\""
  2395. " onmouseout=\"CodeHighlightOff(this, '%s');\"")
  2396. fragment fragment))
  2397. attributes
  2398. (format (org-export-get-coderef-format path desc)
  2399. (org-export-resolve-coderef path info)))))
  2400. ;; Link type is handled by a special function.
  2401. ((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
  2402. (funcall protocol (org-link-unescape path) desc 'html))
  2403. ;; External link with a description part.
  2404. ((and path desc) (format "<a href=\"%s\"%s>%s</a>" path attributes desc))
  2405. ;; External link without a description part.
  2406. (path (format "<a href=\"%s\"%s>%s</a>" path attributes path))
  2407. ;; No path, only description. Try to do something useful.
  2408. (t (format "<i>%s</i>" desc)))))
  2409. ;;;; Paragraph
  2410. (defun org-html-paragraph (paragraph contents info)
  2411. "Transcode a PARAGRAPH element from Org to HTML.
  2412. CONTENTS is the contents of the paragraph, as a string. INFO is
  2413. the plist used as a communication channel."
  2414. (let* ((parent (org-export-get-parent paragraph))
  2415. (parent-type (org-element-type parent))
  2416. (style '((footnote-definition " class=\"footpara\"")))
  2417. (extra (or (cadr (assoc parent-type style)) "")))
  2418. (cond
  2419. ((and (eq (org-element-type parent) 'item)
  2420. (= (org-element-property :begin paragraph)
  2421. (org-element-property :contents-begin parent)))
  2422. ;; leading paragraph in a list item have no tags
  2423. contents)
  2424. ((org-html-standalone-image-p paragraph info)
  2425. ;; standalone image
  2426. contents)
  2427. (t (format "<p%s>\n%s</p>" extra contents)))))
  2428. ;;;; Plain List
  2429. ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
  2430. ;; the correct value for the item counter
  2431. (defun org-html-begin-plain-list (type &optional arg1)
  2432. "Insert the beginning of the HTML list depending on TYPE.
  2433. When ARG1 is a string, use it as the start parameter for ordered
  2434. lists."
  2435. (case type
  2436. (ordered
  2437. (format "<ol class=\"org-ol\"%s>"
  2438. (if arg1 (format " start=\"%d\"" arg1) "")))
  2439. (unordered "<ul class=\"org-ul\">")
  2440. (descriptive "<dl class=\"org-dl\">")))
  2441. (defun org-html-end-plain-list (type)
  2442. "Insert the end of the HTML list depending on TYPE."
  2443. (case type
  2444. (ordered "</ol>")
  2445. (unordered "</ul>")
  2446. (descriptive "</dl>")))
  2447. (defun org-html-plain-list (plain-list contents info)
  2448. "Transcode a PLAIN-LIST element from Org to HTML.
  2449. CONTENTS is the contents of the list. INFO is a plist holding
  2450. contextual information."
  2451. (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
  2452. (type (org-element-property :type plain-list)))
  2453. (format "%s\n%s%s"
  2454. (org-html-begin-plain-list type)
  2455. contents (org-html-end-plain-list type))))
  2456. ;;;; Plain Text
  2457. (defun org-html-convert-special-strings (string)
  2458. "Convert special characters in STRING to HTML."
  2459. (let ((all org-html-special-string-regexps)
  2460. e a re rpl start)
  2461. (while (setq a (pop all))
  2462. (setq re (car a) rpl (cdr a) start 0)
  2463. (while (string-match re string start)
  2464. (setq string (replace-match rpl t nil string))))
  2465. string))
  2466. (defun org-html-encode-plain-text (text)
  2467. "Convert plain text characters from TEXT to HTML equivalent.
  2468. Possible conversions are set in `org-html-protect-char-alist'."
  2469. (mapc
  2470. (lambda (pair)
  2471. (setq text (replace-regexp-in-string (car pair) (cdr pair) text t t)))
  2472. org-html-protect-char-alist)
  2473. text)
  2474. (defun org-html-plain-text (text info)
  2475. "Transcode a TEXT string from Org to HTML.
  2476. TEXT is the string to transcode. INFO is a plist holding
  2477. contextual information."
  2478. (let ((output text))
  2479. ;; Protect following characters: <, >, &.
  2480. (setq output (org-html-encode-plain-text output))
  2481. ;; Handle smart quotes. Be sure to provide original string since
  2482. ;; OUTPUT may have been modified.
  2483. (when (plist-get info :with-smart-quotes)
  2484. (setq output (org-export-activate-smart-quotes output :html info text)))
  2485. ;; Handle special strings.
  2486. (when (plist-get info :with-special-strings)
  2487. (setq output (org-html-convert-special-strings output)))
  2488. ;; Handle break preservation if required.
  2489. (when (plist-get info :preserve-breaks)
  2490. (setq output
  2491. (replace-regexp-in-string
  2492. "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output)))
  2493. ;; Return value.
  2494. output))
  2495. ;; Planning
  2496. (defun org-html-planning (planning contents info)
  2497. "Transcode a PLANNING element from Org to HTML.
  2498. CONTENTS is nil. INFO is a plist used as a communication
  2499. channel."
  2500. (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
  2501. (format
  2502. "<p><span class=\"timestamp-wrapper\">%s</span></p>"
  2503. (mapconcat
  2504. 'identity
  2505. (delq nil
  2506. (list
  2507. (let ((closed (org-element-property :closed planning)))
  2508. (when closed
  2509. (format span-fmt org-closed-string
  2510. (org-translate-time
  2511. (org-element-property :raw-value closed)))))
  2512. (let ((deadline (org-element-property :deadline planning)))
  2513. (when deadline
  2514. (format span-fmt org-deadline-string
  2515. (org-translate-time
  2516. (org-element-property :raw-value deadline)))))
  2517. (let ((scheduled (org-element-property :scheduled planning)))
  2518. (when scheduled
  2519. (format span-fmt org-scheduled-string
  2520. (org-translate-time
  2521. (org-element-property :raw-value scheduled)))))))
  2522. " "))))
  2523. ;;;; Property Drawer
  2524. (defun org-html-property-drawer (property-drawer contents info)
  2525. "Transcode a PROPERTY-DRAWER element from Org to HTML.
  2526. CONTENTS is nil. INFO is a plist holding contextual
  2527. information."
  2528. ;; The property drawer isn't exported but we want separating blank
  2529. ;; lines nonetheless.
  2530. "")
  2531. ;;;; Quote Block
  2532. (defun org-html-quote-block (quote-block contents info)
  2533. "Transcode a QUOTE-BLOCK element from Org to HTML.
  2534. CONTENTS holds the contents of the block. INFO is a plist
  2535. holding contextual information."
  2536. (format "<blockquote>\n%s</blockquote>" contents))
  2537. ;;;; Quote Section
  2538. (defun org-html-quote-section (quote-section contents info)
  2539. "Transcode a QUOTE-SECTION element from Org to HTML.
  2540. CONTENTS is nil. INFO is a plist holding contextual information."
  2541. (let ((value (org-remove-indentation
  2542. (org-element-property :value quote-section))))
  2543. (when value (format "<pre>\n%s</pre>" value))))
  2544. ;;;; Section
  2545. (defun org-html-section (section contents info)
  2546. "Transcode a SECTION element from Org to HTML.
  2547. CONTENTS holds the contents of the section. INFO is a plist
  2548. holding contextual information."
  2549. (let ((parent (org-export-get-parent-headline section)))
  2550. ;; Before first headline: no container, just return CONTENTS.
  2551. (if (not parent) contents
  2552. ;; Get div's class and id references.
  2553. (let* ((class-num (+ (org-export-get-relative-level parent info)
  2554. (1- org-html-toplevel-hlevel)))
  2555. (section-number
  2556. (mapconcat
  2557. 'number-to-string
  2558. (org-export-get-headline-number parent info) "-")))
  2559. ;; Build return value.
  2560. (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
  2561. class-num
  2562. (or (org-element-property :CUSTOM_ID parent) section-number)
  2563. contents)))))
  2564. ;;;; Radio Target
  2565. (defun org-html-radio-target (radio-target text info)
  2566. "Transcode a RADIO-TARGET object from Org to HTML.
  2567. TEXT is the text of the target. INFO is a plist holding
  2568. contextual information."
  2569. (let ((id (org-export-solidify-link-text
  2570. (org-element-property :value radio-target))))
  2571. (org-html--anchor id text)))
  2572. ;;;; Special Block
  2573. (defun org-html-special-block (special-block contents info)
  2574. "Transcode a SPECIAL-BLOCK element from Org to HTML.
  2575. CONTENTS holds the contents of the block. INFO is a plist
  2576. holding contextual information."
  2577. (format "<div class=\"%s\">\n%s\n</div>"
  2578. (downcase (org-element-property :type special-block))
  2579. contents))
  2580. ;;;; Src Block
  2581. (defun org-html-src-block (src-block contents info)
  2582. "Transcode a SRC-BLOCK element from Org to HTML.
  2583. CONTENTS holds the contents of the item. INFO is a plist holding
  2584. contextual information."
  2585. (if (org-export-read-attribute :attr_html src-block :textarea)
  2586. (org-html--textarea-block src-block)
  2587. (let ((lang (org-element-property :language src-block))
  2588. (caption (org-export-get-caption src-block))
  2589. (code (org-html-format-code src-block info))
  2590. (label (let ((lbl (org-element-property :name src-block)))
  2591. (if (not lbl) ""
  2592. (format " id=\"%s\""
  2593. (org-export-solidify-link-text lbl))))))
  2594. (if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
  2595. (format
  2596. "<div class=\"org-src-container\">\n%s%s\n</div>"
  2597. (if (not caption) ""
  2598. (format "<label class=\"org-src-name\">%s</label>"
  2599. (org-export-data caption info)))
  2600. (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code))))))
  2601. ;;;; Statistics Cookie
  2602. (defun org-html-statistics-cookie (statistics-cookie contents info)
  2603. "Transcode a STATISTICS-COOKIE object from Org to HTML.
  2604. CONTENTS is nil. INFO is a plist holding contextual information."
  2605. (let ((cookie-value (org-element-property :value statistics-cookie)))
  2606. (format "<code>%s</code>" cookie-value)))
  2607. ;;;; Strike-Through
  2608. (defun org-html-strike-through (strike-through contents info)
  2609. "Transcode STRIKE-THROUGH from Org to HTML.
  2610. CONTENTS is the text with strike-through markup. INFO is a plist
  2611. holding contextual information."
  2612. (format (or (cdr (assq 'strike-through org-html-text-markup-alist)) "%s")
  2613. contents))
  2614. ;;;; Subscript
  2615. (defun org-html-subscript (subscript contents info)
  2616. "Transcode a SUBSCRIPT object from Org to HTML.
  2617. CONTENTS is the contents of the object. INFO is a plist holding
  2618. contextual information."
  2619. (format "<sub>%s</sub>" contents))
  2620. ;;;; Superscript
  2621. (defun org-html-superscript (superscript contents info)
  2622. "Transcode a SUPERSCRIPT object from Org to HTML.
  2623. CONTENTS is the contents of the object. INFO is a plist holding
  2624. contextual information."
  2625. (format "<sup>%s</sup>" contents))
  2626. ;;;; Tabel Cell
  2627. (defun org-html-table-cell (table-cell contents info)
  2628. "Transcode a TABLE-CELL element from Org to HTML.
  2629. CONTENTS is nil. INFO is a plist used as a communication
  2630. channel."
  2631. (let* ((table-row (org-export-get-parent table-cell))
  2632. (table (org-export-get-parent-table table-cell))
  2633. (cell-attrs
  2634. (if (not org-html-table-align-individual-fields) ""
  2635. (format (if (and (boundp 'org-html-format-table-no-css)
  2636. org-html-format-table-no-css)
  2637. " align=\"%s\"" " class=\"%s\"")
  2638. (org-export-table-cell-alignment table-cell info)))))
  2639. (when (or (not contents) (string= "" (org-trim contents)))
  2640. (setq contents "&#xa0;"))
  2641. (cond
  2642. ((and (org-export-table-has-header-p table info)
  2643. (= 1 (org-export-table-row-group table-row info)))
  2644. (concat "\n" (format (car org-html-table-header-tags) "col" cell-attrs)
  2645. contents (cdr org-html-table-header-tags)))
  2646. ((and org-html-table-use-header-tags-for-first-column
  2647. (zerop (cdr (org-export-table-cell-address table-cell info))))
  2648. (concat "\n" (format (car org-html-table-header-tags) "row" cell-attrs)
  2649. contents (cdr org-html-table-header-tags)))
  2650. (t (concat "\n" (format (car org-html-table-data-tags) cell-attrs)
  2651. contents (cdr org-html-table-data-tags))))))
  2652. ;;;; Table Row
  2653. (defun org-html-table-row (table-row contents info)
  2654. "Transcode a TABLE-ROW element from Org to HTML.
  2655. CONTENTS is the contents of the row. INFO is a plist used as a
  2656. communication channel."
  2657. ;; Rules are ignored since table separators are deduced from
  2658. ;; borders of the current row.
  2659. (when (eq (org-element-property :type table-row) 'standard)
  2660. (let* ((rowgroup-number (org-export-table-row-group table-row info))
  2661. (row-number (org-export-table-row-number table-row info))
  2662. (start-rowgroup-p
  2663. (org-export-table-row-starts-rowgroup-p table-row info))
  2664. (end-rowgroup-p
  2665. (org-export-table-row-ends-rowgroup-p table-row info))
  2666. ;; `top-row-p' and `end-rowgroup-p' are not used directly
  2667. ;; but should be set so that `org-html-table-row-tags' can
  2668. ;; use them (see the docstring of this variable.)
  2669. (top-row-p (and (equal start-rowgroup-p '(top))
  2670. (equal end-rowgroup-p '(below top))))
  2671. (bottom-row-p (and (equal start-rowgroup-p '(above))
  2672. (equal end-rowgroup-p '(bottom above))))
  2673. (rowgroup-tags
  2674. (cond
  2675. ;; Case 1: Row belongs to second or subsequent rowgroups.
  2676. ((not (= 1 rowgroup-number))
  2677. '("<tbody>" . "\n</tbody>"))
  2678. ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
  2679. ((org-export-table-has-header-p
  2680. (org-export-get-parent-table table-row) info)
  2681. '("<thead>" . "\n</thead>"))
  2682. ;; Case 2: Row is from first and only row group.
  2683. (t '("<tbody>" . "\n</tbody>")))))
  2684. (concat
  2685. ;; Begin a rowgroup?
  2686. (when start-rowgroup-p (car rowgroup-tags))
  2687. ;; Actual table row
  2688. (concat "\n" (eval (car org-html-table-row-tags))
  2689. contents
  2690. "\n"
  2691. (eval (cdr org-html-table-row-tags)))
  2692. ;; End a rowgroup?
  2693. (when end-rowgroup-p (cdr rowgroup-tags))))))
  2694. ;;;; Table
  2695. (defun org-html-table-first-row-data-cells (table info)
  2696. "Transcode the first row of TABLE.
  2697. INFO is a plist used as a communication channel."
  2698. (let ((table-row
  2699. (org-element-map table 'table-row
  2700. (lambda (row)
  2701. (unless (eq (org-element-property :type row) 'rule) row))
  2702. info 'first-match))
  2703. (special-column-p (org-export-table-has-special-column-p table)))
  2704. (if (not special-column-p) (org-element-contents table-row)
  2705. (cdr (org-element-contents table-row)))))
  2706. (defun org-html-table--table.el-table (table info)
  2707. "Format table.el tables into HTML.
  2708. INFO is a plist used as a communication channel."
  2709. (when (eq (org-element-property :type table) 'table.el)
  2710. (require 'table)
  2711. (let ((outbuf (with-current-buffer
  2712. (get-buffer-create "*org-export-table*")
  2713. (erase-buffer) (current-buffer))))
  2714. (with-temp-buffer
  2715. (insert (org-element-property :value table))
  2716. (goto-char 1)
  2717. (re-search-forward "^[ \t]*|[^|]" nil t)
  2718. (table-generate-source 'html outbuf))
  2719. (with-current-buffer outbuf
  2720. (prog1 (org-trim (buffer-string))
  2721. (kill-buffer) )))))
  2722. (defun org-html-table (table contents info)
  2723. "Transcode a TABLE element from Org to HTML.
  2724. CONTENTS is the contents of the table. INFO is a plist holding
  2725. contextual information."
  2726. (case (org-element-property :type table)
  2727. ;; Case 1: table.el table. Convert it using appropriate tools.
  2728. (table.el (org-html-table--table.el-table table info))
  2729. ;; Case 2: Standard table.
  2730. (t
  2731. (let* ((label (org-element-property :name table))
  2732. (caption (org-export-get-caption table))
  2733. (attributes
  2734. (org-export-read-attribute :attr_html table :options))
  2735. (alignspec
  2736. (if (and (boundp 'org-html-format-table-no-css)
  2737. org-html-format-table-no-css)
  2738. "align=\"%s\"" "class=\"%s\""))
  2739. (table-column-specs
  2740. (function
  2741. (lambda (table info)
  2742. (mapconcat
  2743. (lambda (table-cell)
  2744. (let ((alignment (org-export-table-cell-alignment
  2745. table-cell info)))
  2746. (concat
  2747. ;; Begin a colgroup?
  2748. (when (org-export-table-cell-starts-colgroup-p
  2749. table-cell info)
  2750. "\n<colgroup>")
  2751. ;; Add a column. Also specify it's alignment.
  2752. (format "\n<col %s/>" (format alignspec alignment))
  2753. ;; End a colgroup?
  2754. (when (org-export-table-cell-ends-colgroup-p
  2755. table-cell info)
  2756. "\n</colgroup>"))))
  2757. (org-html-table-first-row-data-cells table info) "\n"))))
  2758. (table-attributes
  2759. (let ((table-tag (plist-get info :html-table-tag)))
  2760. (concat
  2761. (and (string-match "<table\\(.*\\)>" table-tag)
  2762. (match-string 1 table-tag))
  2763. (and label (format " id=\"%s\""
  2764. (org-export-solidify-link-text label)))
  2765. (unless (string= attributes "")
  2766. (concat " " attributes))))))
  2767. ;; Remove last blank line.
  2768. (setq contents (substring contents 0 -1))
  2769. (format "<table%s>\n%s\n%s\n%s\n</table>"
  2770. table-attributes
  2771. (if (not caption) ""
  2772. (format "<caption>%s</caption>"
  2773. (org-export-data caption info)))
  2774. (funcall table-column-specs table info)
  2775. contents)))))
  2776. ;;;; Target
  2777. (defun org-html-target (target contents info)
  2778. "Transcode a TARGET object from Org to HTML.
  2779. CONTENTS is nil. INFO is a plist holding contextual
  2780. information."
  2781. (let ((id (org-export-solidify-link-text
  2782. (org-element-property :value target))))
  2783. (org-html--anchor id)))
  2784. ;;;; Timestamp
  2785. (defun org-html-timestamp (timestamp contents info)
  2786. "Transcode a TIMESTAMP object from Org to HTML.
  2787. CONTENTS is nil. INFO is a plist holding contextual
  2788. information."
  2789. (let ((value (org-html-plain-text
  2790. (org-timestamp-translate timestamp) info)))
  2791. (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
  2792. (replace-regexp-in-string "--" "&#x2013;" value))))
  2793. ;;;; Underline
  2794. (defun org-html-underline (underline contents info)
  2795. "Transcode UNDERLINE from Org to HTML.
  2796. CONTENTS is the text with underline markup. INFO is a plist
  2797. holding contextual information."
  2798. (format (or (cdr (assq 'underline org-html-text-markup-alist)) "%s")
  2799. contents))
  2800. ;;;; Verbatim
  2801. (defun org-html-verbatim (verbatim contents info)
  2802. "Transcode VERBATIM from Org to HTML.
  2803. CONTENTS is nil. INFO is a plist holding contextual
  2804. information."
  2805. (format (or (cdr (assq 'verbatim org-html-text-markup-alist)) "%s")
  2806. (org-html-plain-text (org-element-property :value verbatim) info)))
  2807. ;;;; Verse Block
  2808. (defun org-html-verse-block (verse-block contents info)
  2809. "Transcode a VERSE-BLOCK element from Org to HTML.
  2810. CONTENTS is verse block contents. INFO is a plist holding
  2811. contextual information."
  2812. ;; Replace each newline character with line break. Also replace
  2813. ;; each blank line with a line break.
  2814. (setq contents (replace-regexp-in-string
  2815. "^ *\\\\\\\\$" "<br/>\n"
  2816. (replace-regexp-in-string
  2817. "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents)))
  2818. ;; Replace each white space at beginning of a line with a
  2819. ;; non-breaking space.
  2820. (while (string-match "^[ \t]+" contents)
  2821. (let* ((num-ws (length (match-string 0 contents)))
  2822. (ws (let (out) (dotimes (i num-ws out)
  2823. (setq out (concat out "&#xa0;"))))))
  2824. (setq contents (replace-match ws nil t contents))))
  2825. (format "<p class=\"verse\">\n%s</p>" contents))
  2826. ;;; Filter Functions
  2827. (defun org-html-final-function (contents backend info)
  2828. "Filter to indent the HTML and convert HTML entities."
  2829. (with-temp-buffer
  2830. (insert contents)
  2831. (set-auto-mode t)
  2832. (if org-html-indent
  2833. (indent-region (point-min) (point-max)))
  2834. (when org-html-use-unicode-chars
  2835. (require 'mm-url)
  2836. (mm-url-decode-entities))
  2837. (buffer-substring-no-properties (point-min) (point-max))))
  2838. ;;; End-user functions
  2839. ;;;###autoload
  2840. (defun org-html-export-as-html
  2841. (&optional async subtreep visible-only body-only ext-plist)
  2842. "Export current buffer to an HTML buffer.
  2843. If narrowing is active in the current buffer, only export its
  2844. narrowed part.
  2845. If a region is active, export that region.
  2846. A non-nil optional argument ASYNC means the process should happen
  2847. asynchronously. The resulting buffer should be accessible
  2848. through the `org-export-stack' interface.
  2849. When optional argument SUBTREEP is non-nil, export the sub-tree
  2850. at point, extracting information from the headline properties
  2851. first.
  2852. When optional argument VISIBLE-ONLY is non-nil, don't export
  2853. contents of hidden elements.
  2854. When optional argument BODY-ONLY is non-nil, only write code
  2855. between \"<body>\" and \"</body>\" tags.
  2856. EXT-PLIST, when provided, is a property list with external
  2857. parameters overriding Org default settings, but still inferior to
  2858. file-local settings.
  2859. Export is done in a buffer named \"*Org HTML Export*\", which
  2860. will be displayed when `org-export-show-temporary-export-buffer'
  2861. is non-nil."
  2862. (interactive)
  2863. (if async
  2864. (org-export-async-start
  2865. (lambda (output)
  2866. (with-current-buffer (get-buffer-create "*Org HTML Export*")
  2867. (erase-buffer)
  2868. (insert output)
  2869. (goto-char (point-min))
  2870. (set-auto-mode t)
  2871. (org-export-add-to-stack (current-buffer) 'html)))
  2872. `(org-export-as 'html ,subtreep ,visible-only ,body-only ',ext-plist))
  2873. (let ((outbuf (org-export-to-buffer
  2874. 'html "*Org HTML Export*"
  2875. subtreep visible-only body-only ext-plist)))
  2876. ;; Set major mode.
  2877. (with-current-buffer outbuf (set-auto-mode t))
  2878. (when org-export-show-temporary-export-buffer
  2879. (switch-to-buffer-other-window outbuf)))))
  2880. ;;;###autoload
  2881. (defun org-html-convert-region-to-html ()
  2882. "Assume the current region has org-mode syntax, and convert it to HTML.
  2883. This can be used in any buffer. For example, you can write an
  2884. itemized list in org-mode syntax in an HTML buffer and use this
  2885. command to convert it."
  2886. (interactive)
  2887. (org-export-replace-region-by 'html))
  2888. ;;;###autoload
  2889. (defun org-html-export-to-html
  2890. (&optional async subtreep visible-only body-only ext-plist)
  2891. "Export current buffer to a HTML file.
  2892. If narrowing is active in the current buffer, only export its
  2893. narrowed part.
  2894. If a region is active, export that region.
  2895. A non-nil optional argument ASYNC means the process should happen
  2896. asynchronously. The resulting file should be accessible through
  2897. the `org-export-stack' interface.
  2898. When optional argument SUBTREEP is non-nil, export the sub-tree
  2899. at point, extracting information from the headline properties
  2900. first.
  2901. When optional argument VISIBLE-ONLY is non-nil, don't export
  2902. contents of hidden elements.
  2903. When optional argument BODY-ONLY is non-nil, only write code
  2904. between \"<body>\" and \"</body>\" tags.
  2905. EXT-PLIST, when provided, is a property list with external
  2906. parameters overriding Org default settings, but still inferior to
  2907. file-local settings.
  2908. Return output file's name."
  2909. (interactive)
  2910. (let* ((extension (concat "." org-html-extension))
  2911. (file (org-export-output-file-name extension subtreep))
  2912. (org-export-coding-system org-html-coding-system))
  2913. (if async
  2914. (org-export-async-start
  2915. (lambda (f) (org-export-add-to-stack f 'html))
  2916. (let ((org-export-coding-system org-html-coding-system))
  2917. `(expand-file-name
  2918. (org-export-to-file
  2919. 'html ,file ,subtreep ,visible-only ,body-only ',ext-plist))))
  2920. (let ((org-export-coding-system org-html-coding-system))
  2921. (org-export-to-file
  2922. 'html file subtreep visible-only body-only ext-plist)))))
  2923. ;;;###autoload
  2924. (defun org-html-publish-to-html (plist filename pub-dir)
  2925. "Publish an org file to HTML.
  2926. FILENAME is the filename of the Org file to be published. PLIST
  2927. is the property list for the given project. PUB-DIR is the
  2928. publishing directory.
  2929. Return output file name."
  2930. (org-publish-org-to 'html filename
  2931. (concat "." (or (plist-get plist :html-extension)
  2932. org-html-extension "html"))
  2933. plist pub-dir))
  2934. ;;; FIXME
  2935. ;;;; org-format-table-html
  2936. ;;;; org-format-org-table-html
  2937. ;;;; org-format-table-table-html
  2938. ;;;; org-table-number-fraction
  2939. ;;;; org-table-number-regexp
  2940. ;;;; org-html-table-caption-above
  2941. ;;;; org-html-inline-image-extensions
  2942. ;;;; org-export-preferred-target-alist
  2943. ;;;; class for anchors
  2944. ;;;; org-export-mark-todo-in-toc
  2945. ;;;; org-html-format-org-link
  2946. ;;;; (caption (and caption (org-xml-encode-org-text caption)))
  2947. ;;;; alt = (file-name-nondirectory path)
  2948. (provide 'ox-html)
  2949. ;; Local variables:
  2950. ;; generated-autoload-file: "org-loaddefs.el"
  2951. ;; End:
  2952. ;;; ox-html.el ends here