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
))
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
"HTML_HTML5_FANCY" nil 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
"HTML_INCLUDE_STYLE" nil org-html-head-include-default-style newline
)
128 (:html-head-include-scripts
"HTML_INCLUDE_SCRIPTS" nil org-html-head-include-scripts newline
)
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 "When exporting to HTML5, set this to t to use new HTML5
923 elements. This variable is ignored for anything other than
926 For compatibility with Internet Explorer, it's probably a good
927 idea to download some form of the html5shiv (for instance
928 https://code.google.com/p/html5shiv/) and add it to your
929 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
930 versions 8 and below."
931 :group
'org-export-html
933 :package-version
'(Org .
"8.0")
936 (defcustom org-html-container-element
"div"
937 "HTML element to use for wrapping top level sections.
938 Can be set with the in-buffer HTML_CONTAINER property or for
939 publishing, with :html-container.
941 Note that changing the default will prevent you from using
942 org-info.js for your website."
943 :group
'org-export-html
945 :package-version
'(Org .
"8.0")
948 (defcustom org-html-divs
949 '((preamble "div" "preamble")
950 (content "div" "content")
951 (postamble "div" "postamble"))
952 "Alist of the three section elements for HTML export.
953 The car of each entry is one of 'preamble, 'content or 'postamble.
954 The cdrs of each entry are the ELEMENT_TYPE and ID for each
955 section of the exported document.
957 Note that changing the default will prevent you from using
958 org-info.js for your website."
959 :group
'org-export-html
961 :package-version
'(Org .
"8.0")
962 :type
'(list :greedy t
963 (list :tag
"Preamble"
964 (const :format
"" preamble
)
965 (string :tag
"element") (string :tag
" id"))
967 (const :format
"" content
)
968 (string :tag
"element") (string :tag
" id"))
969 (list :tag
"Postamble" (const :format
"" postamble
)
970 (string :tag
" id") (string :tag
"element"))))
972 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
973 "Format used for timestamps in preamble, postamble and metadata.
974 See `format-time-string' for more information on its components."
975 :group
'org-export-html
977 :package-version
'(Org .
"8.0")
980 ;;;; Template :: Mathjax
982 (defcustom org-html-mathjax-options
983 '((path "http://orgmode.org/mathjax/MathJax.js")
988 "Options for MathJax setup.
990 path The path where to find MathJax
991 scale Scaling for the HTML-CSS backend, usually between 100 and 133
992 align How to align display math: left, center, or right
993 indent If align is not center, how far from the left/right side?
994 mathml Should a MathML player be used if available?
995 This is faster and reduces bandwidth use, but currently
996 sometimes has lower spacing quality. Therefore, the default is
997 nil. When browsers get better, this switch can be flipped.
999 You can also customize this for each buffer, using something like
1001 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
1002 :group
'org-export-html
1003 :type
'(list :greedy t
1004 (list :tag
"path (the path from where to load MathJax.js)"
1005 (const :format
" " path
) (string))
1006 (list :tag
"scale (scaling for the displayed math)"
1007 (const :format
" " scale
) (string))
1008 (list :tag
"align (alignment of displayed equations)"
1009 (const :format
" " align
) (string))
1010 (list :tag
"indent (indentation with left or right alignment)"
1011 (const :format
" " indent
) (string))
1012 (list :tag
"mathml (should MathML display be used is possible)"
1013 (const :format
" " mathml
) (boolean))))
1015 (defcustom org-html-mathjax-template
1016 "<script type=\"text/javascript\" src=\"%PATH\"></script>
1017 <script type=\"text/javascript\">
1018 <!--/*--><![CDATA[/*><!--*/
1019 MathJax.Hub.Config({
1020 // Only one of the two following lines, depending on user settings
1021 // First allows browser-native MathML display, second forces HTML/CSS
1022 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
1023 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
1024 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
1025 \"TeX/noUndefined.js\"],
1027 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
1028 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
1029 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
1030 ignoreClass: \"tex2jax_ignore\",
1031 processEscapes: false,
1032 processEnvironments: true,
1035 showProcessingMessages: true,
1036 displayAlign: \"%ALIGN\",
1037 displayIndent: \"%INDENT\",
1041 availableFonts: [\"STIX\",\"TeX\"],
1042 preferredFont: \"TeX\",
1058 "The MathJax setup for XHTML files."
1059 :group
'org-export-html
1062 ;;;; Template :: Postamble
1064 (defcustom org-html-postamble
'auto
1065 "Non-nil means insert a postamble in HTML export.
1067 When set to 'auto, check against the
1068 `org-export-with-author/email/creator/date' variables to set the
1069 content of the postamble. When set to a string, use this string
1070 as the postamble. When t, insert a string as defined by the
1071 formatting string in `org-html-postamble-format'.
1073 When set to a function, apply this function and insert the
1074 returned string. The function takes the property list of export
1075 options as its only argument.
1077 Setting :html-postamble in publishing projects will take
1078 precedence over this variable."
1079 :group
'org-export-html
1080 :type
'(choice (const :tag
"No postamble" nil
)
1081 (const :tag
"Auto postamble" auto
)
1082 (const :tag
"Default formatting string" t
)
1083 (string :tag
"Custom formatting string")
1084 (function :tag
"Function (must return a string)")))
1086 (defcustom org-html-postamble-format
1087 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1088 <p class=\"date\">Date: %d</p>
1089 <p class=\"creator\">%c</p>
1090 <p class=\"validation\">%v</p>"))
1091 "Alist of languages and format strings for the HTML postamble.
1093 The first element of each list is the language code, as used for
1094 the LANGUAGE keyword. See `org-export-default-language'.
1096 The second element of each list is a format string to format the
1097 postamble itself. This format string can contain these elements:
1099 %t stands for the title.
1100 %a stands for the author's name.
1101 %e stands for the author's email.
1102 %d stands for the date.
1103 %c will be replaced by `org-html-creator-string'.
1104 %v will be replaced by `org-html-validation-link'.
1105 %T will be replaced by the export time.
1106 %C will be replaced by the last modification time.
1108 If you need to use a \"%\" character, you need to escape it
1110 :group
'org-export-html
1112 (list (string :tag
"Language")
1113 (string :tag
"Format string"))))
1115 (defcustom org-html-validation-link
1116 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1117 "Link to HTML validation service."
1118 :group
'org-export-html
1121 (defcustom org-html-creator-string
1122 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1124 (if (fboundp 'org-version
) (org-version) "unknown version"))
1125 "Information about the creator of the HTML document.
1126 This option can also be set on with the CREATOR keyword."
1127 :group
'org-export-html
1128 :type
'(string :tag
"Creator string"))
1130 ;;;; Template :: Preamble
1132 (defcustom org-html-preamble t
1133 "Non-nil means insert a preamble in HTML export.
1135 When t, insert a string as defined by the formatting string in
1136 `org-html-preamble-format'. When set to a string, use this
1137 formatting string instead (see `org-html-postamble-format' for an
1138 example of such a formatting string).
1140 When set to a function, apply this function and insert the
1141 returned string. The function takes the property list of export
1142 options as its only argument.
1144 Setting :html-preamble in publishing projects will take
1145 precedence over this variable."
1146 :group
'org-export-html
1147 :type
'(choice (const :tag
"No preamble" nil
)
1148 (const :tag
"Default preamble" t
)
1149 (string :tag
"Custom formatting string")
1150 (function :tag
"Function (must return a string)")))
1152 (defcustom org-html-preamble-format
'(("en" ""))
1153 "Alist of languages and format strings for the HTML preamble.
1155 The first element of each list is the language code, as used for
1156 the LANGUAGE keyword. See `org-export-default-language'.
1158 The second element of each list is a format string to format the
1159 preamble itself. This format string can contain these elements:
1161 %t stands for the title.
1162 %a stands for the author's name.
1163 %e stands for the author's email.
1164 %d stands for the date.
1165 %c will be replaced by `org-html-creator-string'.
1166 %v will be replaced by `org-html-validation-link'.
1167 %T will be replaced by the export time.
1168 %C will be replaced by the last modification time.
1170 If you need to use a \"%\" character, you need to escape it
1173 See the default value of `org-html-postamble-format' for an
1175 :group
'org-export-html
1177 (list (string :tag
"Language")
1178 (string :tag
"Format string"))))
1180 (defcustom org-html-link-up
""
1181 "Where should the \"UP\" link of exported HTML pages lead?"
1182 :group
'org-export-html
1183 :type
'(string :tag
"File or URL"))
1185 (defcustom org-html-link-home
""
1186 "Where should the \"HOME\" link of exported HTML pages lead?"
1187 :group
'org-export-html
1188 :type
'(string :tag
"File or URL"))
1190 (defcustom org-html-home
/up-format
1191 "<div id=\"org-div-home-and-up\">
1192 <a accesskey=\"h\" href=\"%s\"> UP </a>
1194 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1196 "Snippet used to insert the HOME and UP links.
1197 This is a format string, the first %s will receive the UP link,
1198 the second the HOME link. If both `org-html-link-up' and
1199 `org-html-link-home' are empty, the entire snippet will be
1201 :group
'org-export-html
1204 ;;;; Template :: Scripts
1206 (define-obsolete-variable-alias
1207 'org-html-style-include-scripts
'org-html-head-include-scripts
"24.4")
1208 (defcustom org-html-head-include-scripts t
1209 "Non-nil means include the JavaScript snippets in exported HTML files.
1210 The actual script is defined in `org-html-scripts' and should
1212 :group
'org-export-html
1214 :package-version
'(Org .
"8.0")
1217 ;;;; Template :: Styles
1219 (define-obsolete-variable-alias
1220 'org-html-style-include-default
'org-html-head-include-default-style
"24.4")
1221 (defcustom org-html-head-include-default-style t
1222 "Non-nil means include the default style in exported HTML files.
1223 The actual style is defined in `org-html-style-default' and
1224 should not be modified. Use `org-html-head' to use your own
1226 :group
'org-export-html
1228 :package-version
'(Org .
"8.0")
1231 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1233 (define-obsolete-variable-alias 'org-html-style
'org-html-head
"24.4")
1234 (defcustom org-html-head
""
1235 "Org-wide head definitions for exported HTML files.
1237 This variable can contain the full HTML structure to provide a
1238 style, including the surrounding HTML tags. You can consider
1239 including definitions for the following classes: title, todo,
1240 done, timestamp, timestamp-kwd, tag, target.
1242 For example, a valid value would be:
1244 <style type=\"text/css\">
1246 p { font-weight: normal; color: gray; }
1247 h1 { color: black; }
1248 .title { text-align: center; }
1249 .todo, .timestamp-kwd { color: red; }
1250 .done { color: green; }
1254 If you want to refer to an external style, use something like
1256 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1258 As the value of this option simply gets inserted into the HTML
1259 <head> header, you can use it to add any arbitrary text to the
1262 You can set this on a per-file basis using #+HTML_HEAD:,
1263 or for publication projects using the :html-head property."
1264 :group
'org-export-html
1266 :package-version
'(Org .
"8.0")
1269 (put 'org-html-head
'safe-local-variable
'stringp
)
1271 (defcustom org-html-head-extra
""
1272 "More head information to add in the HTML output.
1274 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1275 or for publication projects using the :html-head-extra property."
1276 :group
'org-export-html
1278 :package-version
'(Org .
"8.0")
1281 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1285 (defcustom org-html-todo-kwd-class-prefix
""
1286 "Prefix to class names for TODO keywords.
1287 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1288 The default prefix is empty because it is nice to just use the keyword
1289 as a class name. But if you get into conflicts with other, existing
1290 CSS classes, then this prefix can be very useful."
1291 :group
'org-export-html
1295 ;;; Internal Functions
1297 (defun org-html-xhtml-p (info)
1298 (let ((dt (downcase (plist-get info
:html-doctype
))))
1299 (string-match-p "xhtml" dt
)))
1301 (defun org-html-html5-p (info)
1302 (let ((dt (downcase (plist-get info
:html-doctype
))))
1303 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1305 (defun org-html-close-tag (tag attr info
)
1306 (concat "<" tag
" " attr
1307 (if (org-html-xhtml-p info
) " />" ">")))
1309 (defun org-html--make-attribute-string (attributes)
1310 "Return a list of attributes, as a string.
1311 ATTRIBUTES is a plist where values are either strings or nil. An
1312 attributes with a nil value will be omitted from the result."
1314 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1315 (cond ((null item
) (pop output
))
1316 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1317 (t (let ((key (car output
))
1318 (value (replace-regexp-in-string
1319 "\"" """ (org-html-encode-plain-text item
))))
1320 (setcar output
(format "%s=\"%s\"" key value
))))))))
1322 (defun org-html-format-inline-image (src info
&optional
1323 caption label attr standalone-p
)
1324 "Format an inline image from SRC.
1325 CAPTION, LABEL and ATTR are optional arguments providing the
1326 caption, the label and the attribute of the image.
1327 When STANDALONE-P is t, wrap the <img.../> into a <div>...</div>."
1328 (let* ((id (if (not label
) ""
1329 (format " id=\"%s\"" (org-export-solidify-link-text label
))))
1331 (format " src=\"%s\"" src
)
1333 ((string-match "\\<alt=" (or attr
"")) "")
1334 ((string-match "^ltxpng/" src
)
1335 (format " alt=\"%s\""
1336 (org-html-encode-plain-text
1337 (org-find-text-property-in-string
1338 'org-latex-src src
))))
1339 (t (format " alt=\"%s\""
1340 (file-name-nondirectory src
))))))
1341 (html5-fancy (and (org-html-html5-p info
)
1342 (plist-get info
:html-html5-fancy
))))
1345 (let ((img (org-html-close-tag "img" attr info
)))
1346 (format (if html5-fancy
1347 "\n<figure%s>%s%s\n</figure>"
1348 "\n<div%s class=\"figure\">%s%s\n</div>")
1349 id
(format "\n<p>%s</p>" img
)
1350 (if (and caption
(not (string= caption
"")))
1351 (format (if html5-fancy
1352 "\n<figcaption>%s</figcaption>"
1353 "\n<p>%s</p>") caption
) ""))))
1354 (t (org-html-close-tag "img" (concat attr id
) info
)))))
1356 (defun org-html--textarea-block (element)
1357 "Transcode ELEMENT into a textarea block.
1358 ELEMENT is either a src block or an example block."
1359 (let* ((code (car (org-export-unravel-code element
)))
1360 (attr (org-export-read-attribute :attr_html element
)))
1361 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1362 (or (plist-get attr
:width
) 80)
1363 (or (plist-get attr
:height
) (org-count-lines code
))
1368 (defun org-html-htmlize-region-for-paste (beg end
)
1369 "Convert the region between BEG and END to HTML, using htmlize.el.
1370 This is much like `htmlize-region-for-paste', only that it uses
1371 the settings define in the org-... variables."
1372 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1373 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1374 (htmlbuf (htmlize-region beg end
)))
1376 (with-current-buffer htmlbuf
1377 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1378 (plist-get htmlize-buffer-places
'content-end
)))
1379 (kill-buffer htmlbuf
))))
1382 (defun org-html-htmlize-generate-css ()
1383 "Create the CSS for all font definitions in the current Emacs session.
1384 Use this to create face definitions in your CSS style file that can then
1385 be used by code snippets transformed by htmlize.
1386 This command just produces a buffer that contains class definitions for all
1387 faces used in the current Emacs session. You can copy and paste the ones you
1388 need into your CSS file.
1390 If you then set `org-html-htmlize-output-type' to `css', calls
1391 to the function `org-html-htmlize-region-for-paste' will
1392 produce code that uses these same face definitions."
1395 (and (get-buffer "*html*") (kill-buffer "*html*"))
1397 (let ((fl (face-list))
1398 (htmlize-css-name-prefix "org-")
1399 (htmlize-output-type 'css
)
1401 (while (setq f
(pop fl
)
1402 i
(and f
(face-attribute f
:inherit
)))
1403 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1404 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1405 (htmlize-region (point-min) (point-max))))
1406 (org-pop-to-buffer-same-window "*html*")
1407 (goto-char (point-min))
1408 (if (re-search-forward "<style" nil t
)
1409 (delete-region (point-min) (match-beginning 0)))
1410 (if (re-search-forward "</style>" nil t
)
1411 (delete-region (1+ (match-end 0)) (point-max)))
1412 (beginning-of-line 1)
1413 (if (looking-at " +") (replace-match ""))
1414 (goto-char (point-min)))
1416 (defun org-html--make-string (n string
)
1417 "Build a string by concatenating N times STRING."
1418 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1420 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1421 "Turn todo keyword KWD into a valid class name.
1422 Replaces invalid characters with \"_\"."
1424 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1425 (setq kwd
(replace-match "_" t t kwd
))))
1428 (defun org-html-format-footnote-reference (n def refcnt
)
1429 "Format footnote reference N with definition DEF into HTML."
1430 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1431 (format org-html-footnote-format
1432 (let* ((id (format "fnr.%s%s" n extra
))
1433 (href (format " href=\"#fn.%s\"" n
))
1434 (attributes (concat " class=\"footref\"" href
)))
1435 (org-html--anchor id n attributes
)))))
1437 (defun org-html-format-footnotes-section (section-name definitions
)
1438 "Format footnotes section SECTION-NAME."
1439 (if (not definitions
) ""
1440 (format org-html-footnotes-section section-name definitions
)))
1442 (defun org-html-format-footnote-definition (fn)
1443 "Format the footnote definition FN."
1444 (let ((n (car fn
)) (def (cdr fn
)))
1446 "<div class=\"footdef\">%s %s</div>\n"
1447 (format org-html-footnote-format
1448 (let* ((id (format "fn.%s" n
))
1449 (href (format " href=\"#fnr.%s\"" n
))
1450 (attributes (concat " class=\"footnum\"" href
)))
1451 (org-html--anchor id n attributes
)))
1454 (defun org-html-footnote-section (info)
1455 "Format the footnote section.
1456 INFO is a plist used as a communication channel."
1457 (let* ((fn-alist (org-export-collect-footnote-definitions
1458 (plist-get info
:parse-tree
) info
))
1460 (loop for
(n type raw
) in fn-alist collect
1461 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1462 (org-trim (org-export-data raw info
))
1464 (org-trim (org-export-data raw info
))))))))
1466 (org-html-format-footnotes-section
1467 (org-html--translate "Footnotes" info
)
1470 (mapconcat 'org-html-format-footnote-definition fn-alist
"\n"))))))
1475 (defun org-html--build-meta-info (info)
1476 "Return meta tags for exported document.
1477 INFO is a plist used as a communication channel."
1478 (let ((protect-string
1480 (replace-regexp-in-string
1481 "\"" """ (org-html-encode-plain-text str
))))
1482 (title (org-export-data (plist-get info
:title
) info
))
1483 (author (and (plist-get info
:with-author
)
1484 (let ((auth (plist-get info
:author
)))
1486 ;; Return raw Org syntax, skipping non
1487 ;; exportable objects.
1488 (org-element-interpret-data
1489 (org-element-map auth
1490 (cons 'plain-text org-element-all-objects
)
1491 'identity info
))))))
1492 (description (plist-get info
:description
))
1493 (keywords (plist-get info
:keywords
))
1494 (charset (or (and org-html-coding-system
1495 (fboundp 'coding-system-get
)
1496 (coding-system-get org-html-coding-system
1500 (format "<title>%s</title>\n" title
)
1502 (when :time-stamp-file
1504 (concat "<!-- " org-html-metadata-timestamp-format
" -->\n"))))
1506 (if (org-html-html5-p info
)
1507 (org-html-close-tag "meta" " charset=\"%s\"" info
)
1509 "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1512 (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info
)
1514 (and (org-string-nw-p author
)
1515 (org-html-close-tag "meta"
1516 (format " name=\"author\" content=\"%s\""
1517 (funcall protect-string author
))
1520 (and (org-string-nw-p description
)
1521 (org-html-close-tag "meta"
1522 (format " name=\"description\" content=\"%s\"\n"
1523 (funcall protect-string description
))
1526 (and (org-string-nw-p keywords
)
1527 (org-html-close-tag "meta"
1528 (format " name=\"keywords\" content=\"%s\""
1529 (funcall protect-string keywords
))
1533 (defun org-html--build-head (info)
1534 "Return information for the <head>..</head> of the HTML output.
1535 INFO is a plist used as a communication channel."
1536 (org-element-normalize-string
1538 (when (plist-get info
:html-head-include-default-style
)
1539 (org-element-normalize-string org-html-style-default
))
1540 (org-element-normalize-string (plist-get info
:html-head
))
1541 (org-element-normalize-string (plist-get info
:html-head-extra
))
1542 (when (and (plist-get info
:html-htmlized-css-url
)
1543 (eq org-html-htmlize-output-type
'css
))
1544 (org-html-close-tag "link"
1545 (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1546 (plist-get info
:html-htmlized-css-url
))
1548 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1550 (defun org-html--build-mathjax-config (info)
1551 "Insert the user setup into the mathjax template.
1552 INFO is a plist used as a communication channel."
1553 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1554 (org-element-map (plist-get info
:parse-tree
)
1555 '(latex-fragment latex-environment
) 'identity info t
))
1556 (let ((template org-html-mathjax-template
)
1557 (options org-html-mathjax-options
)
1558 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1559 name val
(yes " ") (no "// ") x
)
1562 (setq name
(car e
) val
(nth 1 e
))
1563 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1564 (setq val
(car (read-from-string
1565 (substring in-buffer
(match-end 0))))))
1566 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1567 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1568 (setq template
(replace-match val t t template
))))
1570 (setq val
(nth 1 (assq 'mathml options
)))
1571 (if (string-match (concat "\\<mathml:") in-buffer
)
1572 (setq val
(car (read-from-string
1573 (substring in-buffer
(match-end 0))))))
1574 ;; Exchange prefixes depending on mathml setting.
1575 (if (not val
) (setq x yes yes no no x
))
1576 ;; Replace cookies to turn on or off the config/jax lines.
1577 (if (string-match ":MMLYES:" template
)
1578 (setq template
(replace-match yes t t template
)))
1579 (if (string-match ":MMLNO:" template
)
1580 (setq template
(replace-match no t t template
)))
1581 ;; Return the modified template.
1582 (org-element-normalize-string template
))))
1584 (defun org-html-format-spec (info)
1585 "Return format specification for elements that can be
1586 used in the preamble or postamble."
1587 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1588 (?d .
,(org-export-data (org-export-get-date info
) info
))
1589 (?T .
,(format-time-string org-html-metadata-timestamp-format
))
1590 (?a .
,(org-export-data (plist-get info
:author
) info
))
1593 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1594 (split-string (plist-get info
:email
) ",+ *")
1596 (?c .
,(plist-get info
:creator
))
1597 (?C .
,(let ((file (plist-get info
:input-file
)))
1598 (format-time-string org-html-metadata-timestamp-format
1599 (if file
(nth 5 (file-attributes file
))
1601 (?v .
,(or org-html-validation-link
""))))
1603 (defun org-html--build-pre/postamble
(type info
)
1604 "Return document preamble or postamble as a string, or nil.
1605 TYPE is either 'preamble or 'postamble, INFO is a plist used as a
1606 communication channel."
1607 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1608 (spec (org-html-format-spec info
)))
1610 (let ((section-contents
1611 (if (functionp section
) (funcall section info
)
1613 ((stringp section
) (format-spec section spec
))
1615 (let ((date (cdr (assq ?d spec
)))
1616 (author (cdr (assq ?a spec
)))
1617 (email (cdr (assq ?e spec
)))
1618 (creator (cdr (assq ?c spec
)))
1619 (timestamp (cdr (assq ?T spec
)))
1620 (validation-link (cdr (assq ?v spec
))))
1622 (when (and (plist-get info
:with-date
)
1623 (org-string-nw-p date
))
1624 (format "<p class=\"date\">%s: %s</p>\n"
1625 (org-html--translate "Date" info
)
1627 (when (and (plist-get info
:with-author
)
1628 (org-string-nw-p author
))
1629 (format "<p class=\"author\">%s: %s</p>\n"
1630 (org-html--translate "Author" info
)
1632 (when (and (plist-get info
:with-email
)
1633 (org-string-nw-p email
))
1634 (format "<p class=\"email\">%s: %s</p>\n"
1635 (org-html--translate "Email" info
)
1637 (when (plist-get info
:time-stamp-file
)
1639 "<p class=\"date\">%s: %s</p>\n"
1640 (org-html--translate "Created" info
)
1641 (format-time-string org-html-metadata-timestamp-format
)))
1642 (when (plist-get info
:with-creator
)
1643 (format "<p class=\"creator\">%s</p>\n" creator
))
1644 (format "<p class=\"validation\">%s</p>\n"
1648 (plist-get info
:language
)
1650 (format "org-html-%s-format" type
)))))
1655 (intern (format "org-html-%s-format" type
))))))
1657 (when (org-string-nw-p section-contents
)
1659 (format "<%s id=\"%s\" class=\"%s\">\n"
1660 (nth 1 (assq type org-html-divs
))
1661 (nth 2 (assq type org-html-divs
))
1662 org-html--pre
/postamble-class
)
1663 (org-element-normalize-string section-contents
)
1664 (format "</%s>\n" (nth 1 (assq type org-html-divs
)))))))))
1666 (defun org-html-inner-template (contents info
)
1667 "Return body of document string after HTML conversion.
1668 CONTENTS is the transcoded contents string. INFO is a plist
1669 holding export options."
1671 ;; Table of contents.
1672 (let ((depth (plist-get info
:with-toc
)))
1673 (when depth
(org-html-toc depth info
)))
1674 ;; Document contents.
1676 ;; Footnotes section.
1677 (org-html-footnote-section info
)))
1679 (defun org-html-template (contents info
)
1680 "Return complete document string after HTML conversion.
1681 CONTENTS is the transcoded contents string. INFO is a plist
1682 holding export options."
1684 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1685 (let ((decl (or (and (stringp org-html-xml-declaration
)
1686 org-html-xml-declaration
)
1687 (cdr (assoc (plist-get info
:html-extension
)
1688 org-html-xml-declaration
))
1689 (cdr (assoc "html" org-html-xml-declaration
))
1692 (when (not (or (eq nil decl
) (string= "" decl
)))
1695 (or (and org-html-coding-system
1696 (fboundp 'coding-system-get
)
1697 (coding-system-get org-html-coding-system
'mime-charset
))
1699 (let* ((dt (plist-get info
:html-doctype
))
1700 (dt-cons (assoc dt org-html-doctype-alist
)))
1706 (when (org-html-xhtml-p info
)
1708 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1709 (plist-get info
:language
) (plist-get info
:language
)))
1712 (org-html--build-meta-info info
)
1713 (org-html--build-head info
)
1714 (org-html--build-mathjax-config info
)
1717 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1718 (link-home (org-trim (plist-get info
:html-link-home
))))
1719 (unless (and (string= link-up
"") (string= link-up
""))
1720 (format org-html-home
/up-format
1721 (or link-up link-home
)
1722 (or link-home link-up
))))
1724 (org-html--build-pre/postamble
'preamble info
)
1725 ;; Document contents.
1726 (format "<%s id=\"%s\">\n"
1727 (nth 1 (assq 'content org-html-divs
))
1728 (nth 2 (assq 'content org-html-divs
)))
1730 (let ((title (plist-get info
:title
)))
1731 (format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title
"") info
)))
1734 (nth 1 (assq 'content org-html-divs
)))
1736 (org-html--build-pre/postamble
'postamble info
)
1737 ;; Closing document.
1738 "</body>\n</html>"))
1740 (defun org-html--translate (s info
)
1741 "Translate string S according to specified language.
1742 INFO is a plist used as a communication channel."
1743 (org-export-translate s
:html info
))
1747 (defun org-html--anchor (&optional id desc attributes
)
1748 "Format a HTML anchor."
1749 (let* ((name (and org-html-allow-name-attribute-in-anchors id
))
1750 (attributes (concat (and id
(format " id=\"%s\"" id
))
1751 (and name
(format " name=\"%s\"" name
))
1753 (format "<a%s>%s</a>" attributes
(or desc
""))))
1757 (defun org-html--todo (todo)
1758 "Format TODO keywords into HTML."
1760 (format "<span class=\"%s %s%s\">%s</span>"
1761 (if (member todo org-done-keywords
) "done" "todo")
1762 org-html-todo-kwd-class-prefix
(org-html-fix-class-name todo
)
1767 (defun org-html--tags (tags)
1768 "Format TAGS into HTML."
1770 (format "<span class=\"tag\">%s</span>"
1773 (format "<span class=\"%s\">%s</span>"
1774 (concat org-html-tag-class-prefix
1775 (org-html-fix-class-name tag
))
1781 (defun* org-html-format-headline
1782 (todo todo-type priority text tags
1783 &key level section-number headline-label
&allow-other-keys
)
1784 "Format a headline in HTML."
1785 (let ((section-number
1786 (when section-number
1787 (format "<span class=\"section-number-%d\">%s</span> "
1788 level section-number
)))
1789 (todo (org-html--todo todo
))
1790 (tags (org-html--tags tags
)))
1791 (concat section-number todo
(and todo
" ") text
1792 (and tags
"   ") tags
)))
1796 (defun org-html-fontify-code (code lang
)
1797 "Color CODE with htmlize library.
1798 CODE is a string representing the source code to colorize. LANG
1799 is the language used for CODE, as a string, or nil."
1802 ;; Case 1: No lang. Possibly an example block.
1804 ;; Simple transcoding.
1805 (org-html-encode-plain-text code
))
1806 ;; Case 2: No htmlize or an inferior version of htmlize
1807 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1809 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1810 ;; Simple transcoding.
1811 (org-html-encode-plain-text code
))
1814 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1815 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1817 ;; Case 1: Language is not associated with any Emacs mode
1818 ((not (functionp lang-mode
))
1819 ;; Simple transcoding.
1820 (org-html-encode-plain-text code
))
1821 ;; Case 2: Default. Fontify code.
1824 (setq code
(with-temp-buffer
1825 ;; Switch to language-specific mode.
1829 (font-lock-fontify-buffer)
1830 ;; Remove formatting on newline characters.
1832 (let ((beg (point-min))
1835 (while (progn (end-of-line) (< (point) end
))
1836 (put-text-property (point) (1+ (point)) 'face nil
)
1839 (set-buffer-modified-p nil
)
1841 (org-html-htmlize-region-for-paste
1842 (point-min) (point-max))))
1843 ;; Strip any enclosing <pre></pre> tags.
1844 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
1845 (end (and beg
(string-match "</pre>\\'" code
))))
1846 (if (and beg end
) (substring code beg end
) code
)))))))))
1848 (defun org-html-do-format-code
1849 (code &optional lang refs retain-labels num-start
)
1850 "Format CODE string as source code.
1851 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1852 respectively, the language of the source code, as a string, an
1853 alist between line numbers and references (as returned by
1854 `org-export-unravel-code'), a boolean specifying if labels should
1855 appear in the source code, and the number associated to the first
1857 (let* ((code-lines (org-split-string code
"\n"))
1858 (code-length (length code-lines
))
1862 (length (number-to-string (+ code-length num-start
))))))
1863 (code (org-html-fontify-code code lang
)))
1864 (org-export-format-code
1866 (lambda (loc line-num ref
)
1869 ;; Add line number, if needed.
1871 (format "<span class=\"linenr\">%s</span>"
1872 (format num-fmt line-num
)))
1873 ;; Transcoded src line.
1875 ;; Add label, if needed.
1876 (when (and ref retain-labels
) (format " (%s)" ref
))))
1877 ;; Mark transcoded line as an anchor, if needed.
1879 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1883 (defun org-html-format-code (element info
)
1884 "Format contents of ELEMENT as source code.
1885 ELEMENT is either an example block or a src block. INFO is
1886 a plist used as a communication channel."
1887 (let* ((lang (org-element-property :language element
))
1888 ;; Extract code and references.
1889 (code-info (org-export-unravel-code element
))
1890 (code (car code-info
))
1891 (refs (cdr code-info
))
1892 ;; Does the src block contain labels?
1893 (retain-labels (org-element-property :retain-labels element
))
1894 ;; Does it have line numbers?
1895 (num-start (case (org-element-property :number-lines element
)
1896 (continued (org-export-get-loc element info
))
1898 (org-html-do-format-code code lang refs retain-labels num-start
)))
1901 ;;; Tables of Contents
1903 (defun org-html-toc (depth info
)
1904 "Build a table of contents.
1905 DEPTH is an integer specifying the depth of the table. INFO is a
1906 plist used as a communication channel. Return the table of
1907 contents as a string, or nil if it is empty."
1909 (mapcar (lambda (headline)
1910 (cons (org-html--format-toc-headline headline info
)
1911 (org-export-get-relative-level headline info
)))
1912 (org-export-collect-headlines info depth
))))
1914 (concat "<div id=\"table-of-contents\">\n"
1915 (format "<h%d>%s</h%d>\n"
1916 org-html-toplevel-hlevel
1917 (org-html--translate "Table of Contents" info
)
1918 org-html-toplevel-hlevel
)
1919 "<div id=\"text-table-of-contents\">"
1920 (org-html--toc-text toc-entries
)
1924 (defun org-html--toc-text (toc-entries)
1925 "Return innards of a table of contents, as a string.
1926 TOC-ENTRIES is an alist where key is an entry title, as a string,
1927 and value is its relative level, as an integer."
1928 (let* ((prev-level (1- (cdar toc-entries
)))
1929 (start-level prev-level
))
1933 (let ((headline (car entry
))
1934 (level (cdr entry
)))
1936 (let* ((cnt (- level prev-level
))
1937 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1939 (setq prev-level level
)
1941 (org-html--make-string
1942 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1943 ((< cnt
0) "</li>\n</ul>\n")))
1944 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1947 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
1949 (defun org-html--format-toc-headline (headline info
)
1950 "Return an appropriate table of contents entry for HEADLINE.
1951 INFO is a plist used as a communication channel."
1952 (let* ((headline-number (org-export-get-headline-number headline info
))
1954 (and (not (org-export-low-level-p headline info
))
1955 (org-export-numbered-headline-p headline info
)
1956 (concat (mapconcat 'number-to-string headline-number
".") ". ")))
1957 (tags (and (eq (plist-get info
:with-tags
) t
)
1958 (org-export-get-tags headline info
))))
1959 (format "<a href=\"#%s\">%s</a>"
1961 (org-export-solidify-link-text
1962 (or (org-element-property :CUSTOM_ID headline
)
1963 (concat "sec-" (mapconcat 'number-to-string
1964 headline-number
"-"))))
1966 (concat section-number
1967 (org-export-data-with-translations
1968 (org-export-get-alt-title headline info
)
1969 ;; Ignore any footnote-reference, link,
1970 ;; radio-target and target in table of contents.
1972 '((footnote-reference . ignore
)
1973 (link .
(lambda (link desc i
) desc
))
1974 (radio-target .
(lambda (radio desc i
) desc
))
1976 (org-export-backend-translate-table 'html
))
1978 (and tags
"   ") (org-html--tags tags
)))))
1980 (defun org-html-list-of-listings (info)
1981 "Build a list of listings.
1982 INFO is a plist used as a communication channel. Return the list
1983 of listings as a string, or nil if it is empty."
1984 (let ((lol-entries (org-export-collect-listings info
)))
1986 (concat "<div id=\"list-of-listings\">\n"
1987 (format "<h%d>%s</h%d>\n"
1988 org-html-toplevel-hlevel
1989 (org-html--translate "List of Listings" info
)
1990 org-html-toplevel-hlevel
)
1991 "<div id=\"text-list-of-listings\">\n<ul>\n"
1993 (initial-fmt (org-html--translate "Listing %d:" info
)))
1996 (let ((label (org-element-property :name entry
))
1999 (or (org-export-get-caption entry t
)
2000 (org-export-get-caption entry
))
2005 (concat (format initial-fmt
(incf count
)) " " title
)
2006 (format "<a href=\"#%s\">%s %s</a>"
2007 (org-export-solidify-link-text label
)
2008 (format initial-fmt
(incf count
))
2012 "\n</ul>\n</div>\n</div>"))))
2014 (defun org-html-list-of-tables (info)
2015 "Build a list of tables.
2016 INFO is a plist used as a communication channel. Return the list
2017 of tables as a string, or nil if it is empty."
2018 (let ((lol-entries (org-export-collect-tables info
)))
2020 (concat "<div id=\"list-of-tables\">\n"
2021 (format "<h%d>%s</h%d>\n"
2022 org-html-toplevel-hlevel
2023 (org-html--translate "List of Tables" info
)
2024 org-html-toplevel-hlevel
)
2025 "<div id=\"text-list-of-tables\">\n<ul>\n"
2027 (initial-fmt (org-html--translate "Table %d:" info
)))
2030 (let ((label (org-element-property :name entry
))
2033 (or (org-export-get-caption entry t
)
2034 (org-export-get-caption entry
))
2039 (concat (format initial-fmt
(incf count
)) " " title
)
2040 (format "<a href=\"#%s\">%s %s</a>"
2041 (org-export-solidify-link-text label
)
2042 (format initial-fmt
(incf count
))
2046 "\n</ul>\n</div>\n</div>"))))
2049 ;;; Transcode Functions
2053 (defun org-html-bold (bold contents info
)
2054 "Transcode BOLD from Org to HTML.
2055 CONTENTS is the text with bold markup. INFO is a plist holding
2056 contextual information."
2057 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
2062 (defun org-html-center-block (center-block contents info
)
2063 "Transcode a CENTER-BLOCK element from Org to HTML.
2064 CONTENTS holds the contents of the block. INFO is a plist
2065 holding contextual information."
2066 (format "<div class=\"center\">\n%s</div>" contents
))
2070 (defun org-html-clock (clock contents info
)
2071 "Transcode a CLOCK element from Org to HTML.
2072 CONTENTS is nil. INFO is a plist used as a communication
2075 <span class=\"timestamp-wrapper\">
2076 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2081 (org-element-property :raw-value
2082 (org-element-property :value clock
)))
2083 (let ((time (org-element-property :duration clock
)))
2084 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2088 (defun org-html-code (code contents info
)
2089 "Transcode CODE from Org to HTML.
2090 CONTENTS is nil. INFO is a plist holding contextual
2092 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
2093 (org-html-plain-text (org-element-property :value code
) info
)))
2097 (defun org-html-drawer (drawer contents info
)
2098 "Transcode a DRAWER element from Org to HTML.
2099 CONTENTS holds the contents of the block. INFO is a plist
2100 holding contextual information."
2101 (if (functionp org-html-format-drawer-function
)
2102 (funcall org-html-format-drawer-function
2103 (org-element-property :drawer-name drawer
)
2105 ;; If there's no user defined function: simply
2106 ;; display contents of the drawer.
2111 (defun org-html-dynamic-block (dynamic-block contents info
)
2112 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2113 CONTENTS holds the contents of the block. INFO is a plist
2114 holding contextual information. See `org-export-data'."
2119 (defun org-html-entity (entity contents info
)
2120 "Transcode an ENTITY object from Org to HTML.
2121 CONTENTS are the definition itself. INFO is a plist holding
2122 contextual information."
2123 (org-element-property :html entity
))
2127 (defun org-html-example-block (example-block contents info
)
2128 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2129 CONTENTS is nil. INFO is a plist holding contextual
2131 (if (org-export-read-attribute :attr_html example-block
:textarea
)
2132 (org-html--textarea-block example-block
)
2133 (format "<pre class=\"example\">\n%s</pre>"
2134 (org-html-format-code example-block info
))))
2138 (defun org-html-export-snippet (export-snippet contents info
)
2139 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2140 CONTENTS is nil. INFO is a plist holding contextual
2142 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2143 (org-element-property :value export-snippet
)))
2147 (defun org-html-export-block (export-block contents info
)
2148 "Transcode a EXPORT-BLOCK element from Org to HTML.
2149 CONTENTS is nil. INFO is a plist holding contextual information."
2150 (when (string= (org-element-property :type export-block
) "HTML")
2151 (org-remove-indentation (org-element-property :value export-block
))))
2155 (defun org-html-fixed-width (fixed-width contents info
)
2156 "Transcode a FIXED-WIDTH element from Org to HTML.
2157 CONTENTS is nil. INFO is a plist holding contextual information."
2158 (format "<pre class=\"example\">\n%s</pre>"
2159 (org-html-do-format-code
2160 (org-remove-indentation
2161 (org-element-property :value fixed-width
)))))
2163 ;;;; Footnote Reference
2165 (defun org-html-footnote-reference (footnote-reference contents info
)
2166 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2167 CONTENTS is nil. INFO is a plist holding contextual information."
2169 ;; Insert separator between two footnotes in a row.
2170 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2171 (when (eq (org-element-type prev
) 'footnote-reference
)
2172 org-html-footnote-separator
))
2174 ((not (org-export-footnote-first-reference-p footnote-reference info
))
2175 (org-html-format-footnote-reference
2176 (org-export-get-footnote-number footnote-reference info
)
2178 ;; Inline definitions are secondary strings.
2179 ((eq (org-element-property :type footnote-reference
) 'inline
)
2180 (org-html-format-footnote-reference
2181 (org-export-get-footnote-number footnote-reference info
)
2183 ;; Non-inline footnotes definitions are full Org data.
2184 (t (org-html-format-footnote-reference
2185 (org-export-get-footnote-number footnote-reference info
)
2190 (defun org-html-format-headline--wrap
2191 (headline info
&optional format-function
&rest extra-keys
)
2192 "Transcode a HEADLINE element from Org to HTML.
2193 CONTENTS holds the contents of the headline. INFO is a plist
2194 holding contextual information."
2195 (let* ((level (+ (org-export-get-relative-level headline info
)
2196 (1- org-html-toplevel-hlevel
)))
2197 (headline-number (org-export-get-headline-number headline info
))
2198 (section-number (and (not (org-export-low-level-p headline info
))
2199 (org-export-numbered-headline-p headline info
)
2200 (mapconcat 'number-to-string
2201 headline-number
".")))
2202 (todo (and (plist-get info
:with-todo-keywords
)
2203 (let ((todo (org-element-property :todo-keyword headline
)))
2204 (and todo
(org-export-data todo info
)))))
2205 (todo-type (and todo
(org-element-property :todo-type headline
)))
2206 (priority (and (plist-get info
:with-priority
)
2207 (org-element-property :priority headline
)))
2208 (text (org-export-data (org-element-property :title headline
) info
))
2209 (tags (and (plist-get info
:with-tags
)
2210 (org-export-get-tags headline info
)))
2211 (headline-label (or (org-element-property :CUSTOM_ID headline
)
2212 (concat "sec-" (mapconcat 'number-to-string
2213 headline-number
"-"))))
2214 (format-function (cond
2215 ((functionp format-function
) format-function
)
2216 ((functionp org-html-format-headline-function
)
2218 (lambda (todo todo-type priority text tags
2220 (funcall org-html-format-headline-function
2221 todo todo-type priority text tags
))))
2222 (t 'org-html-format-headline
))))
2223 (apply format-function
2224 todo todo-type priority text tags
2225 :headline-label headline-label
:level level
2226 :section-number section-number extra-keys
)))
2228 (defun org-html-headline (headline contents info
)
2229 "Transcode a HEADLINE element from Org to HTML.
2230 CONTENTS holds the contents of the headline. INFO is a plist
2231 holding contextual information."
2233 (setq contents
(or contents
""))
2234 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2235 (level (org-export-get-relative-level headline info
))
2236 (text (org-export-data (org-element-property :title headline
) info
))
2237 (todo (and (plist-get info
:with-todo-keywords
)
2238 (let ((todo (org-element-property :todo-keyword headline
)))
2239 (and todo
(org-export-data todo info
)))))
2240 (todo-type (and todo
(org-element-property :todo-type headline
)))
2241 (tags (and (plist-get info
:with-tags
)
2242 (org-export-get-tags headline info
)))
2243 (priority (and (plist-get info
:with-priority
)
2244 (org-element-property :priority headline
)))
2245 (section-number (and (org-export-numbered-headline-p headline info
)
2246 (mapconcat 'number-to-string
2247 (org-export-get-headline-number
2248 headline info
) ".")))
2249 ;; Create the headline text.
2250 (full-text (org-html-format-headline--wrap headline info
)))
2252 ;; Case 1: This is a footnote section: ignore it.
2253 ((org-element-property :footnote-section-p headline
) nil
)
2254 ;; Case 2. This is a deep sub-tree: export it as a list item.
2255 ;; Also export as items headlines for which no section
2256 ;; format has been found.
2257 ((org-export-low-level-p headline info
)
2258 ;; Build the real contents of the sub-tree.
2259 (let* ((type (if numberedp
'ordered
'unordered
))
2260 (itemized-body (org-html-format-list-item
2261 contents type nil info nil full-text
)))
2263 (and (org-export-first-sibling-p headline info
)
2264 (org-html-begin-plain-list type
))
2266 (and (org-export-last-sibling-p headline info
)
2267 (org-html-end-plain-list type
)))))
2268 ;; Case 3. Standard headline. Export it as a section.
2270 (let* ((section-number (mapconcat 'number-to-string
2271 (org-export-get-headline-number
2272 headline info
) "-"))
2274 (list (org-element-property :CUSTOM_ID headline
)
2275 (concat "sec-" section-number
)
2276 (org-element-property :ID headline
))))
2277 (preferred-id (car ids
))
2278 (extra-ids (cdr ids
))
2279 (extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2280 (level1 (+ level
(1- org-html-toplevel-hlevel
)))
2281 (first-content (car (org-element-contents headline
))))
2282 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2283 (org-html--container headline info
)
2284 (format "outline-container-%s"
2285 (or (org-element-property :CUSTOM_ID headline
)
2286 (concat "sec-" section-number
)))
2287 (concat (format "outline-%d" level1
) (and extra-class
" ")
2289 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2294 (let ((id (org-export-solidify-link-text
2295 (if (org-uuidgen-p x
) (concat "ID-" x
)
2297 (org-html--anchor id
)))
2301 ;; When there is no section, pretend there is an empty
2302 ;; one to get the correct <div class="outline- ...>
2303 ;; which is needed by `org-info.js'.
2304 (if (not (eq (org-element-type first-content
) 'section
))
2305 (concat (org-html-section first-content
"" info
)
2308 (org-html--container headline info
)))))))
2310 (defun org-html--container (headline info
)
2311 (or (org-element-property :HTML_CONTAINER headline
)
2312 (if (= 1 (org-export-get-relative-level headline info
))
2313 (plist-get info
:html-container
)
2316 ;;;; Horizontal Rule
2318 (defun org-html-horizontal-rule (horizontal-rule contents info
)
2319 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2320 CONTENTS is nil. INFO is a plist holding contextual information."
2321 (org-html-close-tag "hr" nil info
))
2323 ;;;; Inline Src Block
2325 (defun org-html-inline-src-block (inline-src-block contents info
)
2326 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2327 CONTENTS holds the contents of the item. INFO is a plist holding
2328 contextual information."
2329 (let* ((org-lang (org-element-property :language inline-src-block
))
2330 (code (org-element-property :value inline-src-block
)))
2331 (error "Cannot export inline src block")))
2335 (defun org-html-format-section (text class
&optional id
)
2336 "Format a section with TEXT into a HTML div with CLASS and ID."
2337 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
2338 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
2340 (defun org-html-inlinetask (inlinetask contents info
)
2341 "Transcode an INLINETASK element from Org to HTML.
2342 CONTENTS holds the contents of the block. INFO is a plist
2343 holding contextual information."
2345 ;; If `org-html-format-inlinetask-function' is provided, call it
2346 ;; with appropriate arguments.
2347 ((functionp org-html-format-inlinetask-function
)
2348 (let ((format-function
2350 (lambda (todo todo-type priority text tags
2351 &key contents
&allow-other-keys
)
2352 (funcall org-html-format-inlinetask-function
2353 todo todo-type priority text tags contents
)))))
2354 (org-html-format-headline--wrap
2355 inlinetask info format-function
:contents contents
)))
2356 ;; Otherwise, use a default template.
2357 (t (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2358 (org-html-format-headline--wrap inlinetask info
)
2359 (org-html-close-tag "br" nil info
)
2364 (defun org-html-italic (italic contents info
)
2365 "Transcode ITALIC from Org to HTML.
2366 CONTENTS is the text with italic markup. INFO is a plist holding
2367 contextual information."
2368 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
2372 (defun org-html-checkbox (checkbox)
2373 "Format CHECKBOX into HTML."
2374 (case checkbox
(on "<code>[X]</code>")
2375 (off "<code>[ ]</code>")
2376 (trans "<code>[-]</code>")
2379 (defun org-html-format-list-item (contents type checkbox info
2380 &optional term-counter-id
2382 "Format a list item into HTML."
2383 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" ")))
2384 (br (org-html-close-tag "br" nil info
)))
2388 (let* ((counter term-counter-id
)
2389 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2391 (format "<li%s>" extra
)
2392 (when headline
(concat headline br
)))))
2394 (let* ((id term-counter-id
)
2395 (extra (if id
(format " id=\"%s\"" id
) "")))
2397 (format "<li%s>" extra
)
2398 (when headline
(concat headline br
)))))
2400 (let* ((term term-counter-id
))
2401 (setq term
(or term
"(no term)"))
2402 ;; Check-boxes in descriptive lists are associated to tag.
2403 (concat (format "<dt> %s </dt>"
2404 (concat checkbox term
))
2406 (unless (eq type
'descriptive
) checkbox
)
2411 (descriptive "</dd>")))))
2413 (defun org-html-item (item contents info
)
2414 "Transcode an ITEM element from Org to HTML.
2415 CONTENTS holds the contents of the item. INFO is a plist holding
2416 contextual information."
2417 (let* ((plain-list (org-export-get-parent item
))
2418 (type (org-element-property :type plain-list
))
2419 (counter (org-element-property :counter item
))
2420 (checkbox (org-element-property :checkbox item
))
2421 (tag (let ((tag (org-element-property :tag item
)))
2422 (and tag
(org-export-data tag info
)))))
2423 (org-html-format-list-item
2424 contents type checkbox info
(or tag counter
))))
2428 (defun org-html-keyword (keyword contents info
)
2429 "Transcode a KEYWORD element from Org to HTML.
2430 CONTENTS is nil. INFO is a plist holding contextual information."
2431 (let ((key (org-element-property :key keyword
))
2432 (value (org-element-property :value keyword
)))
2434 ((string= key
"HTML") value
)
2435 ((string= key
"TOC")
2436 (let ((value (downcase value
)))
2438 ((string-match "\\<headlines\\>" value
)
2439 (let ((depth (or (and (string-match "[0-9]+" value
)
2440 (string-to-number (match-string 0 value
)))
2441 (plist-get info
:with-toc
))))
2442 (org-html-toc depth info
)))
2443 ((string= "listings" value
) (org-html-list-of-listings info
))
2444 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2446 ;;;; Latex Environment
2448 (defun org-html-format-latex (latex-frag processing-type
)
2449 "Format a LaTeX fragment LATEX-FRAG into HTML."
2450 (let ((cache-relpath "") (cache-dir ""))
2451 (unless (eq processing-type
'mathjax
)
2452 (let ((bfn (or (buffer-file-name)
2454 (expand-file-name "latex" temporary-file-directory
)))))
2457 (file-name-sans-extension
2458 (file-name-nondirectory bfn
)))
2459 cache-dir
(file-name-directory bfn
))))
2462 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2463 nil nil processing-type
)
2466 (defun org-html-latex-environment (latex-environment contents info
)
2467 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2468 CONTENTS is nil. INFO is a plist holding contextual information."
2469 (let ((processing-type (plist-get info
:with-latex
))
2470 (latex-frag (org-remove-indentation
2471 (org-element-property :value latex-environment
)))
2472 (caption (org-export-data
2473 (org-export-get-caption latex-environment
) info
))
2475 (label (org-element-property :name latex-environment
)))
2477 ((memq processing-type
'(t mathjax
))
2478 (org-html-format-latex latex-frag
'mathjax
))
2479 ((eq processing-type
'dvipng
)
2480 (let* ((formula-link (org-html-format-latex
2481 latex-frag processing-type
)))
2482 (when (and formula-link
2483 (string-match "file:\\([^]]*\\)" formula-link
))
2484 (org-html-format-inline-image
2485 (match-string 1 formula-link
) info caption label attr t
))))
2490 (defun org-html-latex-fragment (latex-fragment contents info
)
2491 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2492 CONTENTS is nil. INFO is a plist holding contextual information."
2493 (let ((latex-frag (org-element-property :value latex-fragment
))
2494 (processing-type (plist-get info
:with-latex
)))
2495 (case processing-type
2497 (org-html-format-latex latex-frag
'mathjax
))
2499 (let* ((formula-link (org-html-format-latex
2500 latex-frag processing-type
)))
2501 (when (and formula-link
2502 (string-match "file:\\([^]]*\\)" formula-link
))
2503 (org-html-format-inline-image
2504 (match-string 1 formula-link
) info
))))
2509 (defun org-html-line-break (line-break contents info
)
2510 "Transcode a LINE-BREAK object from Org to HTML.
2511 CONTENTS is nil. INFO is a plist holding contextual information."
2512 (concat (org-html-close-tag "br" nil info
) "\n"))
2516 (defun org-html-link--inline-image (link desc info
)
2517 "Return HTML code for an inline image.
2519 LINK is the link pointing to the inline image. INFO is a plist
2520 used as a communication channel.
2522 Inline images can have these attributes:
2524 #+ATTR_HTML: :width 100px :height 100px :alt \"Alt description\"."
2525 (let* ((type (org-element-property :type link
))
2526 (raw-path (org-element-property :path link
))
2527 (path (cond ((member type
'("http" "https"))
2528 (concat type
":" raw-path
))
2529 ((file-name-absolute-p raw-path
)
2530 (expand-file-name raw-path
))
2532 (parent (org-export-get-parent-element link
))
2533 (caption (org-export-data (org-export-get-caption parent
) info
))
2534 (label (org-element-property :name parent
)))
2535 ;; Return proper string, depending on DISPOSITION.
2536 (org-html-format-inline-image
2537 path info caption label
2538 (org-html--make-attribute-string
2539 (org-export-read-attribute :attr_html parent
))
2540 (org-html-standalone-image-p link info
))))
2542 (defvar org-html-standalone-image-predicate
)
2543 (defun org-html-standalone-image-p (element info
&optional predicate
)
2544 "Test if ELEMENT is a standalone image for the purpose HTML export.
2545 INFO is a plist holding contextual information.
2547 Return non-nil, if ELEMENT is of type paragraph and it's sole
2548 content, save for whitespaces, is a link that qualifies as an
2551 Return non-nil, if ELEMENT is of type link and it's containing
2552 paragraph has no other content save for leading and trailing
2555 Return nil, otherwise.
2557 Bind `org-html-standalone-image-predicate' to constrain
2558 paragraph further. For example, to check for only captioned
2559 standalone images, do the following.
2561 \(setq org-html-standalone-image-predicate
2562 \(lambda \(paragraph\)
2563 \(org-element-property :caption paragraph\)\)\)"
2564 (let ((paragraph (case (org-element-type element
)
2566 (link (and (org-export-inline-image-p
2567 element org-html-inline-image-rules
)
2568 (org-export-get-parent element
)))
2570 (when (eq (org-element-type paragraph
) 'paragraph
)
2571 (when (or (not (and (boundp 'org-html-standalone-image-predicate
)
2572 (functionp org-html-standalone-image-predicate
)))
2573 (funcall org-html-standalone-image-predicate paragraph
))
2574 (let ((contents (org-element-contents paragraph
)))
2575 (loop for x in contents
2576 with inline-image-count
= 0
2578 ((eq (org-element-type x
) 'plain-text
)
2579 (not (org-string-nw-p x
)))
2580 ((eq (org-element-type x
) 'link
)
2581 (when (org-export-inline-image-p
2582 x org-html-inline-image-rules
)
2583 (= (incf inline-image-count
) 1)))
2586 (defun org-html-link (link desc info
)
2587 "Transcode a LINK object from Org to HTML.
2589 DESC is the description part of the link, or the empty string.
2590 INFO is a plist holding contextual information. See
2592 (let* ((link-org-files-as-html-maybe
2594 (lambda (raw-path info
)
2595 "Treat links to `file.org' as links to `file.html', if needed.
2596 See `org-html-link-org-files-as-html'."
2598 ((and org-html-link-org-files-as-html
2600 (downcase (file-name-extension raw-path
"."))))
2601 (concat (file-name-sans-extension raw-path
) "."
2602 (plist-get info
:html-extension
)))
2604 (type (org-element-property :type link
))
2605 (raw-path (org-element-property :path link
))
2606 ;; Ensure DESC really exists, or set it to nil.
2607 (desc (org-string-nw-p desc
))
2610 ((member type
'("http" "https" "ftp" "mailto"))
2611 (concat type
":" raw-path
))
2612 ((string= type
"file")
2613 ;; Treat links to ".org" files as ".html", if needed.
2615 (funcall link-org-files-as-html-maybe raw-path info
))
2616 ;; If file path is absolute, prepend it with protocol
2617 ;; component - "file://".
2618 (when (file-name-absolute-p raw-path
)
2620 (concat "file://" (expand-file-name raw-path
))))
2621 ;; Add search option, if any. A search option can be
2622 ;; relative to a custom-id or a headline title. Any other
2623 ;; option is ignored.
2624 (let ((option (org-element-property :search-option link
)))
2625 (cond ((not option
) raw-path
)
2626 ((eq (aref option
0) ?
#) (concat raw-path option
))
2627 ;; External fuzzy link: try to resolve it if path
2628 ;; belongs to current project, if any.
2629 ((eq (aref option
0) ?
*)
2633 (org-publish-resolve-external-fuzzy-link
2634 (org-element-property :path link
) option
)))
2635 (and numbers
(concat "#sec-"
2636 (mapconcat 'number-to-string
2640 ;; Extract attributes from parent's paragraph. HACK: Only do
2641 ;; this for the first link in parent. This is needed as long
2642 ;; as attributes cannot be set on a per link basis.
2644 (let ((parent (org-export-get-parent-element link
)))
2645 (if (not (eq (org-element-map parent
'link
'identity info t
) link
))
2647 (let ((att (org-html--make-attribute-string
2648 (org-export-read-attribute :attr_html parent
))))
2649 (cond ((not (org-string-nw-p att
)) "")
2650 ((and desc
(string-match (regexp-quote att
) desc
)) "")
2651 (t (concat " " att
)))))))
2655 ((and (or (eq t org-html-inline-images
)
2656 (and org-html-inline-images
(not desc
)))
2657 (org-export-inline-image-p link org-html-inline-image-rules
))
2658 (org-html-link--inline-image link desc info
))
2659 ;; Radio target: Transcode target's contents and use them as
2660 ;; link's description.
2661 ((string= type
"radio")
2662 (let ((destination (org-export-resolve-radio-link link info
)))
2664 (format "<a href=\"#%s\"%s>%s</a>"
2665 (org-export-solidify-link-text path
)
2667 (org-export-data (org-element-contents destination
) info
)))))
2668 ;; Links pointing to a headline: Find destination and build
2669 ;; appropriate referencing command.
2670 ((member type
'("custom-id" "fuzzy" "id"))
2671 (let ((destination (if (string= type
"fuzzy")
2672 (org-export-resolve-fuzzy-link link info
)
2673 (org-export-resolve-id-link link info
))))
2674 (case (org-element-type destination
)
2675 ;; ID link points to an external file.
2677 (let ((fragment (concat "ID-" path
))
2678 ;; Treat links to ".org" files as ".html", if needed.
2679 (path (funcall link-org-files-as-html-maybe
2681 (format "<a href=\"%s#%s\"%s>%s</a>"
2682 path fragment attributes
(or desc destination
))))
2683 ;; Fuzzy link points nowhere.
2688 (org-element-property :raw-link link
) info
))))
2689 ;; Fuzzy link points to an invisible target.
2691 ;; Link points to a headline.
2694 ;; What href to use?
2696 ;; Case 1: Headline is linked via it's CUSTOM_ID
2697 ;; property. Use CUSTOM_ID.
2698 ((string= type
"custom-id")
2699 (org-element-property :CUSTOM_ID destination
))
2700 ;; Case 2: Headline is linked via it's ID property
2701 ;; or through other means. Use the default href.
2702 ((member type
'("id" "fuzzy"))
2704 (mapconcat 'number-to-string
2705 (org-export-get-headline-number
2706 destination info
) "-")))
2707 (t (error "Shouldn't reach here"))))
2708 ;; What description to use?
2710 ;; Case 1: Headline is numbered and LINK has no
2711 ;; description. Display section number.
2712 (if (and (org-export-numbered-headline-p destination info
)
2714 (mapconcat 'number-to-string
2715 (org-export-get-headline-number
2716 destination info
) ".")
2717 ;; Case 2: Either the headline is un-numbered or
2718 ;; LINK has a custom description. Display LINK's
2719 ;; description or headline's title.
2720 (or desc
(org-export-data (org-element-property
2721 :title destination
) info
)))))
2722 (format "<a href=\"#%s\"%s>%s</a>"
2723 (org-export-solidify-link-text href
) attributes desc
)))
2724 ;; Fuzzy link points to a target. Do as above.
2726 (let ((path (org-export-solidify-link-text path
)) number
)
2729 ((org-html-standalone-image-p destination info
)
2730 (org-export-get-ordinal
2731 (assoc 'link
(org-element-contents destination
))
2732 info
'link
'org-html-standalone-image-p
))
2733 (t (org-export-get-ordinal destination info
))))
2734 (setq desc
(when number
2735 (if (atom number
) (number-to-string number
)
2736 (mapconcat 'number-to-string number
".")))))
2737 (format "<a href=\"#%s\"%s>%s</a>"
2738 path attributes
(or desc
"No description for this link")))))))
2739 ;; Coderef: replace link with the reference name or the
2740 ;; equivalent line number.
2741 ((string= type
"coderef")
2742 (let ((fragment (concat "coderef-" path
)))
2743 (format "<a href=\"#%s\"%s%s>%s</a>"
2746 (format (concat "class=\"coderef\""
2747 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2748 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2751 (format (org-export-get-coderef-format path desc
)
2752 (org-export-resolve-coderef path info
)))))
2753 ;; Link type is handled by a special function.
2754 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2755 (funcall protocol
(org-link-unescape path
) desc
'html
))
2756 ;; External link with a description part.
2757 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2758 ;; External link without a description part.
2759 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2760 ;; No path, only description. Try to do something useful.
2761 (t (format "<i>%s</i>" desc
)))))
2765 (defun org-html-paragraph (paragraph contents info
)
2766 "Transcode a PARAGRAPH element from Org to HTML.
2767 CONTENTS is the contents of the paragraph, as a string. INFO is
2768 the plist used as a communication channel."
2769 (let* ((parent (org-export-get-parent paragraph
))
2770 (parent-type (org-element-type parent
))
2771 (style '((footnote-definition " class=\"footpara\"")))
2772 (extra (or (cadr (assoc parent-type style
)) "")))
2774 ((and (eq (org-element-type parent
) 'item
)
2775 (= (org-element-property :begin paragraph
)
2776 (org-element-property :contents-begin parent
)))
2777 ;; leading paragraph in a list item have no tags
2779 ((org-html-standalone-image-p paragraph info
)
2782 (t (format "<p%s>\n%s</p>" extra contents
)))))
2786 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2787 ;; the correct value for the item counter
2788 (defun org-html-begin-plain-list (type &optional arg1
)
2789 "Insert the beginning of the HTML list depending on TYPE.
2790 When ARG1 is a string, use it as the start parameter for ordered
2794 (format "<ol class=\"org-ol\"%s>"
2795 (if arg1
(format " start=\"%d\"" arg1
) "")))
2796 (unordered "<ul class=\"org-ul\">")
2797 (descriptive "<dl class=\"org-dl\">")))
2799 (defun org-html-end-plain-list (type)
2800 "Insert the end of the HTML list depending on TYPE."
2804 (descriptive "</dl>")))
2806 (defun org-html-plain-list (plain-list contents info
)
2807 "Transcode a PLAIN-LIST element from Org to HTML.
2808 CONTENTS is the contents of the list. INFO is a plist holding
2809 contextual information."
2810 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2811 (type (org-element-property :type plain-list
)))
2813 (org-html-begin-plain-list type
)
2814 contents
(org-html-end-plain-list type
))))
2818 (defun org-html-convert-special-strings (string)
2819 "Convert special characters in STRING to HTML."
2820 (let ((all org-html-special-string-regexps
)
2822 (while (setq a
(pop all
))
2823 (setq re
(car a
) rpl
(cdr a
) start
0)
2824 (while (string-match re string start
)
2825 (setq string
(replace-match rpl t nil string
))))
2828 (defun org-html-encode-plain-text (text)
2829 "Convert plain text characters from TEXT to HTML equivalent.
2830 Possible conversions are set in `org-html-protect-char-alist'."
2833 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2834 org-html-protect-char-alist
)
2837 (defun org-html-plain-text (text info
)
2838 "Transcode a TEXT string from Org to HTML.
2839 TEXT is the string to transcode. INFO is a plist holding
2840 contextual information."
2841 (let ((output text
))
2842 ;; Protect following characters: <, >, &.
2843 (setq output
(org-html-encode-plain-text output
))
2844 ;; Handle smart quotes. Be sure to provide original string since
2845 ;; OUTPUT may have been modified.
2846 (when (plist-get info
:with-smart-quotes
)
2847 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2848 ;; Handle special strings.
2849 (when (plist-get info
:with-special-strings
)
2850 (setq output
(org-html-convert-special-strings output
)))
2851 ;; Handle break preservation if required.
2852 (when (plist-get info
:preserve-breaks
)
2854 (replace-regexp-in-string
2855 "\\(\\\\\\\\\\)?[ \t]*\n"
2856 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
2863 (defun org-html-planning (planning contents info
)
2864 "Transcode a PLANNING element from Org to HTML.
2865 CONTENTS is nil. INFO is a plist used as a communication
2867 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2869 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2874 (let ((closed (org-element-property :closed planning
)))
2876 (format span-fmt org-closed-string
2878 (org-element-property :raw-value closed
)))))
2879 (let ((deadline (org-element-property :deadline planning
)))
2881 (format span-fmt org-deadline-string
2883 (org-element-property :raw-value deadline
)))))
2884 (let ((scheduled (org-element-property :scheduled planning
)))
2886 (format span-fmt org-scheduled-string
2888 (org-element-property :raw-value scheduled
)))))))
2891 ;;;; Property Drawer
2893 (defun org-html-property-drawer (property-drawer contents info
)
2894 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2895 CONTENTS is nil. INFO is a plist holding contextual
2897 ;; The property drawer isn't exported but we want separating blank
2898 ;; lines nonetheless.
2903 (defun org-html-quote-block (quote-block contents info
)
2904 "Transcode a QUOTE-BLOCK element from Org to HTML.
2905 CONTENTS holds the contents of the block. INFO is a plist
2906 holding contextual information."
2907 (format "<blockquote>\n%s</blockquote>" contents
))
2911 (defun org-html-quote-section (quote-section contents info
)
2912 "Transcode a QUOTE-SECTION element from Org to HTML.
2913 CONTENTS is nil. INFO is a plist holding contextual information."
2914 (let ((value (org-remove-indentation
2915 (org-element-property :value quote-section
))))
2916 (when value
(format "<pre>\n%s</pre>" value
))))
2920 (defun org-html-section (section contents info
)
2921 "Transcode a SECTION element from Org to HTML.
2922 CONTENTS holds the contents of the section. INFO is a plist
2923 holding contextual information."
2924 (let ((parent (org-export-get-parent-headline section
)))
2925 ;; Before first headline: no container, just return CONTENTS.
2926 (if (not parent
) contents
2927 ;; Get div's class and id references.
2928 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2929 (1- org-html-toplevel-hlevel
)))
2933 (org-export-get-headline-number parent info
) "-")))
2934 ;; Build return value.
2935 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2937 (or (org-element-property :CUSTOM_ID parent
) section-number
)
2942 (defun org-html-radio-target (radio-target text info
)
2943 "Transcode a RADIO-TARGET object from Org to HTML.
2944 TEXT is the text of the target. INFO is a plist holding
2945 contextual information."
2946 (let ((id (org-export-solidify-link-text
2947 (org-element-property :value radio-target
))))
2948 (org-html--anchor id text
)))
2952 (defun org-html-special-block (special-block contents info
)
2953 "Transcode a SPECIAL-BLOCK element from Org to HTML.
2954 CONTENTS holds the contents of the block. INFO is a plist
2955 holding contextual information."
2956 (let* ((block-type (downcase
2957 (org-element-property :type special-block
)))
2958 (contents (or contents
""))
2959 (html5-fancy (and (org-html-html5-p info
)
2960 (plist-get info
:html-html5-fancy
)
2961 (member block-type org-html-html5-elements
)))
2962 (attributes (org-export-read-attribute :attr_html special-block
)))
2964 (let ((class (plist-get attributes
:class
)))
2965 (setq attributes
(plist-put attributes
:class
2966 (if class
(concat class
" " block-type
)
2968 (setq attributes
(org-html--make-attribute-string attributes
))
2969 (when (not (equal attributes
""))
2970 (setq attributes
(concat " " attributes
)))
2972 (format "<%s%s>\n%s</%s>" block-type attributes
2973 contents block-type
)
2974 (format "<div%s>\n%s\n</div>" attributes contents
))))
2978 (defun org-html-src-block (src-block contents info
)
2979 "Transcode a SRC-BLOCK element from Org to HTML.
2980 CONTENTS holds the contents of the item. INFO is a plist holding
2981 contextual information."
2982 (if (org-export-read-attribute :attr_html src-block
:textarea
)
2983 (org-html--textarea-block src-block
)
2984 (let ((lang (org-element-property :language src-block
))
2985 (caption (org-export-get-caption src-block
))
2986 (code (org-html-format-code src-block info
))
2987 (label (let ((lbl (org-element-property :name src-block
)))
2989 (format " id=\"%s\""
2990 (org-export-solidify-link-text lbl
))))))
2991 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
2993 "<div class=\"org-src-container\">\n%s%s\n</div>"
2994 (if (not caption
) ""
2995 (format "<label class=\"org-src-name\">%s</label>"
2996 (org-export-data caption info
)))
2997 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
2999 ;;;; Statistics Cookie
3001 (defun org-html-statistics-cookie (statistics-cookie contents info
)
3002 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3003 CONTENTS is nil. INFO is a plist holding contextual information."
3004 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3005 (format "<code>%s</code>" cookie-value
)))
3009 (defun org-html-strike-through (strike-through contents info
)
3010 "Transcode STRIKE-THROUGH from Org to HTML.
3011 CONTENTS is the text with strike-through markup. INFO is a plist
3012 holding contextual information."
3013 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
3018 (defun org-html-subscript (subscript contents info
)
3019 "Transcode a SUBSCRIPT object from Org to HTML.
3020 CONTENTS is the contents of the object. INFO is a plist holding
3021 contextual information."
3022 (format "<sub>%s</sub>" contents
))
3026 (defun org-html-superscript (superscript contents info
)
3027 "Transcode a SUPERSCRIPT object from Org to HTML.
3028 CONTENTS is the contents of the object. INFO is a plist holding
3029 contextual information."
3030 (format "<sup>%s</sup>" contents
))
3034 (defun org-html-table-cell (table-cell contents info
)
3035 "Transcode a TABLE-CELL element from Org to HTML.
3036 CONTENTS is nil. INFO is a plist used as a communication
3038 (let* ((table-row (org-export-get-parent table-cell
))
3039 (table (org-export-get-parent-table table-cell
))
3041 (if (not org-html-table-align-individual-fields
) ""
3042 (format (if (and (boundp 'org-html-format-table-no-css
)
3043 org-html-format-table-no-css
)
3044 " align=\"%s\"" " class=\"%s\"")
3045 (org-export-table-cell-alignment table-cell info
)))))
3046 (when (or (not contents
) (string= "" (org-trim contents
)))
3047 (setq contents
" "))
3049 ((and (org-export-table-has-header-p table info
)
3050 (= 1 (org-export-table-row-group table-row info
)))
3051 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
3052 contents
(cdr org-html-table-header-tags
)))
3053 ((and org-html-table-use-header-tags-for-first-column
3054 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3055 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
3056 contents
(cdr org-html-table-header-tags
)))
3057 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
3058 contents
(cdr org-html-table-data-tags
))))))
3062 (defun org-html-table-row (table-row contents info
)
3063 "Transcode a TABLE-ROW element from Org to HTML.
3064 CONTENTS is the contents of the row. INFO is a plist used as a
3065 communication channel."
3066 ;; Rules are ignored since table separators are deduced from
3067 ;; borders of the current row.
3068 (when (eq (org-element-property :type table-row
) 'standard
)
3069 (let* ((rowgroup-number (org-export-table-row-group table-row info
))
3070 (row-number (org-export-table-row-number table-row info
))
3072 (org-export-table-row-starts-rowgroup-p table-row info
))
3074 (org-export-table-row-ends-rowgroup-p table-row info
))
3075 ;; `top-row-p' and `end-rowgroup-p' are not used directly
3076 ;; but should be set so that `org-html-table-row-tags' can
3077 ;; use them (see the docstring of this variable.)
3078 (top-row-p (and (equal start-rowgroup-p
'(top))
3079 (equal end-rowgroup-p
'(below top
))))
3080 (bottom-row-p (and (equal start-rowgroup-p
'(above))
3081 (equal end-rowgroup-p
'(bottom above
))))
3084 ;; Case 1: Row belongs to second or subsequent rowgroups.
3085 ((not (= 1 rowgroup-number
))
3086 '("<tbody>" .
"\n</tbody>"))
3087 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
3088 ((org-export-table-has-header-p
3089 (org-export-get-parent-table table-row
) info
)
3090 '("<thead>" .
"\n</thead>"))
3091 ;; Case 2: Row is from first and only row group.
3092 (t '("<tbody>" .
"\n</tbody>")))))
3094 ;; Begin a rowgroup?
3095 (when start-rowgroup-p
(car rowgroup-tags
))
3097 (concat "\n" (eval (car org-html-table-row-tags
))
3100 (eval (cdr org-html-table-row-tags
)))
3102 (when end-rowgroup-p
(cdr rowgroup-tags
))))))
3106 (defun org-html-table-first-row-data-cells (table info
)
3107 "Transcode the first row of TABLE.
3108 INFO is a plist used as a communication channel."
3110 (org-element-map table
'table-row
3112 (unless (eq (org-element-property :type row
) 'rule
) row
))
3114 (special-column-p (org-export-table-has-special-column-p table
)))
3115 (if (not special-column-p
) (org-element-contents table-row
)
3116 (cdr (org-element-contents table-row
)))))
3118 (defun org-html-table--table.el-table
(table info
)
3119 "Format table.el tables into HTML.
3120 INFO is a plist used as a communication channel."
3121 (when (eq (org-element-property :type table
) 'table.el
)
3123 (let ((outbuf (with-current-buffer
3124 (get-buffer-create "*org-export-table*")
3125 (erase-buffer) (current-buffer))))
3127 (insert (org-element-property :value table
))
3129 (re-search-forward "^[ \t]*|[^|]" nil t
)
3130 (table-generate-source 'html outbuf
))
3131 (with-current-buffer outbuf
3132 (prog1 (org-trim (buffer-string))
3135 (defun org-html-table (table contents info
)
3136 "Transcode a TABLE element from Org to HTML.
3137 CONTENTS is the contents of the table. INFO is a plist holding
3138 contextual information."
3139 (case (org-element-property :type table
)
3140 ;; Case 1: table.el table. Convert it using appropriate tools.
3141 (table.el
(org-html-table--table.el-table table info
))
3142 ;; Case 2: Standard table.
3144 (let* ((label (org-element-property :name table
))
3145 (caption (org-export-get-caption table
))
3147 (if (org-html-html5-p info
) ""
3148 (org-html--make-attribute-string
3150 (and label
(list :id
(org-export-solidify-link-text label
)))
3151 (plist-get info
:html-table-attributes
)
3152 (org-export-read-attribute :attr_html table
)))))
3154 (if (and (boundp 'org-html-format-table-no-css
)
3155 org-html-format-table-no-css
)
3156 "align=\"%s\"" "class=\"%s\""))
3159 (lambda (table info
)
3161 (lambda (table-cell)
3162 (let ((alignment (org-export-table-cell-alignment
3165 ;; Begin a colgroup?
3166 (when (org-export-table-cell-starts-colgroup-p
3169 ;; Add a column. Also specify it's alignment.
3172 "col" (concat " " (format alignspec alignment
)) info
))
3174 (when (org-export-table-cell-ends-colgroup-p
3177 (org-html-table-first-row-data-cells table info
) "\n")))))
3178 (format "<table%s>\n%s\n%s\n%s</table>"
3179 (if (equal attributes
"") "" (concat " " attributes
))
3180 (if (not caption
) ""
3181 (format (if org-html-table-caption-above
3182 "<caption align=\"above\">%s</caption>"
3183 "<caption align=\"bottom\">%s</caption>")
3184 (org-export-data caption info
)))
3185 (funcall table-column-specs table info
)
3190 (defun org-html-target (target contents info
)
3191 "Transcode a TARGET object from Org to HTML.
3192 CONTENTS is nil. INFO is a plist holding contextual
3194 (let ((id (org-export-solidify-link-text
3195 (org-element-property :value target
))))
3196 (org-html--anchor id
)))
3200 (defun org-html-timestamp (timestamp contents info
)
3201 "Transcode a TIMESTAMP object from Org to HTML.
3202 CONTENTS is nil. INFO is a plist holding contextual
3204 (let ((value (org-html-plain-text
3205 (org-timestamp-translate timestamp
) info
)))
3206 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3207 (replace-regexp-in-string "--" "–" value
))))
3211 (defun org-html-underline (underline contents info
)
3212 "Transcode UNDERLINE from Org to HTML.
3213 CONTENTS is the text with underline markup. INFO is a plist
3214 holding contextual information."
3215 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
3220 (defun org-html-verbatim (verbatim contents info
)
3221 "Transcode VERBATIM from Org to HTML.
3222 CONTENTS is nil. INFO is a plist holding contextual
3224 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
3225 (org-html-plain-text (org-element-property :value verbatim
) info
)))
3229 (defun org-html-verse-block (verse-block contents info
)
3230 "Transcode a VERSE-BLOCK element from Org to HTML.
3231 CONTENTS is verse block contents. INFO is a plist holding
3232 contextual information."
3233 ;; Replace each newline character with line break. Also replace
3234 ;; each blank line with a line break.
3235 (setq contents
(replace-regexp-in-string
3236 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3237 (replace-regexp-in-string
3238 "\\(\\\\\\\\\\)?[ \t]*\n"
3239 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3240 ;; Replace each white space at beginning of a line with a
3241 ;; non-breaking space.
3242 (while (string-match "^[ \t]+" contents
)
3243 (let* ((num-ws (length (match-string 0 contents
)))
3244 (ws (let (out) (dotimes (i num-ws out
)
3245 (setq out
(concat out
" "))))))
3246 (setq contents
(replace-match ws nil t contents
))))
3247 (format "<p class=\"verse\">\n%s</p>" contents
))
3250 ;;; Filter Functions
3252 (defun org-html-final-function (contents backend info
)
3253 "Filter to indent the HTML and convert HTML entities."
3258 (indent-region (point-min) (point-max)))
3259 (when org-html-use-unicode-chars
3261 (mm-url-decode-entities))
3262 (buffer-substring-no-properties (point-min) (point-max))))
3265 ;;; End-user functions
3268 (defun org-html-export-as-html
3269 (&optional async subtreep visible-only body-only ext-plist
)
3270 "Export current buffer to an HTML buffer.
3272 If narrowing is active in the current buffer, only export its
3275 If a region is active, export that region.
3277 A non-nil optional argument ASYNC means the process should happen
3278 asynchronously. The resulting buffer should be accessible
3279 through the `org-export-stack' interface.
3281 When optional argument SUBTREEP is non-nil, export the sub-tree
3282 at point, extracting information from the headline properties
3285 When optional argument VISIBLE-ONLY is non-nil, don't export
3286 contents of hidden elements.
3288 When optional argument BODY-ONLY is non-nil, only write code
3289 between \"<body>\" and \"</body>\" tags.
3291 EXT-PLIST, when provided, is a property list with external
3292 parameters overriding Org default settings, but still inferior to
3293 file-local settings.
3295 Export is done in a buffer named \"*Org HTML Export*\", which
3296 will be displayed when `org-export-show-temporary-export-buffer'
3300 (org-export-async-start
3302 (with-current-buffer (get-buffer-create "*Org HTML Export*")
3305 (goto-char (point-min))
3307 (org-export-add-to-stack (current-buffer) 'html
)))
3308 `(org-export-as 'html
,subtreep
,visible-only
,body-only
',ext-plist
))
3309 (let ((outbuf (org-export-to-buffer
3310 'html
"*Org HTML Export*"
3311 subtreep visible-only body-only ext-plist
)))
3313 (with-current-buffer outbuf
(set-auto-mode t
))
3314 (when org-export-show-temporary-export-buffer
3315 (switch-to-buffer-other-window outbuf
)))))
3318 (defun org-html-convert-region-to-html ()
3319 "Assume the current region has org-mode syntax, and convert it to HTML.
3320 This can be used in any buffer. For example, you can write an
3321 itemized list in org-mode syntax in an HTML buffer and use this
3322 command to convert it."
3324 (org-export-replace-region-by 'html
))
3327 (defun org-html-export-to-html
3328 (&optional async subtreep visible-only body-only ext-plist
)
3329 "Export current buffer to a HTML file.
3331 If narrowing is active in the current buffer, only export its
3334 If a region is active, export that region.
3336 A non-nil optional argument ASYNC means the process should happen
3337 asynchronously. The resulting file should be accessible through
3338 the `org-export-stack' interface.
3340 When optional argument SUBTREEP is non-nil, export the sub-tree
3341 at point, extracting information from the headline properties
3344 When optional argument VISIBLE-ONLY is non-nil, don't export
3345 contents of hidden elements.
3347 When optional argument BODY-ONLY is non-nil, only write code
3348 between \"<body>\" and \"</body>\" tags.
3350 EXT-PLIST, when provided, is a property list with external
3351 parameters overriding Org default settings, but still inferior to
3352 file-local settings.
3354 Return output file's name."
3356 (let* ((extension (concat "." org-html-extension
))
3357 (file (org-export-output-file-name extension subtreep
))
3358 (org-export-coding-system org-html-coding-system
))
3360 (org-export-async-start
3361 (lambda (f) (org-export-add-to-stack f
'html
))
3362 (let ((org-export-coding-system org-html-coding-system
))
3365 'html
,file
,subtreep
,visible-only
,body-only
',ext-plist
))))
3366 (let ((org-export-coding-system org-html-coding-system
))
3368 'html file subtreep visible-only body-only ext-plist
)))))
3371 (defun org-html-publish-to-html (plist filename pub-dir
)
3372 "Publish an org file to HTML.
3374 FILENAME is the filename of the Org file to be published. PLIST
3375 is the property list for the given project. PUB-DIR is the
3376 publishing directory.
3378 Return output file name."
3379 (org-publish-org-to 'html filename
3380 (concat "." (or (plist-get plist
:html-extension
)
3381 org-html-extension
"html"))
3387 ;;;; org-format-table-html
3388 ;;;; org-format-org-table-html
3389 ;;;; org-format-table-table-html
3390 ;;;; org-table-number-fraction
3391 ;;;; org-table-number-regexp
3392 ;;;; org-html-inline-image-extensions
3393 ;;;; org-export-preferred-target-alist
3394 ;;;; class for anchors
3395 ;;;; org-export-mark-todo-in-toc
3396 ;;;; org-html-format-org-link
3397 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
3398 ;;;; alt = (file-name-nondirectory path)
3403 ;; generated-autoload-file: "org-loaddefs.el"
3406 ;;; ox-html.el ends here