org-e-html: Fix misc. bugs
[org-mode.git] / contrib / lisp / org-e-html.el
blob6c23d8b7464bdab319a18afba66ddcc691bd5451
1 ;;; org-e-html.el --- HTML Back-End For Org Export Engine
3 ;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
5 ;; Author: Jambunathan K <kjambunathan at gmail dot com>
6 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ;;; Commentary:
23 ;; This library implements a HTML back-end for Org generic exporter.
25 ;; To test it, run
27 ;; M-: (org-export-to-buffer 'e-html "*Test e-HTML*") RET
29 ;; in an org-mode buffer then switch to the buffer to see the HTML
30 ;; export. See contrib/lisp/org-export.el for more details on how
31 ;; this exporter works.
33 ;;; Code:
35 ;;; org-e-html.el
36 ;;; Dependencies
38 (require 'org-export)
39 (require 'format-spec)
40 (eval-when-compile (require 'cl) (require 'table))
44 ;;; Function Declarations
46 (declare-function org-element-get-property "org-element" (property element))
47 (declare-function org-element-normalize-string "org-element" (s))
49 (declare-function org-export-data "org-export" (data info))
50 (declare-function org-export-directory "org-export" (type plist))
51 (declare-function org-export-expand-macro "org-export" (macro info))
52 (declare-function org-export-first-sibling-p "org-export" (headline info))
53 (declare-function org-export-footnote-first-reference-p "org-export"
54 (footnote-reference info))
55 (declare-function org-export-get-coderef-format "org-export" (path desc))
56 (declare-function org-export-get-footnote-definition "org-export"
57 (footnote-reference info))
58 (declare-function org-export-get-footnote-number "org-export" (footnote info))
59 (declare-function org-export-get-previous-element "org-export" (blob info))
60 (declare-function org-export-get-relative-level "org-export" (headline info))
61 (declare-function org-export-handle-code
62 "org-export" (element info &optional num-fmt ref-fmt delayed))
63 (declare-function org-export-inline-image-p "org-export"
64 (link &optional extensions))
65 (declare-function org-export-last-sibling-p "org-export" (headline info))
66 (declare-function org-export-low-level-p "org-export" (headline info))
67 (declare-function org-export-output-file-name
68 "org-export" (extension &optional subtreep pub-dir))
69 (declare-function org-export-resolve-coderef "org-export" (ref info))
70 (declare-function org-export-resolve-fuzzy-link "org-export" (link info))
71 (declare-function org-export-resolve-radio-link "org-export" (link info))
72 (declare-function org-export-solidify-link-text "org-export" (s))
73 (declare-function
74 org-export-to-buffer "org-export"
75 (backend buffer &optional subtreep visible-only body-only ext-plist))
76 (declare-function
77 org-export-to-file "org-export"
78 (backend file &optional subtreep visible-only body-only ext-plist))
80 (declare-function org-id-find-id-file "org-id" (id))
81 (declare-function htmlize-region "ext:htmlize" (beg end))
82 (declare-function org-pop-to-buffer-same-window
83 "org-compat" (&optional buffer-or-name norecord label))
86 ;;; Define Back-End
88 (defvar org-e-html-translate-alist
89 '((babel-call . org-e-html-babel-call)
90 (bold . org-e-html-bold)
91 (center-block . org-e-html-center-block)
92 (clock . org-e-html-clock)
93 (code . org-e-html-code)
94 (comment . org-e-html-comment)
95 (comment-block . org-e-html-comment-block)
96 (drawer . org-e-html-drawer)
97 (dynamic-block . org-e-html-dynamic-block)
98 (entity . org-e-html-entity)
99 (example-block . org-e-html-example-block)
100 (export-block . org-e-html-export-block)
101 (export-snippet . org-e-html-export-snippet)
102 (fixed-width . org-e-html-fixed-width)
103 (footnote-definition . org-e-html-footnote-definition)
104 (footnote-reference . org-e-html-footnote-reference)
105 (headline . org-e-html-headline)
106 (horizontal-rule . org-e-html-horizontal-rule)
107 (inline-babel-call . org-e-html-inline-babel-call)
108 (inline-src-block . org-e-html-inline-src-block)
109 (inlinetask . org-e-html-inlinetask)
110 (italic . org-e-html-italic)
111 (item . org-e-html-item)
112 (keyword . org-e-html-keyword)
113 (latex-environment . org-e-html-latex-environment)
114 (latex-fragment . org-e-html-latex-fragment)
115 (line-break . org-e-html-line-break)
116 (link . org-e-html-link)
117 (macro . org-e-html-macro)
118 (paragraph . org-e-html-paragraph)
119 (plain-list . org-e-html-plain-list)
120 (plain-text . org-e-html-plain-text)
121 (planning . org-e-html-planning)
122 (property-drawer . org-e-html-property-drawer)
123 (quote-block . org-e-html-quote-block)
124 (quote-section . org-e-html-quote-section)
125 (radio-target . org-e-html-radio-target)
126 (section . org-e-html-section)
127 (special-block . org-e-html-special-block)
128 (src-block . org-e-html-src-block)
129 (statistics-cookie . org-e-html-statistics-cookie)
130 (strike-through . org-e-html-strike-through)
131 (subscript . org-e-html-subscript)
132 (superscript . org-e-html-superscript)
133 (table . org-e-html-table)
134 (table-cell . org-e-html-table-cell)
135 (table-row . org-e-html-table-row)
136 (target . org-e-html-target)
137 (template . org-e-html-template)
138 (timestamp . org-e-html-timestamp)
139 (underline . org-e-html-underline)
140 (verbatim . org-e-html-verbatim)
141 (verse-block . org-e-html-verse-block))
142 "Alist between element or object types and translators.")
144 ;; FIXME (`org-e-html-options-alist'): Prefix KEYWORD and OPTION with
145 ;; "HTML_". Prefix corresponding properties with `:html-". If such a
146 ;; renaming is taken up, some changes will be required in
147 ;; `org-jsinfo.el', I think. So defer renaming for now.
149 (defconst org-e-html-options-alist
150 '((:agenda-style nil nil org-agenda-export-html-style)
151 (:convert-org-links nil nil org-e-html-link-org-files-as-html)
152 ;; (:expand-quoted-html nil "@" org-e-html-expand)
153 (:inline-images nil nil org-e-html-inline-images)
154 (:link-home "LINK_HOME" nil org-e-html-link-home)
155 (:link-up "LINK_UP" nil org-e-html-link-up)
156 (:style nil nil org-e-html-style)
157 (:style-extra "STYLE" nil org-e-html-style-extra newline)
158 (:style-include-default nil nil org-e-html-style-include-default)
159 (:style-include-scripts nil nil org-e-html-style-include-scripts)
160 ;; (:timestamp nil nil org-e-html-with-timestamp)
161 (:html-extension nil nil org-e-html-extension)
162 (:html-postamble nil nil org-e-html-postamble)
163 (:html-preamble nil nil org-e-html-preamble)
164 (:html-table-tag nil nil org-e-html-table-tag)
165 (:xml-declaration nil nil org-e-html-xml-declaration)
166 (:LaTeX-fragments nil "LaTeX" org-export-with-LaTeX-fragments)
167 (:mathjax "MATHJAX" nil "" space))
168 "Alist between HTML export properties and ways to set them.
169 This variable is the HTML-specific counterpart of
170 `org-export-options-alist'.
172 The CAR of the alist is the property name, and the CDR is a list
173 like (KEYWORD OPTION DEFAULT BEHAVIOUR) where:
175 KEYWORD is a string representing a buffer keyword, or nil.
176 OPTION is a string that could be found in an #+OPTIONS: line.
177 DEFAULT is the default value for the property.
178 BEHAVIOUR determine how Org should handle multiple keywords for
179 the same property. It is a symbol among:
180 nil Keep old value and discard the new one.
181 t Replace old value with the new one.
182 `space' Concatenate the values, separating them with a space.
183 `newline' Concatenate the values, separating them with
184 a newline.
185 `split' Split values at white spaces, and cons them to the
186 previous list.
188 KEYWORD and OPTION have precedence over DEFAULT.")
190 (defconst org-e-html-filters-alist
191 '((:filter-final-output . org-e-html-final-function))
192 "Alist between filters keywords and back-end specific filters.
193 See `org-export-filters-alist' for more information.")
197 ;;; Internal Variables
199 ;; FIXME: it already exists in org-e-html.el
200 (defconst org-e-html-cvt-link-fn
202 "Function to convert link URLs to exportable URLs.
203 Takes two arguments, TYPE and PATH.
204 Returns exportable url as (TYPE PATH), or nil to signal that it
205 didn't handle this case.
206 Intended to be locally bound around a call to `org-export-as-html'." )
211 (defvar org-e-html-format-table-no-css)
212 (defvar htmlize-buffer-places) ; from htmlize.el
213 (defvar body-only) ; dynamically scoped into this.
217 ;;; User Configuration Variables
219 (defgroup org-export-e-html nil
220 "Options for exporting Org mode files to HTML."
221 :tag "Org Export HTML"
222 :group 'org-export)
224 ;;;; Debugging
226 (defcustom org-e-html-pretty-output nil
227 "Enable this to generate pretty HTML."
228 :group 'org-export-e-html
229 :type 'boolean)
232 ;;;; Document
234 (defcustom org-e-html-extension "html"
235 "The extension for exported HTML files."
236 :group 'org-export-e-html
237 :type 'string)
239 (defcustom org-e-html-xml-declaration
240 '(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
241 ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
242 "The extension for exported HTML files.
243 %s will be replaced with the charset of the exported file.
244 This may be a string, or an alist with export extensions
245 and corresponding declarations."
246 :group 'org-export-e-html
247 :type '(choice
248 (string :tag "Single declaration")
249 (repeat :tag "Dependent on extension"
250 (cons (string :tag "Extension")
251 (string :tag "Declaration")))))
253 (defcustom org-e-html-coding-system org-export-coding-system
254 "Coding system for HTML export.
255 Use `org-export-coding-system' as the default value."
256 :group 'org-export-e-html
257 :type 'coding-system)
259 (defvar org-e-html-content-div "content"
260 "The name of the container DIV that holds all the page contents.
262 This variable is obsolete since Org version 7.7.
263 Please set `org-e-html-divs' instead.")
265 (defcustom org-e-html-divs '("preamble" "content" "postamble")
266 "The name of the main divs for HTML export.
267 This is a list of three strings, the first one for the preamble
268 DIV, the second one for the content DIV and the third one for the
269 postamble DIV."
270 :group 'org-export-e-html
271 :type '(list
272 (string :tag " Div for the preamble:")
273 (string :tag " Div for the content:")
274 (string :tag "Div for the postamble:")))
277 ;;;; Document Header (Styles)
279 (defconst org-e-html-style-default
280 "<style type=\"text/css\">
281 <!--/*--><![CDATA[/*><!--*/
282 html { font-family: Times, serif; font-size: 12pt; }
283 .title { text-align: center; }
284 .todo { color: red; }
285 .done { color: green; }
286 .tag { background-color: #add8e6; font-weight:normal }
287 .target { }
288 .timestamp { color: #bebebe; }
289 .timestamp-kwd { color: #5f9ea0; }
290 .right {margin-left:auto; margin-right:0px; text-align:right;}
291 .left {margin-left:0px; margin-right:auto; text-align:left;}
292 .center {margin-left:auto; margin-right:auto; text-align:center;}
293 p.verse { margin-left: 3% }
294 pre {
295 border: 1pt solid #AEBDCC;
296 background-color: #F3F5F7;
297 padding: 5pt;
298 font-family: courier, monospace;
299 font-size: 90%;
300 overflow:auto;
302 table { border-collapse: collapse; }
303 td, th { vertical-align: top; }
304 th.right { text-align:center; }
305 th.left { text-align:center; }
306 th.center { text-align:center; }
307 td.right { text-align:right; }
308 td.left { text-align:left; }
309 td.center { text-align:center; }
310 dt { font-weight: bold; }
311 div.figure { padding: 0.5em; }
312 div.figure p { text-align: center; }
313 div.inlinetask {
314 padding:10px;
315 border:2px solid gray;
316 margin:10px;
317 background: #ffffcc;
319 textarea { overflow-x: auto; }
320 .linenr { font-size:smaller }
321 .code-highlighted {background-color:#ffff00;}
322 .org-info-js_info-navigation { border-style:none; }
323 #org-info-js_console-label { font-size:10px; font-weight:bold;
324 white-space:nowrap; }
325 .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
326 font-weight:bold; }
327 /*]]>*/-->
328 </style>"
329 "The default style specification for exported HTML files.
330 Please use the variables `org-e-html-style' and
331 `org-e-html-style-extra' to add to this style. If you wish to not
332 have the default style included, customize the variable
333 `org-e-html-style-include-default'.")
335 (defcustom org-e-html-style-include-default t
336 "Non-nil means include the default style in exported HTML files.
337 The actual style is defined in `org-e-html-style-default' and should
338 not be modified. Use the variables `org-e-html-style' to add
339 your own style information."
340 :group 'org-export-e-html
341 :type 'boolean)
342 ;;;###autoload
343 (put 'org-e-html-style-include-default 'safe-local-variable 'booleanp)
345 (defcustom org-e-html-style ""
346 "Org-wide style definitions for exported HTML files.
348 This variable needs to contain the full HTML structure to provide a style,
349 including the surrounding HTML tags. If you set the value of this variable,
350 you should consider to include definitions for the following classes:
351 title, todo, done, timestamp, timestamp-kwd, tag, target.
353 For example, a valid value would be:
355 <style type=\"text/css\">
356 <![CDATA[
357 p { font-weight: normal; color: gray; }
358 h1 { color: black; }
359 .title { text-align: center; }
360 .todo, .timestamp-kwd { color: red; }
361 .done { color: green; }
363 </style>
365 If you'd like to refer to an external style file, use something like
367 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
369 As the value of this option simply gets inserted into the HTML <head> header,
370 you can \"misuse\" it to add arbitrary text to the header.
371 See also the variable `org-e-html-style-extra'."
372 :group 'org-export-e-html
373 :type 'string)
374 ;;;###autoload
375 (put 'org-e-html-style 'safe-local-variable 'stringp)
377 (defcustom org-e-html-style-extra ""
378 "Additional style information for HTML export.
379 The value of this variable is inserted into the HTML buffer right after
380 the value of `org-e-html-style'. Use this variable for per-file
381 settings of style information, and do not forget to surround the style
382 settings with <style>...</style> tags."
383 :group 'org-export-e-html
384 :type 'string)
385 ;;;###autoload
386 (put 'org-e-html-style-extra 'safe-local-variable 'stringp)
388 (defcustom org-e-html-mathjax-options
389 '((path "http://orgmode.org/mathjax/MathJax.js")
390 (scale "100")
391 (align "center")
392 (indent "2em")
393 (mathml nil))
394 "Options for MathJax setup.
396 path The path where to find MathJax
397 scale Scaling for the HTML-CSS backend, usually between 100 and 133
398 align How to align display math: left, center, or right
399 indent If align is not center, how far from the left/right side?
400 mathml Should a MathML player be used if available?
401 This is faster and reduces bandwidth use, but currently
402 sometimes has lower spacing quality. Therefore, the default is
403 nil. When browsers get better, this switch can be flipped.
405 You can also customize this for each buffer, using something like
407 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
408 :group 'org-export-e-html
409 :type '(list :greedy t
410 (list :tag "path (the path from where to load MathJax.js)"
411 (const :format " " path) (string))
412 (list :tag "scale (scaling for the displayed math)"
413 (const :format " " scale) (string))
414 (list :tag "align (alignment of displayed equations)"
415 (const :format " " align) (string))
416 (list :tag "indent (indentation with left or right alignment)"
417 (const :format " " indent) (string))
418 (list :tag "mathml (should MathML display be used is possible)"
419 (const :format " " mathml) (boolean))))
422 ;;;; Document Header (Scripts)
424 (defcustom org-e-html-style-include-scripts t
425 "Non-nil means include the JavaScript snippets in exported HTML files.
426 The actual script is defined in `org-e-html-scripts' and should
427 not be modified."
428 :group 'org-export-e-html
429 :type 'boolean)
431 (defconst org-e-html-scripts
432 "<script type=\"text/javascript\">
433 <!--/*--><![CDATA[/*><!--*/
434 function CodeHighlightOn(elem, id)
436 var target = document.getElementById(id);
437 if(null != target) {
438 elem.cacheClassElem = elem.className;
439 elem.cacheClassTarget = target.className;
440 target.className = \"code-highlighted\";
441 elem.className = \"code-highlighted\";
444 function CodeHighlightOff(elem, id)
446 var target = document.getElementById(id);
447 if(elem.cacheClassElem)
448 elem.className = elem.cacheClassElem;
449 if(elem.cacheClassTarget)
450 target.className = elem.cacheClassTarget;
452 /*]]>*///-->
453 </script>"
454 "Basic JavaScript that is needed by HTML files produced by Org-mode.")
457 ;;;; Document Header (Mathjax)
459 (defcustom org-e-html-mathjax-template
460 "<script type=\"text/javascript\" src=\"%PATH\">
461 <!--/*--><![CDATA[/*><!--*/
462 MathJax.Hub.Config({
463 // Only one of the two following lines, depending on user settings
464 // First allows browser-native MathML display, second forces HTML/CSS
465 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
466 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
467 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
468 \"TeX/noUndefined.js\"],
469 tex2jax: {
470 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
471 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
472 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
473 ignoreClass: \"tex2jax_ignore\",
474 processEscapes: false,
475 processEnvironments: true,
476 preview: \"TeX\"
478 showProcessingMessages: true,
479 displayAlign: \"%ALIGN\",
480 displayIndent: \"%INDENT\",
482 \"HTML-CSS\": {
483 scale: %SCALE,
484 availableFonts: [\"STIX\",\"TeX\"],
485 preferredFont: \"TeX\",
486 webFont: \"TeX\",
487 imageFont: \"TeX\",
488 showMathMenu: true,
490 MMLorHTML: {
491 prefer: {
492 MSIE: \"MML\",
493 Firefox: \"MML\",
494 Opera: \"HTML\",
495 other: \"HTML\"
499 /*]]>*///-->
500 </script>"
501 "The MathJax setup for XHTML files."
502 :group 'org-export-e-html
503 :type 'string)
506 ;;;; Preamble
508 (defcustom org-e-html-preamble t
509 "Non-nil means insert a preamble in HTML export.
511 When `t', insert a string as defined by one of the formatting
512 strings in `org-e-html-preamble-format'. When set to a
513 string, this string overrides `org-e-html-preamble-format'.
514 When set to a function, apply this function and insert the
515 returned string. The function takes the property list of export
516 options as its only argument.
518 Setting :html-preamble in publishing projects will take
519 precedence over this variable."
520 :group 'org-export-e-html
521 :type '(choice (const :tag "No preamble" nil)
522 (const :tag "Default preamble" t)
523 (string :tag "Custom formatting string")
524 (function :tag "Function (must return a string)")))
526 (defcustom org-e-html-preamble-format '(("en" ""))
527 "The format for the HTML preamble.
529 %t stands for the title.
530 %a stands for the author's name.
531 %e stands for the author's email.
532 %d stands for the date.
534 If you need to use a \"%\" character, you need to escape it
535 like that: \"%%\"."
536 :group 'org-export-e-html
537 :type 'string)
539 (defcustom org-e-html-link-up ""
540 "Where should the \"UP\" link of exported HTML pages lead?"
541 :group 'org-export-e-html
542 :type '(string :tag "File or URL"))
544 (defcustom org-e-html-link-home ""
545 "Where should the \"HOME\" link of exported HTML pages lead?"
546 :group 'org-export-e-html
547 :type '(string :tag "File or URL"))
549 (defcustom org-e-html-home/up-format
550 "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
551 <a accesskey=\"h\" href=\"%s\"> UP </a>
553 <a accesskey=\"H\" href=\"%s\"> HOME </a>
554 </div>"
555 "Snippet used to insert the HOME and UP links.
556 This is a format string, the first %s will receive the UP link,
557 the second the HOME link. If both `org-e-html-link-up' and
558 `org-e-html-link-home' are empty, the entire snippet will be
559 ignored."
560 :group 'org-export-e-html
561 :type 'string)
563 ;;;; Postamble
565 (defcustom org-e-html-postamble 'auto
566 "Non-nil means insert a postamble in HTML export.
568 When `t', insert a string as defined by the formatting string in
569 `org-e-html-postamble-format'. When set to a string, this
570 string overrides `org-e-html-postamble-format'. When set to
571 'auto, discard `org-e-html-postamble-format' and honor
572 `org-export-author/email/creator-info' variables. When set to a
573 function, apply this function and insert the returned string.
574 The function takes the property list of export options as its
575 only argument.
577 Setting :html-postamble in publishing projects will take
578 precedence over this variable."
579 :group 'org-export-e-html
580 :type '(choice (const :tag "No postamble" nil)
581 (const :tag "Auto preamble" 'auto)
582 (const :tag "Default formatting string" t)
583 (string :tag "Custom formatting string")
584 (function :tag "Function (must return a string)")))
586 (defcustom org-e-html-postamble-format
587 '(("en" "<p class=\"author\">Author: %a (%e)</p>
588 <p class=\"date\">Date: %d</p>
589 <p class=\"creator\">Generated by %c</p>
590 <p class=\"xhtml-validation\">%v</p>
592 "The format for the HTML postamble.
594 %a stands for the author's name.
595 %e stands for the author's email.
596 %d stands for the date.
597 %c will be replaced by information about Org/Emacs versions.
598 %v will be replaced by `org-e-html-validation-link'.
600 If you need to use a \"%\" character, you need to escape it
601 like that: \"%%\"."
602 :group 'org-export-e-html
603 :type 'string)
605 (defcustom org-e-html-validation-link
606 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
607 "Link to HTML validation service."
608 :group 'org-export-e-html
609 :type 'string)
611 ;; FIXME Obsolete since Org 7.7
612 ;; Use the :timestamp option or `org-export-time-stamp-file' instead
613 ;;;; Emphasis
615 (defcustom org-e-html-protect-char-alist
616 '(("&" . "&amp;")
617 ("<" . "&lt;")
618 (">" . "&gt;"))
619 "Alist of characters to be converted by `org-e-html-protect'."
620 :group 'org-export-e-html
621 :type '(repeat (cons (string :tag "Character")
622 (string :tag "HTML equivalent"))))
624 (defconst org-e-html-special-string-regexps
625 '(("\\\\-" . "&shy;")
626 ("---\\([^-]\\)" . "&mdash;\\1")
627 ("--\\([^-]\\)" . "&ndash;\\1")
628 ("\\.\\.\\." . "&hellip;"))
629 "Regular expressions for special string conversion.")
632 ;;;; Todos
634 (defcustom org-e-html-todo-kwd-class-prefix ""
635 "Prefix to class names for TODO keywords.
636 Each TODO keyword gets a class given by the keyword itself, with this prefix.
637 The default prefix is empty because it is nice to just use the keyword
638 as a class name. But if you get into conflicts with other, existing
639 CSS classes, then this prefix can be very useful."
640 :group 'org-export-e-html
641 :type 'string)
644 ;;;; Tags
646 (defcustom org-e-html-tag-class-prefix ""
647 "Prefix to class names for TODO keywords.
648 Each tag gets a class given by the tag itself, with this prefix.
649 The default prefix is empty because it is nice to just use the keyword
650 as a class name. But if you get into conflicts with other, existing
651 CSS classes, then this prefix can be very useful."
652 :group 'org-export-e-html
653 :type 'string)
655 ;;;; Timestamps
656 ;;;; Statistics Cookie
657 ;;;; Subscript
658 ;;;; Superscript
660 ;;;; Inline images
662 (defcustom org-e-html-inline-images 'maybe
663 "Non-nil means inline images into exported HTML pages.
664 This is done using an <img> tag. When nil, an anchor with href is used to
665 link to the image. If this option is `maybe', then images in links with
666 an empty description will be inlined, while images with a description will
667 be linked only."
668 :group 'org-export-e-html
669 :type '(choice (const :tag "Never" nil)
670 (const :tag "Always" t)
671 (const :tag "When there is no description" maybe)))
673 (defcustom org-e-html-inline-image-extensions
674 '("png" "jpeg" "jpg" "gif" "svg")
675 "Extensions of image files that can be inlined into HTML."
676 :group 'org-export-e-html
677 :type '(repeat (string :tag "Extension")))
680 ;;;; Block
681 ;;;; Comment
682 ;;;; Comment Block
683 ;;;; Drawer
684 ;;;; Dynamic Block
685 ;;;; Emphasis
686 ;;;; Entity
687 ;;;; Example Block
688 ;;;; Export Snippet
689 ;;;; Export Block
690 ;;;; Fixed Width
691 ;;;; Footnotes
693 (defcustom org-e-html-footnotes-section "<div id=\"footnotes\">
694 <h2 class=\"footnotes\">%s: </h2>
695 <div id=\"text-footnotes\">
697 </div>
698 </div>"
699 "Format for the footnotes section.
700 Should contain a two instances of %s. The first will be replaced with the
701 language-specific word for \"Footnotes\", the second one will be replaced
702 by the footnotes themselves."
703 :group 'org-export-e-html
704 :type 'string)
706 (defcustom org-e-html-footnote-format "<sup>%s</sup>"
707 "The format for the footnote reference.
708 %s will be replaced by the footnote reference itself."
709 :group 'org-export-e-html
710 :type 'string)
712 (defcustom org-e-html-footnote-separator "<sup>, </sup>"
713 "Text used to separate footnotes."
714 :group 'org-export-e-html
715 :type 'string)
718 ;;;; Headline
719 ;;;; Horizontal Rule
720 ;;;; Inline Babel Call
721 ;;;; Inline Src Block
722 ;;;; Inlinetask
723 ;;;; Item
724 ;;;; Keyword
725 ;;;; Latex Environment
726 ;;;; Latex Fragment
727 ;;;; Line Break
728 ;;;; Link
729 ;;;; Babel Call
730 ;;;; Macro
731 ;;;; Paragraph
732 ;;;; Plain List
733 ;;;; Plain Text
734 ;;;; Property Drawer
735 ;;;; Quote Block
736 ;;;; Quote Section
737 ;;;; Section
738 ;;;; Radio Target
739 ;;;; Special Block
740 ;;;; Src Block
742 (defgroup org-export-e-htmlize nil
743 "Options for processing examples with htmlize.el."
744 :tag "Org Export Htmlize"
745 :group 'org-export-e-html)
747 (defcustom org-export-e-htmlize-output-type 'inline-css
748 "Output type to be used by htmlize when formatting code snippets.
749 Choices are `css', to export the CSS selectors only, or `inline-css', to
750 export the CSS attribute values inline in the HTML. We use as default
751 `inline-css', in order to make the resulting HTML self-containing.
753 However, this will fail when using Emacs in batch mode for export, because
754 then no rich font definitions are in place. It will also not be good if
755 people with different Emacs setup contribute HTML files to a website,
756 because the fonts will represent the individual setups. In these cases,
757 it is much better to let Org/Htmlize assign classes only, and to use
758 a style file to define the look of these classes.
759 To get a start for your css file, start Emacs session and make sure that
760 all the faces you are interested in are defined, for example by loading files
761 in all modes you want. Then, use the command
762 \\[org-export-e-htmlize-generate-css] to extract class definitions."
763 :group 'org-export-e-htmlize
764 :type '(choice (const css) (const inline-css)))
766 (defcustom org-export-e-htmlize-css-font-prefix "org-"
767 "The prefix for CSS class names for htmlize font specifications."
768 :group 'org-export-e-htmlize
769 :type 'string)
771 (defcustom org-export-e-htmlized-org-css-url nil
772 "URL pointing to a CSS file defining text colors for htmlized Emacs buffers.
773 Normally when creating an htmlized version of an Org buffer, htmlize will
774 create CSS to define the font colors. However, this does not work when
775 converting in batch mode, and it also can look bad if different people
776 with different fontification setup work on the same website.
777 When this variable is non-nil, creating an htmlized version of an Org buffer
778 using `org-export-as-org' will remove the internal CSS section and replace it
779 with a link to this URL."
780 :group 'org-export-e-htmlize
781 :type '(choice
782 (const :tag "Keep internal css" nil)
783 (string :tag "URL or local href")))
786 ;;;; Table
788 (defcustom org-e-html-table-tag
789 "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
790 "The HTML tag that is used to start a table.
791 This must be a <table> tag, but you may change the options like
792 borders and spacing."
793 :group 'org-export-e-html
794 :type 'string)
796 (defcustom org-e-html-table-header-tags '("<th scope=\"%s\"%s>" . "</th>")
797 "The opening tag for table header fields.
798 This is customizable so that alignment options can be specified.
799 The first %s will be filled with the scope of the field, either row or col.
800 The second %s will be replaced by a style entry to align the field.
801 See also the variable `org-e-html-table-use-header-tags-for-first-column'.
802 See also the variable `org-e-html-table-align-individual-fields'."
803 :group 'org-export-tables ; FIXME: change group?
804 :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
806 (defcustom org-e-html-table-data-tags '("<td%s>" . "</td>")
807 "The opening tag for table data fields.
808 This is customizable so that alignment options can be specified.
809 The first %s will be filled with the scope of the field, either row or col.
810 The second %s will be replaced by a style entry to align the field.
811 See also the variable `org-e-html-table-align-individual-fields'."
812 :group 'org-export-tables
813 :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
815 (defcustom org-e-html-table-row-tags '("<tr>" . "</tr>")
816 "The opening tag for table data fields.
817 This is customizable so that alignment options can be specified.
818 Instead of strings, these can be Lisp forms that will be evaluated
819 for each row in order to construct the table row tags. During evaluation,
820 the variable `head' will be true when this is a header line, nil when this
821 is a body line. And the variable `nline' will contain the line number,
822 starting from 1 in the first header line. For example
824 (setq org-e-html-table-row-tags
825 (cons '(if head
826 \"<tr>\"
827 (if (= (mod nline 2) 1)
828 \"<tr class=\\\"tr-odd\\\">\"
829 \"<tr class=\\\"tr-even\\\">\"))
830 \"</tr>\"))
832 will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
833 :group 'org-export-tables
834 :type '(cons
835 (choice :tag "Opening tag"
836 (string :tag "Specify")
837 (sexp))
838 (choice :tag "Closing tag"
839 (string :tag "Specify")
840 (sexp))))
842 (defcustom org-e-html-table-align-individual-fields t
843 "Non-nil means attach style attributes for alignment to each table field.
844 When nil, alignment will only be specified in the column tags, but this
845 is ignored by some browsers (like Firefox, Safari). Opera does it right
846 though."
847 :group 'org-export-tables
848 :type 'boolean)
850 (defcustom org-e-html-table-use-header-tags-for-first-column nil
851 "Non-nil means format column one in tables with header tags.
852 When nil, also column one will use data tags."
853 :group 'org-export-tables
854 :type 'boolean)
857 ;;;; Target
858 ;;;; Timestamp
860 ;;;; Verbatim
861 ;;;; Verse Block
862 ;;;; Headline
864 (defcustom org-e-html-toplevel-hlevel 2
865 "The <H> level for level 1 headings in HTML export.
866 This is also important for the classes that will be wrapped around headlines
867 and outline structure. If this variable is 1, the top-level headlines will
868 be <h1>, and the corresponding classes will be outline-1, section-number-1,
869 and outline-text-1. If this is 2, all of these will get a 2 instead.
870 The default for this variable is 2, because we use <h1> for formatting the
871 document title."
872 :group 'org-export-e-html
873 :type 'string)
876 ;;;; Links
877 ;;;; Drawers
878 ;;;; Inlinetasks
879 ;;;; Publishing
881 (defcustom org-e-html-link-org-files-as-html t
882 "Non-nil means make file links to `file.org' point to `file.html'.
883 When org-mode is exporting an org-mode file to HTML, links to
884 non-html files are directly put into a href tag in HTML.
885 However, links to other Org-mode files (recognized by the
886 extension `.org.) should become links to the corresponding html
887 file, assuming that the linked org-mode file will also be
888 converted to HTML.
889 When nil, the links still point to the plain `.org' file."
890 :group 'org-export-e-html
891 :type 'boolean)
894 ;;;; Compilation
898 ;;; User Configurable Variables (MAYBE)
900 ;;;; Preamble
902 (defcustom org-e-html-date-format
903 "\\today"
904 "Format string for \\date{...}."
905 :group 'org-export-e-html
906 :type 'boolean)
908 ;;;; Headline
910 (defcustom org-e-html-format-headline-function nil
911 "Function to format headline text.
913 This function will be called with 5 arguments:
914 TODO the todo keyword (string or nil).
915 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
916 PRIORITY the priority of the headline (integer or nil)
917 TEXT the main headline text (string).
918 TAGS the tags (string or nil).
920 The function result will be used in the section format string.
922 As an example, one could set the variable to the following, in
923 order to reproduce the default set-up:
925 \(defun org-e-html-format-headline \(todo todo-type priority text tags)
926 \"Default format function for an headline.\"
927 \(concat \(when todo
928 \(format \"\\\\textbf{\\\\textsc{\\\\textsf{%s}}} \" todo))
929 \(when priority
930 \(format \"\\\\framebox{\\\\#%c} \" priority))
931 text
932 \(when tags (format \"\\\\hfill{}\\\\textsc{%s}\" tags))))"
933 :group 'org-export-e-html
934 :type 'function)
937 ;;;; Text Markup
939 (defcustom org-e-html-text-markup-alist
940 '((bold . "<b>%s</b>")
941 (code . "<code>%s</code>")
942 (italic . "<i>%s</i>")
943 (strike-through . "<del>%s</del>")
944 (underline . "<span style=\"text-decoration:underline;\">%s</span>")
945 (verbatim . "<code>%s</code>"))
946 "Alist of HTML expressions to convert text markup
948 The key must be a symbol among `bold', `code', `italic',
949 `strike-through', `underline' and `verbatim'. The value is
950 a formatting string to wrap fontified text with.
952 If no association can be found for a given markup, text will be
953 returned as-is."
954 :group 'org-export-e-html
955 :type '(alist :key-type (symbol :tag "Markup type")
956 :value-type (string :tag "Format string"))
957 :options '(bold code italic strike-through underline verbatim))
960 ;;;; Footnotes
962 (defcustom org-e-html-footnote-separator "<sup>, </sup>"
963 "Text used to separate footnotes."
964 :group 'org-export-e-html
965 :type 'string)
968 ;;;; Timestamps
970 (defcustom org-e-html-active-timestamp-format "\\textit{%s}"
971 "A printf format string to be applied to active timestamps."
972 :group 'org-export-e-html
973 :type 'string)
975 (defcustom org-e-html-inactive-timestamp-format "\\textit{%s}"
976 "A printf format string to be applied to inactive timestamps."
977 :group 'org-export-e-html
978 :type 'string)
980 (defcustom org-e-html-diary-timestamp-format "\\textit{%s}"
981 "A printf format string to be applied to diary timestamps."
982 :group 'org-export-e-html
983 :type 'string)
986 ;;;; Links
988 (defcustom org-e-html-inline-image-rules
989 '(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
990 ("http" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
991 ("https" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
992 "Rules characterizing image files that can be inlined into HTML.
994 A rule consists in an association whose key is the type of link
995 to consider, and value is a regexp that will be matched against
996 link's path.
998 Note that, by default, the image extension *actually* allowed
999 depend on the way the HTML file is processed. When used with
1000 pdflatex, pdf, jpg and png images are OK. When processing
1001 through dvi to Postscript, only ps and eps are allowed. The
1002 default we use here encompasses both."
1003 :group 'org-export-e-html
1004 :type '(alist :key-type (string :tag "Type")
1005 :value-type (regexp :tag "Path")))
1007 ;;;; Tables
1009 (defcustom org-e-html-table-caption-above t
1010 "When non-nil, place caption string at the beginning of the table.
1011 Otherwise, place it near the end."
1012 :group 'org-export-e-html
1013 :type 'boolean)
1015 ;;;; Drawers
1017 (defcustom org-e-html-format-drawer-function nil
1018 "Function called to format a drawer in HTML code.
1020 The function must accept two parameters:
1021 NAME the drawer name, like \"LOGBOOK\"
1022 CONTENTS the contents of the drawer.
1024 The function should return the string to be exported.
1026 For example, the variable could be set to the following function
1027 in order to mimic default behaviour:
1029 \(defun org-e-html-format-drawer-default \(name contents\)
1030 \"Format a drawer element for HTML export.\"
1031 contents\)"
1032 :group 'org-export-e-html
1033 :type 'function)
1036 ;;;; Inlinetasks
1038 (defcustom org-e-html-format-inlinetask-function nil
1039 "Function called to format an inlinetask in HTML code.
1041 The function must accept six parameters:
1042 TODO the todo keyword, as a string
1043 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
1044 PRIORITY the inlinetask priority, as a string
1045 NAME the inlinetask name, as a string.
1046 TAGS the inlinetask tags, as a list of strings.
1047 CONTENTS the contents of the inlinetask, as a string.
1049 The function should return the string to be exported.
1051 For example, the variable could be set to the following function
1052 in order to mimic default behaviour:
1054 \(defun org-e-html-format-inlinetask \(todo type priority name tags contents\)
1055 \"Format an inline task element for HTML export.\"
1056 \(let \(\(full-title
1057 \(concat
1058 \(when todo
1059 \(format \"\\\\textbf{\\\\textsf{\\\\textsc{%s}}} \" todo))
1060 \(when priority (format \"\\\\framebox{\\\\#%c} \" priority))
1061 title
1062 \(when tags (format \"\\\\hfill{}\\\\textsc{%s}\" tags)))))
1063 \(format (concat \"\\\\begin{center}\\n\"
1064 \"\\\\fbox{\\n\"
1065 \"\\\\begin{minipage}[c]{.6\\\\textwidth}\\n\"
1066 \"%s\\n\\n\"
1067 \"\\\\rule[.8em]{\\\\textwidth}{2pt}\\n\\n\"
1068 \"%s\"
1069 \"\\\\end{minipage}}\"
1070 \"\\\\end{center}\")
1071 full-title contents))"
1072 :group 'org-export-e-html
1073 :type 'function)
1076 ;; Src blocks
1078 ;;;; Plain text
1080 (defcustom org-e-html-quotes
1081 '(("fr"
1082 ("\\(\\s-\\|[[(]\\|^\\)\"" . "«~")
1083 ("\\(\\S-\\)\"" . "~»")
1084 ("\\(\\s-\\|(\\|^\\)'" . "'"))
1085 ("en"
1086 ("\\(\\s-\\|[[(]\\|^\\)\"" . "``")
1087 ("\\(\\S-\\)\"" . "''")
1088 ("\\(\\s-\\|(\\|^\\)'" . "`")))
1089 "Alist for quotes to use when converting english double-quotes.
1091 The CAR of each item in this alist is the language code.
1092 The CDR of each item in this alist is a list of three CONS:
1093 - the first CONS defines the opening quote;
1094 - the second CONS defines the closing quote;
1095 - the last CONS defines single quotes.
1097 For each item in a CONS, the first string is a regexp
1098 for allowed characters before/after the quote, the second
1099 string defines the replacement string for this quote."
1100 :group 'org-export-e-html
1101 :type '(list
1102 (cons :tag "Opening quote"
1103 (string :tag "Regexp for char before")
1104 (string :tag "Replacement quote "))
1105 (cons :tag "Closing quote"
1106 (string :tag "Regexp for char after ")
1107 (string :tag "Replacement quote "))
1108 (cons :tag "Single quote"
1109 (string :tag "Regexp for char before")
1110 (string :tag "Replacement quote "))))
1112 ;;;; Compilation
1116 ;;; Internal Functions (HTML)
1118 (defun org-e-html-cvt-org-as-html (opt-plist type path)
1119 "Convert an org filename to an equivalent html filename.
1120 If TYPE is not file, just return `nil'.
1121 See variable `org-e-html-link-org-files-as-html'."
1122 (save-match-data
1123 (and
1124 org-e-html-link-org-files-as-html
1125 (string= type "file")
1126 (string-match "\\.org$" path)
1127 (progn
1128 (list
1129 "file"
1130 (concat
1131 (substring path 0 (match-beginning 0))
1132 "." (plist-get opt-plist :html-extension)))))))
1134 (defun org-e-html-format-org-link (opt-plist type-1 path fragment desc attr
1135 descp)
1136 "Make an HTML link.
1137 OPT-PLIST is an options list.
1138 TYPE is the device-type of the link (THIS://foo.html).
1139 PATH is the path of the link (http://THIS#location).
1140 FRAGMENT is the fragment part of the link, if any (foo.html#THIS).
1141 DESC is the link description, if any.
1142 ATTR is a string of other attributes of the \"a\" element."
1143 (declare (special org-lparse-par-open))
1144 (save-match-data
1145 (let* ((may-inline-p
1146 (and (member type-1 '("http" "https" "file"))
1147 (org-lparse-should-inline-p path descp)
1148 (not fragment)))
1149 (type (if (equal type-1 "id") "file" type-1))
1150 (filename path)
1151 ;;First pass. Just sanity stuff.
1152 (components-1
1153 (cond
1154 ((string= type "file")
1155 (list
1156 type
1157 ;;Substitute just if original path was absolute.
1158 ;;(Otherwise path must remain relative)
1159 (if (file-name-absolute-p path)
1160 (concat "file://" (expand-file-name path))
1161 path)))
1162 ((string= type "")
1163 (list nil path))
1164 (t (list type path))))
1166 ;;Second pass. Components converted so they can refer
1167 ;;to a remote site.
1168 (components-2
1170 (and org-e-html-cvt-link-fn
1171 (apply org-e-html-cvt-link-fn
1172 opt-plist components-1))
1173 (apply #'org-e-html-cvt-org-as-html
1174 opt-plist components-1)
1175 components-1))
1176 (type (first components-2))
1177 (thefile (second components-2)))
1180 ;;Third pass. Build final link except for leading type
1181 ;;spec.
1182 (cond
1183 ((or
1184 (not type)
1185 (string= type "http")
1186 (string= type "https")
1187 (string= type "file")
1188 (string= type "coderef"))
1189 (if fragment
1190 (setq thefile (concat thefile "#" fragment))))
1192 (t))
1194 ;;Final URL-build, for all types.
1195 (setq thefile
1196 (let
1197 ((str (org-xml-format-href thefile)))
1198 (if (and type (not (or (string= "file" type)
1199 (string= "coderef" type))))
1200 (concat type ":" str)
1201 str)))
1203 (if may-inline-p
1204 (ignore) ;; (org-e-html-format-image thefile)
1205 (org-lparse-format
1206 'LINK (org-xml-format-desc desc) thefile attr)))))
1208 ;; (caption (and caption (org-xml-encode-org-text caption)))
1209 ;; alt = (file-name-nondirectory path)
1211 (defun org-e-html-format-inline-image (src &optional
1212 caption label attr standalone-p)
1213 (let* ((id (if (not label) ""
1214 (format " id=\"%s\"" (org-export-solidify-link-text label))))
1215 (attr (concat attr
1216 (cond
1217 ((string-match "\\<alt=" (or attr "")) "")
1218 ((string-match "^ltxpng/" src)
1219 (format " alt=\"%s\""
1220 (org-e-html-encode-plain-text
1221 (org-find-text-property-in-string
1222 'org-latex-src src))))
1223 (t (format " alt=\"%s\""
1224 (file-name-nondirectory src)))))))
1225 (cond
1226 (standalone-p
1227 (let ((img (format "<img src=\"%s\" %s/>" src attr)))
1228 (format "\n<div%s class=\"figure\">%s%s\n</div>"
1229 id (format "\n<p>%s</p>" img)
1230 (when caption (format "\n<p>%s</p>" caption)))))
1231 (t (format "<img src=\"%s\" %s/>" src (concat attr id))))))
1233 ;;;; Bibliography
1235 (defun org-e-html-bibliography ()
1236 "Find bibliography, cut it out and return it."
1237 (catch 'exit
1238 (let (beg end (cnt 1) bib)
1239 (save-excursion
1240 (goto-char (point-min))
1241 (when (re-search-forward
1242 "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t)
1243 (setq beg (match-beginning 0))
1244 (while (re-search-forward "</?div\\>" nil t)
1245 (setq cnt (+ cnt (if (string= (match-string 0) "<div") +1 -1)))
1246 (when (= cnt 0)
1247 (and (looking-at ">") (forward-char 1))
1248 (setq bib (buffer-substring beg (point)))
1249 (delete-region beg (point))
1250 (throw 'exit bib))))
1251 nil))))
1253 ;;;; Table
1255 (defun org-e-html-format-table (lines olines)
1256 (let ((org-e-html-format-table-no-css nil))
1257 (org-lparse-format-table lines olines)))
1259 (defun org-e-html-splice-attributes (tag attributes)
1260 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
1261 (if (not attributes)
1263 (let (oldatt newatt)
1264 (setq oldatt (org-extract-attributes-from-string tag)
1265 tag (pop oldatt)
1266 newatt (cdr (org-extract-attributes-from-string attributes)))
1267 (while newatt
1268 (setq oldatt (plist-put oldatt (pop newatt) (pop newatt))))
1269 (if (string-match ">" tag)
1270 (setq tag
1271 (replace-match (concat (org-attributes-to-string oldatt) ">")
1272 t t tag)))
1273 tag)))
1275 (defun org-export-splice-style (style extra)
1276 "Splice EXTRA into STYLE, just before \"</style>\"."
1277 (if (and (stringp extra)
1278 (string-match "\\S-" extra)
1279 (string-match "</style>" style))
1280 (concat (substring style 0 (match-beginning 0))
1281 "\n" extra "\n"
1282 (substring style (match-beginning 0)))
1283 style))
1285 (defun org-export-e-htmlize-region-for-paste (beg end)
1286 "Convert the region to HTML, using htmlize.el.
1287 This is much like `htmlize-region-for-paste', only that it uses
1288 the settings define in the org-... variables."
1289 (let* ((htmlize-output-type org-export-e-htmlize-output-type)
1290 (htmlize-css-name-prefix org-export-e-htmlize-css-font-prefix)
1291 (htmlbuf (htmlize-region beg end)))
1292 (unwind-protect
1293 (with-current-buffer htmlbuf
1294 (buffer-substring (plist-get htmlize-buffer-places 'content-start)
1295 (plist-get htmlize-buffer-places 'content-end)))
1296 (kill-buffer htmlbuf))))
1298 ;;;###autoload
1299 (defun org-export-e-htmlize-generate-css ()
1300 "Create the CSS for all font definitions in the current Emacs session.
1301 Use this to create face definitions in your CSS style file that can then
1302 be used by code snippets transformed by htmlize.
1303 This command just produces a buffer that contains class definitions for all
1304 faces used in the current Emacs session. You can copy and paste the ones you
1305 need into your CSS file.
1307 If you then set `org-export-e-htmlize-output-type' to `css', calls to
1308 the function `org-export-e-htmlize-region-for-paste' will produce code
1309 that uses these same face definitions."
1310 (interactive)
1311 (require 'htmlize)
1312 (and (get-buffer "*html*") (kill-buffer "*html*"))
1313 (with-temp-buffer
1314 (let ((fl (face-list))
1315 (htmlize-css-name-prefix "org-")
1316 (htmlize-output-type 'css)
1317 f i)
1318 (while (setq f (pop fl)
1319 i (and f (face-attribute f :inherit)))
1320 (when (and (symbolp f) (or (not i) (not (listp i))))
1321 (insert (org-add-props (copy-sequence "1") nil 'face f))))
1322 (htmlize-region (point-min) (point-max))))
1323 (org-pop-to-buffer-same-window "*html*")
1324 (goto-char (point-min))
1325 (if (re-search-forward "<style" nil t)
1326 (delete-region (point-min) (match-beginning 0)))
1327 (if (re-search-forward "</style>" nil t)
1328 (delete-region (1+ (match-end 0)) (point-max)))
1329 (beginning-of-line 1)
1330 (if (looking-at " +") (replace-match ""))
1331 (goto-char (point-min)))
1333 (defun org-e-html-make-string (n string)
1334 (let (out) (dotimes (i n out) (setq out (concat string out)))))
1336 (defun org-e-html-toc-text (toc-entries)
1337 (let* ((prev-level (1- (nth 1 (car toc-entries))))
1338 (start-level prev-level))
1339 (concat
1340 (mapconcat
1341 (lambda (entry)
1342 (let ((headline (nth 0 entry))
1343 (level (nth 1 entry)))
1344 (concat
1345 (let* ((cnt (- level prev-level))
1346 (times (if (> cnt 0) (1- cnt) (- cnt)))
1347 rtn)
1348 (setq prev-level level)
1349 (concat
1350 (org-e-html-make-string
1351 times (cond ((> cnt 0) "\n<ul>\n<li>")
1352 ((< cnt 0) "</li>\n</ul>\n")))
1353 (if (> cnt 0) "\n<ul>\n<li>" "</li>\n<li>")))
1354 headline)))
1355 toc-entries "")
1356 (org-e-html-make-string
1357 (- prev-level start-level) "</li>\n</ul>\n"))))
1359 (defun* org-e-html-format-toc-headline
1360 (todo todo-type priority text tags
1361 &key level section-number headline-label &allow-other-keys)
1362 (let ((headline (concat
1363 section-number (and section-number ". ")
1364 text
1365 (and tags "&nbsp;&nbsp;&nbsp;") (org-e-html--tags tags))))
1366 (format "<a href=\"#%s\">%s</a>"
1367 (org-solidify-link-text headline-label)
1368 (if (not nil) headline
1369 (format "<span class=\"%s\">%s</span>" todo-type headline)))))
1371 (defun org-e-html-toc (depth info)
1372 (assert (wholenump depth))
1373 (let* ((headlines (org-export-collect-headlines info depth))
1374 (toc-entries
1375 (loop for headline in headlines collect
1376 (list (org-e-html-format-headline--wrap
1377 headline info 'org-e-html-format-toc-headline)
1378 (org-export-get-relative-level headline info)))))
1379 (when toc-entries
1380 (let* ((lang-specific-heading
1381 (nth 3 (or (assoc (plist-get info :language)
1382 org-export-language-setup)
1383 (assoc "en" org-export-language-setup)))))
1384 (concat
1385 "<div id=\"table-of-contents\">\n"
1386 (format "<h%d>%s</h%d>\n"
1387 org-e-html-toplevel-hlevel
1388 lang-specific-heading
1389 org-e-html-toplevel-hlevel)
1390 "<div id=\"text-table-of-contents\">"
1391 (org-e-html-toc-text toc-entries)
1392 "</div>\n"
1393 "</div>\n")))))
1395 ;; (defun org-e-html-format-line (line)
1396 ;; (case org-lparse-dyn-current-environment
1397 ;; ((quote fixedwidth) (concat (org-e-html-encode-plain-text line) "\n"))
1398 ;; (t (concat line "\n"))))
1400 (defun org-e-html-fix-class-name (kwd) ; audit callers of this function
1401 "Turn todo keyword into a valid class name.
1402 Replaces invalid characters with \"_\"."
1403 (save-match-data
1404 (while (string-match "[^a-zA-Z0-9_]" kwd)
1405 (setq kwd (replace-match "_" t t kwd))))
1406 kwd)
1408 (defun org-e-html-format-footnote-reference (n def refcnt)
1409 (let ((extra (if (= refcnt 1) "" (format ".%d" refcnt))))
1410 (format org-e-html-footnote-format
1411 (format
1412 "<a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a>"
1413 n extra n n))))
1415 (defun org-e-html-format-footnotes-section (section-name definitions)
1416 (if (not definitions) ""
1417 (format org-e-html-footnotes-section section-name definitions)))
1419 (defun org-e-html-format-footnote-definition (fn)
1420 (let ((n (car fn)) (def (cdr fn)))
1421 (format
1422 "<tr>\n<td>%s</td>\n<td>%s</td>\n</tr>\n"
1423 (format
1424 (format org-e-html-footnote-format
1425 "<a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a>")
1426 n n n) def)))
1428 (defun org-e-html-footnote-section (info)
1429 (let* ((fn-alist (org-export-collect-footnote-definitions
1430 (plist-get info :parse-tree) info))
1432 (fn-alist
1433 (loop for (n type raw) in fn-alist collect
1434 (cons n (if (equal (org-element-type raw) 'org-data)
1435 (org-trim (org-export-data raw info))
1436 (format "<p>%s</p>"
1437 (org-trim (org-export-data raw info))))))))
1438 (when fn-alist
1439 (org-e-html-format-footnotes-section
1440 (nth 4 (or (assoc (plist-get info :language)
1441 org-export-language-setup)
1442 (assoc "en" org-export-language-setup)))
1443 (format
1444 "<table>\n%s\n</table>\n"
1445 (mapconcat 'org-e-html-format-footnote-definition fn-alist "\n"))))))
1447 (defun org-e-html-format-date (info)
1448 (let ((date (plist-get info :date)))
1449 (cond
1450 ((and date (string-match "%" date))
1451 (format-time-string date))
1452 (date date)
1453 (t (format-time-string "%Y-%m-%d %T %Z")))))
1457 ;;; Internal Functions (Ngz)
1459 (defun org-e-html--caption/label-string (caption label info)
1460 "Return caption and label HTML string for floats.
1462 CAPTION is a cons cell of secondary strings, the car being the
1463 standard caption and the cdr its short form. LABEL is a string
1464 representing the label. INFO is a plist holding contextual
1465 information.
1467 If there's no caption nor label, return the empty string.
1469 For non-floats, see `org-e-html--wrap-label'."
1470 (setq label nil) ;; FIXME
1472 (let ((label-str (if label (format "\\label{%s}" label) "")))
1473 (cond
1474 ((and (not caption) (not label)) "")
1475 ((not caption) (format "\\label{%s}\n" label))
1476 ;; Option caption format with short name.
1477 ((cdr caption)
1478 (format "\\caption[%s]{%s%s}\n"
1479 (org-export-data (cdr caption) info)
1480 label-str
1481 (org-export-data (car caption) info)))
1482 ;; Standard caption format.
1483 ;; (t (format "\\caption{%s%s}\n"
1484 ;; label-str
1485 ;; (org-export-data (car caption) info)))
1486 (t (org-export-data (car caption) info)))))
1488 (defun org-e-html--find-verb-separator (s)
1489 "Return a character not used in string S.
1490 This is used to choose a separator for constructs like \\verb."
1491 (let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
1492 (loop for c across ll
1493 when (not (string-match (regexp-quote (char-to-string c)) s))
1494 return (char-to-string c))))
1496 (defun org-e-html--quotation-marks (text info)
1497 "Export quotation marks depending on language conventions.
1498 TEXT is a string containing quotation marks to be replaced. INFO
1499 is a plist used as a communication channel."
1500 (mapc (lambda(l)
1501 (let ((start 0))
1502 (while (setq start (string-match (car l) text start))
1503 (let ((new-quote (concat (match-string 1 text) (cdr l))))
1504 (setq text (replace-match new-quote t t text))))))
1505 (cdr (or (assoc (plist-get info :language) org-e-html-quotes)
1506 ;; Falls back on English.
1507 (assoc "en" org-e-html-quotes))))
1508 text)
1510 (defun org-e-html--wrap-label (element output)
1511 "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
1512 This function shouldn't be used for floats. See
1513 `org-e-html--caption/label-string'."
1514 ;; (let ((label (org-element-property :name element)))
1515 ;; (if (or (not output) (not label) (string= output "") (string= label ""))
1516 ;; output
1517 ;; (concat (format "\\label{%s}\n" label) output)))
1518 output)
1522 ;;; Template
1524 (defun org-e-html-meta-info (info)
1525 (let* ((title (org-export-data (plist-get info :title) info))
1526 (author (and (plist-get info :with-author)
1527 (let ((auth (plist-get info :author)))
1528 (and auth (org-export-data auth info)))))
1529 (description (plist-get info :description))
1530 (keywords (plist-get info :keywords)))
1531 (concat
1532 (format "\n<title>%s</title>\n" title)
1533 (format
1534 "\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>"
1535 (or (and org-e-html-coding-system
1536 (fboundp 'coding-system-get)
1537 (coding-system-get org-e-html-coding-system
1538 'mime-charset))
1539 "iso-8859-1"))
1540 (format "\n<meta name=\"title\" content=\"%s\"/>" title)
1541 (format "\n<meta name=\"generator\" content=\"Org-mode\"/>")
1542 (format "\n<meta name=\"generated\" content=\"%s\"/>"
1543 (org-e-html-format-date info))
1544 (format "\n<meta name=\"author\" content=\"%s\"/>" author)
1545 (format "\n<meta name=\"description\" content=\"%s\"/>" description)
1546 (format "\n<meta name=\"keywords\" content=\"%s\"/>" keywords))))
1548 (defun org-e-html-style (info)
1549 (concat
1550 "\n" (when (plist-get info :style-include-default) org-e-html-style-default)
1551 (plist-get info :style)
1552 (plist-get info :style-extra)
1553 "\n"
1554 (when (plist-get info :style-include-scripts)
1555 org-e-html-scripts)))
1557 (defun org-e-html-mathjax-config (info)
1558 "Insert the user setup into the matchjax template."
1559 (when (member (plist-get info :LaTeX-fragments) '(mathjax t))
1560 (let ((template org-e-html-mathjax-template)
1561 (options org-e-html-mathjax-options)
1562 (in-buffer (or (plist-get info :mathjax) ""))
1563 name val (yes " ") (no "// ") x)
1564 (mapc
1565 (lambda (e)
1566 (setq name (car e) val (nth 1 e))
1567 (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
1568 (setq val (car (read-from-string
1569 (substring in-buffer (match-end 0))))))
1570 (if (not (stringp val)) (setq val (format "%s" val)))
1571 (if (string-match (concat "%" (upcase (symbol-name name))) template)
1572 (setq template (replace-match val t t template))))
1573 options)
1574 (setq val (nth 1 (assq 'mathml options)))
1575 (if (string-match (concat "\\<mathml:") in-buffer)
1576 (setq val (car (read-from-string
1577 (substring in-buffer (match-end 0))))))
1578 ;; Exchange prefixes depending on mathml setting
1579 (if (not val) (setq x yes yes no no x))
1580 ;; Replace cookies to turn on or off the config/jax lines
1581 (if (string-match ":MMLYES:" template)
1582 (setq template (replace-match yes t t template)))
1583 (if (string-match ":MMLNO:" template)
1584 (setq template (replace-match no t t template)))
1585 ;; Return the modified template
1586 template)))
1588 (defun org-e-html-preamble (info)
1589 (when (plist-get info :html-preamble)
1590 (let* ((title (org-export-data (plist-get info :title) info))
1591 (date (org-e-html-format-date info))
1592 (author (org-export-data (plist-get info :author) info))
1593 (lang-words (or (assoc (plist-get info :language)
1594 org-export-language-setup)
1595 (assoc "en" org-export-language-setup)))
1596 (email (plist-get info :email))
1597 (html-pre-real-contents
1598 (cond
1599 ((functionp (plist-get info :html-preamble))
1600 (with-temp-buffer
1601 (funcall (plist-get info :html-preamble))
1602 (buffer-string)))
1603 ((stringp (plist-get info :html-preamble))
1604 (format-spec (plist-get info :html-preamble)
1605 `((?t . ,title) (?a . ,author)
1606 (?d . ,date) (?e . ,email))))
1608 (format-spec
1609 (or (cadr (assoc (nth 0 lang-words)
1610 org-e-html-preamble-format))
1611 (cadr (assoc "en" org-e-html-preamble-format)))
1612 `((?t . ,title) (?a . ,author)
1613 (?d . ,date) (?e . ,email)))))))
1614 (when (not (equal html-pre-real-contents ""))
1615 (concat
1616 (format "
1617 <div id=\"%s\"> " (nth 0 org-e-html-divs))
1620 html-pre-real-contents
1622 </div>")))))
1624 (defun org-e-html-postamble (info)
1625 (concat
1626 (when (and (not body-only)
1627 (plist-get info :html-postamble))
1628 (let* ((html-post (plist-get info :html-postamble))
1629 (date (org-e-html-format-date info))
1630 (author (let ((author (plist-get info :author)))
1631 (and author (org-export-data author info))))
1632 (email (plist-get info :email))
1633 (lang-words (or (assoc (plist-get info :language)
1634 org-export-language-setup)
1635 (assoc "en" org-export-language-setup)))
1636 (email
1637 (mapconcat (lambda(e)
1638 (format "<a href=\"mailto:%s\">%s</a>" e e))
1639 (split-string email ",+ *")
1640 ", "))
1641 (html-validation-link (or org-e-html-validation-link ""))
1642 (creator-info org-export-creator-string))
1643 (concat
1644 ;; begin postamble
1646 <div id=\"" (nth 2 org-e-html-divs) "\">"
1647 (cond
1648 ;; auto postamble
1649 ((eq (plist-get info :html-postamble) 'auto)
1650 (concat
1651 (when (plist-get info :time-stamp-file)
1652 (format "
1653 <p class=\"date\"> %s: %s </p> " (nth 2 lang-words) date))
1654 (when (and (plist-get info :with-author) author)
1655 (format "
1656 <p class=\"author\"> %s : %s</p>" (nth 1 lang-words) author))
1657 (when (and (plist-get info :with-email) email)
1658 (format "
1659 <p class=\"email\"> %s </p>" email))
1660 (when (plist-get info :with-creator)
1661 (format "
1662 <p class=\"creator\"> %s </p>" creator-info))
1663 html-validation-link "\n"))
1664 ;; postamble from a string
1665 ((stringp (plist-get info :html-postamble))
1666 (format-spec (plist-get info :html-postamble)
1667 `((?a . ,author) (?e . ,email)
1668 (?d . ,date) (?c . ,creator-info)
1669 (?v . ,html-validation-link))))
1671 ;; postamble from a function
1672 ((functionp (plist-get info :html-postamble))
1673 (with-temp-buffer
1674 (funcall (plist-get info :html-postamble))
1675 (buffer-string)))
1676 ;; default postamble
1678 (format-spec
1679 (or (cadr (assoc (nth 0 lang-words)
1680 org-e-html-postamble-format))
1681 (cadr (assoc "en" org-e-html-postamble-format)))
1682 `((?a . ,author) (?e . ,email)
1683 (?d . ,date) (?c . ,creator-info)
1684 (?v . ,html-validation-link)))))
1686 </div>")))
1687 ;; org-e-html-html-helper-timestamp
1690 (defun org-e-html-template (contents info)
1691 "Return complete document string after HTML conversion.
1692 CONTENTS is the transcoded contents string. RAW-DATA is the
1693 original parsed data. INFO is a plist holding export options."
1694 (concat
1695 (format
1696 (or (and (stringp org-e-html-xml-declaration)
1697 org-e-html-xml-declaration)
1698 (cdr (assoc (plist-get info :html-extension)
1699 org-e-html-xml-declaration))
1700 (cdr (assoc "html" org-e-html-xml-declaration))
1703 (or (and org-e-html-coding-system
1704 (fboundp 'coding-system-get)
1705 (coding-system-get org-e-html-coding-system
1706 'mime-charset))
1707 "iso-8859-1"))
1709 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
1710 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
1711 (format "
1712 <html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\"> "
1713 (plist-get info :language) (plist-get info :language))
1715 <head>"
1716 (org-e-html-meta-info info) ; meta
1717 (org-e-html-style info) ; style
1718 (org-e-html-mathjax-config info) ; mathjax
1720 </head>"
1723 <body>"
1724 (let ((link-up (org-trim (plist-get info :link-up)))
1725 (link-home (org-trim (plist-get info :link-home))))
1726 (unless (and (string= link-up "") (string= link-up ""))
1727 (format org-e-html-home/up-format
1728 (or link-up link-home)
1729 (or link-home link-up))))
1730 ;; preamble
1731 (org-e-html-preamble info)
1732 ;; begin content
1733 (format "
1734 <div id=\"%s\">" (or org-e-html-content-div
1735 (nth 1 org-e-html-divs)))
1736 ;; document title
1737 (format "
1738 <h1 class=\"title\">%s</h1>\n" (org-export-data (plist-get info :title) info))
1739 ;; table of contents
1740 (let ((depth (plist-get info :with-toc)))
1741 (when (wholenump depth) (org-e-html-toc depth info)))
1742 ;; document contents
1743 contents
1744 ;; footnotes section
1745 (org-e-html-footnote-section info)
1746 ;; bibliography
1747 (org-e-html-bibliography)
1748 ;; end content
1749 (unless body-only
1751 </div>")
1753 ;; postamble
1754 (org-e-html-postamble info)
1756 (unless body-only
1758 </body>")
1760 </html>"))
1764 ;;; Transcode Helpers
1766 ;;;; Todo
1768 (defun org-e-html--todo (todo)
1769 (when todo
1770 (format "<span class=\"%s %s%s\">%s</span>"
1771 (if (member todo org-done-keywords) "done" "todo")
1772 org-e-html-todo-kwd-class-prefix (org-e-html-fix-class-name todo)
1773 todo)))
1775 ;;;; Tags
1777 (defun org-e-html--tags (tags)
1778 (when tags
1779 (format "<span class=\"tag\">%s</span>"
1780 (mapconcat
1781 (lambda (tag)
1782 (format "<span class=\"%s\">%s</span>"
1783 (concat org-e-html-tag-class-prefix
1784 (org-e-html-fix-class-name tag))
1785 tag))
1786 tags "&nbsp;"))))
1788 ;;;; Headline
1790 (defun* org-e-html-format-headline
1791 (todo todo-type priority text tags
1792 &key level section-number headline-label &allow-other-keys)
1793 (let ((section-number
1794 (when section-number
1795 (format "<span class=\"section-number-%d\">%s</span> "
1796 level section-number)))
1797 (todo (org-e-html--todo todo))
1798 (tags (org-e-html--tags tags)))
1799 (concat section-number todo (and todo " ") text
1800 (and tags "&nbsp;&nbsp;&nbsp;") tags)))
1802 ;;;; Src Code
1804 (defun org-e-html-fontify-code (code lang)
1805 (when code
1806 (cond
1807 ;; Case 1: No lang. Possibly an example block.
1808 ((not lang)
1809 ;; Simple transcoding.
1810 (org-e-html-encode-plain-text code))
1811 ;; Case 2: No htmlize or an inferior version of htmlize
1812 ((not (and (require 'htmlize nil t) (fboundp 'htmlize-region-for-paste)))
1813 ;; Emit a warning.
1814 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1815 ;; Simple transcoding.
1816 (org-e-html-encode-plain-text code))
1818 ;; Map language
1819 (setq lang (or (assoc-default lang org-src-lang-modes) lang))
1820 (let* ((lang-mode (and lang (intern (format "%s-mode" lang)))))
1821 (cond
1822 ;; Case 1: Language is not associated with any Emacs mode
1823 ((not (functionp lang-mode))
1824 ;; Simple transcoding.
1825 (org-e-html-encode-plain-text code))
1826 ;; Case 2: Default. Fotify code.
1828 ;; htmlize
1829 (setq code (with-temp-buffer
1830 (insert code)
1831 (funcall lang-mode)
1832 (font-lock-fontify-buffer)
1833 ;; markup each line separately
1834 (org-remove-formatting-on-newlines-in-region
1835 (point-min) (point-max))
1836 (org-src-mode)
1837 (set-buffer-modified-p nil)
1838 (org-export-e-htmlize-region-for-paste
1839 (point-min) (point-max))))
1840 ;; Strip any encolosing <pre></pre> tags
1841 (if (string-match "<pre[^>]*>\n*\\([^\000]*\\)</pre>" code)
1842 (match-string 1 code)
1843 code))))))))
1845 (defun org-e-html-do-format-code
1846 (code &optional lang refs retain-labels num-start textarea-p)
1847 (when textarea-p
1848 (setq num-start nil refs nil lang nil))
1849 (let* ((code-lines (org-split-string code "\n"))
1850 (code-length (length code-lines))
1851 (num-fmt
1852 (and num-start
1853 (format "%%%ds: "
1854 (length (number-to-string (+ code-length num-start))))))
1855 (code (org-e-html-fontify-code code lang)))
1856 (assert (= code-length (length (org-split-string code "\n"))))
1857 (org-export-format-code
1858 code
1859 (lambda (loc line-num ref)
1860 (setq loc
1861 (concat
1862 ;; Add line number, if needed.
1863 (when num-start
1864 (format "<span class=\"linenr\">%s</span>"
1865 (format num-fmt line-num)))
1866 ;; Transcoded src line.
1868 ;; Add label, if needed.
1869 (when (and ref retain-labels) (format " (%s)" ref))))
1870 ;; Mark transcoded line as an anchor, if needed.
1871 (if (not ref) loc
1872 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1873 ref loc)))
1874 num-start refs)))
1876 (defun org-e-html-format-code (element info)
1877 (let* ((lang (org-element-property :language element))
1878 ;; (switches (org-element-property :switches element))
1879 (switches nil) ; FIXME
1880 (textarea-p (and switches (string-match "-t\\>" switches)))
1881 ;; Extract code and references.
1882 (code-info (org-export-unravel-code element))
1883 (code (car code-info))
1884 (refs (cdr code-info))
1885 ;; Does the src block contain labels?
1886 (retain-labels (org-element-property :retain-labels element))
1887 ;; Does it have line numbers?
1888 (num-start (case (org-element-property :number-lines element)
1889 (continued (org-export-get-loc element info))
1890 (new 0))))
1891 (org-e-html-do-format-code
1892 code lang refs retain-labels num-start textarea-p)))
1896 ;;; Transcode Functions
1898 ;;;; Bold
1900 (defun org-e-html-bold (bold contents info)
1901 "Transcode BOLD from Org to HTML.
1902 CONTENTS is the text with bold markup. INFO is a plist holding
1903 contextual information."
1904 (format (or (cdr (assq 'bold org-e-html-text-markup-alist)) "%s")
1905 contents))
1908 ;;;; Center Block
1910 (defun org-e-html-center-block (center-block contents info)
1911 "Transcode a CENTER-BLOCK element from Org to HTML.
1912 CONTENTS holds the contents of the block. INFO is a plist
1913 holding contextual information."
1914 (org-e-html--wrap-label
1915 center-block
1916 (format "<div style=\"text-align: center\">\n%s</div>" contents)))
1919 ;;;; Clock
1921 (defun org-e-html-clock (clock contents info)
1922 "Transcode a CLOCK element from Org to HTML.
1923 CONTENTS is nil. INFO is a plist used as a communication
1924 channel."
1925 (format "<p>
1926 <span class=\"timestamp-wrapper\">
1927 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
1928 </span>
1929 </p>"
1930 org-clock-string
1931 (org-translate-time (org-element-property :value clock))
1932 (let ((time (org-element-property :time clock)))
1933 (and time (format " <span class=\"timestamp\">(%s)</span>" time)))))
1936 ;;;; Code
1938 (defun org-e-html-code (code contents info)
1939 "Transcode CODE from Org to HTML.
1940 CONTENTS is nil. INFO is a plist holding contextual
1941 information."
1942 (format (or (cdr (assq 'code org-e-html-text-markup-alist)) "%s")
1943 (org-element-property :value code)))
1946 ;;;; Comment
1948 ;; Comments are ignored.
1951 ;;;; Comment Block
1953 ;; Comment Blocks are ignored.
1956 ;;;; Drawer
1958 (defun org-e-html-drawer (drawer contents info)
1959 "Transcode a DRAWER element from Org to HTML.
1960 CONTENTS holds the contents of the block. INFO is a plist
1961 holding contextual information."
1962 (let* ((name (org-element-property :drawer-name drawer))
1963 (output (if (functionp org-e-html-format-drawer-function)
1964 (funcall org-e-html-format-drawer-function
1965 name contents)
1966 ;; If there's no user defined function: simply
1967 ;; display contents of the drawer.
1968 contents)))
1969 (org-e-html--wrap-label drawer output)))
1972 ;;;; Dynamic Block
1974 (defun org-e-html-dynamic-block (dynamic-block contents info)
1975 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
1976 CONTENTS holds the contents of the block. INFO is a plist
1977 holding contextual information. See `org-export-data'."
1978 (org-e-html--wrap-label dynamic-block contents))
1981 ;;;; Entity
1983 (defun org-e-html-entity (entity contents info)
1984 "Transcode an ENTITY object from Org to HTML.
1985 CONTENTS are the definition itself. INFO is a plist holding
1986 contextual information."
1987 (org-element-property :html entity))
1990 ;;;; Example Block
1992 (defun org-e-html-example-block (example-block contents info)
1993 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
1994 CONTENTS is nil. INFO is a plist holding contextual information."
1995 (let* ((options (or (org-element-property :options example-block) ""))
1996 (lang (org-element-property :language example-block))
1997 (caption (org-element-property :caption example-block))
1998 (label (org-element-property :name example-block))
1999 (caption-str (org-e-html--caption/label-string caption label info))
2000 (attr (mapconcat #'identity
2001 (org-element-property :attr_html example-block)
2002 " "))
2003 ;; (switches (org-element-property :switches example-block))
2004 (switches nil) ; FIXME
2005 (textarea-p (and switches (string-match "-t\\>" switches)))
2006 (code (org-e-html-format-code example-block info)))
2007 (cond
2008 (textarea-p
2009 (let ((cols (if (not (string-match "-w[ \t]+\\([0-9]+\\)" switches))
2010 80 (string-to-number (match-string 1 switches))))
2011 (rows (if (string-match "-h[ \t]+\\([0-9]+\\)" switches)
2012 (string-to-number (match-string 1 switches))
2013 (org-count-lines code))))
2014 (format
2015 "\n<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s\n</textarea>\n</p>"
2016 cols rows code)))
2017 (t (format "\n<pre class=\"example\">\n%s\n</pre>" code)))))
2020 ;;;; Export Snippet
2022 (defun org-e-html-export-snippet (export-snippet contents info)
2023 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2024 CONTENTS is nil. INFO is a plist holding contextual information."
2025 (when (eq (org-export-snippet-backend export-snippet) 'e-html)
2026 (org-element-property :value export-snippet)))
2029 ;;;; Export Block
2031 (defun org-e-html-export-block (export-block contents info)
2032 "Transcode a EXPORT-BLOCK element from Org to HTML.
2033 CONTENTS is nil. INFO is a plist holding contextual information."
2034 (when (string= (org-element-property :type export-block) "HTML")
2035 (org-remove-indentation (org-element-property :value export-block))))
2038 ;;;; Fixed Width
2040 (defun org-e-html-fixed-width (fixed-width contents info)
2041 "Transcode a FIXED-WIDTH element from Org to HTML.
2042 CONTENTS is nil. INFO is a plist holding contextual information."
2043 (org-e-html--wrap-label
2044 fixed-width
2045 (format "\n<pre class=\"example\">\n%s</pre>"
2046 (org-e-html-do-format-code
2047 (org-remove-indentation
2048 (org-element-property :value fixed-width))))))
2051 ;;;; Footnote Definition
2053 ;; Footnote Definitions are ignored.
2056 ;;;; Footnote Reference
2058 (defun org-e-html-footnote-reference (footnote-reference contents info)
2059 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2060 CONTENTS is nil. INFO is a plist holding contextual information."
2061 (concat
2062 ;; Insert separator between two footnotes in a row.
2063 (let ((prev (org-export-get-previous-element footnote-reference info)))
2064 (when (eq (org-element-type prev) 'footnote-reference)
2065 org-e-html-footnote-separator))
2066 (cond
2067 ((not (org-export-footnote-first-reference-p footnote-reference info))
2068 (org-e-html-format-footnote-reference
2069 (org-export-get-footnote-number footnote-reference info)
2070 "IGNORED" 100))
2071 ;; Inline definitions are secondary strings.
2072 ((eq (org-element-property :type footnote-reference) 'inline)
2073 (org-e-html-format-footnote-reference
2074 (org-export-get-footnote-number footnote-reference info)
2075 "IGNORED" 1))
2076 ;; Non-inline footnotes definitions are full Org data.
2077 (t (org-e-html-format-footnote-reference
2078 (org-export-get-footnote-number footnote-reference info)
2079 "IGNORED" 1)))))
2082 ;;;; Headline
2084 (defun org-e-html-format-headline--wrap (headline info
2085 &optional format-function
2086 &rest extra-keys)
2087 "Transcode an HEADLINE element from Org to HTML.
2088 CONTENTS holds the contents of the headline. INFO is a plist
2089 holding contextual information."
2090 (let* ((level (+ (org-export-get-relative-level headline info)
2091 (1- org-e-html-toplevel-hlevel)))
2092 (headline-number (org-export-get-headline-number headline info))
2093 (section-number (and (org-export-numbered-headline-p headline info)
2094 (mapconcat 'number-to-string
2095 headline-number ".")))
2096 (todo (and (plist-get info :with-todo-keywords)
2097 (let ((todo (org-element-property :todo-keyword headline)))
2098 (and todo (org-export-data todo info)))))
2099 (todo-type (and todo (org-element-property :todo-type headline)))
2100 (priority (and (plist-get info :with-priority)
2101 (org-element-property :priority headline)))
2102 (text (org-export-data (org-element-property :title headline) info))
2103 (tags (and (plist-get info :with-tags)
2104 (org-export-get-tags headline info)))
2105 (headline-label (or (org-element-property :custom-id headline)
2106 (concat "sec-" (mapconcat 'number-to-string
2107 headline-number "-"))))
2108 (format-function (cond
2109 ((functionp format-function) format-function)
2110 ((functionp org-e-html-format-headline-function)
2111 (function*
2112 (lambda (todo todo-type priority text tags
2113 &allow-other-keys)
2114 (funcall org-e-html-format-headline-function
2115 todo todo-type priority text tags))))
2116 (t 'org-e-html-format-headline))))
2117 (apply format-function
2118 todo todo-type priority text tags
2119 :headline-label headline-label :level level
2120 :section-number section-number extra-keys)))
2122 (defun org-e-html-headline (headline contents info)
2123 "Transcode an HEADLINE element from Org to HTML.
2124 CONTENTS holds the contents of the headline. INFO is a plist
2125 holding contextual information."
2126 ;; Empty contents?
2127 (setq contents (or contents ""))
2128 (let* ((numberedp (org-export-numbered-headline-p headline info))
2129 (level (org-export-get-relative-level headline info))
2130 (text (org-export-data (org-element-property :title headline) info))
2131 (todo (and (plist-get info :with-todo-keywords)
2132 (let ((todo (org-element-property :todo-keyword headline)))
2133 (and todo (org-export-data todo info)))))
2134 (todo-type (and todo (org-element-property :todo-type headline)))
2135 (tags (and (plist-get info :with-tags)
2136 (org-export-get-tags headline info)))
2137 (priority (and (plist-get info :with-priority)
2138 (org-element-property :priority headline)))
2139 (section-number (and (org-export-numbered-headline-p headline info)
2140 (mapconcat 'number-to-string
2141 (org-export-get-headline-number
2142 headline info) ".")))
2143 ;; Create the headline text.
2144 (full-text (org-e-html-format-headline--wrap headline info)))
2145 (cond
2146 ;; Case 1: This is a footnote section: ignore it.
2147 ((org-element-property :footnote-section-p headline) nil)
2148 ;; Case 2. This is a deep sub-tree: export it as a list item.
2149 ;; Also export as items headlines for which no section
2150 ;; format has been found.
2151 ((org-export-low-level-p headline info) ; FIXME (or (not section-fmt))
2152 ;; Build the real contents of the sub-tree.
2153 (let* ((type (if numberedp 'unordered 'unordered)) ; FIXME
2154 (itemized-body (org-e-html-format-list-item
2155 contents type nil nil full-text)))
2156 (concat
2157 (and (org-export-first-sibling-p headline info)
2158 (org-e-html-begin-plain-list type))
2159 itemized-body
2160 (and (org-export-last-sibling-p headline info)
2161 (org-e-html-end-plain-list type)))))
2162 ;; Case 3. Standard headline. Export it as a section.
2164 (let* ((section-number (mapconcat 'number-to-string
2165 (org-export-get-headline-number
2166 headline info) "-"))
2167 (ids (remove 'nil
2168 (list (org-element-property :custom-id headline)
2169 (org-element-property :id headline)
2170 (concat "sec-" section-number))))
2171 (preferred-id (car ids))
2172 (extra-ids (cdr ids))
2173 (extra-class (org-element-property :html-container-class headline))
2174 (level1 (+ level (1- org-e-html-toplevel-hlevel))))
2175 (format "<div id=\"%s\" class=\"%s\">%s%s</div>\n"
2176 (format "outline-container-%s"
2177 (if (zerop (length extra-ids)) section-number
2178 preferred-id))
2179 (concat (format "outline-%d" level1) (and extra-class " ")
2180 extra-class)
2181 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2182 level1
2183 preferred-id
2184 (mapconcat
2185 (lambda (x)
2186 (let ((id (org-solidify-link-text
2187 (if (org-uuidgen-p x) (concat "ID-" x)
2188 x))))
2189 (format "<a id=\"%s\" name=\"%s\"/>" id id)))
2190 extra-ids "")
2191 full-text
2192 level1)
2193 contents))))))
2196 ;;;; Horizontal Rule
2198 (defun org-e-html-horizontal-rule (horizontal-rule contents info)
2199 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2200 CONTENTS is nil. INFO is a plist holding contextual information."
2201 (let ((attr (mapconcat #'identity
2202 (org-element-property :attr_html horizontal-rule)
2203 " ")))
2204 (org-e-html--wrap-label horizontal-rule "<hr/>\n")))
2207 ;;;; Inline Babel Call
2209 ;; Inline Babel Calls are ignored.
2212 ;;;; Inline Src Block
2214 (defun org-e-html-inline-src-block (inline-src-block contents info)
2215 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2216 CONTENTS holds the contents of the item. INFO is a plist holding
2217 contextual information."
2218 (let* ((org-lang (org-element-property :language inline-src-block))
2219 (code (org-element-property :value inline-src-block))
2220 (separator (org-e-html--find-verb-separator code)))
2221 (error "FIXME")))
2224 ;;;; Inlinetask
2226 (defun org-e-html-format-section (text class &optional id)
2227 (let ((extra (concat (when id (format " id=\"%s\"" id)))))
2228 (concat (format "<div class=\"%s\"%s>\n" class extra) text "</div>\n")))
2230 (defun org-e-html-inlinetask (inlinetask contents info)
2231 "Transcode an INLINETASK element from Org to HTML.
2232 CONTENTS holds the contents of the block. INFO is a plist
2233 holding contextual information."
2234 (cond
2235 ;; If `org-e-html-format-inlinetask-function' is provided, call it
2236 ;; with appropriate arguments.
2237 ((functionp org-e-html-format-inlinetask-function)
2238 (let ((format-function
2239 (function*
2240 (lambda (todo todo-type priority text tags
2241 &key contents &allow-other-keys)
2242 (funcall org-e-html-format-inlinetask-function
2243 todo todo-type priority text tags contents)))))
2244 (org-e-html-format-headline--wrap
2245 inlinetask info format-function :contents contents)))
2246 ;; Otherwise, use a default template.
2247 (t (org-e-html--wrap-label
2248 inlinetask
2249 (format
2250 "\n<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s\n</div>"
2251 (org-e-html-format-headline--wrap inlinetask info)
2252 contents)))))
2255 ;;;; Italic
2257 (defun org-e-html-italic (italic contents info)
2258 "Transcode ITALIC from Org to HTML.
2259 CONTENTS is the text with italic markup. INFO is a plist holding
2260 contextual information."
2261 (format (or (cdr (assq 'italic org-e-html-text-markup-alist)) "%s") contents))
2264 ;;;; Item
2266 (defun org-e-html-checkbox (checkbox)
2267 (case checkbox (on "<code>[X]</code>")
2268 (off "<code>[&nbsp;]</code>")
2269 (trans "<code>[-]</code>")
2270 (t "")))
2272 (defun org-e-html-format-list-item (contents type checkbox
2273 &optional term-counter-id
2274 headline)
2275 (concat
2276 (case type
2277 (ordered
2278 (let* ((counter term-counter-id)
2279 (extra (if counter (format " value=\"%s\"" counter) "")))
2280 (format "<li%s>" extra)))
2281 (unordered
2282 (let* ((id term-counter-id)
2283 (extra (if id (format " id=\"%s\"" id) "")))
2284 (concat
2285 (format "<li%s>" extra)
2286 (when headline (concat headline "<br/>")))))
2287 (descriptive
2288 (let* ((term term-counter-id))
2289 (setq term (or term "(no term)"))
2290 (concat (format "<dt> %s </dt>" term) "<dd>"))))
2291 (org-e-html-checkbox checkbox) (and checkbox " ")
2292 contents
2293 (case type
2294 (ordered "</li>")
2295 (unordered "</li>")
2296 (descriptive "</dd>"))))
2298 (defun org-e-html-item (item contents info)
2299 "Transcode an ITEM element from Org to HTML.
2300 CONTENTS holds the contents of the item. INFO is a plist holding
2301 contextual information."
2302 (let* ((plain-list (org-export-get-parent item info))
2303 (type (org-element-property :type plain-list))
2304 (counter (org-element-property :counter item))
2305 (checkbox (org-element-property :checkbox item))
2306 (tag (let ((tag (org-element-property :tag item)))
2307 (and tag (org-export-data tag info)))))
2308 (org-e-html-format-list-item
2309 contents type checkbox (or tag counter))))
2312 ;;;; Keyword
2314 (defun org-e-html-keyword (keyword contents info)
2315 "Transcode a KEYWORD element from Org to HTML.
2316 CONTENTS is nil. INFO is a plist holding contextual information."
2317 (let ((key (org-element-property :key keyword))
2318 (value (org-element-property :value keyword)))
2319 (cond
2320 ((string= key "LATEX") value)
2321 ((string= key "INDEX") (format "\\index{%s}" value))
2322 ;; Invisible targets.
2323 ((string= key "TARGET") nil) ; FIXME
2324 ((string= key "TOC")
2325 (let ((value (downcase value)))
2326 (cond
2327 ((string-match "\\<headlines\\>" value)
2328 (let ((depth (or (and (string-match "[0-9]+" value)
2329 (string-to-number (match-string 0 value)))
2330 (plist-get info :with-toc))))
2331 (when (wholenump depth) (org-e-html-toc depth info))))
2332 ((string= "tables" value) "\\listoftables")
2333 ((string= "figures" value) "\\listoffigures")
2334 ((string= "listings" value)
2335 (cond
2336 ;; At the moment, src blocks with a caption are wrapped
2337 ;; into a figure environment.
2338 (t "\\listoffigures")))))))))
2341 ;;;; Latex Environment
2343 (defun org-e-html-format-latex (latex-frag processing-type)
2344 (let* ((cache-relpath
2345 (concat "ltxpng/" (file-name-sans-extension
2346 (file-name-nondirectory (buffer-file-name)))))
2347 (cache-dir (file-name-directory (buffer-file-name )))
2348 (display-msg "Creating LaTeX Image..."))
2350 (with-temp-buffer
2351 (insert latex-frag)
2352 (org-format-latex cache-relpath cache-dir nil display-msg
2353 nil nil processing-type)
2354 (buffer-string))))
2356 (defun org-e-html-latex-environment (latex-environment contents info)
2357 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2358 CONTENTS is nil. INFO is a plist holding contextual information."
2359 (org-e-html--wrap-label
2360 latex-environment
2361 (let ((processing-type (plist-get info :LaTeX-fragments))
2362 (latex-frag (org-remove-indentation
2363 (org-element-property :value latex-environment)))
2364 (caption (org-e-html--caption/label-string
2365 (org-element-property :caption latex-environment)
2366 (org-element-property :name latex-environment)
2367 info))
2368 (attr nil) ; FIXME
2369 (label (org-element-property :name latex-environment)))
2370 (cond
2371 ((member processing-type '(t mathjax))
2372 (org-e-html-format-latex latex-frag 'mathjax))
2373 ((equal processing-type 'dvipng)
2374 (let* ((formula-link (org-e-html-format-latex
2375 latex-frag processing-type)))
2376 (when (and formula-link
2377 (string-match "file:\\([^]]*\\)" formula-link))
2378 (org-e-html-format-inline-image
2379 (match-string 1 formula-link) caption label attr t))))
2380 (t latex-frag)))))
2383 ;;;; Latex Fragment
2385 (defun org-e-html-latex-fragment (latex-fragment contents info)
2386 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2387 CONTENTS is nil. INFO is a plist holding contextual information."
2388 (let ((latex-frag (org-element-property :value latex-fragment))
2389 (processing-type (plist-get info :LaTeX-fragments)))
2390 (case processing-type
2391 ((t mathjax)
2392 (org-e-html-format-latex latex-frag 'mathjax))
2393 (dvipng
2394 (let* ((formula-link (org-e-html-format-latex
2395 latex-frag processing-type)))
2396 (when (and formula-link
2397 (string-match "file:\\([^]]*\\)" formula-link))
2398 (org-e-html-format-inline-image
2399 (match-string 1 formula-link)))))
2400 (t latex-frag))))
2402 ;;;; Line Break
2404 (defun org-e-html-line-break (line-break contents info)
2405 "Transcode a LINE-BREAK object from Org to HTML.
2406 CONTENTS is nil. INFO is a plist holding contextual information."
2407 "<br/>")
2410 ;;;; Link
2412 (defun org-e-html-link--inline-image (link desc info)
2413 "Return HTML code for an inline image.
2414 LINK is the link pointing to the inline image. INFO is a plist
2415 used as a communication channel."
2416 (let* ((type (org-element-property :type link))
2417 (raw-path (org-element-property :path link))
2418 (path (cond ((member type '("http" "https"))
2419 (concat type ":" raw-path))
2420 ((file-name-absolute-p raw-path)
2421 (expand-file-name raw-path))
2422 (t raw-path)))
2423 (parent (org-export-get-parent-paragraph link info))
2424 (caption (org-e-html--caption/label-string
2425 (org-element-property :caption parent)
2426 (org-element-property :name parent)
2427 info))
2428 (label (org-element-property :name parent))
2429 ;; Retrieve latex attributes from the element around.
2430 (attr (let ((raw-attr
2431 (mapconcat #'identity
2432 (org-element-property :attr_html parent)
2433 " ")))
2434 (unless (string= raw-attr "") raw-attr))))
2435 ;; Now clear ATTR from any special keyword and set a default
2436 ;; value if nothing is left.
2437 (setq attr (if (not attr) "" (org-trim attr)))
2438 ;; Return proper string, depending on DISPOSITION.
2439 (org-e-html-format-inline-image
2440 path caption label attr (org-e-html-standalone-image-p link info))))
2442 (defvar org-e-html-standalone-image-predicate)
2443 (defun org-e-html-standalone-image-p (element info &optional predicate)
2444 "Test if ELEMENT is a standalone image for the purpose HTML export.
2445 INFO is a plist holding contextual information.
2447 Return non-nil, if ELEMENT is of type paragraph and it's sole
2448 content, save for whitespaces, is a link that qualifies as an
2449 inline image.
2451 Return non-nil, if ELEMENT is of type link and it's containing
2452 paragraph has no other content save for leading and trailing
2453 whitespaces.
2455 Return nil, otherwise.
2457 Bind `org-e-html-standalone-image-predicate' to constrain
2458 paragraph further. For example, to check for only captioned
2459 standalone images, do the following.
2461 \(setq org-e-html-standalone-image-predicate
2462 \(lambda \(paragraph\)
2463 \(org-element-property :caption paragraph\)\)\)
2465 (let ((paragraph (case (org-element-type element)
2466 (paragraph element)
2467 (link (and (org-export-inline-image-p
2468 element org-e-html-inline-image-rules)
2469 (org-export-get-parent element info)))
2470 (t nil))))
2471 (when paragraph
2472 (assert (eq (org-element-type paragraph) 'paragraph))
2473 (when (or (not (and (boundp 'org-e-html-standalone-image-predicate)
2474 (functionp org-e-html-standalone-image-predicate)))
2475 (funcall org-e-html-standalone-image-predicate paragraph))
2476 (let ((contents (org-element-contents paragraph)))
2477 (loop for x in contents
2478 with inline-image-count = 0
2479 always (cond
2480 ((eq (org-element-type x) 'plain-text)
2481 (not (org-string-nw-p x)))
2482 ((eq (org-element-type x) 'link)
2483 (when (org-export-inline-image-p
2484 x org-e-html-inline-image-rules)
2485 (= (incf inline-image-count) 1)))
2486 (t nil))))))))
2488 (defun org-e-html-link (link desc info)
2489 "Transcode a LINK object from Org to HTML.
2491 DESC is the description part of the link, or the empty string.
2492 INFO is a plist holding contextual information. See
2493 `org-export-data'."
2494 (let* ((type (org-element-property :type link))
2495 (raw-path (org-element-property :path link))
2496 ;; Ensure DESC really exists, or set it to nil.
2497 (desc (and (not (string= desc "")) desc))
2498 (path (cond
2499 ((member type '("http" "https" "ftp" "mailto"))
2500 (concat type ":" raw-path))
2501 ((string= type "file")
2502 (when (string-match "\\(.+\\)::.+" raw-path)
2503 (setq raw-path (match-string 1 raw-path)))
2504 (if (file-name-absolute-p raw-path)
2505 (concat "file://" (expand-file-name raw-path))
2506 (concat "file://" raw-path)))
2507 (t raw-path)))
2508 protocol)
2509 (cond
2510 ;; Image file.
2511 ((and (or (eq t org-e-html-inline-images)
2512 (and org-e-html-inline-images (not desc)))
2513 (org-export-inline-image-p link org-e-html-inline-image-rules))
2514 (org-e-html-link--inline-image link desc info))
2515 ;; Radio target: Transcode target's contents and use them as
2516 ;; link's description.
2517 ((string= type "radio")
2518 (let ((destination (org-export-resolve-radio-link link info)))
2519 (when destination
2520 (format "<a href=\"#%s\">%s</a>"
2521 (org-export-solidify-link-text path)
2522 (org-export-data (org-element-contents destination) info)))))
2523 ;; Links pointing to an headline: Find destination and build
2524 ;; appropriate referencing command.
2525 ((member type '("custom-id" "fuzzy" "id"))
2526 (let ((destination (if (string= type "fuzzy")
2527 (org-export-resolve-fuzzy-link link info)
2528 (org-export-resolve-id-link link info))))
2529 (case (org-element-type destination)
2530 ;; Fuzzy link points nowhere.
2531 ((nil)
2532 (format "<i>%s</i>"
2533 (or desc
2534 (org-export-data
2535 (org-element-property :raw-link link) info))))
2536 ;; Fuzzy link points to an invisible target.
2537 (keyword nil)
2538 ;; Link points to an headline.
2539 (headline
2540 (let ((href
2541 ;; What href to use?
2542 (cond
2543 ;; Case 1: Headline is linked via it's CUSTOM_ID
2544 ;; property. Use CUSTOM_ID.
2545 ((string= type "custom-id")
2546 (org-element-property :custom-id destination))
2547 ;; Case 2: Headline is linked via it's ID property
2548 ;; or through other means. Use the default href.
2549 ((member type '("id" "fuzzy"))
2550 (format "sec-%s"
2551 (mapconcat 'number-to-string
2552 (org-export-get-headline-number
2553 destination info) "-")))
2554 (t (error "Shouldn't reach here"))))
2555 (desc
2556 ;; What description to use?
2557 (cond
2558 ;; Case 1: Link already has a description. Use it.
2559 (desc desc)
2560 ;; Case 2: Link has no description and headline is
2561 ;; numbered. Use the section number.
2562 ((org-export-numbered-headline-p destination info)
2563 (mapconcat 'number-to-string
2564 (org-export-get-headline-number
2565 destination info) "."))
2566 ;; Case 3: Link has no description and headline is
2567 ;; un-numbered. Use the headline title.
2568 (t (org-export-data
2569 (org-element-property :title destination) info)))))
2570 (format "<a href=\"#%s\">%s</a>"
2571 (org-solidify-link-text href) desc)))
2572 ;; Fuzzy link points to a target. Do as above.
2574 (let ((path (org-export-solidify-link-text path)) number)
2575 (unless desc
2576 (setq number (cond
2577 ((org-e-html-standalone-image-p destination info)
2578 (org-export-get-ordinal
2579 (assoc 'link (org-element-contents destination))
2580 info 'link 'org-e-html-standalone-image-p))
2581 (t (org-export-get-ordinal destination info))))
2582 (setq desc (when number
2583 (if (atom number) (number-to-string number)
2584 (mapconcat 'number-to-string number ".")))))
2585 (format "<a href=\"#%s\">%s</a>" path (or desc "FIXME")))))))
2586 ;; Coderef: replace link with the reference name or the
2587 ;; equivalent line number.
2588 ((string= type "coderef")
2589 (let ((fragment (concat "coderef-" path)))
2590 (format "<a href=\"#%s\" %s>%s</a>" fragment
2591 (format (concat "class=\"coderef\""
2592 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2593 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2594 fragment fragment)
2595 (format (org-export-get-coderef-format path desc)
2596 (org-export-resolve-coderef path info)))))
2597 ;; Link type is handled by a special function.
2598 ((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
2599 (funcall protocol (org-link-unescape path) desc 'html))
2600 ;; External link with a description part.
2601 ((and path desc) (format "<a href=\"%s\">%s</a>" path desc))
2602 ;; External link without a description part.
2603 (path (format "<a href=\"%s\">%s</a>" path path))
2604 ;; No path, only description. Try to do something useful.
2605 (t (format "<i>%s</i>" desc)))))
2608 ;;;; Babel Call
2610 ;; Babel Calls are ignored.
2613 ;;;; Macro
2615 (defun org-e-html-macro (macro contents info)
2616 "Transcode a MACRO element from Org to HTML.
2617 CONTENTS is nil. INFO is a plist holding contextual information."
2618 ;; Use available tools.
2619 (org-export-expand-macro macro info))
2622 ;;;; Paragraph
2624 (defun org-e-html-paragraph (paragraph contents info)
2625 "Transcode a PARAGRAPH element from Org to HTML.
2626 CONTENTS is the contents of the paragraph, as a string. INFO is
2627 the plist used as a communication channel."
2628 (let* ((style nil) ; FIXME
2629 (class (cdr (assoc style '((footnote . "footnote")
2630 (verse . nil)))))
2631 (extra (if class (format " class=\"%s\"" class) ""))
2632 (parent (org-export-get-parent paragraph info)))
2633 (cond
2634 ((and (equal (car parent) 'item)
2635 (= (org-element-property :begin paragraph)
2636 (org-element-property :contents-begin parent)))
2637 ;; leading paragraph in a list item have no tags
2638 contents)
2639 ((org-e-html-standalone-image-p paragraph info)
2640 ;; standalone image
2641 contents)
2642 (t (format "<p%s>\n%s\n</p>" extra contents)))))
2645 ;;;; Plain List
2647 (defun org-e-html-begin-plain-list (type &optional arg1)
2648 (case type
2649 (ordered
2650 (format "<ol%s>" (if arg1 ; FIXME
2651 (format " start=\"%d\"" arg1)
2652 "")))
2653 (unordered "<ul>")
2654 (descriptive "<dl>")))
2656 (defun org-e-html-end-plain-list (type)
2657 (case type
2658 (ordered "</ol>")
2659 (unordered "</ul>")
2660 (descriptive "</dl>")))
2662 (defun org-e-html-plain-list (plain-list contents info)
2663 "Transcode a PLAIN-LIST element from Org to HTML.
2664 CONTENTS is the contents of the list. INFO is a plist holding
2665 contextual information."
2666 (let* (arg1 ;; FIXME
2667 (type (org-element-property :type plain-list))
2668 (attr (mapconcat #'identity
2669 (org-element-property :attr_html plain-list)
2670 " ")))
2671 (org-e-html--wrap-label
2672 plain-list (format "%s\n%s%s"
2673 (org-e-html-begin-plain-list type)
2674 contents (org-e-html-end-plain-list type)))))
2676 ;;;; Plain Text
2678 (defun org-e-html-convert-special-strings (string)
2679 "Convert special characters in STRING to HTML."
2680 (let ((all org-e-html-special-string-regexps)
2681 e a re rpl start)
2682 (while (setq a (pop all))
2683 (setq re (car a) rpl (cdr a) start 0)
2684 (while (string-match re string start)
2685 (setq string (replace-match rpl t nil string))))
2686 string))
2688 (defun org-e-html-encode-plain-text (s)
2689 "Convert plain text characters to HTML equivalent.
2690 Possible conversions are set in `org-export-html-protect-char-alist'."
2691 (let ((cl org-e-html-protect-char-alist) c)
2692 (while (setq c (pop cl))
2693 (let ((start 0))
2694 (while (string-match (car c) s start)
2695 (setq s (replace-match (cdr c) t t s)
2696 start (1+ (match-beginning 0))))))
2699 (defun org-e-html-plain-text (text info)
2700 "Transcode a TEXT string from Org to HTML.
2701 TEXT is the string to transcode. INFO is a plist holding
2702 contextual information."
2703 (setq text (org-e-html-encode-plain-text text))
2704 ;; Protect %, #, &, $, ~, ^, _, { and }.
2705 ;; (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" text)
2706 ;; (setq text
2707 ;; (replace-match (format "\\%s" (match-string 2 text)) nil t text 2)))
2708 ;; Protect \
2709 ;; (setq text (replace-regexp-in-string
2710 ;; "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
2711 ;; "$\\backslash$" text nil t 1))
2712 ;; HTML into \HTML{} and TeX into \TeX{}.
2713 ;; (let ((case-fold-search nil)
2714 ;; (start 0))
2715 ;; (while (string-match "\\<\\(\\(?:La\\)?TeX\\)\\>" text start)
2716 ;; (setq text (replace-match
2717 ;; (format "\\%s{}" (match-string 1 text)) nil t text)
2718 ;; start (match-end 0))))
2719 ;; Handle quotation marks
2720 ;; (setq text (org-e-html--quotation-marks text info))
2721 ;; Convert special strings.
2722 ;; (when (plist-get info :with-special-strings)
2723 ;; (while (string-match (regexp-quote "...") text)
2724 ;; (setq text (replace-match "\\ldots{}" nil t text))))
2725 (when (plist-get info :with-special-strings)
2726 (setq text (org-e-html-convert-special-strings text)))
2727 ;; Handle break preservation if required.
2728 (when (plist-get info :preserve-breaks)
2729 (setq text (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n"
2730 text)))
2731 ;; Return value.
2732 text)
2735 ;; Planning
2737 (defun org-e-html-planning (planning contents info)
2738 "Transcode a PLANNING element from Org to HTML.
2739 CONTENTS is nil. INFO is a plist used as a communication
2740 channel."
2741 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2742 (format
2743 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2744 (mapconcat
2745 'identity
2746 (delq nil
2747 (list
2748 (let ((closed (org-element-property :closed planning)))
2749 (when closed
2750 (format span-fmt org-closed-string
2751 (org-translate-time closed))))
2752 (let ((deadline (org-element-property :deadline planning)))
2753 (when deadline
2754 (format span-fmt org-deadline-string
2755 (org-translate-time deadline))))
2756 (let ((scheduled (org-element-property :scheduled planning)))
2757 (when scheduled
2758 (format span-fmt org-scheduled-string
2759 (org-translate-time scheduled))))))
2760 " "))))
2763 ;;;; Property Drawer
2765 (defun org-e-html-property-drawer (property-drawer contents info)
2766 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2767 CONTENTS is nil. INFO is a plist holding contextual
2768 information."
2769 ;; The property drawer isn't exported but we want separating blank
2770 ;; lines nonetheless.
2774 ;;;; Quote Block
2776 (defun org-e-html-quote-block (quote-block contents info)
2777 "Transcode a QUOTE-BLOCK element from Org to HTML.
2778 CONTENTS holds the contents of the block. INFO is a plist
2779 holding contextual information."
2780 (org-e-html--wrap-label
2781 quote-block (format "<blockquote>\n%s</blockquote>" contents)))
2784 ;;;; Quote Section
2786 (defun org-e-html-quote-section (quote-section contents info)
2787 "Transcode a QUOTE-SECTION element from Org to HTML.
2788 CONTENTS is nil. INFO is a plist holding contextual information."
2789 (let ((value (org-remove-indentation
2790 (org-element-property :value quote-section))))
2791 (when value (format "<pre>\n%s</pre>" value))))
2794 ;;;; Section
2796 (defun org-e-html-section (section contents info) ; FIXME
2797 "Transcode a SECTION element from Org to HTML.
2798 CONTENTS holds the contents of the section. INFO is a plist
2799 holding contextual information."
2800 (let ((parent (org-export-get-parent-headline section info)))
2801 ;; Before first headline: no container, just return CONTENTS.
2802 (if (not parent) contents
2803 ;; Get div's class and id references.
2804 (let* ((class-num (+ (org-export-get-relative-level parent info)
2805 (1- org-e-html-toplevel-hlevel)))
2806 (section-number
2807 (mapconcat
2808 'number-to-string
2809 (org-export-get-headline-number parent info) "-"))
2810 (ids (remove 'nil
2811 (list (org-element-property :custom-id parent)
2812 (org-element-property :id parent)
2813 (concat "sec-" section-number))))
2814 (preferred-id (car ids))
2815 (extra-ids (cdr ids)))
2816 ;; Build return value.
2817 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2818 class-num
2819 (if (zerop (length extra-ids)) section-number preferred-id)
2820 contents)))))
2822 ;;;; Radio Target
2824 (defun org-e-html-radio-target (radio-target text info)
2825 "Transcode a RADIO-TARGET object from Org to HTML.
2826 TEXT is the text of the target. INFO is a plist holding
2827 contextual information."
2828 (let ((id (org-export-solidify-link-text
2829 (org-element-property :value radio-target))))
2830 (format "<a id=\"%s\" name=\"%s\">%s</a>" id id text)))
2833 ;;;; Special Block
2835 (defun org-e-html-special-block (special-block contents info)
2836 "Transcode a SPECIAL-BLOCK element from Org to HTML.
2837 CONTENTS holds the contents of the block. INFO is a plist
2838 holding contextual information."
2839 (let ((type (downcase (org-element-property :type special-block))))
2840 (org-e-html--wrap-label
2841 special-block
2842 (format "\\begin{%s}\n%s\\end{%s}" type contents type))))
2845 ;;;; Src Block
2847 (defun org-e-html-src-block (src-block contents info)
2848 "Transcode a SRC-BLOCK element from Org to HTML.
2849 CONTENTS holds the contents of the item. INFO is a plist holding
2850 contextual information."
2851 (let* ((lang (org-element-property :language src-block))
2852 (caption (org-element-property :caption src-block))
2853 (label (org-element-property :name src-block))
2854 (caption-str (org-e-html--caption/label-string caption label info))
2855 (attr (mapconcat #'identity
2856 (org-element-property :attr_html src-block)
2857 " "))
2858 ;; (switches (org-element-property :switches src-block))
2859 (switches nil) ; FIXME
2860 (textarea-p (and switches (string-match "-t\\>" switches)))
2861 (code (org-e-html-format-code src-block info)))
2862 (cond
2863 (lang (format
2864 "\n<div class=\"org-src-container\">\n%s%s\n</div>"
2865 (if (not caption) ""
2866 (format "<label class=\"org-src-name\">%s</label>" caption-str))
2867 (format "\n<pre class=\"src src-%s\">%s\n</pre>" lang code)))
2868 (textarea-p
2869 (let ((cols (if (not (string-match "-w[ \t]+\\([0-9]+\\)" switches))
2870 80 (string-to-number (match-string 1 switches))))
2871 (rows (if (string-match "-h[ \t]+\\([0-9]+\\)" switches)
2872 (string-to-number (match-string 1 switches))
2873 (org-count-lines code))))
2874 (format
2875 "\n<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s\n</textarea>\n</p>"
2876 cols rows code)))
2877 (t (format "\n<pre class=\"example\">\n%s\n</pre>" code)))))
2879 ;;;; Statistics Cookie
2881 (defun org-e-html-statistics-cookie (statistics-cookie contents info)
2882 "Transcode a STATISTICS-COOKIE object from Org to HTML.
2883 CONTENTS is nil. INFO is a plist holding contextual information."
2884 (let ((cookie-value (org-element-property :value statistics-cookie)))
2885 (format "<code>%s</code>" cookie-value)))
2888 ;;;; Strike-Through
2890 (defun org-e-html-strike-through (strike-through contents info)
2891 "Transcode STRIKE-THROUGH from Org to HTML.
2892 CONTENTS is the text with strike-through markup. INFO is a plist
2893 holding contextual information."
2894 (format (or (cdr (assq 'strike-through org-e-html-text-markup-alist)) "%s")
2895 contents))
2898 ;;;; Subscript
2900 (defun org-e-html-subscript (subscript contents info)
2901 "Transcode a SUBSCRIPT object from Org to HTML.
2902 CONTENTS is the contents of the object. INFO is a plist holding
2903 contextual information."
2904 (format "<sub>%s</sub>" contents))
2907 ;;;; Superscript
2909 (defun org-e-html-superscript (superscript contents info)
2910 "Transcode a SUPERSCRIPT object from Org to HTML.
2911 CONTENTS is the contents of the object. INFO is a plist holding
2912 contextual information."
2913 (format "<sup>%s</sup>" contents))
2916 ;;;; Tabel Cell
2918 (defun org-e-html-table-cell (table-cell contents info)
2919 "Transcode a TABLE-CELL element from Org to HTML.
2920 CONTENTS is nil. INFO is a plist used as a communication
2921 channel."
2922 (let* ((table-row (org-export-get-parent table-cell info))
2923 (table (org-export-get-parent-table table-cell info))
2924 (cell-attrs
2925 (if (not org-e-html-table-align-individual-fields) ""
2926 (format (if (and (boundp 'org-e-html-format-table-no-css)
2927 org-e-html-format-table-no-css)
2928 " align=\"%s\"" " class=\"%s\"")
2929 (org-export-table-cell-alignment table-cell info)))))
2930 (when (or (not contents) (string= "" (org-trim contents)))
2931 (setq contents "&nbsp;"))
2932 (cond
2933 ((and (org-export-table-has-header-p table info)
2934 (= 1 (org-export-table-row-group table-row info)))
2935 (concat "\n" (format (car org-e-html-table-header-tags) "col" cell-attrs)
2936 contents (cdr org-e-html-table-header-tags)))
2937 ((and org-e-html-table-use-header-tags-for-first-column
2938 (zerop (cdr (org-export-table-cell-address table-cell info))))
2939 (concat "\n" (format (car org-e-html-table-header-tags) "row" cell-attrs)
2940 contents (cdr org-e-html-table-header-tags)))
2941 (t (concat "\n" (format (car org-e-html-table-data-tags) cell-attrs)
2942 contents (cdr org-e-html-table-data-tags))))))
2945 ;;;; Table Row
2947 (defun org-e-html-table-row (table-row contents info)
2948 "Transcode a TABLE-ROW element from Org to HTML.
2949 CONTENTS is the contents of the row. INFO is a plist used as a
2950 communication channel."
2951 ;; Rules are ignored since table separators are deduced from
2952 ;; borders of the current row.
2953 (when (eq (org-element-property :type table-row) 'standard)
2954 (let* ((first-rowgroup-p (= 1 (org-export-table-row-group table-row info)))
2955 (rowgroup-tags
2956 (cond
2957 ;; Case 1: Row belongs to second or subsequent rowgroups.
2958 ((not (= 1 (org-export-table-row-group table-row info)))
2959 '("\n<tbody>" . "\n</tbody>"))
2960 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
2961 ((org-export-table-has-header-p
2962 (org-export-get-parent-table table-row info) info)
2963 '("\n<thead>" . "\n</thead>"))
2964 ;; Case 2: Row is from first and only row group.
2965 (t '("\n<tbody>" . "\n</tbody>")))))
2966 (concat
2967 ;; Begin a rowgroup?
2968 (when (org-export-table-row-starts-rowgroup-p table-row info)
2969 (car rowgroup-tags))
2970 ;; Actual table row
2971 (concat "\n" (eval (car org-e-html-table-row-tags))
2972 contents (eval (cdr org-e-html-table-row-tags)))
2973 ;; End a rowgroup?
2974 (when (org-export-table-row-ends-rowgroup-p table-row info)
2975 (cdr rowgroup-tags))))))
2978 ;;;; Table
2980 (defun org-e-html-table-first-row-data-cells (table info)
2981 (let ((table-row
2982 (org-element-map
2983 table 'table-row
2984 (lambda (row)
2985 (unless (eq (org-element-property :type row) 'rule) row))
2986 info 'first-match))
2987 (special-column-p (org-export-table-has-special-column-p table)))
2988 (if (not special-column-p) (org-element-contents table-row)
2989 (cdr (org-element-contents table-row)))))
2991 (defun org-e-html-table--table.el-table (table info)
2992 (when (eq (org-element-property :type table) 'table.el)
2993 (require 'table)
2994 (let ((outbuf (with-current-buffer
2995 (get-buffer-create "*org-export-table*")
2996 (erase-buffer) (current-buffer))))
2997 (with-temp-buffer
2998 (insert (org-element-property :value table))
2999 (goto-char 1)
3000 (re-search-forward "^[ \t]*|[^|]" nil t)
3001 (table-generate-source 'html outbuf))
3002 (with-current-buffer outbuf
3003 (prog1 (org-trim (buffer-string))
3004 (kill-buffer) )))))
3006 (defun org-e-html-table (table contents info)
3007 "Transcode a TABLE element from Org to HTML.
3008 CONTENTS is the contents of the table. INFO is a plist holding
3009 contextual information."
3010 (case (org-element-property :type table)
3011 ;; Case 1: table.el table. Convert it using appropriate tools.
3012 (table.el (org-e-html-table--table.el-table table info))
3013 ;; Case 2: Standard table.
3015 (let* ((label (org-element-property :name table))
3016 (caption (org-e-html--caption/label-string
3017 (org-element-property :caption table) label info))
3018 (attributes (mapconcat #'identity
3019 (org-element-property :attr_html table)
3020 " "))
3021 (alignspec
3022 (if (and (boundp 'org-e-html-format-table-no-css)
3023 org-e-html-format-table-no-css)
3024 "align=\"%s\"" "class=\"%s\""))
3025 (table-column-specs
3026 (function
3027 (lambda (table info)
3028 (mapconcat
3029 (lambda (table-cell)
3030 (let ((alignment (org-export-table-cell-alignment
3031 table-cell info)))
3032 (concat
3033 ;; Begin a colgroup?
3034 (when (org-export-table-cell-starts-colgroup-p
3035 table-cell info)
3036 "\n<colgroup>")
3037 ;; Add a column. Also specify it's alignment.
3038 (format "\n<col %s/>" (format alignspec alignment))
3039 ;; End a colgroup?
3040 (when (org-export-table-cell-ends-colgroup-p
3041 table-cell info)
3042 "\n</colgroup>"))))
3043 (org-e-html-table-first-row-data-cells table info) "\n"))))
3044 (table-attributes
3045 (let ((table-tag (plist-get info :html-table-tag)))
3046 (concat
3047 (and (string-match "<table\\(.*\\)>" table-tag)
3048 (match-string 1 table-tag))
3049 (and label (format " id=\"%s\""
3050 (org-solidify-link-text label)))))))
3051 ;; Remove last blank line.
3052 (setq contents (substring contents 0 -1))
3053 ;; FIXME: splice
3054 (format "\n<table%s>\n<caption>%s</caption>\n%s\n%s\n</table>"
3055 table-attributes
3056 (or caption "")
3057 (funcall table-column-specs table info)
3058 contents)))))
3060 ;;;; Target
3062 (defun org-e-html-target (target contents info)
3063 "Transcode a TARGET object from Org to HTML.
3064 CONTENTS is nil. INFO is a plist holding contextual
3065 information."
3066 (let ((id (org-export-solidify-link-text
3067 (org-element-property :value target))))
3068 (format "<a id=\"%s\" name=\"%s\"/>" id id)))
3071 ;;;; Timestamp
3073 (defun org-e-html-timestamp (timestamp contents info)
3074 "Transcode a TIMESTAMP object from Org to HTML.
3075 CONTENTS is nil. INFO is a plist holding contextual
3076 information."
3077 (let ((value (org-translate-time (org-element-property :value timestamp))))
3078 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3079 value)))
3082 ;;;; Underline
3084 (defun org-e-html-underline (underline contents info)
3085 "Transcode UNDERLINE from Org to HTML.
3086 CONTENTS is the text with underline markup. INFO is a plist
3087 holding contextual information."
3088 (format (or (cdr (assq 'underline org-e-html-text-markup-alist)) "%s")
3089 contents))
3092 ;;;; Verbatim
3094 (defun org-e-html-verbatim (verbatim contents info)
3095 "Transcode VERBATIM from Org to HTML.
3096 CONTENTS is nil. INFO is a plist holding contextual
3097 information."
3098 (format (or (cdr (assq 'verbatim org-e-html-text-markup-alist)) "%s")
3099 (org-element-property :value verbatim)))
3102 ;;;; Verse Block
3104 (defun org-e-html-verse-block (verse-block contents info)
3105 "Transcode a VERSE-BLOCK element from Org to HTML.
3106 CONTENTS is verse block contents. INFO is a plist holding
3107 contextual information."
3108 ;; Replace each newline character with line break. Also replace
3109 ;; each blank line with a line break.
3110 (setq contents (replace-regexp-in-string
3111 "^ *\\\\\\\\$" "<br/>\n"
3112 (replace-regexp-in-string
3113 "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents)))
3114 ;; Replace each white space at beginning of a line with a
3115 ;; non-breaking space.
3116 (while (string-match "^[ \t]+" contents)
3117 (let* ((num-ws (length (match-string 0 contents)))
3118 (ws (let (out) (dotimes (i num-ws out)
3119 (setq out (concat out "&nbsp;"))))))
3120 (setq contents (replace-match ws nil t contents))))
3121 (org-e-html--wrap-label
3122 verse-block (format "<p class=\"verse\">\n%s</p>" contents)))
3127 ;;; Filter Functions
3129 (defun org-e-html-final-function (contents backend info)
3130 (if (not org-e-html-pretty-output) contents
3131 (with-temp-buffer
3132 (nxml-mode)
3133 (insert contents)
3134 (indent-region (point-min) (point-max))
3135 (buffer-substring-no-properties (point-min) (point-max)))))
3138 ;;; Interactive functions
3140 ;;;###autoload
3141 (defun org-e-html-export-to-html
3142 (&optional subtreep visible-only body-only ext-plist pub-dir)
3143 "Export current buffer to a HTML file.
3145 If narrowing is active in the current buffer, only export its
3146 narrowed part.
3148 If a region is active, export that region.
3150 When optional argument SUBTREEP is non-nil, export the sub-tree
3151 at point, extracting information from the headline properties
3152 first.
3154 When optional argument VISIBLE-ONLY is non-nil, don't export
3155 contents of hidden elements.
3157 When optional argument BODY-ONLY is non-nil, only write code
3158 between \"\\begin{document}\" and \"\\end{document}\".
3160 EXT-PLIST, when provided, is a property list with external
3161 parameters overriding Org default settings, but still inferior to
3162 file-local settings.
3164 When optional argument PUB-DIR is set, use it as the publishing
3165 directory.
3167 Return output file's name."
3168 (interactive)
3169 (setq debug-on-error t) ; FIXME
3170 (let* ((extension (concat "." org-e-html-extension))
3171 (file (org-export-output-file-name extension subtreep pub-dir))
3172 (org-export-coding-system org-e-html-coding-system))
3173 (org-export-to-file
3174 'e-html file subtreep visible-only body-only ext-plist)))
3178 ;;; FIXMES, TODOS, FOR REVIEW etc
3180 ;;;; org-format-table-html
3181 ;;;; org-format-org-table-html
3182 ;;;; org-format-table-table-html
3183 ;;;; org-table-number-fraction
3184 ;;;; org-table-number-regexp
3185 ;;;; org-e-html-table-caption-above
3187 ;;;; org-whitespace
3188 ;;;; "<span style=\"visibility:hidden;\">%s</span>"
3189 ;;;; Remove display properties
3191 ;;;; org-e-html-with-timestamp
3192 ;;;; org-e-html-html-helper-timestamp
3194 ;;;; org-export-as-html-and-open
3195 ;;;; org-export-as-html-batch
3196 ;;;; org-export-as-html-to-buffer
3197 ;;;; org-replace-region-by-html
3198 ;;;; org-export-region-as-html
3199 ;;;; org-export-as-html
3201 ;;;; (org-export-directory :html opt-plist)
3202 ;;;; (plist-get opt-plist :html-extension)
3203 ;;;; org-e-html-toplevel-hlevel
3204 ;;;; org-e-html-special-string-regexps
3205 ;;;; org-e-html-inline-images
3206 ;;;; org-e-html-inline-image-extensions
3207 ;;;; org-e-html-protect-char-alist
3208 ;;;; org-e-html-table-use-header-tags-for-first-column
3209 ;;;; org-e-html-todo-kwd-class-prefix
3210 ;;;; org-e-html-tag-class-prefix
3211 ;;;; org-e-html-footnote-separator
3213 ;;;; org-export-preferred-target-alist
3214 ;;;; org-solidify-link-text
3215 ;;;; class for anchors
3216 ;;;; org-export-with-section-numbers, body-only
3217 ;;;; org-export-mark-todo-in-toc
3219 (provide 'org-e-html)
3220 ;;; org-e-html.el ends here