ox-html.el 119 KB

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