1 ;;; ox-html.el --- HTML Back-End for Org Export Engine
3 ;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Jambunathan K <kjambunathan at gmail dot com>
7 ;; Keywords: outlines, hypermedia, calendar, wp
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;; This library implements a HTML back-end for Org generic exporter.
28 ;; M-x org-html-export-as-html
30 ;; in an Org mode buffer. See ox.el for more details on how this
39 (require 'format-spec
)
40 (eval-when-compile (require 'cl
) (require 'table nil
'noerror
))
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
))
49 (declare-function mm-url-decode-entities
"mm-url" ())
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
))
104 :filters-alist
'((:filter-options . org-html-infojs-install-script
)
105 (:filter-final-output . org-html-final-function
))
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"
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
)))))))
115 '((:html-extension nil nil org-html-extension
)
116 (:html-link-org-as-html nil nil org-html-link-org-files-as-html
)
117 (:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
118 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
119 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
120 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
121 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
122 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
123 (:html-postamble nil
"html-postamble" org-html-postamble
)
124 (:html-preamble nil
"html-preamble" org-html-preamble
)
125 (:html-head
"HTML_HEAD" nil org-html-head newline
)
126 (:html-head-extra
"HTML_HEAD_EXTRA" nil org-html-head-extra newline
)
127 (:html-head-include-default-style nil
"html-style" org-html-head-include-default-style
)
128 (:html-head-include-scripts nil
"html-scripts" org-html-head-include-scripts
)
129 (:html-table-attributes nil nil org-html-table-default-attributes
)
130 (:html-table-row-tags nil nil org-html-table-row-tags
)
131 (:html-xml-declaration nil nil org-html-xml-declaration
)
132 (:html-inline-images nil nil org-html-inline-images
)
133 (:infojs-opt
"INFOJS_OPT" nil nil
)
134 ;; Redefine regular options.
135 (:creator
"CREATOR" nil org-html-creator-string
)
136 (:with-latex nil
"tex" org-html-with-latex
)))
139 ;;; Internal Variables
141 (defvar org-html-format-table-no-css
)
142 (defvar htmlize-buffer-places
) ; from htmlize.el
144 (defvar org-html--pre
/postamble-class
"status"
145 "CSS class used for pre/postamble")
147 (defconst org-html-doctype-alist
148 '(("html4-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
149 \"http://www.w3.org/TR/html4/strict.dtd\">")
150 ("html4-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
151 \"http://www.w3.org/TR/html4/loose.dtd\">")
152 ("html4-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
153 \"http://www.w3.org/TR/html4/frameset.dtd\">")
155 ("xhtml-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
156 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
157 ("xhtml-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
158 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
159 ("xhtml-framset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
160 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
161 ("xhtml-11" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
162 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
164 ("html5" .
"<!DOCTYPE html>")
165 ("xhtml5" .
"<!DOCTYPE html>"))
166 "An alist mapping (x)html flavors to specific doctypes.")
168 (defconst org-html-html5-elements
169 '("article" "aside" "audio" "canvas" "details" "figcaption"
170 "figure" "footer" "header" "menu" "meter" "nav" "output"
171 "progress" "section" "video")
172 "New elements in html5.
174 <hgroup> is not included because it's currently impossible to
175 wrap special blocks around multiple headlines. For other blocks
176 that should contain headlines, use the HTML_CONTAINER property on
177 the headline itself.")
179 (defconst org-html-special-string-regexps
180 '(("\\\\-" .
"­") ; shy
181 ("---\\([^-]\\)" .
"—\\1") ; mdash
182 ("--\\([^-]\\)" .
"–\\1") ; ndash
183 ("\\.\\.\\." .
"…")) ; hellip
184 "Regular expressions for special string conversion.")
186 (defconst org-html-scripts
187 "<script type=\"text/javascript\">
189 @licstart The following is the entire license notice for the
190 JavaScript code in this tag.
192 Copyright (C) 2012 Free Software Foundation, Inc.
194 The JavaScript code in this tag is free software: you can
195 redistribute it and/or modify it under the terms of the GNU
196 General Public License (GNU GPL) as published by the Free Software
197 Foundation, either version 3 of the License, or (at your option)
198 any later version. The code is distributed WITHOUT ANY WARRANTY;
199 without even the implied warranty of MERCHANTABILITY or FITNESS
200 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
202 As additional permission under GNU GPL version 3 section 7, you
203 may distribute non-source (e.g., minimized or compacted) forms of
204 that code without the copy of the GNU GPL normally required by
205 section 4, provided you include this license notice and a URL
206 through which recipients can access the Corresponding Source.
209 @licend The above is the entire license notice
210 for the JavaScript code in this tag.
212 <!--/*--><![CDATA[/*><!--*/
213 function CodeHighlightOn(elem, id)
215 var target = document.getElementById(id);
217 elem.cacheClassElem = elem.className;
218 elem.cacheClassTarget = target.className;
219 target.className = \"code-highlighted\";
220 elem.className = \"code-highlighted\";
223 function CodeHighlightOff(elem, id)
225 var target = document.getElementById(id);
226 if(elem.cacheClassElem)
227 elem.className = elem.cacheClassElem;
228 if(elem.cacheClassTarget)
229 target.className = elem.cacheClassTarget;
233 "Basic JavaScript that is needed by HTML files produced by Org mode.")
235 (defconst org-html-style-default
236 "<style type=\"text/css\">
237 <!--/*--><![CDATA[/*><!--*/
238 .title { text-align: center; }
239 .todo { font-family: monospace; color: red; }
240 .done { color: green; }
241 .tag { background-color: #eee; font-family: monospace;
242 padding: 2px; font-size: 80%; font-weight: normal; }
243 .timestamp { color: #bebebe; }
244 .timestamp-kwd { color: #5f9ea0; }
245 .right { margin-left: auto; margin-right: 0px; text-align: right; }
246 .left { margin-left: 0px; margin-right: auto; text-align: left; }
247 .center { margin-left: auto; margin-right: auto; text-align: center; }
248 .underline { text-decoration: underline; }
249 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
250 p.verse { margin-left: 3%; }
252 border: 1px solid #ccc;
253 box-shadow: 3px 3px 3px #eee;
255 font-family: monospace;
267 background-color: white;
271 border: 1px solid black;
273 pre.src:hover:before { display: inline;}
274 pre.src-sh:before { content: 'sh'; }
275 pre.src-bash:before { content: 'sh'; }
276 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
277 pre.src-R:before { content: 'R'; }
278 pre.src-perl:before { content: 'Perl'; }
279 pre.src-java:before { content: 'Java'; }
280 pre.src-sql:before { content: 'SQL'; }
282 table { border-collapse:collapse; }
283 td, th { vertical-align:top; }
284 th.right { text-align: center; }
285 th.left { text-align: center; }
286 th.center { text-align: center; }
287 td.right { text-align: right; }
288 td.left { text-align: left; }
289 td.center { text-align: center; }
290 dt { font-weight: bold; }
291 .footpara:nth-child(2) { display: inline; }
292 .footpara { display: block; }
293 .footdef { margin-bottom: 1em; }
294 .figure { padding: 1em; }
295 .figure p { text-align: center; }
298 border: 2px solid gray;
303 { text-align: right; font-size: 70%; white-space: nowrap; }
304 textarea { overflow-x: auto; }
305 .linenr { font-size: smaller }
306 .code-highlighted { background-color: #ffff00; }
307 .org-info-js_info-navigation { border-style: none; }
308 #org-info-js_console-label
309 { font-size: 10px; font-weight: bold; white-space: nowrap; }
310 .org-info-js_search-highlight
311 { background-color: #ffff00; color: #000000; font-weight: bold; }
314 "The default style specification for exported HTML files.
315 You can use `org-html-head' and `org-html-head-extra' to add to
316 this style. If you don't want to include this default style,
317 customize `org-html-head-include-default-style'.")
320 ;;; User Configuration Variables
322 (defgroup org-export-html nil
323 "Options for exporting Org mode files to HTML."
324 :tag
"Org Export HTML"
329 (defvar org-html-infojs-opts-table
330 '((path PATH
"http://orgmode.org/org-info.js")
334 (tdepth TOC_DEPTH
"max")
335 (sdepth SECTION_DEPTH
"max")
336 (mouse MOUSE_HINT
"underline")
337 (buttons VIEW_BUTTONS
"0")
339 (up LINK_UP
:html-link-up
)
340 (home LINK_HOME
:html-link-home
))
341 "JavaScript options, long form for script, default values.")
343 (defcustom org-html-use-infojs
'when-configured
344 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
345 This option can be nil or t to never or always use the script.
346 It can also be the symbol `when-configured', meaning that the
347 script will be linked into the export file if and only if there
348 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
349 `org-html-infojs-options'."
350 :group
'org-export-html
352 :package-version
'(Org .
"8.0")
354 (const :tag
"Never" nil
)
355 (const :tag
"When configured in buffer" when-configured
)
356 (const :tag
"Always" t
)))
358 (defcustom org-html-infojs-options
359 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
360 "Options settings for the INFOJS JavaScript.
361 Each of the options must have an entry in `org-html-infojs-opts-table'.
362 The value can either be a string that will be passed to the script, or
363 a property. This property is then assumed to be a property that is defined
364 by the Export/Publishing setup of Org.
365 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
366 means to use the maximum value consistent with other options."
367 :group
'org-export-html
369 :package-version
'(Org .
"8.0")
371 `(set :greedy t
:inline t
374 (list 'cons
(list 'const
(car x
))
376 (symbol :tag
"Publishing/Export property")
377 (string :tag
"Value"))))
378 org-html-infojs-opts-table
)))
380 (defcustom org-html-infojs-template
381 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
384 * @source: %SCRIPT_PATH
386 * @licstart The following is the entire license notice for the
387 * JavaScript code in %SCRIPT_PATH.
389 * Copyright (C) 2012-2013 Sebastian Rose
392 * The JavaScript code in this tag is free software: you can
393 * redistribute it and/or modify it under the terms of the GNU
394 * General Public License (GNU GPL) as published by the Free Software
395 * Foundation, either version 3 of the License, or (at your option)
396 * any later version. The code is distributed WITHOUT ANY WARRANTY;
397 * without even the implied warranty of MERCHANTABILITY or FITNESS
398 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
400 * As additional permission under GNU GPL version 3 section 7, you
401 * may distribute non-source (e.g., minimized or compacted) forms of
402 * that code without the copy of the GNU GPL normally required by
403 * section 4, provided you include this license notice and a URL
404 * through which recipients can access the Corresponding Source.
406 * @licend The above is the entire license notice
407 * for the JavaScript code in %SCRIPT_PATH.
412 <script type=\"text/javascript\">
415 @licstart The following is the entire license notice for the
416 JavaScript code in this tag.
418 Copyright (C) 2012-2013 Free Software Foundation, Inc.
420 The JavaScript code in this tag is free software: you can
421 redistribute it and/or modify it under the terms of the GNU
422 General Public License (GNU GPL) as published by the Free Software
423 Foundation, either version 3 of the License, or (at your option)
424 any later version. The code is distributed WITHOUT ANY WARRANTY;
425 without even the implied warranty of MERCHANTABILITY or FITNESS
426 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
428 As additional permission under GNU GPL version 3 section 7, you
429 may distribute non-source (e.g., minimized or compacted) forms of
430 that code without the copy of the GNU GPL normally required by
431 section 4, provided you include this license notice and a URL
432 through which recipients can access the Corresponding Source.
435 @licend The above is the entire license notice
436 for the JavaScript code in this tag.
439 <!--/*--><![CDATA[/*><!--*/
441 org_html_manager.setup(); // activate after the parameters are set
444 "The template for the export style additions when org-info.js is used.
445 Option settings will replace the %MANAGER-OPTIONS cookie."
446 :group
'org-export-html
448 :package-version
'(Org .
"8.0")
451 (defun org-html-infojs-install-script (exp-plist backend
)
452 "Install script in export options when appropriate.
453 EXP-PLIST is a plist containing export options. BACKEND is the
454 export back-end currently used."
455 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
456 (not org-html-use-infojs
)
457 (and (eq org-html-use-infojs
'when-configured
)
458 (or (not (plist-get exp-plist
:infojs-opt
))
459 (string-match "\\<view:nil\\>"
460 (plist-get exp-plist
:infojs-opt
)))))
461 (let* ((template org-html-infojs-template
)
462 (ptoc (plist-get exp-plist
:with-toc
))
463 (hlevels (plist-get exp-plist
:headline-levels
))
465 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
466 (options (plist-get exp-plist
:infojs-opt
))
467 (table org-html-infojs-opts-table
)
469 (dolist (entry table
)
470 (let* ((opt (car entry
))
472 ;; Compute default values for script option OPT from
473 ;; `org-html-infojs-options' variable.
475 (let ((default (cdr (assq opt org-html-infojs-options
))))
476 (if (and (symbolp default
) (not (memq default
'(t nil
))))
477 (plist-get exp-plist default
)
479 ;; Value set through INFOJS_OPT keyword has precedence
480 ;; over the default one.
481 (val (if (and options
482 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
484 (match-string 1 options
)
488 (replace-regexp-in-string
489 "%SCRIPT_PATH" val template t t
)))
490 (sdepth (when (integerp (read val
))
491 (setq sdepth
(min (read val
) sdepth
))))
492 (tdepth (when (integerp (read val
))
493 (setq tdepth
(min (read val
) tdepth
))))
496 ((or (eq val t
) (equal val
"t")) "1")
497 ((or (eq val nil
) (equal val
"nil")) "0")
499 (t (format "%s" val
))))
500 (push (cons var val
) style
)))))
501 ;; Now we set the depth of the *generated* TOC to SDEPTH,
502 ;; because the toc will actually determine the splitting. How
503 ;; much of the toc will actually be displayed is governed by the
505 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
506 ;; The table of contents should not show more sections than we
508 (setq tdepth
(min tdepth sdepth
))
509 (push (cons "TOC_DEPTH" tdepth
) style
)
510 ;; Build style string.
511 (setq style
(mapconcat
512 (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
516 (when (and style
(> (length style
) 0))
517 (and (string-match "%MANAGER_OPTIONS" template
)
518 (setq style
(replace-match style t t template
))
521 exp-plist
:html-head-extra
522 (concat (or (plist-get exp-plist
:html-head-extra
) "")
525 ;; This script absolutely needs the table of contents, so we
526 ;; change that setting.
527 (unless (plist-get exp-plist
:with-toc
)
528 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
529 ;; Return the modified property list.
534 (defcustom org-html-text-markup-alist
535 '((bold .
"<b>%s</b>")
536 (code .
"<code>%s</code>")
537 (italic .
"<i>%s</i>")
538 (strike-through .
"<del>%s</del>")
539 (underline .
"<span class=\"underline\">%s</span>")
540 (verbatim .
"<code>%s</code>"))
541 "Alist of HTML expressions to convert text markup.
543 The key must be a symbol among `bold', `code', `italic',
544 `strike-through', `underline' and `verbatim'. The value is
545 a formatting string to wrap fontified text with.
547 If no association can be found for a given markup, text will be
549 :group
'org-export-html
550 :type
'(alist :key-type
(symbol :tag
"Markup type")
551 :value-type
(string :tag
"Format string"))
552 :options
'(bold code italic strike-through underline verbatim
))
554 (defcustom org-html-indent nil
555 "Non-nil means to indent the generated HTML.
556 Warning: non-nil may break indentation of source code blocks."
557 :group
'org-export-html
559 :package-version
'(Org .
"8.0")
562 (defcustom org-html-use-unicode-chars nil
563 "Non-nil means to use unicode characters instead of HTML entities."
564 :group
'org-export-html
566 :package-version
'(Org .
"8.0")
571 (defcustom org-html-format-drawer-function nil
572 "Function called to format a drawer in HTML code.
574 The function must accept two parameters:
575 NAME the drawer name, like \"LOGBOOK\"
576 CONTENTS the contents of the drawer.
578 The function should return the string to be exported.
580 For example, the variable could be set to the following function
581 in order to mimic default behaviour:
583 \(defun org-html-format-drawer-default \(name contents\)
584 \"Format a drawer element for HTML export.\"
586 :group
'org-export-html
591 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
592 <h2 class=\"footnotes\">%s: </h2>
593 <div id=\"text-footnotes\">
597 "Format for the footnotes section.
598 Should contain a two instances of %s. The first will be replaced with the
599 language-specific word for \"Footnotes\", the second one will be replaced
600 by the footnotes themselves."
601 :group
'org-export-html
604 (defcustom org-html-footnote-format
"<sup>%s</sup>"
605 "The format for the footnote reference.
606 %s will be replaced by the footnote reference itself."
607 :group
'org-export-html
610 (defcustom org-html-footnote-separator
"<sup>, </sup>"
611 "Text used to separate footnotes."
612 :group
'org-export-html
617 (defcustom org-html-toplevel-hlevel
2
618 "The <H> level for level 1 headings in HTML export.
619 This is also important for the classes that will be wrapped around headlines
620 and outline structure. If this variable is 1, the top-level headlines will
621 be <h1>, and the corresponding classes will be outline-1, section-number-1,
622 and outline-text-1. If this is 2, all of these will get a 2 instead.
623 The default for this variable is 2, because we use <h1> for formatting the
625 :group
'org-export-html
628 (defcustom org-html-format-headline-function nil
629 "Function to format headline text.
631 This function will be called with 5 arguments:
632 TODO the todo keyword (string or nil).
633 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
634 PRIORITY the priority of the headline (integer or nil)
635 TEXT the main headline text (string).
636 TAGS the tags (string or nil).
638 The function result will be used in the section format string."
639 :group
'org-export-html
644 (defcustom org-html-allow-name-attribute-in-anchors t
645 "When nil, do not set \"name\" attribute in anchors.
646 By default, anchors are formatted with both \"id\" and \"name\"
647 attributes, when appropriate."
648 :group
'org-export-html
650 :package-version
'(Org .
"8.0")
655 (defcustom org-html-format-inlinetask-function nil
656 "Function called to format an inlinetask in HTML code.
658 The function must accept six parameters:
659 TODO the todo keyword, as a string
660 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
661 PRIORITY the inlinetask priority, as a string
662 NAME the inlinetask name, as a string.
663 TAGS the inlinetask tags, as a list of strings.
664 CONTENTS the contents of the inlinetask, as a string.
666 The function should return the string to be exported."
667 :group
'org-export-html
672 (defcustom org-html-with-latex org-export-with-latex
673 "Non-nil means process LaTeX math snippets.
675 When set, the exporter will process LaTeX environments and
678 This option can also be set with the +OPTIONS line,
679 e.g. \"tex:mathjax\". Allowed values are:
681 nil Ignore math snippets.
682 `verbatim' Keep everything in verbatim
683 `dvipng' Process the LaTeX fragments to images. This will also
684 include processing of non-math environments.
685 `imagemagick' Convert the LaTeX fragments to pdf files and use
686 imagemagick to convert pdf files to png files.
687 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
689 t Synonym for `mathjax'."
690 :group
'org-export-html
692 :package-version
'(Org .
"8.0")
694 (const :tag
"Do not process math in any way" nil
)
695 (const :tag
"Use dvipng to make images" dvipng
)
696 (const :tag
"Use imagemagick to make images" imagemagick
)
697 (const :tag
"Use MathJax to display math" mathjax
)
698 (const :tag
"Leave math verbatim" verbatim
)))
700 ;;;; Links :: Generic
702 (defcustom org-html-link-org-files-as-html t
703 "Non-nil means make file links to `file.org' point to `file.html'.
704 When `org-mode' is exporting an `org-mode' file to HTML, links to
705 non-html files are directly put into a href tag in HTML.
706 However, links to other Org-mode files (recognized by the
707 extension `.org.) should become links to the corresponding html
708 file, assuming that the linked `org-mode' file will also be
710 When nil, the links still point to the plain `.org' file."
711 :group
'org-export-html
714 ;;;; Links :: Inline images
716 (defcustom org-html-inline-images
'maybe
717 "Non-nil means inline images into exported HTML pages.
718 This is done using an <img> tag. When nil, an anchor with href is used to
719 link to the image. If this option is `maybe', then images in links with
720 an empty description will be inlined, while images with a description will
722 :group
'org-export-html
723 :type
'(choice (const :tag
"Never" nil
)
724 (const :tag
"Always" t
)
725 (const :tag
"When there is no description" maybe
)))
727 (defcustom org-html-inline-image-rules
728 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
729 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
730 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
731 "Rules characterizing image files that can be inlined into HTML.
732 A rule consists in an association whose key is the type of link
733 to consider, and value is a regexp that will be matched against
735 :group
'org-export-html
737 :package-version
'(Org .
"8.0")
738 :type
'(alist :key-type
(string :tag
"Type")
739 :value-type
(regexp :tag
"Path")))
743 (defcustom org-html-protect-char-alist
747 "Alist of characters to be converted by `org-html-protect'."
748 :group
'org-export-html
749 :type
'(repeat (cons (string :tag
"Character")
750 (string :tag
"HTML equivalent"))))
754 (defcustom org-html-htmlize-output-type
'inline-css
755 "Output type to be used by htmlize when formatting code snippets.
756 Choices are `css', to export the CSS selectors only, or `inline-css', to
757 export the CSS attribute values inline in the HTML. We use as default
758 `inline-css', in order to make the resulting HTML self-containing.
760 However, this will fail when using Emacs in batch mode for export, because
761 then no rich font definitions are in place. It will also not be good if
762 people with different Emacs setup contribute HTML files to a website,
763 because the fonts will represent the individual setups. In these cases,
764 it is much better to let Org/Htmlize assign classes only, and to use
765 a style file to define the look of these classes.
766 To get a start for your css file, start Emacs session and make sure that
767 all the faces you are interested in are defined, for example by loading files
768 in all modes you want. Then, use the command
769 \\[org-html-htmlize-generate-css] to extract class definitions."
770 :group
'org-export-html
771 :type
'(choice (const css
) (const inline-css
)))
773 (defcustom org-html-htmlize-font-prefix
"org-"
774 "The prefix for CSS class names for htmlize font specifications."
775 :group
'org-export-html
780 (defcustom org-html-table-default-attributes
781 '(:border
"2" :cellspacing
"0" :cellpadding
"6" :rules
"groups" :frame
"hsides")
782 "Default attributes and values which will be used in table tags.
783 This is a plist where attributes are symbols, starting with
784 colons, and values are strings.
786 When exporting to HTML5, these values will be disregarded."
787 :group
'org-export-html
789 :package-version
'(Org .
"8.0")
790 :type
'(plist :key-type
(symbol :tag
"Property")
791 :value-type
(string :tag
"Value")))
793 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
794 "The opening tag for table header fields.
795 This is customizable so that alignment options can be specified.
796 The first %s will be filled with the scope of the field, either row or col.
797 The second %s will be replaced by a style entry to align the field.
798 See also the variable `org-html-table-use-header-tags-for-first-column'.
799 See also the variable `org-html-table-align-individual-fields'."
800 :group
'org-export-html
801 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
803 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
804 "The opening tag for table data fields.
805 This is customizable so that alignment options can be specified.
806 The first %s will be filled with the scope of the field, either row or col.
807 The second %s will be replaced by a style entry to align the field.
808 See also the variable `org-html-table-align-individual-fields'."
809 :group
'org-export-html
810 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
812 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
813 "The opening and ending tags for table rows.
814 This is customizable so that alignment options can be specified.
815 Instead of strings, these can be Lisp forms that will be
816 evaluated for each row in order to construct the table row tags.
818 During evaluation, these variables will be dynamically bound so that
821 `row-number': row number (0 is the first row)
822 `rowgroup-number': group number of current row
823 `start-rowgroup-p': non-nil means the row starts a group
824 `end-rowgroup-p': non-nil means the row ends a group
825 `top-row-p': non-nil means this is the top row
826 `bottom-row-p': non-nil means this is the bottom row
830 \(setq org-html-table-row-tags
831 (cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
832 (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
833 (t (if (= (mod row-number 2) 1)
834 \"<tr class=\\\"tr-odd\\\">\"
835 \"<tr class=\\\"tr-even\\\">\")))
838 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
839 and the bottom row, and otherwise alternate between \"tr-odd\" and
840 \"tr-even\" for odd and even rows."
841 :group
'org-export-html
843 (choice :tag
"Opening tag"
844 (string :tag
"Specify")
846 (choice :tag
"Closing tag"
847 (string :tag
"Specify")
850 (defcustom org-html-table-align-individual-fields t
851 "Non-nil means attach style attributes for alignment to each table field.
852 When nil, alignment will only be specified in the column tags, but this
853 is ignored by some browsers (like Firefox, Safari). Opera does it right
855 :group
'org-export-html
858 (defcustom org-html-table-use-header-tags-for-first-column nil
859 "Non-nil means format column one in tables with header tags.
860 When nil, also column one will use data tags."
861 :group
'org-export-html
864 (defcustom org-html-table-caption-above t
865 "When non-nil, place caption string at the beginning of the table.
866 Otherwise, place it near the end."
867 :group
'org-export-html
872 (defcustom org-html-tag-class-prefix
""
873 "Prefix to class names for TODO keywords.
874 Each tag gets a class given by the tag itself, with this prefix.
875 The default prefix is empty because it is nice to just use the keyword
876 as a class name. But if you get into conflicts with other, existing
877 CSS classes, then this prefix can be very useful."
878 :group
'org-export-html
881 ;;;; Template :: Generic
883 (defcustom org-html-extension
"html"
884 "The extension for exported HTML files."
885 :group
'org-export-html
888 (defcustom org-html-xml-declaration
889 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
890 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
891 "The extension for exported HTML files.
892 %s will be replaced with the charset of the exported file.
893 This may be a string, or an alist with export extensions
894 and corresponding declarations.
896 This declaration only applies when exporting to XHTML."
897 :group
'org-export-html
899 (string :tag
"Single declaration")
900 (repeat :tag
"Dependent on extension"
901 (cons (string :tag
"Extension")
902 (string :tag
"Declaration")))))
904 (defcustom org-html-coding-system
'utf-8
905 "Coding system for HTML export.
906 Use utf-8 as the default value."
907 :group
'org-export-html
909 :package-version
'(Org .
"8.0")
910 :type
'coding-system
)
912 (defcustom org-html-doctype
"xhtml-strict"
913 "Document type definition to use for exported HTML files.
914 Can be set with the in-buffer HTML_DOCTYPE property or for
915 publishing, with :html-doctype."
916 :group
'org-export-html
918 :package-version
'(Org .
"8.0")
921 (defcustom org-html-html5-fancy nil
922 "Non-nil means using new HTML5 elements.
923 This variable is ignored for anything other than HTML5 export.
925 For compatibility with Internet Explorer, it's probably a good
926 idea to download some form of the html5shiv (for instance
927 https://code.google.com/p/html5shiv/) and add it to your
928 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
929 versions 8 and below."
930 :group
'org-export-html
932 :package-version
'(Org .
"8.0")
935 (defcustom org-html-container-element
"div"
936 "HTML element to use for wrapping top level sections.
937 Can be set with the in-buffer HTML_CONTAINER property or for
938 publishing, with :html-container.
940 Note that changing the default will prevent you from using
941 org-info.js for your website."
942 :group
'org-export-html
944 :package-version
'(Org .
"8.0")
947 (defcustom org-html-divs
948 '((preamble "div" "preamble")
949 (content "div" "content")
950 (postamble "div" "postamble"))
951 "Alist of the three section elements for HTML export.
952 The car of each entry is one of 'preamble, 'content or 'postamble.
953 The cdrs of each entry are the ELEMENT_TYPE and ID for each
954 section of the exported document.
956 Note that changing the default will prevent you from using
957 org-info.js for your website."
958 :group
'org-export-html
960 :package-version
'(Org .
"8.0")
961 :type
'(list :greedy t
962 (list :tag
"Preamble"
963 (const :format
"" preamble
)
964 (string :tag
"element") (string :tag
" id"))
966 (const :format
"" content
)
967 (string :tag
"element") (string :tag
" id"))
968 (list :tag
"Postamble" (const :format
"" postamble
)
969 (string :tag
" id") (string :tag
"element"))))
971 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
972 "Format used for timestamps in preamble, postamble and metadata.
973 See `format-time-string' for more information on its components."
974 :group
'org-export-html
976 :package-version
'(Org .
"8.0")
979 ;;;; Template :: Mathjax
981 (defcustom org-html-mathjax-options
982 '((path "http://orgmode.org/mathjax/MathJax.js")
987 "Options for MathJax setup.
989 path The path where to find MathJax
990 scale Scaling for the HTML-CSS backend, usually between 100 and 133
991 align How to align display math: left, center, or right
992 indent If align is not center, how far from the left/right side?
993 mathml Should a MathML player be used if available?
994 This is faster and reduces bandwidth use, but currently
995 sometimes has lower spacing quality. Therefore, the default is
996 nil. When browsers get better, this switch can be flipped.
998 You can also customize this for each buffer, using something like
1000 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
1001 :group
'org-export-html
1002 :type
'(list :greedy t
1003 (list :tag
"path (the path from where to load MathJax.js)"
1004 (const :format
" " path
) (string))
1005 (list :tag
"scale (scaling for the displayed math)"
1006 (const :format
" " scale
) (string))
1007 (list :tag
"align (alignment of displayed equations)"
1008 (const :format
" " align
) (string))
1009 (list :tag
"indent (indentation with left or right alignment)"
1010 (const :format
" " indent
) (string))
1011 (list :tag
"mathml (should MathML display be used is possible)"
1012 (const :format
" " mathml
) (boolean))))
1014 (defcustom org-html-mathjax-template
1015 "<script type=\"text/javascript\" src=\"%PATH\"></script>
1016 <script type=\"text/javascript\">
1017 <!--/*--><![CDATA[/*><!--*/
1018 MathJax.Hub.Config({
1019 // Only one of the two following lines, depending on user settings
1020 // First allows browser-native MathML display, second forces HTML/CSS
1021 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
1022 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
1023 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
1024 \"TeX/noUndefined.js\"],
1026 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
1027 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
1028 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
1029 ignoreClass: \"tex2jax_ignore\",
1030 processEscapes: false,
1031 processEnvironments: true,
1034 showProcessingMessages: true,
1035 displayAlign: \"%ALIGN\",
1036 displayIndent: \"%INDENT\",
1040 availableFonts: [\"STIX\",\"TeX\"],
1041 preferredFont: \"TeX\",
1057 "The MathJax setup for XHTML files."
1058 :group
'org-export-html
1061 ;;;; Template :: Postamble
1063 (defcustom org-html-postamble
'auto
1064 "Non-nil means insert a postamble in HTML export.
1066 When set to 'auto, check against the
1067 `org-export-with-author/email/creator/date' variables to set the
1068 content of the postamble. When set to a string, use this string
1069 as the postamble. When t, insert a string as defined by the
1070 formatting string in `org-html-postamble-format'.
1072 When set to a function, apply this function and insert the
1073 returned string. The function takes the property list of export
1074 options as its only argument.
1076 Setting :html-postamble in publishing projects will take
1077 precedence over this variable."
1078 :group
'org-export-html
1079 :type
'(choice (const :tag
"No postamble" nil
)
1080 (const :tag
"Auto postamble" auto
)
1081 (const :tag
"Default formatting string" t
)
1082 (string :tag
"Custom formatting string")
1083 (function :tag
"Function (must return a string)")))
1085 (defcustom org-html-postamble-format
1086 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1087 <p class=\"date\">Date: %d</p>
1088 <p class=\"creator\">%c</p>
1089 <p class=\"validation\">%v</p>"))
1090 "Alist of languages and format strings for the HTML postamble.
1092 The first element of each list is the language code, as used for
1093 the LANGUAGE keyword. See `org-export-default-language'.
1095 The second element of each list is a format string to format the
1096 postamble itself. This format string can contain these elements:
1098 %t stands for the title.
1099 %a stands for the author's name.
1100 %e stands for the author's email.
1101 %d stands for the date.
1102 %c will be replaced by `org-html-creator-string'.
1103 %v will be replaced by `org-html-validation-link'.
1104 %T will be replaced by the export time.
1105 %C will be replaced by the last modification time.
1107 If you need to use a \"%\" character, you need to escape it
1109 :group
'org-export-html
1111 (list (string :tag
"Language")
1112 (string :tag
"Format string"))))
1114 (defcustom org-html-validation-link
1115 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1116 "Link to HTML validation service."
1117 :group
'org-export-html
1120 (defcustom org-html-creator-string
1121 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1123 (if (fboundp 'org-version
) (org-version) "unknown version"))
1124 "Information about the creator of the HTML document.
1125 This option can also be set on with the CREATOR keyword."
1126 :group
'org-export-html
1127 :type
'(string :tag
"Creator string"))
1129 ;;;; Template :: Preamble
1131 (defcustom org-html-preamble t
1132 "Non-nil means insert a preamble in HTML export.
1134 When t, insert a string as defined by the formatting string in
1135 `org-html-preamble-format'. When set to a string, use this
1136 formatting string instead (see `org-html-postamble-format' for an
1137 example of such a formatting string).
1139 When set to a function, apply this function and insert the
1140 returned string. The function takes the property list of export
1141 options as its only argument.
1143 Setting :html-preamble in publishing projects will take
1144 precedence over this variable."
1145 :group
'org-export-html
1146 :type
'(choice (const :tag
"No preamble" nil
)
1147 (const :tag
"Default preamble" t
)
1148 (string :tag
"Custom formatting string")
1149 (function :tag
"Function (must return a string)")))
1151 (defcustom org-html-preamble-format
'(("en" ""))
1152 "Alist of languages and format strings for the HTML preamble.
1154 The first element of each list is the language code, as used for
1155 the LANGUAGE keyword. See `org-export-default-language'.
1157 The second element of each list is a format string to format the
1158 preamble itself. This format string can contain these elements:
1160 %t stands for the title.
1161 %a stands for the author's name.
1162 %e stands for the author's email.
1163 %d stands for the date.
1164 %c will be replaced by `org-html-creator-string'.
1165 %v will be replaced by `org-html-validation-link'.
1166 %T will be replaced by the export time.
1167 %C will be replaced by the last modification time.
1169 If you need to use a \"%\" character, you need to escape it
1172 See the default value of `org-html-postamble-format' for an
1174 :group
'org-export-html
1176 (list (string :tag
"Language")
1177 (string :tag
"Format string"))))
1179 (defcustom org-html-link-up
""
1180 "Where should the \"UP\" link of exported HTML pages lead?"
1181 :group
'org-export-html
1182 :type
'(string :tag
"File or URL"))
1184 (defcustom org-html-link-home
""
1185 "Where should the \"HOME\" link of exported HTML pages lead?"
1186 :group
'org-export-html
1187 :type
'(string :tag
"File or URL"))
1189 (defcustom org-html-home
/up-format
1190 "<div id=\"org-div-home-and-up\">
1191 <a accesskey=\"h\" href=\"%s\"> UP </a>
1193 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1195 "Snippet used to insert the HOME and UP links.
1196 This is a format string, the first %s will receive the UP link,
1197 the second the HOME link. If both `org-html-link-up' and
1198 `org-html-link-home' are empty, the entire snippet will be
1200 :group
'org-export-html
1203 ;;;; Template :: Scripts
1205 (define-obsolete-variable-alias
1206 'org-html-style-include-scripts
'org-html-head-include-scripts
"24.4")
1207 (defcustom org-html-head-include-scripts t
1208 "Non-nil means include the JavaScript snippets in exported HTML files.
1209 The actual script is defined in `org-html-scripts' and should
1211 :group
'org-export-html
1213 :package-version
'(Org .
"8.0")
1216 ;;;; Template :: Styles
1218 (define-obsolete-variable-alias
1219 'org-html-style-include-default
'org-html-head-include-default-style
"24.4")
1220 (defcustom org-html-head-include-default-style t
1221 "Non-nil means include the default style in exported HTML files.
1222 The actual style is defined in `org-html-style-default' and
1223 should not be modified. Use `org-html-head' to use your own
1225 :group
'org-export-html
1227 :package-version
'(Org .
"8.0")
1230 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1232 (define-obsolete-variable-alias 'org-html-style
'org-html-head
"24.4")
1233 (defcustom org-html-head
""
1234 "Org-wide head definitions for exported HTML files.
1236 This variable can contain the full HTML structure to provide a
1237 style, including the surrounding HTML tags. You can consider
1238 including definitions for the following classes: title, todo,
1239 done, timestamp, timestamp-kwd, tag, target.
1241 For example, a valid value would be:
1243 <style type=\"text/css\">
1245 p { font-weight: normal; color: gray; }
1246 h1 { color: black; }
1247 .title { text-align: center; }
1248 .todo, .timestamp-kwd { color: red; }
1249 .done { color: green; }
1253 If you want to refer to an external style, use something like
1255 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1257 As the value of this option simply gets inserted into the HTML
1258 <head> header, you can use it to add any arbitrary text to the
1261 You can set this on a per-file basis using #+HTML_HEAD:,
1262 or for publication projects using the :html-head property."
1263 :group
'org-export-html
1265 :package-version
'(Org .
"8.0")
1268 (put 'org-html-head
'safe-local-variable
'stringp
)
1270 (defcustom org-html-head-extra
""
1271 "More head information to add in the HTML output.
1273 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1274 or for publication projects using the :html-head-extra property."
1275 :group
'org-export-html
1277 :package-version
'(Org .
"8.0")
1280 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1284 (defcustom org-html-todo-kwd-class-prefix
""
1285 "Prefix to class names for TODO keywords.
1286 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1287 The default prefix is empty because it is nice to just use the keyword
1288 as a class name. But if you get into conflicts with other, existing
1289 CSS classes, then this prefix can be very useful."
1290 :group
'org-export-html
1294 ;;; Internal Functions
1296 (defun org-html-xhtml-p (info)
1297 (let ((dt (downcase (plist-get info
:html-doctype
))))
1298 (string-match-p "xhtml" dt
)))
1300 (defun org-html-html5-p (info)
1301 (let ((dt (downcase (plist-get info
:html-doctype
))))
1302 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1304 (defun org-html-close-tag (tag attr info
)
1305 (concat "<" tag
" " attr
1306 (if (org-html-xhtml-p info
) " />" ">")))
1308 (defun org-html-doctype (info)
1309 "Return correct html doctype tag from `org-html-doctype-alist',
1310 or the literal value of :html-doctype from INFO if :html-doctype
1311 is not found in the alist.
1312 INFO is a plist used as a communication channel."
1313 (let ((dt (plist-get info
:html-doctype
)))
1314 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1316 (defun org-html--make-attribute-string (attributes)
1317 "Return a list of attributes, as a string.
1318 ATTRIBUTES is a plist where values are either strings or nil. An
1319 attributes with a nil value will be omitted from the result."
1321 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1322 (cond ((null item
) (pop output
))
1323 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1324 (t (let ((key (car output
))
1325 (value (replace-regexp-in-string
1326 "\"" """ (org-html-encode-plain-text item
))))
1327 (setcar output
(format "%s=\"%s\"" key value
))))))))
1329 (defun org-html-format-inline-image (src info
&optional
1330 caption label attr standalone-p
)
1331 "Format an inline image from SRC.
1332 CAPTION, LABEL and ATTR are optional arguments providing the
1333 caption, the label and the attribute of the image.
1334 When STANDALONE-P is t, wrap the <img.../> into a <div>...</div>."
1335 (let* ((id (if (not label
) ""
1336 (format " id=\"%s\"" (org-export-solidify-link-text label
))))
1338 (format " src=\"%s\"" src
)
1340 ((string-match "\\<alt=" (or attr
"")) "")
1341 ((string-match "^ltxpng/" src
)
1342 (format " alt=\"%s\""
1343 (org-html-encode-plain-text
1344 (org-find-text-property-in-string
1345 'org-latex-src src
))))
1346 (t (format " alt=\"%s\""
1347 (file-name-nondirectory src
))))))
1348 (html5-fancy (and (org-html-html5-p info
)
1349 (plist-get info
:html-html5-fancy
))))
1352 (let ((img (org-html-close-tag "img" attr info
)))
1353 (format (if html5-fancy
1354 "\n<figure%s>%s%s\n</figure>"
1355 "\n<div%s class=\"figure\">%s%s\n</div>")
1356 id
(format "\n<p>%s</p>" img
)
1357 (if (and caption
(not (string= caption
"")))
1358 (format (if html5-fancy
1359 "\n<figcaption>%s</figcaption>"
1360 "\n<p>%s</p>") caption
) ""))))
1361 (t (org-html-close-tag "img" (concat attr id
) info
)))))
1363 (defun org-html--textarea-block (element)
1364 "Transcode ELEMENT into a textarea block.
1365 ELEMENT is either a src block or an example block."
1366 (let* ((code (car (org-export-unravel-code element
)))
1367 (attr (org-export-read-attribute :attr_html element
)))
1368 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1369 (or (plist-get attr
:width
) 80)
1370 (or (plist-get attr
:height
) (org-count-lines code
))
1375 (defun org-html-htmlize-region-for-paste (beg end
)
1376 "Convert the region between BEG and END to HTML, using htmlize.el.
1377 This is much like `htmlize-region-for-paste', only that it uses
1378 the settings define in the org-... variables."
1379 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1380 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1381 (htmlbuf (htmlize-region beg end
)))
1383 (with-current-buffer htmlbuf
1384 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1385 (plist-get htmlize-buffer-places
'content-end
)))
1386 (kill-buffer htmlbuf
))))
1389 (defun org-html-htmlize-generate-css ()
1390 "Create the CSS for all font definitions in the current Emacs session.
1391 Use this to create face definitions in your CSS style file that can then
1392 be used by code snippets transformed by htmlize.
1393 This command just produces a buffer that contains class definitions for all
1394 faces used in the current Emacs session. You can copy and paste the ones you
1395 need into your CSS file.
1397 If you then set `org-html-htmlize-output-type' to `css', calls
1398 to the function `org-html-htmlize-region-for-paste' will
1399 produce code that uses these same face definitions."
1402 (and (get-buffer "*html*") (kill-buffer "*html*"))
1404 (let ((fl (face-list))
1405 (htmlize-css-name-prefix "org-")
1406 (htmlize-output-type 'css
)
1408 (while (setq f
(pop fl
)
1409 i
(and f
(face-attribute f
:inherit
)))
1410 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1411 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1412 (htmlize-region (point-min) (point-max))))
1413 (org-pop-to-buffer-same-window "*html*")
1414 (goto-char (point-min))
1415 (if (re-search-forward "<style" nil t
)
1416 (delete-region (point-min) (match-beginning 0)))
1417 (if (re-search-forward "</style>" nil t
)
1418 (delete-region (1+ (match-end 0)) (point-max)))
1419 (beginning-of-line 1)
1420 (if (looking-at " +") (replace-match ""))
1421 (goto-char (point-min)))
1423 (defun org-html--make-string (n string
)
1424 "Build a string by concatenating N times STRING."
1425 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1427 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1428 "Turn todo keyword KWD into a valid class name.
1429 Replaces invalid characters with \"_\"."
1431 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1432 (setq kwd
(replace-match "_" t t kwd
))))
1435 (defun org-html-format-footnote-reference (n def refcnt
)
1436 "Format footnote reference N with definition DEF into HTML."
1437 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1438 (format org-html-footnote-format
1439 (let* ((id (format "fnr.%s%s" n extra
))
1440 (href (format " href=\"#fn.%s\"" n
))
1441 (attributes (concat " class=\"footref\"" href
)))
1442 (org-html--anchor id n attributes
)))))
1444 (defun org-html-format-footnotes-section (section-name definitions
)
1445 "Format footnotes section SECTION-NAME."
1446 (if (not definitions
) ""
1447 (format org-html-footnotes-section section-name definitions
)))
1449 (defun org-html-format-footnote-definition (fn)
1450 "Format the footnote definition FN."
1451 (let ((n (car fn
)) (def (cdr fn
)))
1453 "<div class=\"footdef\">%s %s</div>\n"
1454 (format org-html-footnote-format
1455 (let* ((id (format "fn.%s" n
))
1456 (href (format " href=\"#fnr.%s\"" n
))
1457 (attributes (concat " class=\"footnum\"" href
)))
1458 (org-html--anchor id n attributes
)))
1461 (defun org-html-footnote-section (info)
1462 "Format the footnote section.
1463 INFO is a plist used as a communication channel."
1464 (let* ((fn-alist (org-export-collect-footnote-definitions
1465 (plist-get info
:parse-tree
) info
))
1467 (loop for
(n type raw
) in fn-alist collect
1468 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1469 (org-trim (org-export-data raw info
))
1471 (org-trim (org-export-data raw info
))))))))
1473 (org-html-format-footnotes-section
1474 (org-html--translate "Footnotes" info
)
1477 (mapconcat 'org-html-format-footnote-definition fn-alist
"\n"))))))
1482 (defun org-html--build-meta-info (info)
1483 "Return meta tags for exported document.
1484 INFO is a plist used as a communication channel."
1485 (let ((protect-string
1487 (replace-regexp-in-string
1488 "\"" """ (org-html-encode-plain-text str
))))
1489 (title (org-export-data (plist-get info
:title
) info
))
1490 (author (and (plist-get info
:with-author
)
1491 (let ((auth (plist-get info
:author
)))
1493 ;; Return raw Org syntax, skipping non
1494 ;; exportable objects.
1495 (org-element-interpret-data
1496 (org-element-map auth
1497 (cons 'plain-text org-element-all-objects
)
1498 'identity info
))))))
1499 (description (plist-get info
:description
))
1500 (keywords (plist-get info
:keywords
))
1501 (charset (or (and org-html-coding-system
1502 (fboundp 'coding-system-get
)
1503 (coding-system-get org-html-coding-system
1507 (format "<title>%s</title>\n" title
)
1508 (when (plist-get info
:time-stamp-file
)
1510 (concat "<!-- " org-html-metadata-timestamp-format
" -->\n")))
1512 (if (org-html-html5-p info
)
1513 (org-html-close-tag "meta" " charset=\"%s\"" info
)
1515 "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1518 (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info
)
1520 (and (org-string-nw-p author
)
1521 (org-html-close-tag "meta"
1522 (format " name=\"author\" content=\"%s\""
1523 (funcall protect-string author
))
1526 (and (org-string-nw-p description
)
1527 (org-html-close-tag "meta"
1528 (format " name=\"description\" content=\"%s\"\n"
1529 (funcall protect-string description
))
1532 (and (org-string-nw-p keywords
)
1533 (org-html-close-tag "meta"
1534 (format " name=\"keywords\" content=\"%s\""
1535 (funcall protect-string keywords
))
1539 (defun org-html--build-head (info)
1540 "Return information for the <head>..</head> of the HTML output.
1541 INFO is a plist used as a communication channel."
1542 (org-element-normalize-string
1544 (when (plist-get info
:html-head-include-default-style
)
1545 (org-element-normalize-string org-html-style-default
))
1546 (org-element-normalize-string (plist-get info
:html-head
))
1547 (org-element-normalize-string (plist-get info
:html-head-extra
))
1548 (when (and (plist-get info
:html-htmlized-css-url
)
1549 (eq org-html-htmlize-output-type
'css
))
1550 (org-html-close-tag "link"
1551 (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1552 (plist-get info
:html-htmlized-css-url
))
1554 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1556 (defun org-html--build-mathjax-config (info)
1557 "Insert the user setup into the mathjax template.
1558 INFO is a plist used as a communication channel."
1559 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1560 (org-element-map (plist-get info
:parse-tree
)
1561 '(latex-fragment latex-environment
) 'identity info t
))
1562 (let ((template org-html-mathjax-template
)
1563 (options org-html-mathjax-options
)
1564 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1565 name val
(yes " ") (no "// ") x
)
1568 (setq name
(car e
) val
(nth 1 e
))
1569 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1570 (setq val
(car (read-from-string
1571 (substring in-buffer
(match-end 0))))))
1572 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1573 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1574 (setq template
(replace-match val t t template
))))
1576 (setq val
(nth 1 (assq 'mathml options
)))
1577 (if (string-match (concat "\\<mathml:") in-buffer
)
1578 (setq val
(car (read-from-string
1579 (substring in-buffer
(match-end 0))))))
1580 ;; Exchange prefixes depending on mathml setting.
1581 (if (not val
) (setq x yes yes no no x
))
1582 ;; Replace cookies to turn on or off the config/jax lines.
1583 (if (string-match ":MMLYES:" template
)
1584 (setq template
(replace-match yes t t template
)))
1585 (if (string-match ":MMLNO:" template
)
1586 (setq template
(replace-match no t t template
)))
1587 ;; Return the modified template.
1588 (org-element-normalize-string template
))))
1590 (defun org-html-format-spec (info)
1591 "Return format specification for elements that can be
1592 used in the preamble or postamble."
1593 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1594 (?d .
,(org-export-data (org-export-get-date info
) info
))
1595 (?T .
,(format-time-string org-html-metadata-timestamp-format
))
1596 (?a .
,(org-export-data (plist-get info
:author
) info
))
1599 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1600 (split-string (plist-get info
:email
) ",+ *")
1602 (?c .
,(plist-get info
:creator
))
1603 (?C .
,(let ((file (plist-get info
:input-file
)))
1604 (format-time-string org-html-metadata-timestamp-format
1605 (if file
(nth 5 (file-attributes file
))
1607 (?v .
,(or org-html-validation-link
""))))
1609 (defun org-html--build-pre/postamble
(type info
)
1610 "Return document preamble or postamble as a string, or nil.
1611 TYPE is either 'preamble or 'postamble, INFO is a plist used as a
1612 communication channel."
1613 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1614 (spec (org-html-format-spec info
)))
1616 (let ((section-contents
1617 (if (functionp section
) (funcall section info
)
1619 ((stringp section
) (format-spec section spec
))
1621 (let ((date (cdr (assq ?d spec
)))
1622 (author (cdr (assq ?a spec
)))
1623 (email (cdr (assq ?e spec
)))
1624 (creator (cdr (assq ?c spec
)))
1625 (timestamp (cdr (assq ?T spec
)))
1626 (validation-link (cdr (assq ?v spec
))))
1628 (when (and (plist-get info
:with-date
)
1629 (org-string-nw-p date
))
1630 (format "<p class=\"date\">%s: %s</p>\n"
1631 (org-html--translate "Date" info
)
1633 (when (and (plist-get info
:with-author
)
1634 (org-string-nw-p author
))
1635 (format "<p class=\"author\">%s: %s</p>\n"
1636 (org-html--translate "Author" info
)
1638 (when (and (plist-get info
:with-email
)
1639 (org-string-nw-p email
))
1640 (format "<p class=\"email\">%s: %s</p>\n"
1641 (org-html--translate "Email" info
)
1643 (when (plist-get info
:time-stamp-file
)
1645 "<p class=\"date\">%s: %s</p>\n"
1646 (org-html--translate "Created" info
)
1647 (format-time-string org-html-metadata-timestamp-format
)))
1648 (when (plist-get info
:with-creator
)
1649 (format "<p class=\"creator\">%s</p>\n" creator
))
1650 (format "<p class=\"validation\">%s</p>\n"
1654 (plist-get info
:language
)
1656 (format "org-html-%s-format" type
)))))
1661 (intern (format "org-html-%s-format" type
))))))
1663 (when (org-string-nw-p section-contents
)
1665 (format "<%s id=\"%s\" class=\"%s\">\n"
1666 (nth 1 (assq type org-html-divs
))
1667 (nth 2 (assq type org-html-divs
))
1668 org-html--pre
/postamble-class
)
1669 (org-element-normalize-string section-contents
)
1670 (format "</%s>\n" (nth 1 (assq type org-html-divs
)))))))))
1672 (defun org-html-inner-template (contents info
)
1673 "Return body of document string after HTML conversion.
1674 CONTENTS is the transcoded contents string. INFO is a plist
1675 holding export options."
1677 ;; Table of contents.
1678 (let ((depth (plist-get info
:with-toc
)))
1679 (when depth
(org-html-toc depth info
)))
1680 ;; Document contents.
1682 ;; Footnotes section.
1683 (org-html-footnote-section info
)))
1685 (defun org-html-template (contents info
)
1686 "Return complete document string after HTML conversion.
1687 CONTENTS is the transcoded contents string. INFO is a plist
1688 holding export options."
1690 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1691 (let ((decl (or (and (stringp org-html-xml-declaration
)
1692 org-html-xml-declaration
)
1693 (cdr (assoc (plist-get info
:html-extension
)
1694 org-html-xml-declaration
))
1695 (cdr (assoc "html" org-html-xml-declaration
))
1698 (when (not (or (eq nil decl
) (string= "" decl
)))
1701 (or (and org-html-coding-system
1702 (fboundp 'coding-system-get
)
1703 (coding-system-get org-html-coding-system
'mime-charset
))
1705 (org-html-doctype info
)
1708 (when (org-html-xhtml-p info
)
1710 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1711 (plist-get info
:language
) (plist-get info
:language
)))
1714 (org-html--build-meta-info info
)
1715 (org-html--build-head info
)
1716 (org-html--build-mathjax-config info
)
1719 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1720 (link-home (org-trim (plist-get info
:html-link-home
))))
1721 (unless (and (string= link-up
"") (string= link-home
""))
1722 (format org-html-home
/up-format
1723 (or link-up link-home
)
1724 (or link-home link-up
))))
1726 (org-html--build-pre/postamble
'preamble info
)
1727 ;; Document contents.
1728 (format "<%s id=\"%s\">\n"
1729 (nth 1 (assq 'content org-html-divs
))
1730 (nth 2 (assq 'content org-html-divs
)))
1732 (let ((title (plist-get info
:title
)))
1733 (format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title
"") info
)))
1736 (nth 1 (assq 'content org-html-divs
)))
1738 (org-html--build-pre/postamble
'postamble info
)
1739 ;; Closing document.
1740 "</body>\n</html>"))
1742 (defun org-html--translate (s info
)
1743 "Translate string S according to specified language.
1744 INFO is a plist used as a communication channel."
1745 (org-export-translate s
:html info
))
1749 (defun org-html--anchor (&optional id desc attributes
)
1750 "Format a HTML anchor."
1751 (let* ((name (and org-html-allow-name-attribute-in-anchors id
))
1752 (attributes (concat (and id
(format " id=\"%s\"" id
))
1753 (and name
(format " name=\"%s\"" name
))
1755 (format "<a%s>%s</a>" attributes
(or desc
""))))
1759 (defun org-html--todo (todo)
1760 "Format TODO keywords into HTML."
1762 (format "<span class=\"%s %s%s\">%s</span>"
1763 (if (member todo org-done-keywords
) "done" "todo")
1764 org-html-todo-kwd-class-prefix
(org-html-fix-class-name todo
)
1769 (defun org-html--tags (tags)
1770 "Format TAGS into HTML."
1772 (format "<span class=\"tag\">%s</span>"
1775 (format "<span class=\"%s\">%s</span>"
1776 (concat org-html-tag-class-prefix
1777 (org-html-fix-class-name tag
))
1783 (defun* org-html-format-headline
1784 (todo todo-type priority text tags
1785 &key level section-number headline-label
&allow-other-keys
)
1786 "Format a headline in HTML."
1787 (let ((section-number
1788 (when section-number
1789 (format "<span class=\"section-number-%d\">%s</span> "
1790 level section-number
)))
1791 (todo (org-html--todo todo
))
1792 (tags (org-html--tags tags
)))
1793 (concat section-number todo
(and todo
" ") text
1794 (and tags
"   ") tags
)))
1798 (defun org-html-fontify-code (code lang
)
1799 "Color CODE with htmlize library.
1800 CODE is a string representing the source code to colorize. LANG
1801 is the language used for CODE, as a string, or nil."
1804 ;; Case 1: No lang. Possibly an example block.
1806 ;; Simple transcoding.
1807 (org-html-encode-plain-text code
))
1808 ;; Case 2: No htmlize or an inferior version of htmlize
1809 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1811 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1812 ;; Simple transcoding.
1813 (org-html-encode-plain-text code
))
1816 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1817 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1819 ;; Case 1: Language is not associated with any Emacs mode
1820 ((not (functionp lang-mode
))
1821 ;; Simple transcoding.
1822 (org-html-encode-plain-text code
))
1823 ;; Case 2: Default. Fontify code.
1826 (setq code
(with-temp-buffer
1827 ;; Switch to language-specific mode.
1831 (font-lock-fontify-buffer)
1832 ;; Remove formatting on newline characters.
1834 (let ((beg (point-min))
1837 (while (progn (end-of-line) (< (point) end
))
1838 (put-text-property (point) (1+ (point)) 'face nil
)
1841 (set-buffer-modified-p nil
)
1843 (org-html-htmlize-region-for-paste
1844 (point-min) (point-max))))
1845 ;; Strip any enclosing <pre></pre> tags.
1846 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
1847 (end (and beg
(string-match "</pre>\\'" code
))))
1848 (if (and beg end
) (substring code beg end
) code
)))))))))
1850 (defun org-html-do-format-code
1851 (code &optional lang refs retain-labels num-start
)
1852 "Format CODE string as source code.
1853 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1854 respectively, the language of the source code, as a string, an
1855 alist between line numbers and references (as returned by
1856 `org-export-unravel-code'), a boolean specifying if labels should
1857 appear in the source code, and the number associated to the first
1859 (let* ((code-lines (org-split-string code
"\n"))
1860 (code-length (length code-lines
))
1864 (length (number-to-string (+ code-length num-start
))))))
1865 (code (org-html-fontify-code code lang
)))
1866 (org-export-format-code
1868 (lambda (loc line-num ref
)
1871 ;; Add line number, if needed.
1873 (format "<span class=\"linenr\">%s</span>"
1874 (format num-fmt line-num
)))
1875 ;; Transcoded src line.
1877 ;; Add label, if needed.
1878 (when (and ref retain-labels
) (format " (%s)" ref
))))
1879 ;; Mark transcoded line as an anchor, if needed.
1881 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1885 (defun org-html-format-code (element info
)
1886 "Format contents of ELEMENT as source code.
1887 ELEMENT is either an example block or a src block. INFO is
1888 a plist used as a communication channel."
1889 (let* ((lang (org-element-property :language element
))
1890 ;; Extract code and references.
1891 (code-info (org-export-unravel-code element
))
1892 (code (car code-info
))
1893 (refs (cdr code-info
))
1894 ;; Does the src block contain labels?
1895 (retain-labels (org-element-property :retain-labels element
))
1896 ;; Does it have line numbers?
1897 (num-start (case (org-element-property :number-lines element
)
1898 (continued (org-export-get-loc element info
))
1900 (org-html-do-format-code code lang refs retain-labels num-start
)))
1903 ;;; Tables of Contents
1905 (defun org-html-toc (depth info
)
1906 "Build a table of contents.
1907 DEPTH is an integer specifying the depth of the table. INFO is a
1908 plist used as a communication channel. Return the table of
1909 contents as a string, or nil if it is empty."
1911 (mapcar (lambda (headline)
1912 (cons (org-html--format-toc-headline headline info
)
1913 (org-export-get-relative-level headline info
)))
1914 (org-export-collect-headlines info depth
))))
1916 (concat "<div id=\"table-of-contents\">\n"
1917 (format "<h%d>%s</h%d>\n"
1918 org-html-toplevel-hlevel
1919 (org-html--translate "Table of Contents" info
)
1920 org-html-toplevel-hlevel
)
1921 "<div id=\"text-table-of-contents\">"
1922 (org-html--toc-text toc-entries
)
1926 (defun org-html--toc-text (toc-entries)
1927 "Return innards of a table of contents, as a string.
1928 TOC-ENTRIES is an alist where key is an entry title, as a string,
1929 and value is its relative level, as an integer."
1930 (let* ((prev-level (1- (cdar toc-entries
)))
1931 (start-level prev-level
))
1935 (let ((headline (car entry
))
1936 (level (cdr entry
)))
1938 (let* ((cnt (- level prev-level
))
1939 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1941 (setq prev-level level
)
1943 (org-html--make-string
1944 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1945 ((< cnt
0) "</li>\n</ul>\n")))
1946 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1949 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
1951 (defun org-html--format-toc-headline (headline info
)
1952 "Return an appropriate table of contents entry for HEADLINE.
1953 INFO is a plist used as a communication channel."
1954 (let* ((headline-number (org-export-get-headline-number headline info
))
1956 (and (not (org-export-low-level-p headline info
))
1957 (org-export-numbered-headline-p headline info
)
1958 (concat (mapconcat 'number-to-string headline-number
".") ". ")))
1959 (tags (and (eq (plist-get info
:with-tags
) t
)
1960 (org-export-get-tags headline info
))))
1961 (format "<a href=\"#%s\">%s</a>"
1963 (org-export-solidify-link-text
1964 (or (org-element-property :CUSTOM_ID headline
)
1965 (concat "sec-" (mapconcat 'number-to-string
1966 headline-number
"-"))))
1968 (concat section-number
1969 (org-export-data-with-translations
1970 (org-export-get-alt-title headline info
)
1971 ;; Ignore any footnote-reference, link,
1972 ;; radio-target and target in table of contents.
1974 '((footnote-reference . ignore
)
1975 (link .
(lambda (link desc i
) desc
))
1976 (radio-target .
(lambda (radio desc i
) desc
))
1978 (org-export-backend-translate-table 'html
))
1980 (and tags
"   ") (org-html--tags tags
)))))
1982 (defun org-html-list-of-listings (info)
1983 "Build a list of listings.
1984 INFO is a plist used as a communication channel. Return the list
1985 of listings as a string, or nil if it is empty."
1986 (let ((lol-entries (org-export-collect-listings info
)))
1988 (concat "<div id=\"list-of-listings\">\n"
1989 (format "<h%d>%s</h%d>\n"
1990 org-html-toplevel-hlevel
1991 (org-html--translate "List of Listings" info
)
1992 org-html-toplevel-hlevel
)
1993 "<div id=\"text-list-of-listings\">\n<ul>\n"
1995 (initial-fmt (org-html--translate "Listing %d:" info
)))
1998 (let ((label (org-element-property :name entry
))
2001 (or (org-export-get-caption entry t
)
2002 (org-export-get-caption entry
))
2007 (concat (format initial-fmt
(incf count
)) " " title
)
2008 (format "<a href=\"#%s\">%s %s</a>"
2009 (org-export-solidify-link-text label
)
2010 (format initial-fmt
(incf count
))
2014 "\n</ul>\n</div>\n</div>"))))
2016 (defun org-html-list-of-tables (info)
2017 "Build a list of tables.
2018 INFO is a plist used as a communication channel. Return the list
2019 of tables as a string, or nil if it is empty."
2020 (let ((lol-entries (org-export-collect-tables info
)))
2022 (concat "<div id=\"list-of-tables\">\n"
2023 (format "<h%d>%s</h%d>\n"
2024 org-html-toplevel-hlevel
2025 (org-html--translate "List of Tables" info
)
2026 org-html-toplevel-hlevel
)
2027 "<div id=\"text-list-of-tables\">\n<ul>\n"
2029 (initial-fmt (org-html--translate "Table %d:" info
)))
2032 (let ((label (org-element-property :name entry
))
2035 (or (org-export-get-caption entry t
)
2036 (org-export-get-caption entry
))
2041 (concat (format initial-fmt
(incf count
)) " " title
)
2042 (format "<a href=\"#%s\">%s %s</a>"
2043 (org-export-solidify-link-text label
)
2044 (format initial-fmt
(incf count
))
2048 "\n</ul>\n</div>\n</div>"))))
2051 ;;; Transcode Functions
2055 (defun org-html-bold (bold contents info
)
2056 "Transcode BOLD from Org to HTML.
2057 CONTENTS is the text with bold markup. INFO is a plist holding
2058 contextual information."
2059 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
2064 (defun org-html-center-block (center-block contents info
)
2065 "Transcode a CENTER-BLOCK element from Org to HTML.
2066 CONTENTS holds the contents of the block. INFO is a plist
2067 holding contextual information."
2068 (format "<div class=\"center\">\n%s</div>" contents
))
2072 (defun org-html-clock (clock contents info
)
2073 "Transcode a CLOCK element from Org to HTML.
2074 CONTENTS is nil. INFO is a plist used as a communication
2077 <span class=\"timestamp-wrapper\">
2078 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2083 (org-element-property :raw-value
2084 (org-element-property :value clock
)))
2085 (let ((time (org-element-property :duration clock
)))
2086 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2090 (defun org-html-code (code contents info
)
2091 "Transcode CODE from Org to HTML.
2092 CONTENTS is nil. INFO is a plist holding contextual
2094 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
2095 (org-html-encode-plain-text (org-element-property :value code
))))
2099 (defun org-html-drawer (drawer contents info
)
2100 "Transcode a DRAWER element from Org to HTML.
2101 CONTENTS holds the contents of the block. INFO is a plist
2102 holding contextual information."
2103 (if (functionp org-html-format-drawer-function
)
2104 (funcall org-html-format-drawer-function
2105 (org-element-property :drawer-name drawer
)
2107 ;; If there's no user defined function: simply
2108 ;; display contents of the drawer.
2113 (defun org-html-dynamic-block (dynamic-block contents info
)
2114 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2115 CONTENTS holds the contents of the block. INFO is a plist
2116 holding contextual information. See `org-export-data'."
2121 (defun org-html-entity (entity contents info
)
2122 "Transcode an ENTITY object from Org to HTML.
2123 CONTENTS are the definition itself. INFO is a plist holding
2124 contextual information."
2125 (org-element-property :html entity
))
2129 (defun org-html-example-block (example-block contents info
)
2130 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2131 CONTENTS is nil. INFO is a plist holding contextual
2133 (if (org-export-read-attribute :attr_html example-block
:textarea
)
2134 (org-html--textarea-block example-block
)
2135 (format "<pre class=\"example\">\n%s</pre>"
2136 (org-html-format-code example-block info
))))
2140 (defun org-html-export-snippet (export-snippet contents info
)
2141 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2142 CONTENTS is nil. INFO is a plist holding contextual
2144 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2145 (org-element-property :value export-snippet
)))
2149 (defun org-html-export-block (export-block contents info
)
2150 "Transcode a EXPORT-BLOCK element from Org to HTML.
2151 CONTENTS is nil. INFO is a plist holding contextual information."
2152 (when (string= (org-element-property :type export-block
) "HTML")
2153 (org-remove-indentation (org-element-property :value export-block
))))
2157 (defun org-html-fixed-width (fixed-width contents info
)
2158 "Transcode a FIXED-WIDTH element from Org to HTML.
2159 CONTENTS is nil. INFO is a plist holding contextual information."
2160 (format "<pre class=\"example\">\n%s</pre>"
2161 (org-html-do-format-code
2162 (org-remove-indentation
2163 (org-element-property :value fixed-width
)))))
2165 ;;;; Footnote Reference
2167 (defun org-html-footnote-reference (footnote-reference contents info
)
2168 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2169 CONTENTS is nil. INFO is a plist holding contextual information."
2171 ;; Insert separator between two footnotes in a row.
2172 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2173 (when (eq (org-element-type prev
) 'footnote-reference
)
2174 org-html-footnote-separator
))
2176 ((not (org-export-footnote-first-reference-p footnote-reference info
))
2177 (org-html-format-footnote-reference
2178 (org-export-get-footnote-number footnote-reference info
)
2180 ;; Inline definitions are secondary strings.
2181 ((eq (org-element-property :type footnote-reference
) 'inline
)
2182 (org-html-format-footnote-reference
2183 (org-export-get-footnote-number footnote-reference info
)
2185 ;; Non-inline footnotes definitions are full Org data.
2186 (t (org-html-format-footnote-reference
2187 (org-export-get-footnote-number footnote-reference info
)
2192 (defun org-html-format-headline--wrap
2193 (headline info
&optional format-function
&rest extra-keys
)
2194 "Transcode a HEADLINE element from Org to HTML.
2195 CONTENTS holds the contents of the headline. INFO is a plist
2196 holding contextual information."
2197 (let* ((level (+ (org-export-get-relative-level headline info
)
2198 (1- org-html-toplevel-hlevel
)))
2199 (headline-number (org-export-get-headline-number headline info
))
2200 (section-number (and (not (org-export-low-level-p headline info
))
2201 (org-export-numbered-headline-p headline info
)
2202 (mapconcat 'number-to-string
2203 headline-number
".")))
2204 (todo (and (plist-get info
:with-todo-keywords
)
2205 (let ((todo (org-element-property :todo-keyword headline
)))
2206 (and todo
(org-export-data todo info
)))))
2207 (todo-type (and todo
(org-element-property :todo-type headline
)))
2208 (priority (and (plist-get info
:with-priority
)
2209 (org-element-property :priority headline
)))
2210 (text (org-export-data (org-element-property :title headline
) info
))
2211 (tags (and (plist-get info
:with-tags
)
2212 (org-export-get-tags headline info
)))
2213 (headline-label (or (org-element-property :CUSTOM_ID headline
)
2214 (concat "sec-" (mapconcat 'number-to-string
2215 headline-number
"-"))))
2216 (format-function (cond
2217 ((functionp format-function
) format-function
)
2218 ((functionp org-html-format-headline-function
)
2220 (lambda (todo todo-type priority text tags
2222 (funcall org-html-format-headline-function
2223 todo todo-type priority text tags
))))
2224 (t 'org-html-format-headline
))))
2225 (apply format-function
2226 todo todo-type priority text tags
2227 :headline-label headline-label
:level level
2228 :section-number section-number extra-keys
)))
2230 (defun org-html-headline (headline contents info
)
2231 "Transcode a HEADLINE element from Org to HTML.
2232 CONTENTS holds the contents of the headline. INFO is a plist
2233 holding contextual information."
2235 (setq contents
(or contents
""))
2236 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2237 (level (org-export-get-relative-level headline info
))
2238 (text (org-export-data (org-element-property :title headline
) info
))
2239 (todo (and (plist-get info
:with-todo-keywords
)
2240 (let ((todo (org-element-property :todo-keyword headline
)))
2241 (and todo
(org-export-data todo info
)))))
2242 (todo-type (and todo
(org-element-property :todo-type headline
)))
2243 (tags (and (plist-get info
:with-tags
)
2244 (org-export-get-tags headline info
)))
2245 (priority (and (plist-get info
:with-priority
)
2246 (org-element-property :priority headline
)))
2247 (section-number (and (org-export-numbered-headline-p headline info
)
2248 (mapconcat 'number-to-string
2249 (org-export-get-headline-number
2250 headline info
) ".")))
2251 ;; Create the headline text.
2252 (full-text (org-html-format-headline--wrap headline info
)))
2254 ;; Case 1: This is a footnote section: ignore it.
2255 ((org-element-property :footnote-section-p headline
) nil
)
2256 ;; Case 2. This is a deep sub-tree: export it as a list item.
2257 ;; Also export as items headlines for which no section
2258 ;; format has been found.
2259 ((org-export-low-level-p headline info
)
2260 ;; Build the real contents of the sub-tree.
2261 (let* ((type (if numberedp
'ordered
'unordered
))
2262 (itemized-body (org-html-format-list-item
2263 contents type nil info nil full-text
)))
2265 (and (org-export-first-sibling-p headline info
)
2266 (org-html-begin-plain-list type
))
2268 (and (org-export-last-sibling-p headline info
)
2269 (org-html-end-plain-list type
)))))
2270 ;; Case 3. Standard headline. Export it as a section.
2272 (let* ((section-number (mapconcat 'number-to-string
2273 (org-export-get-headline-number
2274 headline info
) "-"))
2276 (list (org-element-property :CUSTOM_ID headline
)
2277 (concat "sec-" section-number
)
2278 (org-element-property :ID headline
))))
2279 (preferred-id (car ids
))
2280 (extra-ids (cdr ids
))
2281 (extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2282 (level1 (+ level
(1- org-html-toplevel-hlevel
)))
2283 (first-content (car (org-element-contents headline
))))
2284 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2285 (org-html--container headline info
)
2286 (format "outline-container-%s"
2287 (or (org-element-property :CUSTOM_ID headline
)
2288 (concat "sec-" section-number
)))
2289 (concat (format "outline-%d" level1
) (and extra-class
" ")
2291 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2296 (let ((id (org-export-solidify-link-text
2297 (if (org-uuidgen-p x
) (concat "ID-" x
)
2299 (org-html--anchor id
)))
2303 ;; When there is no section, pretend there is an empty
2304 ;; one to get the correct <div class="outline- ...>
2305 ;; which is needed by `org-info.js'.
2306 (if (not (eq (org-element-type first-content
) 'section
))
2307 (concat (org-html-section first-content
"" info
)
2310 (org-html--container headline info
)))))))
2312 (defun org-html--container (headline info
)
2313 (or (org-element-property :HTML_CONTAINER headline
)
2314 (if (= 1 (org-export-get-relative-level headline info
))
2315 (plist-get info
:html-container
)
2318 ;;;; Horizontal Rule
2320 (defun org-html-horizontal-rule (horizontal-rule contents info
)
2321 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2322 CONTENTS is nil. INFO is a plist holding contextual information."
2323 (org-html-close-tag "hr" nil info
))
2325 ;;;; Inline Src Block
2327 (defun org-html-inline-src-block (inline-src-block contents info
)
2328 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2329 CONTENTS holds the contents of the item. INFO is a plist holding
2330 contextual information."
2331 (let* ((org-lang (org-element-property :language inline-src-block
))
2332 (code (org-element-property :value inline-src-block
)))
2333 (error "Cannot export inline src block")))
2337 (defun org-html-format-section (text class
&optional id
)
2338 "Format a section with TEXT into a HTML div with CLASS and ID."
2339 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
2340 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
2342 (defun org-html-inlinetask (inlinetask contents info
)
2343 "Transcode an INLINETASK element from Org to HTML.
2344 CONTENTS holds the contents of the block. INFO is a plist
2345 holding contextual information."
2347 ;; If `org-html-format-inlinetask-function' is provided, call it
2348 ;; with appropriate arguments.
2349 ((functionp org-html-format-inlinetask-function
)
2350 (let ((format-function
2352 (lambda (todo todo-type priority text tags
2353 &key contents
&allow-other-keys
)
2354 (funcall org-html-format-inlinetask-function
2355 todo todo-type priority text tags contents
)))))
2356 (org-html-format-headline--wrap
2357 inlinetask info format-function
:contents contents
)))
2358 ;; Otherwise, use a default template.
2359 (t (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2360 (org-html-format-headline--wrap inlinetask info
)
2361 (org-html-close-tag "br" nil info
)
2366 (defun org-html-italic (italic contents info
)
2367 "Transcode ITALIC from Org to HTML.
2368 CONTENTS is the text with italic markup. INFO is a plist holding
2369 contextual information."
2370 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
2374 (defun org-html-checkbox (checkbox)
2375 "Format CHECKBOX into HTML."
2376 (case checkbox
(on "<code>[X]</code>")
2377 (off "<code>[ ]</code>")
2378 (trans "<code>[-]</code>")
2381 (defun org-html-format-list-item (contents type checkbox info
2382 &optional term-counter-id
2384 "Format a list item into HTML."
2385 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" ")))
2386 (br (org-html-close-tag "br" nil info
)))
2390 (let* ((counter term-counter-id
)
2391 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2393 (format "<li%s>" extra
)
2394 (when headline
(concat headline br
)))))
2396 (let* ((id term-counter-id
)
2397 (extra (if id
(format " id=\"%s\"" id
) "")))
2399 (format "<li%s>" extra
)
2400 (when headline
(concat headline br
)))))
2402 (let* ((term term-counter-id
))
2403 (setq term
(or term
"(no term)"))
2404 ;; Check-boxes in descriptive lists are associated to tag.
2405 (concat (format "<dt> %s </dt>"
2406 (concat checkbox term
))
2408 (unless (eq type
'descriptive
) checkbox
)
2413 (descriptive "</dd>")))))
2415 (defun org-html-item (item contents info
)
2416 "Transcode an ITEM element from Org to HTML.
2417 CONTENTS holds the contents of the item. INFO is a plist holding
2418 contextual information."
2419 (let* ((plain-list (org-export-get-parent item
))
2420 (type (org-element-property :type plain-list
))
2421 (counter (org-element-property :counter item
))
2422 (checkbox (org-element-property :checkbox item
))
2423 (tag (let ((tag (org-element-property :tag item
)))
2424 (and tag
(org-export-data tag info
)))))
2425 (org-html-format-list-item
2426 contents type checkbox info
(or tag counter
))))
2430 (defun org-html-keyword (keyword contents info
)
2431 "Transcode a KEYWORD element from Org to HTML.
2432 CONTENTS is nil. INFO is a plist holding contextual information."
2433 (let ((key (org-element-property :key keyword
))
2434 (value (org-element-property :value keyword
)))
2436 ((string= key
"HTML") value
)
2437 ((string= key
"TOC")
2438 (let ((value (downcase value
)))
2440 ((string-match "\\<headlines\\>" value
)
2441 (let ((depth (or (and (string-match "[0-9]+" value
)
2442 (string-to-number (match-string 0 value
)))
2443 (plist-get info
:with-toc
))))
2444 (org-html-toc depth info
)))
2445 ((string= "listings" value
) (org-html-list-of-listings info
))
2446 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2448 ;;;; Latex Environment
2450 (defun org-html-format-latex (latex-frag processing-type
)
2451 "Format a LaTeX fragment LATEX-FRAG into HTML."
2452 (let ((cache-relpath "") (cache-dir ""))
2453 (unless (eq processing-type
'mathjax
)
2454 (let ((bfn (or (buffer-file-name)
2456 (expand-file-name "latex" temporary-file-directory
)))))
2459 (file-name-sans-extension
2460 (file-name-nondirectory bfn
)))
2461 cache-dir
(file-name-directory bfn
))))
2464 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2465 nil nil processing-type
)
2468 (defun org-html-latex-environment (latex-environment contents info
)
2469 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2470 CONTENTS is nil. INFO is a plist holding contextual information."
2471 (let ((processing-type (plist-get info
:with-latex
))
2472 (latex-frag (org-remove-indentation
2473 (org-element-property :value latex-environment
)))
2474 (caption (org-export-data
2475 (org-export-get-caption latex-environment
) info
))
2477 (label (org-element-property :name latex-environment
)))
2479 ((memq processing-type
'(t mathjax
))
2480 (org-html-format-latex latex-frag
'mathjax
))
2481 ((eq processing-type
'dvipng
)
2482 (let* ((formula-link (org-html-format-latex
2483 latex-frag processing-type
)))
2484 (when (and formula-link
2485 (string-match "file:\\([^]]*\\)" formula-link
))
2486 (org-html-format-inline-image
2487 (match-string 1 formula-link
) info caption label attr t
))))
2492 (defun org-html-latex-fragment (latex-fragment contents info
)
2493 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2494 CONTENTS is nil. INFO is a plist holding contextual information."
2495 (let ((latex-frag (org-element-property :value latex-fragment
))
2496 (processing-type (plist-get info
:with-latex
)))
2497 (case processing-type
2499 (org-html-format-latex latex-frag
'mathjax
))
2501 (let* ((formula-link (org-html-format-latex
2502 latex-frag processing-type
)))
2503 (when (and formula-link
2504 (string-match "file:\\([^]]*\\)" formula-link
))
2505 (org-html-format-inline-image
2506 (match-string 1 formula-link
) info
))))
2511 (defun org-html-line-break (line-break contents info
)
2512 "Transcode a LINE-BREAK object from Org to HTML.
2513 CONTENTS is nil. INFO is a plist holding contextual information."
2514 (concat (org-html-close-tag "br" nil info
) "\n"))
2518 (defun org-html-link--inline-image (link desc info
)
2519 "Return HTML code for an inline image.
2521 LINK is the link pointing to the inline image. INFO is a plist
2522 used as a communication channel.
2524 Inline images can have these attributes:
2526 #+ATTR_HTML: :width 100px :height 100px :alt \"Alt description\"."
2527 (let* ((type (org-element-property :type link
))
2528 (raw-path (org-element-property :path link
))
2529 (path (cond ((member type
'("http" "https"))
2530 (concat type
":" raw-path
))
2531 ((file-name-absolute-p raw-path
)
2532 (expand-file-name raw-path
))
2534 (parent (org-export-get-parent-element link
))
2535 (caption (org-export-data (org-export-get-caption parent
) info
))
2536 (label (org-element-property :name parent
)))
2537 ;; Return proper string, depending on DISPOSITION.
2538 (org-html-format-inline-image
2539 path info caption label
2540 (org-html--make-attribute-string
2541 (org-export-read-attribute :attr_html parent
))
2542 (org-html-standalone-image-p link info
))))
2544 (defvar org-html-standalone-image-predicate
)
2545 (defun org-html-standalone-image-p (element info
&optional predicate
)
2546 "Test if ELEMENT is a standalone image for the purpose HTML export.
2547 INFO is a plist holding contextual information.
2549 Return non-nil, if ELEMENT is of type paragraph and it's sole
2550 content, save for whitespaces, is a link that qualifies as an
2553 Return non-nil, if ELEMENT is of type link and it's containing
2554 paragraph has no other content save for leading and trailing
2557 Return nil, otherwise.
2559 Bind `org-html-standalone-image-predicate' to constrain
2560 paragraph further. For example, to check for only captioned
2561 standalone images, do the following.
2563 \(setq org-html-standalone-image-predicate
2564 \(lambda \(paragraph\)
2565 \(org-element-property :caption paragraph\)\)\)"
2566 (let ((paragraph (case (org-element-type element
)
2568 (link (and (org-export-inline-image-p
2569 element org-html-inline-image-rules
)
2570 (org-export-get-parent element
)))
2572 (when (eq (org-element-type paragraph
) 'paragraph
)
2573 (when (or (not (and (boundp 'org-html-standalone-image-predicate
)
2574 (functionp org-html-standalone-image-predicate
)))
2575 (funcall org-html-standalone-image-predicate paragraph
))
2576 (let ((contents (org-element-contents paragraph
)))
2577 (loop for x in contents
2578 with inline-image-count
= 0
2580 ((eq (org-element-type x
) 'plain-text
)
2581 (not (org-string-nw-p x
)))
2582 ((eq (org-element-type x
) 'link
)
2583 (when (org-export-inline-image-p
2584 x org-html-inline-image-rules
)
2585 (= (incf inline-image-count
) 1)))
2588 (defun org-html-link (link desc info
)
2589 "Transcode a LINK object from Org to HTML.
2591 DESC is the description part of the link, or the empty string.
2592 INFO is a plist holding contextual information. See
2594 (let* ((link-org-files-as-html-maybe
2596 (lambda (raw-path info
)
2597 "Treat links to `file.org' as links to `file.html', if needed.
2598 See `org-html-link-org-files-as-html'."
2600 ((and org-html-link-org-files-as-html
2602 (downcase (file-name-extension raw-path
"."))))
2603 (concat (file-name-sans-extension raw-path
) "."
2604 (plist-get info
:html-extension
)))
2606 (type (org-element-property :type link
))
2607 (raw-path (org-element-property :path link
))
2608 ;; Ensure DESC really exists, or set it to nil.
2609 (desc (org-string-nw-p desc
))
2612 ((member type
'("http" "https" "ftp" "mailto"))
2613 (concat type
":" raw-path
))
2614 ((string= type
"file")
2615 ;; Treat links to ".org" files as ".html", if needed.
2617 (funcall link-org-files-as-html-maybe raw-path info
))
2618 ;; If file path is absolute, prepend it with protocol
2619 ;; component - "file://".
2620 (when (file-name-absolute-p raw-path
)
2622 (concat "file://" (expand-file-name raw-path
))))
2623 ;; Add search option, if any. A search option can be
2624 ;; relative to a custom-id or a headline title. Any other
2625 ;; option is ignored.
2626 (let ((option (org-element-property :search-option link
)))
2627 (cond ((not option
) raw-path
)
2628 ((eq (aref option
0) ?
#) (concat raw-path option
))
2629 ;; External fuzzy link: try to resolve it if path
2630 ;; belongs to current project, if any.
2631 ((eq (aref option
0) ?
*)
2635 (org-publish-resolve-external-fuzzy-link
2636 (org-element-property :path link
) option
)))
2637 (and numbers
(concat "#sec-"
2638 (mapconcat 'number-to-string
2642 ;; Extract attributes from parent's paragraph. HACK: Only do
2643 ;; this for the first link in parent. This is needed as long
2644 ;; as attributes cannot be set on a per link basis.
2646 (let ((parent (org-export-get-parent-element link
)))
2647 (if (not (eq (org-element-map parent
'link
'identity info t
) link
))
2649 (let ((att (org-html--make-attribute-string
2650 (org-export-read-attribute :attr_html parent
))))
2651 (cond ((not (org-string-nw-p att
)) "")
2652 ((and desc
(string-match (regexp-quote att
) desc
)) "")
2653 (t (concat " " att
)))))))
2657 ((and (or (eq t org-html-inline-images
)
2658 (and org-html-inline-images
(not desc
)))
2659 (org-export-inline-image-p link org-html-inline-image-rules
))
2660 (org-html-link--inline-image link desc info
))
2661 ;; Radio target: Transcode target's contents and use them as
2662 ;; link's description.
2663 ((string= type
"radio")
2664 (let ((destination (org-export-resolve-radio-link link info
)))
2666 (format "<a href=\"#%s\"%s>%s</a>"
2667 (org-export-solidify-link-text path
)
2669 (org-export-data (org-element-contents destination
) info
)))))
2670 ;; Links pointing to a headline: Find destination and build
2671 ;; appropriate referencing command.
2672 ((member type
'("custom-id" "fuzzy" "id"))
2673 (let ((destination (if (string= type
"fuzzy")
2674 (org-export-resolve-fuzzy-link link info
)
2675 (org-export-resolve-id-link link info
))))
2676 (case (org-element-type destination
)
2677 ;; ID link points to an external file.
2679 (let ((fragment (concat "ID-" path
))
2680 ;; Treat links to ".org" files as ".html", if needed.
2681 (path (funcall link-org-files-as-html-maybe
2683 (format "<a href=\"%s#%s\"%s>%s</a>"
2684 path fragment attributes
(or desc destination
))))
2685 ;; Fuzzy link points nowhere.
2690 (org-element-property :raw-link link
) info
))))
2691 ;; Fuzzy link points to an invisible target.
2693 ;; Link points to a headline.
2696 ;; What href to use?
2698 ;; Case 1: Headline is linked via it's CUSTOM_ID
2699 ;; property. Use CUSTOM_ID.
2700 ((string= type
"custom-id")
2701 (org-element-property :CUSTOM_ID destination
))
2702 ;; Case 2: Headline is linked via it's ID property
2703 ;; or through other means. Use the default href.
2704 ((member type
'("id" "fuzzy"))
2706 (mapconcat 'number-to-string
2707 (org-export-get-headline-number
2708 destination info
) "-")))
2709 (t (error "Shouldn't reach here"))))
2710 ;; What description to use?
2712 ;; Case 1: Headline is numbered and LINK has no
2713 ;; description. Display section number.
2714 (if (and (org-export-numbered-headline-p destination info
)
2716 (mapconcat 'number-to-string
2717 (org-export-get-headline-number
2718 destination info
) ".")
2719 ;; Case 2: Either the headline is un-numbered or
2720 ;; LINK has a custom description. Display LINK's
2721 ;; description or headline's title.
2722 (or desc
(org-export-data (org-element-property
2723 :title destination
) info
)))))
2724 (format "<a href=\"#%s\"%s>%s</a>"
2725 (org-export-solidify-link-text href
) attributes desc
)))
2726 ;; Fuzzy link points to a target. Do as above.
2728 (let ((path (org-export-solidify-link-text path
)) number
)
2731 ((org-html-standalone-image-p destination info
)
2732 (org-export-get-ordinal
2733 (assoc 'link
(org-element-contents destination
))
2734 info
'link
'org-html-standalone-image-p
))
2735 (t (org-export-get-ordinal destination info
))))
2736 (setq desc
(when number
2737 (if (atom number
) (number-to-string number
)
2738 (mapconcat 'number-to-string number
".")))))
2739 (format "<a href=\"#%s\"%s>%s</a>"
2740 path attributes
(or desc
"No description for this link")))))))
2741 ;; Coderef: replace link with the reference name or the
2742 ;; equivalent line number.
2743 ((string= type
"coderef")
2744 (let ((fragment (concat "coderef-" path
)))
2745 (format "<a href=\"#%s\"%s%s>%s</a>"
2748 (format (concat "class=\"coderef\""
2749 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2750 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2753 (format (org-export-get-coderef-format path desc
)
2754 (org-export-resolve-coderef path info
)))))
2755 ;; Link type is handled by a special function.
2756 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2757 (funcall protocol
(org-link-unescape path
) desc
'html
))
2758 ;; External link with a description part.
2759 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2760 ;; External link without a description part.
2761 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2762 ;; No path, only description. Try to do something useful.
2763 (t (format "<i>%s</i>" desc
)))))
2767 (defun org-html-paragraph (paragraph contents info
)
2768 "Transcode a PARAGRAPH element from Org to HTML.
2769 CONTENTS is the contents of the paragraph, as a string. INFO is
2770 the plist used as a communication channel."
2771 (let* ((parent (org-export-get-parent paragraph
))
2772 (parent-type (org-element-type parent
))
2773 (style '((footnote-definition " class=\"footpara\"")))
2774 (extra (or (cadr (assoc parent-type style
)) "")))
2776 ((and (eq (org-element-type parent
) 'item
)
2777 (= (org-element-property :begin paragraph
)
2778 (org-element-property :contents-begin parent
)))
2779 ;; leading paragraph in a list item have no tags
2781 ((org-html-standalone-image-p paragraph info
)
2784 (t (format "<p%s>\n%s</p>" extra contents
)))))
2788 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2789 ;; the correct value for the item counter
2790 (defun org-html-begin-plain-list (type &optional arg1
)
2791 "Insert the beginning of the HTML list depending on TYPE.
2792 When ARG1 is a string, use it as the start parameter for ordered
2796 (format "<ol class=\"org-ol\"%s>"
2797 (if arg1
(format " start=\"%d\"" arg1
) "")))
2798 (unordered "<ul class=\"org-ul\">")
2799 (descriptive "<dl class=\"org-dl\">")))
2801 (defun org-html-end-plain-list (type)
2802 "Insert the end of the HTML list depending on TYPE."
2806 (descriptive "</dl>")))
2808 (defun org-html-plain-list (plain-list contents info
)
2809 "Transcode a PLAIN-LIST element from Org to HTML.
2810 CONTENTS is the contents of the list. INFO is a plist holding
2811 contextual information."
2812 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2813 (type (org-element-property :type plain-list
)))
2815 (org-html-begin-plain-list type
)
2816 contents
(org-html-end-plain-list type
))))
2820 (defun org-html-convert-special-strings (string)
2821 "Convert special characters in STRING to HTML."
2822 (let ((all org-html-special-string-regexps
)
2824 (while (setq a
(pop all
))
2825 (setq re
(car a
) rpl
(cdr a
) start
0)
2826 (while (string-match re string start
)
2827 (setq string
(replace-match rpl t nil string
))))
2830 (defun org-html-encode-plain-text (text)
2831 "Convert plain text characters from TEXT to HTML equivalent.
2832 Possible conversions are set in `org-html-protect-char-alist'."
2835 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2836 org-html-protect-char-alist
)
2839 (defun org-html-plain-text (text info
)
2840 "Transcode a TEXT string from Org to HTML.
2841 TEXT is the string to transcode. INFO is a plist holding
2842 contextual information."
2843 (let ((output text
))
2844 ;; Protect following characters: <, >, &.
2845 (setq output
(org-html-encode-plain-text output
))
2846 ;; Handle smart quotes. Be sure to provide original string since
2847 ;; OUTPUT may have been modified.
2848 (when (plist-get info
:with-smart-quotes
)
2849 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2850 ;; Handle special strings.
2851 (when (plist-get info
:with-special-strings
)
2852 (setq output
(org-html-convert-special-strings output
)))
2853 ;; Handle break preservation if required.
2854 (when (plist-get info
:preserve-breaks
)
2856 (replace-regexp-in-string
2857 "\\(\\\\\\\\\\)?[ \t]*\n"
2858 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
2865 (defun org-html-planning (planning contents info
)
2866 "Transcode a PLANNING element from Org to HTML.
2867 CONTENTS is nil. INFO is a plist used as a communication
2869 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2871 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2876 (let ((closed (org-element-property :closed planning
)))
2878 (format span-fmt org-closed-string
2880 (org-element-property :raw-value closed
)))))
2881 (let ((deadline (org-element-property :deadline planning
)))
2883 (format span-fmt org-deadline-string
2885 (org-element-property :raw-value deadline
)))))
2886 (let ((scheduled (org-element-property :scheduled planning
)))
2888 (format span-fmt org-scheduled-string
2890 (org-element-property :raw-value scheduled
)))))))
2893 ;;;; Property Drawer
2895 (defun org-html-property-drawer (property-drawer contents info
)
2896 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2897 CONTENTS is nil. INFO is a plist holding contextual
2899 ;; The property drawer isn't exported but we want separating blank
2900 ;; lines nonetheless.
2905 (defun org-html-quote-block (quote-block contents info
)
2906 "Transcode a QUOTE-BLOCK element from Org to HTML.
2907 CONTENTS holds the contents of the block. INFO is a plist
2908 holding contextual information."
2909 (format "<blockquote>\n%s</blockquote>" contents
))
2913 (defun org-html-quote-section (quote-section contents info
)
2914 "Transcode a QUOTE-SECTION element from Org to HTML.
2915 CONTENTS is nil. INFO is a plist holding contextual information."
2916 (let ((value (org-remove-indentation
2917 (org-element-property :value quote-section
))))
2918 (when value
(format "<pre>\n%s</pre>" value
))))
2922 (defun org-html-section (section contents info
)
2923 "Transcode a SECTION element from Org to HTML.
2924 CONTENTS holds the contents of the section. INFO is a plist
2925 holding contextual information."
2926 (let ((parent (org-export-get-parent-headline section
)))
2927 ;; Before first headline: no container, just return CONTENTS.
2928 (if (not parent
) contents
2929 ;; Get div's class and id references.
2930 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2931 (1- org-html-toplevel-hlevel
)))
2935 (org-export-get-headline-number parent info
) "-")))
2936 ;; Build return value.
2937 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2939 (or (org-element-property :CUSTOM_ID parent
) section-number
)
2944 (defun org-html-radio-target (radio-target text info
)
2945 "Transcode a RADIO-TARGET object from Org to HTML.
2946 TEXT is the text of the target. INFO is a plist holding
2947 contextual information."
2948 (let ((id (org-export-solidify-link-text
2949 (org-element-property :value radio-target
))))
2950 (org-html--anchor id text
)))
2954 (defun org-html-special-block (special-block contents info
)
2955 "Transcode a SPECIAL-BLOCK element from Org to HTML.
2956 CONTENTS holds the contents of the block. INFO is a plist
2957 holding contextual information."
2958 (let* ((block-type (downcase
2959 (org-element-property :type special-block
)))
2960 (contents (or contents
""))
2961 (html5-fancy (and (org-html-html5-p info
)
2962 (plist-get info
:html-html5-fancy
)
2963 (member block-type org-html-html5-elements
)))
2964 (attributes (org-export-read-attribute :attr_html special-block
)))
2966 (let ((class (plist-get attributes
:class
)))
2967 (setq attributes
(plist-put attributes
:class
2968 (if class
(concat class
" " block-type
)
2970 (setq attributes
(org-html--make-attribute-string attributes
))
2971 (when (not (equal attributes
""))
2972 (setq attributes
(concat " " attributes
)))
2974 (format "<%s%s>\n%s</%s>" block-type attributes
2975 contents block-type
)
2976 (format "<div%s>\n%s\n</div>" attributes contents
))))
2980 (defun org-html-src-block (src-block contents info
)
2981 "Transcode a SRC-BLOCK element from Org to HTML.
2982 CONTENTS holds the contents of the item. INFO is a plist holding
2983 contextual information."
2984 (if (org-export-read-attribute :attr_html src-block
:textarea
)
2985 (org-html--textarea-block src-block
)
2986 (let ((lang (org-element-property :language src-block
))
2987 (caption (org-export-get-caption src-block
))
2988 (code (org-html-format-code src-block info
))
2989 (label (let ((lbl (org-element-property :name src-block
)))
2991 (format " id=\"%s\""
2992 (org-export-solidify-link-text lbl
))))))
2993 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
2995 "<div class=\"org-src-container\">\n%s%s\n</div>"
2996 (if (not caption
) ""
2997 (format "<label class=\"org-src-name\">%s</label>"
2998 (org-export-data caption info
)))
2999 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3001 ;;;; Statistics Cookie
3003 (defun org-html-statistics-cookie (statistics-cookie contents info
)
3004 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3005 CONTENTS is nil. INFO is a plist holding contextual information."
3006 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3007 (format "<code>%s</code>" cookie-value
)))
3011 (defun org-html-strike-through (strike-through contents info
)
3012 "Transcode STRIKE-THROUGH from Org to HTML.
3013 CONTENTS is the text with strike-through markup. INFO is a plist
3014 holding contextual information."
3015 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
3020 (defun org-html-subscript (subscript contents info
)
3021 "Transcode a SUBSCRIPT object from Org to HTML.
3022 CONTENTS is the contents of the object. INFO is a plist holding
3023 contextual information."
3024 (format "<sub>%s</sub>" contents
))
3028 (defun org-html-superscript (superscript contents info
)
3029 "Transcode a SUPERSCRIPT object from Org to HTML.
3030 CONTENTS is the contents of the object. INFO is a plist holding
3031 contextual information."
3032 (format "<sup>%s</sup>" contents
))
3036 (defun org-html-table-cell (table-cell contents info
)
3037 "Transcode a TABLE-CELL element from Org to HTML.
3038 CONTENTS is nil. INFO is a plist used as a communication
3040 (let* ((table-row (org-export-get-parent table-cell
))
3041 (table (org-export-get-parent-table table-cell
))
3043 (if (not org-html-table-align-individual-fields
) ""
3044 (format (if (and (boundp 'org-html-format-table-no-css
)
3045 org-html-format-table-no-css
)
3046 " align=\"%s\"" " class=\"%s\"")
3047 (org-export-table-cell-alignment table-cell info
)))))
3048 (when (or (not contents
) (string= "" (org-trim contents
)))
3049 (setq contents
" "))
3051 ((and (org-export-table-has-header-p table info
)
3052 (= 1 (org-export-table-row-group table-row info
)))
3053 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
3054 contents
(cdr org-html-table-header-tags
)))
3055 ((and org-html-table-use-header-tags-for-first-column
3056 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3057 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
3058 contents
(cdr org-html-table-header-tags
)))
3059 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
3060 contents
(cdr org-html-table-data-tags
))))))
3064 (defun org-html-table-row (table-row contents info
)
3065 "Transcode a TABLE-ROW element from Org to HTML.
3066 CONTENTS is the contents of the row. INFO is a plist used as a
3067 communication channel."
3068 ;; Rules are ignored since table separators are deduced from
3069 ;; borders of the current row.
3070 (when (eq (org-element-property :type table-row
) 'standard
)
3071 (let* ((rowgroup-number (org-export-table-row-group table-row info
))
3072 (row-number (org-export-table-row-number table-row info
))
3074 (org-export-table-row-starts-rowgroup-p table-row info
))
3076 (org-export-table-row-ends-rowgroup-p table-row info
))
3077 ;; `top-row-p' and `end-rowgroup-p' are not used directly
3078 ;; but should be set so that `org-html-table-row-tags' can
3079 ;; use them (see the docstring of this variable.)
3080 (top-row-p (and (equal start-rowgroup-p
'(top))
3081 (equal end-rowgroup-p
'(below top
))))
3082 (bottom-row-p (and (equal start-rowgroup-p
'(above))
3083 (equal end-rowgroup-p
'(bottom above
))))
3086 ;; Case 1: Row belongs to second or subsequent rowgroups.
3087 ((not (= 1 rowgroup-number
))
3088 '("<tbody>" .
"\n</tbody>"))
3089 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
3090 ((org-export-table-has-header-p
3091 (org-export-get-parent-table table-row
) info
)
3092 '("<thead>" .
"\n</thead>"))
3093 ;; Case 2: Row is from first and only row group.
3094 (t '("<tbody>" .
"\n</tbody>")))))
3096 ;; Begin a rowgroup?
3097 (when start-rowgroup-p
(car rowgroup-tags
))
3099 (concat "\n" (eval (car org-html-table-row-tags
))
3102 (eval (cdr org-html-table-row-tags
)))
3104 (when end-rowgroup-p
(cdr rowgroup-tags
))))))
3108 (defun org-html-table-first-row-data-cells (table info
)
3109 "Transcode the first row of TABLE.
3110 INFO is a plist used as a communication channel."
3112 (org-element-map table
'table-row
3114 (unless (eq (org-element-property :type row
) 'rule
) row
))
3116 (special-column-p (org-export-table-has-special-column-p table
)))
3117 (if (not special-column-p
) (org-element-contents table-row
)
3118 (cdr (org-element-contents table-row
)))))
3120 (defun org-html-table--table.el-table
(table info
)
3121 "Format table.el tables into HTML.
3122 INFO is a plist used as a communication channel."
3123 (when (eq (org-element-property :type table
) 'table.el
)
3125 (let ((outbuf (with-current-buffer
3126 (get-buffer-create "*org-export-table*")
3127 (erase-buffer) (current-buffer))))
3129 (insert (org-element-property :value table
))
3131 (re-search-forward "^[ \t]*|[^|]" nil t
)
3132 (table-generate-source 'html outbuf
))
3133 (with-current-buffer outbuf
3134 (prog1 (org-trim (buffer-string))
3137 (defun org-html-table (table contents info
)
3138 "Transcode a TABLE element from Org to HTML.
3139 CONTENTS is the contents of the table. INFO is a plist holding
3140 contextual information."
3141 (case (org-element-property :type table
)
3142 ;; Case 1: table.el table. Convert it using appropriate tools.
3143 (table.el
(org-html-table--table.el-table table info
))
3144 ;; Case 2: Standard table.
3146 (let* ((label (org-element-property :name table
))
3147 (caption (org-export-get-caption table
))
3149 (if (org-html-html5-p info
) ""
3150 (org-html--make-attribute-string
3152 (and label
(list :id
(org-export-solidify-link-text label
)))
3153 (plist-get info
:html-table-attributes
)
3154 (org-export-read-attribute :attr_html table
)))))
3156 (if (and (boundp 'org-html-format-table-no-css
)
3157 org-html-format-table-no-css
)
3158 "align=\"%s\"" "class=\"%s\""))
3161 (lambda (table info
)
3163 (lambda (table-cell)
3164 (let ((alignment (org-export-table-cell-alignment
3167 ;; Begin a colgroup?
3168 (when (org-export-table-cell-starts-colgroup-p
3171 ;; Add a column. Also specify it's alignment.
3174 "col" (concat " " (format alignspec alignment
)) info
))
3176 (when (org-export-table-cell-ends-colgroup-p
3179 (org-html-table-first-row-data-cells table info
) "\n")))))
3180 (format "<table%s>\n%s\n%s\n%s</table>"
3181 (if (equal attributes
"") "" (concat " " attributes
))
3182 (if (not caption
) ""
3183 (format (if org-html-table-caption-above
3184 "<caption align=\"above\">%s</caption>"
3185 "<caption align=\"bottom\">%s</caption>")
3186 (org-export-data caption info
)))
3187 (funcall table-column-specs table info
)
3192 (defun org-html-target (target contents info
)
3193 "Transcode a TARGET object from Org to HTML.
3194 CONTENTS is nil. INFO is a plist holding contextual
3196 (let ((id (org-export-solidify-link-text
3197 (org-element-property :value target
))))
3198 (org-html--anchor id
)))
3202 (defun org-html-timestamp (timestamp contents info
)
3203 "Transcode a TIMESTAMP object from Org to HTML.
3204 CONTENTS is nil. INFO is a plist holding contextual
3206 (let ((value (org-html-plain-text
3207 (org-timestamp-translate timestamp
) info
)))
3208 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3209 (replace-regexp-in-string "--" "–" value
))))
3213 (defun org-html-underline (underline contents info
)
3214 "Transcode UNDERLINE from Org to HTML.
3215 CONTENTS is the text with underline markup. INFO is a plist
3216 holding contextual information."
3217 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
3222 (defun org-html-verbatim (verbatim contents info
)
3223 "Transcode VERBATIM from Org to HTML.
3224 CONTENTS is nil. INFO is a plist holding contextual
3226 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
3227 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3231 (defun org-html-verse-block (verse-block contents info
)
3232 "Transcode a VERSE-BLOCK element from Org to HTML.
3233 CONTENTS is verse block contents. INFO is a plist holding
3234 contextual information."
3235 ;; Replace each newline character with line break. Also replace
3236 ;; each blank line with a line break.
3237 (setq contents
(replace-regexp-in-string
3238 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3239 (replace-regexp-in-string
3240 "\\(\\\\\\\\\\)?[ \t]*\n"
3241 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3242 ;; Replace each white space at beginning of a line with a
3243 ;; non-breaking space.
3244 (while (string-match "^[ \t]+" contents
)
3245 (let* ((num-ws (length (match-string 0 contents
)))
3246 (ws (let (out) (dotimes (i num-ws out
)
3247 (setq out
(concat out
" "))))))
3248 (setq contents
(replace-match ws nil t contents
))))
3249 (format "<p class=\"verse\">\n%s</p>" contents
))
3252 ;;; Filter Functions
3254 (defun org-html-final-function (contents backend info
)
3255 "Filter to indent the HTML and convert HTML entities."
3260 (indent-region (point-min) (point-max)))
3261 (when org-html-use-unicode-chars
3263 (mm-url-decode-entities))
3264 (buffer-substring-no-properties (point-min) (point-max))))
3267 ;;; End-user functions
3270 (defun org-html-export-as-html
3271 (&optional async subtreep visible-only body-only ext-plist
)
3272 "Export current buffer to an HTML buffer.
3274 If narrowing is active in the current buffer, only export its
3277 If a region is active, export that region.
3279 A non-nil optional argument ASYNC means the process should happen
3280 asynchronously. The resulting buffer should be accessible
3281 through the `org-export-stack' interface.
3283 When optional argument SUBTREEP is non-nil, export the sub-tree
3284 at point, extracting information from the headline properties
3287 When optional argument VISIBLE-ONLY is non-nil, don't export
3288 contents of hidden elements.
3290 When optional argument BODY-ONLY is non-nil, only write code
3291 between \"<body>\" and \"</body>\" tags.
3293 EXT-PLIST, when provided, is a property list with external
3294 parameters overriding Org default settings, but still inferior to
3295 file-local settings.
3297 Export is done in a buffer named \"*Org HTML Export*\", which
3298 will be displayed when `org-export-show-temporary-export-buffer'
3302 (org-export-async-start
3304 (with-current-buffer (get-buffer-create "*Org HTML Export*")
3307 (goto-char (point-min))
3309 (org-export-add-to-stack (current-buffer) 'html
)))
3310 `(org-export-as 'html
,subtreep
,visible-only
,body-only
',ext-plist
))
3311 (let ((outbuf (org-export-to-buffer
3312 'html
"*Org HTML Export*"
3313 subtreep visible-only body-only ext-plist
)))
3315 (with-current-buffer outbuf
(set-auto-mode t
))
3316 (when org-export-show-temporary-export-buffer
3317 (switch-to-buffer-other-window outbuf
)))))
3320 (defun org-html-convert-region-to-html ()
3321 "Assume the current region has org-mode syntax, and convert it to HTML.
3322 This can be used in any buffer. For example, you can write an
3323 itemized list in org-mode syntax in an HTML buffer and use this
3324 command to convert it."
3326 (org-export-replace-region-by 'html
))
3329 (defun org-html-export-to-html
3330 (&optional async subtreep visible-only body-only ext-plist
)
3331 "Export current buffer to a HTML file.
3333 If narrowing is active in the current buffer, only export its
3336 If a region is active, export that region.
3338 A non-nil optional argument ASYNC means the process should happen
3339 asynchronously. The resulting file should be accessible through
3340 the `org-export-stack' interface.
3342 When optional argument SUBTREEP is non-nil, export the sub-tree
3343 at point, extracting information from the headline properties
3346 When optional argument VISIBLE-ONLY is non-nil, don't export
3347 contents of hidden elements.
3349 When optional argument BODY-ONLY is non-nil, only write code
3350 between \"<body>\" and \"</body>\" tags.
3352 EXT-PLIST, when provided, is a property list with external
3353 parameters overriding Org default settings, but still inferior to
3354 file-local settings.
3356 Return output file's name."
3358 (let* ((extension (concat "." org-html-extension
))
3359 (file (org-export-output-file-name extension subtreep
))
3360 (org-export-coding-system org-html-coding-system
))
3362 (org-export-async-start
3363 (lambda (f) (org-export-add-to-stack f
'html
))
3364 (let ((org-export-coding-system org-html-coding-system
))
3367 'html
,file
,subtreep
,visible-only
,body-only
',ext-plist
))))
3368 (let ((org-export-coding-system org-html-coding-system
))
3370 'html file subtreep visible-only body-only ext-plist
)))))
3373 (defun org-html-publish-to-html (plist filename pub-dir
)
3374 "Publish an org file to HTML.
3376 FILENAME is the filename of the Org file to be published. PLIST
3377 is the property list for the given project. PUB-DIR is the
3378 publishing directory.
3380 Return output file name."
3381 (org-publish-org-to 'html filename
3382 (concat "." (or (plist-get plist
:html-extension
)
3383 org-html-extension
"html"))
3389 ;;;; org-format-table-html
3390 ;;;; org-format-org-table-html
3391 ;;;; org-format-table-table-html
3392 ;;;; org-table-number-fraction
3393 ;;;; org-table-number-regexp
3394 ;;;; org-html-inline-image-extensions
3395 ;;;; org-export-preferred-target-alist
3396 ;;;; class for anchors
3397 ;;;; org-export-mark-todo-in-toc
3398 ;;;; org-html-format-org-link
3399 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
3400 ;;;; alt = (file-name-nondirectory path)
3405 ;; generated-autoload-file: "org-loaddefs.el"
3408 ;;; ox-html.el ends here