ox-html.el 139 KB

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