Fix bug when exporing inactive timestamps.
[org-mode/org-mode-NeilSmithlineMods.git] / lisp / org-html.el
blob2f0377b7cf661d50570a29139c0351aa32c34d8f
1 ;;; org-html.el --- HTML export for Org-mode
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
6 ;; Author: Carsten Dominik <carsten at orgmode dot org>
7 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; Homepage: http://orgmode.org
9 ;; Version: 7.4
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ;;; Commentary:
29 ;;; Code:
31 (require 'org-exp)
33 (eval-when-compile (require 'cl))
35 (declare-function org-id-find-id-file "org-id" (id))
36 (declare-function htmlize-region "ext:htmlize" (beg end))
38 (defgroup org-export-html nil
39 "Options specific for HTML export of Org-mode files."
40 :tag "Org Export HTML"
41 :group 'org-export)
43 (defcustom org-export-html-footnotes-section "<div id=\"footnotes\">
44 <h2 class=\"footnotes\">%s: </h2>
45 <div id=\"text-footnotes\">
47 </div>
48 </div>"
49 "Format for the footnotes section.
50 Should contain a two instances of %s. The first will be replaced with the
51 language-specific word for \"Footnotes\", the second one will be replaced
52 by the footnotes themselves."
53 :group 'org-export-html
54 :type 'string)
56 (defcustom org-export-html-footnote-format "<sup>%s</sup>"
57 "The format for the footnote reference.
58 %s will be replaced by the footnote reference itself."
59 :group 'org-export-html
60 :type 'string)
62 (defcustom org-export-html-coding-system nil
63 "Coding system for HTML export, defaults to `buffer-file-coding-system'."
64 :group 'org-export-html
65 :type 'coding-system)
67 (defcustom org-export-html-extension "html"
68 "The extension for exported HTML files."
69 :group 'org-export-html
70 :type 'string)
72 (defcustom org-export-html-xml-declaration
73 '(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
74 ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
75 "The extension for exported HTML files.
76 %s will be replaced with the charset of the exported file.
77 This may be a string, or an alist with export extensions
78 and corresponding declarations."
79 :group 'org-export-html
80 :type '(choice
81 (string :tag "Single declaration")
82 (repeat :tag "Dependent on extension"
83 (cons (string :tag "Extension")
84 (string :tag "Declaration")))))
86 (defcustom org-export-html-style-include-scripts t
87 "Non-nil means include the JavaScript snippets in exported HTML files.
88 The actual script is defined in `org-export-html-scripts' and should
89 not be modified."
90 :group 'org-export-html
91 :type 'boolean)
93 (defconst org-export-html-scripts
94 "<script type=\"text/javascript\">
95 <!--/*--><![CDATA[/*><!--*/
96 function CodeHighlightOn(elem, id)
98 var target = document.getElementById(id);
99 if(null != target) {
100 elem.cacheClassElem = elem.className;
101 elem.cacheClassTarget = target.className;
102 target.className = \"code-highlighted\";
103 elem.className = \"code-highlighted\";
106 function CodeHighlightOff(elem, id)
108 var target = document.getElementById(id);
109 if(elem.cacheClassElem)
110 elem.className = elem.cacheClassElem;
111 if(elem.cacheClassTarget)
112 target.className = elem.cacheClassTarget;
114 /*]]>*///-->
115 </script>"
116 "Basic JavaScript that is needed by HTML files produced by Org-mode.")
118 (defconst org-export-html-style-default
119 "<style type=\"text/css\">
120 <!--/*--><![CDATA[/*><!--*/
121 html { font-family: Times, serif; font-size: 12pt; }
122 .title { text-align: center; }
123 .todo { color: red; }
124 .done { color: green; }
125 .tag { background-color: #add8e6; font-weight:normal }
126 .target { }
127 .timestamp { color: #bebebe; }
128 .timestamp-kwd { color: #5f9ea0; }
129 .right {margin-left:auto; margin-right:0px; text-align:right;}
130 .left {margin-left:0px; margin-right:auto; text-align:left;}
131 .center {margin-left:auto; margin-right:auto; text-align:center;}
132 p.verse { margin-left: 3% }
133 pre {
134 border: 1pt solid #AEBDCC;
135 background-color: #F3F5F7;
136 padding: 5pt;
137 font-family: courier, monospace;
138 font-size: 90%;
139 overflow:auto;
141 table { border-collapse: collapse; }
142 td, th { vertical-align: top; }
143 th.right { text-align:center; }
144 th.left { text-align:center; }
145 th.center { text-align:center; }
146 td.right { text-align:right; }
147 td.left { text-align:left; }
148 td.center { text-align:center; }
149 dt { font-weight: bold; }
150 div.figure { padding: 0.5em; }
151 div.figure p { text-align: center; }
152 textarea { overflow-x: auto; }
153 .linenr { font-size:smaller }
154 .code-highlighted {background-color:#ffff00;}
155 .org-info-js_info-navigation { border-style:none; }
156 #org-info-js_console-label { font-size:10px; font-weight:bold;
157 white-space:nowrap; }
158 .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
159 font-weight:bold; }
160 /*]]>*/-->
161 </style>"
162 "The default style specification for exported HTML files.
163 Please use the variables `org-export-html-style' and
164 `org-export-html-style-extra' to add to this style. If you wish to not
165 have the default style included, customize the variable
166 `org-export-html-style-include-default'.")
168 (defcustom org-export-html-style-include-default t
169 "Non-nil means include the default style in exported HTML files.
170 The actual style is defined in `org-export-html-style-default' and should
171 not be modified. Use the variables `org-export-html-style' to add
172 your own style information."
173 :group 'org-export-html
174 :type 'boolean)
175 ;;;###autoload
176 (put 'org-export-html-style-include-default 'safe-local-variable 'booleanp)
178 (defcustom org-export-html-style ""
179 "Org-wide style definitions for exported HTML files.
181 This variable needs to contain the full HTML structure to provide a style,
182 including the surrounding HTML tags. If you set the value of this variable,
183 you should consider to include definitions for the following classes:
184 title, todo, done, timestamp, timestamp-kwd, tag, target.
186 For example, a valid value would be:
188 <style type=\"text/css\">
189 <![CDATA[
190 p { font-weight: normal; color: gray; }
191 h1 { color: black; }
192 .title { text-align: center; }
193 .todo, .timestamp-kwd { color: red; }
194 .done { color: green; }
196 </style>
198 If you'd like to refer to en external style file, use something like
200 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
202 As the value of this option simply gets inserted into the HTML <head> header,
203 you can \"misuse\" it to add arbitrary text to the header.
204 See also the variable `org-export-html-style-extra'."
205 :group 'org-export-html
206 :type 'string)
207 ;;;###autoload
208 (put 'org-export-html-style 'safe-local-variable 'stringp)
210 (defcustom org-export-html-style-extra ""
211 "Additional style information for HTML export.
212 The value of this variable is inserted into the HTML buffer right after
213 the value of `org-export-html-style'. Use this variable for per-file
214 settings of style information, and do not forget to surround the style
215 settings with <style>...</style> tags."
216 :group 'org-export-html
217 :type 'string)
218 ;;;###autoload
219 (put 'org-export-html-style-extra 'safe-local-variable 'stringp)
221 (defcustom org-export-html-mathjax-options
222 '((path "http://orgmode.org/mathjax/MathJax.js")
223 (scale "100")
224 (align "center")
225 (indent "2em")
226 (mathml nil))
227 "Options for MathJax setup.
229 path The path where to find MathJax
230 scale Scaling for the HTML-CSS backend, usually between 100 and 133
231 align How to align display math: left, center, or right
232 indent If align is not center, how far from the left/right side?
233 mathml Should a MathML player be used if available?
234 This is faster and reduces bandwidth use, but currently
235 sometimes has lower spacing quality. Therefore, the default is
236 nil. When browsers get better, this switch can be flipped.
238 You can also customize this for each buffer, using something like
240 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
241 :group 'org-export-html
242 :type '(list :greedy t
243 (list :tag "path (the path from where to load MathJax.js)"
244 (const :format " " path) (string))
245 (list :tag "scale (scaling for the displayed math)"
246 (const :format " " scale) (string))
247 (list :tag "align (alignment of displayed equations)"
248 (const :format " " align) (string))
249 (list :tag "indent (indentation with left or right alignment)"
250 (const :format " " indent) (string))
251 (list :tag "mathml (should MathML display be used is possible)"
252 (const :format " " mathml) (boolean))))
254 (defun org-export-html-mathjax-config (template options in-buffer)
255 "Insert the user setup into the matchjax template."
256 (let (name val (yes " ") (no "// ") x)
257 (mapc
258 (lambda (e)
259 (setq name (car e) val (nth 1 e))
260 (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
261 (setq val (car (read-from-string
262 (substring in-buffer (match-end 0))))))
263 (if (not (stringp val)) (setq val (format "%s" val)))
264 (if (string-match (concat "%" (upcase (symbol-name name))) template)
265 (setq template (replace-match val t t template))))
266 options)
267 (setq val (nth 1 (assq 'mathml options)))
268 (if (string-match (concat "\\<mathml:") in-buffer)
269 (setq val (car (read-from-string
270 (substring in-buffer (match-end 0))))))
271 ;; Exchange prefixes depending on mathml setting
272 (if (not val) (setq x yes yes no no x))
273 ;; Replace cookies to turn on or off the config/jax lines
274 (if (string-match ":MMLYES:" template)
275 (setq template (replace-match yes t t template)))
276 (if (string-match ":MMLNO:" template)
277 (setq template (replace-match no t t template)))
278 ;; Return the modified template
279 template))
281 (defcustom org-export-html-mathjax-template
282 "<script type=\"text/javascript\" src=\"%PATH\">
283 <!--/*--><![CDATA[/*><!--*/
284 MathJax.Hub.Config({
285 // Only one of the two following lines, depending on user settings
286 // First allows browser-native MathML display, second forces HTML/CSS
287 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
288 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
289 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
290 \"TeX/noUndefined.js\"],
291 tex2jax: {
292 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
293 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
294 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
295 ignoreClass: \"tex2jax_ignore\",
296 processEscapes: false,
297 processEnvironments: true,
298 preview: \"TeX\"
300 showProcessingMessages: true,
301 displayAlign: \"%ALIGN\",
302 displayIndent: \"%INDENT\",
304 \"HTML-CSS\": {
305 scale: %SCALE,
306 availableFonts: [\"STIX\",\"TeX\"],
307 preferredFont: \"TeX\",
308 webFont: \"TeX\",
309 imageFont: \"TeX\",
310 showMathMenu: true,
312 MMLorHTML: {
313 prefer: {
314 MSIE: \"MML\",
315 Firefox: \"MML\",
316 Opera: \"HTML\",
317 other: \"HTML\"
321 /*]]>*///-->
322 </script>"
323 "The MathJax setup for XHTML files."
324 :group 'org-export-html
325 :type 'string)
327 (defcustom org-export-html-tag-class-prefix ""
328 "Prefix to class names for TODO keywords.
329 Each tag gets a class given by the tag itself, with this prefix.
330 The default prefix is empty because it is nice to just use the keyword
331 as a class name. But if you get into conflicts with other, existing
332 CSS classes, then this prefix can be very useful."
333 :group 'org-export-html
334 :type 'string)
336 (defcustom org-export-html-todo-kwd-class-prefix ""
337 "Prefix to class names for TODO keywords.
338 Each TODO keyword gets a class given by the keyword itself, with this prefix.
339 The default prefix is empty because it is nice to just use the keyword
340 as a class name. But if you get into conflicts with other, existing
341 CSS classes, then this prefix can be very useful."
342 :group 'org-export-html
343 :type 'string)
345 (defcustom org-export-html-title-format "<h1 class=\"title\">%s</h1>\n"
346 "Format for typesetting the document title in HTML export."
347 :group 'org-export-html
348 :type 'string)
350 (defcustom org-export-html-home/up-format
351 "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
352 <a accesskey=\"h\" href=\"%s\"> UP </a>
354 <a accesskey=\"H\" href=\"%s\"> HOME </a>
355 </div>"
356 "Snippet used to insert the HOME and UP links.
357 This is a format string, the first %s will receive the UP link,
358 the second the HOME link. If both `org-export-html-link-up' and
359 `org-export-html-link-home' are empty, the entire snippet will be
360 ignored."
361 :group 'org-export-html
362 :type 'string)
364 (defcustom org-export-html-toplevel-hlevel 2
365 "The <H> level for level 1 headings in HTML export.
366 This is also important for the classes that will be wrapped around headlines
367 and outline structure. If this variable is 1, the top-level headlines will
368 be <h1>, and the corresponding classes will be outline-1, section-number-1,
369 and outline-text-1. If this is 2, all of these will get a 2 instead.
370 The default for this variable is 2, because we use <h1> for formatting the
371 document title."
372 :group 'org-export-html
373 :type 'string)
375 (defcustom org-export-html-link-org-files-as-html t
376 "Non-nil means make file links to `file.org' point to `file.html'.
377 When org-mode is exporting an org-mode file to HTML, links to
378 non-html files are directly put into a href tag in HTML.
379 However, links to other Org-mode files (recognized by the
380 extension `.org.) should become links to the corresponding html
381 file, assuming that the linked org-mode file will also be
382 converted to HTML.
383 When nil, the links still point to the plain `.org' file."
384 :group 'org-export-html
385 :type 'boolean)
387 (defcustom org-export-html-inline-images 'maybe
388 "Non-nil means inline images into exported HTML pages.
389 This is done using an <img> tag. When nil, an anchor with href is used to
390 link to the image. If this option is `maybe', then images in links with
391 an empty description will be inlined, while images with a description will
392 be linked only."
393 :group 'org-export-html
394 :type '(choice (const :tag "Never" nil)
395 (const :tag "Always" t)
396 (const :tag "When there is no description" maybe)))
398 (defcustom org-export-html-inline-image-extensions
399 '("png" "jpeg" "jpg" "gif" "svg")
400 "Extensions of image files that can be inlined into HTML."
401 :group 'org-export-html
402 :type '(repeat (string :tag "Extension")))
404 (defcustom org-export-html-table-tag
405 "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
406 "The HTML tag that is used to start a table.
407 This must be a <table> tag, but you may change the options like
408 borders and spacing."
409 :group 'org-export-html
410 :type 'string)
412 (defcustom org-export-table-header-tags '("<th scope=\"%s\"%s>" . "</th>")
413 "The opening tag for table header fields.
414 This is customizable so that alignment options can be specified.
415 The first %s will be filled with the scope of the field, either row or col.
416 The second %s will be replaced by a style entry to align the field.
417 See also the variable `org-export-html-table-use-header-tags-for-first-column'.
418 See also the variable `org-export-html-table-align-individual-fields'."
419 :group 'org-export-tables
420 :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
422 (defcustom org-export-table-data-tags '("<td%s>" . "</td>")
423 "The opening tag for table data fields.
424 This is customizable so that alignment options can be specified.
425 The first %s will be filled with the scope of the field, either row or col.
426 The second %s will be replaced by a style entry to align the field.
427 See also the variable `org-export-html-table-align-individual-fields'."
428 :group 'org-export-tables
429 :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
431 (defcustom org-export-table-row-tags '("<tr>" . "</tr>")
432 "The opening tag for table data fields.
433 This is customizable so that alignment options can be specified.
434 Instead of strings, these can be Lisp forms that will be evaluated
435 for each row in order to construct the table row tags. During evaluation,
436 the variable `head' will be true when this is a header line, nil when this
437 is a body line. And the variable `nline' will contain the line number,
438 starting from 1 in the first header line. For example
440 (setq org-export-table-row-tags
441 (cons '(if head
442 \"<tr>\"
443 (if (= (mod nline 2) 1)
444 \"<tr class=\\\"tr-odd\\\">\"
445 \"<tr class=\\\"tr-even\\\">\"))
446 \"</tr>\"))
448 will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
449 :group 'org-export-tables
450 :type '(cons
451 (choice :tag "Opening tag"
452 (string :tag "Specify")
453 (sexp))
454 (choice :tag "Closing tag"
455 (string :tag "Specify")
456 (sexp))))
458 (defcustom org-export-html-table-align-individual-fields t
459 "Non-nil means attach style attributes for alignment to each table field.
460 When nil, alignment will only be specified in the column tags, but this
461 is ignored by some browsers (like Firefox, Safari). Opera does it right
462 though."
463 :group 'org-export-tables
464 :type 'boolean)
466 (defcustom org-export-html-table-use-header-tags-for-first-column nil
467 "Non-nil means format column one in tables with header tags.
468 When nil, also column one will use data tags."
469 :group 'org-export-tables
470 :type 'boolean)
472 (defcustom org-export-html-validation-link nil
473 "Non-nil means add validation link to postamble of HTML exported files."
474 :group 'org-export-html
475 :type '(choice
476 (const :tag "Nothing" nil)
477 (const :tag "XHTML 1.0" "<p class=\"xhtml-validation\"><a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a></p>")
478 (string :tag "Specify full HTML")))
480 (defcustom org-export-html-with-timestamp nil
481 "If non-nil, write timestamp into the exported HTML text.
482 If non-nil Write `org-export-html-html-helper-timestamp' into the
483 exported HTML text. Otherwise, the buffer will just be saved to
484 a file."
485 :group 'org-export-html
486 :type 'boolean)
488 (defcustom org-export-html-html-helper-timestamp
489 "<br/><br/><hr/><p><!-- hhmts start --> <!-- hhmts end --></p>\n"
490 "The HTML tag used as timestamp delimiter for HTML-helper-mode."
491 :group 'org-export-html
492 :type 'string)
494 (defgroup org-export-htmlize nil
495 "Options for processing examples with htmlize.el."
496 :tag "Org Export Htmlize"
497 :group 'org-export-html)
499 (defcustom org-export-htmlize-output-type 'inline-css
500 "Output type to be used by htmlize when formatting code snippets.
501 Choices are `css', to export the CSS selectors only, or `inline-css', to
502 export the CSS attribute values inline in the HTML. We use as default
503 `inline-css', in order to make the resulting HTML self-containing.
505 However, this will fail when using Emacs in batch mode for export, because
506 then no rich font definitions are in place. It will also not be good if
507 people with different Emacs setup contribute HTML files to a website,
508 because the fonts will represent the individual setups. In these cases,
509 it is much better to let Org/Htmlize assign classes only, and to use
510 a style file to define the look of these classes.
511 To get a start for your css file, start Emacs session and make sure that
512 all the faces you are interested in are defined, for example by loading files
513 in all modes you want. Then, use the command
514 \\[org-export-htmlize-generate-css] to extract class definitions."
515 :group 'org-export-htmlize
516 :type '(choice (const css) (const inline-css)))
518 (defcustom org-export-htmlize-css-font-prefix "org-"
519 "The prefix for CSS class names for htmlize font specifications."
520 :group 'org-export-htmlize
521 :type 'string)
523 (defcustom org-export-htmlized-org-css-url nil
524 "URL pointing to a CSS file defining text colors for htmlized Emacs buffers.
525 Normally when creating an htmlized version of an Org buffer, htmlize will
526 create CSS to define the font colors. However, this does not work when
527 converting in batch mode, and it also can look bad if different people
528 with different fontification setup work on the same website.
529 When this variable is non-nil, creating an htmlized version of an Org buffer
530 using `org-export-as-org' will remove the internal CSS section and replace it
531 with a link to this URL."
532 :group 'org-export-htmlize
533 :type '(choice
534 (const :tag "Keep internal css" nil)
535 (string :tag "URL or local href")))
537 ;;; Variables, constants, and parameter plists
539 (defvar org-export-html-preamble nil
540 "Preamble, to be inserted just after <body>. Set by publishing functions.
541 This may also be a function, building and inserting the preamble.")
542 (defvar org-export-html-postamble nil
543 "Postamble, to be inserted just before </body>. Set by publishing functions.
544 This may also be a function, building and inserting the postamble.")
545 (defvar org-export-html-auto-preamble t
546 "Should default preamble be inserted? Set by publishing functions.")
547 (defvar org-export-html-auto-postamble t
548 "Should default postamble be inserted? Set by publishing functions.")
550 ;;; Hooks
552 (defvar org-export-html-after-blockquotes-hook nil
553 "Hook run during HTML export, after blockquote, verse, center are done.")
555 (defvar org-export-html-final-hook nil
556 "Hook run at the end of HTML export, in the new buffer.")
558 ;;; HTML export
560 (defun org-export-html-preprocess (parameters)
561 "Convert LaTeX fragments to images."
562 (when (and org-current-export-file
563 (plist-get parameters :LaTeX-fragments))
564 (org-format-latex
565 (concat "ltxpng/" (file-name-sans-extension
566 (file-name-nondirectory
567 org-current-export-file)))
568 org-current-export-dir nil "Creating LaTeX image %s"
569 nil nil
570 (cond
571 ((eq (plist-get parameters :LaTeX-fragments) 'verbatim) 'verbatim)
572 ((eq (plist-get parameters :LaTeX-fragments) 'mathjax ) 'mathjax)
573 ((eq (plist-get parameters :LaTeX-fragments) t ) 'mathjax)
574 ((eq (plist-get parameters :LaTeX-fragments) 'dvipng ) 'dvipng)
575 (t nil))))
576 (goto-char (point-min))
577 (let (label l1)
578 (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t)
579 (org-if-unprotected-at (match-beginning 1)
580 (setq label (match-string 1))
581 (save-match-data
582 (if (string-match "\\`[a-z]\\{1,10\\}:\\(.+\\)" label)
583 (setq l1 (substring label (match-beginning 1)))
584 (setq l1 label)))
585 (replace-match (format "[[#%s][%s]]" label l1) t t)))))
587 ;;;###autoload
588 (defun org-export-as-html-and-open (arg)
589 "Export the outline as HTML and immediately open it with a browser.
590 If there is an active region, export only the region.
591 The prefix ARG specifies how many levels of the outline should become
592 headlines. The default is 3. Lower levels will become bulleted lists."
593 (interactive "P")
594 (org-export-as-html arg 'hidden)
595 (org-open-file buffer-file-name)
596 (when org-export-kill-product-buffer-when-displayed
597 (kill-buffer (current-buffer))))
599 ;;;###autoload
600 (defun org-export-as-html-batch ()
601 "Call the function `org-export-as-html'.
602 This function can be used in batch processing as:
603 emacs --batch
604 --load=$HOME/lib/emacs/org.el
605 --eval \"(setq org-export-headline-levels 2)\"
606 --visit=MyFile --funcall org-export-as-html-batch"
607 (org-export-as-html org-export-headline-levels 'hidden))
609 ;;;###autoload
610 (defun org-export-as-html-to-buffer (arg)
611 "Call `org-export-as-html` with output to a temporary buffer.
612 No file is created. The prefix ARG is passed through to `org-export-as-html'."
613 (interactive "P")
614 (org-export-as-html arg nil nil "*Org HTML Export*")
615 (when org-export-show-temporary-export-buffer
616 (switch-to-buffer-other-window "*Org HTML Export*")))
618 ;;;###autoload
619 (defun org-replace-region-by-html (beg end)
620 "Assume the current region has org-mode syntax, and convert it to HTML.
621 This can be used in any buffer. For example, you could write an
622 itemized list in org-mode syntax in an HTML buffer and then use this
623 command to convert it."
624 (interactive "r")
625 (let (reg html buf pop-up-frames)
626 (save-window-excursion
627 (if (org-mode-p)
628 (setq html (org-export-region-as-html
629 beg end t 'string))
630 (setq reg (buffer-substring beg end)
631 buf (get-buffer-create "*Org tmp*"))
632 (with-current-buffer buf
633 (erase-buffer)
634 (insert reg)
635 (org-mode)
636 (setq html (org-export-region-as-html
637 (point-min) (point-max) t 'string)))
638 (kill-buffer buf)))
639 (delete-region beg end)
640 (insert html)))
642 ;;;###autoload
643 (defun org-export-region-as-html (beg end &optional body-only buffer)
644 "Convert region from BEG to END in org-mode buffer to HTML.
645 If prefix arg BODY-ONLY is set, omit file header, footer, and table of
646 contents, and only produce the region of converted text, useful for
647 cut-and-paste operations.
648 If BUFFER is a buffer or a string, use/create that buffer as a target
649 of the converted HTML. If BUFFER is the symbol `string', return the
650 produced HTML as a string and leave not buffer behind. For example,
651 a Lisp program could call this function in the following way:
653 (setq html (org-export-region-as-html beg end t 'string))
655 When called interactively, the output buffer is selected, and shown
656 in a window. A non-interactive call will only return the buffer."
657 (interactive "r\nP")
658 (when (interactive-p)
659 (setq buffer "*Org HTML Export*"))
660 (let ((transient-mark-mode t) (zmacs-regions t)
661 ext-plist rtn)
662 (setq ext-plist (plist-put ext-plist :ignore-subtree-p t))
663 (goto-char end)
664 (set-mark (point)) ;; to activate the region
665 (goto-char beg)
666 (setq rtn (org-export-as-html
667 nil nil ext-plist
668 buffer body-only))
669 (if (fboundp 'deactivate-mark) (deactivate-mark))
670 (if (and (interactive-p) (bufferp rtn))
671 (switch-to-buffer-other-window rtn)
672 rtn)))
674 (defvar html-table-tag nil) ; dynamically scoped into this.
675 (defvar org-par-open nil)
677 ;;; org-html-cvt-link-fn
678 (defconst org-html-cvt-link-fn
680 "Function to convert link URLs to exportable URLs.
681 Takes two arguments, TYPE and PATH.
682 Returns exportable url as (TYPE PATH), or nil to signal that it
683 didn't handle this case.
684 Intended to be locally bound around a call to `org-export-as-html'." )
686 (defun org-html-cvt-org-as-html (opt-plist type path)
687 "Convert an org filename to an equivalent html filename.
688 If TYPE is not file, just return `nil'.
689 See variable `org-export-html-link-org-files-as-html'"
691 (save-match-data
692 (and
693 org-export-html-link-org-files-as-html
694 (string= type "file")
695 (string-match "\\.org$" path)
696 (progn
697 (list
698 "file"
699 (concat
700 (substring path 0 (match-beginning 0))
702 (plist-get opt-plist :html-extension)))))))
705 ;;; org-html-should-inline-p
706 (defun org-html-should-inline-p (filename descp)
707 "Return non-nil if link FILENAME should be inlined.
708 The decision to inline the FILENAME link is based on the current
709 settings. DESCP is the boolean of whether there was a link
710 description. See variables `org-export-html-inline-images' and
711 `org-export-html-inline-image-extensions'."
712 (declare (special
713 org-export-html-inline-images
714 org-export-html-inline-image-extensions))
715 (and (or (eq t org-export-html-inline-images)
716 (and org-export-html-inline-images (not descp)))
717 (org-file-image-p
718 filename org-export-html-inline-image-extensions)))
720 ;;; org-html-make-link
721 (defun org-html-make-link (opt-plist type path fragment desc attr
722 may-inline-p)
723 "Make an HTML link.
724 OPT-PLIST is an options list.
725 TYPE is the device-type of the link (THIS://foo.html)
726 PATH is the path of the link (http://THIS#locationx)
727 FRAGMENT is the fragment part of the link, if any (foo.html#THIS)
728 DESC is the link description, if any.
729 ATTR is a string of other attributes of the a element.
730 MAY-INLINE-P allows inlining it as an image."
732 (declare (special org-par-open))
733 (save-match-data
734 (let* ((filename path)
735 ;;First pass. Just sanity stuff.
736 (components-1
737 (cond
738 ((string= type "file")
739 (list
740 type
741 ;;Substitute just if original path was absolute.
742 ;;(Otherwise path must remain relative)
743 (if (file-name-absolute-p path)
744 (concat "file://" (expand-file-name path))
745 path)))
746 ((string= type "")
747 (list nil path))
748 (t (list type path))))
750 ;;Second pass. Components converted so they can refer
751 ;;to a remote site.
752 (components-2
754 (and org-html-cvt-link-fn
755 (apply org-html-cvt-link-fn
756 opt-plist components-1))
757 (apply #'org-html-cvt-org-as-html
758 opt-plist components-1)
759 components-1))
760 (type (first components-2))
761 (thefile (second components-2)))
764 ;;Third pass. Build final link except for leading type
765 ;;spec.
766 (cond
767 ((or
768 (not type)
769 (string= type "http")
770 (string= type "https")
771 (string= type "file"))
772 (if fragment
773 (setq thefile (concat thefile "#" fragment))))
775 (t))
777 ;;Final URL-build, for all types.
778 (setq thefile
779 (let
780 ((str (org-export-html-format-href thefile)))
781 (if (and type (not (string= "file" type)))
782 (concat type ":" str)
783 str)))
785 (if (and
786 may-inline-p
787 ;;Can't inline a URL with a fragment.
788 (not fragment))
789 (progn
790 (message "image %s %s" thefile org-par-open)
791 (org-export-html-format-image thefile org-par-open))
792 (concat
793 "<a href=\"" thefile "\"" (if attr (concat " " attr)) ">"
794 (org-export-html-format-desc desc)
795 "</a>")))))
797 (defun org-html-handle-links (line opt-plist)
798 "Return LINE with markup of Org mode links.
799 OPT-PLIST is the export options list."
800 (let ((start 0)
801 (current-dir (if buffer-file-name
802 (file-name-directory buffer-file-name)
803 default-directory))
804 (link-validate (plist-get opt-plist :link-validation-function))
805 type id-file fnc
806 rpl path attr desc descp desc1 desc2 link)
807 (while (string-match org-bracket-link-analytic-regexp++ line start)
808 (setq start (match-beginning 0))
809 (setq path (save-match-data (org-link-unescape
810 (match-string 3 line))))
811 (setq type (cond
812 ((match-end 2) (match-string 2 line))
813 ((save-match-data
814 (or (file-name-absolute-p path)
815 (string-match "^\\.\\.?/" path)))
816 "file")
817 (t "internal")))
818 (setq path (org-extract-attributes (org-link-unescape path)))
819 (setq attr (get-text-property 0 'org-attributes path))
820 (setq desc1 (if (match-end 5) (match-string 5 line))
821 desc2 (if (match-end 2) (concat type ":" path) path)
822 descp (and desc1 (not (equal desc1 desc2)))
823 desc (or desc1 desc2))
824 ;; Make an image out of the description if that is so wanted
825 (when (and descp (org-file-image-p
826 desc org-export-html-inline-image-extensions))
827 (save-match-data
828 (if (string-match "^file:" desc)
829 (setq desc (substring desc (match-end 0)))))
830 (setq desc (org-add-props
831 (concat "<img src=\"" desc "\"/>")
832 '(org-protected t))))
833 (cond
834 ((equal type "internal")
835 (let
836 ((frag-0
837 (if (= (string-to-char path) ?#)
838 (substring path 1)
839 path)))
840 (setq rpl
841 (org-html-make-link
842 opt-plist
845 (org-solidify-link-text
846 (save-match-data (org-link-unescape frag-0))
847 nil)
848 desc attr nil))))
849 ((and (equal type "id")
850 (setq id-file (org-id-find-id-file path)))
851 ;; This is an id: link to another file (if it was the same file,
852 ;; it would have become an internal link...)
853 (save-match-data
854 (setq id-file (file-relative-name
855 id-file
856 (file-name-directory org-current-export-file)))
857 (setq rpl
858 (org-html-make-link opt-plist
859 "file" id-file
860 (concat (if (org-uuidgen-p path) "ID-") path)
861 desc
862 attr
863 nil))))
864 ((member type '("http" "https"))
865 ;; standard URL, can inline as image
866 (setq rpl
867 (org-html-make-link opt-plist
868 type path nil
869 desc
870 attr
871 (org-html-should-inline-p path descp))))
872 ((member type '("ftp" "mailto" "news"))
873 ;; standard URL, can't inline as image
874 (setq rpl
875 (org-html-make-link opt-plist
876 type path nil
877 desc
878 attr
879 nil)))
881 ((string= type "coderef")
882 (let*
883 ((coderef-str (format "coderef-%s" path))
884 (attr-1
885 (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
886 coderef-str coderef-str)))
887 (setq rpl
888 (org-html-make-link opt-plist
889 type "" coderef-str
890 (format
891 (org-export-get-coderef-format
892 path
893 (and descp desc))
894 (cdr (assoc path org-export-code-refs)))
895 attr-1
896 nil))))
898 ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
899 ;; The link protocol has a function for format the link
900 (setq rpl
901 (save-match-data
902 (funcall fnc (org-link-unescape path) desc1 'html))))
904 ((string= type "file")
905 ;; FILE link
906 (save-match-data
907 (let*
908 ((components
910 (string-match "::\\(.*\\)" path)
911 (list
912 (replace-match "" t nil path)
913 (match-string 1 path))
914 (list path nil)))
916 ;;The proper path, without a fragment
917 (path-1
918 (first components))
920 ;;The raw fragment
921 (fragment-0
922 (second components))
924 ;;Check the fragment. If it can't be used as
925 ;;target fragment we'll pass nil instead.
926 (fragment-1
928 (and fragment-0
929 (not (string-match "^[0-9]*$" fragment-0))
930 (not (string-match "^\\*" fragment-0))
931 (not (string-match "^/.*/$" fragment-0)))
932 (org-solidify-link-text
933 (org-link-unescape fragment-0))
934 nil))
935 (desc-2
936 ;;Description minus "file:" and ".org"
937 (if (string-match "^file:" desc)
938 (let
939 ((desc-1 (replace-match "" t t desc)))
940 (if (string-match "\\.org$" desc-1)
941 (replace-match "" t t desc-1)
942 desc-1))
943 desc)))
945 (setq rpl
947 (and
948 (functionp link-validate)
949 (not (funcall link-validate path-1 current-dir)))
950 desc
951 (org-html-make-link opt-plist
952 "file" path-1 fragment-1 desc-2 attr
953 (org-html-should-inline-p path-1 descp)))))))
956 ;; just publish the path, as default
957 (setq rpl (concat "<i>&lt;" type ":"
958 (save-match-data (org-link-unescape path))
959 "&gt;</i>"))))
960 (setq line (replace-match rpl t t line)
961 start (+ start (length rpl))))
962 line))
964 ;;; org-export-as-html
965 ;;;###autoload
966 (defun org-export-as-html (arg &optional hidden ext-plist
967 to-buffer body-only pub-dir)
968 "Export the outline as a pretty HTML file.
969 If there is an active region, export only the region. The prefix
970 ARG specifies how many levels of the outline should become
971 headlines. The default is 3. Lower levels will become bulleted
972 lists. HIDDEN is obsolete and does nothing.
973 EXT-PLIST is a property list with external parameters overriding
974 org-mode's default settings, but still inferior to file-local
975 settings. When TO-BUFFER is non-nil, create a buffer with that
976 name and export to that buffer. If TO-BUFFER is the symbol
977 `string', don't leave any buffer behind but just return the
978 resulting HTML as a string. When BODY-ONLY is set, don't produce
979 the file header and footer, simply return the content of
980 <body>...</body>, without even the body tags themselves. When
981 PUB-DIR is set, use this as the publishing directory."
982 (interactive "P")
983 (run-hooks 'org-export-first-hook)
985 ;; Make sure we have a file name when we need it.
986 (when (and (not (or to-buffer body-only))
987 (not buffer-file-name))
988 (if (buffer-base-buffer)
989 (org-set-local 'buffer-file-name
990 (with-current-buffer (buffer-base-buffer)
991 buffer-file-name))
992 (error "Need a file name to be able to export")))
994 (message "Exporting...")
995 (setq-default org-todo-line-regexp org-todo-line-regexp)
996 (setq-default org-deadline-line-regexp org-deadline-line-regexp)
997 (setq-default org-done-keywords org-done-keywords)
998 (setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp)
999 (let* ((opt-plist
1000 (org-export-process-option-filters
1001 (org-combine-plists (org-default-export-plist)
1002 ext-plist
1003 (org-infile-export-plist))))
1004 (body-only (or body-only (plist-get opt-plist :body-only)))
1005 (style (concat (if (plist-get opt-plist :style-include-default)
1006 org-export-html-style-default)
1007 (plist-get opt-plist :style)
1008 (plist-get opt-plist :style-extra)
1009 "\n"
1010 (if (plist-get opt-plist :style-include-scripts)
1011 org-export-html-scripts)))
1012 (html-extension (plist-get opt-plist :html-extension))
1013 valid thetoc have-headings first-heading-pos
1014 (odd org-odd-levels-only)
1015 (region-p (org-region-active-p))
1016 (rbeg (and region-p (region-beginning)))
1017 (rend (and region-p (region-end)))
1018 (subtree-p
1019 (if (plist-get opt-plist :ignore-subtree-p)
1021 (when region-p
1022 (save-excursion
1023 (goto-char rbeg)
1024 (and (org-at-heading-p)
1025 (>= (org-end-of-subtree t t) rend))))))
1026 (level-offset (if subtree-p
1027 (save-excursion
1028 (goto-char rbeg)
1029 (+ (funcall outline-level)
1030 (if org-odd-levels-only 1 0)))
1032 (opt-plist (setq org-export-opt-plist
1033 (if subtree-p
1034 (org-export-add-subtree-options opt-plist rbeg)
1035 opt-plist)))
1036 ;; The following two are dynamically scoped into other
1037 ;; routines below.
1038 (org-current-export-dir
1039 (or pub-dir (org-export-directory :html opt-plist)))
1040 (org-current-export-file buffer-file-name)
1041 (level 0) (line "") (origline "") txt todo
1042 (umax nil)
1043 (umax-toc nil)
1044 (filename (if to-buffer nil
1045 (expand-file-name
1046 (concat
1047 (file-name-sans-extension
1048 (or (and subtree-p
1049 (org-entry-get (region-beginning)
1050 "EXPORT_FILE_NAME" t))
1051 (file-name-nondirectory buffer-file-name)))
1052 "." html-extension)
1053 (file-name-as-directory
1054 (or pub-dir (org-export-directory :html opt-plist))))))
1055 (current-dir (if buffer-file-name
1056 (file-name-directory buffer-file-name)
1057 default-directory))
1058 (buffer (if to-buffer
1059 (cond
1060 ((eq to-buffer 'string) (get-buffer-create "*Org HTML Export*"))
1061 (t (get-buffer-create to-buffer)))
1062 (find-file-noselect filename)))
1063 (org-levels-open (make-vector org-level-max nil))
1064 (date (plist-get opt-plist :date))
1065 (author (plist-get opt-plist :author))
1066 (title (or (and subtree-p (org-export-get-title-from-subtree))
1067 (plist-get opt-plist :title)
1068 (and (not body-only)
1069 (not
1070 (plist-get opt-plist :skip-before-1st-heading))
1071 (org-export-grab-title-from-buffer))
1072 (and buffer-file-name
1073 (file-name-sans-extension
1074 (file-name-nondirectory buffer-file-name)))
1075 "UNTITLED"))
1076 (link-up (and (plist-get opt-plist :link-up)
1077 (string-match "\\S-" (plist-get opt-plist :link-up))
1078 (plist-get opt-plist :link-up)))
1079 (link-home (and (plist-get opt-plist :link-home)
1080 (string-match "\\S-" (plist-get opt-plist :link-home))
1081 (plist-get opt-plist :link-home)))
1082 (dummy (setq opt-plist (plist-put opt-plist :title title)))
1083 (html-table-tag (plist-get opt-plist :html-table-tag))
1084 (quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
1085 (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)"))
1086 (inquote nil)
1087 (infixed nil)
1088 (inverse nil)
1089 (in-local-list nil)
1090 (local-list-type nil)
1091 (local-list-indent nil)
1092 (llt org-plain-list-ordered-item-terminator)
1093 (email (plist-get opt-plist :email))
1094 (language (plist-get opt-plist :language))
1095 (keywords (plist-get opt-plist :keywords))
1096 (description (plist-get opt-plist :description))
1097 (lang-words nil)
1098 (head-count 0) cnt
1099 (start 0)
1100 (coding-system (and (boundp 'buffer-file-coding-system)
1101 buffer-file-coding-system))
1102 (coding-system-for-write (or org-export-html-coding-system
1103 coding-system))
1104 (save-buffer-coding-system (or org-export-html-coding-system
1105 coding-system))
1106 (charset (and coding-system-for-write
1107 (fboundp 'coding-system-get)
1108 (coding-system-get coding-system-for-write
1109 'mime-charset)))
1110 (region
1111 (buffer-substring
1112 (if region-p (region-beginning) (point-min))
1113 (if region-p (region-end) (point-max))))
1114 (org-export-have-math nil)
1115 (lines
1116 (org-split-string
1117 (org-export-preprocess-string
1118 region
1119 :emph-multiline t
1120 :for-html t
1121 :skip-before-1st-heading
1122 (plist-get opt-plist :skip-before-1st-heading)
1123 :drawers (plist-get opt-plist :drawers)
1124 :todo-keywords (plist-get opt-plist :todo-keywords)
1125 :tags (plist-get opt-plist :tags)
1126 :priority (plist-get opt-plist :priority)
1127 :footnotes (plist-get opt-plist :footnotes)
1128 :timestamps (plist-get opt-plist :timestamps)
1129 :archived-trees
1130 (plist-get opt-plist :archived-trees)
1131 :select-tags (plist-get opt-plist :select-tags)
1132 :exclude-tags (plist-get opt-plist :exclude-tags)
1133 :add-text
1134 (plist-get opt-plist :text)
1135 :LaTeX-fragments
1136 (plist-get opt-plist :LaTeX-fragments))
1137 "[\r\n]"))
1138 (mathjax
1139 (if (or (eq (plist-get opt-plist :LaTeX-fragments) 'mathjax)
1140 (and org-export-have-math
1141 (eq (plist-get opt-plist :LaTeX-fragments) t)))
1143 (org-export-html-mathjax-config
1144 org-export-html-mathjax-template
1145 org-export-html-mathjax-options
1146 (or (plist-get opt-plist :mathjax) ""))
1147 ""))
1148 table-open
1149 table-buffer table-orig-buffer
1150 ind item-type starter
1151 snumber item-tag item-number
1152 footnotes footref-seen
1153 href
1156 (let ((inhibit-read-only t))
1157 (org-unmodified
1158 (remove-text-properties (point-min) (point-max)
1159 '(:org-license-to-kill t))))
1161 (message "Exporting...")
1163 (setq org-min-level (org-get-min-level lines level-offset))
1164 (setq org-last-level org-min-level)
1165 (org-init-section-numbers)
1167 (cond
1168 ((and date (string-match "%" date))
1169 (setq date (format-time-string date)))
1170 (date)
1171 (t (setq date (format-time-string "%Y-%m-%d %T %Z"))))
1173 ;; Get the language-dependent settings
1174 (setq lang-words (or (assoc language org-export-language-setup)
1175 (assoc "en" org-export-language-setup)))
1177 ;; Switch to the output buffer
1178 (set-buffer buffer)
1179 (let ((inhibit-read-only t)) (erase-buffer))
1180 (fundamental-mode)
1181 (org-install-letbind)
1183 (and (fboundp 'set-buffer-file-coding-system)
1184 (set-buffer-file-coding-system coding-system-for-write))
1186 (let ((case-fold-search nil)
1187 (org-odd-levels-only odd))
1188 ;; create local variables for all options, to make sure all called
1189 ;; functions get the correct information
1190 (mapc (lambda (x)
1191 (set (make-local-variable (nth 2 x))
1192 (plist-get opt-plist (car x))))
1193 org-export-plist-vars)
1194 (setq umax (if arg (prefix-numeric-value arg)
1195 org-export-headline-levels))
1196 (setq umax-toc (if (integerp org-export-with-toc)
1197 (min org-export-with-toc umax)
1198 umax))
1199 (unless body-only
1200 ;; File header
1201 (insert (format
1203 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
1204 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
1205 <html xmlns=\"http://www.w3.org/1999/xhtml\"
1206 lang=\"%s\" xml:lang=\"%s\">
1207 <head>
1208 <title>%s</title>
1209 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
1210 <meta name=\"generator\" content=\"Org-mode\"/>
1211 <meta name=\"generated\" content=\"%s\"/>
1212 <meta name=\"author\" content=\"%s\"/>
1213 <meta name=\"description\" content=\"%s\"/>
1214 <meta name=\"keywords\" content=\"%s\"/>
1217 </head>
1218 <body>
1219 <div id=\"content\">
1222 (format
1223 (or (and (stringp org-export-html-xml-declaration)
1224 org-export-html-xml-declaration)
1225 (cdr (assoc html-extension org-export-html-xml-declaration))
1226 (cdr (assoc "html" org-export-html-xml-declaration))
1229 (or charset "iso-8859-1"))
1230 language language
1231 title
1232 (or charset "iso-8859-1")
1233 date author description keywords
1234 style
1235 mathjax
1236 (if (or link-up link-home)
1237 (concat
1238 (format org-export-html-home/up-format
1239 (or link-up link-home)
1240 (or link-home link-up))
1241 "\n")
1242 "")))
1244 (org-export-html-insert-plist-item opt-plist :preamble opt-plist)
1246 (when (plist-get opt-plist :auto-preamble)
1247 (if title (insert (format org-export-html-title-format
1248 (org-html-expand title))))))
1250 (if (and org-export-with-toc (not body-only))
1251 (progn
1252 (push (format "<h%d>%s</h%d>\n"
1253 org-export-html-toplevel-hlevel
1254 (nth 3 lang-words)
1255 org-export-html-toplevel-hlevel)
1256 thetoc)
1257 (push "<div id=\"text-table-of-contents\">\n" thetoc)
1258 (push "<ul>\n<li>" thetoc)
1259 (setq lines
1260 (mapcar '(lambda (line)
1261 (if (and (string-match org-todo-line-regexp line)
1262 (not (get-text-property 0 'org-protected line)))
1263 ;; This is a headline
1264 (progn
1265 (setq have-headings t)
1266 (setq level (- (match-end 1) (match-beginning 1)
1267 level-offset)
1268 level (org-tr-level level)
1269 txt (save-match-data
1270 (org-html-expand
1271 (org-export-cleanup-toc-line
1272 (match-string 3 line))))
1273 todo
1274 (or (and org-export-mark-todo-in-toc
1275 (match-beginning 2)
1276 (not (member (match-string 2 line)
1277 org-done-keywords)))
1278 ; TODO, not DONE
1279 (and org-export-mark-todo-in-toc
1280 (= level umax-toc)
1281 (org-search-todo-below
1282 line lines level))))
1283 (if (string-match
1284 (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt)
1285 (setq txt (replace-match "&nbsp;&nbsp;&nbsp;<span class=\"tag\"> \\1</span>" t nil txt)))
1286 (if (string-match quote-re0 txt)
1287 (setq txt (replace-match "" t t txt)))
1288 (setq snumber (org-section-number level))
1289 (if org-export-with-section-numbers
1290 (setq txt (concat snumber " " txt)))
1291 (if (<= level (max umax umax-toc))
1292 (setq head-count (+ head-count 1)))
1293 (if (<= level umax-toc)
1294 (progn
1295 (if (> level org-last-level)
1296 (progn
1297 (setq cnt (- level org-last-level))
1298 (while (>= (setq cnt (1- cnt)) 0)
1299 (push "\n<ul>\n<li>" thetoc))
1300 (push "\n" thetoc)))
1301 (if (< level org-last-level)
1302 (progn
1303 (setq cnt (- org-last-level level))
1304 (while (>= (setq cnt (1- cnt)) 0)
1305 (push "</li>\n</ul>" thetoc))
1306 (push "\n" thetoc)))
1307 ;; Check for targets
1308 (while (string-match org-any-target-regexp line)
1309 (setq line (replace-match
1310 (concat "@<span class=\"target\">" (match-string 1 line) "@</span> ")
1311 t t line)))
1312 (while (string-match "&lt;\\(&lt;\\)+\\|&gt;\\(&gt;\\)+" txt)
1313 (setq txt (replace-match "" t t txt)))
1314 (setq href
1315 (replace-regexp-in-string
1316 "\\." "_" (format "sec-%s" snumber)))
1317 (setq href (org-solidify-link-text (or (cdr (assoc href org-export-preferred-target-alist)) href)))
1318 (push
1319 (format
1320 (if todo
1321 "</li>\n<li><a href=\"#%s\"><span class=\"todo\">%s</span></a>"
1322 "</li>\n<li><a href=\"#%s\">%s</a>")
1323 href txt) thetoc)
1325 (setq org-last-level level))
1327 line)
1328 lines))
1329 (while (> org-last-level (1- org-min-level))
1330 (setq org-last-level (1- org-last-level))
1331 (push "</li>\n</ul>\n" thetoc))
1332 (push "</div>\n" thetoc)
1333 (setq thetoc (if have-headings (nreverse thetoc) nil))))
1335 (setq head-count 0)
1336 (org-init-section-numbers)
1338 (org-open-par)
1340 (while (setq line (pop lines) origline line)
1341 (catch 'nextline
1343 ;; end of quote section?
1344 (when (and inquote (string-match "^\\*+ " line))
1345 (insert "</pre>\n")
1346 (org-open-par)
1347 (setq inquote nil))
1348 ;; inside a quote section?
1349 (when inquote
1350 (insert (org-html-protect line) "\n")
1351 (throw 'nextline nil))
1353 ;; Fixed-width, verbatim lines (examples)
1354 (when (and org-export-with-fixed-width
1355 (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line))
1356 (when (not infixed)
1357 (setq infixed t)
1358 (org-close-par-maybe)
1360 (insert "<pre class=\"example\">\n"))
1361 (insert (org-html-protect (match-string 3 line)) "\n")
1362 (when (or (not lines)
1363 (not (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)"
1364 (car lines))))
1365 (setq infixed nil)
1366 (insert "</pre>\n")
1367 (org-open-par))
1368 (throw 'nextline nil))
1370 ;; Explicit list closure
1371 (when (equal "ORG-LIST-END" line)
1372 (while local-list-indent
1373 (org-close-li (car local-list-type))
1374 (insert (format "</%sl>\n" (car local-list-type)))
1375 (pop local-list-type)
1376 (pop local-list-indent))
1377 (setq in-local-list nil)
1378 (org-open-par)
1379 (throw 'nextline nil))
1381 ;; Protected HTML
1382 (when (and (get-text-property 0 'org-protected line)
1383 ;; Make sure it is the entire line that is protected
1384 (not (< (or (next-single-property-change
1385 0 'org-protected line) 10000)
1386 (length line))))
1387 (let (par (ind (get-text-property 0 'original-indentation line)))
1388 (when (re-search-backward
1389 "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
1390 (setq par (match-string 1))
1391 (replace-match "\\2\n"))
1392 (insert line "\n")
1393 (while (and lines
1394 (or (= (length (car lines)) 0)
1395 (not ind)
1396 (equal ind (get-text-property 0 'original-indentation (car lines))))
1397 (or (= (length (car lines)) 0)
1398 (get-text-property 0 'org-protected (car lines))))
1399 (insert (pop lines) "\n"))
1400 (and par (insert "<p>\n")))
1401 (throw 'nextline nil))
1403 ;; Blockquotes, verse, and center
1404 (when (equal "ORG-BLOCKQUOTE-START" line)
1405 (org-close-par-maybe)
1406 (insert "<blockquote>\n")
1407 (org-open-par)
1408 (throw 'nextline nil))
1409 (when (equal "ORG-BLOCKQUOTE-END" line)
1410 (org-close-par-maybe)
1411 (insert "\n</blockquote>\n")
1412 (org-open-par)
1413 (throw 'nextline nil))
1414 (when (equal "ORG-VERSE-START" line)
1415 (org-close-par-maybe)
1416 (insert "\n<p class=\"verse\">\n")
1417 (setq org-par-open t)
1418 (setq inverse t)
1419 (throw 'nextline nil))
1420 (when (equal "ORG-VERSE-END" line)
1421 (insert "</p>\n")
1422 (setq org-par-open nil)
1423 (org-open-par)
1424 (setq inverse nil)
1425 (throw 'nextline nil))
1426 (when (equal "ORG-CENTER-START" line)
1427 (org-close-par-maybe)
1428 (insert "\n<div style=\"text-align: center\">")
1429 (org-open-par)
1430 (throw 'nextline nil))
1431 (when (equal "ORG-CENTER-END" line)
1432 (org-close-par-maybe)
1433 (insert "\n</div>")
1434 (org-open-par)
1435 (throw 'nextline nil))
1436 (run-hooks 'org-export-html-after-blockquotes-hook)
1437 (when inverse
1438 (let ((i (org-get-string-indentation line)))
1439 (if (> i 0)
1440 (setq line (concat (mapconcat 'identity
1441 (make-list (* 2 i) "\\nbsp") "")
1442 " " (org-trim line))))
1443 (unless (string-match "\\\\\\\\[ \t]*$" line)
1444 (setq line (concat line "\\\\")))))
1446 ;; make targets to anchors
1447 (setq start 0)
1448 (while (string-match
1449 "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start)
1450 (cond
1451 ((get-text-property (match-beginning 1) 'org-protected line)
1452 (setq start (match-end 1)))
1453 ((match-end 2)
1454 (setq line (replace-match
1455 (format
1456 "@<a name=\"%s\" id=\"%s\">@</a>"
1457 (org-solidify-link-text (match-string 1 line))
1458 (org-solidify-link-text (match-string 1 line)))
1459 t t line)))
1460 ((and org-export-with-toc (equal (string-to-char line) ?*))
1461 ;; FIXME: NOT DEPENDENT on TOC?????????????????????
1462 (setq line (replace-match
1463 (concat "@<span class=\"target\">"
1464 (match-string 1 line) "@</span> ")
1465 ;; (concat "@<i>" (match-string 1 line) "@</i> ")
1466 t t line)))
1468 (setq line (replace-match
1469 (concat "@<a name=\""
1470 (org-solidify-link-text (match-string 1 line))
1471 "\" class=\"target\">" (match-string 1 line)
1472 "@</a> ")
1473 t t line)))))
1475 ;; replace "&" by "&amp;", "<" and ">" by "&lt;" and "&gt;"
1476 ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
1477 ;; Also handle sub_superscripts and checkboxes
1478 (or (string-match org-table-hline-regexp line)
1479 (setq line (org-html-expand line)))
1481 ;; Format the links
1482 (setq line (org-html-handle-links line opt-plist))
1484 (setq line (org-html-handle-time-stamps line))
1486 ;; TODO items
1487 (if (and (string-match org-todo-line-regexp line)
1488 (match-beginning 2))
1490 (setq line
1491 (concat (substring line 0 (match-beginning 2))
1492 "<span class=\""
1493 (if (member (match-string 2 line)
1494 org-done-keywords)
1495 "done" "todo")
1496 " " (match-string 2 line)
1497 "\"> " (org-export-html-get-todo-kwd-class-name
1498 (match-string 2 line))
1499 "</span>" (substring line (match-end 2)))))
1501 ;; Does this contain a reference to a footnote?
1502 (when org-export-with-footnotes
1503 (setq start 0)
1504 (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
1505 (if (get-text-property (match-beginning 2) 'org-protected line)
1506 (setq start (match-end 2))
1507 (let ((n (match-string 2 line)) extra a)
1508 (if (setq a (assoc n footref-seen))
1509 (progn
1510 (setcdr a (1+ (cdr a)))
1511 (setq extra (format ".%d" (cdr a))))
1512 (setq extra "")
1513 (push (cons n 1) footref-seen))
1514 (setq line
1515 (replace-match
1516 (format
1517 (concat "%s"
1518 (format org-export-html-footnote-format
1519 "<a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a>"))
1520 (or (match-string 1 line) "") n extra n n)
1521 t t line))))))
1523 (cond
1524 ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
1525 ;; This is a headline
1526 (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
1527 level-offset))
1528 txt (match-string 2 line))
1529 (if (string-match quote-re0 txt)
1530 (setq txt (replace-match "" t t txt)))
1531 (if (<= level (max umax umax-toc))
1532 (setq head-count (+ head-count 1)))
1533 (setq first-heading-pos (or first-heading-pos (point)))
1534 (org-html-level-start level txt umax
1535 (and org-export-with-toc (<= level umax))
1536 head-count)
1538 ;; QUOTES
1539 (when (string-match quote-re line)
1540 (org-close-par-maybe)
1541 (insert "<pre>")
1542 (setq inquote t)))
1544 ((and org-export-with-tables
1545 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
1546 (when (not table-open)
1547 ;; New table starts
1548 (setq table-open t table-buffer nil table-orig-buffer nil))
1550 ;; Accumulate lines
1551 (setq table-buffer (cons line table-buffer)
1552 table-orig-buffer (cons origline table-orig-buffer))
1553 (when (or (not lines)
1554 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
1555 (car lines))))
1556 (setq table-open nil
1557 table-buffer (nreverse table-buffer)
1558 table-orig-buffer (nreverse table-orig-buffer))
1559 (org-close-par-maybe)
1560 (insert (org-format-table-html table-buffer table-orig-buffer))))
1562 ;; Normal lines
1563 (when (string-match
1564 (cond
1565 ((eq llt t) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+[.)]\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
1566 ((= llt ?.) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+\\.\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
1567 ((= llt ?\)) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+)\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
1568 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))
1569 line)
1570 (setq ind (or (get-text-property 0 'original-indentation line)
1571 (org-get-string-indentation line))
1572 item-type (if (match-beginning 4) "o" "u")
1573 starter (if (match-beginning 2)
1574 (substring (match-string 2 line) 0 -1))
1575 line (substring line (match-beginning 5))
1576 item-number nil
1577 item-tag nil)
1578 (if (string-match "\\[@\\(?:start:\\)?\\([0-9]+\\)\\][ \t]?" line)
1579 (setq item-number (match-string 1 line)
1580 line (replace-match "" t t line)))
1581 (if (and starter (string-match "\\(.*?\\) ::[ \t]*" line))
1582 (setq item-type "d"
1583 item-tag (match-string 1 line)
1584 line (substring line (match-end 0))))
1585 (cond
1586 ((and starter
1587 (or (not in-local-list)
1588 (> ind (car local-list-indent))))
1589 ;; Start new (level of) list
1590 (org-close-par-maybe)
1591 (insert (cond
1592 ((equal item-type "u") "<ul>\n<li>\n")
1593 ((and (equal item-type "o") item-number)
1594 (format "<ol>\n<li value=\"%s\">\n" item-number))
1595 ((equal item-type "o") "<ol>\n<li>\n")
1596 ((equal item-type "d")
1597 (format "<dl>\n<dt>%s</dt><dd>\n" item-tag))))
1598 (push item-type local-list-type)
1599 (push ind local-list-indent)
1600 (setq in-local-list t))
1601 ;; Continue list
1602 (starter
1603 ;; terminate any previous sublist but first ensure
1604 ;; list is not ill-formed.
1605 (let ((min-ind (apply 'min local-list-indent)))
1606 (when (< ind min-ind) (setq ind min-ind)))
1607 (while (< ind (car local-list-indent))
1608 (org-close-li (car local-list-type))
1609 (insert (format "</%sl>\n" (car local-list-type)))
1610 (pop local-list-type) (pop local-list-indent)
1611 (setq in-local-list local-list-indent))
1612 ;; insert new item
1613 (org-close-li (car local-list-type))
1614 (insert (cond
1615 ((equal (car local-list-type) "d")
1616 (format "<dt>%s</dt><dd>\n" (or item-tag "???")))
1617 ((and (equal item-type "o") item-number)
1618 (format "<li value=\"%s\">\n" item-number))
1619 (t "<li>\n")))))
1620 (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line)
1621 (setq line
1622 (replace-match
1623 (if (equal (match-string 1 line) "X")
1624 "<b>[X]</b>"
1625 "<b>[<span style=\"visibility:hidden;\">X</span>]</b>")
1626 t t line))))
1628 ;; Horizontal line
1629 (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line)
1630 (if org-par-open
1631 (insert "\n</p>\n<hr/>\n<p>\n")
1632 (insert "\n<hr/>\n"))
1633 (throw 'nextline nil))
1635 ;; Empty lines start a new paragraph. If hand-formatted lists
1636 ;; are not fully interpreted, lines starting with "-", "+", "*"
1637 ;; also start a new paragraph.
1638 (if (string-match "^ [-+*]-\\|^[ \t]*$" line) (org-open-par))
1640 ;; Is this the start of a footnote?
1641 (when org-export-with-footnotes
1642 (when (and (boundp 'footnote-section-tag-regexp)
1643 (string-match (concat "^" footnote-section-tag-regexp)
1644 line))
1645 ;; ignore this line
1646 (throw 'nextline nil))
1647 (when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" line)
1648 (org-close-par-maybe)
1649 (let ((n (match-string 1 line)))
1650 (setq org-par-open t
1651 line (replace-match
1652 (format
1653 (concat "<p class=\"footnote\">"
1654 (format org-export-html-footnote-format
1655 "<a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a>"))
1656 n n n) t t line)))))
1657 ;; Check if the line break needs to be conserved
1658 (cond
1659 ((string-match "\\\\\\\\[ \t]*$" line)
1660 (setq line (replace-match "<br/>" t t line)))
1661 (org-export-preserve-breaks
1662 (setq line (concat line "<br/>"))))
1664 ;; Check if a paragraph should be started
1665 (let ((start 0))
1666 (while (and org-par-open
1667 (string-match "\\\\par\\>" line start))
1668 ;; Leave a space in the </p> so that the footnote matcher
1669 ;; does not see this.
1670 (if (not (get-text-property (match-beginning 0)
1671 'org-protected line))
1672 (setq line (replace-match "</p ><p >" t t line)))
1673 (setq start (match-end 0))))
1675 (insert line "\n")))))
1677 ;; Properly close all local lists and other lists
1678 (when inquote
1679 (insert "</pre>\n")
1680 (org-open-par))
1682 (org-html-level-start 1 nil umax
1683 (and org-export-with-toc (<= level umax))
1684 head-count)
1685 ;; the </div> to close the last text-... div.
1686 (when (and (> umax 0) first-heading-pos) (insert "</div>\n"))
1688 (save-excursion
1689 (goto-char (point-min))
1690 (while (re-search-forward "<p class=\"footnote\">[^\000]*?\\(</p>\\|\\'\\)" nil t)
1691 (push (match-string 0) footnotes)
1692 (replace-match "" t t)))
1693 (when footnotes
1694 (insert (format org-export-html-footnotes-section
1695 (nth 4 lang-words)
1696 (mapconcat 'identity (nreverse footnotes) "\n"))
1697 "\n"))
1698 (let ((bib (org-export-html-get-bibliography)))
1699 (when bib
1700 (insert "\n" bib "\n")))
1701 (unless body-only
1702 (when (plist-get opt-plist :auto-postamble)
1703 (insert "<div id=\"postamble\">\n")
1704 (when (and org-export-author-info author)
1705 (insert "<p class=\"author\"> "
1706 (nth 1 lang-words) ": " author "\n")
1707 (when (and org-export-email-info email (string-match "\\S-" email))
1708 (if (listp (split-string email ",+ *"))
1709 (mapc (lambda(e)
1710 (insert "<a href=\"mailto:" e "\">&lt;"
1711 e "&gt;</a>\n"))
1712 (split-string email ",+ *"))
1713 (insert "<a href=\"mailto:" email "\">&lt;"
1714 email "&gt;</a>\n")))
1715 (insert "</p>\n"))
1716 (when (and date org-export-time-stamp-file)
1717 (insert "<p class=\"date\"> "
1718 (nth 2 lang-words) ": "
1719 date "</p>\n"))
1720 (when org-export-creator-info
1721 (insert (format "<p class=\"creator\">HTML generated by org-mode %s in emacs %s</p>\n"
1722 org-version emacs-major-version)))
1723 (when org-export-html-validation-link
1724 (insert org-export-html-validation-link "\n"))
1725 (insert "</div>"))
1727 (if org-export-html-with-timestamp
1728 (insert org-export-html-html-helper-timestamp))
1729 (org-export-html-insert-plist-item opt-plist :postamble opt-plist)
1730 (insert "\n</div>\n</body>\n</html>\n"))
1732 (unless (plist-get opt-plist :buffer-will-be-killed)
1733 (normal-mode)
1734 (if (eq major-mode (default-value 'major-mode))
1735 (html-mode)))
1737 ;; insert the table of contents
1738 (goto-char (point-min))
1739 (when thetoc
1740 (if (or (re-search-forward
1741 "<p>\\s-*\\[TABLE-OF-CONTENTS\\]\\s-*</p>" nil t)
1742 (re-search-forward
1743 "\\[TABLE-OF-CONTENTS\\]" nil t))
1744 (progn
1745 (goto-char (match-beginning 0))
1746 (replace-match ""))
1747 (goto-char first-heading-pos)
1748 (when (looking-at "\\s-*</p>")
1749 (goto-char (match-end 0))
1750 (insert "\n")))
1751 (insert "<div id=\"table-of-contents\">\n")
1752 (mapc 'insert thetoc)
1753 (insert "</div>\n"))
1754 ;; remove empty paragraphs and lists
1755 (goto-char (point-min))
1756 (while (re-search-forward "<p>[ \r\n\t]*</p>" nil t)
1757 (replace-match ""))
1758 (goto-char (point-min))
1759 (while (re-search-forward "<li>[ \r\n\t]*</li>\n?" nil t)
1760 (replace-match ""))
1761 (goto-char (point-min))
1762 ;; Convert whitespace place holders
1763 (goto-char (point-min))
1764 (let (beg end n)
1765 (while (setq beg (next-single-property-change (point) 'org-whitespace))
1766 (setq n (get-text-property beg 'org-whitespace)
1767 end (next-single-property-change beg 'org-whitespace))
1768 (goto-char beg)
1769 (delete-region beg end)
1770 (insert (format "<span style=\"visibility:hidden;\">%s</span>"
1771 (make-string n ?x)))))
1772 ;; Remove empty lines at the beginning of the file.
1773 (goto-char (point-min))
1774 (when (looking-at "\\s-+\n") (replace-match ""))
1775 ;; Remove display properties
1776 (remove-text-properties (point-min) (point-max) '(display t))
1777 ;; Run the hook
1778 (run-hooks 'org-export-html-final-hook)
1779 (or to-buffer (save-buffer))
1780 (goto-char (point-min))
1781 (or (org-export-push-to-kill-ring "HTML")
1782 (message "Exporting... done"))
1783 (if (eq to-buffer 'string)
1784 (prog1 (buffer-substring (point-min) (point-max))
1785 (kill-buffer (current-buffer)))
1786 (current-buffer)))))
1788 (defun org-export-html-insert-plist-item (plist key &rest args)
1789 (let ((item (plist-get plist key)))
1790 (cond ((functionp item)
1791 (apply item args))
1792 (item
1793 (insert item)))))
1795 (defun org-export-html-format-href (s)
1796 "Make sure the S is valid as a href reference in an XHTML document."
1797 (save-match-data
1798 (let ((start 0))
1799 (while (string-match "&" s start)
1800 (setq start (+ (match-beginning 0) 3)
1801 s (replace-match "&amp;" t t s)))))
1804 (defun org-export-html-format-desc (s)
1805 "Make sure the S is valid as a description in a link."
1806 (if (and s (not (get-text-property 1 'org-protected s)))
1807 (save-match-data
1808 (org-html-do-expand s))
1811 (defun org-export-html-format-image (src par-open)
1812 "Create image tag with source and attributes."
1813 (save-match-data
1814 (if (string-match "^ltxpng/" src)
1815 (format "<img src=\"%s\" alt=\"%s\"/>"
1816 src (org-find-text-property-in-string 'org-latex-src src))
1817 (let* ((caption (org-find-text-property-in-string 'org-caption src))
1818 (attr (org-find-text-property-in-string 'org-attributes src))
1819 (label (org-find-text-property-in-string 'org-label src)))
1820 (setq caption (and caption (org-html-do-expand caption)))
1821 (concat
1822 (if caption
1823 (format "%s<div %sclass=\"figure\">
1824 <p>"
1825 (if org-par-open "</p>\n" "")
1826 (if label (format "id=\"%s\" " (org-solidify-link-text label)) "")))
1827 (format "<img src=\"%s\"%s />"
1829 (if (string-match "\\<alt=" (or attr ""))
1830 (concat " " attr )
1831 (concat " " attr " alt=\"" src "\"")))
1832 (if caption
1833 (format "</p>%s
1834 </div>%s"
1835 (concat "\n<p>" caption "</p>")
1836 (if org-par-open "\n<p>" ""))))))))
1838 (defun org-export-html-get-bibliography ()
1839 "Find bibliography, cut it out and return it."
1840 (catch 'exit
1841 (let (beg end (cnt 1) bib)
1842 (save-excursion
1843 (goto-char (point-min))
1844 (when (re-search-forward "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t)
1845 (setq beg (match-beginning 0))
1846 (while (re-search-forward "</?div\\>" nil t)
1847 (setq cnt (+ cnt (if (string= (match-string 0) "<div") +1 -1)))
1848 (when (= cnt 0)
1849 (and (looking-at ">") (forward-char 1))
1850 (setq bib (buffer-substring beg (point)))
1851 (delete-region beg (point))
1852 (throw 'exit bib))))
1853 nil))))
1855 (defvar org-table-number-regexp) ; defined in org-table.el
1856 (defun org-format-table-html (lines olines &optional no-css)
1857 "Find out which HTML converter to use and return the HTML code.
1858 NO-CSS is passed to the exporter."
1859 (if (stringp lines)
1860 (setq lines (org-split-string lines "\n")))
1861 (if (string-match "^[ \t]*|" (car lines))
1862 ;; A normal org table
1863 (org-format-org-table-html lines nil no-css)
1864 ;; Table made by table.el - test for spanning
1865 (let* ((hlines (delq nil (mapcar
1866 (lambda (x)
1867 (if (string-match "^[ \t]*\\+-" x) x
1868 nil))
1869 lines)))
1870 (first (car hlines))
1871 (ll (and (string-match "\\S-+" first)
1872 (match-string 0 first)))
1873 (re (concat "^[ \t]*" (regexp-quote ll)))
1874 (spanning (delq nil (mapcar (lambda (x) (not (string-match re x)))
1875 hlines))))
1876 (if (and (not spanning)
1877 (not org-export-prefer-native-exporter-for-tables))
1878 ;; We can use my own converter with HTML conversions
1879 (org-format-table-table-html lines)
1880 ;; Need to use the code generator in table.el, with the original text.
1881 (org-format-table-table-html-using-table-generate-source olines)))))
1883 (defvar org-table-number-fraction) ; defined in org-table.el
1884 (defun org-format-org-table-html (lines &optional splice no-css)
1885 "Format a table into HTML.
1886 LINES is a list of lines. Optional argument SPLICE means, do not
1887 insert header and surrounding <table> tags, just format the lines.
1888 Optional argument NO-CSS means use XHTML attributes instead of CSS
1889 for formatting. This is required for the DocBook exporter."
1890 (require 'org-table)
1891 ;; Get rid of hlines at beginning and end
1892 (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
1893 (setq lines (nreverse lines))
1894 (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
1895 (setq lines (nreverse lines))
1896 (when org-export-table-remove-special-lines
1897 ;; Check if the table has a marking column. If yes remove the
1898 ;; column and the special lines
1899 (setq lines (org-table-clean-before-export lines)))
1901 (let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
1902 (label (org-find-text-property-in-string 'org-label (car lines)))
1903 (forced-aligns (org-find-text-property-in-string 'org-forced-aligns
1904 (car lines)))
1905 (attributes (org-find-text-property-in-string 'org-attributes
1906 (car lines)))
1907 (html-table-tag (org-export-splice-attributes
1908 html-table-tag attributes))
1909 (head (and org-export-highlight-first-table-line
1910 (delq nil (mapcar
1911 (lambda (x) (string-match "^[ \t]*|-" x))
1912 (cdr lines)))))
1913 (nline 0) fnum nfields i (cnt 0)
1914 tbopen line fields html gr colgropen rowstart rowend
1915 ali align aligns n)
1916 (setq caption (and caption (org-html-do-expand caption)))
1917 (when (and forced-aligns org-table-clean-did-remove-column)
1918 (setq forced-aligns
1919 (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) forced-aligns)))
1920 (if splice (setq head nil))
1921 (unless splice (push (if head "<thead>" "<tbody>") html))
1922 (setq tbopen t)
1923 (while (setq line (pop lines))
1924 (catch 'next-line
1925 (if (string-match "^[ \t]*|-" line)
1926 (progn
1927 (unless splice
1928 (push (if head "</thead>" "</tbody>") html)
1929 (if lines (push "<tbody>" html) (setq tbopen nil)))
1930 (setq head nil) ;; head ends here, first time around
1931 ;; ignore this line
1932 (throw 'next-line t)))
1933 ;; Break the line into fields
1934 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
1935 (unless fnum (setq fnum (make-vector (length fields) 0)
1936 nfields (length fnum)))
1937 (setq nline (1+ nline) i -1
1938 rowstart (eval (car org-export-table-row-tags))
1939 rowend (eval (cdr org-export-table-row-tags)))
1940 (push (concat rowstart
1941 (mapconcat
1942 (lambda (x)
1943 (setq i (1+ i) ali (format "@@class%03d@@" i))
1944 (if (and (< i nfields) ; make sure no rogue line causes an error here
1945 (string-match org-table-number-regexp x))
1946 (incf (aref fnum i)))
1947 (cond
1948 (head
1949 (concat
1950 (format (car org-export-table-header-tags)
1951 "col" ali)
1953 (cdr org-export-table-header-tags)))
1954 ((and (= i 0) org-export-html-table-use-header-tags-for-first-column)
1955 (concat
1956 (format (car org-export-table-header-tags)
1957 "row" ali)
1959 (cdr org-export-table-header-tags)))
1961 (concat (format (car org-export-table-data-tags) ali)
1963 (cdr org-export-table-data-tags)))))
1964 fields "")
1965 rowend)
1966 html)))
1967 (unless splice (if tbopen (push "</tbody>" html)))
1968 (unless splice (push "</table>\n" html))
1969 (setq html (nreverse html))
1970 (unless splice
1971 ;; Put in col tags with the alignment (unfortunately often ignored...)
1972 (unless (car org-table-colgroup-info)
1973 (setq org-table-colgroup-info
1974 (cons :start (cdr org-table-colgroup-info))))
1975 (setq i 0)
1976 (push (mapconcat
1977 (lambda (x)
1978 (setq gr (pop org-table-colgroup-info)
1979 i (1+ i)
1980 align (if (assoc i forced-aligns)
1981 (cdr (assoc (cdr (assoc i forced-aligns))
1982 '(("l" . "left") ("r" . "right")
1983 ("c" . "center"))))
1984 (if (> (/ (float x) nline)
1985 org-table-number-fraction)
1986 "right" "left")))
1987 (push align aligns)
1988 (format (if no-css
1989 "%s<col align=\"%s\" />%s"
1990 "%s<col class=\"%s\" />%s")
1991 (if (memq gr '(:start :startend))
1992 (prog1
1993 (if colgropen
1994 "</colgroup>\n<colgroup>"
1995 "<colgroup>")
1996 (setq colgropen t))
1998 align
1999 (if (memq gr '(:end :startend))
2000 (progn (setq colgropen nil) "</colgroup>")
2001 "")))
2002 fnum "")
2003 html)
2004 (setq aligns (nreverse aligns))
2005 (if colgropen (setq html (cons (car html)
2006 (cons "</colgroup>" (cdr html)))))
2007 ;; Since the output of HTML table formatter can also be used in
2008 ;; DocBook document, we want to always include the caption to make
2009 ;; DocBook XML file valid.
2010 (push (format "<caption>%s</caption>" (or caption "")) html)
2011 (when label (push (format "<a name=\"%s\" id=\"%s\"></a>" (org-solidify-link-text label) (org-solidify-link-text label))
2012 html))
2013 (push html-table-tag html))
2014 (setq html (mapcar
2015 (lambda (x)
2016 (replace-regexp-in-string
2017 "@@class\\([0-9]+\\)@@"
2018 (lambda (txt)
2019 (if (not org-export-html-table-align-individual-fields)
2021 (setq n (string-to-number (match-string 1 txt)))
2022 (format (if no-css " align=\"%s\"" " class=\"%s\"")
2023 (or (nth n aligns) "left"))))
2025 html))
2026 (concat (mapconcat 'identity html "\n") "\n")))
2028 (defun org-export-splice-attributes (tag attributes)
2029 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
2030 (if (not attributes)
2032 (let (oldatt newatt)
2033 (setq oldatt (org-extract-attributes-from-string tag)
2034 tag (pop oldatt)
2035 newatt (cdr (org-extract-attributes-from-string attributes)))
2036 (while newatt
2037 (setq oldatt (plist-put oldatt (pop newatt) (pop newatt))))
2038 (if (string-match ">" tag)
2039 (setq tag
2040 (replace-match (concat (org-attributes-to-string oldatt) ">")
2041 t t tag)))
2042 tag)))
2044 (defun org-format-table-table-html (lines)
2045 "Format a table generated by table.el into HTML.
2046 This conversion does *not* use `table-generate-source' from table.el.
2047 This has the advantage that Org-mode's HTML conversions can be used.
2048 But it has the disadvantage, that no cell- or row-spanning is allowed."
2049 (let (line field-buffer
2050 (head org-export-highlight-first-table-line)
2051 fields html empty i)
2052 (setq html (concat html-table-tag "\n"))
2053 (while (setq line (pop lines))
2054 (setq empty "&nbsp;")
2055 (catch 'next-line
2056 (if (string-match "^[ \t]*\\+-" line)
2057 (progn
2058 (if field-buffer
2059 (progn
2060 (setq
2061 html
2062 (concat
2063 html
2064 "<tr>"
2065 (mapconcat
2066 (lambda (x)
2067 (if (equal x "") (setq x empty))
2068 (if head
2069 (concat
2070 (format (car org-export-table-header-tags) "col" "")
2072 (cdr org-export-table-header-tags))
2073 (concat (format (car org-export-table-data-tags) "") x
2074 (cdr org-export-table-data-tags))))
2075 field-buffer "\n")
2076 "</tr>\n"))
2077 (setq head nil)
2078 (setq field-buffer nil)))
2079 ;; Ignore this line
2080 (throw 'next-line t)))
2081 ;; Break the line into fields and store the fields
2082 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
2083 (if field-buffer
2084 (setq field-buffer (mapcar
2085 (lambda (x)
2086 (concat x "<br/>" (pop fields)))
2087 field-buffer))
2088 (setq field-buffer fields))))
2089 (setq html (concat html "</table>\n"))
2090 html))
2092 (defun org-format-table-table-html-using-table-generate-source (lines)
2093 "Format a table into html, using `table-generate-source' from table.el.
2094 This has the advantage that cell- or row-spanning is allowed.
2095 But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
2096 (require 'table)
2097 (with-current-buffer (get-buffer-create " org-tmp1 ")
2098 (erase-buffer)
2099 (insert (mapconcat 'identity lines "\n"))
2100 (goto-char (point-min))
2101 (if (not (re-search-forward "|[^+]" nil t))
2102 (error "Error processing table"))
2103 (table-recognize-table)
2104 (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
2105 (table-generate-source 'html " org-tmp2 ")
2106 (set-buffer " org-tmp2 ")
2107 (buffer-substring (point-min) (point-max))))
2109 (defun org-export-splice-style (style extra)
2110 "Splice EXTRA into STYLE, just before \"</style>\"."
2111 (if (and (stringp extra)
2112 (string-match "\\S-" extra)
2113 (string-match "</style>" style))
2114 (concat (substring style 0 (match-beginning 0))
2115 "\n" extra "\n"
2116 (substring style (match-beginning 0)))
2117 style))
2119 (defun org-html-handle-time-stamps (s)
2120 "Format time stamps in string S, or remove them."
2121 (catch 'exit
2122 (let (r b)
2123 (while (string-match org-maybe-keyword-time-regexp s)
2124 (or b (setq b (substring s 0 (match-beginning 0))))
2125 (setq r (concat
2126 r (substring s 0 (match-beginning 0))
2127 " <span class=\"timestamp-wrapper\">"
2128 (if (match-end 1)
2129 (format "<span class=\"timestamp-kwd\">%s </span>"
2130 (match-string 1 s)))
2131 (format " <span class=\"timestamp\">%s</span>"
2132 (substring
2133 (org-translate-time (match-string 3 s)) 1 -1))
2134 "</span>")
2135 s (substring s (match-end 0))))
2136 ;; Line break if line started and ended with time stamp stuff
2137 (if (not r)
2139 (setq r (concat r s))
2140 (unless (string-match "\\S-" (concat b s))
2141 (setq r (concat r "@<br/>")))
2142 r))))
2144 (defvar htmlize-buffer-places) ; from htmlize.el
2145 (defun org-export-htmlize-region-for-paste (beg end)
2146 "Convert the region to HTML, using htmlize.el.
2147 This is much like `htmlize-region-for-paste', only that it uses
2148 the settings define in the org-... variables."
2149 (let* ((htmlize-output-type org-export-htmlize-output-type)
2150 (htmlize-css-name-prefix org-export-htmlize-css-font-prefix)
2151 (htmlbuf (htmlize-region beg end)))
2152 (unwind-protect
2153 (with-current-buffer htmlbuf
2154 (buffer-substring (plist-get htmlize-buffer-places 'content-start)
2155 (plist-get htmlize-buffer-places 'content-end)))
2156 (kill-buffer htmlbuf))))
2158 ;;;###autoload
2159 (defun org-export-htmlize-generate-css ()
2160 "Create the CSS for all font definitions in the current Emacs session.
2161 Use this to create face definitions in your CSS style file that can then
2162 be used by code snippets transformed by htmlize.
2163 This command just produces a buffer that contains class definitions for all
2164 faces used in the current Emacs session. You can copy and paste the ones you
2165 need into your CSS file.
2167 If you then set `org-export-htmlize-output-type' to `css', calls to
2168 the function `org-export-htmlize-region-for-paste' will produce code
2169 that uses these same face definitions."
2170 (interactive)
2171 (require 'htmlize)
2172 (and (get-buffer "*html*") (kill-buffer "*html*"))
2173 (with-temp-buffer
2174 (let ((fl (face-list))
2175 (htmlize-css-name-prefix "org-")
2176 (htmlize-output-type 'css)
2177 f i)
2178 (while (setq f (pop fl)
2179 i (and f (face-attribute f :inherit)))
2180 (when (and (symbolp f) (or (not i) (not (listp i))))
2181 (insert (org-add-props (copy-sequence "1") nil 'face f))))
2182 (htmlize-region (point-min) (point-max))))
2183 (switch-to-buffer "*html*")
2184 (goto-char (point-min))
2185 (if (re-search-forward "<style" nil t)
2186 (delete-region (point-min) (match-beginning 0)))
2187 (if (re-search-forward "</style>" nil t)
2188 (delete-region (1+ (match-end 0)) (point-max)))
2189 (beginning-of-line 1)
2190 (if (looking-at " +") (replace-match ""))
2191 (goto-char (point-min)))
2193 (defun org-html-protect (s)
2194 "convert & to &amp;, < to &lt; and > to &gt;"
2195 (let ((start 0))
2196 (while (string-match "&" s start)
2197 (setq s (replace-match "&amp;" t t s)
2198 start (1+ (match-beginning 0))))
2199 (while (string-match "<" s)
2200 (setq s (replace-match "&lt;" t t s)))
2201 (while (string-match ">" s)
2202 (setq s (replace-match "&gt;" t t s)))
2203 ; (while (string-match "\"" s)
2204 ; (setq s (replace-match "&quot;" t t s)))
2208 (defun org-html-expand (string)
2209 "Prepare STRING for HTML export. Apply all active conversions.
2210 If there are links in the string, don't modify these."
2211 (let* ((re (concat org-bracket-link-regexp "\\|"
2212 (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
2213 m s l res)
2214 (if (string-match "^[ \t]*\\+-[-+]*\\+[ \t]*$" string)
2215 string
2216 (while (setq m (string-match re string))
2217 (setq s (substring string 0 m)
2218 l (match-string 0 string)
2219 string (substring string (match-end 0)))
2220 (push (org-html-do-expand s) res)
2221 (push l res))
2222 (push (org-html-do-expand string) res)
2223 (apply 'concat (nreverse res)))))
2225 (defun org-html-do-expand (s)
2226 "Apply all active conversions to translate special ASCII to HTML."
2227 (setq s (org-html-protect s))
2228 (if org-export-html-expand
2229 (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
2230 (setq s (replace-match "<\\1>" t nil s))))
2231 (if org-export-with-emphasize
2232 (setq s (org-export-html-convert-emphasize s)))
2233 (if org-export-with-special-strings
2234 (setq s (org-export-html-convert-special-strings s)))
2235 (if org-export-with-sub-superscripts
2236 (setq s (org-export-html-convert-sub-super s)))
2237 (if org-export-with-TeX-macros
2238 (let ((start 0) wd rep)
2239 (while (setq start (string-match "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?"
2240 s start))
2241 (if (get-text-property (match-beginning 0) 'org-protected s)
2242 (setq start (match-end 0))
2243 (setq wd (match-string 1 s))
2244 (if (setq rep (org-entity-get-representation wd 'html))
2245 (setq s (replace-match rep t t s))
2246 (setq start (+ start (length wd))))))))
2249 (defun org-export-html-convert-special-strings (string)
2250 "Convert special characters in STRING to HTML."
2251 (let ((all org-export-html-special-string-regexps)
2252 e a re rpl start)
2253 (while (setq a (pop all))
2254 (setq re (car a) rpl (cdr a) start 0)
2255 (while (string-match re string start)
2256 (if (get-text-property (match-beginning 0) 'org-protected string)
2257 (setq start (match-end 0))
2258 (setq string (replace-match rpl t nil string)))))
2259 string))
2261 (defun org-export-html-convert-sub-super (string)
2262 "Convert sub- and superscripts in STRING to HTML."
2263 (let (key c (s 0) (requireb (eq org-export-with-sub-superscripts '{})))
2264 (while (string-match org-match-substring-regexp string s)
2265 (cond
2266 ((and requireb (match-end 8)) (setq s (match-end 2)))
2267 ((get-text-property (match-beginning 2) 'org-protected string)
2268 (setq s (match-end 2)))
2270 (setq s (match-end 1)
2271 key (if (string= (match-string 2 string) "_") "sub" "sup")
2272 c (or (match-string 8 string)
2273 (match-string 6 string)
2274 (match-string 5 string))
2275 string (replace-match
2276 (concat (match-string 1 string)
2277 "<" key ">" c "</" key ">")
2278 t t string)))))
2279 (while (string-match "\\\\\\([_^]\\)" string)
2280 (setq string (replace-match (match-string 1 string) t t string)))
2281 string))
2283 (defun org-export-html-convert-emphasize (string)
2284 "Apply emphasis."
2285 (let ((s 0) rpl)
2286 (while (string-match org-emph-re string s)
2287 (if (not (equal
2288 (substring string (match-beginning 3) (1+ (match-beginning 3)))
2289 (substring string (match-beginning 4) (1+ (match-beginning 4)))))
2290 (setq s (match-beginning 0)
2292 (concat
2293 (match-string 1 string)
2294 (nth 2 (assoc (match-string 3 string) org-emphasis-alist))
2295 (match-string 4 string)
2296 (nth 3 (assoc (match-string 3 string)
2297 org-emphasis-alist))
2298 (match-string 5 string))
2299 string (replace-match rpl t t string)
2300 s (+ s (- (length rpl) 2)))
2301 (setq s (1+ s))))
2302 string))
2304 (defun org-open-par ()
2305 "Insert <p>, but first close previous paragraph if any."
2306 (org-close-par-maybe)
2307 (insert "\n<p>")
2308 (setq org-par-open t))
2309 (defun org-close-par-maybe ()
2310 "Close paragraph if there is one open."
2311 (when org-par-open
2312 (insert "</p>")
2313 (setq org-par-open nil)))
2314 (defun org-close-li (&optional type)
2315 "Close <li> if necessary."
2316 (org-close-par-maybe)
2317 (insert (if (equal type "d") "</dd>\n" "</li>\n")))
2319 (defvar in-local-list)
2320 (defvar local-list-indent)
2321 (defvar local-list-type)
2323 (defvar body-only) ; dynamically scoped into this.
2324 (defun org-html-level-start (level title umax with-toc head-count)
2325 "Insert a new level in HTML export.
2326 When TITLE is nil, just close all open levels."
2327 (org-close-par-maybe)
2328 (let* ((target (and title (org-get-text-property-any 0 'target title)))
2329 (extra-targets (and target
2330 (assoc target org-export-target-aliases)))
2331 (extra-class (and title (org-get-text-property-any 0 'html-container-class title)))
2332 (preferred (and target
2333 (cdr (assoc target org-export-preferred-target-alist))))
2334 (l org-level-max)
2335 snumber snu href suffix)
2336 (setq extra-targets (remove (or preferred target) extra-targets))
2337 (setq extra-targets
2338 (mapconcat (lambda (x)
2339 (setq x (org-solidify-link-text
2340 (if (org-uuidgen-p x) (concat "ID-" x) x)))
2341 (format "<a name=\"%s\" id=\"%s\"></a>"
2342 x x))
2343 extra-targets
2344 ""))
2345 (while (>= l level)
2346 (if (aref org-levels-open (1- l))
2347 (progn
2348 (org-html-level-close l umax)
2349 (aset org-levels-open (1- l) nil)))
2350 (setq l (1- l)))
2351 (when title
2352 ;; If title is nil, this means this function is called to close
2353 ;; all levels, so the rest is done only if title is given
2354 (when (string-match (org-re "\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title)
2355 (setq title (replace-match
2356 (if org-export-with-tags
2357 (save-match-data
2358 (concat
2359 "&nbsp;&nbsp;&nbsp;<span class=\"tag\">"
2360 (mapconcat
2361 (lambda (x)
2362 (format "<span class=\"%s\">%s</span>"
2363 (org-export-html-get-tag-class-name x)
2365 (org-split-string (match-string 1 title) ":")
2366 "&nbsp;")
2367 "</span>"))
2369 t t title)))
2370 (if (> level umax)
2371 (progn
2372 (if (aref org-levels-open (1- level))
2373 (progn
2374 (org-close-li)
2375 (if target
2376 (insert (format "<li id=\"%s\">" (org-solidify-link-text (or preferred target)))
2377 extra-targets title "<br/>\n")
2378 (insert "<li>" title "<br/>\n")))
2379 (aset org-levels-open (1- level) t)
2380 (org-close-par-maybe)
2381 (if target
2382 (insert (format "<ul>\n<li id=\"%s\">" (org-solidify-link-text (or preferred target)))
2383 extra-targets title "<br/>\n")
2384 (insert "<ul>\n<li>" title "<br/>\n"))))
2385 (aset org-levels-open (1- level) t)
2386 (setq snumber (org-section-number level)
2387 snu (replace-regexp-in-string "\\." "_" snumber))
2388 (setq level (+ level org-export-html-toplevel-hlevel -1))
2389 (if (and org-export-with-section-numbers (not body-only))
2390 (setq title (concat
2391 (format "<span class=\"section-number-%d\">%s</span>"
2392 level snumber)
2393 " " title)))
2394 (unless (= head-count 1) (insert "\n</div>\n"))
2395 (setq href (cdr (assoc (concat "sec-" snu) org-export-preferred-target-alist)))
2396 (setq suffix (org-solidify-link-text (or href snu)))
2397 (setq href (org-solidify-link-text (or href (concat "sec-" snu))))
2398 (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"
2399 suffix level (if extra-class (concat " " extra-class) "")
2400 level href
2401 extra-targets
2402 title level level suffix))
2403 (org-open-par)))))
2405 (defun org-export-html-get-tag-class-name (tag)
2406 "Turn tag into a valid class name.
2407 Replaces invalid characters with \"_\" and then prepends a prefix."
2408 (save-match-data
2409 (while (string-match "[^a-zA-Z0-9_]" tag)
2410 (setq tag (replace-match "_" t t tag))))
2411 (concat org-export-html-tag-class-prefix tag))
2413 (defun org-export-html-get-todo-kwd-class-name (kwd)
2414 "Turn todo keyword into a valid class name.
2415 Replaces invalid characters with \"_\" and then prepends a prefix."
2416 (save-match-data
2417 (while (string-match "[^a-zA-Z0-9_]" kwd)
2418 (setq kwd (replace-match "_" t t kwd))))
2419 (concat org-export-html-todo-kwd-class-prefix kwd))
2421 (defun org-html-level-close (level max-outline-level)
2422 "Terminate one level in HTML export."
2423 (if (<= level max-outline-level)
2424 (insert "</div>\n")
2425 (org-close-li)
2426 (insert "</ul>\n")))
2428 (provide 'org-html)
2430 ;; arch-tag: 8109d84d-eb8f-460b-b1a8-f45f3a6c7ea1
2431 ;;; org-html.el ends here