ox-html.el 118 KB

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