ox-html.el (org-html-display-buffer-mode): Delete
[org-mode.git] / lisp / ox-html.el
blob3e0a2881c51961d231f7d67d3167d45116e837a2
1 ;;; ox-html.el --- HTML Back-End for Org Export Engine
3 ;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
5 ;; Author: Jambunathan K <kjambunathan at gmail dot com>
6 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; GNU Emacs 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 ;; GNU Emacs 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 GNU Emacs. 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-x org-export-as-html
29 ;; in an Org mode buffer. See ox.el for more details on how this
30 ;; exporter works.
32 ;;; Code:
34 ;;; Dependencies
36 (require 'ox)
37 (require 'ox-publish)
38 (require 'format-spec)
39 (eval-when-compile (require 'cl) (require 'table))
43 ;;; Function Declarations
45 (declare-function org-id-find-id-file "org-id" (id))
46 (declare-function htmlize-region "ext:htmlize" (beg end))
47 (declare-function org-pop-to-buffer-same-window
48 "org-compat" (&optional buffer-or-name norecord label))
51 ;;; Define Back-End
53 (org-export-define-backend html
54 ((bold . org-html-bold)
55 (center-block . org-html-center-block)
56 (clock . org-html-clock)
57 (code . org-html-code)
58 (drawer . org-html-drawer)
59 (dynamic-block . org-html-dynamic-block)
60 (entity . org-html-entity)
61 (example-block . org-html-example-block)
62 (export-block . org-html-export-block)
63 (export-snippet . org-html-export-snippet)
64 (fixed-width . org-html-fixed-width)
65 (footnote-definition . org-html-footnote-definition)
66 (footnote-reference . org-html-footnote-reference)
67 (headline . org-html-headline)
68 (horizontal-rule . org-html-horizontal-rule)
69 (inline-src-block . org-html-inline-src-block)
70 (inlinetask . org-html-inlinetask)
71 (inner-template . org-html-inner-template)
72 (italic . org-html-italic)
73 (item . org-html-item)
74 (keyword . org-html-keyword)
75 (latex-environment . org-html-latex-environment)
76 (latex-fragment . org-html-latex-fragment)
77 (line-break . org-html-line-break)
78 (link . org-html-link)
79 (paragraph . org-html-paragraph)
80 (plain-list . org-html-plain-list)
81 (plain-text . org-html-plain-text)
82 (planning . org-html-planning)
83 (property-drawer . org-html-property-drawer)
84 (quote-block . org-html-quote-block)
85 (quote-section . org-html-quote-section)
86 (radio-target . org-html-radio-target)
87 (section . org-html-section)
88 (special-block . org-html-special-block)
89 (src-block . org-html-src-block)
90 (statistics-cookie . org-html-statistics-cookie)
91 (strike-through . org-html-strike-through)
92 (subscript . org-html-subscript)
93 (superscript . org-html-superscript)
94 (table . org-html-table)
95 (table-cell . org-html-table-cell)
96 (table-row . org-html-table-row)
97 (target . org-html-target)
98 (template . org-html-template)
99 (timestamp . org-html-timestamp)
100 (underline . org-html-underline)
101 (verbatim . org-html-verbatim)
102 (verse-block . org-html-verse-block))
103 :export-block "HTML"
104 :filters-alist ((:filter-options . org-html-infojs-install-script)
105 (:filter-final-output . org-html-final-function))
106 :menu-entry
107 (?h "Export to HTML"
108 ((?H "As HTML buffer" org-html-export-as-html)
109 (?h "As HTML file" org-html-export-to-html)
110 (?o "As HTML file and open"
111 (lambda (a s v b)
112 (if a (org-html-export-to-html t s v b)
113 (org-open-file (org-html-export-to-html nil s v b)))))))
114 :options-alist
115 ((:html-extension nil nil org-html-extension)
116 (:html-link-home "HTML_LINK_HOME" nil org-html-link-home)
117 (:html-link-up "HTML_LINK_UP" nil org-html-link-up)
118 (:html-mathjax "HTML_MATHJAX" nil "" space)
119 (:html-postamble nil "html-postamble" org-html-postamble)
120 (:html-preamble nil "html-preamble" org-html-preamble)
121 (:html-head "HTML_HEAD" nil org-html-head newline)
122 (:html-head-include-default-style nil nil org-html-head-include-default-style)
123 (:html-head-include-scripts nil nil org-html-head-include-scripts)
124 (:html-table-tag nil nil org-html-table-tag)
125 ;; Redefine regular options.
126 (:creator "CREATOR" nil org-html-creator-string)
127 (:with-latex nil "tex" org-html-with-latex)
128 ;; Leave room for "ox-infojs.el" extension.
129 (:infojs-opt "INFOJS_OPT" nil nil)))
133 ;;; Internal Variables
135 (defvar org-html-format-table-no-css)
136 (defvar htmlize-buffer-places) ; from htmlize.el
138 (defconst org-html-special-string-regexps
139 '(("\\\\-" . "&#x00ad;") ; shy
140 ("---\\([^-]\\)" . "&#x2014;\\1") ; mdash
141 ("--\\([^-]\\)" . "&#x2013;\\1") ; ndash
142 ("\\.\\.\\." . "&#x2026;")) ; hellip
143 "Regular expressions for special string conversion.")
145 (defconst org-html-scripts
146 "<script type=\"text/javascript\">
148 @licstart The following is the entire license notice for the
149 JavaScript code in this tag.
151 Copyright (C) 2012 Free Software Foundation, Inc.
153 The JavaScript code in this tag is free software: you can
154 redistribute it and/or modify it under the terms of the GNU
155 General Public License (GNU GPL) as published by the Free Software
156 Foundation, either version 3 of the License, or (at your option)
157 any later version. The code is distributed WITHOUT ANY WARRANTY;
158 without even the implied warranty of MERCHANTABILITY or FITNESS
159 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
161 As additional permission under GNU GPL version 3 section 7, you
162 may distribute non-source (e.g., minimized or compacted) forms of
163 that code without the copy of the GNU GPL normally required by
164 section 4, provided you include this license notice and a URL
165 through which recipients can access the Corresponding Source.
168 @licend The above is the entire license notice
169 for the JavaScript code in this tag.
171 <!--/*--><![CDATA[/*><!--*/
172 function CodeHighlightOn(elem, id)
174 var target = document.getElementById(id);
175 if(null != target) {
176 elem.cacheClassElem = elem.className;
177 elem.cacheClassTarget = target.className;
178 target.className = \"code-highlighted\";
179 elem.className = \"code-highlighted\";
182 function CodeHighlightOff(elem, id)
184 var target = document.getElementById(id);
185 if(elem.cacheClassElem)
186 elem.className = elem.cacheClassElem;
187 if(elem.cacheClassTarget)
188 target.className = elem.cacheClassTarget;
190 /*]]>*///-->
191 </script>"
192 "Basic JavaScript that is needed by HTML files produced by Org mode.")
194 (defconst org-html-style-default
195 "<style type=\"text/css\">
196 <!--/*--><![CDATA[/*><!--*/
197 html { font-family: Times, serif; font-size: 12pt; }
198 .title { text-align: center; }
199 .todo { color: red; }
200 .done { color: green; }
201 .tag { background-color: #add8e6; font-weight:normal }
202 .target { }
203 .timestamp { color: #bebebe; }
204 .timestamp-kwd { color: #5f9ea0; }
205 .right {margin-left:auto; margin-right:0px; text-align:right;}
206 .left {margin-left:0px; margin-right:auto; text-align:left;}
207 .center {margin-left:auto; margin-right:auto; text-align:center;}
208 p.verse { margin-left: 3% }
209 pre {
210 border: 1pt solid #AEBDCC;
211 background-color: #F3F5F7;
212 padding: 5pt;
213 font-family: courier, monospace;
214 font-size: 90%;
215 overflow:auto;
217 table { border-collapse: collapse; }
218 td, th { vertical-align: top; }
219 th.right { text-align:center; }
220 th.left { text-align:center; }
221 th.center { text-align:center; }
222 td.right { text-align:right; }
223 td.left { text-align:left; }
224 td.center { text-align:center; }
225 dt { font-weight: bold; }
226 div.figure { padding: 0.5em; }
227 div.figure p { text-align: center; }
228 div.inlinetask {
229 padding:10px;
230 border:2px solid gray;
231 margin:10px;
232 background: #ffffcc;
234 textarea { overflow-x: auto; }
235 .linenr { font-size:smaller }
236 .code-highlighted {background-color:#ffff00;}
237 .org-info-js_info-navigation { border-style:none; }
238 #org-info-js_console-label { font-size:10px; font-weight:bold;
239 white-space:nowrap; }
240 .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
241 font-weight:bold; }
242 /*]]>*/-->
243 </style>"
244 "The default style specification for exported HTML files.
245 You can use `org-html-head' and `org-html-head-extra' to add to
246 this style. If you don't want to include this default style,
247 customize `org-html-head-include-default-style'.")
251 ;;; User Configuration Variables
253 (defgroup org-export-html nil
254 "Options for exporting Org mode files to HTML."
255 :tag "Org Export HTML"
256 :group 'org-export)
259 ;;;; Handle infojs
261 (defvar org-html-infojs-opts-table
262 '((path PATH "http://orgmode.org/org-info.js")
263 (view VIEW "info")
264 (toc TOC :with-toc)
265 (ftoc FIXED_TOC "0")
266 (tdepth TOC_DEPTH "max")
267 (sdepth SECTION_DEPTH "max")
268 (mouse MOUSE_HINT "underline")
269 (buttons VIEW_BUTTONS "0")
270 (ltoc LOCAL_TOC "1")
271 (up LINK_UP :html-link-up)
272 (home LINK_HOME :html-link-home))
273 "JavaScript options, long form for script, default values.")
275 (defcustom org-html-use-infojs 'when-configured
276 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
277 This option can be nil or t to never or always use the script.
278 It can also be the symbol `when-configured', meaning that the
279 script will be linked into the export file if and only if there
280 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
281 `org-html-infojs-options'."
282 :group 'org-export-html
283 :version "24.4"
284 :package-version '(Org . "8.0")
285 :type '(choice
286 (const :tag "Never" nil)
287 (const :tag "When configured in buffer" when-configured)
288 (const :tag "Always" t)))
290 (defcustom org-html-infojs-options
291 (mapcar (lambda (x) (cons (car x) (nth 2 x))) org-html-infojs-opts-table)
292 "Options settings for the INFOJS JavaScript.
293 Each of the options must have an entry in `org-html-infojs-opts-table'.
294 The value can either be a string that will be passed to the script, or
295 a property. This property is then assumed to be a property that is defined
296 by the Export/Publishing setup of Org.
297 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
298 means to use the maximum value consistent with other options."
299 :group 'org-export-html
300 :version "24.4"
301 :package-version '(Org . "8.0")
302 :type
303 `(set :greedy t :inline t
304 ,@(mapcar
305 (lambda (x)
306 (list 'cons (list 'const (car x))
307 '(choice
308 (symbol :tag "Publishing/Export property")
309 (string :tag "Value"))))
310 org-html-infojs-opts-table)))
312 (defcustom org-html-infojs-template
313 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
316 * @source: %SCRIPT_PATH
318 * @licstart The following is the entire license notice for the
319 * JavaScript code in %SCRIPT_PATH.
321 * Copyright (C) 2012-2013 Sebastian Rose
324 * The JavaScript code in this tag is free software: you can
325 * redistribute it and/or modify it under the terms of the GNU
326 * General Public License (GNU GPL) as published by the Free Software
327 * Foundation, either version 3 of the License, or (at your option)
328 * any later version. The code is distributed WITHOUT ANY WARRANTY;
329 * without even the implied warranty of MERCHANTABILITY or FITNESS
330 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
332 * As additional permission under GNU GPL version 3 section 7, you
333 * may distribute non-source (e.g., minimized or compacted) forms of
334 * that code without the copy of the GNU GPL normally required by
335 * section 4, provided you include this license notice and a URL
336 * through which recipients can access the Corresponding Source.
338 * @licend The above is the entire license notice
339 * for the JavaScript code in %SCRIPT_PATH.
342 </script>
344 <script type=\"text/javascript\">
347 @licstart The following is the entire license notice for the
348 JavaScript code in this tag.
350 Copyright (C) 2012-2013 Free Software Foundation, Inc.
352 The JavaScript code in this tag is free software: you can
353 redistribute it and/or modify it under the terms of the GNU
354 General Public License (GNU GPL) as published by the Free Software
355 Foundation, either version 3 of the License, or (at your option)
356 any later version. The code is distributed WITHOUT ANY WARRANTY;
357 without even the implied warranty of MERCHANTABILITY or FITNESS
358 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
360 As additional permission under GNU GPL version 3 section 7, you
361 may distribute non-source (e.g., minimized or compacted) forms of
362 that code without the copy of the GNU GPL normally required by
363 section 4, provided you include this license notice and a URL
364 through which recipients can access the Corresponding Source.
367 @licend The above is the entire license notice
368 for the JavaScript code in this tag.
371 <!--/*--><![CDATA[/*><!--*/
372 %MANAGER_OPTIONS
373 org_html_manager.setup(); // activate after the parameters are set
374 /*]]>*///-->
375 </script>"
376 "The template for the export style additions when org-info.js is used.
377 Option settings will replace the %MANAGER-OPTIONS cookie."
378 :group 'org-export-html
379 :version "24.4"
380 :package-version '(Org . "8.0")
381 :type 'string)
383 (defun org-html-infojs-install-script (exp-plist backend)
384 "Install script in export options when appropriate.
385 EXP-PLIST is a plist containing export options. BACKEND is the
386 export back-end currently used."
387 (unless (or (not org-html-use-infojs)
388 (and (eq org-html-use-infojs 'when-configured)
389 (or (not (plist-get exp-plist :infojs-opt))
390 (string-match "\\<view:nil\\>"
391 (plist-get exp-plist :infojs-opt)))))
392 (let* ((template org-html-infojs-template)
393 (ptoc (plist-get exp-plist :with-toc))
394 (hlevels (plist-get exp-plist :headline-levels))
395 (sdepth hlevels)
396 (tdepth (if (integerp ptoc) (min ptoc hlevels) hlevels))
397 (options (plist-get exp-plist :infojs-opt))
398 (table org-html-infojs-opts-table)
399 style)
400 (dolist (entry table)
401 (let* ((opt (car entry))
402 (var (nth 1 entry))
403 ;; Compute default values for script option OPT from
404 ;; `org-html-infojs-options' variable.
405 (default
406 (let ((default (cdr (assq opt org-html-infojs-options))))
407 (if (and (symbolp default) (not (memq default '(t nil))))
408 (plist-get exp-plist default)
409 default)))
410 ;; Value set through INFOJS_OPT keyword has precedence
411 ;; over the default one.
412 (val (if (and options
413 (string-match (format "\\<%s:\\(\\S-+\\)" opt)
414 options))
415 (match-string 1 options)
416 default)))
417 (case opt
418 (path (setq template
419 (replace-regexp-in-string
420 "%SCRIPT_PATH" val template t t)))
421 (sdepth (when (integerp (read val))
422 (setq sdepth (min (read val) sdepth))))
423 (tdepth (when (integerp (read val))
424 (setq tdepth (min (read val) tdepth))))
425 (otherwise (setq val
426 (cond
427 ((or (eq val t) (equal val "t")) "1")
428 ((or (eq val nil) (equal val "nil")) "0")
429 ((stringp val) val)
430 (t (format "%s" val))))
431 (push (cons var val) style)))))
432 ;; Now we set the depth of the *generated* TOC to SDEPTH,
433 ;; because the toc will actually determine the splitting. How
434 ;; much of the toc will actually be displayed is governed by the
435 ;; TDEPTH option.
436 (setq exp-plist (plist-put exp-plist :with-toc sdepth))
437 ;; The table of contents should not show more sections than we
438 ;; generate.
439 (setq tdepth (min tdepth sdepth))
440 (push (cons "TOC_DEPTH" tdepth) style)
441 ;; Build style string.
442 (setq style (mapconcat
443 (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
444 (car x)
445 (cdr x)))
446 style "\n"))
447 (when (and style (> (length style) 0))
448 (and (string-match "%MANAGER_OPTIONS" template)
449 (setq style (replace-match style t t template))
450 (setq exp-plist
451 (plist-put
452 exp-plist :html-head-extra
453 (concat (or (plist-get exp-plist :html-head-extra) "")
454 "\n"
455 style)))))
456 ;; This script absolutely needs the table of contents, so we
457 ;; change that setting.
458 (unless (plist-get exp-plist :with-toc)
459 (setq exp-plist (plist-put exp-plist :with-toc t)))
460 ;; Return the modified property list.
461 exp-plist)))
464 ;;;; Bold etc
466 (defcustom org-html-text-markup-alist
467 '((bold . "<b>%s</b>")
468 (code . "<code>%s</code>")
469 (italic . "<i>%s</i>")
470 (strike-through . "<del>%s</del>")
471 (underline . "<span style=\"text-decoration:underline;\">%s</span>")
472 (verbatim . "<code>%s</code>"))
473 "Alist of HTML expressions to convert text markup
475 The key must be a symbol among `bold', `code', `italic',
476 `strike-through', `underline' and `verbatim'. The value is
477 a formatting string to wrap fontified text with.
479 If no association can be found for a given markup, text will be
480 returned as-is."
481 :group 'org-export-html
482 :type '(alist :key-type (symbol :tag "Markup type")
483 :value-type (string :tag "Format string"))
484 :options '(bold code italic strike-through underline verbatim))
487 ;;;; Debugging
489 (defcustom org-html-pretty-output nil
490 "Enable this to generate pretty HTML."
491 :group 'org-export-html
492 :type 'boolean)
495 ;;;; Drawers
497 (defcustom org-html-format-drawer-function nil
498 "Function called to format a drawer in HTML code.
500 The function must accept two parameters:
501 NAME the drawer name, like \"LOGBOOK\"
502 CONTENTS the contents of the drawer.
504 The function should return the string to be exported.
506 For example, the variable could be set to the following function
507 in order to mimic default behaviour:
509 \(defun org-html-format-drawer-default \(name contents\)
510 \"Format a drawer element for HTML export.\"
511 contents\)"
512 :group 'org-export-html
513 :type 'function)
516 ;;;; Footnotes
518 (defcustom org-html-footnotes-section "<div id=\"footnotes\">
519 <h2 class=\"footnotes\">%s: </h2>
520 <div id=\"text-footnotes\">
522 </div>
523 </div>"
524 "Format for the footnotes section.
525 Should contain a two instances of %s. The first will be replaced with the
526 language-specific word for \"Footnotes\", the second one will be replaced
527 by the footnotes themselves."
528 :group 'org-export-html
529 :type 'string)
531 (defcustom org-html-footnote-format "<sup>%s</sup>"
532 "The format for the footnote reference.
533 %s will be replaced by the footnote reference itself."
534 :group 'org-export-html
535 :type 'string)
537 (defcustom org-html-footnote-separator "<sup>, </sup>"
538 "Text used to separate footnotes."
539 :group 'org-export-html
540 :type 'string)
543 ;;;; Headline
545 (defcustom org-html-toplevel-hlevel 2
546 "The <H> level for level 1 headings in HTML export.
547 This is also important for the classes that will be wrapped around headlines
548 and outline structure. If this variable is 1, the top-level headlines will
549 be <h1>, and the corresponding classes will be outline-1, section-number-1,
550 and outline-text-1. If this is 2, all of these will get a 2 instead.
551 The default for this variable is 2, because we use <h1> for formatting the
552 document title."
553 :group 'org-export-html
554 :type 'integer)
556 (defcustom org-html-format-headline-function nil
557 "Function to format headline text.
559 This function will be called with 5 arguments:
560 TODO the todo keyword (string or nil).
561 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
562 PRIORITY the priority of the headline (integer or nil)
563 TEXT the main headline text (string).
564 TAGS the tags (string or nil).
566 The function result will be used in the section format string."
567 :group 'org-export-html
568 :type 'function)
571 ;;;; HTML-specific
573 (defcustom org-html-allow-name-attribute-in-anchors t
574 "When nil, do not set \"name\" attribute in anchors.
575 By default, anchors are formatted with both \"id\" and \"name\"
576 attributes, when appropriate."
577 :group 'org-export-html
578 :type 'boolean)
581 ;;;; Inlinetasks
583 (defcustom org-html-format-inlinetask-function nil
584 "Function called to format an inlinetask in HTML code.
586 The function must accept six parameters:
587 TODO the todo keyword, as a string
588 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
589 PRIORITY the inlinetask priority, as a string
590 NAME the inlinetask name, as a string.
591 TAGS the inlinetask tags, as a list of strings.
592 CONTENTS the contents of the inlinetask, as a string.
594 The function should return the string to be exported."
595 :group 'org-export-html
596 :type 'function)
599 ;;;; LaTeX
601 (defcustom org-html-with-latex org-export-with-latex
602 "Non-nil means process LaTeX math snippets.
604 When set, the exporter will process LaTeX environments and
605 fragments.
607 This option can also be set with the +OPTIONS line,
608 e.g. \"tex:mathjax\". Allowed values are:
610 nil Ignore math snippets.
611 `verbatim' Keep everything in verbatim
612 `dvipng' Process the LaTeX fragments to images. This will also
613 include processing of non-math environments.
614 `imagemagick' Convert the LaTeX fragments to pdf files and use
615 imagemagick to convert pdf files to png files.
616 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
617 be loaded.
618 t Synonym for `mathjax'."
619 :group 'org-export-html
620 :type '(choice
621 (const :tag "Do not process math in any way" nil)
622 (const :tag "Use dvipng to make images" dvipng)
623 (const :tag "Use imagemagick to make images" imagemagick)
624 (const :tag "Use MathJax to display math" mathjax)
625 (const :tag "Leave math verbatim" verbatim)))
628 ;;;; Links :: Generic
630 (defcustom org-html-link-org-files-as-html t
631 "Non-nil means make file links to `file.org' point to `file.html'.
632 When org-mode is exporting an org-mode file to HTML, links to
633 non-html files are directly put into a href tag in HTML.
634 However, links to other Org-mode files (recognized by the
635 extension `.org.) should become links to the corresponding html
636 file, assuming that the linked org-mode file will also be
637 converted to HTML.
638 When nil, the links still point to the plain `.org' file."
639 :group 'org-export-html
640 :type 'boolean)
643 ;;;; Links :: Inline images
645 (defcustom org-html-inline-images 'maybe
646 "Non-nil means inline images into exported HTML pages.
647 This is done using an <img> tag. When nil, an anchor with href is used to
648 link to the image. If this option is `maybe', then images in links with
649 an empty description will be inlined, while images with a description will
650 be linked only."
651 :group 'org-export-html
652 :type '(choice (const :tag "Never" nil)
653 (const :tag "Always" t)
654 (const :tag "When there is no description" maybe)))
656 (defcustom org-html-inline-image-rules
657 '(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
658 ("http" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
659 ("https" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
660 "Rules characterizing image files that can be inlined into HTML.
662 A rule consists in an association whose key is the type of link
663 to consider, and value is a regexp that will be matched against
664 link's path.
666 Note that, by default, the image extension *actually* allowed
667 depend on the way the HTML file is processed. When used with
668 pdflatex, pdf, jpg and png images are OK. When processing
669 through dvi to Postscript, only ps and eps are allowed. The
670 default we use here encompasses both."
671 :group 'org-export-html
672 :type '(alist :key-type (string :tag "Type")
673 :value-type (regexp :tag "Path")))
676 ;;;; Plain Text
678 (defcustom org-html-protect-char-alist
679 '(("&" . "&amp;")
680 ("<" . "&lt;")
681 (">" . "&gt;"))
682 "Alist of characters to be converted by `org-html-protect'."
683 :group 'org-export-html
684 :type '(repeat (cons (string :tag "Character")
685 (string :tag "HTML equivalent"))))
688 ;;;; Src Block
690 (defcustom org-html-htmlize-output-type 'inline-css
691 "Output type to be used by htmlize when formatting code snippets.
692 Choices are `css', to export the CSS selectors only, or `inline-css', to
693 export the CSS attribute values inline in the HTML. We use as default
694 `inline-css', in order to make the resulting HTML self-containing.
696 However, this will fail when using Emacs in batch mode for export, because
697 then no rich font definitions are in place. It will also not be good if
698 people with different Emacs setup contribute HTML files to a website,
699 because the fonts will represent the individual setups. In these cases,
700 it is much better to let Org/Htmlize assign classes only, and to use
701 a style file to define the look of these classes.
702 To get a start for your css file, start Emacs session and make sure that
703 all the faces you are interested in are defined, for example by loading files
704 in all modes you want. Then, use the command
705 \\[org-html-htmlize-generate-css] to extract class definitions."
706 :group 'org-export-html
707 :type '(choice (const css) (const inline-css)))
709 (defcustom org-html-htmlize-font-prefix "org-"
710 "The prefix for CSS class names for htmlize font specifications."
711 :group 'org-export-html
712 :type 'string)
714 ;;;; Table
716 (defcustom org-html-table-tag
717 "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
718 "The HTML tag that is used to start a table.
719 This must be a <table> tag, but you may change the options like
720 borders and spacing."
721 :group 'org-export-html
722 :type 'string)
724 (defcustom org-html-table-header-tags '("<th scope=\"%s\"%s>" . "</th>")
725 "The opening tag for table header fields.
726 This is customizable so that alignment options can be specified.
727 The first %s will be filled with the scope of the field, either row or col.
728 The second %s will be replaced by a style entry to align the field.
729 See also the variable `org-html-table-use-header-tags-for-first-column'.
730 See also the variable `org-html-table-align-individual-fields'."
731 :group 'org-export-html
732 :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
734 (defcustom org-html-table-data-tags '("<td%s>" . "</td>")
735 "The opening tag for table data fields.
736 This is customizable so that alignment options can be specified.
737 The first %s will be filled with the scope of the field, either row or col.
738 The second %s will be replaced by a style entry to align the field.
739 See also the variable `org-html-table-align-individual-fields'."
740 :group 'org-export-html
741 :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
743 (defcustom org-html-table-row-tags '("<tr>" . "</tr>")
744 "The opening tag for table data fields.
745 This is customizable so that alignment options can be specified.
746 Instead of strings, these can be Lisp forms that will be evaluated
747 for each row in order to construct the table row tags. During evaluation,
748 the variable `head' will be true when this is a header line, nil when this
749 is a body line. And the variable `nline' will contain the line number,
750 starting from 1 in the first header line. For example
752 (setq org-html-table-row-tags
753 (cons '(if head
754 \"<tr>\"
755 (if (= (mod nline 2) 1)
756 \"<tr class=\\\"tr-odd\\\">\"
757 \"<tr class=\\\"tr-even\\\">\"))
758 \"</tr>\"))
760 will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
761 :group 'org-export-html
762 :type '(cons
763 (choice :tag "Opening tag"
764 (string :tag "Specify")
765 (sexp))
766 (choice :tag "Closing tag"
767 (string :tag "Specify")
768 (sexp))))
770 (defcustom org-html-table-align-individual-fields t
771 "Non-nil means attach style attributes for alignment to each table field.
772 When nil, alignment will only be specified in the column tags, but this
773 is ignored by some browsers (like Firefox, Safari). Opera does it right
774 though."
775 :group 'org-export-html
776 :type 'boolean)
778 (defcustom org-html-table-use-header-tags-for-first-column nil
779 "Non-nil means format column one in tables with header tags.
780 When nil, also column one will use data tags."
781 :group 'org-export-html
782 :type 'boolean)
784 (defcustom org-html-table-caption-above t
785 "When non-nil, place caption string at the beginning of the table.
786 Otherwise, place it near the end."
787 :group 'org-export-html
788 :type 'boolean)
791 ;;;; Tags
793 (defcustom org-html-tag-class-prefix ""
794 "Prefix to class names for TODO keywords.
795 Each tag gets a class given by the tag itself, with this prefix.
796 The default prefix is empty because it is nice to just use the keyword
797 as a class name. But if you get into conflicts with other, existing
798 CSS classes, then this prefix can be very useful."
799 :group 'org-export-html
800 :type 'string)
803 ;;;; Template :: Generic
805 (defcustom org-html-extension "html"
806 "The extension for exported HTML files."
807 :group 'org-export-html
808 :type 'string)
810 (defcustom org-html-xml-declaration
811 '(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
812 ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
813 "The extension for exported HTML files.
814 %s will be replaced with the charset of the exported file.
815 This may be a string, or an alist with export extensions
816 and corresponding declarations."
817 :group 'org-export-html
818 :type '(choice
819 (string :tag "Single declaration")
820 (repeat :tag "Dependent on extension"
821 (cons (string :tag "Extension")
822 (string :tag "Declaration")))))
824 (defcustom org-html-coding-system 'utf-8
825 "Coding system for HTML export.
826 Use utf-8 as the default value."
827 :group 'org-export-html
828 :type 'coding-system)
830 (defcustom org-html-divs '("preamble" "content" "postamble")
831 "The name of the main divs for HTML export.
832 This is a list of three strings, the first one for the preamble
833 DIV, the second one for the content DIV and the third one for the
834 postamble DIV."
835 :group 'org-export-html
836 :type '(list
837 (string :tag " Div for the preamble:")
838 (string :tag " Div for the content:")
839 (string :tag "Div for the postamble:")))
842 ;;;; Template :: Mathjax
844 (defcustom org-html-mathjax-options
845 '((path "http://orgmode.org/mathjax/MathJax.js")
846 (scale "100")
847 (align "center")
848 (indent "2em")
849 (mathml nil))
850 "Options for MathJax setup.
852 path The path where to find MathJax
853 scale Scaling for the HTML-CSS backend, usually between 100 and 133
854 align How to align display math: left, center, or right
855 indent If align is not center, how far from the left/right side?
856 mathml Should a MathML player be used if available?
857 This is faster and reduces bandwidth use, but currently
858 sometimes has lower spacing quality. Therefore, the default is
859 nil. When browsers get better, this switch can be flipped.
861 You can also customize this for each buffer, using something like
863 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
864 :group 'org-export-html
865 :type '(list :greedy t
866 (list :tag "path (the path from where to load MathJax.js)"
867 (const :format " " path) (string))
868 (list :tag "scale (scaling for the displayed math)"
869 (const :format " " scale) (string))
870 (list :tag "align (alignment of displayed equations)"
871 (const :format " " align) (string))
872 (list :tag "indent (indentation with left or right alignment)"
873 (const :format " " indent) (string))
874 (list :tag "mathml (should MathML display be used is possible)"
875 (const :format " " mathml) (boolean))))
877 (defcustom org-html-mathjax-template
878 "<script type=\"text/javascript\" src=\"%PATH\">
879 <!--/*--><![CDATA[/*><!--*/
880 MathJax.Hub.Config({
881 // Only one of the two following lines, depending on user settings
882 // First allows browser-native MathML display, second forces HTML/CSS
883 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
884 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
885 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
886 \"TeX/noUndefined.js\"],
887 tex2jax: {
888 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
889 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
890 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
891 ignoreClass: \"tex2jax_ignore\",
892 processEscapes: false,
893 processEnvironments: true,
894 preview: \"TeX\"
896 showProcessingMessages: true,
897 displayAlign: \"%ALIGN\",
898 displayIndent: \"%INDENT\",
900 \"HTML-CSS\": {
901 scale: %SCALE,
902 availableFonts: [\"STIX\",\"TeX\"],
903 preferredFont: \"TeX\",
904 webFont: \"TeX\",
905 imageFont: \"TeX\",
906 showMathMenu: true,
908 MMLorHTML: {
909 prefer: {
910 MSIE: \"MML\",
911 Firefox: \"MML\",
912 Opera: \"HTML\",
913 other: \"HTML\"
917 /*]]>*///-->
918 </script>"
919 "The MathJax setup for XHTML files."
920 :group 'org-export-html
921 :type 'string)
924 ;;;; Template :: Postamble
926 (defcustom org-html-postamble 'auto
927 "Non-nil means insert a postamble in HTML export.
929 When `t', insert a string as defined by the formatting string in
930 `org-html-postamble-format'. When set to a string, this
931 string overrides `org-html-postamble-format'. When set to
932 'auto, discard `org-html-postamble-format' and honor
933 `org-export-author/email/creator-info' variables. When set to a
934 function, apply this function and insert the returned string.
935 The function takes the property list of export options as its
936 only argument.
938 Setting :html-postamble in publishing projects will take
939 precedence over this variable."
940 :group 'org-export-html
941 :type '(choice (const :tag "No postamble" nil)
942 (const :tag "Auto preamble" 'auto)
943 (const :tag "Default formatting string" t)
944 (string :tag "Custom formatting string")
945 (function :tag "Function (must return a string)")))
947 (defcustom org-html-postamble-format
948 '(("en" "<p class=\"author\">Author: %a (%e)</p>
949 <p class=\"date\">Date: %d</p>
950 <p class=\"creator\">Generated by %c</p>
951 <p class=\"xhtml-validation\">%v</p>"))
952 "Alist of languages and format strings for the HTML postamble.
954 The first element of each list is the language code, as used for
955 the #+LANGUAGE keyword.
957 The second element of each list is a format string to format the
958 postamble itself. This format string can contain these elements:
960 %a stands for the author's name.
961 %e stands for the author's email.
962 %d stands for the date.
963 %c will be replaced by information about Org/Emacs versions.
964 %v will be replaced by `org-html-validation-link'.
966 If you need to use a \"%\" character, you need to escape it
967 like that: \"%%\"."
968 :group 'org-export-html
969 :type '(alist :key-type (string :tag "Language")
970 :value-type (string :tag "Format string")))
972 (defcustom org-html-validation-link
973 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
974 "Link to HTML validation service."
975 :group 'org-export-html
976 :type 'string)
978 (defcustom org-html-creator-string
979 (format "Generated by <a href=\"http://orgmode.org\">Org</a> mode %s in <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s."
980 (if (fboundp 'org-version) (org-version) "(Unknown)")
981 emacs-version)
982 "String to insert at the end of the HTML document."
983 :group 'org-export-html
984 :type '(string :tag "Creator string"))
987 ;;;; Template :: Preamble
989 (defcustom org-html-preamble t
990 "Non-nil means insert a preamble in HTML export.
992 When `t', insert a string as defined by one of the formatting
993 strings in `org-html-preamble-format'. When set to a
994 string, this string overrides `org-html-preamble-format'.
995 When set to a function, apply this function and insert the
996 returned string. The function takes the property list of export
997 options as its only argument.
999 Setting :html-preamble in publishing projects will take
1000 precedence over this variable."
1001 :group 'org-export-html
1002 :type '(choice (const :tag "No preamble" nil)
1003 (const :tag "Default preamble" t)
1004 (string :tag "Custom formatting string")
1005 (function :tag "Function (must return a string)")))
1007 (defcustom org-html-preamble-format '(("en" ""))
1008 "Alist of languages and format strings for the HTML preamble.
1010 The first element of each list is the language code, as used for
1011 the #+LANGUAGE keyword.
1013 The second element of each list is a format string to format the
1014 preamble itself. This format string can contain these elements:
1016 %t stands for the title.
1017 %a stands for the author's name.
1018 %e stands for the author's email.
1019 %d stands for the date.
1021 If you need to use a \"%\" character, you need to escape it
1022 like that: \"%%\"."
1023 :group 'org-export-html
1024 :type '(alist :key-type (string :tag "Language")
1025 :value-type (string :tag "Format string")))
1027 (defcustom org-html-link-up ""
1028 "Where should the \"UP\" link of exported HTML pages lead?"
1029 :group 'org-export-html
1030 :type '(string :tag "File or URL"))
1032 (defcustom org-html-link-home ""
1033 "Where should the \"HOME\" link of exported HTML pages lead?"
1034 :group 'org-export-html
1035 :type '(string :tag "File or URL"))
1037 (defcustom org-html-home/up-format
1038 "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
1039 <a accesskey=\"h\" href=\"%s\"> UP </a>
1041 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1042 </div>"
1043 "Snippet used to insert the HOME and UP links.
1044 This is a format string, the first %s will receive the UP link,
1045 the second the HOME link. If both `org-html-link-up' and
1046 `org-html-link-home' are empty, the entire snippet will be
1047 ignored."
1048 :group 'org-export-html
1049 :type 'string)
1052 ;;;; Template :: Scripts
1054 (define-obsolete-variable-alias
1055 'org-html-style-include-scripts 'org-html-head-include-scripts "24.4")
1056 (defcustom org-html-head-include-scripts t
1057 "Non-nil means include the JavaScript snippets in exported HTML files.
1058 The actual script is defined in `org-html-scripts' and should
1059 not be modified."
1060 :group 'org-export-html
1061 :version "24.4"
1062 :package-version '(Org . "8.0")
1063 :type 'boolean)
1066 ;;;; Template :: Styles
1068 (define-obsolete-variable-alias
1069 'org-html-style-include-default 'org-html-head-include-default-style "24.4")
1070 (defcustom org-html-head-include-default-style t
1071 "Non-nil means include the default style in exported HTML files.
1072 The actual style is defined in `org-html-style-default' and
1073 should not be modified. Use `org-html-head' to add your own
1074 style information."
1075 :group 'org-export-html
1076 :version "24.4"
1077 :package-version '(Org . "8.0")
1078 :type 'boolean)
1079 ;;;###autoload
1080 (put 'org-html-head-include-default-style 'safe-local-variable 'booleanp)
1082 (define-obsolete-variable-alias 'org-html-style 'org-html-head "24.4")
1083 (defcustom org-html-head ""
1084 "Org-wide head definitions for exported HTML files.
1086 This variable can contain the full HTML structure to provide a
1087 style, including the surrounding HTML tags. You can consider
1088 including definitions for the following classes: title, todo,
1089 done, timestamp, timestamp-kwd, tag, target.
1091 For example, a valid value would be:
1093 <style type=\"text/css\">
1094 <![CDATA[
1095 p { font-weight: normal; color: gray; }
1096 h1 { color: black; }
1097 .title { text-align: center; }
1098 .todo, .timestamp-kwd { color: red; }
1099 .done { color: green; }
1101 </style>
1103 If you want to refer to an external style, use something like
1105 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1107 As the value of this option simply gets inserted into the HTML
1108 <head> header, you can use it to add any arbitrary text to the
1109 header."
1110 :group 'org-export-html
1111 :version "24.4"
1112 :package-version '(Org . "8.0")
1113 :type 'string)
1114 ;;;###autoload
1115 (put 'org-html-head 'safe-local-variable 'stringp)
1117 ;;;; Todos
1119 (defcustom org-html-todo-kwd-class-prefix ""
1120 "Prefix to class names for TODO keywords.
1121 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1122 The default prefix is empty because it is nice to just use the keyword
1123 as a class name. But if you get into conflicts with other, existing
1124 CSS classes, then this prefix can be very useful."
1125 :group 'org-export-html
1126 :type 'string)
1129 ;;; Internal Functions
1131 (defun org-html-format-inline-image (src &optional
1132 caption label attr standalone-p)
1133 (let* ((id (if (not label) ""
1134 (format " id=\"%s\"" (org-export-solidify-link-text label))))
1135 (attr (concat attr
1136 (cond
1137 ((string-match "\\<alt=" (or attr "")) "")
1138 ((string-match "^ltxpng/" src)
1139 (format " alt=\"%s\""
1140 (org-html-encode-plain-text
1141 (org-find-text-property-in-string
1142 'org-latex-src src))))
1143 (t (format " alt=\"%s\""
1144 (file-name-nondirectory src)))))))
1145 (cond
1146 (standalone-p
1147 (let ((img (format "<img src=\"%s\" %s/>" src attr)))
1148 (format "\n<div%s class=\"figure\">%s%s\n</div>"
1149 id (format "\n<p>%s</p>" img)
1150 (when caption (format "\n<p>%s</p>" caption)))))
1151 (t (format "<img src=\"%s\" %s/>" src (concat attr id))))))
1153 (defun org-html--textarea-block (element)
1154 "Transcode ELEMENT into a textarea block.
1155 ELEMENT is either a src block or an example block."
1156 (let ((code (car (org-export-unravel-code element)))
1157 (attr (org-export-read-attribute :attr_html element)))
1158 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>"
1159 (or (plist-get attr :width) 80)
1160 (or (plist-get attr :height) (org-count-lines code))
1161 code)))
1164 ;;;; Bibliography
1166 (defun org-html-bibliography ()
1167 "Find bibliography, cut it out and return it."
1168 (catch 'exit
1169 (let (beg end (cnt 1) bib)
1170 (save-excursion
1171 (goto-char (point-min))
1172 (when (re-search-forward
1173 "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t)
1174 (setq beg (match-beginning 0))
1175 (while (re-search-forward "</?div\\>" nil t)
1176 (setq cnt (+ cnt (if (string= (match-string 0) "<div") +1 -1)))
1177 (when (= cnt 0)
1178 (and (looking-at ">") (forward-char 1))
1179 (setq bib (buffer-substring beg (point)))
1180 (delete-region beg (point))
1181 (throw 'exit bib))))
1182 nil))))
1184 ;;;; Table
1186 (defun org-html-splice-attributes (tag attributes)
1187 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
1188 (if (not attributes)
1190 (let (oldatt newatt)
1191 (setq oldatt (org-extract-attributes-from-string tag)
1192 tag (pop oldatt)
1193 newatt (cdr (org-extract-attributes-from-string attributes)))
1194 (while newatt
1195 (setq oldatt (plist-put oldatt (pop newatt) (pop newatt))))
1196 (if (string-match ">" tag)
1197 (setq tag
1198 (replace-match (concat (org-attributes-to-string oldatt) ">")
1199 t t tag)))
1200 tag)))
1202 (defun org-export-splice-style (style extra)
1203 "Splice EXTRA into STYLE, just before \"</style>\"."
1204 (if (and (stringp extra)
1205 (string-match "\\S-" extra)
1206 (string-match "</style>" style))
1207 (concat (substring style 0 (match-beginning 0))
1208 "\n" extra "\n"
1209 (substring style (match-beginning 0)))
1210 style))
1212 (defun org-html-htmlize-region-for-paste (beg end)
1213 "Convert the region to HTML, using htmlize.el.
1214 This is much like `htmlize-region-for-paste', only that it uses
1215 the settings define in the org-... variables."
1216 (let* ((htmlize-output-type org-html-htmlize-output-type)
1217 (htmlize-css-name-prefix org-html-htmlize-font-prefix)
1218 (htmlbuf (htmlize-region beg end)))
1219 (unwind-protect
1220 (with-current-buffer htmlbuf
1221 (buffer-substring (plist-get htmlize-buffer-places 'content-start)
1222 (plist-get htmlize-buffer-places 'content-end)))
1223 (kill-buffer htmlbuf))))
1225 ;;;###autoload
1226 (defun org-html-htmlize-generate-css ()
1227 "Create the CSS for all font definitions in the current Emacs session.
1228 Use this to create face definitions in your CSS style file that can then
1229 be used by code snippets transformed by htmlize.
1230 This command just produces a buffer that contains class definitions for all
1231 faces used in the current Emacs session. You can copy and paste the ones you
1232 need into your CSS file.
1234 If you then set `org-html-htmlize-output-type' to `css', calls
1235 to the function `org-html-htmlize-region-for-paste' will
1236 produce code that uses these same face definitions."
1237 (interactive)
1238 (require 'htmlize)
1239 (and (get-buffer "*html*") (kill-buffer "*html*"))
1240 (with-temp-buffer
1241 (let ((fl (face-list))
1242 (htmlize-css-name-prefix "org-")
1243 (htmlize-output-type 'css)
1244 f i)
1245 (while (setq f (pop fl)
1246 i (and f (face-attribute f :inherit)))
1247 (when (and (symbolp f) (or (not i) (not (listp i))))
1248 (insert (org-add-props (copy-sequence "1") nil 'face f))))
1249 (htmlize-region (point-min) (point-max))))
1250 (org-pop-to-buffer-same-window "*html*")
1251 (goto-char (point-min))
1252 (if (re-search-forward "<style" nil t)
1253 (delete-region (point-min) (match-beginning 0)))
1254 (if (re-search-forward "</style>" nil t)
1255 (delete-region (1+ (match-end 0)) (point-max)))
1256 (beginning-of-line 1)
1257 (if (looking-at " +") (replace-match ""))
1258 (goto-char (point-min)))
1260 (defun org-html--make-string (n string)
1261 "Build a string by concatenating N times STRING."
1262 (let (out) (dotimes (i n out) (setq out (concat string out)))))
1264 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1265 "Turn todo keyword into a valid class name.
1266 Replaces invalid characters with \"_\"."
1267 (save-match-data
1268 (while (string-match "[^a-zA-Z0-9_]" kwd)
1269 (setq kwd (replace-match "_" t t kwd))))
1270 kwd)
1272 (defun org-html-format-footnote-reference (n def refcnt)
1273 (let ((extra (if (= refcnt 1) "" (format ".%d" refcnt))))
1274 (format org-html-footnote-format
1275 (let* ((id (format "fnr.%s%s" n extra))
1276 (href (format " href=\"#fn.%s\"" n))
1277 (attributes (concat " class=\"footref\"" href)))
1278 (org-html--anchor id n attributes)))))
1280 (defun org-html-format-footnotes-section (section-name definitions)
1281 (if (not definitions) ""
1282 (format org-html-footnotes-section section-name definitions)))
1284 (defun org-html-format-footnote-definition (fn)
1285 (let ((n (car fn)) (def (cdr fn)))
1286 (format
1287 "<tr>\n<td>%s</td>\n<td>%s</td>\n</tr>\n"
1288 (format org-html-footnote-format
1289 (let* ((id (format "fn.%s" n))
1290 (href (format " href=\"#fnr.%s\"" n))
1291 (attributes (concat " class=\"footnum\"" href)))
1292 (org-html--anchor id n attributes)))
1293 def)))
1295 (defun org-html-footnote-section (info)
1296 (let* ((fn-alist (org-export-collect-footnote-definitions
1297 (plist-get info :parse-tree) info))
1299 (fn-alist
1300 (loop for (n type raw) in fn-alist collect
1301 (cons n (if (eq (org-element-type raw) 'org-data)
1302 (org-trim (org-export-data raw info))
1303 (format "<p>%s</p>"
1304 (org-trim (org-export-data raw info))))))))
1305 (when fn-alist
1306 (org-html-format-footnotes-section
1307 (org-html--translate "Footnotes" info)
1308 (format
1309 "<table>\n%s\n</table>\n"
1310 (mapconcat 'org-html-format-footnote-definition fn-alist "\n"))))))
1314 ;;; Template
1316 (defun org-html--build-meta-info (info)
1317 "Return meta tags for exported document.
1318 INFO is a plist used as a communication channel."
1319 (let* ((title (org-export-data (plist-get info :title) info))
1320 (author (and (plist-get info :with-author)
1321 (let ((auth (plist-get info :author)))
1322 (and auth (org-export-data auth info)))))
1323 (date (and (plist-get info :with-date)
1324 (let ((date (plist-get info :date)))
1325 (and date (org-export-data date info)))))
1326 (description (plist-get info :description))
1327 (keywords (plist-get info :keywords)))
1328 (concat
1329 (format "<title>%s</title>\n" title)
1330 (format
1331 "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>\n"
1332 (or (and org-html-coding-system
1333 (fboundp 'coding-system-get)
1334 (coding-system-get org-html-coding-system 'mime-charset))
1335 "iso-8859-1"))
1336 (format "<meta name=\"title\" content=\"%s\"/>\n" title)
1337 (format "<meta name=\"generator\" content=\"Org-mode\"/>\n")
1338 (and date (format "<meta name=\"generated\" content=\"%s\"/>\n" date))
1339 (and author (format "<meta name=\"author\" content=\"%s\"/>\n" author))
1340 (and description
1341 (format "<meta name=\"description\" content=\"%s\"/>\n" description))
1342 (and keywords
1343 (format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords)))))
1345 (defun org-html--build-style (info)
1346 "Return style information for exported document.
1347 INFO is a plist used as a communication channel."
1348 (org-element-normalize-string
1349 (concat
1350 (when (plist-get info :html-head-include-default-style)
1351 (org-element-normalize-string org-html-style-default))
1352 (org-element-normalize-string (plist-get info :html-style))
1353 (when (and (plist-get info :html-htmlized-css-url)
1354 (eq org-html-htmlize-output-type 'css))
1355 (format "<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\" />\n"
1356 (plist-get info :html-htmlized-css-url)))
1357 (when (plist-get info :html-head-include-scripts) org-html-scripts))))
1359 (defun org-html--build-mathjax-config (info)
1360 "Insert the user setup into the mathjax template.
1361 INFO is a plist used as a communication channel."
1362 (when (and (memq (plist-get info :with-latex) '(mathjax t))
1363 (org-element-map (plist-get info :parse-tree)
1364 '(latex-fragment latex-environment) 'identity info t))
1365 (let ((template org-html-mathjax-template)
1366 (options org-html-mathjax-options)
1367 (in-buffer (or (plist-get info :html-mathjax) ""))
1368 name val (yes " ") (no "// ") x)
1369 (mapc
1370 (lambda (e)
1371 (setq name (car e) val (nth 1 e))
1372 (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
1373 (setq val (car (read-from-string
1374 (substring in-buffer (match-end 0))))))
1375 (if (not (stringp val)) (setq val (format "%s" val)))
1376 (if (string-match (concat "%" (upcase (symbol-name name))) template)
1377 (setq template (replace-match val t t template))))
1378 options)
1379 (setq val (nth 1 (assq 'mathml options)))
1380 (if (string-match (concat "\\<mathml:") in-buffer)
1381 (setq val (car (read-from-string
1382 (substring in-buffer (match-end 0))))))
1383 ;; Exchange prefixes depending on mathml setting.
1384 (if (not val) (setq x yes yes no no x))
1385 ;; Replace cookies to turn on or off the config/jax lines.
1386 (if (string-match ":MMLYES:" template)
1387 (setq template (replace-match yes t t template)))
1388 (if (string-match ":MMLNO:" template)
1389 (setq template (replace-match no t t template)))
1390 ;; Return the modified template.
1391 (org-element-normalize-string template))))
1393 (defun org-html--build-preamble (info)
1394 "Return document preamble as a string, or nil.
1395 INFO is a plist used as a communication channel."
1396 (let ((preamble (plist-get info :html-preamble)))
1397 (when preamble
1398 (let ((preamble-contents
1399 (if (functionp preamble) (funcall preamble info)
1400 (let ((title (org-export-data (plist-get info :title) info))
1401 (date (if (not (plist-get info :with-date)) ""
1402 (org-export-data (plist-get info :date) info)))
1403 (author (if (not (plist-get info :with-author)) ""
1404 (org-export-data (plist-get info :author) info)))
1405 (email (if (not (plist-get info :with-email)) ""
1406 (plist-get info :email))))
1407 (if (stringp preamble)
1408 (format-spec preamble
1409 `((?t . ,title) (?a . ,author)
1410 (?d . ,date) (?e . ,email)))
1411 (format-spec
1412 (or (cadr (assoc (plist-get info :language)
1413 org-html-preamble-format))
1414 (cadr (assoc "en" org-html-preamble-format)))
1415 `((?t . ,title) (?a . ,author)
1416 (?d . ,date) (?e . ,email))))))))
1417 (when (org-string-nw-p preamble-contents)
1418 (concat (format "<div id=\"%s\">\n" (nth 0 org-html-divs))
1419 (org-element-normalize-string preamble-contents)
1420 "</div>\n"))))))
1422 (defun org-html--build-postamble (info)
1423 "Return document postamble as a string, or nil.
1424 INFO is a plist used as a communication channel."
1425 (let ((postamble (plist-get info :html-postamble)))
1426 (when postamble
1427 (let ((postamble-contents
1428 (if (functionp postamble) (funcall postamble info)
1429 (let ((date (if (not (plist-get info :with-date)) ""
1430 (org-export-data (plist-get info :date) info)))
1431 (author (let ((author (plist-get info :author)))
1432 (and author (org-export-data author info))))
1433 (email (mapconcat
1434 (lambda (e)
1435 (format "<a href=\"mailto:%s\">%s</a>" e e))
1436 (split-string (plist-get info :email) ",+ *")
1437 ", "))
1438 (html-validation-link (or org-html-validation-link ""))
1439 (creator-info (plist-get info :creator)))
1440 (cond ((stringp postamble)
1441 (format-spec postamble
1442 `((?a . ,author) (?e . ,email)
1443 (?d . ,date) (?c . ,creator-info)
1444 (?v . ,html-validation-link))))
1445 ((eq postamble 'auto)
1446 (concat
1447 (when (plist-get info :time-stamp-file)
1448 (format "<p class=\"date\">%s: %s</p>\n"
1449 (org-html--translate "Date" info)
1450 date))
1451 (when (and (plist-get info :with-author) author)
1452 (format "<p class=\"author\">%s : %s</p>\n"
1453 (org-html--translate "Author" info)
1454 author))
1455 (when (and (plist-get info :with-email) email)
1456 (format "<p class=\"email\">%s </p>\n" email))
1457 (when (plist-get info :with-creator)
1458 (format "<p class=\"creator\">%s</p>\n"
1459 creator-info))
1460 html-validation-link "\n"))
1461 (t (format-spec
1462 (or (cadr (assoc (plist-get info :language)
1463 org-html-postamble-format))
1464 (cadr (assoc "en" org-html-postamble-format)))
1465 `((?a . ,author) (?e . ,email)
1466 (?d . ,date) (?c . ,creator-info)
1467 (?v . ,html-validation-link)))))))))
1468 (when (org-string-nw-p postamble-contents)
1469 (concat
1470 (format "<div id=\"%s\">\n" (nth 2 org-html-divs))
1471 (org-element-normalize-string postamble-contents)
1472 "</div>\n"))))))
1474 (defun org-html-inner-template (contents info)
1475 "Return body of document string after HTML conversion.
1476 CONTENTS is the transcoded contents string. INFO is a plist
1477 holding export options."
1478 (concat
1479 (format "<div id=\"%s\">\n" (nth 1 org-html-divs))
1480 ;; Document title.
1481 (let ((title (plist-get info :title)))
1482 (when title
1483 (format "<h1 class=\"title\">%s</h1>\n" (org-export-data title info))))
1484 ;; Table of contents.
1485 (let ((depth (plist-get info :with-toc)))
1486 (when depth (org-html-toc depth info)))
1487 ;; Document contents.
1488 contents
1489 ;; Footnotes section.
1490 (org-html-footnote-section info)
1491 ;; Bibliography.
1492 (org-html-bibliography)
1493 "\n</div>"))
1495 (defun org-html-template (contents info)
1496 "Return complete document string after HTML conversion.
1497 CONTENTS is the transcoded contents string. INFO is a plist
1498 holding export options."
1499 (concat
1500 (format
1501 (or (and (stringp org-html-xml-declaration)
1502 org-html-xml-declaration)
1503 (cdr (assoc (plist-get info :html-extension)
1504 org-html-xml-declaration))
1505 (cdr (assoc "html" org-html-xml-declaration))
1508 (or (and org-html-coding-system
1509 (fboundp 'coding-system-get)
1510 (coding-system-get org-html-coding-system 'mime-charset))
1511 "iso-8859-1"))
1512 "\n"
1513 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
1514 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
1515 (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n"
1516 (plist-get info :language) (plist-get info :language))
1517 "<head>\n"
1518 (org-html--build-meta-info info)
1519 (org-html--build-style info)
1520 (org-html--build-mathjax-config info)
1521 "</head>\n"
1522 "<body>\n"
1523 (let ((link-up (org-trim (plist-get info :html-link-up)))
1524 (link-home (org-trim (plist-get info :html-link-home))))
1525 (unless (and (string= link-up "") (string= link-up ""))
1526 (format org-html-home/up-format
1527 (or link-up link-home)
1528 (or link-home link-up))))
1529 ;; Preamble.
1530 (org-html--build-preamble info)
1531 ;; Document contents.
1532 contents
1533 ;; Postamble.
1534 (org-html--build-postamble info)
1535 ;; Closing document.
1536 "</body>\n</html>"))
1538 (defun org-html--translate (s info)
1539 "Translate string S according to specified language.
1540 INFO is a plist used as a communication channel."
1541 (org-export-translate s :html info))
1543 ;;;; Anchor
1545 (defun org-html--anchor (&optional id desc attributes)
1546 (let* ((name (and org-html-allow-name-attribute-in-anchors id))
1547 (attributes (concat (and id (format " id=\"%s\"" id))
1548 (and name (format " name=\"%s\"" name))
1549 attributes)))
1550 (format "<a%s>%s</a>" attributes (or desc ""))))
1552 ;;;; Todo
1554 (defun org-html--todo (todo)
1555 (when todo
1556 (format "<span class=\"%s %s%s\">%s</span>"
1557 (if (member todo org-done-keywords) "done" "todo")
1558 org-html-todo-kwd-class-prefix (org-html-fix-class-name todo)
1559 todo)))
1561 ;;;; Tags
1563 (defun org-html--tags (tags)
1564 (when tags
1565 (format "<span class=\"tag\">%s</span>"
1566 (mapconcat
1567 (lambda (tag)
1568 (format "<span class=\"%s\">%s</span>"
1569 (concat org-html-tag-class-prefix
1570 (org-html-fix-class-name tag))
1571 tag))
1572 tags "&#xa0;"))))
1574 ;;;; Headline
1576 (defun* org-html-format-headline
1577 (todo todo-type priority text tags
1578 &key level section-number headline-label &allow-other-keys)
1579 (let ((section-number
1580 (when section-number
1581 (format "<span class=\"section-number-%d\">%s</span> "
1582 level section-number)))
1583 (todo (org-html--todo todo))
1584 (tags (org-html--tags tags)))
1585 (concat section-number todo (and todo " ") text
1586 (and tags "&#xa0;&#xa0;&#xa0;") tags)))
1588 ;;;; Src Code
1590 (defun org-html-fontify-code (code lang)
1591 "Color CODE with htmlize library.
1592 CODE is a string representing the source code to colorize. LANG
1593 is the language used for CODE, as a string, or nil."
1594 (when code
1595 (cond
1596 ;; Case 1: No lang. Possibly an example block.
1597 ((not lang)
1598 ;; Simple transcoding.
1599 (org-html-encode-plain-text code))
1600 ;; Case 2: No htmlize or an inferior version of htmlize
1601 ((not (and (require 'htmlize nil t) (fboundp 'htmlize-region-for-paste)))
1602 ;; Emit a warning.
1603 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1604 ;; Simple transcoding.
1605 (org-html-encode-plain-text code))
1607 ;; Map language
1608 (setq lang (or (assoc-default lang org-src-lang-modes) lang))
1609 (let* ((lang-mode (and lang (intern (format "%s-mode" lang)))))
1610 (cond
1611 ;; Case 1: Language is not associated with any Emacs mode
1612 ((not (functionp lang-mode))
1613 ;; Simple transcoding.
1614 (org-html-encode-plain-text code))
1615 ;; Case 2: Default. Fontify code.
1617 ;; htmlize
1618 (setq code (with-temp-buffer
1619 ;; Switch to language-specific mode.
1620 (funcall lang-mode)
1621 (insert code)
1622 ;; Fontify buffer.
1623 (font-lock-fontify-buffer)
1624 ;; Remove formatting on newline characters.
1625 (save-excursion
1626 (let ((beg (point-min))
1627 (end (point-max)))
1628 (goto-char beg)
1629 (while (progn (end-of-line) (< (point) end))
1630 (put-text-property (point) (1+ (point)) 'face nil)
1631 (forward-char 1))))
1632 (org-src-mode)
1633 (set-buffer-modified-p nil)
1634 ;; Htmlize region.
1635 (org-html-htmlize-region-for-paste
1636 (point-min) (point-max))))
1637 ;; Strip any enclosing <pre></pre> tags.
1638 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code) (match-end 0)))
1639 (end (and beg (string-match "</pre>\\'" code))))
1640 (if (and beg end) (substring code beg end) code)))))))))
1642 (defun org-html-do-format-code
1643 (code &optional lang refs retain-labels num-start)
1644 "Format CODE string as source code.
1645 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1646 respectively, the language of the source code, as a string, an
1647 alist between line numbers and references (as returned by
1648 `org-export-unravel-code'), a boolean specifying if labels should
1649 appear in the source code, and the number associated to the first
1650 line of code."
1651 (let* ((code-lines (org-split-string code "\n"))
1652 (code-length (length code-lines))
1653 (num-fmt
1654 (and num-start
1655 (format "%%%ds: "
1656 (length (number-to-string (+ code-length num-start))))))
1657 (code (org-html-fontify-code code lang)))
1658 (org-export-format-code
1659 code
1660 (lambda (loc line-num ref)
1661 (setq loc
1662 (concat
1663 ;; Add line number, if needed.
1664 (when num-start
1665 (format "<span class=\"linenr\">%s</span>"
1666 (format num-fmt line-num)))
1667 ;; Transcoded src line.
1669 ;; Add label, if needed.
1670 (when (and ref retain-labels) (format " (%s)" ref))))
1671 ;; Mark transcoded line as an anchor, if needed.
1672 (if (not ref) loc
1673 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1674 ref loc)))
1675 num-start refs)))
1677 (defun org-html-format-code (element info)
1678 "Format contents of ELEMENT as source code.
1679 ELEMENT is either an example block or a src block. INFO is
1680 a plist used as a communication channel."
1681 (let* ((lang (org-element-property :language element))
1682 ;; Extract code and references.
1683 (code-info (org-export-unravel-code element))
1684 (code (car code-info))
1685 (refs (cdr code-info))
1686 ;; Does the src block contain labels?
1687 (retain-labels (org-element-property :retain-labels element))
1688 ;; Does it have line numbers?
1689 (num-start (case (org-element-property :number-lines element)
1690 (continued (org-export-get-loc element info))
1691 (new 0))))
1692 (org-html-do-format-code code lang refs retain-labels num-start)))
1696 ;;; Tables of Contents
1698 (defun org-html-toc (depth info)
1699 "Build a table of contents.
1700 DEPTH is an integer specifying the depth of the table. INFO is
1701 a plist used as a communication channel. Return the table of
1702 contents as a string, or nil if it is empty."
1703 (let ((toc-entries
1704 (mapcar (lambda (headline)
1705 (cons (org-html--format-toc-headline headline info)
1706 (org-export-get-relative-level headline info)))
1707 (org-export-collect-headlines info depth))))
1708 (when toc-entries
1709 (concat "<div id=\"table-of-contents\">\n"
1710 (format "<h%d>%s</h%d>\n"
1711 org-html-toplevel-hlevel
1712 (org-html--translate "Table of Contents" info)
1713 org-html-toplevel-hlevel)
1714 "<div id=\"text-table-of-contents\">"
1715 (org-html--toc-text toc-entries)
1716 "</div>\n"
1717 "</div>\n"))))
1719 (defun org-html--toc-text (toc-entries)
1720 "Return innards of a table of contents, as a string.
1721 TOC-ENTRIES is an alist where key is an entry title, as a string,
1722 and value is its relative level, as an integer."
1723 (let* ((prev-level (1- (cdar toc-entries)))
1724 (start-level prev-level))
1725 (concat
1726 (mapconcat
1727 (lambda (entry)
1728 (let ((headline (car entry))
1729 (level (cdr entry)))
1730 (concat
1731 (let* ((cnt (- level prev-level))
1732 (times (if (> cnt 0) (1- cnt) (- cnt)))
1733 rtn)
1734 (setq prev-level level)
1735 (concat
1736 (org-html--make-string
1737 times (cond ((> cnt 0) "\n<ul>\n<li>")
1738 ((< cnt 0) "</li>\n</ul>\n")))
1739 (if (> cnt 0) "\n<ul>\n<li>" "</li>\n<li>")))
1740 headline)))
1741 toc-entries "")
1742 (org-html--make-string (- prev-level start-level) "</li>\n</ul>\n"))))
1744 (defun org-html--format-toc-headline (headline info)
1745 "Return an appropriate table of contents entry for HEADLINE.
1746 INFO is a plist used as a communication channel."
1747 (let* ((headline-number (org-export-get-headline-number headline info))
1748 (section-number
1749 (and (not (org-export-low-level-p headline info))
1750 (org-export-numbered-headline-p headline info)
1751 (concat (mapconcat 'number-to-string headline-number ".") ". ")))
1752 (tags (and (eq (plist-get info :with-tags) t)
1753 (org-export-get-tags headline info))))
1754 (format "<a href=\"#%s\">%s</a>"
1755 ;; Label.
1756 (org-export-solidify-link-text
1757 (or (org-element-property :CUSTOM_ID headline)
1758 (concat "sec-" (mapconcat 'number-to-string
1759 headline-number "-"))))
1760 ;; Body.
1761 (concat section-number
1762 (org-export-data-with-translations
1763 (org-export-get-alt-title headline info)
1764 ;; Ignore any footnote-reference, link,
1765 ;; radio-target and target in table of contents.
1766 (append
1767 '((footnote-reference . ignore)
1768 (link . (lambda (link desc i) desc))
1769 (radio-target . (lambda (radio desc i) desc))
1770 (target . ignore))
1771 (org-export-backend-translate-table 'html))
1772 info)
1773 (and tags "&#xa0;&#xa0;&#xa0;") (org-html--tags tags)))))
1775 (defun org-html-list-of-listings (info)
1776 "Build a list of listings.
1777 INFO is a plist used as a communication channel. Return the list
1778 of listings as a string, or nil if it is empty."
1779 (let ((lol-entries (org-export-collect-listings info)))
1780 (when lol-entries
1781 (concat "<div id=\"list-of-listings\">\n"
1782 (format "<h%d>%s</h%d>\n"
1783 org-html-toplevel-hlevel
1784 (org-html--translate "List of Listings" info)
1785 org-html-toplevel-hlevel)
1786 "<div id=\"text-list-of-listings\">\n<ul>\n"
1787 (let ((count 0)
1788 (initial-fmt (org-html--translate "Listing %d:" info)))
1789 (mapconcat
1790 (lambda (entry)
1791 (let ((label (org-element-property :name entry))
1792 (title (org-trim
1793 (org-export-data
1794 (or (org-export-get-caption entry t)
1795 (org-export-get-caption entry))
1796 info))))
1797 (concat
1798 "<li>"
1799 (if (not label)
1800 (concat (format initial-fmt (incf count)) " " title)
1801 (format "<a href=\"#%s\">%s %s</a>"
1802 (org-export-solidify-link-text label)
1803 (format initial-fmt (incf count))
1804 title))
1805 "</li>")))
1806 lol-entries "\n"))
1807 "\n</ul>\n</div>\n</div>"))))
1809 (defun org-html-list-of-tables (info)
1810 "Build a list of tables.
1811 INFO is a plist used as a communication channel. Return the list
1812 of tables as a string, or nil if it is empty."
1813 (let ((lol-entries (org-export-collect-tables info)))
1814 (when lol-entries
1815 (concat "<div id=\"list-of-tables\">\n"
1816 (format "<h%d>%s</h%d>\n"
1817 org-html-toplevel-hlevel
1818 (org-html--translate "List of Tables" info)
1819 org-html-toplevel-hlevel)
1820 "<div id=\"text-list-of-tables\">\n<ul>\n"
1821 (let ((count 0)
1822 (initial-fmt (org-html--translate "Table %d:" info)))
1823 (mapconcat
1824 (lambda (entry)
1825 (let ((label (org-element-property :name entry))
1826 (title (org-trim
1827 (org-export-data
1828 (or (org-export-get-caption entry t)
1829 (org-export-get-caption entry))
1830 info))))
1831 (concat
1832 "<li>"
1833 (if (not label)
1834 (concat (format initial-fmt (incf count)) " " title)
1835 (format "<a href=\"#%s\">%s %s</a>"
1836 (org-export-solidify-link-text label)
1837 (format initial-fmt (incf count))
1838 title))
1839 "</li>")))
1840 lol-entries "\n"))
1841 "\n</ul>\n</div>\n</div>"))))
1845 ;;; Transcode Functions
1847 ;;;; Bold
1849 (defun org-html-bold (bold contents info)
1850 "Transcode BOLD from Org to HTML.
1851 CONTENTS is the text with bold markup. INFO is a plist holding
1852 contextual information."
1853 (format (or (cdr (assq 'bold org-html-text-markup-alist)) "%s")
1854 contents))
1857 ;;;; Center Block
1859 (defun org-html-center-block (center-block contents info)
1860 "Transcode a CENTER-BLOCK element from Org to HTML.
1861 CONTENTS holds the contents of the block. INFO is a plist
1862 holding contextual information."
1863 (format "<div style=\"text-align: center\">\n%s</div>" contents))
1866 ;;;; Clock
1868 (defun org-html-clock (clock contents info)
1869 "Transcode a CLOCK element from Org to HTML.
1870 CONTENTS is nil. INFO is a plist used as a communication
1871 channel."
1872 (format "<p>
1873 <span class=\"timestamp-wrapper\">
1874 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
1875 </span>
1876 </p>"
1877 org-clock-string
1878 (org-translate-time
1879 (org-element-property :raw-value
1880 (org-element-property :value clock)))
1881 (let ((time (org-element-property :duration clock)))
1882 (and time (format " <span class=\"timestamp\">(%s)</span>" time)))))
1885 ;;;; Code
1887 (defun org-html-code (code contents info)
1888 "Transcode CODE from Org to HTML.
1889 CONTENTS is nil. INFO is a plist holding contextual
1890 information."
1891 (format (or (cdr (assq 'code org-html-text-markup-alist)) "%s")
1892 (org-element-property :value code)))
1895 ;;;; Drawer
1897 (defun org-html-drawer (drawer contents info)
1898 "Transcode a DRAWER element from Org to HTML.
1899 CONTENTS holds the contents of the block. INFO is a plist
1900 holding contextual information."
1901 (if (functionp org-html-format-drawer-function)
1902 (funcall org-html-format-drawer-function
1903 (org-element-property :drawer-name drawer)
1904 contents)
1905 ;; If there's no user defined function: simply
1906 ;; display contents of the drawer.
1907 contents))
1910 ;;;; Dynamic Block
1912 (defun org-html-dynamic-block (dynamic-block contents info)
1913 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
1914 CONTENTS holds the contents of the block. INFO is a plist
1915 holding contextual information. See `org-export-data'."
1916 contents)
1919 ;;;; Entity
1921 (defun org-html-entity (entity contents info)
1922 "Transcode an ENTITY object from Org to HTML.
1923 CONTENTS are the definition itself. INFO is a plist holding
1924 contextual information."
1925 (org-element-property :html entity))
1928 ;;;; Example Block
1930 (defun org-html-example-block (example-block contents info)
1931 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
1932 CONTENTS is nil. INFO is a plist holding contextual
1933 information."
1934 (if (org-export-read-attribute :attr_html example-block :textarea)
1935 (org-html--textarea-block example-block)
1936 (format "<pre class=\"example\">\n%s</pre>"
1937 (org-html-format-code example-block info))))
1940 ;;;; Export Snippet
1942 (defun org-html-export-snippet (export-snippet contents info)
1943 "Transcode a EXPORT-SNIPPET object from Org to HTML.
1944 CONTENTS is nil. INFO is a plist holding contextual
1945 information."
1946 (when (eq (org-export-snippet-backend export-snippet) 'html)
1947 (org-element-property :value export-snippet)))
1950 ;;;; Export Block
1952 (defun org-html-export-block (export-block contents info)
1953 "Transcode a EXPORT-BLOCK element from Org to HTML.
1954 CONTENTS is nil. INFO is a plist holding contextual information."
1955 (when (string= (org-element-property :type export-block) "HTML")
1956 (org-remove-indentation (org-element-property :value export-block))))
1959 ;;;; Fixed Width
1961 (defun org-html-fixed-width (fixed-width contents info)
1962 "Transcode a FIXED-WIDTH element from Org to HTML.
1963 CONTENTS is nil. INFO is a plist holding contextual information."
1964 (format "<pre class=\"example\">\n%s</pre>"
1965 (org-html-do-format-code
1966 (org-remove-indentation
1967 (org-element-property :value fixed-width)))))
1970 ;;;; Footnote Reference
1972 (defun org-html-footnote-reference (footnote-reference contents info)
1973 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
1974 CONTENTS is nil. INFO is a plist holding contextual information."
1975 (concat
1976 ;; Insert separator between two footnotes in a row.
1977 (let ((prev (org-export-get-previous-element footnote-reference info)))
1978 (when (eq (org-element-type prev) 'footnote-reference)
1979 org-html-footnote-separator))
1980 (cond
1981 ((not (org-export-footnote-first-reference-p footnote-reference info))
1982 (org-html-format-footnote-reference
1983 (org-export-get-footnote-number footnote-reference info)
1984 "IGNORED" 100))
1985 ;; Inline definitions are secondary strings.
1986 ((eq (org-element-property :type footnote-reference) 'inline)
1987 (org-html-format-footnote-reference
1988 (org-export-get-footnote-number footnote-reference info)
1989 "IGNORED" 1))
1990 ;; Non-inline footnotes definitions are full Org data.
1991 (t (org-html-format-footnote-reference
1992 (org-export-get-footnote-number footnote-reference info)
1993 "IGNORED" 1)))))
1996 ;;;; Headline
1998 (defun org-html-format-headline--wrap
1999 (headline info &optional format-function &rest extra-keys)
2000 "Transcode a HEADLINE element from Org to HTML.
2001 CONTENTS holds the contents of the headline. INFO is a plist
2002 holding contextual information."
2003 (let* ((level (+ (org-export-get-relative-level headline info)
2004 (1- org-html-toplevel-hlevel)))
2005 (headline-number (org-export-get-headline-number headline info))
2006 (section-number (and (not (org-export-low-level-p headline info))
2007 (org-export-numbered-headline-p headline info)
2008 (mapconcat 'number-to-string
2009 headline-number ".")))
2010 (todo (and (plist-get info :with-todo-keywords)
2011 (let ((todo (org-element-property :todo-keyword headline)))
2012 (and todo (org-export-data todo info)))))
2013 (todo-type (and todo (org-element-property :todo-type headline)))
2014 (priority (and (plist-get info :with-priority)
2015 (org-element-property :priority headline)))
2016 (text (org-export-data (org-element-property :title headline) info))
2017 (tags (and (plist-get info :with-tags)
2018 (org-export-get-tags headline info)))
2019 (headline-label (or (org-element-property :CUSTOM_ID headline)
2020 (concat "sec-" (mapconcat 'number-to-string
2021 headline-number "-"))))
2022 (format-function (cond
2023 ((functionp format-function) format-function)
2024 ((functionp org-html-format-headline-function)
2025 (function*
2026 (lambda (todo todo-type priority text tags
2027 &allow-other-keys)
2028 (funcall org-html-format-headline-function
2029 todo todo-type priority text tags))))
2030 (t 'org-html-format-headline))))
2031 (apply format-function
2032 todo todo-type priority text tags
2033 :headline-label headline-label :level level
2034 :section-number section-number extra-keys)))
2036 (defun org-html-headline (headline contents info)
2037 "Transcode a HEADLINE element from Org to HTML.
2038 CONTENTS holds the contents of the headline. INFO is a plist
2039 holding contextual information."
2040 ;; Empty contents?
2041 (setq contents (or contents ""))
2042 (let* ((numberedp (org-export-numbered-headline-p headline info))
2043 (level (org-export-get-relative-level headline info))
2044 (text (org-export-data (org-element-property :title headline) info))
2045 (todo (and (plist-get info :with-todo-keywords)
2046 (let ((todo (org-element-property :todo-keyword headline)))
2047 (and todo (org-export-data todo info)))))
2048 (todo-type (and todo (org-element-property :todo-type headline)))
2049 (tags (and (plist-get info :with-tags)
2050 (org-export-get-tags headline info)))
2051 (priority (and (plist-get info :with-priority)
2052 (org-element-property :priority headline)))
2053 (section-number (and (org-export-numbered-headline-p headline info)
2054 (mapconcat 'number-to-string
2055 (org-export-get-headline-number
2056 headline info) ".")))
2057 ;; Create the headline text.
2058 (full-text (org-html-format-headline--wrap headline info)))
2059 (cond
2060 ;; Case 1: This is a footnote section: ignore it.
2061 ((org-element-property :footnote-section-p headline) nil)
2062 ;; Case 2. This is a deep sub-tree: export it as a list item.
2063 ;; Also export as items headlines for which no section
2064 ;; format has been found.
2065 ((org-export-low-level-p headline info)
2066 ;; Build the real contents of the sub-tree.
2067 (let* ((type (if numberedp 'ordered 'unordered))
2068 (itemized-body (org-html-format-list-item
2069 contents type nil nil full-text)))
2070 (concat
2071 (and (org-export-first-sibling-p headline info)
2072 (org-html-begin-plain-list type))
2073 itemized-body
2074 (and (org-export-last-sibling-p headline info)
2075 (org-html-end-plain-list type)))))
2076 ;; Case 3. Standard headline. Export it as a section.
2078 (let* ((section-number (mapconcat 'number-to-string
2079 (org-export-get-headline-number
2080 headline info) "-"))
2081 (ids (remove 'nil
2082 (list (org-element-property :CUSTOM_ID headline)
2083 (concat "sec-" section-number)
2084 (org-element-property :ID headline))))
2085 (preferred-id (car ids))
2086 (extra-ids (cdr ids))
2087 (extra-class (org-element-property :HTML_CONTAINER_CLASS headline))
2088 (level1 (+ level (1- org-html-toplevel-hlevel)))
2089 (first-content (car (org-element-contents headline))))
2090 (format "<div id=\"%s\" class=\"%s\">%s%s</div>\n"
2091 (format "outline-container-%s"
2092 (or (org-element-property :CUSTOM_ID headline)
2093 section-number))
2094 (concat (format "outline-%d" level1) (and extra-class " ")
2095 extra-class)
2096 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2097 level1
2098 preferred-id
2099 (mapconcat
2100 (lambda (x)
2101 (let ((id (org-export-solidify-link-text
2102 (if (org-uuidgen-p x) (concat "ID-" x)
2103 x))))
2104 (org-html--anchor id)))
2105 extra-ids "")
2106 full-text
2107 level1)
2108 ;; When there is no section, pretend there is an empty
2109 ;; one to get the correct <div class="outline- ...>
2110 ;; which is needed by `org-info.js'.
2111 (if (not (eq (org-element-type first-content) 'section))
2112 (concat (org-html-section first-content "" info)
2113 contents)
2114 contents)))))))
2117 ;;;; Horizontal Rule
2119 (defun org-html-horizontal-rule (horizontal-rule contents info)
2120 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2121 CONTENTS is nil. INFO is a plist holding contextual information."
2122 "<hr/>")
2125 ;;;; Inline Src Block
2127 (defun org-html-inline-src-block (inline-src-block contents info)
2128 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2129 CONTENTS holds the contents of the item. INFO is a plist holding
2130 contextual information."
2131 (let* ((org-lang (org-element-property :language inline-src-block))
2132 (code (org-element-property :value inline-src-block)))
2133 (error "Cannot export inline src block")))
2136 ;;;; Inlinetask
2138 (defun org-html-format-section (text class &optional id)
2139 (let ((extra (concat (when id (format " id=\"%s\"" id)))))
2140 (concat (format "<div class=\"%s\"%s>\n" class extra) text "</div>\n")))
2142 (defun org-html-inlinetask (inlinetask contents info)
2143 "Transcode an INLINETASK element from Org to HTML.
2144 CONTENTS holds the contents of the block. INFO is a plist
2145 holding contextual information."
2146 (cond
2147 ;; If `org-html-format-inlinetask-function' is provided, call it
2148 ;; with appropriate arguments.
2149 ((functionp org-html-format-inlinetask-function)
2150 (let ((format-function
2151 (function*
2152 (lambda (todo todo-type priority text tags
2153 &key contents &allow-other-keys)
2154 (funcall org-html-format-inlinetask-function
2155 todo todo-type priority text tags contents)))))
2156 (org-html-format-headline--wrap
2157 inlinetask info format-function :contents contents)))
2158 ;; Otherwise, use a default template.
2159 (t (format "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>"
2160 (org-html-format-headline--wrap inlinetask info)
2161 contents))))
2164 ;;;; Italic
2166 (defun org-html-italic (italic contents info)
2167 "Transcode ITALIC from Org to HTML.
2168 CONTENTS is the text with italic markup. INFO is a plist holding
2169 contextual information."
2170 (format (or (cdr (assq 'italic org-html-text-markup-alist)) "%s") contents))
2173 ;;;; Item
2175 (defun org-html-checkbox (checkbox)
2176 (case checkbox (on "<code>[X]</code>")
2177 (off "<code>[&#xa0;]</code>")
2178 (trans "<code>[-]</code>")
2179 (t "")))
2181 (defun org-html-format-list-item (contents type checkbox
2182 &optional term-counter-id
2183 headline)
2184 (let ((checkbox (concat (org-html-checkbox checkbox) (and checkbox " "))))
2185 (concat
2186 (case type
2187 (ordered
2188 (let* ((counter term-counter-id)
2189 (extra (if counter (format " value=\"%s\"" counter) "")))
2190 (concat
2191 (format "<li%s>" extra)
2192 (when headline (concat headline "<br/>")))))
2193 (unordered
2194 (let* ((id term-counter-id)
2195 (extra (if id (format " id=\"%s\"" id) "")))
2196 (concat
2197 (format "<li%s>" extra)
2198 (when headline (concat headline "<br/>")))))
2199 (descriptive
2200 (let* ((term term-counter-id))
2201 (setq term (or term "(no term)"))
2202 ;; Check-boxes in descriptive lists are associated to tag.
2203 (concat (format "<dt> %s </dt>"
2204 (concat checkbox term))
2205 "<dd>"))))
2206 (unless (eq type 'descriptive) checkbox)
2207 contents
2208 (case type
2209 (ordered "</li>")
2210 (unordered "</li>")
2211 (descriptive "</dd>")))))
2213 (defun org-html-item (item contents info)
2214 "Transcode an ITEM element from Org to HTML.
2215 CONTENTS holds the contents of the item. INFO is a plist holding
2216 contextual information."
2217 (let* ((plain-list (org-export-get-parent item))
2218 (type (org-element-property :type plain-list))
2219 (counter (org-element-property :counter item))
2220 (checkbox (org-element-property :checkbox item))
2221 (tag (let ((tag (org-element-property :tag item)))
2222 (and tag (org-export-data tag info)))))
2223 (org-html-format-list-item
2224 contents type checkbox (or tag counter))))
2227 ;;;; Keyword
2229 (defun org-html-keyword (keyword contents info)
2230 "Transcode a KEYWORD element from Org to HTML.
2231 CONTENTS is nil. INFO is a plist holding contextual information."
2232 (let ((key (org-element-property :key keyword))
2233 (value (org-element-property :value keyword)))
2234 (cond
2235 ((string= key "HTML") value)
2236 ;; Invisible targets.
2237 ((string= key "TARGET") nil)
2238 ((string= key "TOC")
2239 (let ((value (downcase value)))
2240 (cond
2241 ((string-match "\\<headlines\\>" value)
2242 (let ((depth (or (and (string-match "[0-9]+" value)
2243 (string-to-number (match-string 0 value)))
2244 (plist-get info :with-toc))))
2245 (org-html-toc depth info)))
2246 ((string= "listings" value) (org-html-list-of-listings info))
2247 ((string= "tables" value) (org-html-list-of-tables info))))))))
2250 ;;;; Latex Environment
2252 (defun org-html-format-latex (latex-frag processing-type)
2253 "Format LaTeX fragments into HTML."
2254 (let ((cache-relpath "") (cache-dir "") bfn)
2255 (unless (eq processing-type 'mathjax)
2256 (setq bfn (buffer-file-name)
2257 cache-relpath
2258 (concat "ltxpng/"
2259 (file-name-sans-extension
2260 (file-name-nondirectory bfn)))
2261 cache-dir (file-name-directory bfn)))
2262 (with-temp-buffer
2263 (insert latex-frag)
2264 (org-format-latex cache-relpath cache-dir nil "Creating LaTeX Image..."
2265 nil nil processing-type)
2266 (buffer-string))))
2268 (defun org-html-latex-environment (latex-environment contents info)
2269 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2270 CONTENTS is nil. INFO is a plist holding contextual information."
2271 (let ((processing-type (plist-get info :with-latex))
2272 (latex-frag (org-remove-indentation
2273 (org-element-property :value latex-environment)))
2274 (caption (org-export-data
2275 (org-export-get-caption latex-environment) info))
2276 (attr nil) ; FIXME
2277 (label (org-element-property :name latex-environment)))
2278 (cond
2279 ((memq processing-type '(t mathjax))
2280 (org-html-format-latex latex-frag 'mathjax))
2281 ((eq processing-type 'dvipng)
2282 (let* ((formula-link (org-html-format-latex
2283 latex-frag processing-type)))
2284 (when (and formula-link
2285 (string-match "file:\\([^]]*\\)" formula-link))
2286 (org-html-format-inline-image
2287 (match-string 1 formula-link) caption label attr t))))
2288 (t latex-frag))))
2291 ;;;; Latex Fragment
2293 (defun org-html-latex-fragment (latex-fragment contents info)
2294 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2295 CONTENTS is nil. INFO is a plist holding contextual information."
2296 (let ((latex-frag (org-element-property :value latex-fragment))
2297 (processing-type (plist-get info :with-latex)))
2298 (case processing-type
2299 ((t mathjax)
2300 (org-html-format-latex latex-frag 'mathjax))
2301 (dvipng
2302 (let* ((formula-link (org-html-format-latex
2303 latex-frag processing-type)))
2304 (when (and formula-link
2305 (string-match "file:\\([^]]*\\)" formula-link))
2306 (org-html-format-inline-image
2307 (match-string 1 formula-link)))))
2308 (t latex-frag))))
2311 ;;;; Line Break
2313 (defun org-html-line-break (line-break contents info)
2314 "Transcode a LINE-BREAK object from Org to HTML.
2315 CONTENTS is nil. INFO is a plist holding contextual information."
2316 "<br/>\n")
2319 ;;;; Link
2321 (defun org-html-link--inline-image (link desc info)
2322 "Return HTML code for an inline image.
2323 LINK is the link pointing to the inline image. INFO is a plist
2324 used as a communication channel."
2325 (let* ((type (org-element-property :type link))
2326 (raw-path (org-element-property :path link))
2327 (path (cond ((member type '("http" "https"))
2328 (concat type ":" raw-path))
2329 ((file-name-absolute-p raw-path)
2330 (expand-file-name raw-path))
2331 (t raw-path)))
2332 (parent (org-export-get-parent-element link))
2333 (caption (org-export-data (org-export-get-caption parent) info))
2334 (label (org-element-property :name parent))
2335 (attr (mapconcat #'identity (org-element-property :attr_html parent) " ")))
2336 ;; Return proper string, depending on DISPOSITION.
2337 (org-html-format-inline-image
2338 path caption label attr (org-html-standalone-image-p link info))))
2340 (defvar org-html-standalone-image-predicate)
2341 (defun org-html-standalone-image-p (element info &optional predicate)
2342 "Test if ELEMENT is a standalone image for the purpose HTML export.
2343 INFO is a plist holding contextual information.
2345 Return non-nil, if ELEMENT is of type paragraph and it's sole
2346 content, save for whitespaces, is a link that qualifies as an
2347 inline image.
2349 Return non-nil, if ELEMENT is of type link and it's containing
2350 paragraph has no other content save for leading and trailing
2351 whitespaces.
2353 Return nil, otherwise.
2355 Bind `org-html-standalone-image-predicate' to constrain
2356 paragraph further. For example, to check for only captioned
2357 standalone images, do the following.
2359 \(setq org-html-standalone-image-predicate
2360 \(lambda \(paragraph\)
2361 \(org-element-property :caption paragraph\)\)\)"
2362 (let ((paragraph (case (org-element-type element)
2363 (paragraph element)
2364 (link (and (org-export-inline-image-p
2365 element org-html-inline-image-rules)
2366 (org-export-get-parent element)))
2367 (t nil))))
2368 (when (eq (org-element-type paragraph) 'paragraph)
2369 (when (or (not (and (boundp 'org-html-standalone-image-predicate)
2370 (functionp org-html-standalone-image-predicate)))
2371 (funcall org-html-standalone-image-predicate paragraph))
2372 (let ((contents (org-element-contents paragraph)))
2373 (loop for x in contents
2374 with inline-image-count = 0
2375 always (cond
2376 ((eq (org-element-type x) 'plain-text)
2377 (not (org-string-nw-p x)))
2378 ((eq (org-element-type x) 'link)
2379 (when (org-export-inline-image-p
2380 x org-html-inline-image-rules)
2381 (= (incf inline-image-count) 1)))
2382 (t nil))))))))
2384 (defun org-html-link (link desc info)
2385 "Transcode a LINK object from Org to HTML.
2387 DESC is the description part of the link, or the empty string.
2388 INFO is a plist holding contextual information. See
2389 `org-export-data'."
2390 (let* ((--link-org-files-as-html-maybe
2391 (function
2392 (lambda (raw-path info)
2393 "Treat links to `file.org' as links to `file.html', if needed.
2394 See `org-html-link-org-files-as-html'."
2395 (cond
2396 ((and org-html-link-org-files-as-html
2397 (string= ".org"
2398 (downcase (file-name-extension raw-path "."))))
2399 (concat (file-name-sans-extension raw-path) "."
2400 (plist-get info :html-extension)))
2401 (t raw-path)))))
2402 (type (org-element-property :type link))
2403 (raw-path (org-element-property :path link))
2404 ;; Ensure DESC really exists, or set it to nil.
2405 (desc (and (not (string= desc "")) desc))
2406 (path
2407 (cond
2408 ((member type '("http" "https" "ftp" "mailto"))
2409 (concat type ":" raw-path))
2410 ((string= type "file")
2411 ;; Treat links to ".org" files as ".html", if needed.
2412 (setq raw-path
2413 (funcall --link-org-files-as-html-maybe raw-path info))
2414 ;; If file path is absolute, prepend it with protocol
2415 ;; component - "file://".
2416 (when (file-name-absolute-p raw-path)
2417 (setq raw-path
2418 (concat "file://" (expand-file-name raw-path))))
2419 ;; Add search option, if any. A search option can be
2420 ;; relative to a custom-id or a headline title. Any other
2421 ;; option is ignored.
2422 (let ((option (org-element-property :search-option link)))
2423 (cond ((not option) raw-path)
2424 ((eq (aref option 0) ?#) (concat raw-path option))
2425 ;; External fuzzy link: try to resolve it if path
2426 ;; belongs to current project, if any.
2427 ((eq (aref option 0) ?*)
2428 (concat
2429 raw-path
2430 (let ((numbers
2431 (org-publish-resolve-external-fuzzy-link
2432 (org-element-property :path link) option)))
2433 (and numbers (concat "#sec-"
2434 (mapconcat 'number-to-string
2435 numbers "-")))))))))
2436 (t raw-path)))
2437 attributes protocol)
2438 ;; Extract attributes from parent's paragraph. HACK: Only do this
2439 ;; for the first link in parent. This is needed as long as
2440 ;; attributes cannot be set on a per link basis.
2441 (and (setq attributes
2442 (let ((parent (org-export-get-parent-element link)))
2443 (if (not (eq (org-element-map parent 'link 'identity info t)
2444 link))
2446 (mapconcat
2447 'identity
2448 (let ((att (org-element-property :attr_html parent)))
2449 (unless (and desc att
2450 (string-match (regexp-quote (car att)) desc))
2451 att))
2452 " "))))
2453 (unless (string= attributes "")
2454 (setq attributes (concat " " attributes))))
2455 (cond
2456 ;; Image file.
2457 ((and (or (eq t org-html-inline-images)
2458 (and org-html-inline-images (not desc)))
2459 (org-export-inline-image-p link org-html-inline-image-rules))
2460 (org-html-link--inline-image link desc info))
2461 ;; Radio target: Transcode target's contents and use them as
2462 ;; link's description.
2463 ((string= type "radio")
2464 (let ((destination (org-export-resolve-radio-link link info)))
2465 (when destination
2466 (format "<a href=\"#%s\"%s>%s</a>"
2467 (org-export-solidify-link-text path)
2468 attributes
2469 (org-export-data (org-element-contents destination) info)))))
2470 ;; Links pointing to a headline: Find destination and build
2471 ;; appropriate referencing command.
2472 ((member type '("custom-id" "fuzzy" "id"))
2473 (let ((destination (if (string= type "fuzzy")
2474 (org-export-resolve-fuzzy-link link info)
2475 (org-export-resolve-id-link link info))))
2476 (case (org-element-type destination)
2477 ;; ID link points to an external file.
2478 (plain-text
2479 (let ((fragment (concat "ID-" path))
2480 ;; Treat links to ".org" files as ".html", if needed.
2481 (path (funcall --link-org-files-as-html-maybe
2482 destination info)))
2483 (format "<a href=\"%s#%s\"%s>%s</a>"
2484 path fragment attributes (or desc destination))))
2485 ;; Fuzzy link points nowhere.
2486 ((nil)
2487 (format "<i>%s</i>"
2488 (or desc
2489 (org-export-data
2490 (org-element-property :raw-link link) info))))
2491 ;; Fuzzy link points to an invisible target.
2492 (keyword nil)
2493 ;; Link points to a headline.
2494 (headline
2495 (let ((href
2496 ;; What href to use?
2497 (cond
2498 ;; Case 1: Headline is linked via it's CUSTOM_ID
2499 ;; property. Use CUSTOM_ID.
2500 ((string= type "custom-id")
2501 (org-element-property :CUSTOM_ID destination))
2502 ;; Case 2: Headline is linked via it's ID property
2503 ;; or through other means. Use the default href.
2504 ((member type '("id" "fuzzy"))
2505 (format "sec-%s"
2506 (mapconcat 'number-to-string
2507 (org-export-get-headline-number
2508 destination info) "-")))
2509 (t (error "Shouldn't reach here"))))
2510 ;; What description to use?
2511 (desc
2512 ;; Case 1: Headline is numbered and LINK has no
2513 ;; description or LINK's description matches
2514 ;; headline's title. Display section number.
2515 (if (and (org-export-numbered-headline-p destination info)
2516 (or (not desc)
2517 (string= desc (org-element-property
2518 :raw-value destination))))
2519 (mapconcat 'number-to-string
2520 (org-export-get-headline-number
2521 destination info) ".")
2522 ;; Case 2: Either the headline is un-numbered or
2523 ;; LINK has a custom description. Display LINK's
2524 ;; description or headline's title.
2525 (or desc (org-export-data (org-element-property
2526 :title destination) info)))))
2527 (format "<a href=\"#%s\"%s>%s</a>"
2528 (org-export-solidify-link-text href) attributes desc)))
2529 ;; Fuzzy link points to a target. Do as above.
2531 (let ((path (org-export-solidify-link-text path)) number)
2532 (unless desc
2533 (setq number (cond
2534 ((org-html-standalone-image-p destination info)
2535 (org-export-get-ordinal
2536 (assoc 'link (org-element-contents destination))
2537 info 'link 'org-html-standalone-image-p))
2538 (t (org-export-get-ordinal destination info))))
2539 (setq desc (when number
2540 (if (atom number) (number-to-string number)
2541 (mapconcat 'number-to-string number ".")))))
2542 (format "<a href=\"#%s\"%s>%s</a>"
2543 path attributes (or desc "No description for this link")))))))
2544 ;; Coderef: replace link with the reference name or the
2545 ;; equivalent line number.
2546 ((string= type "coderef")
2547 (let ((fragment (concat "coderef-" path)))
2548 (format "<a href=\"#%s\"%s%s>%s</a>"
2549 fragment
2550 (org-trim
2551 (format (concat "class=\"coderef\""
2552 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2553 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2554 fragment fragment))
2555 attributes
2556 (format (org-export-get-coderef-format path desc)
2557 (org-export-resolve-coderef path info)))))
2558 ;; Link type is handled by a special function.
2559 ((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
2560 (funcall protocol (org-link-unescape path) desc 'html))
2561 ;; External link with a description part.
2562 ((and path desc) (format "<a href=\"%s\"%s>%s</a>" path attributes desc))
2563 ;; External link without a description part.
2564 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path))
2565 ;; No path, only description. Try to do something useful.
2566 (t (format "<i>%s</i>" desc)))))
2569 ;;;; Paragraph
2571 (defun org-html-paragraph (paragraph contents info)
2572 "Transcode a PARAGRAPH element from Org to HTML.
2573 CONTENTS is the contents of the paragraph, as a string. INFO is
2574 the plist used as a communication channel."
2575 (let* ((style nil) ; FIXME
2576 (class (cdr (assoc style '((footnote . "footnote")
2577 (verse . nil)))))
2578 (extra (if class (format " class=\"%s\"" class) ""))
2579 (parent (org-export-get-parent paragraph)))
2580 (cond
2581 ((and (eq (org-element-type parent) 'item)
2582 (= (org-element-property :begin paragraph)
2583 (org-element-property :contents-begin parent)))
2584 ;; leading paragraph in a list item have no tags
2585 contents)
2586 ((org-html-standalone-image-p paragraph info)
2587 ;; standalone image
2588 contents)
2589 (t (format "<p%s>\n%s</p>" extra contents)))))
2592 ;;;; Plain List
2594 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2595 ;; the correct value for the item counter
2596 (defun org-html-begin-plain-list (type &optional arg1)
2597 "Insert the beginning of the HTML list depending on TYPE.
2598 When ARG1 is a string, use it as the start parameter for ordered
2599 lists."
2600 (case type
2601 (ordered
2602 (format "<ol class=\"org-ol\"%s>"
2603 (if arg1 (format " start=\"%d\"" arg1) "")))
2604 (unordered "<ul class=\"org-ul\">")
2605 (descriptive "<dl class=\"org-dl\">")))
2607 (defun org-html-end-plain-list (type)
2608 "Insert the end of the HTML list depending on TYPE."
2609 (case type
2610 (ordered "</ol>")
2611 (unordered "</ul>")
2612 (descriptive "</dl>")))
2614 (defun org-html-plain-list (plain-list contents info)
2615 "Transcode a PLAIN-LIST element from Org to HTML.
2616 CONTENTS is the contents of the list. INFO is a plist holding
2617 contextual information."
2618 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2619 (type (org-element-property :type plain-list)))
2620 (format "%s\n%s%s"
2621 (org-html-begin-plain-list type)
2622 contents (org-html-end-plain-list type))))
2624 ;;;; Plain Text
2626 (defun org-html-convert-special-strings (string)
2627 "Convert special characters in STRING to HTML."
2628 (let ((all org-html-special-string-regexps)
2629 e a re rpl start)
2630 (while (setq a (pop all))
2631 (setq re (car a) rpl (cdr a) start 0)
2632 (while (string-match re string start)
2633 (setq string (replace-match rpl t nil string))))
2634 string))
2636 (defun org-html-encode-plain-text (text)
2637 "Convert plain text characters to HTML equivalent.
2638 Possible conversions are set in `org-export-html-protect-char-alist'."
2639 (mapc
2640 (lambda (pair)
2641 (setq text (replace-regexp-in-string (car pair) (cdr pair) text t t)))
2642 org-html-protect-char-alist)
2643 text)
2645 (defun org-html-plain-text (text info)
2646 "Transcode a TEXT string from Org to HTML.
2647 TEXT is the string to transcode. INFO is a plist holding
2648 contextual information."
2649 (let ((output text))
2650 ;; Protect following characters: <, >, &.
2651 (setq output (org-html-encode-plain-text output))
2652 ;; Handle smart quotes. Be sure to provide original string since
2653 ;; OUTPUT may have been modified.
2654 (when (plist-get info :with-smart-quotes)
2655 (setq output (org-export-activate-smart-quotes output :html info text)))
2656 ;; Handle special strings.
2657 (when (plist-get info :with-special-strings)
2658 (setq output (org-html-convert-special-strings output)))
2659 ;; Handle break preservation if required.
2660 (when (plist-get info :preserve-breaks)
2661 (setq output
2662 (replace-regexp-in-string
2663 "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output)))
2664 ;; Return value.
2665 output))
2668 ;; Planning
2670 (defun org-html-planning (planning contents info)
2671 "Transcode a PLANNING element from Org to HTML.
2672 CONTENTS is nil. INFO is a plist used as a communication
2673 channel."
2674 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2675 (format
2676 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2677 (mapconcat
2678 'identity
2679 (delq nil
2680 (list
2681 (let ((closed (org-element-property :closed planning)))
2682 (when closed
2683 (format span-fmt org-closed-string
2684 (org-translate-time
2685 (org-element-property :raw-value closed)))))
2686 (let ((deadline (org-element-property :deadline planning)))
2687 (when deadline
2688 (format span-fmt org-deadline-string
2689 (org-translate-time
2690 (org-element-property :raw-value deadline)))))
2691 (let ((scheduled (org-element-property :scheduled planning)))
2692 (when scheduled
2693 (format span-fmt org-scheduled-string
2694 (org-translate-time
2695 (org-element-property :raw-value scheduled)))))))
2696 " "))))
2699 ;;;; Property Drawer
2701 (defun org-html-property-drawer (property-drawer contents info)
2702 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2703 CONTENTS is nil. INFO is a plist holding contextual
2704 information."
2705 ;; The property drawer isn't exported but we want separating blank
2706 ;; lines nonetheless.
2710 ;;;; Quote Block
2712 (defun org-html-quote-block (quote-block contents info)
2713 "Transcode a QUOTE-BLOCK element from Org to HTML.
2714 CONTENTS holds the contents of the block. INFO is a plist
2715 holding contextual information."
2716 (format "<blockquote>\n%s</blockquote>" contents))
2719 ;;;; Quote Section
2721 (defun org-html-quote-section (quote-section contents info)
2722 "Transcode a QUOTE-SECTION element from Org to HTML.
2723 CONTENTS is nil. INFO is a plist holding contextual information."
2724 (let ((value (org-remove-indentation
2725 (org-element-property :value quote-section))))
2726 (when value (format "<pre>\n%s</pre>" value))))
2729 ;;;; Section
2731 (defun org-html-section (section contents info)
2732 "Transcode a SECTION element from Org to HTML.
2733 CONTENTS holds the contents of the section. INFO is a plist
2734 holding contextual information."
2735 (let ((parent (org-export-get-parent-headline section)))
2736 ;; Before first headline: no container, just return CONTENTS.
2737 (if (not parent) contents
2738 ;; Get div's class and id references.
2739 (let* ((class-num (+ (org-export-get-relative-level parent info)
2740 (1- org-html-toplevel-hlevel)))
2741 (section-number
2742 (mapconcat
2743 'number-to-string
2744 (org-export-get-headline-number parent info) "-")))
2745 ;; Build return value.
2746 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2747 class-num
2748 (or (org-element-property :CUSTOM_ID parent) section-number)
2749 contents)))))
2751 ;;;; Radio Target
2753 (defun org-html-radio-target (radio-target text info)
2754 "Transcode a RADIO-TARGET object from Org to HTML.
2755 TEXT is the text of the target. INFO is a plist holding
2756 contextual information."
2757 (let ((id (org-export-solidify-link-text
2758 (org-element-property :value radio-target))))
2759 (org-html--anchor id text)))
2762 ;;;; Special Block
2764 (defun org-html-special-block (special-block contents info)
2765 "Transcode a SPECIAL-BLOCK element from Org to HTML.
2766 CONTENTS holds the contents of the block. INFO is a plist
2767 holding contextual information."
2768 (format "<div class=\"%s\">\n%s\n</div>"
2769 (downcase (org-element-property :type special-block))
2770 contents))
2773 ;;;; Src Block
2775 (defun org-html-src-block (src-block contents info)
2776 "Transcode a SRC-BLOCK element from Org to HTML.
2777 CONTENTS holds the contents of the item. INFO is a plist holding
2778 contextual information."
2779 (if (org-export-read-attribute :attr_html src-block :textarea)
2780 (org-html--textarea-block src-block)
2781 (let ((lang (org-element-property :language src-block))
2782 (caption (org-export-get-caption src-block))
2783 (code (org-html-format-code src-block info))
2784 (label (let ((lbl (org-element-property :name src-block)))
2785 (if (not lbl) ""
2786 (format " id=\"%s\""
2787 (org-export-solidify-link-text lbl))))))
2788 (if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
2789 (format
2790 "<div class=\"org-src-container\">\n%s%s\n</div>"
2791 (if (not caption) ""
2792 (format "<label class=\"org-src-name\">%s</label>"
2793 (org-export-data caption info)))
2794 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code))))))
2797 ;;;; Statistics Cookie
2799 (defun org-html-statistics-cookie (statistics-cookie contents info)
2800 "Transcode a STATISTICS-COOKIE object from Org to HTML.
2801 CONTENTS is nil. INFO is a plist holding contextual information."
2802 (let ((cookie-value (org-element-property :value statistics-cookie)))
2803 (format "<code>%s</code>" cookie-value)))
2806 ;;;; Strike-Through
2808 (defun org-html-strike-through (strike-through contents info)
2809 "Transcode STRIKE-THROUGH from Org to HTML.
2810 CONTENTS is the text with strike-through markup. INFO is a plist
2811 holding contextual information."
2812 (format (or (cdr (assq 'strike-through org-html-text-markup-alist)) "%s")
2813 contents))
2816 ;;;; Subscript
2818 (defun org-html-subscript (subscript contents info)
2819 "Transcode a SUBSCRIPT object from Org to HTML.
2820 CONTENTS is the contents of the object. INFO is a plist holding
2821 contextual information."
2822 (format "<sub>%s</sub>" contents))
2825 ;;;; Superscript
2827 (defun org-html-superscript (superscript contents info)
2828 "Transcode a SUPERSCRIPT object from Org to HTML.
2829 CONTENTS is the contents of the object. INFO is a plist holding
2830 contextual information."
2831 (format "<sup>%s</sup>" contents))
2834 ;;;; Tabel Cell
2836 (defun org-html-table-cell (table-cell contents info)
2837 "Transcode a TABLE-CELL element from Org to HTML.
2838 CONTENTS is nil. INFO is a plist used as a communication
2839 channel."
2840 (let* ((table-row (org-export-get-parent table-cell))
2841 (table (org-export-get-parent-table table-cell))
2842 (cell-attrs
2843 (if (not org-html-table-align-individual-fields) ""
2844 (format (if (and (boundp 'org-html-format-table-no-css)
2845 org-html-format-table-no-css)
2846 " align=\"%s\"" " class=\"%s\"")
2847 (org-export-table-cell-alignment table-cell info)))))
2848 (when (or (not contents) (string= "" (org-trim contents)))
2849 (setq contents "&#xa0;"))
2850 (cond
2851 ((and (org-export-table-has-header-p table info)
2852 (= 1 (org-export-table-row-group table-row info)))
2853 (concat "\n" (format (car org-html-table-header-tags) "col" cell-attrs)
2854 contents (cdr org-html-table-header-tags)))
2855 ((and org-html-table-use-header-tags-for-first-column
2856 (zerop (cdr (org-export-table-cell-address table-cell info))))
2857 (concat "\n" (format (car org-html-table-header-tags) "row" cell-attrs)
2858 contents (cdr org-html-table-header-tags)))
2859 (t (concat "\n" (format (car org-html-table-data-tags) cell-attrs)
2860 contents (cdr org-html-table-data-tags))))))
2863 ;;;; Table Row
2865 (defun org-html-table-row (table-row contents info)
2866 "Transcode a TABLE-ROW element from Org to HTML.
2867 CONTENTS is the contents of the row. INFO is a plist used as a
2868 communication channel."
2869 ;; Rules are ignored since table separators are deduced from
2870 ;; borders of the current row.
2871 (when (eq (org-element-property :type table-row) 'standard)
2872 (let* ((first-rowgroup-p (= 1 (org-export-table-row-group table-row info)))
2873 (rowgroup-tags
2874 (cond
2875 ;; Case 1: Row belongs to second or subsequent rowgroups.
2876 ((not (= 1 (org-export-table-row-group table-row info)))
2877 '("<tbody>" . "\n</tbody>"))
2878 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
2879 ((org-export-table-has-header-p
2880 (org-export-get-parent-table table-row) info)
2881 '("<thead>" . "\n</thead>"))
2882 ;; Case 2: Row is from first and only row group.
2883 (t '("<tbody>" . "\n</tbody>")))))
2884 (concat
2885 ;; Begin a rowgroup?
2886 (when (org-export-table-row-starts-rowgroup-p table-row info)
2887 (car rowgroup-tags))
2888 ;; Actual table row
2889 (concat "\n" (eval (car org-html-table-row-tags))
2890 contents
2891 "\n"
2892 (eval (cdr org-html-table-row-tags)))
2893 ;; End a rowgroup?
2894 (when (org-export-table-row-ends-rowgroup-p table-row info)
2895 (cdr rowgroup-tags))))))
2898 ;;;; Table
2900 (defun org-html-table-first-row-data-cells (table info)
2901 (let ((table-row
2902 (org-element-map table 'table-row
2903 (lambda (row)
2904 (unless (eq (org-element-property :type row) 'rule) row))
2905 info 'first-match))
2906 (special-column-p (org-export-table-has-special-column-p table)))
2907 (if (not special-column-p) (org-element-contents table-row)
2908 (cdr (org-element-contents table-row)))))
2910 (defun org-html-table--table.el-table (table info)
2911 (when (eq (org-element-property :type table) 'table.el)
2912 (require 'table)
2913 (let ((outbuf (with-current-buffer
2914 (get-buffer-create "*org-export-table*")
2915 (erase-buffer) (current-buffer))))
2916 (with-temp-buffer
2917 (insert (org-element-property :value table))
2918 (goto-char 1)
2919 (re-search-forward "^[ \t]*|[^|]" nil t)
2920 (table-generate-source 'html outbuf))
2921 (with-current-buffer outbuf
2922 (prog1 (org-trim (buffer-string))
2923 (kill-buffer) )))))
2925 (defun org-html-table (table contents info)
2926 "Transcode a TABLE element from Org to HTML.
2927 CONTENTS is the contents of the table. INFO is a plist holding
2928 contextual information."
2929 (case (org-element-property :type table)
2930 ;; Case 1: table.el table. Convert it using appropriate tools.
2931 (table.el (org-html-table--table.el-table table info))
2932 ;; Case 2: Standard table.
2934 (let* ((label (org-element-property :name table))
2935 (caption (org-export-get-caption table))
2936 (attributes (mapconcat #'identity
2937 (org-element-property :attr_html table)
2938 " "))
2939 (alignspec
2940 (if (and (boundp 'org-html-format-table-no-css)
2941 org-html-format-table-no-css)
2942 "align=\"%s\"" "class=\"%s\""))
2943 (table-column-specs
2944 (function
2945 (lambda (table info)
2946 (mapconcat
2947 (lambda (table-cell)
2948 (let ((alignment (org-export-table-cell-alignment
2949 table-cell info)))
2950 (concat
2951 ;; Begin a colgroup?
2952 (when (org-export-table-cell-starts-colgroup-p
2953 table-cell info)
2954 "\n<colgroup>")
2955 ;; Add a column. Also specify it's alignment.
2956 (format "\n<col %s/>" (format alignspec alignment))
2957 ;; End a colgroup?
2958 (when (org-export-table-cell-ends-colgroup-p
2959 table-cell info)
2960 "\n</colgroup>"))))
2961 (org-html-table-first-row-data-cells table info) "\n"))))
2962 (table-attributes
2963 (let ((table-tag (plist-get info :html-table-tag)))
2964 (concat
2965 (and (string-match "<table\\(.*\\)>" table-tag)
2966 (match-string 1 table-tag))
2967 (and label (format " id=\"%s\""
2968 (org-export-solidify-link-text label)))
2969 (unless (string= attributes "")
2970 (concat " " attributes))))))
2971 ;; Remove last blank line.
2972 (setq contents (substring contents 0 -1))
2973 (format "<table%s>\n%s\n%s\n%s\n</table>"
2974 table-attributes
2975 (if (not caption) ""
2976 (format "<caption>%s</caption>"
2977 (org-export-data caption info)))
2978 (funcall table-column-specs table info)
2979 contents)))))
2982 ;;;; Target
2984 (defun org-html-target (target contents info)
2985 "Transcode a TARGET object from Org to HTML.
2986 CONTENTS is nil. INFO is a plist holding contextual
2987 information."
2988 (let ((id (org-export-solidify-link-text
2989 (org-element-property :value target))))
2990 (org-html--anchor id)))
2993 ;;;; Timestamp
2995 (defun org-html-timestamp (timestamp contents info)
2996 "Transcode a TIMESTAMP object from Org to HTML.
2997 CONTENTS is nil. INFO is a plist holding contextual
2998 information."
2999 (let ((value (org-html-plain-text
3000 (org-timestamp-translate timestamp) info)))
3001 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3002 (replace-regexp-in-string "--" "&#x2013;" value))))
3005 ;;;; Underline
3007 (defun org-html-underline (underline contents info)
3008 "Transcode UNDERLINE from Org to HTML.
3009 CONTENTS is the text with underline markup. INFO is a plist
3010 holding contextual information."
3011 (format (or (cdr (assq 'underline org-html-text-markup-alist)) "%s")
3012 contents))
3015 ;;;; Verbatim
3017 (defun org-html-verbatim (verbatim contents info)
3018 "Transcode VERBATIM from Org to HTML.
3019 CONTENTS is nil. INFO is a plist holding contextual
3020 information."
3021 (format (or (cdr (assq 'verbatim org-html-text-markup-alist)) "%s")
3022 (org-element-property :value verbatim)))
3025 ;;;; Verse Block
3027 (defun org-html-verse-block (verse-block contents info)
3028 "Transcode a VERSE-BLOCK element from Org to HTML.
3029 CONTENTS is verse block contents. INFO is a plist holding
3030 contextual information."
3031 ;; Replace each newline character with line break. Also replace
3032 ;; each blank line with a line break.
3033 (setq contents (replace-regexp-in-string
3034 "^ *\\\\\\\\$" "<br/>\n"
3035 (replace-regexp-in-string
3036 "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents)))
3037 ;; Replace each white space at beginning of a line with a
3038 ;; non-breaking space.
3039 (while (string-match "^[ \t]+" contents)
3040 (let* ((num-ws (length (match-string 0 contents)))
3041 (ws (let (out) (dotimes (i num-ws out)
3042 (setq out (concat out "&#xa0;"))))))
3043 (setq contents (replace-match ws nil t contents))))
3044 (format "<p class=\"verse\">\n%s</p>" contents))
3048 ;;; Filter Functions
3050 (defun org-html-final-function (contents backend info)
3051 (if (not org-html-pretty-output) contents
3052 (with-temp-buffer
3053 (html-mode)
3054 (insert contents)
3055 (indent-region (point-min) (point-max))
3056 (buffer-substring-no-properties (point-min) (point-max)))))
3060 ;;; End-user functions
3062 ;;;###autoload
3063 (defun org-html-export-as-html
3064 (&optional async subtreep visible-only body-only ext-plist)
3065 "Export current buffer to an HTML buffer.
3067 If narrowing is active in the current buffer, only export its
3068 narrowed part.
3070 If a region is active, export that region.
3072 A non-nil optional argument ASYNC means the process should happen
3073 asynchronously. The resulting buffer should be accessible
3074 through the `org-export-stack' interface.
3076 When optional argument SUBTREEP is non-nil, export the sub-tree
3077 at point, extracting information from the headline properties
3078 first.
3080 When optional argument VISIBLE-ONLY is non-nil, don't export
3081 contents of hidden elements.
3083 When optional argument BODY-ONLY is non-nil, only write code
3084 between \"<body>\" and \"</body>\" tags.
3086 EXT-PLIST, when provided, is a property list with external
3087 parameters overriding Org default settings, but still inferior to
3088 file-local settings.
3090 Export is done in a buffer named \"*Org HTML Export*\", which
3091 will be displayed when `org-export-show-temporary-export-buffer'
3092 is non-nil."
3093 (interactive)
3094 (if async
3095 (org-export-async-start
3096 (lambda (output)
3097 (with-current-buffer (get-buffer-create "*Org HTML Export*")
3098 (erase-buffer)
3099 (insert output)
3100 (goto-char (point-min))
3101 (set-auto-mode t)
3102 (org-export-add-to-stack (current-buffer) 'html)))
3103 `(org-export-as 'html ,subtreep ,visible-only ,body-only ',ext-plist))
3104 (let ((outbuf (org-export-to-buffer
3105 'html "*Org HTML Export*"
3106 subtreep visible-only body-only ext-plist)))
3107 ;; Set major mode.
3108 (with-current-buffer outbuf (set-auto-mode t))
3109 (when org-export-show-temporary-export-buffer
3110 (switch-to-buffer-other-window outbuf)))))
3112 ;;;###autoload
3113 (defun org-html-export-to-html
3114 (&optional async subtreep visible-only body-only ext-plist)
3115 "Export current buffer to a HTML file.
3117 If narrowing is active in the current buffer, only export its
3118 narrowed part.
3120 If a region is active, export that region.
3122 A non-nil optional argument ASYNC means the process should happen
3123 asynchronously. The resulting file should be accessible through
3124 the `org-export-stack' interface.
3126 When optional argument SUBTREEP is non-nil, export the sub-tree
3127 at point, extracting information from the headline properties
3128 first.
3130 When optional argument VISIBLE-ONLY is non-nil, don't export
3131 contents of hidden elements.
3133 When optional argument BODY-ONLY is non-nil, only write code
3134 between \"<body>\" and \"</body>\" tags.
3136 EXT-PLIST, when provided, is a property list with external
3137 parameters overriding Org default settings, but still inferior to
3138 file-local settings.
3140 Return output file's name."
3141 (interactive)
3142 (let* ((extension (concat "." org-html-extension))
3143 (file (org-export-output-file-name extension subtreep))
3144 (org-export-coding-system org-html-coding-system))
3145 (if async
3146 (org-export-async-start
3147 (lambda (f) (org-export-add-to-stack f 'html))
3148 (let ((org-export-coding-system org-html-coding-system))
3149 `(expand-file-name
3150 (org-export-to-file
3151 'html ,file ,subtreep ,visible-only ,body-only ',ext-plist))))
3152 (let ((org-export-coding-system org-html-coding-system))
3153 (org-export-to-file
3154 'html file subtreep visible-only body-only ext-plist)))))
3156 ;;;###autoload
3157 (defun org-html-publish-to-html (plist filename pub-dir)
3158 "Publish an org file to HTML.
3160 FILENAME is the filename of the Org file to be published. PLIST
3161 is the property list for the given project. PUB-DIR is the
3162 publishing directory.
3164 Return output file name."
3165 (org-publish-org-to 'html filename ".html" plist pub-dir))
3169 ;;; FIXME
3171 ;;;; org-format-table-html
3172 ;;;; org-format-org-table-html
3173 ;;;; org-format-table-table-html
3174 ;;;; org-table-number-fraction
3175 ;;;; org-table-number-regexp
3176 ;;;; org-html-table-caption-above
3177 ;;;; org-html-with-timestamp
3178 ;;;; org-html-html-helper-timestamp
3179 ;;;; org-html-inline-image-extensions
3180 ;;;; org-export-preferred-target-alist
3181 ;;;; class for anchors
3182 ;;;; org-export-with-section-numbers, body-only
3183 ;;;; org-export-mark-todo-in-toc
3184 ;;;; org-html-format-org-link
3185 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
3186 ;;;; alt = (file-name-nondirectory path)
3188 (provide 'ox-html)
3190 ;; Local variables:
3191 ;; generated-autoload-file: "org-loaddefs.el"
3192 ;; End:
3194 ;;; ox-html.el ends here