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