org-html.el 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135
  1. ;;; org-html.el --- HTML export for Org-mode
  2. ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
  3. ;; Free Software Foundation, Inc.
  4. ;; Author: Carsten Dominik <carsten at orgmode dot org>
  5. ;; Keywords: outlines, hypermedia, calendar, wp
  6. ;; Homepage: http://orgmode.org
  7. ;; Version: 6.36trans
  8. ;;
  9. ;; This file is part of GNU Emacs.
  10. ;;
  11. ;; GNU Emacs is free software: you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation, either version 3 of the License, or
  14. ;; (at your option) any later version.
  15. ;; GNU Emacs is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;; GNU General Public License for more details.
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  21. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  22. ;;
  23. ;;; Commentary:
  24. (require 'org-exp)
  25. (eval-when-compile (require 'cl))
  26. (declare-function org-id-find-id-file "org-id" (id))
  27. (declare-function htmlize-region "ext:htmlize" (beg end))
  28. (defgroup org-export-html nil
  29. "Options specific for HTML export of Org-mode files."
  30. :tag "Org Export HTML"
  31. :group 'org-export)
  32. (defcustom org-export-html-footnotes-section "<div id=\"footnotes\">
  33. <h2 class=\"footnotes\">%s: </h2>
  34. <div id=\"text-footnotes\">
  35. %s
  36. </div>
  37. </div>"
  38. "Format for the footnotes section.
  39. Should contain a two instances of %s. The first will be replaced with the
  40. language-specific word for \"Footnotes\", the second one will be replaced
  41. by the footnotes themselves."
  42. :group 'org-export-html
  43. :type 'string)
  44. (defcustom org-export-html-footnote-format "<sup>%s</sup>"
  45. "The format for the footnote reference.
  46. %s will be replaced by the footnote reference itself."
  47. :group 'org-export-html
  48. :type 'string)
  49. (defcustom org-export-html-coding-system nil
  50. "Coding system for HTML export, defaults to buffer-file-coding-system."
  51. :group 'org-export-html
  52. :type 'coding-system)
  53. (defcustom org-export-html-extension "html"
  54. "The extension for exported HTML files."
  55. :group 'org-export-html
  56. :type 'string)
  57. (defcustom org-export-html-xml-declaration
  58. '(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
  59. ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
  60. "The extension for exported HTML files.
  61. %s will be replaced with the charset of the exported file.
  62. This may be a string, or an alist with export extensions
  63. and corresponding declarations."
  64. :group 'org-export-html
  65. :type '(choice
  66. (string :tag "Single declaration")
  67. (repeat :tag "Dependent on extension"
  68. (cons (string :tag "Extension")
  69. (string :tag "Declaration")))))
  70. (defcustom org-export-html-style-include-scripts t
  71. "Non-nil means include the javascript snippets in exported HTML files.
  72. The actual script is defined in `org-export-html-scripts' and should
  73. not be modified."
  74. :group 'org-export-html
  75. :type 'boolean)
  76. (defconst org-export-html-scripts
  77. "<script type=\"text/javascript\">
  78. <!--/*--><![CDATA[/*><!--*/
  79. function CodeHighlightOn(elem, id)
  80. {
  81. var target = document.getElementById(id);
  82. if(null != target) {
  83. elem.cacheClassElem = elem.className;
  84. elem.cacheClassTarget = target.className;
  85. target.className = \"code-highlighted\";
  86. elem.className = \"code-highlighted\";
  87. }
  88. }
  89. function CodeHighlightOff(elem, id)
  90. {
  91. var target = document.getElementById(id);
  92. if(elem.cacheClassElem)
  93. elem.className = elem.cacheClassElem;
  94. if(elem.cacheClassTarget)
  95. target.className = elem.cacheClassTarget;
  96. }
  97. /*]]>*///-->
  98. </script>"
  99. "Basic javascript that is needed by HTML files produced by Org-mode.")
  100. (defconst org-export-html-style-default
  101. "<style type=\"text/css\">
  102. <!--/*--><![CDATA[/*><!--*/
  103. html { font-family: Times, serif; font-size: 12pt; }
  104. .title { text-align: center; }
  105. .todo { color: red; }
  106. .done { color: green; }
  107. .tag { background-color: #add8e6; font-weight:normal }
  108. .target { }
  109. .timestamp { color: #bebebe; }
  110. .timestamp-kwd { color: #5f9ea0; }
  111. p.verse { margin-left: 3% }
  112. pre {
  113. border: 1pt solid #AEBDCC;
  114. background-color: #F3F5F7;
  115. padding: 5pt;
  116. font-family: courier, monospace;
  117. font-size: 90%;
  118. overflow:auto;
  119. }
  120. table { border-collapse: collapse; }
  121. td, th { vertical-align: top; }
  122. dt { font-weight: bold; }
  123. div.figure { padding: 0.5em; }
  124. div.figure p { text-align: center; }
  125. textarea { overflow-x: auto; }
  126. .linenr { font-size:smaller }
  127. .code-highlighted {background-color:#ffff00;}
  128. .org-info-js_info-navigation { border-style:none; }
  129. #org-info-js_console-label { font-size:10px; font-weight:bold;
  130. white-space:nowrap; }
  131. .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
  132. font-weight:bold; }
  133. /*]]>*/-->
  134. </style>"
  135. "The default style specification for exported HTML files.
  136. Please use the variables `org-export-html-style' and
  137. `org-export-html-style-extra' to add to this style. If you wish to not
  138. have the default style included, customize the variable
  139. `org-export-html-style-include-default'.")
  140. (defcustom org-export-html-style-include-default t
  141. "Non-nil means include the default style in exported HTML files.
  142. The actual style is defined in `org-export-html-style-default' and should
  143. not be modified. Use the variables `org-export-html-style' to add
  144. your own style information."
  145. :group 'org-export-html
  146. :type 'boolean)
  147. ;;;###autoload
  148. (put 'org-export-html-style-include-default 'safe-local-variable 'booleanp)
  149. (defcustom org-export-html-style ""
  150. "Org-wide style definitions for exported HTML files.
  151. This variable needs to contain the full HTML structure to provide a style,
  152. including the surrounding HTML tags. If you set the value of this variable,
  153. you should consider to include definitions for the following classes:
  154. title, todo, done, timestamp, timestamp-kwd, tag, target.
  155. For example, a valid value would be:
  156. <style type=\"text/css\">
  157. <![CDATA[
  158. p { font-weight: normal; color: gray; }
  159. h1 { color: black; }
  160. .title { text-align: center; }
  161. .todo, .timestamp-kwd { color: red; }
  162. .done { color: green; }
  163. ]]>
  164. </style>
  165. If you'd like to refer to en external style file, use something like
  166. <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
  167. As the value of this option simply gets inserted into the HTML <head> header,
  168. you can \"misuse\" it to add arbitrary text to the header.
  169. See also the variable `org-export-html-style-extra'."
  170. :group 'org-export-html
  171. :type 'string)
  172. ;;;###autoload
  173. (put 'org-export-html-style 'safe-local-variable 'stringp)
  174. (defcustom org-export-html-style-extra ""
  175. "Additional style information for HTML export.
  176. The value of this variable is inserted into the HTML buffer right after
  177. the value of `org-export-html-style'. Use this variable for per-file
  178. settings of style information, and do not forget to surround the style
  179. settings with <style>...</style> tags."
  180. :group 'org-export-html
  181. :type 'string)
  182. ;;;###autoload
  183. (put 'org-export-html-style-extra 'safe-local-variable 'stringp)
  184. (defcustom org-export-html-tag-class-prefix ""
  185. "Prefix to clas names for TODO keywords.
  186. Each tag gets a class given by the tag itself, with this prefix.
  187. The default prefix is empty because it is nice to just use the keyword
  188. as a class name. But if you get into conflicts with other, existing
  189. CSS classes, then this prefic can be very useful."
  190. :group 'org-export-html
  191. :type 'string)
  192. (defcustom org-export-html-todo-kwd-class-prefix ""
  193. "Prefix to clas names for TODO keywords.
  194. Each TODO keyword gets a class given by the keyword itself, with this prefix.
  195. The default prefix is empty because it is nice to just use the keyword
  196. as a class name. But if you get into conflicts with other, existing
  197. CSS classes, then this prefic can be very useful."
  198. :group 'org-export-html
  199. :type 'string)
  200. (defcustom org-export-html-title-format "<h1 class=\"title\">%s</h1>\n"
  201. "Format for typesetting the document title in HTML export."
  202. :group 'org-export-html
  203. :type 'string)
  204. (defcustom org-export-html-home/up-format
  205. "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
  206. <a accesskey=\"h\" href=\"%s\"> UP </a>
  207. |
  208. <a accesskey=\"H\" href=\"%s\"> HOME </a>
  209. </div>"
  210. "Snippet used to insert the HOME and UP links. This is a format,
  211. the first %s will receive the UP link, the second the HOME link.
  212. If both `org-export-html-link-up' and `org-export-html-link-home' are
  213. empty, the entire snippet will be ignored."
  214. :group 'org-export-html
  215. :type 'string)
  216. (defcustom org-export-html-toplevel-hlevel 2
  217. "The <H> level for level 1 headings in HTML export.
  218. This is also important for the classes that will be wrapped around headlines
  219. and outline structure. If this variable is 1, the top-level headlines will
  220. be <h1>, and the corresponding classes will be outline-1, section-number-1,
  221. and outline-text-1. If this is 2, all of these will get a 2 instead.
  222. The default for this variable is 2, because we use <h1> for formatting the
  223. document title."
  224. :group 'org-export-html
  225. :type 'string)
  226. (defcustom org-export-html-link-org-files-as-html t
  227. "Non-nil means make file links to `file.org' point to `file.html'.
  228. When org-mode is exporting an org-mode file to HTML, links to
  229. non-html files are directly put into a href tag in HTML.
  230. However, links to other Org-mode files (recognized by the
  231. extension `.org.) should become links to the corresponding html
  232. file, assuming that the linked org-mode file will also be
  233. converted to HTML.
  234. When nil, the links still point to the plain `.org' file."
  235. :group 'org-export-html
  236. :type 'boolean)
  237. (defcustom org-export-html-inline-images 'maybe
  238. "Non-nil means inline images into exported HTML pages.
  239. This is done using an <img> tag. When nil, an anchor with href is used to
  240. link to the image. If this option is `maybe', then images in links with
  241. an empty description will be inlined, while images with a description will
  242. be linked only."
  243. :group 'org-export-html
  244. :type '(choice (const :tag "Never" nil)
  245. (const :tag "Always" t)
  246. (const :tag "When there is no description" maybe)))
  247. (defcustom org-export-html-inline-image-extensions
  248. '("png" "jpeg" "jpg" "gif")
  249. "Extensions of image files that can be inlined into HTML."
  250. :group 'org-export-html
  251. :type '(repeat (string :tag "Extension")))
  252. (defcustom org-export-html-table-tag
  253. "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
  254. "The HTML tag that is used to start a table.
  255. This must be a <table> tag, but you may change the options like
  256. borders and spacing."
  257. :group 'org-export-html
  258. :type 'string)
  259. (defcustom org-export-table-header-tags '("<th scope=\"%s\">" . "</th>")
  260. "The opening tag for table header fields.
  261. This is customizable so that alignment options can be specified.
  262. %s will be filled with the scope of the field, either row or col.
  263. See also the variable `org-export-html-table-use-header-tags-for-first-column'."
  264. :group 'org-export-tables
  265. :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
  266. (defcustom org-export-table-data-tags '("<td>" . "</td>")
  267. "The opening tag for table data fields.
  268. This is customizable so that alignment options can be specified."
  269. :group 'org-export-tables
  270. :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
  271. (defcustom org-export-table-row-tags '("<tr>" . "</tr>")
  272. "The opening tag for table data fields.
  273. This is customizable so that alignment options can be specified.
  274. Instead of strings, these can be Lisp forms that will be evaluated
  275. for each row in order to construct the table row tags. During evaluation,
  276. the variable `head' will be true when this is a header line, nil when this
  277. is a body line. And the variable `nline' will contain the line number,
  278. starting from 1 in the first header line. For example
  279. (setq org-export-table-row-tags
  280. (cons '(if head
  281. \"<tr>\"
  282. (if (= (mod nline 2) 1)
  283. \"<tr class=\\\"tr-odd\\\">\"
  284. \"<tr class=\\\"tr-even\\\">\"))
  285. \"</tr>\"))
  286. will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
  287. :group 'org-export-tables
  288. :type '(cons
  289. (choice :tag "Opening tag"
  290. (string :tag "Specify")
  291. (sexp))
  292. (choice :tag "Closing tag"
  293. (string :tag "Specify")
  294. (sexp))))
  295. (defcustom org-export-html-table-use-header-tags-for-first-column nil
  296. "Non-nil means format column one in tables with header tags.
  297. When nil, also column one will use data tags."
  298. :group 'org-export-tables
  299. :type 'boolean)
  300. (defcustom org-export-html-validation-link nil
  301. "Non-nil means add validationlink to postamble of HTML exported files."
  302. :group 'org-export-html
  303. :type '(choice
  304. (const :tag "Nothing" nil)
  305. (const :tag "XHTML 1.0" "<p class=\"xhtml-validation\"><a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a></p>")
  306. (string :tag "Specify full HTML")))
  307. (defcustom org-export-html-with-timestamp nil
  308. "If non-nil, write `org-export-html-html-helper-timestamp'
  309. into the exported HTML text. Otherwise, the buffer will just be saved
  310. to a file."
  311. :group 'org-export-html
  312. :type 'boolean)
  313. (defcustom org-export-html-html-helper-timestamp
  314. "<br/><br/><hr><p><!-- hhmts start --> <!-- hhmts end --></p>\n"
  315. "The HTML tag used as timestamp delimiter for HTML-helper-mode."
  316. :group 'org-export-html
  317. :type 'string)
  318. (defgroup org-export-htmlize nil
  319. "Options for processing examples with htmlize.el."
  320. :tag "Org Export Htmlize"
  321. :group 'org-export-html)
  322. (defcustom org-export-htmlize-output-type 'inline-css
  323. "Output type to be used by htmlize when formatting code snippets.
  324. We use as default `inline-css', in order to make the resulting
  325. HTML self-containing.
  326. However, this will fail when using Emacs in batch mode for export, because
  327. then no rich font definitions are in place. It will also not be good if
  328. people with different Emacs setup contribute HTML files to a website,
  329. because the fonts will represent the individual setups. In these cases,
  330. it is much better to let Org/Htmlize assign classes only, and to use
  331. a style file to define the look of these classes.
  332. To get a start for your css file, start Emacs session and make sure that
  333. all the faces you are interested in are defined, for example by loading files
  334. in all modes you want. Then, use the command
  335. \\[org-export-htmlize-generate-css] to extract class definitions."
  336. :group 'org-export-htmlize
  337. :type '(choice (const css) (const inline-css)))
  338. (defcustom org-export-htmlize-css-font-prefix "org-"
  339. "The prefix for CSS class names for htmlize font specifications."
  340. :group 'org-export-htmlize
  341. :type 'string)
  342. (defcustom org-export-htmlized-org-css-url nil
  343. "URL pointing to a CSS file defining text colors for htmlized Emacs buffers.
  344. Normally when creating an htmlized version of an Org buffer, htmlize will
  345. create CSS to define the font colors. However, this does not work when
  346. converting in batch mode, and it also can look bad if different people
  347. with different fontification setup work on the same website.
  348. When this variable is non-nil, creating an htmlized version of an Org buffer
  349. using `org-export-as-org' will remove the internal CSS section and replace it
  350. with a link to this URL."
  351. :group 'org-export-htmlize
  352. :type '(choice
  353. (const :tag "Keep internal css" nil)
  354. (string :tag "URL or local href")))
  355. ;;; Variables, constants, and parameter plists
  356. (defvar org-export-html-preamble nil
  357. "Preamble, to be inserted just before <body>. Set by publishing functions.
  358. This may also be a function, building and inserting the preamble.")
  359. (defvar org-export-html-postamble nil
  360. "Preamble, to be inserted just after </body>. Set by publishing functions.
  361. This may also be a function, building and inserting the postamble.")
  362. (defvar org-export-html-auto-preamble t
  363. "Should default preamble be inserted? Set by publishing functions.")
  364. (defvar org-export-html-auto-postamble t
  365. "Should default postamble be inserted? Set by publishing functions.")
  366. ;;; Hooks
  367. (defvar org-export-html-after-blockquotes-hook nil
  368. "Hook run during HTML export, after blockquote, verse, center are done.")
  369. (defvar org-export-html-final-hook nil
  370. "Hook run at the end of HTML export, in the new buffer.")
  371. ;;; HTML export
  372. (defun org-export-html-preprocess (parameters)
  373. ;; Convert LaTeX fragments to images
  374. (when (and org-current-export-file
  375. (plist-get parameters :LaTeX-fragments))
  376. (org-format-latex
  377. (concat "ltxpng/" (file-name-sans-extension
  378. (file-name-nondirectory
  379. org-current-export-file)))
  380. org-current-export-dir nil "Creating LaTeX image %s"))
  381. (goto-char (point-min))
  382. (let (label l1)
  383. (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t)
  384. (org-if-unprotected-at (match-beginning 1)
  385. (setq label (match-string 1))
  386. (save-match-data
  387. (if (string-match "\\`[a-z]\\{1,10\\}:\\(.+\\)" label)
  388. (setq l1 (substring label (match-beginning 1)))
  389. (setq l1 label)))
  390. (replace-match (format "[[#%s][%s]]" label l1) t t)))))
  391. ;;;###autoload
  392. (defun org-export-as-html-and-open (arg)
  393. "Export the outline as HTML and immediately open it with a browser.
  394. If there is an active region, export only the region.
  395. The prefix ARG specifies how many levels of the outline should become
  396. headlines. The default is 3. Lower levels will become bulleted lists."
  397. (interactive "P")
  398. (org-export-as-html arg 'hidden)
  399. (org-open-file buffer-file-name)
  400. (when org-export-kill-product-buffer-when-displayed
  401. (kill-buffer (current-buffer))))
  402. ;;;###autoload
  403. (defun org-export-as-html-batch ()
  404. "Call `org-export-as-html', may be used in batch processing as
  405. emacs --batch
  406. --load=$HOME/lib/emacs/org.el
  407. --eval \"(setq org-export-headline-levels 2)\"
  408. --visit=MyFile --funcall org-export-as-html-batch"
  409. (org-export-as-html org-export-headline-levels 'hidden))
  410. ;;;###autoload
  411. (defun org-export-as-html-to-buffer (arg)
  412. "Call `org-export-as-html` with output to a temporary buffer.
  413. No file is created. The prefix ARG is passed through to `org-export-as-html'."
  414. (interactive "P")
  415. (org-export-as-html arg nil nil "*Org HTML Export*")
  416. (when org-export-show-temporary-export-buffer
  417. (switch-to-buffer-other-window "*Org HTML Export*")))
  418. ;;;###autoload
  419. (defun org-replace-region-by-html (beg end)
  420. "Assume the current region has org-mode syntax, and convert it to HTML.
  421. This can be used in any buffer. For example, you could write an
  422. itemized list in org-mode syntax in an HTML buffer and then use this
  423. command to convert it."
  424. (interactive "r")
  425. (let (reg html buf pop-up-frames)
  426. (save-window-excursion
  427. (if (org-mode-p)
  428. (setq html (org-export-region-as-html
  429. beg end t 'string))
  430. (setq reg (buffer-substring beg end)
  431. buf (get-buffer-create "*Org tmp*"))
  432. (with-current-buffer buf
  433. (erase-buffer)
  434. (insert reg)
  435. (org-mode)
  436. (setq html (org-export-region-as-html
  437. (point-min) (point-max) t 'string)))
  438. (kill-buffer buf)))
  439. (delete-region beg end)
  440. (insert html)))
  441. ;;;###autoload
  442. (defun org-export-region-as-html (beg end &optional body-only buffer)
  443. "Convert region from BEG to END in org-mode buffer to HTML.
  444. If prefix arg BODY-ONLY is set, omit file header, footer, and table of
  445. contents, and only produce the region of converted text, useful for
  446. cut-and-paste operations.
  447. If BUFFER is a buffer or a string, use/create that buffer as a target
  448. of the converted HTML. If BUFFER is the symbol `string', return the
  449. produced HTML as a string and leave not buffer behind. For example,
  450. a Lisp program could call this function in the following way:
  451. (setq html (org-export-region-as-html beg end t 'string))
  452. When called interactively, the output buffer is selected, and shown
  453. in a window. A non-interactive call will only return the buffer."
  454. (interactive "r\nP")
  455. (when (interactive-p)
  456. (setq buffer "*Org HTML Export*"))
  457. (let ((transient-mark-mode t) (zmacs-regions t)
  458. ext-plist rtn)
  459. (setq ext-plist (plist-put ext-plist :ignore-subtree-p t))
  460. (goto-char end)
  461. (set-mark (point)) ;; to activate the region
  462. (goto-char beg)
  463. (setq rtn (org-export-as-html
  464. nil nil ext-plist
  465. buffer body-only))
  466. (if (fboundp 'deactivate-mark) (deactivate-mark))
  467. (if (and (interactive-p) (bufferp rtn))
  468. (switch-to-buffer-other-window rtn)
  469. rtn)))
  470. (defvar html-table-tag nil) ; dynamically scoped into this.
  471. (defvar org-par-open nil)
  472. ;;;###autoload
  473. (defun org-export-as-html (arg &optional hidden ext-plist
  474. to-buffer body-only pub-dir)
  475. "Export the outline as a pretty HTML file.
  476. If there is an active region, export only the region. The prefix
  477. ARG specifies how many levels of the outline should become
  478. headlines. The default is 3. Lower levels will become bulleted
  479. lists. HIDDEN is obsolete and does nothing.
  480. EXT-PLIST is a property list with external parameters overriding
  481. org-mode's default settings, but still inferior to file-local
  482. settings. When TO-BUFFER is non-nil, create a buffer with that
  483. name and export to that buffer. If TO-BUFFER is the symbol
  484. `string', don't leave any buffer behind but just return the
  485. resulting HTML as a string. When BODY-ONLY is set, don't produce
  486. the file header and footer, simply return the content of
  487. <body>...</body>, without even the body tags themselves. When
  488. PUB-DIR is set, use this as the publishing directory."
  489. (interactive "P")
  490. (run-hooks 'org-export-first-hook)
  491. ;; Make sure we have a file name when we need it.
  492. (when (and (not (or to-buffer body-only))
  493. (not buffer-file-name))
  494. (if (buffer-base-buffer)
  495. (org-set-local 'buffer-file-name
  496. (with-current-buffer (buffer-base-buffer)
  497. buffer-file-name))
  498. (error "Need a file name to be able to export")))
  499. (message "Exporting...")
  500. (setq-default org-todo-line-regexp org-todo-line-regexp)
  501. (setq-default org-deadline-line-regexp org-deadline-line-regexp)
  502. (setq-default org-done-keywords org-done-keywords)
  503. (setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp)
  504. (let* ((opt-plist
  505. (org-export-process-option-filters
  506. (org-combine-plists (org-default-export-plist)
  507. ext-plist
  508. (org-infile-export-plist))))
  509. (body-only (or body-only (plist-get opt-plist :body-only)))
  510. (style (concat (if (plist-get opt-plist :style-include-default)
  511. org-export-html-style-default)
  512. (plist-get opt-plist :style)
  513. (plist-get opt-plist :style-extra)
  514. "\n"
  515. (if (plist-get opt-plist :style-include-scripts)
  516. org-export-html-scripts)))
  517. (html-extension (plist-get opt-plist :html-extension))
  518. (link-validate (plist-get opt-plist :link-validation-function))
  519. valid thetoc have-headings first-heading-pos
  520. (odd org-odd-levels-only)
  521. (region-p (org-region-active-p))
  522. (rbeg (and region-p (region-beginning)))
  523. (rend (and region-p (region-end)))
  524. (subtree-p
  525. (if (plist-get opt-plist :ignore-subtree-p)
  526. nil
  527. (when region-p
  528. (save-excursion
  529. (goto-char rbeg)
  530. (and (org-at-heading-p)
  531. (>= (org-end-of-subtree t t) rend))))))
  532. (level-offset (if subtree-p
  533. (save-excursion
  534. (goto-char rbeg)
  535. (+ (funcall outline-level)
  536. (if org-odd-levels-only 1 0)))
  537. 0))
  538. (opt-plist (setq org-export-opt-plist
  539. (if subtree-p
  540. (org-export-add-subtree-options opt-plist rbeg)
  541. opt-plist)))
  542. ;; The following two are dynamically scoped into other
  543. ;; routines below.
  544. (org-current-export-dir
  545. (or pub-dir (org-export-directory :html opt-plist)))
  546. (org-current-export-file buffer-file-name)
  547. (level 0) (line "") (origline "") txt todo
  548. (umax nil)
  549. (umax-toc nil)
  550. (filename (if to-buffer nil
  551. (expand-file-name
  552. (concat
  553. (file-name-sans-extension
  554. (or (and subtree-p
  555. (org-entry-get (region-beginning)
  556. "EXPORT_FILE_NAME" t))
  557. (file-name-nondirectory buffer-file-name)))
  558. "." html-extension)
  559. (file-name-as-directory
  560. (or pub-dir (org-export-directory :html opt-plist))))))
  561. (current-dir (if buffer-file-name
  562. (file-name-directory buffer-file-name)
  563. default-directory))
  564. (buffer (if to-buffer
  565. (cond
  566. ((eq to-buffer 'string) (get-buffer-create "*Org HTML Export*"))
  567. (t (get-buffer-create to-buffer)))
  568. (find-file-noselect filename)))
  569. (org-levels-open (make-vector org-level-max nil))
  570. (date (plist-get opt-plist :date))
  571. (author (plist-get opt-plist :author))
  572. (title (or (and subtree-p (org-export-get-title-from-subtree))
  573. (plist-get opt-plist :title)
  574. (and (not body-only)
  575. (not
  576. (plist-get opt-plist :skip-before-1st-heading))
  577. (org-export-grab-title-from-buffer))
  578. (and buffer-file-name
  579. (file-name-sans-extension
  580. (file-name-nondirectory buffer-file-name)))
  581. "UNTITLED"))
  582. (link-up (and (plist-get opt-plist :link-up)
  583. (string-match "\\S-" (plist-get opt-plist :link-up))
  584. (plist-get opt-plist :link-up)))
  585. (link-home (and (plist-get opt-plist :link-home)
  586. (string-match "\\S-" (plist-get opt-plist :link-home))
  587. (plist-get opt-plist :link-home)))
  588. (dummy (setq opt-plist (plist-put opt-plist :title title)))
  589. (html-table-tag (plist-get opt-plist :html-table-tag))
  590. (quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
  591. (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)"))
  592. (inquote nil)
  593. (infixed nil)
  594. (inverse nil)
  595. (in-local-list nil)
  596. (local-list-type nil)
  597. (local-list-indent nil)
  598. (llt org-plain-list-ordered-item-terminator)
  599. (email (plist-get opt-plist :email))
  600. (language (plist-get opt-plist :language))
  601. (keywords (plist-get opt-plist :keywords))
  602. (description (plist-get opt-plist :description))
  603. (lang-words nil)
  604. (head-count 0) cnt
  605. (start 0)
  606. (coding-system (and (boundp 'buffer-file-coding-system)
  607. buffer-file-coding-system))
  608. (coding-system-for-write (or org-export-html-coding-system
  609. coding-system))
  610. (save-buffer-coding-system (or org-export-html-coding-system
  611. coding-system))
  612. (charset (and coding-system-for-write
  613. (fboundp 'coding-system-get)
  614. (coding-system-get coding-system-for-write
  615. 'mime-charset)))
  616. (region
  617. (buffer-substring
  618. (if region-p (region-beginning) (point-min))
  619. (if region-p (region-end) (point-max))))
  620. (lines
  621. (org-split-string
  622. (org-export-preprocess-string
  623. region
  624. :emph-multiline t
  625. :for-html t
  626. :skip-before-1st-heading
  627. (plist-get opt-plist :skip-before-1st-heading)
  628. :drawers (plist-get opt-plist :drawers)
  629. :todo-keywords (plist-get opt-plist :todo-keywords)
  630. :tags (plist-get opt-plist :tags)
  631. :priority (plist-get opt-plist :priority)
  632. :footnotes (plist-get opt-plist :footnotes)
  633. :timestamps (plist-get opt-plist :timestamps)
  634. :archived-trees
  635. (plist-get opt-plist :archived-trees)
  636. :select-tags (plist-get opt-plist :select-tags)
  637. :exclude-tags (plist-get opt-plist :exclude-tags)
  638. :add-text
  639. (plist-get opt-plist :text)
  640. :LaTeX-fragments
  641. (plist-get opt-plist :LaTeX-fragments))
  642. "[\r\n]"))
  643. table-open type
  644. table-buffer table-orig-buffer
  645. ind item-type starter didclose
  646. rpl path attr desc descp desc1 desc2 link
  647. snumber fnc item-tag initial-number
  648. footnotes footref-seen
  649. id-file href
  650. )
  651. (let ((inhibit-read-only t))
  652. (org-unmodified
  653. (remove-text-properties (point-min) (point-max)
  654. '(:org-license-to-kill t))))
  655. (message "Exporting...")
  656. (setq org-min-level (org-get-min-level lines level-offset))
  657. (setq org-last-level org-min-level)
  658. (org-init-section-numbers)
  659. (cond
  660. ((and date (string-match "%" date))
  661. (setq date (format-time-string date)))
  662. (date)
  663. (t (setq date (format-time-string "%Y-%m-%d %T %Z"))))
  664. ;; Get the language-dependent settings
  665. (setq lang-words (or (assoc language org-export-language-setup)
  666. (assoc "en" org-export-language-setup)))
  667. ;; Switch to the output buffer
  668. (set-buffer buffer)
  669. (let ((inhibit-read-only t)) (erase-buffer))
  670. (fundamental-mode)
  671. (org-install-letbind)
  672. (and (fboundp 'set-buffer-file-coding-system)
  673. (set-buffer-file-coding-system coding-system-for-write))
  674. (let ((case-fold-search nil)
  675. (org-odd-levels-only odd))
  676. ;; create local variables for all options, to make sure all called
  677. ;; functions get the correct information
  678. (mapc (lambda (x)
  679. (set (make-local-variable (nth 2 x))
  680. (plist-get opt-plist (car x))))
  681. org-export-plist-vars)
  682. (setq umax (if arg (prefix-numeric-value arg)
  683. org-export-headline-levels))
  684. (setq umax-toc (if (integerp org-export-with-toc)
  685. (min org-export-with-toc umax)
  686. umax))
  687. (unless body-only
  688. ;; File header
  689. (insert (format
  690. "%s
  691. <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
  692. \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
  693. <html xmlns=\"http://www.w3.org/1999/xhtml\"
  694. lang=\"%s\" xml:lang=\"%s\">
  695. <head>
  696. <title>%s</title>
  697. <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
  698. <meta name=\"generator\" content=\"Org-mode\"/>
  699. <meta name=\"generated\" content=\"%s\"/>
  700. <meta name=\"author\" content=\"%s\"/>
  701. <meta name=\"description\" content=\"%s\"/>
  702. <meta name=\"keywords\" content=\"%s\"/>
  703. %s
  704. </head>
  705. <body>
  706. <div id=\"content\">
  707. %s
  708. "
  709. (format
  710. (or (and (stringp org-export-html-xml-declaration)
  711. org-export-html-xml-declaration)
  712. (cdr (assoc html-extension org-export-html-xml-declaration))
  713. (cdr (assoc "html" org-export-html-xml-declaration))
  714. "")
  715. (or charset "iso-8859-1"))
  716. language language
  717. (org-html-expand title)
  718. (or charset "iso-8859-1")
  719. date author description keywords
  720. style
  721. (if (or link-up link-home)
  722. (concat
  723. (format org-export-html-home/up-format
  724. (or link-up link-home)
  725. (or link-home link-up))
  726. "\n")
  727. "")))
  728. (org-export-html-insert-plist-item opt-plist :preamble opt-plist)
  729. (when (plist-get opt-plist :auto-preamble)
  730. (if title (insert (format org-export-html-title-format
  731. (org-html-expand title))))))
  732. (if (and org-export-with-toc (not body-only))
  733. (progn
  734. (push (format "<h%d>%s</h%d>\n"
  735. org-export-html-toplevel-hlevel
  736. (nth 3 lang-words)
  737. org-export-html-toplevel-hlevel)
  738. thetoc)
  739. (push "<div id=\"text-table-of-contents\">\n" thetoc)
  740. (push "<ul>\n<li>" thetoc)
  741. (setq lines
  742. (mapcar '(lambda (line)
  743. (if (and (string-match org-todo-line-regexp line)
  744. (not (get-text-property 0 'org-protected line)))
  745. ;; This is a headline
  746. (progn
  747. (setq have-headings t)
  748. (setq level (- (match-end 1) (match-beginning 1)
  749. level-offset)
  750. level (org-tr-level level)
  751. txt (save-match-data
  752. (org-html-expand
  753. (org-export-cleanup-toc-line
  754. (match-string 3 line))))
  755. todo
  756. (or (and org-export-mark-todo-in-toc
  757. (match-beginning 2)
  758. (not (member (match-string 2 line)
  759. org-done-keywords)))
  760. ; TODO, not DONE
  761. (and org-export-mark-todo-in-toc
  762. (= level umax-toc)
  763. (org-search-todo-below
  764. line lines level))))
  765. (if (string-match
  766. (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt)
  767. (setq txt (replace-match "&nbsp;&nbsp;&nbsp;<span class=\"tag\"> \\1</span>" t nil txt)))
  768. (if (string-match quote-re0 txt)
  769. (setq txt (replace-match "" t t txt)))
  770. (setq snumber (org-section-number level))
  771. (if org-export-with-section-numbers
  772. (setq txt (concat snumber " " txt)))
  773. (if (<= level (max umax umax-toc))
  774. (setq head-count (+ head-count 1)))
  775. (if (<= level umax-toc)
  776. (progn
  777. (if (> level org-last-level)
  778. (progn
  779. (setq cnt (- level org-last-level))
  780. (while (>= (setq cnt (1- cnt)) 0)
  781. (push "\n<ul>\n<li>" thetoc))
  782. (push "\n" thetoc)))
  783. (if (< level org-last-level)
  784. (progn
  785. (setq cnt (- org-last-level level))
  786. (while (>= (setq cnt (1- cnt)) 0)
  787. (push "</li>\n</ul>" thetoc))
  788. (push "\n" thetoc)))
  789. ;; Check for targets
  790. (while (string-match org-any-target-regexp line)
  791. (setq line (replace-match
  792. (concat "@<span class=\"target\">" (match-string 1 line) "@</span> ")
  793. t t line)))
  794. (while (string-match "&lt;\\(&lt;\\)+\\|&gt;\\(&gt;\\)+" txt)
  795. (setq txt (replace-match "" t t txt)))
  796. (setq href
  797. (replace-regexp-in-string
  798. "\\." "_" (format "sec-%s" snumber)))
  799. (setq href (or (cdr (assoc href org-export-preferred-target-alist)) href))
  800. (push
  801. (format
  802. (if todo
  803. "</li>\n<li><a href=\"#%s\"><span class=\"todo\">%s</span></a>"
  804. "</li>\n<li><a href=\"#%s\">%s</a>")
  805. href txt) thetoc)
  806. (setq org-last-level level))
  807. )))
  808. line)
  809. lines))
  810. (while (> org-last-level (1- org-min-level))
  811. (setq org-last-level (1- org-last-level))
  812. (push "</li>\n</ul>\n" thetoc))
  813. (push "</div>\n" thetoc)
  814. (setq thetoc (if have-headings (nreverse thetoc) nil))))
  815. (setq head-count 0)
  816. (org-init-section-numbers)
  817. (org-open-par)
  818. (while (setq line (pop lines) origline line)
  819. (catch 'nextline
  820. ;; end of quote section?
  821. (when (and inquote (string-match "^\\*+ " line))
  822. (insert "</pre>\n")
  823. (org-open-par)
  824. (setq inquote nil))
  825. ;; inside a quote section?
  826. (when inquote
  827. (insert (org-html-protect line) "\n")
  828. (throw 'nextline nil))
  829. ;; Fixed-width, verbatim lines (examples)
  830. (when (and org-export-with-fixed-width
  831. (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line))
  832. (when (not infixed)
  833. (setq infixed t)
  834. (org-close-par-maybe)
  835. (insert "<pre class=\"example\">\n"))
  836. (insert (org-html-protect (match-string 3 line)) "\n")
  837. (when (or (not lines)
  838. (not (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)"
  839. (car lines))))
  840. (setq infixed nil)
  841. (insert "</pre>\n")
  842. (org-open-par))
  843. (throw 'nextline nil))
  844. (org-export-html-close-lists-maybe line)
  845. ;; Protected HTML
  846. (when (get-text-property 0 'org-protected line)
  847. (let (par (ind (get-text-property 0 'original-indentation line)))
  848. (when (re-search-backward
  849. "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
  850. (setq par (match-string 1))
  851. (replace-match "\\2\n"))
  852. (insert line "\n")
  853. (while (and lines
  854. (or (= (length (car lines)) 0)
  855. (not ind)
  856. (equal ind (get-text-property 0 'original-indentation (car lines))))
  857. (or (= (length (car lines)) 0)
  858. (get-text-property 0 'org-protected (car lines))))
  859. (insert (pop lines) "\n"))
  860. (and par (insert "<p>\n")))
  861. (throw 'nextline nil))
  862. ;; Blockquotes, verse, and center
  863. (when (equal "ORG-BLOCKQUOTE-START" line)
  864. (org-close-par-maybe)
  865. (insert "<blockquote>\n")
  866. (org-open-par)
  867. (throw 'nextline nil))
  868. (when (equal "ORG-BLOCKQUOTE-END" line)
  869. (org-close-par-maybe)
  870. (insert "\n</blockquote>\n")
  871. (org-open-par)
  872. (throw 'nextline nil))
  873. (when (equal "ORG-VERSE-START" line)
  874. (org-close-par-maybe)
  875. (insert "\n<p class=\"verse\">\n")
  876. (setq org-par-open t)
  877. (setq inverse t)
  878. (throw 'nextline nil))
  879. (when (equal "ORG-VERSE-END" line)
  880. (insert "</p>\n")
  881. (setq org-par-open nil)
  882. (org-open-par)
  883. (setq inverse nil)
  884. (throw 'nextline nil))
  885. (when (equal "ORG-CENTER-START" line)
  886. (org-close-par-maybe)
  887. (insert "\n<div style=\"text-align: center\">")
  888. (org-open-par)
  889. (throw 'nextline nil))
  890. (when (equal "ORG-CENTER-END" line)
  891. (org-close-par-maybe)
  892. (insert "\n</div>")
  893. (org-open-par)
  894. (throw 'nextline nil))
  895. (run-hooks 'org-export-html-after-blockquotes-hook)
  896. (when inverse
  897. (let ((i (org-get-string-indentation line)))
  898. (if (> i 0)
  899. (setq line (concat (mapconcat 'identity
  900. (make-list (* 2 i) "\\nbsp") "")
  901. " " (org-trim line))))
  902. (unless (string-match "\\\\\\\\[ \t]*$" line)
  903. (setq line (concat line "\\\\")))))
  904. ;; make targets to anchors
  905. (setq start 0)
  906. (while (string-match
  907. "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start)
  908. (cond
  909. ((get-text-property (match-beginning 1) 'org-protected line)
  910. (setq start (match-end 1)))
  911. ((match-end 2)
  912. (setq line (replace-match
  913. (format
  914. "@<a name=\"%s\" id=\"%s\">@</a>"
  915. (org-solidify-link-text (match-string 1 line))
  916. (org-solidify-link-text (match-string 1 line)))
  917. t t line)))
  918. ((and org-export-with-toc (equal (string-to-char line) ?*))
  919. ;; FIXME: NOT DEPENDENT on TOC?????????????????????
  920. (setq line (replace-match
  921. (concat "@<span class=\"target\">"
  922. (match-string 1 line) "@</span> ")
  923. ;; (concat "@<i>" (match-string 1 line) "@</i> ")
  924. t t line)))
  925. (t
  926. (setq line (replace-match
  927. (concat "@<a name=\""
  928. (org-solidify-link-text (match-string 1 line))
  929. "\" class=\"target\">" (match-string 1 line)
  930. "@</a> ")
  931. t t line)))))
  932. (setq line (org-html-handle-time-stamps line))
  933. ;; replace "&" by "&amp;", "<" and ">" by "&lt;" and "&gt;"
  934. ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
  935. ;; Also handle sub_superscripts and checkboxes
  936. (or (string-match org-table-hline-regexp line)
  937. (setq line (org-html-expand line)))
  938. ;; Format the links
  939. (setq start 0)
  940. (while (string-match org-bracket-link-analytic-regexp++ line start)
  941. (setq start (match-beginning 0))
  942. (setq path (save-match-data (org-link-unescape
  943. (match-string 3 line))))
  944. (setq type (cond
  945. ((match-end 2) (match-string 2 line))
  946. ((save-match-data
  947. (or (file-name-absolute-p path)
  948. (string-match "^\\.\\.?/" path)))
  949. "file")
  950. (t "internal")))
  951. (setq path (org-extract-attributes (org-link-unescape path)))
  952. (setq attr (get-text-property 0 'org-attributes path))
  953. (setq desc1 (if (match-end 5) (match-string 5 line))
  954. desc2 (if (match-end 2) (concat type ":" path) path)
  955. descp (and desc1 (not (equal desc1 desc2)))
  956. desc (or desc1 desc2))
  957. ;; Make an image out of the description if that is so wanted
  958. (when (and descp (org-file-image-p
  959. desc org-export-html-inline-image-extensions))
  960. (save-match-data
  961. (if (string-match "^file:" desc)
  962. (setq desc (substring desc (match-end 0)))))
  963. (setq desc (org-add-props
  964. (concat "<img src=\"" desc "\"/>")
  965. '(org-protected t))))
  966. ;; FIXME: do we need to unescape here somewhere?
  967. (cond
  968. ((equal type "internal")
  969. (setq rpl
  970. (concat
  971. "<a href=\""
  972. (if (= (string-to-char path) ?#) "" "#")
  973. (org-solidify-link-text
  974. (save-match-data (org-link-unescape path)) nil)
  975. "\"" attr ">"
  976. (org-export-html-format-desc desc)
  977. "</a>")))
  978. ((and (equal type "id")
  979. (setq id-file (org-id-find-id-file path)))
  980. ;; This is an id: link to another file (if it was the same file,
  981. ;; it would have become an internal link...)
  982. (save-match-data
  983. (setq id-file (file-relative-name
  984. id-file (file-name-directory org-current-export-file)))
  985. (setq id-file (concat (file-name-sans-extension id-file)
  986. "." html-extension))
  987. (setq rpl (concat "<a href=\"" id-file "#"
  988. (if (org-uuidgen-p path) "ID-")
  989. path "\""
  990. attr ">"
  991. (org-export-html-format-desc desc)
  992. "</a>"))))
  993. ((member type '("http" "https"))
  994. ;; standard URL, just check if we need to inline an image
  995. (if (and (or (eq t org-export-html-inline-images)
  996. (and org-export-html-inline-images (not descp)))
  997. (org-file-image-p
  998. path org-export-html-inline-image-extensions))
  999. (setq rpl (org-export-html-format-image
  1000. (concat type ":" path) org-par-open))
  1001. (setq link (concat type ":" path))
  1002. (setq rpl (concat "<a href=\""
  1003. (org-export-html-format-href link)
  1004. "\"" attr ">"
  1005. (org-export-html-format-desc desc)
  1006. "</a>"))))
  1007. ((member type '("ftp" "mailto" "news"))
  1008. ;; standard URL
  1009. (setq link (concat type ":" path))
  1010. (setq rpl (concat "<a href=\""
  1011. (org-export-html-format-href link)
  1012. "\"" attr ">"
  1013. (org-export-html-format-desc desc)
  1014. "</a>")))
  1015. ((string= type "coderef")
  1016. (setq rpl (format "<a href=\"#coderef-%s\" class=\"coderef\" onmouseover=\"CodeHighlightOn(this, 'coderef-%s');\" onmouseout=\"CodeHighlightOff(this, 'coderef-%s');\">%s</a>"
  1017. path path path
  1018. (format (org-export-get-coderef-format path (and descp desc))
  1019. (cdr (assoc path org-export-code-refs))))))
  1020. ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
  1021. ;; The link protocol has a function for format the link
  1022. (setq rpl
  1023. (save-match-data
  1024. (funcall fnc (org-link-unescape path) desc1 'html))))
  1025. ((string= type "file")
  1026. ;; FILE link
  1027. (let* ((filename path)
  1028. (abs-p (file-name-absolute-p filename))
  1029. thefile file-is-image-p search)
  1030. (save-match-data
  1031. (if (string-match "::\\(.*\\)" filename)
  1032. (setq search (match-string 1 filename)
  1033. filename (replace-match "" t nil filename)))
  1034. (setq valid
  1035. (if (functionp link-validate)
  1036. (funcall link-validate filename current-dir)
  1037. t))
  1038. (setq file-is-image-p
  1039. (org-file-image-p
  1040. filename org-export-html-inline-image-extensions))
  1041. (setq thefile (if abs-p (expand-file-name filename) filename))
  1042. (when (and org-export-html-link-org-files-as-html
  1043. (string-match "\\.org$" thefile))
  1044. (setq thefile (concat (substring thefile 0
  1045. (match-beginning 0))
  1046. "." html-extension))
  1047. (if (and search
  1048. ;; make sure this is can be used as target search
  1049. (not (string-match "^[0-9]*$" search))
  1050. (not (string-match "^\\*" search))
  1051. (not (string-match "^/.*/$" search)))
  1052. (setq thefile
  1053. (concat thefile
  1054. (if (= (string-to-char search) ?#) "" "#")
  1055. (org-solidify-link-text
  1056. (org-link-unescape search)))))
  1057. (when (string-match "^file:" desc)
  1058. (setq desc (replace-match "" t t desc))
  1059. (if (string-match "\\.org$" desc)
  1060. (setq desc (replace-match "" t t desc))))))
  1061. (setq rpl (if (and file-is-image-p
  1062. (or (eq t org-export-html-inline-images)
  1063. (and org-export-html-inline-images
  1064. (not descp))))
  1065. (progn
  1066. (message "image %s %s" thefile org-par-open)
  1067. (org-export-html-format-image thefile org-par-open))
  1068. (concat "<a href=\"" thefile "\"" attr ">"
  1069. (org-export-html-format-desc desc)
  1070. "</a>")))
  1071. (if (not valid) (setq rpl desc))))
  1072. (t
  1073. ;; just publish the path, as default
  1074. (setq rpl (concat "<i>&lt;" type ":"
  1075. (save-match-data (org-link-unescape path))
  1076. "&gt;</i>"))))
  1077. (setq line (replace-match rpl t t line)
  1078. start (+ start (length rpl))))
  1079. ;; TODO items
  1080. (if (and (string-match org-todo-line-regexp line)
  1081. (match-beginning 2))
  1082. (setq line
  1083. (concat (substring line 0 (match-beginning 2))
  1084. "<span class=\""
  1085. (if (member (match-string 2 line)
  1086. org-done-keywords)
  1087. "done" "todo")
  1088. " " (match-string 2 line)
  1089. "\"> " (org-export-html-get-todo-kwd-class-name
  1090. (match-string 2 line))
  1091. "</span>" (substring line (match-end 2)))))
  1092. ;; Does this contain a reference to a footnote?
  1093. (when org-export-with-footnotes
  1094. (setq start 0)
  1095. (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
  1096. (if (get-text-property (match-beginning 2) 'org-protected line)
  1097. (setq start (match-end 2))
  1098. (let ((n (match-string 2 line)) extra a)
  1099. (if (setq a (assoc n footref-seen))
  1100. (progn
  1101. (setcdr a (1+ (cdr a)))
  1102. (setq extra (format ".%d" (cdr a))))
  1103. (setq extra "")
  1104. (push (cons n 1) footref-seen))
  1105. (setq line
  1106. (replace-match
  1107. (format
  1108. (concat "%s"
  1109. (format org-export-html-footnote-format
  1110. "<a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a>"))
  1111. (or (match-string 1 line) "") n extra n n)
  1112. t t line))))))
  1113. (cond
  1114. ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
  1115. ;; This is a headline
  1116. (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
  1117. level-offset))
  1118. txt (match-string 2 line))
  1119. (if (string-match quote-re0 txt)
  1120. (setq txt (replace-match "" t t txt)))
  1121. (if (<= level (max umax umax-toc))
  1122. (setq head-count (+ head-count 1)))
  1123. (when in-local-list
  1124. ;; Close any local lists before inserting a new header line
  1125. (while local-list-type
  1126. (org-close-li (car local-list-type))
  1127. (insert (format "</%sl>\n" (car local-list-type)))
  1128. (pop local-list-type))
  1129. (setq local-list-indent nil
  1130. in-local-list nil))
  1131. (setq first-heading-pos (or first-heading-pos (point)))
  1132. (org-html-level-start level txt umax
  1133. (and org-export-with-toc (<= level umax))
  1134. head-count)
  1135. ;; QUOTES
  1136. (when (string-match quote-re line)
  1137. (org-close-par-maybe)
  1138. (insert "<pre>")
  1139. (setq inquote t)))
  1140. ((string-match "^[ \t]*- __+[ \t]*$" line)
  1141. ;; Explicit list closure
  1142. (when local-list-type
  1143. (let ((ind (org-get-indentation line)))
  1144. (while (and local-list-indent
  1145. (<= ind (car local-list-indent)))
  1146. (org-close-li (car local-list-type))
  1147. (insert (format "</%sl>\n" (car local-list-type)))
  1148. (pop local-list-type)
  1149. (pop local-list-indent))
  1150. (or local-list-indent (setq in-local-list nil))))
  1151. (throw 'nextline nil))
  1152. ((and org-export-with-tables
  1153. (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
  1154. (when (not table-open)
  1155. ;; New table starts
  1156. (setq table-open t table-buffer nil table-orig-buffer nil))
  1157. ;; Accumulate lines
  1158. (setq table-buffer (cons line table-buffer)
  1159. table-orig-buffer (cons origline table-orig-buffer))
  1160. (when (or (not lines)
  1161. (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
  1162. (car lines))))
  1163. (setq table-open nil
  1164. table-buffer (nreverse table-buffer)
  1165. table-orig-buffer (nreverse table-orig-buffer))
  1166. (org-close-par-maybe)
  1167. (insert (org-format-table-html table-buffer table-orig-buffer))))
  1168. (t
  1169. ;; Normal lines
  1170. (when (string-match
  1171. (cond
  1172. ((eq llt t) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+[.)]\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
  1173. ((= llt ?.) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+\\.\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
  1174. ((= llt ?\)) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+)\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
  1175. (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))
  1176. line)
  1177. (setq ind (or (get-text-property 0 'original-indentation line)
  1178. (org-get-string-indentation line))
  1179. item-type (if (match-beginning 4) "o" "u")
  1180. starter (if (match-beginning 2)
  1181. (substring (match-string 2 line) 0 -1))
  1182. line (substring line (match-beginning 5))
  1183. initial-number nil
  1184. item-tag nil)
  1185. (if (string-match "\\`\\[@start:\\([0-9]+\\)\\][ \t]?" line)
  1186. (setq initial-number (match-string 1 line)
  1187. line (replace-match "" t t line)))
  1188. (if (and starter (string-match "\\(.*?\\) ::[ \t]*" line))
  1189. (setq item-type "d"
  1190. item-tag (match-string 1 line)
  1191. line (substring line (match-end 0))))
  1192. (when (and (not (equal item-type "d"))
  1193. (not (string-match "[^ \t]" line)))
  1194. ;; empty line. Pretend indentation is large.
  1195. (setq ind (if org-empty-line-terminates-plain-lists
  1196. 0
  1197. (1+ (or (car local-list-indent) 1)))))
  1198. (setq didclose nil)
  1199. (while (and in-local-list
  1200. (or (and (= ind (car local-list-indent))
  1201. (not starter))
  1202. (< ind (car local-list-indent))))
  1203. (setq didclose t)
  1204. (org-close-li (car local-list-type))
  1205. (insert (format "</%sl>\n" (car local-list-type)))
  1206. (pop local-list-type) (pop local-list-indent)
  1207. (setq in-local-list local-list-indent))
  1208. (cond
  1209. ((and starter
  1210. (or (not in-local-list)
  1211. (> ind (car local-list-indent))))
  1212. ;; check for a specified start number
  1213. ;; Start new (level of) list
  1214. (org-close-par-maybe)
  1215. (insert (cond
  1216. ((equal item-type "u") "<ul>\n<li>\n")
  1217. ((equal item-type "o")
  1218. (if initial-number
  1219. (format "<ol start=%s>\n<li>\n" initial-number)
  1220. "<ol>\n<li>\n"))
  1221. ((equal item-type "d")
  1222. (format "<dl>\n<dt>%s</dt><dd>\n" item-tag))))
  1223. (push item-type local-list-type)
  1224. (push ind local-list-indent)
  1225. (setq in-local-list t))
  1226. (starter
  1227. ;; continue current list
  1228. (org-close-li (car local-list-type))
  1229. (insert (cond
  1230. ((equal (car local-list-type) "d")
  1231. (format "<dt>%s</dt><dd>\n" (or item-tag "???")))
  1232. (t "<li>\n"))))
  1233. (didclose
  1234. ;; we did close a list, normal text follows: need <p>
  1235. (org-open-par)))
  1236. (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line)
  1237. (setq line
  1238. (replace-match
  1239. (if (equal (match-string 1 line) "X")
  1240. "<b>[X]</b>"
  1241. "<b>[<span style=\"visibility:hidden;\">X</span>]</b>")
  1242. t t line))))
  1243. ;; Horizontal line
  1244. (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line)
  1245. (if org-par-open
  1246. (insert "\n</p>\n<hr/>\n<p>\n")
  1247. (insert "\n<hr/>\n"))
  1248. (throw 'nextline nil))
  1249. ;; Empty lines start a new paragraph. If hand-formatted lists
  1250. ;; are not fully interpreted, lines starting with "-", "+", "*"
  1251. ;; also start a new paragraph.
  1252. (if (string-match "^ [-+*]-\\|^[ \t]*$" line) (org-open-par))
  1253. ;; Is this the start of a footnote?
  1254. (when org-export-with-footnotes
  1255. (when (and (boundp 'footnote-section-tag-regexp)
  1256. (string-match (concat "^" footnote-section-tag-regexp)
  1257. line))
  1258. ;; ignore this line
  1259. (throw 'nextline nil))
  1260. (when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" line)
  1261. (org-close-par-maybe)
  1262. (let ((n (match-string 1 line)))
  1263. (setq org-par-open t
  1264. line (replace-match
  1265. (format
  1266. (concat "<p class=\"footnote\">"
  1267. (format org-export-html-footnote-format
  1268. "<a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a>"))
  1269. n n n) t t line)))))
  1270. ;; Check if the line break needs to be conserved
  1271. (cond
  1272. ((string-match "\\\\\\\\[ \t]*$" line)
  1273. (setq line (replace-match "<br/>" t t line)))
  1274. (org-export-preserve-breaks
  1275. (setq line (concat line "<br/>"))))
  1276. ;; Check if a paragraph should be started
  1277. (let ((start 0))
  1278. (while (and org-par-open
  1279. (string-match "\\\\par\\>" line start))
  1280. ;; Leave a space in the </p> so that the footnote matcher
  1281. ;; does not see this.
  1282. (if (not (get-text-property (match-beginning 0)
  1283. 'org-protected line))
  1284. (setq line (replace-match "</p ><p >" t t line)))
  1285. (setq start (match-end 0))))
  1286. (insert line "\n")))))
  1287. ;; Properly close all local lists and other lists
  1288. (when inquote
  1289. (insert "</pre>\n")
  1290. (org-open-par))
  1291. (when in-local-list
  1292. ;; Close any local lists before inserting a new header line
  1293. (while local-list-type
  1294. (org-close-li (car local-list-type))
  1295. (insert (format "</%sl>\n" (car local-list-type)))
  1296. (pop local-list-type))
  1297. (setq local-list-indent nil
  1298. in-local-list nil))
  1299. (org-html-level-start 1 nil umax
  1300. (and org-export-with-toc (<= level umax))
  1301. head-count)
  1302. ;; the </div> to close the last text-... div.
  1303. (when (and (> umax 0) first-heading-pos) (insert "</div>\n"))
  1304. (save-excursion
  1305. (goto-char (point-min))
  1306. (while (re-search-forward "<p class=\"footnote\">[^\000]*?\\(</p>\\|\\'\\)" nil t)
  1307. (push (match-string 0) footnotes)
  1308. (replace-match "" t t)))
  1309. (when footnotes
  1310. (insert (format org-export-html-footnotes-section
  1311. (nth 4 lang-words)
  1312. (mapconcat 'identity (nreverse footnotes) "\n"))
  1313. "\n"))
  1314. (let ((bib (org-export-html-get-bibliography)))
  1315. (when bib
  1316. (insert "\n" bib "\n")))
  1317. (unless body-only
  1318. (when (plist-get opt-plist :auto-postamble)
  1319. (insert "<div id=\"postamble\">\n")
  1320. (when (and org-export-author-info author)
  1321. (insert "<p class=\"author\"> "
  1322. (nth 1 lang-words) ": " author "\n")
  1323. (when (and org-export-email-info email (string-match "\\S-" email))
  1324. (if (listp (split-string email ",+ *"))
  1325. (mapc (lambda(e)
  1326. (insert "<a href=\"mailto:" e "\">&lt;"
  1327. e "&gt;</a>\n"))
  1328. (split-string email ",+ *"))
  1329. (insert "<a href=\"mailto:" email "\">&lt;"
  1330. email "&gt;</a>\n")))
  1331. (insert "</p>\n"))
  1332. (when (and date org-export-time-stamp-file)
  1333. (insert "<p class=\"date\"> "
  1334. (nth 2 lang-words) ": "
  1335. date "</p>\n"))
  1336. (when org-export-creator-info
  1337. (insert (format "<p class=\"creator\">HTML generated by org-mode %s in emacs %s</p>\n"
  1338. org-version emacs-major-version)))
  1339. (when org-export-html-validation-link
  1340. (insert org-export-html-validation-link "\n"))
  1341. (insert "</div>"))
  1342. (if org-export-html-with-timestamp
  1343. (insert org-export-html-html-helper-timestamp))
  1344. (org-export-html-insert-plist-item opt-plist :postamble opt-plist)
  1345. (insert "\n</div>\n</body>\n</html>\n"))
  1346. (unless (plist-get opt-plist :buffer-will-be-killed)
  1347. (normal-mode)
  1348. (if (eq major-mode (default-value 'major-mode))
  1349. (html-mode)))
  1350. ;; insert the table of contents
  1351. (goto-char (point-min))
  1352. (when thetoc
  1353. (if (or (re-search-forward
  1354. "<p>\\s-*\\[TABLE-OF-CONTENTS\\]\\s-*</p>" nil t)
  1355. (re-search-forward
  1356. "\\[TABLE-OF-CONTENTS\\]" nil t))
  1357. (progn
  1358. (goto-char (match-beginning 0))
  1359. (replace-match ""))
  1360. (goto-char first-heading-pos)
  1361. (when (looking-at "\\s-*</p>")
  1362. (goto-char (match-end 0))
  1363. (insert "\n")))
  1364. (insert "<div id=\"table-of-contents\">\n")
  1365. (mapc 'insert thetoc)
  1366. (insert "</div>\n"))
  1367. ;; remove empty paragraphs and lists
  1368. (goto-char (point-min))
  1369. (while (re-search-forward "<p>[ \r\n\t]*</p>" nil t)
  1370. (replace-match ""))
  1371. (goto-char (point-min))
  1372. (while (re-search-forward "<li>[ \r\n\t]*</li>\n?" nil t)
  1373. (replace-match ""))
  1374. (goto-char (point-min))
  1375. (while (re-search-forward "</ul>\\s-*<ul>\n?" nil t)
  1376. (replace-match ""))
  1377. ;; Convert whitespace place holders
  1378. (goto-char (point-min))
  1379. (let (beg end n)
  1380. (while (setq beg (next-single-property-change (point) 'org-whitespace))
  1381. (setq n (get-text-property beg 'org-whitespace)
  1382. end (next-single-property-change beg 'org-whitespace))
  1383. (goto-char beg)
  1384. (delete-region beg end)
  1385. (insert (format "<span style=\"visibility:hidden;\">%s</span>"
  1386. (make-string n ?x)))))
  1387. ;; Remove empty lines at the beginning of the file.
  1388. (goto-char (point-min))
  1389. (when (looking-at "\\s-+\n") (replace-match ""))
  1390. ;; Remove display properties
  1391. (remove-text-properties (point-min) (point-max) '(display t))
  1392. ;; Run the hook
  1393. (run-hooks 'org-export-html-final-hook)
  1394. (or to-buffer (save-buffer))
  1395. (goto-char (point-min))
  1396. (or (org-export-push-to-kill-ring "HTML")
  1397. (message "Exporting... done"))
  1398. (if (eq to-buffer 'string)
  1399. (prog1 (buffer-substring (point-min) (point-max))
  1400. (kill-buffer (current-buffer)))
  1401. (current-buffer)))))
  1402. (defun org-export-html-insert-plist-item (plist key &rest args)
  1403. (let ((item (plist-get plist key)))
  1404. (cond ((functionp item)
  1405. (apply item args))
  1406. (item
  1407. (insert item)))))
  1408. (defun org-export-html-format-href (s)
  1409. "Make sure the S is valid as a href reference in an XHTML document."
  1410. (save-match-data
  1411. (let ((start 0))
  1412. (while (string-match "&" s start)
  1413. (setq start (+ (match-beginning 0) 3)
  1414. s (replace-match "&amp;" t t s)))))
  1415. s)
  1416. (defun org-export-html-format-desc (s)
  1417. "Make sure the S is valid as a description in a link."
  1418. (if (and s (not (get-text-property 1 'org-protected s)))
  1419. (save-match-data
  1420. (org-html-do-expand s))
  1421. s))
  1422. (defun org-export-html-format-image (src par-open)
  1423. "Create image tag with source and attributes."
  1424. (save-match-data
  1425. (if (string-match "^ltxpng/" src)
  1426. (format "<img src=\"%s\" alt=\"%s\"/>"
  1427. src (org-find-text-property-in-string 'org-latex-src src))
  1428. (let* ((caption (org-find-text-property-in-string 'org-caption src))
  1429. (attr (org-find-text-property-in-string 'org-attributes src))
  1430. (label (org-find-text-property-in-string 'org-label src)))
  1431. (setq caption (and caption (org-html-do-expand caption)))
  1432. (concat
  1433. (if caption
  1434. (format "%s<div %sclass=\"figure\">
  1435. <p>"
  1436. (if org-par-open "</p>\n" "")
  1437. (if label (format "id=\"%s\" " label) "")))
  1438. (format "<img src=\"%s\"%s />"
  1439. src
  1440. (if (string-match "\\<alt=" (or attr ""))
  1441. (concat " " attr )
  1442. (concat " " attr " alt=\"" src "\"")))
  1443. (if caption
  1444. (format "</p>%s
  1445. </div>%s"
  1446. (concat "\n<p>" caption "</p>")
  1447. (if org-par-open "\n<p>" ""))))))))
  1448. (defun org-export-html-get-bibliography ()
  1449. "Find bibliography, cut it out and return it."
  1450. (catch 'exit
  1451. (let (beg end (cnt 1) bib)
  1452. (save-excursion
  1453. (goto-char (point-min))
  1454. (when (re-search-forward "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t)
  1455. (setq beg (match-beginning 0))
  1456. (while (re-search-forward "</?div\\>" nil t)
  1457. (setq cnt (+ cnt (if (string= (match-string 0) "<div") +1 -1)))
  1458. (when (= cnt 0)
  1459. (and (looking-at ">") (forward-char 1))
  1460. (setq bib (buffer-substring beg (point)))
  1461. (delete-region beg (point))
  1462. (throw 'exit bib))))
  1463. nil))))
  1464. (defvar org-table-number-regexp) ; defined in org-table.el
  1465. (defun org-format-table-html (lines olines)
  1466. "Find out which HTML converter to use and return the HTML code."
  1467. (if (stringp lines)
  1468. (setq lines (org-split-string lines "\n")))
  1469. (if (string-match "^[ \t]*|" (car lines))
  1470. ;; A normal org table
  1471. (org-format-org-table-html lines)
  1472. ;; Table made by table.el - test for spanning
  1473. (let* ((hlines (delq nil (mapcar
  1474. (lambda (x)
  1475. (if (string-match "^[ \t]*\\+-" x) x
  1476. nil))
  1477. lines)))
  1478. (first (car hlines))
  1479. (ll (and (string-match "\\S-+" first)
  1480. (match-string 0 first)))
  1481. (re (concat "^[ \t]*" (regexp-quote ll)))
  1482. (spanning (delq nil (mapcar (lambda (x) (not (string-match re x)))
  1483. hlines))))
  1484. (if (and (not spanning)
  1485. (not org-export-prefer-native-exporter-for-tables))
  1486. ;; We can use my own converter with HTML conversions
  1487. (org-format-table-table-html lines)
  1488. ;; Need to use the code generator in table.el, with the original text.
  1489. (org-format-table-table-html-using-table-generate-source olines)))))
  1490. (defvar org-table-number-fraction) ; defined in org-table.el
  1491. (defun org-format-org-table-html (lines &optional splice)
  1492. "Format a table into HTML."
  1493. (require 'org-table)
  1494. ;; Get rid of hlines at beginning and end
  1495. (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
  1496. (setq lines (nreverse lines))
  1497. (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
  1498. (setq lines (nreverse lines))
  1499. (when org-export-table-remove-special-lines
  1500. ;; Check if the table has a marking column. If yes remove the
  1501. ;; column and the special lines
  1502. (setq lines (org-table-clean-before-export lines)))
  1503. (let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
  1504. (label (org-find-text-property-in-string 'org-label (car lines)))
  1505. (attributes (org-find-text-property-in-string 'org-attributes
  1506. (car lines)))
  1507. (html-table-tag (org-export-splice-attributes
  1508. html-table-tag attributes))
  1509. (head (and org-export-highlight-first-table-line
  1510. (delq nil (mapcar
  1511. (lambda (x) (string-match "^[ \t]*|-" x))
  1512. (cdr lines)))))
  1513. (nline 0) fnum nfields i
  1514. tbopen line fields html gr colgropen rowstart rowend)
  1515. (setq caption (and caption (org-html-do-expand caption)))
  1516. (if splice (setq head nil))
  1517. (unless splice (push (if head "<thead>" "<tbody>") html))
  1518. (setq tbopen t)
  1519. (while (setq line (pop lines))
  1520. (catch 'next-line
  1521. (if (string-match "^[ \t]*|-" line)
  1522. (progn
  1523. (unless splice
  1524. (push (if head "</thead>" "</tbody>") html)
  1525. (if lines (push "<tbody>" html) (setq tbopen nil)))
  1526. (setq head nil) ;; head ends here, first time around
  1527. ;; ignore this line
  1528. (throw 'next-line t)))
  1529. ;; Break the line into fields
  1530. (setq fields (org-split-string line "[ \t]*|[ \t]*"))
  1531. (unless fnum (setq fnum (make-vector (length fields) 0)
  1532. nfields (length fnum)))
  1533. (setq nline (1+ nline) i -1
  1534. rowstart (eval (car org-export-table-row-tags))
  1535. rowend (eval (cdr org-export-table-row-tags)))
  1536. (push (concat rowstart
  1537. (mapconcat
  1538. (lambda (x)
  1539. (setq i (1+ i))
  1540. (if (and (< i nfields) ; make sure no rogue line causes an error here
  1541. (string-match org-table-number-regexp x))
  1542. (incf (aref fnum i)))
  1543. (cond
  1544. (head
  1545. (concat
  1546. (format (car org-export-table-header-tags) "col")
  1547. x
  1548. (cdr org-export-table-header-tags)))
  1549. ((and (= i 0) org-export-html-table-use-header-tags-for-first-column)
  1550. (concat
  1551. (format (car org-export-table-header-tags) "row")
  1552. x
  1553. (cdr org-export-table-header-tags)))
  1554. (t
  1555. (concat (car org-export-table-data-tags) x
  1556. (cdr org-export-table-data-tags)))))
  1557. fields "")
  1558. rowend)
  1559. html)))
  1560. (unless splice (if tbopen (push "</tbody>" html)))
  1561. (unless splice (push "</table>\n" html))
  1562. (setq html (nreverse html))
  1563. (unless splice
  1564. ;; Put in col tags with the alignment (unfortunately often ignored...)
  1565. (unless (car org-table-colgroup-info)
  1566. (setq org-table-colgroup-info
  1567. (cons :start (cdr org-table-colgroup-info))))
  1568. (push (mapconcat
  1569. (lambda (x)
  1570. (setq gr (pop org-table-colgroup-info))
  1571. (format "%s<col align=\"%s\" />%s"
  1572. (if (memq gr '(:start :startend))
  1573. (prog1
  1574. (if colgropen "</colgroup>\n<colgroup>" "<colgroup>")
  1575. (setq colgropen t))
  1576. "")
  1577. (if (> (/ (float x) nline) org-table-number-fraction)
  1578. "right" "left")
  1579. (if (memq gr '(:end :startend))
  1580. (progn (setq colgropen nil) "</colgroup>")
  1581. "")))
  1582. fnum "")
  1583. html)
  1584. (if colgropen (setq html (cons (car html) (cons "</colgroup>" (cdr html)))))
  1585. ;; Since the output of HTML table formatter can also be used in
  1586. ;; DocBook document, we want to always include the caption to make
  1587. ;; DocBook XML file valid.
  1588. (push (format "<caption>%s</caption>" (or caption "")) html)
  1589. (when label (push (format "<a name=\"%s\" id=\"%s\"></a>" label label)
  1590. html))
  1591. (push html-table-tag html))
  1592. (concat (mapconcat 'identity html "\n") "\n")))
  1593. (defun org-export-splice-attributes (tag attributes)
  1594. "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
  1595. (if (not attributes)
  1596. tag
  1597. (let (oldatt newatt)
  1598. (setq oldatt (org-extract-attributes-from-string tag)
  1599. tag (pop oldatt)
  1600. newatt (cdr (org-extract-attributes-from-string attributes)))
  1601. (while newatt
  1602. (setq oldatt (plist-put oldatt (pop newatt) (pop newatt))))
  1603. (if (string-match ">" tag)
  1604. (setq tag
  1605. (replace-match (concat (org-attributes-to-string oldatt) ">")
  1606. t t tag)))
  1607. tag)))
  1608. (defun org-format-table-table-html (lines)
  1609. "Format a table generated by table.el into HTML.
  1610. This conversion does *not* use `table-generate-source' from table.el.
  1611. This has the advantage that Org-mode's HTML conversions can be used.
  1612. But it has the disadvantage, that no cell- or row-spanning is allowed."
  1613. (let (line field-buffer
  1614. (head org-export-highlight-first-table-line)
  1615. fields html empty i)
  1616. (setq html (concat html-table-tag "\n"))
  1617. (while (setq line (pop lines))
  1618. (setq empty "&nbsp;")
  1619. (catch 'next-line
  1620. (if (string-match "^[ \t]*\\+-" line)
  1621. (progn
  1622. (if field-buffer
  1623. (progn
  1624. (setq
  1625. html
  1626. (concat
  1627. html
  1628. "<tr>"
  1629. (mapconcat
  1630. (lambda (x)
  1631. (if (equal x "") (setq x empty))
  1632. (if head
  1633. (concat
  1634. (format (car org-export-table-header-tags) "col")
  1635. x
  1636. (cdr org-export-table-header-tags))
  1637. (concat (car org-export-table-data-tags) x
  1638. (cdr org-export-table-data-tags))))
  1639. field-buffer "\n")
  1640. "</tr>\n"))
  1641. (setq head nil)
  1642. (setq field-buffer nil)))
  1643. ;; Ignore this line
  1644. (throw 'next-line t)))
  1645. ;; Break the line into fields and store the fields
  1646. (setq fields (org-split-string line "[ \t]*|[ \t]*"))
  1647. (if field-buffer
  1648. (setq field-buffer (mapcar
  1649. (lambda (x)
  1650. (concat x "<br/>" (pop fields)))
  1651. field-buffer))
  1652. (setq field-buffer fields))))
  1653. (setq html (concat html "</table>\n"))
  1654. html))
  1655. (defun org-format-table-table-html-using-table-generate-source (lines)
  1656. "Format a table into html, using `table-generate-source' from table.el.
  1657. This has the advantage that cell- or row-spanning is allowed.
  1658. But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
  1659. (require 'table)
  1660. (with-current-buffer (get-buffer-create " org-tmp1 ")
  1661. (erase-buffer)
  1662. (insert (mapconcat 'identity lines "\n"))
  1663. (goto-char (point-min))
  1664. (if (not (re-search-forward "|[^+]" nil t))
  1665. (error "Error processing table"))
  1666. (table-recognize-table)
  1667. (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
  1668. (table-generate-source 'html " org-tmp2 ")
  1669. (set-buffer " org-tmp2 ")
  1670. (buffer-substring (point-min) (point-max))))
  1671. (defun org-export-splice-style (style extra)
  1672. "Splice EXTRA into STYLE, just before \"</style>\"."
  1673. (if (and (stringp extra)
  1674. (string-match "\\S-" extra)
  1675. (string-match "</style>" style))
  1676. (concat (substring style 0 (match-beginning 0))
  1677. "\n" extra "\n"
  1678. (substring style (match-beginning 0)))
  1679. style))
  1680. (defun org-html-handle-time-stamps (s)
  1681. "Format time stamps in string S, or remove them."
  1682. (catch 'exit
  1683. (let (r b)
  1684. (while (string-match org-maybe-keyword-time-regexp s)
  1685. (or b (setq b (substring s 0 (match-beginning 0))))
  1686. (setq r (concat
  1687. r (substring s 0 (match-beginning 0))
  1688. " @<span class=\"timestamp-wrapper\">"
  1689. (if (match-end 1)
  1690. (format "@<span class=\"timestamp-kwd\">%s @</span>"
  1691. (match-string 1 s)))
  1692. (format " @<span class=\"timestamp\">%s@</span>"
  1693. (substring
  1694. (org-translate-time (match-string 3 s)) 1 -1))
  1695. "@</span>")
  1696. s (substring s (match-end 0))))
  1697. ;; Line break if line started and ended with time stamp stuff
  1698. (if (not r)
  1699. s
  1700. (setq r (concat r s))
  1701. (unless (string-match "\\S-" (concat b s))
  1702. (setq r (concat r "@<br/>")))
  1703. r))))
  1704. (defvar htmlize-buffer-places) ; from htmlize.el
  1705. (defun org-export-htmlize-region-for-paste (beg end)
  1706. "Convert the region to HTML, using htmlize.el.
  1707. This is much like `htmlize-region-for-paste', only that it uses
  1708. the settings define in the org-... variables."
  1709. (let* ((htmlize-output-type org-export-htmlize-output-type)
  1710. (htmlize-css-name-prefix org-export-htmlize-css-font-prefix)
  1711. (htmlbuf (htmlize-region beg end)))
  1712. (unwind-protect
  1713. (with-current-buffer htmlbuf
  1714. (buffer-substring (plist-get htmlize-buffer-places 'content-start)
  1715. (plist-get htmlize-buffer-places 'content-end)))
  1716. (kill-buffer htmlbuf))))
  1717. ;;;###autoload
  1718. (defun org-export-htmlize-generate-css ()
  1719. "Create the CSS for all font definitions in the current Emacs session.
  1720. Use this to create face definitions in your CSS style file that can then
  1721. be used by code snippets transformed by htmlize.
  1722. This command just produces a buffer that contains class definitions for all
  1723. faces used in the current Emacs session. You can copy and paste the ones you
  1724. need into your CSS file.
  1725. If you then set `org-export-htmlize-output-type' to `css', calls to
  1726. the function `org-export-htmlize-region-for-paste' will produce code
  1727. that uses these same face definitions."
  1728. (interactive)
  1729. (require 'htmlize)
  1730. (and (get-buffer "*html*") (kill-buffer "*html*"))
  1731. (with-temp-buffer
  1732. (let ((fl (face-list))
  1733. (htmlize-css-name-prefix "org-")
  1734. (htmlize-output-type 'css)
  1735. f i)
  1736. (while (setq f (pop fl)
  1737. i (and f (face-attribute f :inherit)))
  1738. (when (and (symbolp f) (or (not i) (not (listp i))))
  1739. (insert (org-add-props (copy-sequence "1") nil 'face f))))
  1740. (htmlize-region (point-min) (point-max))))
  1741. (switch-to-buffer "*html*")
  1742. (goto-char (point-min))
  1743. (if (re-search-forward "<style" nil t)
  1744. (delete-region (point-min) (match-beginning 0)))
  1745. (if (re-search-forward "</style>" nil t)
  1746. (delete-region (1+ (match-end 0)) (point-max)))
  1747. (beginning-of-line 1)
  1748. (if (looking-at " +") (replace-match ""))
  1749. (goto-char (point-min)))
  1750. (defun org-html-protect (s)
  1751. ;; convert & to &amp;, < to &lt; and > to &gt;
  1752. (let ((start 0))
  1753. (while (string-match "&" s start)
  1754. (setq s (replace-match "&amp;" t t s)
  1755. start (1+ (match-beginning 0))))
  1756. (while (string-match "<" s)
  1757. (setq s (replace-match "&lt;" t t s)))
  1758. (while (string-match ">" s)
  1759. (setq s (replace-match "&gt;" t t s)))
  1760. ; (while (string-match "\"" s)
  1761. ; (setq s (replace-match "&quot;" t t s)))
  1762. )
  1763. s)
  1764. (defun org-html-expand (string)
  1765. "Prepare STRING for HTML export. Applies all active conversions.
  1766. If there are links in the string, don't modify these."
  1767. (let* ((re (concat org-bracket-link-regexp "\\|"
  1768. (org-re "[ \t]+\\(:[[:alnum:]_@:]+:\\)[ \t]*$")))
  1769. m s l res)
  1770. (if (string-match "^[ \t]*\\+-[-+]*\\+[ \t]*$" string)
  1771. string
  1772. (while (setq m (string-match re string))
  1773. (setq s (substring string 0 m)
  1774. l (match-string 0 string)
  1775. string (substring string (match-end 0)))
  1776. (push (org-html-do-expand s) res)
  1777. (push l res))
  1778. (push (org-html-do-expand string) res)
  1779. (apply 'concat (nreverse res)))))
  1780. (defun org-html-do-expand (s)
  1781. "Apply all active conversions to translate special ASCII to HTML."
  1782. (setq s (org-html-protect s))
  1783. (if org-export-html-expand
  1784. (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
  1785. (setq s (replace-match "<\\1>" t nil s))))
  1786. (if org-export-with-emphasize
  1787. (setq s (org-export-html-convert-emphasize s)))
  1788. (if org-export-with-special-strings
  1789. (setq s (org-export-html-convert-special-strings s)))
  1790. (if org-export-with-sub-superscripts
  1791. (setq s (org-export-html-convert-sub-super s)))
  1792. (if org-export-with-TeX-macros
  1793. (let ((start 0) wd rep)
  1794. (while (setq start (string-match "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?"
  1795. s start))
  1796. (if (get-text-property (match-beginning 0) 'org-protected s)
  1797. (setq start (match-end 0))
  1798. (setq wd (match-string 1 s))
  1799. (if (setq rep (org-entity-get-representation wd 'html))
  1800. (setq s (replace-match rep t t s))
  1801. (setq start (+ start (length wd))))))))
  1802. s)
  1803. (defun org-export-html-convert-special-strings (string)
  1804. "Convert special characters in STRING to HTML."
  1805. (let ((all org-export-html-special-string-regexps)
  1806. e a re rpl start)
  1807. (while (setq a (pop all))
  1808. (setq re (car a) rpl (cdr a) start 0)
  1809. (while (string-match re string start)
  1810. (if (get-text-property (match-beginning 0) 'org-protected string)
  1811. (setq start (match-end 0))
  1812. (setq string (replace-match rpl t nil string)))))
  1813. string))
  1814. (defun org-export-html-convert-sub-super (string)
  1815. "Convert sub- and superscripts in STRING to HTML."
  1816. (let (key c (s 0) (requireb (eq org-export-with-sub-superscripts '{})))
  1817. (while (string-match org-match-substring-regexp string s)
  1818. (cond
  1819. ((and requireb (match-end 8)) (setq s (match-end 2)))
  1820. ((get-text-property (match-beginning 2) 'org-protected string)
  1821. (setq s (match-end 2)))
  1822. (t
  1823. (setq s (match-end 1)
  1824. key (if (string= (match-string 2 string) "_") "sub" "sup")
  1825. c (or (match-string 8 string)
  1826. (match-string 6 string)
  1827. (match-string 5 string))
  1828. string (replace-match
  1829. (concat (match-string 1 string)
  1830. "<" key ">" c "</" key ">")
  1831. t t string)))))
  1832. (while (string-match "\\\\\\([_^]\\)" string)
  1833. (setq string (replace-match (match-string 1 string) t t string)))
  1834. string))
  1835. (defun org-export-html-convert-emphasize (string)
  1836. "Apply emphasis."
  1837. (let ((s 0) rpl)
  1838. (while (string-match org-emph-re string s)
  1839. (if (not (equal
  1840. (substring string (match-beginning 3) (1+ (match-beginning 3)))
  1841. (substring string (match-beginning 4) (1+ (match-beginning 4)))))
  1842. (setq s (match-beginning 0)
  1843. rpl
  1844. (concat
  1845. (match-string 1 string)
  1846. (nth 2 (assoc (match-string 3 string) org-emphasis-alist))
  1847. (match-string 4 string)
  1848. (nth 3 (assoc (match-string 3 string)
  1849. org-emphasis-alist))
  1850. (match-string 5 string))
  1851. string (replace-match rpl t t string)
  1852. s (+ s (- (length rpl) 2)))
  1853. (setq s (1+ s))))
  1854. string))
  1855. (defun org-open-par ()
  1856. "Insert <p>, but first close previous paragraph if any."
  1857. (org-close-par-maybe)
  1858. (insert "\n<p>")
  1859. (setq org-par-open t))
  1860. (defun org-close-par-maybe ()
  1861. "Close paragraph if there is one open."
  1862. (when org-par-open
  1863. (insert "</p>")
  1864. (setq org-par-open nil)))
  1865. (defun org-close-li (&optional type)
  1866. "Close <li> if necessary."
  1867. (org-close-par-maybe)
  1868. (insert (if (equal type "d") "</dd>\n" "</li>\n")))
  1869. (defvar in-local-list)
  1870. (defvar local-list-indent)
  1871. (defvar local-list-type)
  1872. (defun org-export-html-close-lists-maybe (line)
  1873. (let* ((rawhtml (and in-local-list
  1874. (get-text-property 0 'org-protected line)))
  1875. (ind (if rawhtml
  1876. (org-get-indentation line)
  1877. (or (get-text-property 0 'original-indentation line))))
  1878. didclose)
  1879. (when ind
  1880. (while (and in-local-list
  1881. (<= ind (car local-list-indent)))
  1882. (setq didclose t)
  1883. (org-close-li (car local-list-type))
  1884. (insert (format "</%sl>\n" (car local-list-type)))
  1885. (pop local-list-type) (pop local-list-indent)
  1886. (setq in-local-list local-list-indent))
  1887. (and didclose (org-open-par)))))
  1888. (defvar body-only) ; dynamically scoped into this.
  1889. (defun org-html-level-start (level title umax with-toc head-count)
  1890. "Insert a new level in HTML export.
  1891. When TITLE is nil, just close all open levels."
  1892. (org-close-par-maybe)
  1893. (let* ((target (and title (org-get-text-property-any 0 'target title)))
  1894. (extra-targets (and target
  1895. (assoc target org-export-target-aliases)))
  1896. (extra-class (and title (org-get-text-property-any 0 'html-container-class title)))
  1897. (preferred (and target
  1898. (cdr (assoc target org-export-preferred-target-alist))))
  1899. (remove (or preferred target))
  1900. (l org-level-max)
  1901. snumber snu href suffix)
  1902. (setq extra-targets (remove remove extra-targets))
  1903. (setq extra-targets
  1904. (mapconcat (lambda (x)
  1905. (if (org-uuidgen-p x) (setq x (concat "ID-" x)))
  1906. (format "<a name=\"%s\" id=\"%s\"></a>"
  1907. x x))
  1908. extra-targets
  1909. ""))
  1910. (while (>= l level)
  1911. (if (aref org-levels-open (1- l))
  1912. (progn
  1913. (org-html-level-close l umax)
  1914. (aset org-levels-open (1- l) nil)))
  1915. (setq l (1- l)))
  1916. (when title
  1917. ;; If title is nil, this means this function is called to close
  1918. ;; all levels, so the rest is done only if title is given
  1919. (when (string-match (org-re "\\(:[[:alnum:]_@:]+:\\)[ \t]*$") title)
  1920. (setq title (replace-match
  1921. (if org-export-with-tags
  1922. (save-match-data
  1923. (concat
  1924. "&nbsp;&nbsp;&nbsp;<span class=\"tag\">"
  1925. (mapconcat
  1926. (lambda (x)
  1927. (format "<span class=\"%s\">%s</span>"
  1928. (org-export-html-get-tag-class-name x)
  1929. x))
  1930. (org-split-string (match-string 1 title) ":")
  1931. "&nbsp;")
  1932. "</span>"))
  1933. "")
  1934. t t title)))
  1935. (if (> level umax)
  1936. (progn
  1937. (if (aref org-levels-open (1- level))
  1938. (progn
  1939. (org-close-li)
  1940. (if target
  1941. (insert (format "<li id=\"%s\">" target) extra-targets title "<br/>\n")
  1942. (insert "<li>" title "<br/>\n")))
  1943. (aset org-levels-open (1- level) t)
  1944. (org-close-par-maybe)
  1945. (if target
  1946. (insert (format "<ul>\n<li id=\"%s\">" target)
  1947. extra-targets title "<br/>\n")
  1948. (insert "<ul>\n<li>" title "<br/>\n"))))
  1949. (aset org-levels-open (1- level) t)
  1950. (setq snumber (org-section-number level)
  1951. snu (replace-regexp-in-string "\\." "_" snumber))
  1952. (setq level (+ level org-export-html-toplevel-hlevel -1))
  1953. (if (and org-export-with-section-numbers (not body-only))
  1954. (setq title (concat
  1955. (format "<span class=\"section-number-%d\">%s</span>"
  1956. level snumber)
  1957. " " title)))
  1958. (unless (= head-count 1) (insert "\n</div>\n"))
  1959. (setq href (cdr (assoc (concat "sec-" snu) org-export-preferred-target-alist)))
  1960. (setq suffix (or href snu))
  1961. (setq href (or href (concat "sec-" snu)))
  1962. (insert (format "\n<div id=\"outline-container-%s\" class=\"outline-%d%s\">\n<h%d id=\"%s\">%s%s</h%d>\n<div class=\"outline-text-%d\" id=\"text-%s\">\n"
  1963. suffix level (if extra-class (concat " " extra-class) "")
  1964. level href
  1965. extra-targets
  1966. title level level suffix))
  1967. (org-open-par)))))
  1968. (defun org-export-html-get-tag-class-name (tag)
  1969. "Turn tag into a valid class name.
  1970. Replaces invalid characters with \"_\" and then prepends a prefix."
  1971. (save-match-data
  1972. (while (string-match "[^a-zA-Z0-9_]" tag)
  1973. (setq tag (replace-match "_" t t tag))))
  1974. (concat org-export-html-tag-class-prefix tag))
  1975. (defun org-export-html-get-todo-kwd-class-name (kwd)
  1976. "Turn todo keyword into a valid class name.
  1977. Replaces invalid characters with \"_\" and then prepends a prefix."
  1978. (save-match-data
  1979. (while (string-match "[^a-zA-Z0-9_]" kwd)
  1980. (setq kwd (replace-match "_" t t kwd))))
  1981. (concat org-export-html-todo-kwd-class-prefix kwd))
  1982. (defun org-html-level-close (level max-outline-level)
  1983. "Terminate one level in HTML export."
  1984. (if (<= level max-outline-level)
  1985. (insert "</div>\n")
  1986. (org-close-li)
  1987. (insert "</ul>\n")))
  1988. (provide 'org-html)
  1989. ;; arch-tag: 8109d84d-eb8f-460b-b1a8-f45f3a6c7ea1
  1990. ;;; org-html.el ends here