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