org-e-html.el 115 KB

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