ox-html.el 139 KB

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