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