Upstream patches for integrating org-lprint and org-odt.
[org-mode/org-jambu.git] / lisp / org-html.el
blob40f202af005554d566ac3622e0f58ab20cd7c647
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.5
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 (require 'org-lprint)
36 (eval-when-compile (require 'cl) (require 'table) (require 'browse-url))
38 (declare-function org-id-find-id-file "org-id" (id))
39 (declare-function htmlize-region "ext:htmlize" (beg end))
41 (defgroup org-export-html nil
42 "Options specific for HTML export of Org-mode files."
43 :tag "Org Export HTML"
44 :group 'org-export)
46 (defcustom org-export-html-footnotes-section "<div id=\"footnotes\">
47 <h2 class=\"footnotes\">%s: </h2>
48 <div id=\"text-footnotes\">
50 </div>
51 </div>"
52 "Format for the footnotes section.
53 Should contain a two instances of %s. The first will be replaced with the
54 language-specific word for \"Footnotes\", the second one will be replaced
55 by the footnotes themselves."
56 :group 'org-export-html
57 :type 'string)
59 (defcustom org-export-html-footnote-format "<sup>%s</sup>"
60 "The format for the footnote reference.
61 %s will be replaced by the footnote reference itself."
62 :group 'org-export-html
63 :type 'string)
65 (defcustom org-export-html-coding-system nil
66 "Coding system for HTML export, defaults to `buffer-file-coding-system'."
67 :group 'org-export-html
68 :type 'coding-system)
70 (defcustom org-export-html-extension "html"
71 "The extension for exported HTML files."
72 :group 'org-export-html
73 :type 'string)
75 (defcustom org-export-html-xml-declaration
76 '(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
77 ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
78 "The extension for exported HTML files.
79 %s will be replaced with the charset of the exported file.
80 This may be a string, or an alist with export extensions
81 and corresponding declarations."
82 :group 'org-export-html
83 :type '(choice
84 (string :tag "Single declaration")
85 (repeat :tag "Dependent on extension"
86 (cons (string :tag "Extension")
87 (string :tag "Declaration")))))
89 (defcustom org-export-html-style-include-scripts t
90 "Non-nil means include the JavaScript snippets in exported HTML files.
91 The actual script is defined in `org-export-html-scripts' and should
92 not be modified."
93 :group 'org-export-html
94 :type 'boolean)
96 (defconst org-export-html-scripts
97 "<script type=\"text/javascript\">
98 <!--/*--><![CDATA[/*><!--*/
99 function CodeHighlightOn(elem, id)
101 var target = document.getElementById(id);
102 if(null != target) {
103 elem.cacheClassElem = elem.className;
104 elem.cacheClassTarget = target.className;
105 target.className = \"code-highlighted\";
106 elem.className = \"code-highlighted\";
109 function CodeHighlightOff(elem, id)
111 var target = document.getElementById(id);
112 if(elem.cacheClassElem)
113 elem.className = elem.cacheClassElem;
114 if(elem.cacheClassTarget)
115 target.className = elem.cacheClassTarget;
117 /*]]>*///-->
118 </script>"
119 "Basic JavaScript that is needed by HTML files produced by Org-mode.")
121 (defconst org-export-html-style-default
122 "<style type=\"text/css\">
123 <!--/*--><![CDATA[/*><!--*/
124 html { font-family: Times, serif; font-size: 12pt; }
125 .title { text-align: center; }
126 .todo { color: red; }
127 .done { color: green; }
128 .tag { background-color: #add8e6; font-weight:normal }
129 .target { }
130 .timestamp { color: #bebebe; }
131 .timestamp-kwd { color: #5f9ea0; }
132 .right {margin-left:auto; margin-right:0px; text-align:right;}
133 .left {margin-left:0px; margin-right:auto; text-align:left;}
134 .center {margin-left:auto; margin-right:auto; text-align:center;}
135 p.verse { margin-left: 3% }
136 pre {
137 border: 1pt solid #AEBDCC;
138 background-color: #F3F5F7;
139 padding: 5pt;
140 font-family: courier, monospace;
141 font-size: 90%;
142 overflow:auto;
144 table { border-collapse: collapse; }
145 td, th { vertical-align: top; }
146 th.right { text-align:center; }
147 th.left { text-align:center; }
148 th.center { text-align:center; }
149 td.right { text-align:right; }
150 td.left { text-align:left; }
151 td.center { text-align:center; }
152 dt { font-weight: bold; }
153 div.figure { padding: 0.5em; }
154 div.figure p { text-align: center; }
155 textarea { overflow-x: auto; }
156 .linenr { font-size:smaller }
157 .code-highlighted {background-color:#ffff00;}
158 .org-info-js_info-navigation { border-style:none; }
159 #org-info-js_console-label { font-size:10px; font-weight:bold;
160 white-space:nowrap; }
161 .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
162 font-weight:bold; }
163 /*]]>*/-->
164 </style>"
165 "The default style specification for exported HTML files.
166 Please use the variables `org-export-html-style' and
167 `org-export-html-style-extra' to add to this style. If you wish to not
168 have the default style included, customize the variable
169 `org-export-html-style-include-default'.")
171 (defcustom org-export-html-style-include-default t
172 "Non-nil means include the default style in exported HTML files.
173 The actual style is defined in `org-export-html-style-default' and should
174 not be modified. Use the variables `org-export-html-style' to add
175 your own style information."
176 :group 'org-export-html
177 :type 'boolean)
178 ;;;###autoload
179 (put 'org-export-html-style-include-default 'safe-local-variable 'booleanp)
181 (defcustom org-export-html-style ""
182 "Org-wide style definitions for exported HTML files.
184 This variable needs to contain the full HTML structure to provide a style,
185 including the surrounding HTML tags. If you set the value of this variable,
186 you should consider to include definitions for the following classes:
187 title, todo, done, timestamp, timestamp-kwd, tag, target.
189 For example, a valid value would be:
191 <style type=\"text/css\">
192 <![CDATA[
193 p { font-weight: normal; color: gray; }
194 h1 { color: black; }
195 .title { text-align: center; }
196 .todo, .timestamp-kwd { color: red; }
197 .done { color: green; }
199 </style>
201 If you'd like to refer to en external style file, use something like
203 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
205 As the value of this option simply gets inserted into the HTML <head> header,
206 you can \"misuse\" it to add arbitrary text to the header.
207 See also the variable `org-export-html-style-extra'."
208 :group 'org-export-html
209 :type 'string)
210 ;;;###autoload
211 (put 'org-export-html-style 'safe-local-variable 'stringp)
213 (defcustom org-export-html-style-extra ""
214 "Additional style information for HTML export.
215 The value of this variable is inserted into the HTML buffer right after
216 the value of `org-export-html-style'. Use this variable for per-file
217 settings of style information, and do not forget to surround the style
218 settings with <style>...</style> tags."
219 :group 'org-export-html
220 :type 'string)
221 ;;;###autoload
222 (put 'org-export-html-style-extra 'safe-local-variable 'stringp)
224 (defcustom org-export-html-mathjax-options
225 '((path "http://orgmode.org/mathjax/MathJax.js")
226 (scale "100")
227 (align "center")
228 (indent "2em")
229 (mathml nil))
230 "Options for MathJax setup.
232 path The path where to find MathJax
233 scale Scaling for the HTML-CSS backend, usually between 100 and 133
234 align How to align display math: left, center, or right
235 indent If align is not center, how far from the left/right side?
236 mathml Should a MathML player be used if available?
237 This is faster and reduces bandwidth use, but currently
238 sometimes has lower spacing quality. Therefore, the default is
239 nil. When browsers get better, this switch can be flipped.
241 You can also customize this for each buffer, using something like
243 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
244 :group 'org-export-html
245 :type '(list :greedy t
246 (list :tag "path (the path from where to load MathJax.js)"
247 (const :format " " path) (string))
248 (list :tag "scale (scaling for the displayed math)"
249 (const :format " " scale) (string))
250 (list :tag "align (alignment of displayed equations)"
251 (const :format " " align) (string))
252 (list :tag "indent (indentation with left or right alignment)"
253 (const :format " " indent) (string))
254 (list :tag "mathml (should MathML display be used is possible)"
255 (const :format " " mathml) (boolean))))
257 (defun org-export-html-mathjax-config (template options in-buffer)
258 "Insert the user setup into the matchjax template."
259 (let (name val (yes " ") (no "// ") x)
260 (mapc
261 (lambda (e)
262 (setq name (car e) val (nth 1 e))
263 (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
264 (setq val (car (read-from-string
265 (substring in-buffer (match-end 0))))))
266 (if (not (stringp val)) (setq val (format "%s" val)))
267 (if (string-match (concat "%" (upcase (symbol-name name))) template)
268 (setq template (replace-match val t t template))))
269 options)
270 (setq val (nth 1 (assq 'mathml options)))
271 (if (string-match (concat "\\<mathml:") in-buffer)
272 (setq val (car (read-from-string
273 (substring in-buffer (match-end 0))))))
274 ;; Exchange prefixes depending on mathml setting
275 (if (not val) (setq x yes yes no no x))
276 ;; Replace cookies to turn on or off the config/jax lines
277 (if (string-match ":MMLYES:" template)
278 (setq template (replace-match yes t t template)))
279 (if (string-match ":MMLNO:" template)
280 (setq template (replace-match no t t template)))
281 ;; Return the modified template
282 template))
284 (defcustom org-export-html-mathjax-template
285 "<script type=\"text/javascript\" src=\"%PATH\">
286 <!--/*--><![CDATA[/*><!--*/
287 MathJax.Hub.Config({
288 // Only one of the two following lines, depending on user settings
289 // First allows browser-native MathML display, second forces HTML/CSS
290 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
291 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
292 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
293 \"TeX/noUndefined.js\"],
294 tex2jax: {
295 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
296 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
297 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
298 ignoreClass: \"tex2jax_ignore\",
299 processEscapes: false,
300 processEnvironments: true,
301 preview: \"TeX\"
303 showProcessingMessages: true,
304 displayAlign: \"%ALIGN\",
305 displayIndent: \"%INDENT\",
307 \"HTML-CSS\": {
308 scale: %SCALE,
309 availableFonts: [\"STIX\",\"TeX\"],
310 preferredFont: \"TeX\",
311 webFont: \"TeX\",
312 imageFont: \"TeX\",
313 showMathMenu: true,
315 MMLorHTML: {
316 prefer: {
317 MSIE: \"MML\",
318 Firefox: \"MML\",
319 Opera: \"HTML\",
320 other: \"HTML\"
324 /*]]>*///-->
325 </script>"
326 "The MathJax setup for XHTML files."
327 :group 'org-export-html
328 :type 'string)
330 (defcustom org-export-html-tag-class-prefix ""
331 "Prefix to class names for TODO keywords.
332 Each tag gets a class given by the tag itself, with this prefix.
333 The default prefix is empty because it is nice to just use the keyword
334 as a class name. But if you get into conflicts with other, existing
335 CSS classes, then this prefix can be very useful."
336 :group 'org-export-html
337 :type 'string)
339 (defcustom org-export-html-todo-kwd-class-prefix ""
340 "Prefix to class names for TODO keywords.
341 Each TODO keyword gets a class given by the keyword itself, with this prefix.
342 The default prefix is empty because it is nice to just use the keyword
343 as a class name. But if you get into conflicts with other, existing
344 CSS classes, then this prefix can be very useful."
345 :group 'org-export-html
346 :type 'string)
348 (defcustom org-export-html-preamble t
349 "Non-nil means insert a preamble in HTML export.
351 When `t', insert a string as defined by one of the formatting
352 strings in `org-export-html-preamble-format'. When set to a
353 string, this string overrides `org-export-html-preamble-format'.
354 When set to a function, apply this function and insert the
355 returned string. The function takes the property list of export
356 options as its only argument.
358 Setting :html-preamble in publishing projects will take
359 precedence over this variable."
360 :group 'org-export-html
361 :type '(choice (const :tag "No preamble" nil)
362 (const :tag "Default preamble" t)
363 (string :tag "Custom formatting string")
364 (function :tag "Function (must return a string)")))
366 (defcustom org-export-html-preamble-format
367 '(("en" "<h1 class=\"title\">%t</h1>"))
368 "The format for the HTML preamble.
370 %t stands for the title.
372 If you need to use a \"%\" character, you need to escape it
373 like that: \"%%\"."
374 :group 'org-export-html
375 :type 'string)
377 (defcustom org-export-html-postamble 'auto
378 "Non-nil means insert a postamble in HTML export.
380 When `t', insert a string as defined by the formatting string in
381 `org-export-html-postamble-format'. When set to a string, this
382 string overrides `org-export-html-postamble-format'. When set to
383 'auto, discard `org-export-html-postamble-format' and honor
384 `org-export-author/email/creator-info' variables. When set to a
385 function, apply this function and insert the returned string.
386 The function takes the property list of export options as its
387 only argument.
389 Setting :html-postamble in publishing projects will take
390 precedence over this variable."
391 :group 'org-export-html
392 :type '(choice (const :tag "No postamble" nil)
393 (const :tag "Auto preamble" 'auto)
394 (const :tag "Default formatting string" t)
395 (string :tag "Custom formatting string")
396 (function :tag "Function (must return a string)")))
398 (defcustom org-export-html-postamble-format
399 '(("en" "<p class=\"author\">Author: %a (%e)</p>
400 <p class=\"date\">Date: %d</p>
401 <p class=\"creator\">Generated by %c</p>
402 <p class=\"xhtml-validation\">%v</p>
404 "The format for the HTML postamble.
406 %a stands for the author.
407 %e stands for the email(s).
408 %d stands for the date.
409 %c will be replaced by information about Org/Emacs.
410 %v will be replaced by `org-export-html-validation-link'.
412 If you need to use a \"%\" character, you need to escape it
413 like that: \"%%\"."
414 :group 'org-export-html
415 :type 'string)
417 (defcustom org-export-html-home/up-format
418 "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
419 <a accesskey=\"h\" href=\"%s\"> UP </a>
421 <a accesskey=\"H\" href=\"%s\"> HOME </a>
422 </div>"
423 "Snippet used to insert the HOME and UP links.
424 This is a format string, the first %s will receive the UP link,
425 the second the HOME link. If both `org-export-html-link-up' and
426 `org-export-html-link-home' are empty, the entire snippet will be
427 ignored."
428 :group 'org-export-html
429 :type 'string)
431 (defcustom org-export-html-toplevel-hlevel 2
432 "The <H> level for level 1 headings in HTML export.
433 This is also important for the classes that will be wrapped around headlines
434 and outline structure. If this variable is 1, the top-level headlines will
435 be <h1>, and the corresponding classes will be outline-1, section-number-1,
436 and outline-text-1. If this is 2, all of these will get a 2 instead.
437 The default for this variable is 2, because we use <h1> for formatting the
438 document title."
439 :group 'org-export-html
440 :type 'string)
442 (defcustom org-export-html-link-org-files-as-html t
443 "Non-nil means make file links to `file.org' point to `file.html'.
444 When org-mode is exporting an org-mode file to HTML, links to
445 non-html files are directly put into a href tag in HTML.
446 However, links to other Org-mode files (recognized by the
447 extension `.org.) should become links to the corresponding html
448 file, assuming that the linked org-mode file will also be
449 converted to HTML.
450 When nil, the links still point to the plain `.org' file."
451 :group 'org-export-html
452 :type 'boolean)
454 (defcustom org-export-html-inline-images 'maybe
455 "Non-nil means inline images into exported HTML pages.
456 This is done using an <img> tag. When nil, an anchor with href is used to
457 link to the image. If this option is `maybe', then images in links with
458 an empty description will be inlined, while images with a description will
459 be linked only."
460 :group 'org-export-html
461 :type '(choice (const :tag "Never" nil)
462 (const :tag "Always" t)
463 (const :tag "When there is no description" maybe)))
465 (defcustom org-export-html-inline-image-extensions
466 '("png" "jpeg" "jpg" "gif" "svg")
467 "Extensions of image files that can be inlined into HTML."
468 :group 'org-export-html
469 :type '(repeat (string :tag "Extension")))
471 (defcustom org-export-html-table-tag
472 "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
473 "The HTML tag that is used to start a table.
474 This must be a <table> tag, but you may change the options like
475 borders and spacing."
476 :group 'org-export-html
477 :type 'string)
479 (defcustom org-export-table-header-tags '("<th scope=\"%s\"%s>" . "</th>")
480 "The opening tag for table header fields.
481 This is customizable so that alignment options can be specified.
482 The first %s will be filled with the scope of the field, either row or col.
483 The second %s will be replaced by a style entry to align the field.
484 See also the variable `org-export-html-table-use-header-tags-for-first-column'.
485 See also the variable `org-export-html-table-align-individual-fields'."
486 :group 'org-export-tables
487 :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
489 (defcustom org-export-table-data-tags '("<td%s>" . "</td>")
490 "The opening tag for table data fields.
491 This is customizable so that alignment options can be specified.
492 The first %s will be filled with the scope of the field, either row or col.
493 The second %s will be replaced by a style entry to align the field.
494 See also the variable `org-export-html-table-align-individual-fields'."
495 :group 'org-export-tables
496 :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
498 (defcustom org-export-table-row-tags '("<tr>" . "</tr>")
499 "The opening tag for table data fields.
500 This is customizable so that alignment options can be specified.
501 Instead of strings, these can be Lisp forms that will be evaluated
502 for each row in order to construct the table row tags. During evaluation,
503 the variable `head' will be true when this is a header line, nil when this
504 is a body line. And the variable `nline' will contain the line number,
505 starting from 1 in the first header line. For example
507 (setq org-export-table-row-tags
508 (cons '(if head
509 \"<tr>\"
510 (if (= (mod nline 2) 1)
511 \"<tr class=\\\"tr-odd\\\">\"
512 \"<tr class=\\\"tr-even\\\">\"))
513 \"</tr>\"))
515 will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
516 :group 'org-export-tables
517 :type '(cons
518 (choice :tag "Opening tag"
519 (string :tag "Specify")
520 (sexp))
521 (choice :tag "Closing tag"
522 (string :tag "Specify")
523 (sexp))))
525 (defcustom org-export-html-table-align-individual-fields t
526 "Non-nil means attach style attributes for alignment to each table field.
527 When nil, alignment will only be specified in the column tags, but this
528 is ignored by some browsers (like Firefox, Safari). Opera does it right
529 though."
530 :group 'org-export-tables
531 :type 'boolean)
533 (defcustom org-export-html-table-use-header-tags-for-first-column nil
534 "Non-nil means format column one in tables with header tags.
535 When nil, also column one will use data tags."
536 :group 'org-export-tables
537 :type 'boolean)
539 (defcustom org-export-html-validation-link
540 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
541 "Link to HTML validation service."
542 :group 'org-export-html
543 :type 'string)
545 (defcustom org-export-html-with-timestamp nil
546 "If non-nil, write timestamp into the exported HTML text.
547 If non-nil, write `org-export-html-html-helper-timestamp' into the
548 exported HTML text. Otherwise, the buffer will just be saved to
549 a file."
550 :group 'org-export-html
551 :type 'boolean)
553 (defcustom org-export-html-html-helper-timestamp
554 "<br/><br/><hr/><p><!-- hhmts start --> <!-- hhmts end --></p>\n"
555 "The HTML tag used as timestamp delimiter for HTML-helper-mode."
556 :group 'org-export-html
557 :type 'string)
559 (defcustom org-export-html-protect-char-alist
560 '(("&" . "&amp;")
561 ("<" . "&lt;")
562 (">" . "&gt;"))
563 "Alist of characters to be converted by `org-html-protect'."
564 :type '(repeat (cons (string :tag "Character")
565 (string :tag "HTML equivalent"))))
567 (defgroup org-export-htmlize nil
568 "Options for processing examples with htmlize.el."
569 :tag "Org Export Htmlize"
570 :group 'org-export-html)
572 (defcustom org-export-htmlize-output-type 'inline-css
573 "Output type to be used by htmlize when formatting code snippets.
574 Choices are `css', to export the CSS selectors only, or `inline-css', to
575 export the CSS attribute values inline in the HTML. We use as default
576 `inline-css', in order to make the resulting HTML self-containing.
578 However, this will fail when using Emacs in batch mode for export, because
579 then no rich font definitions are in place. It will also not be good if
580 people with different Emacs setup contribute HTML files to a website,
581 because the fonts will represent the individual setups. In these cases,
582 it is much better to let Org/Htmlize assign classes only, and to use
583 a style file to define the look of these classes.
584 To get a start for your css file, start Emacs session and make sure that
585 all the faces you are interested in are defined, for example by loading files
586 in all modes you want. Then, use the command
587 \\[org-export-htmlize-generate-css] to extract class definitions."
588 :group 'org-export-htmlize
589 :type '(choice (const css) (const inline-css)))
591 (defcustom org-export-htmlize-css-font-prefix "org-"
592 "The prefix for CSS class names for htmlize font specifications."
593 :group 'org-export-htmlize
594 :type 'string)
596 (defcustom org-export-htmlized-org-css-url nil
597 "URL pointing to a CSS file defining text colors for htmlized Emacs buffers.
598 Normally when creating an htmlized version of an Org buffer, htmlize will
599 create CSS to define the font colors. However, this does not work when
600 converting in batch mode, and it also can look bad if different people
601 with different fontification setup work on the same website.
602 When this variable is non-nil, creating an htmlized version of an Org buffer
603 using `org-export-as-org' will remove the internal CSS section and replace it
604 with a link to this URL."
605 :group 'org-export-htmlize
606 :type '(choice
607 (const :tag "Keep internal css" nil)
608 (string :tag "URL or local href")))
610 ;;; Hooks
612 (defvar org-export-html-after-blockquotes-hook nil
613 "Hook run during HTML export, after blockquote, verse, center are done.")
615 (defvar org-export-html-final-hook nil
616 "Hook run at the end of HTML export, in the new buffer.")
618 ;;; HTML export
620 (defun org-export-html-preprocess (parameters)
621 "Convert LaTeX fragments to images."
622 (when (and org-current-export-file
623 (plist-get parameters :LaTeX-fragments))
624 (org-format-latex
625 (concat "ltxpng/" (file-name-sans-extension
626 (file-name-nondirectory
627 org-current-export-file)))
628 org-current-export-dir nil "Creating LaTeX image %s"
629 nil nil
630 (cond
631 ((eq (plist-get parameters :LaTeX-fragments) 'verbatim) 'verbatim)
632 ((eq (plist-get parameters :LaTeX-fragments) 'mathjax ) 'mathjax)
633 ((eq (plist-get parameters :LaTeX-fragments) t ) 'mathjax)
634 ((eq (plist-get parameters :LaTeX-fragments) 'dvipng ) 'dvipng)
635 (t nil))))
636 (goto-char (point-min))
637 (let (label l1)
638 (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t)
639 (org-if-unprotected-at (match-beginning 1)
640 (setq label (match-string 1))
641 (save-match-data
642 (if (string-match "\\`[a-z]\\{1,10\\}:\\(.+\\)" label)
643 (setq l1 (substring label (match-beginning 1)))
644 (setq l1 label)))
645 (replace-match (format "[[#%s][%s]]" label l1) t t)))))
647 (defvar html-table-tag nil) ; dynamically scoped into this.
649 ;;; org-html-cvt-link-fn
650 (defconst org-html-cvt-link-fn
652 "Function to convert link URLs to exportable URLs.
653 Takes two arguments, TYPE and PATH.
654 Returns exportable url as (TYPE PATH), or nil to signal that it
655 didn't handle this case.
656 Intended to be locally bound around a call to `org-export-as-html'." )
658 (defun org-html-cvt-org-as-html (opt-plist type path)
659 "Convert an org filename to an equivalent html filename.
660 If TYPE is not file, just return `nil'.
661 See variable `org-export-html-link-org-files-as-html'"
663 (save-match-data
664 (and
665 org-export-html-link-org-files-as-html
666 (string= type "file")
667 (string-match "\\.org$" path)
668 (progn
669 (list
670 "file"
671 (concat
672 (substring path 0 (match-beginning 0))
674 (plist-get opt-plist :html-extension)))))))
677 ;;; org-html-should-inline-p
678 (defun org-html-should-inline-p (filename descp)
679 "Return non-nil if link FILENAME should be inlined.
680 The decision to inline the FILENAME link is based on the current
681 settings. DESCP is the boolean of whether there was a link
682 description. See variables `org-export-html-inline-images' and
683 `org-export-html-inline-image-extensions'."
684 (declare (special
685 org-export-html-inline-images
686 org-export-html-inline-image-extensions))
687 (and (or (eq t org-export-html-inline-images)
688 (and org-export-html-inline-images (not descp)))
689 (org-file-image-p
690 filename org-export-html-inline-image-extensions)))
692 ;;; org-html-format-org-link
693 (defun org-html-format-org-link (opt-plist type-1 path fragment desc attr
694 descp)
695 "Make an HTML link.
696 OPT-PLIST is an options list.
697 TYPE is the device-type of the link (THIS://foo.html)
698 PATH is the path of the link (http://THIS#locationx)
699 FRAGMENT is the fragment part of the link, if any (foo.html#THIS)
700 DESC is the link description, if any.
701 ATTR is a string of other attributes of the a element.
702 MAY-INLINE-P allows inlining it as an image."
703 (declare (special org-lprint-par-open))
704 (when (string= type-1 "coderef")
705 (setq attr
706 (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
707 fragment fragment)))
708 (save-match-data
709 (let* ((may-inline-p
710 (and (member type-1 '("http" "https" "file"))
711 (org-html-should-inline-p path descp)
712 (not fragment)))
713 (type (if (equal type-1 "id") "file" type-1))
714 (filename path)
715 ;;First pass. Just sanity stuff.
716 (components-1
717 (cond
718 ((string= type "file")
719 (list
720 type
721 ;;Substitute just if original path was absolute.
722 ;;(Otherwise path must remain relative)
723 (if (file-name-absolute-p path)
724 (concat "file://" (expand-file-name path))
725 path)))
726 ((string= type "")
727 (list nil path))
728 (t (list type path))))
730 ;;Second pass. Components converted so they can refer
731 ;;to a remote site.
732 (components-2
734 (and org-html-cvt-link-fn
735 (apply org-html-cvt-link-fn
736 opt-plist components-1))
737 (apply #'org-html-cvt-org-as-html
738 opt-plist components-1)
739 components-1))
740 (type (first components-2))
741 (thefile (second components-2)))
744 ;;Third pass. Build final link except for leading type
745 ;;spec.
746 (cond
747 ((or
748 (not type)
749 (string= type "http")
750 (string= type "https")
751 (string= type "file")
752 (string= type "coderef"))
753 (if fragment
754 (setq thefile (concat thefile "#" fragment))))
756 (t))
758 ;;Final URL-build, for all types.
759 (setq thefile
760 (let
761 ((str (org-export-html-format-href thefile)))
762 (if (and type (not (or (string= "file" type)
763 (string= "coderef" type))))
764 (concat type ":" str)
765 str)))
767 (if may-inline-p
768 (org-export-html-format-image thefile)
769 (org-lprint-format
770 'LINK (org-export-html-format-desc desc) thefile attr)))))
772 (defun org-html-format-inline-image (desc)
773 ;; FIXME: alt text missing here?
774 (org-html-format-tags "<img src=\"%s\" alt=\"\"/>" "" desc))
776 (defvar org-lprint-link-description-is-image)
778 (defun org-export-html-format-href (s)
779 "Make sure the S is valid as a href reference in an XHTML document."
780 (save-match-data
781 (let ((start 0))
782 (while (string-match "&" s start)
783 (setq start (+ (match-beginning 0) 3)
784 s (replace-match "&amp;" t t s)))))
787 (defun org-export-html-format-desc (s)
788 "Make sure the S is valid as a description in a link."
789 (if (and s (not (get-text-property 1 'org-protected s)))
790 (save-match-data
791 (org-xml-encode-org-text s))
794 (defun org-export-html-format-image (src)
795 "Create image tag with source and attributes."
796 (save-match-data
797 (if (string-match "^ltxpng/" src)
798 (format "<img src=\"%s\" alt=\"%s\"/>"
799 src (org-find-text-property-in-string 'org-latex-src src))
800 (let* ((caption (org-find-text-property-in-string 'org-caption src))
801 (attr (org-find-text-property-in-string 'org-attributes src))
802 (label (org-find-text-property-in-string 'org-label src))
803 (caption (and caption (org-xml-encode-org-text caption)))
804 (img (format "<img src=\"%s\"%s />"
806 (if (string-match "\\<alt=" (or attr ""))
807 (concat " " attr )
808 (concat " " attr " alt=\"" src "\""))))
809 (extra (concat
810 (and label
811 (format "id=\"%s\" " (org-solidify-link-text label)))
812 "class=\"figure\"")))
813 (if caption
814 (with-temp-buffer
815 (with-org-lprint-preserve-paragraph-state
816 (insert
817 (org-lprint-format
818 '("<div %s>" . "\n</div>")
819 (concat
820 (org-lprint-format '("\n<p>" . "</p>") img)
821 (org-lprint-format '("\n<p>" . "</p>") caption))
822 extra)))
823 (buffer-string))
824 img)))))
826 (defun org-export-html-get-bibliography ()
827 "Find bibliography, cut it out and return it."
828 (catch 'exit
829 (let (beg end (cnt 1) bib)
830 (save-excursion
831 (goto-char (point-min))
832 (when (re-search-forward "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t)
833 (setq beg (match-beginning 0))
834 (while (re-search-forward "</?div\\>" nil t)
835 (setq cnt (+ cnt (if (string= (match-string 0) "<div") +1 -1)))
836 (when (= cnt 0)
837 (and (looking-at ">") (forward-char 1))
838 (setq bib (buffer-substring beg (point)))
839 (delete-region beg (point))
840 (throw 'exit bib))))
841 nil))))
843 (defun org-html-format-table (lines olines)
844 (let ((org-html-format-table-no-css nil))
845 (org-lprint-format-table lines olines)))
847 ;; Following variable is defined for native tables i.e., when
848 ;; `org-lprint-table-is-styled' evals to t.
849 (defvar org-html-format-table-no-css)
850 (defvar org-table-number-regexp) ; defined in org-table.el
852 (defun org-format-table-html (lines olines &optional no-css)
853 "Find out which HTML converter to use and return the HTML code.
854 NO-CSS is passed to the exporter."
855 (let* ((org-lprint-backend 'html)
856 (org-lprint-entity-control-callbacks-alist
857 (org-lprint-get 'ENTITY-CONTROL))
858 (org-lprint-entity-format-callbacks-alist
859 (org-lprint-get 'ENTITY-FORMAT))
860 (org-html-format-table-no-css no-css))
861 (org-lprint-format-table lines olines)))
863 (defun org-format-org-table-html (lines &optional splice no-css)
864 ;; This routine might get called outside of org-export-as-html. For
865 ;; example, this could happen as part of org-table-export or as part
866 ;; of org-export-as-docbook. Explicitly bind the parser callback to
867 ;; the html ones for the duration of the call.
868 (let* ((org-lprint-backend 'html)
869 (org-lprint-entity-control-callbacks-alist
870 (org-lprint-get 'ENTITY-CONTROL))
871 (org-lprint-entity-format-callbacks-alist
872 (org-lprint-get 'ENTITY-FORMAT))
873 (org-html-format-table-no-css no-css))
874 (org-lprint-format-org-table lines splice)))
876 (defun org-export-splice-attributes (tag attributes)
877 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
878 (if (not attributes)
880 (let (oldatt newatt)
881 (setq oldatt (org-extract-attributes-from-string tag)
882 tag (pop oldatt)
883 newatt (cdr (org-extract-attributes-from-string attributes)))
884 (while newatt
885 (setq oldatt (plist-put oldatt (pop newatt) (pop newatt))))
886 (if (string-match ">" tag)
887 (setq tag
888 (replace-match (concat (org-attributes-to-string oldatt) ">")
889 t t tag)))
890 tag)))
892 (defun org-format-table-table-html (lines)
893 (let* ((org-lprint-get 'html)
894 (org-lprint-entity-control-callbacks-alist
895 (org-lprint-get 'ENTITY-CONTROL))
896 (org-lprint-entity-format-callbacks-alist
897 (org-lprint-get 'ENTITY-FORMAT)))
898 (org-lprint-format-table-table lines)))
900 (defun org-export-splice-style (style extra)
901 "Splice EXTRA into STYLE, just before \"</style>\"."
902 (if (and (stringp extra)
903 (string-match "\\S-" extra)
904 (string-match "</style>" style))
905 (concat (substring style 0 (match-beginning 0))
906 "\n" extra "\n"
907 (substring style (match-beginning 0)))
908 style))
910 (defvar htmlize-buffer-places) ; from htmlize.el
911 (defun org-export-htmlize-region-for-paste (beg end)
912 "Convert the region to HTML, using htmlize.el.
913 This is much like `htmlize-region-for-paste', only that it uses
914 the settings define in the org-... variables."
915 (let* ((htmlize-output-type org-export-htmlize-output-type)
916 (htmlize-css-name-prefix org-export-htmlize-css-font-prefix)
917 (htmlbuf (htmlize-region beg end)))
918 (unwind-protect
919 (with-current-buffer htmlbuf
920 (buffer-substring (plist-get htmlize-buffer-places 'content-start)
921 (plist-get htmlize-buffer-places 'content-end)))
922 (kill-buffer htmlbuf))))
924 ;;;###autoload
925 (defun org-export-htmlize-generate-css ()
926 "Create the CSS for all font definitions in the current Emacs session.
927 Use this to create face definitions in your CSS style file that can then
928 be used by code snippets transformed by htmlize.
929 This command just produces a buffer that contains class definitions for all
930 faces used in the current Emacs session. You can copy and paste the ones you
931 need into your CSS file.
933 If you then set `org-export-htmlize-output-type' to `css', calls to
934 the function `org-export-htmlize-region-for-paste' will produce code
935 that uses these same face definitions."
936 (interactive)
937 (require 'htmlize)
938 (and (get-buffer "*html*") (kill-buffer "*html*"))
939 (with-temp-buffer
940 (let ((fl (face-list))
941 (htmlize-css-name-prefix "org-")
942 (htmlize-output-type 'css)
943 f i)
944 (while (setq f (pop fl)
945 i (and f (face-attribute f :inherit)))
946 (when (and (symbolp f) (or (not i) (not (listp i))))
947 (insert (org-add-props (copy-sequence "1") nil 'face f))))
948 (htmlize-region (point-min) (point-max))))
949 (switch-to-buffer "*html*")
950 (goto-char (point-min))
951 (if (re-search-forward "<style" nil t)
952 (delete-region (point-min) (match-beginning 0)))
953 (if (re-search-forward "</style>" nil t)
954 (delete-region (1+ (match-end 0)) (point-max)))
955 (beginning-of-line 1)
956 (if (looking-at " +") (replace-match ""))
957 (goto-char (point-min)))
959 (defvar body-only) ; dynamically scoped into this.
960 (defun org-export-html-get-tag-class-name (tag)
961 "Turn tag into a valid class name.
962 Replaces invalid characters with \"_\" and then prepends a prefix."
963 (save-match-data
964 (while (string-match "[^a-zA-Z0-9_]" tag)
965 (setq tag (replace-match "_" t t tag))))
966 (concat org-export-html-tag-class-prefix tag))
968 (defun org-export-html-get-todo-kwd-class-name (kwd)
969 "Turn todo keyword into a valid class name.
970 Replaces invalid characters with \"_\" and then prepends a prefix."
971 (save-match-data
972 (while (string-match "[^a-zA-Z0-9_]" kwd)
973 (setq kwd (replace-match "_" t t kwd))))
974 (concat org-export-html-todo-kwd-class-prefix kwd))
976 (defun org-html-end-export ()
977 ;; insert the table of contents
978 (when (and org-export-with-toc (not body-only) org-lprint-toc)
979 (org-html-insert-toc org-lprint-toc))
981 ;; remove empty paragraphs
982 (goto-char (point-min))
983 (while (re-search-forward "<p>[ \r\n\t]*</p>" nil t)
984 (replace-match ""))
986 ;; Convert whitespace place holders
987 (goto-char (point-min))
988 (let (beg end n)
989 (while (setq beg (next-single-property-change (point) 'org-whitespace))
990 (setq n (get-text-property beg 'org-whitespace)
991 end (next-single-property-change beg 'org-whitespace))
992 (goto-char beg)
993 (delete-region beg end)
994 (insert (format "<span style=\"visibility:hidden;\">%s</span>"
995 (make-string n ?x)))))
997 ;; Remove empty lines at the beginning of the file.
998 (goto-char (point-min))
999 (when (looking-at "\\s-+\n") (replace-match ""))
1001 ;; Remove display properties
1002 (remove-text-properties (point-min) (point-max) '(display t))
1004 ;; kill temporary buffers
1005 (when org-lprint-footnote-buffer
1006 (kill-buffer org-lprint-footnote-buffer))
1008 ;; Run the hook
1009 (run-hooks 'org-export-html-final-hook))
1011 ;;;_ , toc (rename these routines)
1012 (defun org-html-format-toc-entry (snumber todo headline tags href)
1013 (setq headline (concat
1014 (and org-export-with-section-numbers
1015 (concat snumber " "))
1016 headline
1017 (and tags
1018 (concat
1019 (org-lprint-format 'SPACES 3)
1020 (org-lprint-format 'FONTIFY tags "tag")))))
1021 (when todo
1022 (setq headline (org-lprint-format 'FONTIFY headline "todo")))
1023 (org-lprint-format 'LINK headline (concat "#" href)))
1025 (defun org-html-format-toc-item (toc-entry level org-last-level)
1026 (when (> level org-last-level)
1027 (let ((cnt (- level org-last-level)))
1028 (while (>= (setq cnt (1- cnt)) 0)
1029 (org-lprint-begin 'LIST 'unordered)
1030 (org-lprint-begin 'LIST-ITEM 'unordered))))
1031 (when (< level org-last-level)
1032 (let ((cnt (- org-last-level level)))
1033 (while (>= (setq cnt (1- cnt)) 0)
1034 (org-lprint-end-list-item)
1035 (org-lprint-end 'LIST 'unordered))))
1037 (org-lprint-end-list-item)
1038 (org-lprint-begin 'LIST-ITEM 'unordered)
1039 (insert toc-entry))
1041 (defun org-html-begin-toc (lang-specific-heading)
1042 (org-lprint-insert-tag "<div id=\"table-of-contents\">")
1043 (insert
1044 (org-lprint-format 'HEADING lang-specific-heading
1045 (or (org-lprint-get 'TOPLEVEL-HLEVEL) 1)))
1046 (org-lprint-insert-tag "<div id=\"text-table-of-contents\">")
1047 (org-lprint-begin 'LIST 'unordered)
1048 (org-lprint-begin 'LIST-ITEM 'unordered))
1050 (defun org-html-end-toc ()
1051 (while (> org-last-level (1- org-min-level))
1052 (setq org-last-level (1- org-last-level))
1053 (org-lprint-end-list-item)
1054 (org-lprint-end 'LIST 'unordered))
1055 (org-lprint-insert-tag "</div>")
1056 (org-lprint-insert-tag "</div>")
1058 ;; cleanup empty list items in toc
1059 (while (re-search-backward "<li>[ \r\n\t]*</li>\n?" (point-min) t)
1060 (replace-match "")))
1062 ;;;_. postamble
1064 ;;;_ org-newhtml.el
1065 ;;;_. preamble
1066 ;;;_. obsolete
1067 ;;;_. maybe
1068 ;;;_. hacks (to be documented)
1070 ;; Refer `org-lprint-char-styles'
1072 ;;;_. user-specific
1073 ;;;_ , custom settings
1074 ;;;_ . potential custom settings
1075 ;;;_ , interactive commands
1077 ;;;###autoload
1078 (defun org-export-as-html-and-open (arg)
1079 "Export the outline as HTML and immediately open it with a browser.
1080 If there is an active region, export only the region.
1081 The prefix ARG specifies how many levels of the outline should become
1082 headlines. The default is 3. Lower levels will become bulleted lists."
1083 (interactive "P")
1084 (org-lprint-and-open "html" "html" arg))
1086 ;;;###autoload
1087 (defun org-export-as-html-batch ()
1088 "Call the function `org-lprint-batch'.
1089 This function can be used in batch processing as:
1090 emacs --batch
1091 --load=$HOME/lib/emacs/org.el
1092 --eval \"(setq org-export-headline-levels 2)\"
1093 --visit=MyFile --funcall org-export-as-html-batch"
1094 (org-lprint-batch "html"))
1096 ;;;###autoload
1097 (defun org-export-as-html-to-buffer (arg)
1098 "Call `org-lprint-to-buffer` with output to a temporary buffer.
1099 No file is created. The prefix ARG is passed through to `org-lprint-to-buffer'."
1100 (interactive "P")
1101 (org-lprint-to-buffer "html" arg))
1103 ;;;###autoload
1104 (defun org-replace-region-by-html (beg end)
1105 "Assume the current region has org-mode syntax, and convert it to HTML.
1106 This can be used in any buffer. For example, you could write an
1107 itemized list in org-mode syntax in an HTML buffer and then use this
1108 command to convert it."
1109 (interactive "r")
1110 (org-replace-region-by "html" beg end))
1112 ;;;###autoload
1113 (defun org-export-region-as-html (beg end &optional body-only buffer)
1114 "Convert region from BEG to END in `org-mode' buffer to HTML.
1115 If prefix arg BODY-ONLY is set, omit file header, footer, and table of
1116 contents, and only produce the region of converted text, useful for
1117 cut-and-paste operations.
1118 If BUFFER is a buffer or a string, use/create that buffer as a target
1119 of the converted HTML. If BUFFER is the symbol `string', return the
1120 produced HTML as a string and leave not buffer behind. For example,
1121 a Lisp program could call this function in the following way:
1123 (setq html (org-export-region-as-html beg end t 'string))
1125 When called interactively, the output buffer is selected, and shown
1126 in a window. A non-interactive call will only return the buffer."
1127 (interactive "r\nP")
1128 (org-lprint-region "html" beg end body-only buffer))
1130 ;;; org-export-as-html
1131 ;;;###autoload
1132 (defun org-export-as-html (arg &optional hidden ext-plist
1133 to-buffer body-only pub-dir)
1134 "Export the outline as a pretty HTML file.
1135 Use `org-lprint' internally to perform the actual export. This
1136 routine merely binds the TARGET-BACKEND and NATIVE-BACKEND args
1137 of `org-lprint' to \"html\"."
1138 (interactive "P")
1139 (org-lprint "html" "html" arg hidden ext-plist to-buffer body-only pub-dir))
1141 ;;;_. parser
1142 ;;;_ , initialization
1143 (defvar org-html-entity-control-callbacks-alist
1144 `((EXPORT
1145 . (org-html-begin-export org-html-end-export))
1146 (DOCUMENT-CONTENT
1147 . (org-html-begin-document-content org-html-end-document-content))
1148 (DOCUMENT-BODY
1149 . (org-html-begin-document-body org-html-end-document-body))
1150 (TOC
1151 . (org-html-begin-toc org-html-end-toc))
1152 (ENVIRONMENT
1153 . (org-html-begin-environment org-html-end-environment))
1154 (FOOTNOTE-DEFINITION
1155 . (org-html-begin-footnote-definition org-html-end-footnote-definition))
1156 (TABLE
1157 . (org-html-begin-table org-html-end-table))
1158 (TABLE-ROWGROUP
1159 . (org-html-begin-table-rowgroup org-html-end-table-rowgroup))
1160 (LIST
1161 . (org-html-begin-list org-html-end-list))
1162 (LIST-ITEM
1163 . (org-html-begin-list-item org-html-end-list-item))
1164 (OUTLINE
1165 . (org-html-begin-outline org-html-end-outline))
1166 (OUTLINE-TEXT
1167 . (org-html-begin-outline-text org-html-end-outline-text))
1168 (PARAGRAPH
1169 . (org-html-begin-paragraph org-html-end-paragraph)))
1170 "Alist of control callbacks registered with the exporter.
1171 Each element is of the form (ENTITY . (BEGIN-ENTITY-FUNCTION
1172 END-ENTITY-FUNCTION)). ENTITY is one of PARAGRAPH, LIST etc as
1173 seen above. BEGIN-ENTITY-FUNCTION and END-ENTITY-FUNCTION are
1174 functions that get called when the exporter needs to begin or end
1175 an entity in the currently exported file. The signatures of
1176 these callbacks are specific to the ENTITY being emitted. These
1177 callbacks always get called with exported file as the current
1178 buffer and need to insert the appropriate tags into the current
1179 buffer. For example, `org-html-begin-paragraph' inserts <p> and
1180 `org-html-end-paragraph' inserts </p> in to the current buffer.
1181 These callbacks are invoked via `org-lprint-begin' and
1182 `org-lprint-end'.")
1184 (defvar org-html-entity-format-callbacks-alist
1185 `((EXTRA-TARGETS . org-lprint-format-extra-targets)
1186 (ORG-TAGS . org-lprint-format-org-tags)
1187 (SECTION-NUMBER . org-lprint-format-section-number)
1188 (HEADLINE . org-html-format-headline)
1189 (TOC-ENTRY . org-html-format-toc-entry)
1190 (TOC-ITEM . org-html-format-toc-item)
1191 (TAGS . org-html-format-tags)
1192 (SPACES . org-html-format-spaces)
1193 (TABS . org-html-format-tabs)
1194 (LINE-BREAK . org-html-format-line-break)
1195 (FONTIFY . org-html-format-fontify)
1196 (TODO . org-lprint-format-todo)
1197 (ORG-LINK . org-html-format-org-link)
1198 (LINK . org-html-format-link)
1199 (INLINE-IMAGE . org-html-format-inline-image)
1200 (HEADING . org-html-format-heading)
1201 (ANCHOR . org-html-format-anchor)
1202 (TABLE . org-html-format-table)
1203 (TABLE-ROW . org-html-format-table-row)
1204 (TABLE-CELL . org-html-format-table-cell)
1205 (FOOTNOTES-SECTION . org-html-format-footnotes-section)
1206 (FOOTNOTE-REFERENCE . org-html-format-footnote-reference)
1207 (HORIZONTAL-LINE . org-html-format-horizontal-line)
1208 (LINE . org-html-format-line)
1209 (COMMENT . org-html-format-comment)
1210 (ORG-ENTITY . org-html-format-org-entity))
1211 "Alist of format callbacks registered with the exporter.
1212 Each element is of the form (ENTITY . ENTITY-FORMAT-FUNCTION).
1213 ENTITY is one of LINE, HEADING, COMMENT, LINK, TABLE-ROW etc as
1214 seen above. ENTITY-FORMAT-FUNCTION is a functions that gets
1215 called when the exporter needs to format a string in `org-mode'
1216 buffer in a backend specific way. The signatures of the
1217 formatting callback is specific to the ENTITY being passed in.
1218 These callbacks always need to encode the incoming entity in
1219 backend specific way and return the same. These callbacks do not
1220 make any modifications to the exporter file. For example,
1221 `org-html-format-table-row' encloses incoming entity in <tr>
1222 </tr> tags and returns it.")
1224 ;;;_ , callbacks
1225 ;;;_ . control callbacks
1226 ;;;_ , generic
1229 ;;;_ , document body
1230 (defun org-html-begin-document-body (opt-plist)
1231 (let ((link-up (and (plist-get opt-plist :link-up)
1232 (string-match "\\S-" (plist-get opt-plist :link-up))
1233 (plist-get opt-plist :link-up)))
1234 (link-home (and (plist-get opt-plist :link-home)
1235 (string-match "\\S-" (plist-get opt-plist :link-home))
1236 (plist-get opt-plist :link-home))))
1237 (insert "\n<body>")
1238 (org-lprint-insert-tag "<div id=\"content\">")
1239 (insert "\n"
1240 (or (and (or link-up link-home)
1241 (format org-export-html-home/up-format
1242 (or link-up link-home)
1243 (or link-home link-up))) "")
1244 "\n"))
1245 (org-html-insert-preamble opt-plist))
1247 (defun org-html-end-document-body (opt-plist)
1248 (org-html-insert-postamble opt-plist)
1249 (unless body-only
1250 (org-lprint-insert-tag "</div>")
1251 (insert "\n</body>")))
1253 ;;;_ , document content
1254 (defun org-html-begin-document-content (opt-plist)
1255 (let* ((language (plist-get opt-plist :language))
1256 (charset (or (and coding-system-for-write
1257 (fboundp 'coding-system-get)
1258 (coding-system-get coding-system-for-write
1259 'mime-charset))
1260 "iso-8859-1"))
1261 (style (concat (if (plist-get opt-plist :style-include-default)
1262 org-export-html-style-default)
1263 (plist-get opt-plist :style)
1264 (plist-get opt-plist :style-extra)
1265 "\n"
1266 (if (plist-get opt-plist :style-include-scripts)
1267 org-export-html-scripts)))
1268 (mathjax
1269 (if (or (eq (plist-get opt-plist :LaTeX-fragments) 'mathjax)
1270 (and org-export-have-math
1271 (eq (plist-get opt-plist :LaTeX-fragments) t)))
1273 (org-export-html-mathjax-config
1274 org-export-html-mathjax-template
1275 org-export-html-mathjax-options
1276 (or (plist-get opt-plist :mathjax) "")) "")))
1277 (insert (format
1279 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
1280 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
1281 <html xmlns=\"http://www.w3.org/1999/xhtml\"
1282 lang=\"%s\" xml:lang=\"%s\">
1283 <head>
1284 <title>%s</title>
1285 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
1286 <meta name=\"generator\" content=\"Org-mode\"/>
1287 <meta name=\"generated\" content=\"%s\"/>
1288 <meta name=\"author\" content=\"%s\"/>
1289 <meta name=\"description\" content=\"%s\"/>
1290 <meta name=\"keywords\" content=\"%s\"/>
1293 </head>
1295 (format
1296 (or (and (stringp org-export-html-xml-declaration)
1297 org-export-html-xml-declaration)
1298 (cdr (assoc (plist-get opt-plist :html-extension)
1299 org-export-html-xml-declaration))
1300 (cdr (assoc "html" org-export-html-xml-declaration))
1303 charset)
1304 language language
1305 (plist-get opt-plist :title)
1306 charset
1307 (plist-get opt-plist :effective-date)
1308 (plist-get opt-plist :author)
1309 (plist-get opt-plist :description)
1310 (plist-get opt-plist :keywords)
1311 style
1312 mathjax))))
1314 (defun org-html-end-document-content ()
1315 (insert "\n</html>\n"))
1317 ;;;_ , outline
1318 (defun org-html-begin-outline (level1 snumber title tags
1319 target extra-targets extra-class)
1320 (let* ((class (format "outline-%d" level1))
1321 (class (if extra-class (concat class " " extra-class) class))
1322 (id (format "outline-container-%s"
1323 (org-lprint-suffix-from-snumber snumber)))
1324 (extra (concat (when id (format " id=\"%s\"" id))
1325 (when class (format " class=\"%s\"" class)))))
1326 (org-lprint-insert-tag "<div%s>" extra)
1327 (insert
1328 (org-lprint-format 'HEADING
1329 (org-lprint-format
1330 'HEADLINE title extra-targets tags snumber level1)
1331 level1 target))))
1333 (defun org-html-end-outline ()
1334 (org-lprint-insert-tag "</div>"))
1336 ;;;_ , outline-text
1337 (defun org-html-begin-outline-text (level1 snumber extra-class)
1338 (let* ((class (format "outline-text-%d" level1))
1339 (class (if extra-class (concat class " " extra-class) class))
1340 (id (format "text-%s" (org-lprint-suffix-from-snumber snumber)))
1341 (extra (concat (when id (format " id=\"%s\"" id))
1342 (when class (format " class=\"%s\"" class)))))
1343 (org-lprint-insert-tag "<div%s>" extra)))
1345 (defun org-html-end-outline-text ()
1346 (org-lprint-insert-tag "</div>"))
1348 ;;;_ , paragraph
1349 (defun org-html-begin-paragraph (&optional style)
1350 (let* ((class (cdr (assoc style '((footnote . "footnote")
1351 (verse . nil)))))
1352 (extra (if class (format " class=\"%s\"" class) "")))
1353 (org-lprint-insert-tag "<p%s>" extra)))
1355 (defun org-html-end-paragraph ()
1356 (insert "</p>"))
1358 ;;;_ , environment
1359 (defun org-html-format-environment (style beg-end)
1360 (assert (memq style '(blockquote center verse fixedwidth quote native)) t)
1361 (case style
1362 (blockquote
1363 (case beg-end
1364 (BEGIN
1365 (org-lprint-end-paragraph)
1366 (insert "<blockquote>\n")
1367 (org-lprint-begin-paragraph))
1368 (END
1369 (org-lprint-end-paragraph)
1370 (insert "\n</blockquote>\n")
1371 (org-lprint-begin-paragraph))))
1372 (verse
1373 (case beg-end
1374 (BEGIN
1375 (org-lprint-end-paragraph)
1376 (insert "\n<p class=\"verse\">\n")
1377 (setq org-lprint-par-open t))
1378 (END
1379 (insert "</p>\n")
1380 (setq org-lprint-par-open nil)
1381 (org-lprint-begin-paragraph))))
1382 (center
1383 (case beg-end
1384 (BEGIN
1385 (org-lprint-end-paragraph)
1386 (insert "\n<div style=\"text-align: center\">")
1387 (org-lprint-begin-paragraph))
1388 (END
1389 (org-lprint-end-paragraph)
1390 (insert "\n</div>")
1391 (org-lprint-begin-paragraph))))
1392 (fixedwidth
1393 (case beg-end
1394 (BEGIN
1395 (org-lprint-end-paragraph)
1396 (insert "<pre class=\"example\">\n"))
1397 (END
1398 (insert "</pre>\n")
1399 (org-lprint-begin-paragraph))))
1400 (quote
1401 (case beg-end
1402 (BEGIN
1403 (org-lprint-end-paragraph)
1404 (insert "<pre>"))
1405 (END
1406 (insert "</pre>\n")
1407 (org-lprint-begin-paragraph))))
1408 (native
1409 (case beg-end
1410 (BEGIN (org-lprint-end-paragraph))
1411 (END (org-lprint-begin-paragraph))))
1412 (t (error "Unknown environment %s" style))))
1414 (defun org-html-begin-environment (style)
1415 (org-html-format-environment style 'BEGIN))
1417 (defun org-html-end-environment (style)
1418 (org-html-format-environment style 'END))
1420 ;;;_ , list
1422 (defun org-html-begin-list (ltype &optional arg1)
1423 (setq ltype (or (org-lprint-html-list-type-to-canonical-list-type ltype)
1424 ltype))
1426 (case ltype
1427 (ordered (let ((extra (if arg1 (format " start=\"%d\"" arg1) "")))
1428 (org-lprint-insert-tag "<ol%s>" extra)))
1429 (unordered (org-lprint-insert-tag "<ul>"))
1430 (description (org-lprint-insert-tag "<dl>"))
1431 (t (error "Unknown list type: %s" ltype))))
1433 (defun org-html-end-list (ltype)
1434 (setq ltype (or (org-lprint-html-list-type-to-canonical-list-type ltype)
1435 ltype))
1437 (org-lprint-insert-tag
1438 (case ltype
1439 (ordered "</ol>")
1440 (unordered "</ul>")
1441 (description "</dl>")
1442 (t (error "Unknown list type: %s" ltype)))))
1444 (defun org-html-begin-list-item (ltype &optional arg headline)
1445 (setq ltype (or (org-lprint-html-list-type-to-canonical-list-type ltype)
1446 ltype))
1447 (case ltype
1448 (ordered
1449 (assert (not headline) t)
1450 (let* ((counter arg)
1451 (extra (if counter (format " value=\"%s\"" counter) "")))
1452 (org-lprint-insert-tag "<li%s>" extra)))
1453 (unordered
1454 (let* ((id arg)
1455 (extra (if id (format " id=\"%s\"" id) "")))
1456 (org-lprint-insert-tag "<li%s>" extra)
1457 (when headline
1458 (insert headline (org-lprint-format 'LINE-BREAK) "\n"))))
1459 (description
1460 (assert (not headline) t)
1461 (let* ((desc-tag (or arg "(no term)")))
1462 (insert
1463 (org-html-format-tags '("<dt>" . "</dt>") desc-tag))
1464 (org-lprint-insert-tag "<dd>")))
1465 (t (error "Unknown list type"))))
1467 (defun org-html-end-list-item (ltype)
1468 (setq ltype (or (org-lprint-html-list-type-to-canonical-list-type ltype)
1469 ltype))
1470 (case ltype
1471 (ordered (org-lprint-insert-tag "</li>"))
1472 (unordered (org-lprint-insert-tag "</li>"))
1473 (description (org-lprint-insert-tag "</dd>"))
1474 (t (error "Unknown list type"))))
1476 ;;;_ , table
1478 (defun org-html-begin-table-rowgroup (&optional is-header-row)
1479 (when org-lprint-table-rowgrp-open
1480 (org-lprint-end 'TABLE-ROWGROUP))
1481 (org-lprint-insert-tag (if is-header-row "<thead>" "<tbody>"))
1482 (setq org-lprint-table-rowgrp-open t)
1483 (setq org-lprint-table-cur-rowgrp-is-hdr is-header-row))
1485 (defun org-html-end-table-rowgroup ()
1486 (when org-lprint-table-rowgrp-open
1487 (setq org-lprint-table-rowgrp-open nil)
1488 (org-lprint-insert-tag
1489 (if org-lprint-table-cur-rowgrp-is-hdr "</thead>" "</tbody>"))))
1491 (defun org-html-begin-table (caption label attributes)
1492 (let ((html-table-tag
1493 (org-export-splice-attributes html-table-tag attributes)))
1494 (when label
1495 (setq html-table-tag
1496 (org-export-splice-attributes
1497 html-table-tag
1498 (format "id=\"%s\"" (org-solidify-link-text label)))))
1499 (org-lprint-insert-tag html-table-tag))
1501 ;; Since the output of HTML table formatter can also be used in
1502 ;; DocBook document, we want to always include the caption to make
1503 ;; DocBook XML file valid.
1504 (insert (format "<caption>%s</caption>" (or caption "")) "\n"))
1506 (defun org-html-end-table ()
1507 (when org-lprint-table-is-styled
1508 (goto-char org-lprint-table-begin-marker)
1509 (setq org-lprint-table-begin-marker nil)
1511 (let ((c -1) gr colgropen)
1512 (insert
1513 (mapconcat
1514 (lambda (x)
1515 (incf c)
1516 (setq gr (pop org-table-colgroup-info))
1518 (concat
1519 (if (memq gr '(:start :startend))
1520 (prog1
1521 (if colgropen
1522 "</colgroup>\n<colgroup>"
1523 "<colgroup>")
1524 (setq colgropen t))
1527 (let* ((align (aref org-lprint-table-colalign-vector c))
1528 (alignspec (if org-html-format-table-no-css
1529 " align=\"%s\"" " class=\"%s\""))
1530 (extra (format alignspec align)))
1531 (format "<col%s />" extra))
1533 (if (memq gr '(:end :startend))
1534 (progn (setq colgropen nil) "</colgroup>")
1535 "")))
1536 org-lprint-table-num-numeric-items-per-column ""))
1538 (if colgropen (insert "</colgroup>")))
1540 ;; fill style attributes for table cells
1541 (while (re-search-forward "@@class\\([0-9]+\\)@@" nil t)
1542 (let ((c (string-to-number (match-string 1))))
1543 (replace-match
1544 (if org-export-html-table-align-individual-fields
1545 (format (if org-html-format-table-no-css " align=\"%s\""
1546 " class=\"%s\"")
1547 (or (aref org-lprint-table-colalign-vector c) "left")) "")
1548 t t)))
1549 (goto-char (point-max)))
1550 (org-lprint-insert-tag "</table>\n"))
1552 (defun org-html-format-table-row (row)
1553 (org-html-format-tags
1554 (cons (eval (car org-export-table-row-tags))
1555 (eval (cdr org-export-table-row-tags))) row))
1557 (defun org-html-format-table-cell (text r c)
1558 (let ((cell-style-cookie (or (and org-lprint-table-is-styled
1559 (format "@@class%03d@@" c)) "")))
1560 (cond
1561 (org-lprint-table-cur-rowgrp-is-hdr
1562 (org-html-format-tags
1563 org-export-table-header-tags text "col" cell-style-cookie))
1564 ((and (= c 0) org-export-html-table-use-header-tags-for-first-column)
1565 (org-html-format-tags
1566 org-export-table-header-tags text "row" cell-style-cookie))
1568 (org-html-format-tags
1569 org-export-table-data-tags text cell-style-cookie)))))
1571 ;;;_ , footnote definition
1572 (defun org-html-begin-footnote-definition (n)
1573 (org-lprint-begin-paragraph 'footnote)
1574 (insert
1575 (format
1576 (format org-export-html-footnote-format
1577 "<a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a>")
1578 n n n)))
1580 (defun org-html-end-footnote-definition (n)
1581 (org-lprint-end-paragraph))
1583 ;;;_ . format callbacks
1585 ;;;_ , spaces
1586 (defun org-html-format-spaces (n)
1587 (let ((space (or (and org-lprint-encode-pending "\\nbsp") "&nbsp;")) out)
1588 (while (> n 0)
1589 (setq out (concat out space))
1590 (setq n (1- n))) out))
1592 ;;;_ , tabs
1593 (defun org-html-format-tabs (&optional n)
1594 (ignore))
1596 ;;;_ , line break
1597 (defun org-html-format-line-break ()
1598 (org-html-format-tags "<br/>" ""))
1600 ;;;_ , horizontal line
1601 (defun org-html-format-horizontal-line ()
1602 (concat "\n" "<hr/>" "\n"))
1604 ;;;_ , line
1606 (defun org-html-format-line (line)
1607 (case org-lprint-dyn-current-environment
1608 ((quote fixedwidth) (concat (org-xml-encode-plain-text line) "\n"))
1609 (t (concat line "\n"))))
1611 (defun org-html-format-comment (fmt &rest args)
1612 (let ((comment (apply 'format fmt args)))
1613 (format "\n<!-- %s -->\n" comment)))
1615 ;;;_ , character styles
1616 (defun org-html-format-fontify (text style &optional id)
1617 (let (class extra how)
1618 (cond
1619 ((eq style 'underline)
1620 (setq extra " style=\"text-decoration:underline;\"" ))
1621 ((setq how (cdr (assoc style
1622 '((bold . ("<b>" . "</b>"))
1623 (emphasis . ("<i>" . "</i>"))
1624 (code . ("<code>" . "</code>"))
1625 (verbatim . ("<code>" . "</code>"))
1626 (strike . ("<del>" . "</del>"))
1627 (subscript . ("<sub>" . "</sub>"))
1628 (superscript . ("<sup>" . "</sup>")))))))
1629 ((listp style)
1630 (setq class (mapconcat 'identity style " ")))
1631 ((stringp style)
1632 (setq class style))
1633 (t (error "Unknown style %S" style)))
1635 (setq extra (concat (when class (format " class=\"%s\"" class))
1636 (when id (format " id=\"%s\"" id))
1637 extra))
1638 (org-html-format-tags
1639 (or how '("<span%s>" . "</span>")) text extra)))
1641 ;;;_ , link
1642 (defun org-html-format-link (text href &optional extra)
1643 (let ((extra (concat (format " href=\"%s\"" href)
1644 (and extra (concat " " extra)))))
1645 (org-html-format-tags '("<a%s>" . "</a>") text extra)))
1647 ;;;_ , heading
1648 (defun org-html-format-heading (text level &optional id)
1649 (let* ((extra (concat (when id (format " id=\"%s\"" id)))))
1650 (concat (format "<h%d%s>" level extra) text (format "</h%d>" level))))
1652 ;;;_ , headline
1653 (defun org-html-format-headline (title extra-targets tags
1654 &optional snumber level)
1655 (concat
1656 (org-lprint-format 'EXTRA-TARGETS extra-targets)
1657 (concat (org-lprint-format 'SECTION-NUMBER snumber level) " ")
1658 title
1659 (and tags (concat (org-lprint-format 'SPACES 3)
1660 (org-lprint-format 'ORG-TAGS tags)))))
1662 ;;;_ , anchor
1663 (defun org-html-format-anchor (text name &optional class)
1664 (let* ((id name)
1665 (extra (concat
1666 (when name (format " name=\"%s\"" name))
1667 (when id (format " id=\"%s\"" id))
1668 (when class (format " class=\"%s\"" class)))))
1669 (org-html-format-tags '("<a%s>" . "</a>") text extra)))
1673 ;;;_ , target
1674 ;;;_ , footnote reference
1675 (defun org-html-format-footnote-reference (n def refcnt)
1676 (let ((extra (if (= refcnt 1) "" (format ".%d" refcnt))))
1677 (format org-export-html-footnote-format
1678 (format
1679 "<a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a>"
1680 n extra n n))))
1682 ;;;_ , footnotes section
1683 (defun org-html-format-footnotes-section (section-name definitions)
1684 (if (not definitions) ""
1685 (format org-export-html-footnotes-section section-name definitions)))
1687 ;;;_ , org entity
1688 (defun org-html-format-org-entity (wd)
1689 (org-entity-get-representation wd 'html))
1691 ;;;_ , image
1692 ;;;_ , generic
1694 (defun org-html-format-tags (tag text &rest args)
1695 (let ((prefix (when org-lprint-encode-pending "@"))
1696 (suffix (when org-lprint-encode-pending "@")))
1697 (apply 'org-lprint-format-tags tag text prefix suffix args)))
1699 ;;;_ . maintenance callbacks
1700 ;;;_ , init method
1701 ;;;_ , save method
1702 ;;;_ , cleanup method
1703 ;;;_ . get callback
1704 (defun org-html-get (what &optional opt-plist)
1705 (case what
1706 (BACKEND 'html)
1707 (INIT-METHOD nil)
1708 (SAVE-METHOD nil)
1709 (CLEANUP-METHOD nil)
1710 (OTHER-BACKENDS
1711 '("etext" "html" "html10" "mediawiki" "pdf" "sdw" "sdw3" "sdw4"
1712 "text" "text10" "odt" "vor" "vor4"))
1713 (CONVERT-METHOD org-export-convert-process)
1714 (EXPORT-DIR (org-export-directory :html opt-plist))
1715 (FILE-NAME-EXTENSION (plist-get opt-plist :html-extension))
1716 (EXPORT-BUFFER-NAME "*Org HTML Export*")
1717 (ENTITY-CONTROL org-html-entity-control-callbacks-alist)
1718 (ENTITY-FORMAT org-html-entity-format-callbacks-alist)
1719 (TOPLEVEL-HLEVEL org-export-html-toplevel-hlevel)
1720 (SPECIAL-STRING-REGEXPS org-export-html-special-string-regexps)
1721 (CODING-SYSTEM-FOR-WRITE org-export-html-coding-system)
1722 (CODING-SYSTEM-FOR-SAVE org-export-html-coding-system)
1723 (t (error "Unknown property: %s" what))))
1725 ;;;_ , coding system
1726 (defun org-html-get-coding-system-for-write ()
1727 (or org-export-html-coding-system
1728 (and (boundp 'buffer-file-coding-system) buffer-file-coding-system)))
1730 (defun org-html-get-coding-system-for-save ()
1731 (or org-export-html-coding-system
1732 (and (boundp 'buffer-file-coding-system) buffer-file-coding-system)))
1734 ;;;_. newhtml (non-parser & misc)
1735 (defun org-html-insert-toc (toc)
1736 ;; locate where toc needs to be inserted
1737 (goto-char (point-min))
1738 (cond
1739 ((or (re-search-forward "<p>\\s-*\\[TABLE-OF-CONTENTS\\]\\s-*</p>" nil t)
1740 (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t))
1741 (goto-char (match-beginning 0))
1742 (replace-match "")
1743 (insert toc))
1744 (org-lprint-dyn-first-heading-pos
1745 (goto-char org-lprint-dyn-first-heading-pos)
1746 (when (looking-at "\\s-*</p>")
1747 (goto-char (match-end 0))
1748 (insert "\n"))
1749 (insert toc))
1750 (t (ignore))))
1752 (defun org-html-insert-preamble (opt-plist)
1753 (when (plist-get opt-plist :html-preamble)
1754 (let ((html-pre (plist-get opt-plist :html-preamble))
1755 (title (plist-get opt-plist :title))
1756 (date (plist-get opt-plist :effective-date))
1757 (author (plist-get opt-plist :author))
1758 (lang-words (plist-get opt-plist :lang-words))
1759 (email (plist-get opt-plist :email)))
1760 (cond ((stringp html-pre)
1761 (insert
1762 (format-spec html-pre `((?t . ,title) (?a . ,author)
1763 (?d . ,date) (?e . ,email)))))
1764 ((functionp html-pre)
1765 (funcall html-pre opt-plist))
1767 (insert
1768 (format-spec
1769 (or (cadr (assoc (nth 0 lang-words)
1770 org-export-html-preamble-format))
1771 (cadr (assoc "en" org-export-html-preamble-format)))
1772 `((?t . ,title) (?a . ,author)
1773 (?d . ,date) (?e . ,email)))))))))
1775 (defun org-html-insert-postamble (opt-plist)
1776 (when org-lprint-footnote-definitions
1777 (insert
1778 (org-lprint-format
1779 'FOOTNOTES-SECTION (nth 4 (plist-get opt-plist :lang-words))
1780 (mapconcat (lambda (x) (cdr x))
1781 (nreverse org-lprint-footnote-definitions) "\n"))))
1782 (let ((bib (org-export-html-get-bibliography)))
1783 (when bib
1784 (insert "\n" bib "\n")))
1786 ;; export html postamble
1787 (unless body-only
1788 (let* ((html-post (plist-get opt-plist :html-postamble))
1789 (date (plist-get opt-plist :effective-date))
1790 (author (plist-get opt-plist :author))
1791 (email (plist-get opt-plist :email))
1792 (lang-words (plist-get opt-plist :lang-words))
1793 (html-validation-link (or org-export-html-validation-link ""))
1794 (email
1795 (mapconcat (lambda(e)
1796 (format "<a href=\"mailto:%s\">%s</a>" e e))
1797 (split-string email ",+ *")
1798 ", "))
1799 (creator-info
1800 (concat "Org version " org-version " with Emacs version "
1801 (number-to-string emacs-major-version))))
1802 (when (plist-get opt-plist :html-postamble)
1803 (cond ((stringp html-post)
1804 (insert "<div id=\"postamble\">\n")
1805 (insert (format-spec html-post
1806 `((?a . ,author) (?e . ,email)
1807 (?d . ,date) (?c . ,creator-info)
1808 (?v . ,html-validation-link))))
1809 (insert "</div>"))
1810 ((functionp html-post)
1811 (funcall html-post opt-plist))
1812 ((eq html-post 'auto)
1813 ;; fall back on default postamble
1814 (insert "<div id=\"postamble\">\n")
1815 (when (plist-get opt-plist :time-stamp-file)
1816 (insert "<p class=\"date\">" (nth 2 lang-words) ": " date "</p>\n"))
1817 (when (and (plist-get opt-plist :author-info) author)
1818 (insert "<p class=\"author\">" (nth 1 lang-words) ": " author "</p>\n"))
1819 (when (and (plist-get opt-plist :email-info) email)
1820 (insert "<p class=\"email\">" email "</p>\n"))
1821 (when (plist-get opt-plist :creator-info)
1822 (insert "<p class=\"creator\">"
1823 (concat "Org version " org-version " with Emacs version "
1824 (number-to-string emacs-major-version) "</p>\n")))
1825 (insert html-validation-link "\n</div>"))
1827 (insert "<div id=\"postamble\">\n")
1828 (insert (format-spec
1829 (or (cadr (assoc (nth 0 lang-words)
1830 org-export-html-postamble-format))
1831 (cadr (assoc "en" org-export-html-postamble-format)))
1832 `((?a . ,author) (?e . ,email)
1833 (?d . ,date) (?c . ,creator-info)
1834 (?v . ,html-validation-link))))
1835 (insert "</div>"))))))
1837 (if org-export-html-with-timestamp
1838 (insert org-export-html-html-helper-timestamp)))
1840 ;;;_. preprocessor
1841 ;;;_. postamble
1843 ;;;_. backward compatibility
1845 (provide 'org-html)
1847 ;; arch-tag: 8109d84d-eb8f-460b-b1a8-f45f3a6c7ea1
1848 ;;; org-html.el ends here