org-e-html.el 117 KB

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