1 ;;; ox-html.el --- HTML Back-End for Org Export Engine
3 ;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Jambunathan K <kjambunathan at gmail dot com>
7 ;; Keywords: outlines, hypermedia, calendar, wp
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;; This library implements a HTML back-end for Org generic exporter.
28 ;; M-x org-html-export-as-html
30 ;; in an Org mode buffer. See ox.el for more details on how this
39 (require 'format-spec
)
40 (eval-when-compile (require 'cl
) (require 'table nil
'noerror
))
43 ;;; Function Declarations
45 (declare-function org-id-find-id-file
"org-id" (id))
46 (declare-function htmlize-region
"ext:htmlize" (beg end
))
47 (declare-function org-pop-to-buffer-same-window
48 "org-compat" (&optional buffer-or-name norecord label
))
49 (declare-function mm-url-decode-entities
"mm-url" ())
53 (org-export-define-backend 'html
54 '((bold . org-html-bold
)
55 (center-block . org-html-center-block
)
56 (clock . org-html-clock
)
57 (code . org-html-code
)
58 (drawer . org-html-drawer
)
59 (dynamic-block . org-html-dynamic-block
)
60 (entity . org-html-entity
)
61 (example-block . org-html-example-block
)
62 (export-block . org-html-export-block
)
63 (export-snippet . org-html-export-snippet
)
64 (fixed-width . org-html-fixed-width
)
65 (footnote-definition . org-html-footnote-definition
)
66 (footnote-reference . org-html-footnote-reference
)
67 (headline . org-html-headline
)
68 (horizontal-rule . org-html-horizontal-rule
)
69 (inline-src-block . org-html-inline-src-block
)
70 (inlinetask . org-html-inlinetask
)
71 (inner-template . org-html-inner-template
)
72 (italic . org-html-italic
)
73 (item . org-html-item
)
74 (keyword . org-html-keyword
)
75 (latex-environment . org-html-latex-environment
)
76 (latex-fragment . org-html-latex-fragment
)
77 (line-break . org-html-line-break
)
78 (link . org-html-link
)
79 (paragraph . org-html-paragraph
)
80 (plain-list . org-html-plain-list
)
81 (plain-text . org-html-plain-text
)
82 (planning . org-html-planning
)
83 (property-drawer . org-html-property-drawer
)
84 (quote-block . org-html-quote-block
)
85 (quote-section . org-html-quote-section
)
86 (radio-target . org-html-radio-target
)
87 (section . org-html-section
)
88 (special-block . org-html-special-block
)
89 (src-block . org-html-src-block
)
90 (statistics-cookie . org-html-statistics-cookie
)
91 (strike-through . org-html-strike-through
)
92 (subscript . org-html-subscript
)
93 (superscript . org-html-superscript
)
94 (table . org-html-table
)
95 (table-cell . org-html-table-cell
)
96 (table-row . org-html-table-row
)
97 (target . org-html-target
)
98 (template . org-html-template
)
99 (timestamp . org-html-timestamp
)
100 (underline . org-html-underline
)
101 (verbatim . org-html-verbatim
)
102 (verse-block . org-html-verse-block
))
104 :filters-alist
'((:filter-options . org-html-infojs-install-script
)
105 (:filter-final-output . org-html-final-function
))
107 '(?h
"Export to HTML"
108 ((?H
"As HTML buffer" org-html-export-as-html
)
109 (?h
"As HTML file" org-html-export-to-html
)
110 (?o
"As HTML file and open"
112 (if a
(org-html-export-to-html t s v b
)
113 (org-open-file (org-html-export-to-html nil s v b
)))))))
115 '((:html-extension nil nil org-html-extension
)
116 (:html-link-org-as-html nil nil org-html-link-org-files-as-html
)
117 (:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
118 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
119 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
120 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
121 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
122 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
123 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
124 (:html-postamble nil
"html-postamble" org-html-postamble
)
125 (:html-preamble nil
"html-preamble" org-html-preamble
)
126 (:html-head
"HTML_HEAD" nil org-html-head newline
)
127 (:html-head-extra
"HTML_HEAD_EXTRA" nil org-html-head-extra newline
)
128 (:html-head-include-default-style nil
"html-style" org-html-head-include-default-style
)
129 (:html-head-include-scripts nil
"html-scripts" org-html-head-include-scripts
)
130 (:html-table-attributes nil nil org-html-table-default-attributes
)
131 (:html-table-row-tags nil nil org-html-table-row-tags
)
132 (:html-xml-declaration nil nil org-html-xml-declaration
)
133 (:html-inline-images nil nil org-html-inline-images
)
134 (:infojs-opt
"INFOJS_OPT" nil nil
)
135 ;; Redefine regular options.
136 (:creator
"CREATOR" nil org-html-creator-string
)
137 (:with-latex nil
"tex" org-html-with-latex
)))
140 ;;; Internal Variables
142 (defvar org-html-format-table-no-css
)
143 (defvar htmlize-buffer-places
) ; from htmlize.el
145 (defvar org-html--pre
/postamble-class
"status"
146 "CSS class used for pre/postamble")
148 (defconst org-html-doctype-alist
149 '(("html4-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
150 \"http://www.w3.org/TR/html4/strict.dtd\">")
151 ("html4-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
152 \"http://www.w3.org/TR/html4/loose.dtd\">")
153 ("html4-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
154 \"http://www.w3.org/TR/html4/frameset.dtd\">")
156 ("xhtml-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
157 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
158 ("xhtml-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
159 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
160 ("xhtml-framset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
161 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
162 ("xhtml-11" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
163 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
165 ("html5" .
"<!DOCTYPE html>")
166 ("xhtml5" .
"<!DOCTYPE html>"))
167 "An alist mapping (x)html flavors to specific doctypes.")
169 (defconst org-html-html5-elements
170 '("article" "aside" "audio" "canvas" "details" "figcaption"
171 "figure" "footer" "header" "menu" "meter" "nav" "output"
172 "progress" "section" "video")
173 "New elements in html5.
175 <hgroup> is not included because it's currently impossible to
176 wrap special blocks around multiple headlines. For other blocks
177 that should contain headlines, use the HTML_CONTAINER property on
178 the headline itself.")
180 (defconst org-html-special-string-regexps
181 '(("\\\\-" .
"­") ; shy
182 ("---\\([^-]\\)" .
"—\\1") ; mdash
183 ("--\\([^-]\\)" .
"–\\1") ; ndash
184 ("\\.\\.\\." .
"…")) ; hellip
185 "Regular expressions for special string conversion.")
187 (defconst org-html-scripts
188 "<script type=\"text/javascript\">
190 @licstart The following is the entire license notice for the
191 JavaScript code in this tag.
193 Copyright (C) 2012 Free Software Foundation, Inc.
195 The JavaScript code in this tag is free software: you can
196 redistribute it and/or modify it under the terms of the GNU
197 General Public License (GNU GPL) as published by the Free Software
198 Foundation, either version 3 of the License, or (at your option)
199 any later version. The code is distributed WITHOUT ANY WARRANTY;
200 without even the implied warranty of MERCHANTABILITY or FITNESS
201 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
203 As additional permission under GNU GPL version 3 section 7, you
204 may distribute non-source (e.g., minimized or compacted) forms of
205 that code without the copy of the GNU GPL normally required by
206 section 4, provided you include this license notice and a URL
207 through which recipients can access the Corresponding Source.
210 @licend The above is the entire license notice
211 for the JavaScript code in this tag.
213 <!--/*--><![CDATA[/*><!--*/
214 function CodeHighlightOn(elem, id)
216 var target = document.getElementById(id);
218 elem.cacheClassElem = elem.className;
219 elem.cacheClassTarget = target.className;
220 target.className = \"code-highlighted\";
221 elem.className = \"code-highlighted\";
224 function CodeHighlightOff(elem, id)
226 var target = document.getElementById(id);
227 if(elem.cacheClassElem)
228 elem.className = elem.cacheClassElem;
229 if(elem.cacheClassTarget)
230 target.className = elem.cacheClassTarget;
234 "Basic JavaScript that is needed by HTML files produced by Org mode.")
236 (defconst org-html-style-default
237 "<style type=\"text/css\">
238 <!--/*--><![CDATA[/*><!--*/
239 .title { text-align: center; }
240 .todo { font-family: monospace; color: red; }
241 .done { color: green; }
242 .tag { background-color: #eee; font-family: monospace;
243 padding: 2px; font-size: 80%; font-weight: normal; }
244 .timestamp { color: #bebebe; }
245 .timestamp-kwd { color: #5f9ea0; }
246 .right { margin-left: auto; margin-right: 0px; text-align: right; }
247 .left { margin-left: 0px; margin-right: auto; text-align: left; }
248 .center { margin-left: auto; margin-right: auto; text-align: center; }
249 .underline { text-decoration: underline; }
250 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
251 p.verse { margin-left: 3%; }
253 border: 1px solid #ccc;
254 box-shadow: 3px 3px 3px #eee;
256 font-family: monospace;
268 background-color: white;
272 border: 1px solid black;
274 pre.src:hover:before { display: inline;}
275 pre.src-sh:before { content: 'sh'; }
276 pre.src-bash:before { content: 'sh'; }
277 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
278 pre.src-R:before { content: 'R'; }
279 pre.src-perl:before { content: 'Perl'; }
280 pre.src-java:before { content: 'Java'; }
281 pre.src-sql:before { content: 'SQL'; }
283 table { border-collapse:collapse; }
284 td, th { vertical-align:top; }
285 th.right { text-align: center; }
286 th.left { text-align: center; }
287 th.center { text-align: center; }
288 td.right { text-align: right; }
289 td.left { text-align: left; }
290 td.center { text-align: center; }
291 dt { font-weight: bold; }
292 .footpara:nth-child(2) { display: inline; }
293 .footpara { display: block; }
294 .footdef { margin-bottom: 1em; }
295 .figure { padding: 1em; }
296 .figure p { text-align: center; }
299 border: 2px solid gray;
304 { text-align: right; font-size: 70%; white-space: nowrap; }
305 textarea { overflow-x: auto; }
306 .linenr { font-size: smaller }
307 .code-highlighted { background-color: #ffff00; }
308 .org-info-js_info-navigation { border-style: none; }
309 #org-info-js_console-label
310 { font-size: 10px; font-weight: bold; white-space: nowrap; }
311 .org-info-js_search-highlight
312 { background-color: #ffff00; color: #000000; font-weight: bold; }
315 "The default style specification for exported HTML files.
316 You can use `org-html-head' and `org-html-head-extra' to add to
317 this style. If you don't want to include this default style,
318 customize `org-html-head-include-default-style'.")
321 ;;; User Configuration Variables
323 (defgroup org-export-html nil
324 "Options for exporting Org mode files to HTML."
325 :tag
"Org Export HTML"
330 (defvar org-html-infojs-opts-table
331 '((path PATH
"http://orgmode.org/org-info.js")
335 (tdepth TOC_DEPTH
"max")
336 (sdepth SECTION_DEPTH
"max")
337 (mouse MOUSE_HINT
"underline")
338 (buttons VIEW_BUTTONS
"0")
340 (up LINK_UP
:html-link-up
)
341 (home LINK_HOME
:html-link-home
))
342 "JavaScript options, long form for script, default values.")
344 (defcustom org-html-use-infojs
'when-configured
345 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
346 This option can be nil or t to never or always use the script.
347 It can also be the symbol `when-configured', meaning that the
348 script will be linked into the export file if and only if there
349 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
350 `org-html-infojs-options'."
351 :group
'org-export-html
353 :package-version
'(Org .
"8.0")
355 (const :tag
"Never" nil
)
356 (const :tag
"When configured in buffer" when-configured
)
357 (const :tag
"Always" t
)))
359 (defcustom org-html-infojs-options
360 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
361 "Options settings for the INFOJS JavaScript.
362 Each of the options must have an entry in `org-html-infojs-opts-table'.
363 The value can either be a string that will be passed to the script, or
364 a property. This property is then assumed to be a property that is defined
365 by the Export/Publishing setup of Org.
366 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
367 means to use the maximum value consistent with other options."
368 :group
'org-export-html
370 :package-version
'(Org .
"8.0")
372 `(set :greedy t
:inline t
375 (list 'cons
(list 'const
(car x
))
377 (symbol :tag
"Publishing/Export property")
378 (string :tag
"Value"))))
379 org-html-infojs-opts-table
)))
381 (defcustom org-html-infojs-template
382 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
385 * @source: %SCRIPT_PATH
387 * @licstart The following is the entire license notice for the
388 * JavaScript code in %SCRIPT_PATH.
390 * Copyright (C) 2012-2013 Sebastian Rose
393 * The JavaScript code in this tag is free software: you can
394 * redistribute it and/or modify it under the terms of the GNU
395 * General Public License (GNU GPL) as published by the Free Software
396 * Foundation, either version 3 of the License, or (at your option)
397 * any later version. The code is distributed WITHOUT ANY WARRANTY;
398 * without even the implied warranty of MERCHANTABILITY or FITNESS
399 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
401 * As additional permission under GNU GPL version 3 section 7, you
402 * may distribute non-source (e.g., minimized or compacted) forms of
403 * that code without the copy of the GNU GPL normally required by
404 * section 4, provided you include this license notice and a URL
405 * through which recipients can access the Corresponding Source.
407 * @licend The above is the entire license notice
408 * for the JavaScript code in %SCRIPT_PATH.
413 <script type=\"text/javascript\">
416 @licstart The following is the entire license notice for the
417 JavaScript code in this tag.
419 Copyright (C) 2012-2013 Free Software Foundation, Inc.
421 The JavaScript code in this tag is free software: you can
422 redistribute it and/or modify it under the terms of the GNU
423 General Public License (GNU GPL) as published by the Free Software
424 Foundation, either version 3 of the License, or (at your option)
425 any later version. The code is distributed WITHOUT ANY WARRANTY;
426 without even the implied warranty of MERCHANTABILITY or FITNESS
427 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
429 As additional permission under GNU GPL version 3 section 7, you
430 may distribute non-source (e.g., minimized or compacted) forms of
431 that code without the copy of the GNU GPL normally required by
432 section 4, provided you include this license notice and a URL
433 through which recipients can access the Corresponding Source.
436 @licend The above is the entire license notice
437 for the JavaScript code in this tag.
440 <!--/*--><![CDATA[/*><!--*/
442 org_html_manager.setup(); // activate after the parameters are set
445 "The template for the export style additions when org-info.js is used.
446 Option settings will replace the %MANAGER-OPTIONS cookie."
447 :group
'org-export-html
449 :package-version
'(Org .
"8.0")
452 (defun org-html-infojs-install-script (exp-plist backend
)
453 "Install script in export options when appropriate.
454 EXP-PLIST is a plist containing export options. BACKEND is the
455 export back-end currently used."
456 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
457 (not org-html-use-infojs
)
458 (and (eq org-html-use-infojs
'when-configured
)
459 (or (not (plist-get exp-plist
:infojs-opt
))
460 (string-match "\\<view:nil\\>"
461 (plist-get exp-plist
:infojs-opt
)))))
462 (let* ((template org-html-infojs-template
)
463 (ptoc (plist-get exp-plist
:with-toc
))
464 (hlevels (plist-get exp-plist
:headline-levels
))
466 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
467 (options (plist-get exp-plist
:infojs-opt
))
468 (table org-html-infojs-opts-table
)
470 (dolist (entry table
)
471 (let* ((opt (car entry
))
473 ;; Compute default values for script option OPT from
474 ;; `org-html-infojs-options' variable.
476 (let ((default (cdr (assq opt org-html-infojs-options
))))
477 (if (and (symbolp default
) (not (memq default
'(t nil
))))
478 (plist-get exp-plist default
)
480 ;; Value set through INFOJS_OPT keyword has precedence
481 ;; over the default one.
482 (val (if (and options
483 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
485 (match-string 1 options
)
489 (replace-regexp-in-string
490 "%SCRIPT_PATH" val template t t
)))
491 (sdepth (when (integerp (read val
))
492 (setq sdepth
(min (read val
) sdepth
))))
493 (tdepth (when (integerp (read val
))
494 (setq tdepth
(min (read val
) tdepth
))))
497 ((or (eq val t
) (equal val
"t")) "1")
498 ((or (eq val nil
) (equal val
"nil")) "0")
500 (t (format "%s" val
))))
501 (push (cons var val
) style
)))))
502 ;; Now we set the depth of the *generated* TOC to SDEPTH,
503 ;; because the toc will actually determine the splitting. How
504 ;; much of the toc will actually be displayed is governed by the
506 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
507 ;; The table of contents should not show more sections than we
509 (setq tdepth
(min tdepth sdepth
))
510 (push (cons "TOC_DEPTH" tdepth
) style
)
511 ;; Build style string.
512 (setq style
(mapconcat
513 (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
517 (when (and style
(> (length style
) 0))
518 (and (string-match "%MANAGER_OPTIONS" template
)
519 (setq style
(replace-match style t t template
))
522 exp-plist
:html-head-extra
523 (concat (or (plist-get exp-plist
:html-head-extra
) "")
526 ;; This script absolutely needs the table of contents, so we
527 ;; change that setting.
528 (unless (plist-get exp-plist
:with-toc
)
529 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
530 ;; Return the modified property list.
535 (defcustom org-html-text-markup-alist
536 '((bold .
"<b>%s</b>")
537 (code .
"<code>%s</code>")
538 (italic .
"<i>%s</i>")
539 (strike-through .
"<del>%s</del>")
540 (underline .
"<span class=\"underline\">%s</span>")
541 (verbatim .
"<code>%s</code>"))
542 "Alist of HTML expressions to convert text markup.
544 The key must be a symbol among `bold', `code', `italic',
545 `strike-through', `underline' and `verbatim'. The value is
546 a formatting string to wrap fontified text with.
548 If no association can be found for a given markup, text will be
550 :group
'org-export-html
551 :type
'(alist :key-type
(symbol :tag
"Markup type")
552 :value-type
(string :tag
"Format string"))
553 :options
'(bold code italic strike-through underline verbatim
))
555 (defcustom org-html-indent nil
556 "Non-nil means to indent the generated HTML.
557 Warning: non-nil may break indentation of source code blocks."
558 :group
'org-export-html
560 :package-version
'(Org .
"8.0")
563 (defcustom org-html-use-unicode-chars nil
564 "Non-nil means to use unicode characters instead of HTML entities."
565 :group
'org-export-html
567 :package-version
'(Org .
"8.0")
572 (defcustom org-html-format-drawer-function nil
573 "Function called to format a drawer in HTML code.
575 The function must accept two parameters:
576 NAME the drawer name, like \"LOGBOOK\"
577 CONTENTS the contents of the drawer.
579 The function should return the string to be exported.
581 For example, the variable could be set to the following function
582 in order to mimic default behaviour:
584 \(defun org-html-format-drawer-default \(name contents\)
585 \"Format a drawer element for HTML export.\"
587 :group
'org-export-html
592 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
593 <h2 class=\"footnotes\">%s: </h2>
594 <div id=\"text-footnotes\">
598 "Format for the footnotes section.
599 Should contain a two instances of %s. The first will be replaced with the
600 language-specific word for \"Footnotes\", the second one will be replaced
601 by the footnotes themselves."
602 :group
'org-export-html
605 (defcustom org-html-footnote-format
"<sup>%s</sup>"
606 "The format for the footnote reference.
607 %s will be replaced by the footnote reference itself."
608 :group
'org-export-html
611 (defcustom org-html-footnote-separator
"<sup>, </sup>"
612 "Text used to separate footnotes."
613 :group
'org-export-html
618 (defcustom org-html-toplevel-hlevel
2
619 "The <H> level for level 1 headings in HTML export.
620 This is also important for the classes that will be wrapped around headlines
621 and outline structure. If this variable is 1, the top-level headlines will
622 be <h1>, and the corresponding classes will be outline-1, section-number-1,
623 and outline-text-1. If this is 2, all of these will get a 2 instead.
624 The default for this variable is 2, because we use <h1> for formatting the
626 :group
'org-export-html
629 (defcustom org-html-format-headline-function nil
630 "Function to format headline text.
632 This function will be called with 5 arguments:
633 TODO the todo keyword (string or nil).
634 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
635 PRIORITY the priority of the headline (integer or nil)
636 TEXT the main headline text (string).
637 TAGS the tags (string or nil).
639 The function result will be used in the section format string."
640 :group
'org-export-html
645 (defcustom org-html-allow-name-attribute-in-anchors t
646 "When nil, do not set \"name\" attribute in anchors.
647 By default, anchors are formatted with both \"id\" and \"name\"
648 attributes, when appropriate."
649 :group
'org-export-html
651 :package-version
'(Org .
"8.0")
656 (defcustom org-html-format-inlinetask-function nil
657 "Function called to format an inlinetask in HTML code.
659 The function must accept six parameters:
660 TODO the todo keyword, as a string
661 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
662 PRIORITY the inlinetask priority, as a string
663 NAME the inlinetask name, as a string.
664 TAGS the inlinetask tags, as a list of strings.
665 CONTENTS the contents of the inlinetask, as a string.
667 The function should return the string to be exported."
668 :group
'org-export-html
673 (defcustom org-html-with-latex org-export-with-latex
674 "Non-nil means process LaTeX math snippets.
676 When set, the exporter will process LaTeX environments and
679 This option can also be set with the +OPTIONS line,
680 e.g. \"tex:mathjax\". Allowed values are:
682 nil Ignore math snippets.
683 `verbatim' Keep everything in verbatim
684 `dvipng' Process the LaTeX fragments to images. This will also
685 include processing of non-math environments.
686 `imagemagick' Convert the LaTeX fragments to pdf files and use
687 imagemagick to convert pdf files to png files.
688 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
690 t Synonym for `mathjax'."
691 :group
'org-export-html
693 :package-version
'(Org .
"8.0")
695 (const :tag
"Do not process math in any way" nil
)
696 (const :tag
"Use dvipng to make images" dvipng
)
697 (const :tag
"Use imagemagick to make images" imagemagick
)
698 (const :tag
"Use MathJax to display math" mathjax
)
699 (const :tag
"Leave math verbatim" verbatim
)))
701 ;;;; Links :: Generic
703 (defcustom org-html-link-org-files-as-html t
704 "Non-nil means make file links to `file.org' point to `file.html'.
705 When `org-mode' is exporting an `org-mode' file to HTML, links to
706 non-html files are directly put into a href tag in HTML.
707 However, links to other Org-mode files (recognized by the
708 extension `.org.) should become links to the corresponding html
709 file, assuming that the linked `org-mode' file will also be
711 When nil, the links still point to the plain `.org' file."
712 :group
'org-export-html
715 ;;;; Links :: Inline images
717 (defcustom org-html-inline-images
'maybe
718 "Non-nil means inline images into exported HTML pages.
719 This is done using an <img> tag. When nil, an anchor with href is used to
720 link to the image. If this option is `maybe', then images in links with
721 an empty description will be inlined, while images with a description will
723 :group
'org-export-html
724 :type
'(choice (const :tag
"Never" nil
)
725 (const :tag
"Always" t
)
726 (const :tag
"When there is no description" maybe
)))
728 (defcustom org-html-inline-image-rules
729 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
730 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
731 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
732 "Rules characterizing image files that can be inlined into HTML.
733 A rule consists in an association whose key is the type of link
734 to consider, and value is a regexp that will be matched against
736 :group
'org-export-html
738 :package-version
'(Org .
"8.0")
739 :type
'(alist :key-type
(string :tag
"Type")
740 :value-type
(regexp :tag
"Path")))
744 (defcustom org-html-protect-char-alist
748 "Alist of characters to be converted by `org-html-protect'."
749 :group
'org-export-html
750 :type
'(repeat (cons (string :tag
"Character")
751 (string :tag
"HTML equivalent"))))
755 (defcustom org-html-htmlize-output-type
'inline-css
756 "Output type to be used by htmlize when formatting code snippets.
757 Choices are `css', to export the CSS selectors only, or `inline-css', to
758 export the CSS attribute values inline in the HTML. We use as default
759 `inline-css', in order to make the resulting HTML self-containing.
761 However, this will fail when using Emacs in batch mode for export, because
762 then no rich font definitions are in place. It will also not be good if
763 people with different Emacs setup contribute HTML files to a website,
764 because the fonts will represent the individual setups. In these cases,
765 it is much better to let Org/Htmlize assign classes only, and to use
766 a style file to define the look of these classes.
767 To get a start for your css file, start Emacs session and make sure that
768 all the faces you are interested in are defined, for example by loading files
769 in all modes you want. Then, use the command
770 \\[org-html-htmlize-generate-css] to extract class definitions."
771 :group
'org-export-html
772 :type
'(choice (const css
) (const inline-css
)))
774 (defcustom org-html-htmlize-font-prefix
"org-"
775 "The prefix for CSS class names for htmlize font specifications."
776 :group
'org-export-html
781 (defcustom org-html-table-default-attributes
782 '(:border
"2" :cellspacing
"0" :cellpadding
"6" :rules
"groups" :frame
"hsides")
783 "Default attributes and values which will be used in table tags.
784 This is a plist where attributes are symbols, starting with
785 colons, and values are strings.
787 When exporting to HTML5, these values will be disregarded."
788 :group
'org-export-html
790 :package-version
'(Org .
"8.0")
791 :type
'(plist :key-type
(symbol :tag
"Property")
792 :value-type
(string :tag
"Value")))
794 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
795 "The opening tag for table header fields.
796 This is customizable so that alignment options can be specified.
797 The first %s will be filled with the scope of the field, either row or col.
798 The second %s will be replaced by a style entry to align the field.
799 See also the variable `org-html-table-use-header-tags-for-first-column'.
800 See also the variable `org-html-table-align-individual-fields'."
801 :group
'org-export-html
802 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
804 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
805 "The opening tag for table data fields.
806 This is customizable so that alignment options can be specified.
807 The first %s will be filled with the scope of the field, either row or col.
808 The second %s will be replaced by a style entry to align the field.
809 See also the variable `org-html-table-align-individual-fields'."
810 :group
'org-export-html
811 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
813 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
814 "The opening and ending tags for table rows.
815 This is customizable so that alignment options can be specified.
816 Instead of strings, these can be Lisp forms that will be
817 evaluated for each row in order to construct the table row tags.
819 During evaluation, these variables will be dynamically bound so that
822 `row-number': row number (0 is the first row)
823 `rowgroup-number': group number of current row
824 `start-rowgroup-p': non-nil means the row starts a group
825 `end-rowgroup-p': non-nil means the row ends a group
826 `top-row-p': non-nil means this is the top row
827 `bottom-row-p': non-nil means this is the bottom row
831 \(setq org-html-table-row-tags
832 (cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
833 (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
834 (t (if (= (mod row-number 2) 1)
835 \"<tr class=\\\"tr-odd\\\">\"
836 \"<tr class=\\\"tr-even\\\">\")))
839 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
840 and the bottom row, and otherwise alternate between \"tr-odd\" and
841 \"tr-even\" for odd and even rows."
842 :group
'org-export-html
844 (choice :tag
"Opening tag"
845 (string :tag
"Specify")
847 (choice :tag
"Closing tag"
848 (string :tag
"Specify")
851 (defcustom org-html-table-align-individual-fields t
852 "Non-nil means attach style attributes for alignment to each table field.
853 When nil, alignment will only be specified in the column tags, but this
854 is ignored by some browsers (like Firefox, Safari). Opera does it right
856 :group
'org-export-html
859 (defcustom org-html-table-use-header-tags-for-first-column nil
860 "Non-nil means format column one in tables with header tags.
861 When nil, also column one will use data tags."
862 :group
'org-export-html
865 (defcustom org-html-table-caption-above t
866 "When non-nil, place caption string at the beginning of the table.
867 Otherwise, place it near the end."
868 :group
'org-export-html
873 (defcustom org-html-tag-class-prefix
""
874 "Prefix to class names for TODO keywords.
875 Each tag gets a class given by the tag itself, with this prefix.
876 The default prefix is empty because it is nice to just use the keyword
877 as a class name. But if you get into conflicts with other, existing
878 CSS classes, then this prefix can be very useful."
879 :group
'org-export-html
882 ;;;; Template :: Generic
884 (defcustom org-html-extension
"html"
885 "The extension for exported HTML files."
886 :group
'org-export-html
889 (defcustom org-html-xml-declaration
890 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
891 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
892 "The extension for exported HTML files.
893 %s will be replaced with the charset of the exported file.
894 This may be a string, or an alist with export extensions
895 and corresponding declarations.
897 This declaration only applies when exporting to XHTML."
898 :group
'org-export-html
900 (string :tag
"Single declaration")
901 (repeat :tag
"Dependent on extension"
902 (cons (string :tag
"Extension")
903 (string :tag
"Declaration")))))
905 (defcustom org-html-coding-system
'utf-8
906 "Coding system for HTML export.
907 Use utf-8 as the default value."
908 :group
'org-export-html
910 :package-version
'(Org .
"8.0")
911 :type
'coding-system
)
913 (defcustom org-html-doctype
"xhtml-strict"
914 "Document type definition to use for exported HTML files.
915 Can be set with the in-buffer HTML_DOCTYPE property or for
916 publishing, with :html-doctype."
917 :group
'org-export-html
919 :package-version
'(Org .
"8.0")
922 (defcustom org-html-html5-fancy nil
923 "Non-nil means using new HTML5 elements.
924 This variable is ignored for anything other than HTML5 export.
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-link-use-abs-url nil
1191 "Should we prepend relative links with HTML_LINK_HOME?"
1192 :group
'org-export-html
1194 :package-version
'(Org .
"8.1")
1197 (defcustom org-html-home
/up-format
1198 "<div id=\"org-div-home-and-up\">
1199 <a accesskey=\"h\" href=\"%s\"> UP </a>
1201 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1203 "Snippet used to insert the HOME and UP links.
1204 This is a format string, the first %s will receive the UP link,
1205 the second the HOME link. If both `org-html-link-up' and
1206 `org-html-link-home' are empty, the entire snippet will be
1208 :group
'org-export-html
1211 ;;;; Template :: Scripts
1213 (define-obsolete-variable-alias
1214 'org-html-style-include-scripts
'org-html-head-include-scripts
"24.4")
1215 (defcustom org-html-head-include-scripts t
1216 "Non-nil means include the JavaScript snippets in exported HTML files.
1217 The actual script is defined in `org-html-scripts' and should
1219 :group
'org-export-html
1221 :package-version
'(Org .
"8.0")
1224 ;;;; Template :: Styles
1226 (define-obsolete-variable-alias
1227 'org-html-style-include-default
'org-html-head-include-default-style
"24.4")
1228 (defcustom org-html-head-include-default-style t
1229 "Non-nil means include the default style in exported HTML files.
1230 The actual style is defined in `org-html-style-default' and
1231 should not be modified. Use `org-html-head' to use your own
1233 :group
'org-export-html
1235 :package-version
'(Org .
"8.0")
1238 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1240 (define-obsolete-variable-alias 'org-html-style
'org-html-head
"24.4")
1241 (defcustom org-html-head
""
1242 "Org-wide head definitions for exported HTML files.
1244 This variable can contain the full HTML structure to provide a
1245 style, including the surrounding HTML tags. You can consider
1246 including definitions for the following classes: title, todo,
1247 done, timestamp, timestamp-kwd, tag, target.
1249 For example, a valid value would be:
1251 <style type=\"text/css\">
1253 p { font-weight: normal; color: gray; }
1254 h1 { color: black; }
1255 .title { text-align: center; }
1256 .todo, .timestamp-kwd { color: red; }
1257 .done { color: green; }
1261 If you want to refer to an external style, use something like
1263 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1265 As the value of this option simply gets inserted into the HTML
1266 <head> header, you can use it to add any arbitrary text to the
1269 You can set this on a per-file basis using #+HTML_HEAD:,
1270 or for publication projects using the :html-head property."
1271 :group
'org-export-html
1273 :package-version
'(Org .
"8.0")
1276 (put 'org-html-head
'safe-local-variable
'stringp
)
1278 (defcustom org-html-head-extra
""
1279 "More head information to add in the HTML output.
1281 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1282 or for publication projects using the :html-head-extra property."
1283 :group
'org-export-html
1285 :package-version
'(Org .
"8.0")
1288 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1292 (defcustom org-html-todo-kwd-class-prefix
""
1293 "Prefix to class names for TODO keywords.
1294 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1295 The default prefix is empty because it is nice to just use the keyword
1296 as a class name. But if you get into conflicts with other, existing
1297 CSS classes, then this prefix can be very useful."
1298 :group
'org-export-html
1302 ;;; Internal Functions
1304 (defun org-html-xhtml-p (info)
1305 (let ((dt (downcase (plist-get info
:html-doctype
))))
1306 (string-match-p "xhtml" dt
)))
1308 (defun org-html-html5-p (info)
1309 (let ((dt (downcase (plist-get info
:html-doctype
))))
1310 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1312 (defun org-html-close-tag (tag attr info
)
1313 (concat "<" tag
" " attr
1314 (if (org-html-xhtml-p info
) " />" ">")))
1316 (defun org-html-doctype (info)
1317 "Return correct html doctype tag from `org-html-doctype-alist',
1318 or the literal value of :html-doctype from INFO if :html-doctype
1319 is not found in the alist.
1320 INFO is a plist used as a communication channel."
1321 (let ((dt (plist-get info
:html-doctype
)))
1322 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1324 (defun org-html--make-attribute-string (attributes)
1325 "Return a list of attributes, as a string.
1326 ATTRIBUTES is a plist where values are either strings or nil. An
1327 attributes with a nil value will be omitted from the result."
1329 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1330 (cond ((null item
) (pop output
))
1331 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1332 (t (let ((key (car output
))
1333 (value (replace-regexp-in-string
1334 "\"" """ (org-html-encode-plain-text item
))))
1335 (setcar output
(format "%s=\"%s\"" key value
))))))))
1337 (defun org-html-format-inline-image (src info
&optional
1338 caption label attr standalone-p
)
1339 "Format an inline image from SRC.
1340 CAPTION, LABEL and ATTR are optional arguments providing the
1341 caption, the label and the attribute of the image.
1342 When STANDALONE-P is t, wrap the <img.../> into a <div>...</div>."
1343 (let* ((id (if (not label
) ""
1344 (format " id=\"%s\"" (org-export-solidify-link-text label
))))
1346 (format " src=\"%s\"" src
)
1348 ((string-match "\\<alt=" (or attr
"")) "")
1349 ((string-match "^ltxpng/" src
)
1350 (format " alt=\"%s\""
1351 (org-html-encode-plain-text
1352 (org-find-text-property-in-string
1353 'org-latex-src src
))))
1354 (t (format " alt=\"%s\""
1355 (file-name-nondirectory src
))))))
1356 (html5-fancy (and (org-html-html5-p info
)
1357 (plist-get info
:html-html5-fancy
))))
1360 (let ((img (org-html-close-tag "img" attr info
)))
1361 (format (if html5-fancy
1362 "\n<figure%s>%s%s\n</figure>"
1363 "\n<div%s class=\"figure\">%s%s\n</div>")
1364 id
(format "\n<p>%s</p>" img
)
1365 (if (and caption
(not (string= caption
"")))
1366 (format (if html5-fancy
1367 "\n<figcaption>%s</figcaption>"
1368 "\n<p>%s</p>") caption
) ""))))
1369 (t (org-html-close-tag "img" (concat attr id
) info
)))))
1371 (defun org-html--textarea-block (element)
1372 "Transcode ELEMENT into a textarea block.
1373 ELEMENT is either a src block or an example block."
1374 (let* ((code (car (org-export-unravel-code element
)))
1375 (attr (org-export-read-attribute :attr_html element
)))
1376 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1377 (or (plist-get attr
:width
) 80)
1378 (or (plist-get attr
:height
) (org-count-lines code
))
1381 (defun org-html--has-caption-p (element &optional info
)
1382 "Non-nil when ELEMENT has a caption affiliated keyword.
1383 INFO is a plist used as a communication channel. This function
1384 is meant to be used as a predicate for `org-export-get-ordinal' or
1385 a value to `org-html-standalone-image-predicate'."
1386 (org-element-property :caption element
))
1390 (defun org-html-htmlize-region-for-paste (beg end
)
1391 "Convert the region between BEG and END to HTML, using htmlize.el.
1392 This is much like `htmlize-region-for-paste', only that it uses
1393 the settings define in the org-... variables."
1394 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1395 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1396 (htmlbuf (htmlize-region beg end
)))
1398 (with-current-buffer htmlbuf
1399 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1400 (plist-get htmlize-buffer-places
'content-end
)))
1401 (kill-buffer htmlbuf
))))
1404 (defun org-html-htmlize-generate-css ()
1405 "Create the CSS for all font definitions in the current Emacs session.
1406 Use this to create face definitions in your CSS style file that can then
1407 be used by code snippets transformed by htmlize.
1408 This command just produces a buffer that contains class definitions for all
1409 faces used in the current Emacs session. You can copy and paste the ones you
1410 need into your CSS file.
1412 If you then set `org-html-htmlize-output-type' to `css', calls
1413 to the function `org-html-htmlize-region-for-paste' will
1414 produce code that uses these same face definitions."
1417 (and (get-buffer "*html*") (kill-buffer "*html*"))
1419 (let ((fl (face-list))
1420 (htmlize-css-name-prefix "org-")
1421 (htmlize-output-type 'css
)
1423 (while (setq f
(pop fl
)
1424 i
(and f
(face-attribute f
:inherit
)))
1425 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1426 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1427 (htmlize-region (point-min) (point-max))))
1428 (org-pop-to-buffer-same-window "*html*")
1429 (goto-char (point-min))
1430 (if (re-search-forward "<style" nil t
)
1431 (delete-region (point-min) (match-beginning 0)))
1432 (if (re-search-forward "</style>" nil t
)
1433 (delete-region (1+ (match-end 0)) (point-max)))
1434 (beginning-of-line 1)
1435 (if (looking-at " +") (replace-match ""))
1436 (goto-char (point-min)))
1438 (defun org-html--make-string (n string
)
1439 "Build a string by concatenating N times STRING."
1440 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1442 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1443 "Turn todo keyword KWD into a valid class name.
1444 Replaces invalid characters with \"_\"."
1446 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1447 (setq kwd
(replace-match "_" t t kwd
))))
1450 (defun org-html-format-footnote-reference (n def refcnt
)
1451 "Format footnote reference N with definition DEF into HTML."
1452 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1453 (format org-html-footnote-format
1454 (let* ((id (format "fnr.%s%s" n extra
))
1455 (href (format " href=\"#fn.%s\"" n
))
1456 (attributes (concat " class=\"footref\"" href
)))
1457 (org-html--anchor id n attributes
)))))
1459 (defun org-html-format-footnotes-section (section-name definitions
)
1460 "Format footnotes section SECTION-NAME."
1461 (if (not definitions
) ""
1462 (format org-html-footnotes-section section-name definitions
)))
1464 (defun org-html-format-footnote-definition (fn)
1465 "Format the footnote definition FN."
1466 (let ((n (car fn
)) (def (cdr fn
)))
1468 "<div class=\"footdef\">%s %s</div>\n"
1469 (format org-html-footnote-format
1470 (let* ((id (format "fn.%s" n
))
1471 (href (format " href=\"#fnr.%s\"" n
))
1472 (attributes (concat " class=\"footnum\"" href
)))
1473 (org-html--anchor id n attributes
)))
1476 (defun org-html-footnote-section (info)
1477 "Format the footnote section.
1478 INFO is a plist used as a communication channel."
1479 (let* ((fn-alist (org-export-collect-footnote-definitions
1480 (plist-get info
:parse-tree
) info
))
1482 (loop for
(n type raw
) in fn-alist collect
1483 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1484 (org-trim (org-export-data raw info
))
1486 (org-trim (org-export-data raw info
))))))))
1488 (org-html-format-footnotes-section
1489 (org-html--translate "Footnotes" info
)
1492 (mapconcat 'org-html-format-footnote-definition fn-alist
"\n"))))))
1497 (defun org-html--build-meta-info (info)
1498 "Return meta tags for exported document.
1499 INFO is a plist used as a communication channel."
1500 (let ((protect-string
1502 (replace-regexp-in-string
1503 "\"" """ (org-html-encode-plain-text str
))))
1504 (title (org-export-data (plist-get info
:title
) info
))
1505 (author (and (plist-get info
:with-author
)
1506 (let ((auth (plist-get info
:author
)))
1508 ;; Return raw Org syntax, skipping non
1509 ;; exportable objects.
1510 (org-element-interpret-data
1511 (org-element-map auth
1512 (cons 'plain-text org-element-all-objects
)
1513 'identity info
))))))
1514 (description (plist-get info
:description
))
1515 (keywords (plist-get info
:keywords
))
1516 (charset (or (and org-html-coding-system
1517 (fboundp 'coding-system-get
)
1518 (coding-system-get org-html-coding-system
1522 (format "<title>%s</title>\n" title
)
1523 (when (plist-get info
:time-stamp-file
)
1525 (concat "<!-- " org-html-metadata-timestamp-format
" -->\n")))
1527 (if (org-html-html5-p info
)
1528 (org-html-close-tag "meta" " charset=\"%s\"" info
)
1530 "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1533 (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info
)
1535 (and (org-string-nw-p author
)
1536 (org-html-close-tag "meta"
1537 (format " name=\"author\" content=\"%s\""
1538 (funcall protect-string author
))
1541 (and (org-string-nw-p description
)
1542 (org-html-close-tag "meta"
1543 (format " name=\"description\" content=\"%s\"\n"
1544 (funcall protect-string description
))
1547 (and (org-string-nw-p keywords
)
1548 (org-html-close-tag "meta"
1549 (format " name=\"keywords\" content=\"%s\""
1550 (funcall protect-string keywords
))
1554 (defun org-html--build-head (info)
1555 "Return information for the <head>..</head> of the HTML output.
1556 INFO is a plist used as a communication channel."
1557 (org-element-normalize-string
1559 (when (plist-get info
:html-head-include-default-style
)
1560 (org-element-normalize-string org-html-style-default
))
1561 (org-element-normalize-string (plist-get info
:html-head
))
1562 (org-element-normalize-string (plist-get info
:html-head-extra
))
1563 (when (and (plist-get info
:html-htmlized-css-url
)
1564 (eq org-html-htmlize-output-type
'css
))
1565 (org-html-close-tag "link"
1566 (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1567 (plist-get info
:html-htmlized-css-url
))
1569 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1571 (defun org-html--build-mathjax-config (info)
1572 "Insert the user setup into the mathjax template.
1573 INFO is a plist used as a communication channel."
1574 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1575 (org-element-map (plist-get info
:parse-tree
)
1576 '(latex-fragment latex-environment
) 'identity info t
))
1577 (let ((template org-html-mathjax-template
)
1578 (options org-html-mathjax-options
)
1579 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1580 name val
(yes " ") (no "// ") x
)
1583 (setq name
(car e
) val
(nth 1 e
))
1584 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1585 (setq val
(car (read-from-string
1586 (substring in-buffer
(match-end 0))))))
1587 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1588 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1589 (setq template
(replace-match val t t template
))))
1591 (setq val
(nth 1 (assq 'mathml options
)))
1592 (if (string-match (concat "\\<mathml:") in-buffer
)
1593 (setq val
(car (read-from-string
1594 (substring in-buffer
(match-end 0))))))
1595 ;; Exchange prefixes depending on mathml setting.
1596 (if (not val
) (setq x yes yes no no x
))
1597 ;; Replace cookies to turn on or off the config/jax lines.
1598 (if (string-match ":MMLYES:" template
)
1599 (setq template
(replace-match yes t t template
)))
1600 (if (string-match ":MMLNO:" template
)
1601 (setq template
(replace-match no t t template
)))
1602 ;; Return the modified template.
1603 (org-element-normalize-string template
))))
1605 (defun org-html-format-spec (info)
1606 "Return format specification for elements that can be
1607 used in the preamble or postamble."
1608 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1609 (?d .
,(org-export-data (org-export-get-date info
) info
))
1610 (?T .
,(format-time-string org-html-metadata-timestamp-format
))
1611 (?a .
,(org-export-data (plist-get info
:author
) info
))
1614 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1615 (split-string (plist-get info
:email
) ",+ *")
1617 (?c .
,(plist-get info
:creator
))
1618 (?C .
,(let ((file (plist-get info
:input-file
)))
1619 (format-time-string org-html-metadata-timestamp-format
1620 (if file
(nth 5 (file-attributes file
))
1622 (?v .
,(or org-html-validation-link
""))))
1624 (defun org-html--build-pre/postamble
(type info
)
1625 "Return document preamble or postamble as a string, or nil.
1626 TYPE is either 'preamble or 'postamble, INFO is a plist used as a
1627 communication channel."
1628 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1629 (spec (org-html-format-spec info
)))
1631 (let ((section-contents
1632 (if (functionp section
) (funcall section info
)
1634 ((stringp section
) (format-spec section spec
))
1636 (let ((date (cdr (assq ?d spec
)))
1637 (author (cdr (assq ?a spec
)))
1638 (email (cdr (assq ?e spec
)))
1639 (creator (cdr (assq ?c spec
)))
1640 (timestamp (cdr (assq ?T spec
)))
1641 (validation-link (cdr (assq ?v spec
))))
1643 (when (and (plist-get info
:with-date
)
1644 (org-string-nw-p date
))
1645 (format "<p class=\"date\">%s: %s</p>\n"
1646 (org-html--translate "Date" info
)
1648 (when (and (plist-get info
:with-author
)
1649 (org-string-nw-p author
))
1650 (format "<p class=\"author\">%s: %s</p>\n"
1651 (org-html--translate "Author" info
)
1653 (when (and (plist-get info
:with-email
)
1654 (org-string-nw-p email
))
1655 (format "<p class=\"email\">%s: %s</p>\n"
1656 (org-html--translate "Email" info
)
1658 (when (plist-get info
:time-stamp-file
)
1660 "<p class=\"date\">%s: %s</p>\n"
1661 (org-html--translate "Created" info
)
1662 (format-time-string org-html-metadata-timestamp-format
)))
1663 (when (plist-get info
:with-creator
)
1664 (format "<p class=\"creator\">%s</p>\n" creator
))
1665 (format "<p class=\"validation\">%s</p>\n"
1669 (plist-get info
:language
)
1671 (format "org-html-%s-format" type
)))))
1676 (intern (format "org-html-%s-format" type
))))))
1678 (when (org-string-nw-p section-contents
)
1680 (format "<%s id=\"%s\" class=\"%s\">\n"
1681 (nth 1 (assq type org-html-divs
))
1682 (nth 2 (assq type org-html-divs
))
1683 org-html--pre
/postamble-class
)
1684 (org-element-normalize-string section-contents
)
1685 (format "</%s>\n" (nth 1 (assq type org-html-divs
)))))))))
1687 (defun org-html-inner-template (contents info
)
1688 "Return body of document string after HTML conversion.
1689 CONTENTS is the transcoded contents string. INFO is a plist
1690 holding export options."
1692 ;; Table of contents.
1693 (let ((depth (plist-get info
:with-toc
)))
1694 (when depth
(org-html-toc depth info
)))
1695 ;; Document contents.
1697 ;; Footnotes section.
1698 (org-html-footnote-section info
)))
1700 (defun org-html-template (contents info
)
1701 "Return complete document string after HTML conversion.
1702 CONTENTS is the transcoded contents string. INFO is a plist
1703 holding export options."
1705 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1706 (let ((decl (or (and (stringp org-html-xml-declaration
)
1707 org-html-xml-declaration
)
1708 (cdr (assoc (plist-get info
:html-extension
)
1709 org-html-xml-declaration
))
1710 (cdr (assoc "html" org-html-xml-declaration
))
1713 (when (not (or (eq nil decl
) (string= "" decl
)))
1716 (or (and org-html-coding-system
1717 (fboundp 'coding-system-get
)
1718 (coding-system-get org-html-coding-system
'mime-charset
))
1720 (org-html-doctype info
)
1723 (when (org-html-xhtml-p info
)
1725 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1726 (plist-get info
:language
) (plist-get info
:language
)))
1729 (org-html--build-meta-info info
)
1730 (org-html--build-head info
)
1731 (org-html--build-mathjax-config info
)
1734 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1735 (link-home (org-trim (plist-get info
:html-link-home
))))
1736 (unless (and (string= link-up
"") (string= link-home
""))
1737 (format org-html-home
/up-format
1738 (or link-up link-home
)
1739 (or link-home link-up
))))
1741 (org-html--build-pre/postamble
'preamble info
)
1742 ;; Document contents.
1743 (format "<%s id=\"%s\">\n"
1744 (nth 1 (assq 'content org-html-divs
))
1745 (nth 2 (assq 'content org-html-divs
)))
1747 (let ((title (plist-get info
:title
)))
1748 (format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title
"") info
)))
1751 (nth 1 (assq 'content org-html-divs
)))
1753 (org-html--build-pre/postamble
'postamble info
)
1754 ;; Closing document.
1755 "</body>\n</html>"))
1757 (defun org-html--translate (s info
)
1758 "Translate string S according to specified language.
1759 INFO is a plist used as a communication channel."
1760 (org-export-translate s
:html info
))
1764 (defun org-html--anchor (&optional id desc attributes
)
1765 "Format a HTML anchor."
1766 (let* ((name (and org-html-allow-name-attribute-in-anchors id
))
1767 (attributes (concat (and id
(format " id=\"%s\"" id
))
1768 (and name
(format " name=\"%s\"" name
))
1770 (format "<a%s>%s</a>" attributes
(or desc
""))))
1774 (defun org-html--todo (todo)
1775 "Format TODO keywords into HTML."
1777 (format "<span class=\"%s %s%s\">%s</span>"
1778 (if (member todo org-done-keywords
) "done" "todo")
1779 org-html-todo-kwd-class-prefix
(org-html-fix-class-name todo
)
1784 (defun org-html--tags (tags)
1785 "Format TAGS into HTML."
1787 (format "<span class=\"tag\">%s</span>"
1790 (format "<span class=\"%s\">%s</span>"
1791 (concat org-html-tag-class-prefix
1792 (org-html-fix-class-name tag
))
1798 (defun* org-html-format-headline
1799 (todo todo-type priority text tags
1800 &key level section-number headline-label
&allow-other-keys
)
1801 "Format a headline in HTML."
1802 (let ((section-number
1803 (when section-number
1804 (format "<span class=\"section-number-%d\">%s</span> "
1805 level section-number
)))
1806 (todo (org-html--todo todo
))
1807 (tags (org-html--tags tags
)))
1808 (concat section-number todo
(and todo
" ") text
1809 (and tags
"   ") tags
)))
1813 (defun org-html-fontify-code (code lang
)
1814 "Color CODE with htmlize library.
1815 CODE is a string representing the source code to colorize. LANG
1816 is the language used for CODE, as a string, or nil."
1819 ;; Case 1: No lang. Possibly an example block.
1821 ;; Simple transcoding.
1822 (org-html-encode-plain-text code
))
1823 ;; Case 2: No htmlize or an inferior version of htmlize
1824 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1826 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1827 ;; Simple transcoding.
1828 (org-html-encode-plain-text code
))
1831 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1832 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1834 ;; Case 1: Language is not associated with any Emacs mode
1835 ((not (functionp lang-mode
))
1836 ;; Simple transcoding.
1837 (org-html-encode-plain-text code
))
1838 ;; Case 2: Default. Fontify code.
1841 (setq code
(with-temp-buffer
1842 ;; Switch to language-specific mode.
1846 (font-lock-fontify-buffer)
1847 ;; Remove formatting on newline characters.
1849 (let ((beg (point-min))
1852 (while (progn (end-of-line) (< (point) end
))
1853 (put-text-property (point) (1+ (point)) 'face nil
)
1856 (set-buffer-modified-p nil
)
1858 (org-html-htmlize-region-for-paste
1859 (point-min) (point-max))))
1860 ;; Strip any enclosing <pre></pre> tags.
1861 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
1862 (end (and beg
(string-match "</pre>\\'" code
))))
1863 (if (and beg end
) (substring code beg end
) code
)))))))))
1865 (defun org-html-do-format-code
1866 (code &optional lang refs retain-labels num-start
)
1867 "Format CODE string as source code.
1868 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1869 respectively, the language of the source code, as a string, an
1870 alist between line numbers and references (as returned by
1871 `org-export-unravel-code'), a boolean specifying if labels should
1872 appear in the source code, and the number associated to the first
1874 (let* ((code-lines (org-split-string code
"\n"))
1875 (code-length (length code-lines
))
1879 (length (number-to-string (+ code-length num-start
))))))
1880 (code (org-html-fontify-code code lang
)))
1881 (org-export-format-code
1883 (lambda (loc line-num ref
)
1886 ;; Add line number, if needed.
1888 (format "<span class=\"linenr\">%s</span>"
1889 (format num-fmt line-num
)))
1890 ;; Transcoded src line.
1892 ;; Add label, if needed.
1893 (when (and ref retain-labels
) (format " (%s)" ref
))))
1894 ;; Mark transcoded line as an anchor, if needed.
1896 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1900 (defun org-html-format-code (element info
)
1901 "Format contents of ELEMENT as source code.
1902 ELEMENT is either an example block or a src block. INFO is
1903 a plist used as a communication channel."
1904 (let* ((lang (org-element-property :language element
))
1905 ;; Extract code and references.
1906 (code-info (org-export-unravel-code element
))
1907 (code (car code-info
))
1908 (refs (cdr code-info
))
1909 ;; Does the src block contain labels?
1910 (retain-labels (org-element-property :retain-labels element
))
1911 ;; Does it have line numbers?
1912 (num-start (case (org-element-property :number-lines element
)
1913 (continued (org-export-get-loc element info
))
1915 (org-html-do-format-code code lang refs retain-labels num-start
)))
1918 ;;; Tables of Contents
1920 (defun org-html-toc (depth info
)
1921 "Build a table of contents.
1922 DEPTH is an integer specifying the depth of the table. INFO is a
1923 plist used as a communication channel. Return the table of
1924 contents as a string, or nil if it is empty."
1926 (mapcar (lambda (headline)
1927 (cons (org-html--format-toc-headline headline info
)
1928 (org-export-get-relative-level headline info
)))
1929 (org-export-collect-headlines info depth
))))
1931 (concat "<div id=\"table-of-contents\">\n"
1932 (format "<h%d>%s</h%d>\n"
1933 org-html-toplevel-hlevel
1934 (org-html--translate "Table of Contents" info
)
1935 org-html-toplevel-hlevel
)
1936 "<div id=\"text-table-of-contents\">"
1937 (org-html--toc-text toc-entries
)
1941 (defun org-html--toc-text (toc-entries)
1942 "Return innards of a table of contents, as a string.
1943 TOC-ENTRIES is an alist where key is an entry title, as a string,
1944 and value is its relative level, as an integer."
1945 (let* ((prev-level (1- (cdar toc-entries
)))
1946 (start-level prev-level
))
1950 (let ((headline (car entry
))
1951 (level (cdr entry
)))
1953 (let* ((cnt (- level prev-level
))
1954 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1956 (setq prev-level level
)
1958 (org-html--make-string
1959 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1960 ((< cnt
0) "</li>\n</ul>\n")))
1961 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1964 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
1966 (defun org-html--format-toc-headline (headline info
)
1967 "Return an appropriate table of contents entry for HEADLINE.
1968 INFO is a plist used as a communication channel."
1969 (let* ((headline-number (org-export-get-headline-number headline info
))
1971 (and (not (org-export-low-level-p headline info
))
1972 (org-export-numbered-headline-p headline info
)
1973 (concat (mapconcat 'number-to-string headline-number
".") ". ")))
1974 (tags (and (eq (plist-get info
:with-tags
) t
)
1975 (org-export-get-tags headline info
))))
1976 (format "<a href=\"#%s\">%s</a>"
1978 (org-export-solidify-link-text
1979 (or (org-element-property :CUSTOM_ID headline
)
1980 (concat "sec-" (mapconcat 'number-to-string
1981 headline-number
"-"))))
1983 (concat section-number
1984 (org-export-data-with-translations
1985 (org-export-get-alt-title headline info
)
1986 ;; Ignore any footnote-reference, link,
1987 ;; radio-target and target in table of contents.
1989 '((footnote-reference . ignore
)
1990 (link .
(lambda (link desc i
) desc
))
1991 (radio-target .
(lambda (radio desc i
) desc
))
1993 (org-export-backend-translate-table 'html
))
1995 (and tags
"   ") (org-html--tags tags
)))))
1997 (defun org-html-list-of-listings (info)
1998 "Build a list of listings.
1999 INFO is a plist used as a communication channel. Return the list
2000 of listings as a string, or nil if it is empty."
2001 (let ((lol-entries (org-export-collect-listings info
)))
2003 (concat "<div id=\"list-of-listings\">\n"
2004 (format "<h%d>%s</h%d>\n"
2005 org-html-toplevel-hlevel
2006 (org-html--translate "List of Listings" info
)
2007 org-html-toplevel-hlevel
)
2008 "<div id=\"text-list-of-listings\">\n<ul>\n"
2010 (initial-fmt (org-html--translate "Listing %d:" info
)))
2013 (let ((label (org-element-property :name entry
))
2016 (or (org-export-get-caption entry t
)
2017 (org-export-get-caption entry
))
2022 (concat (format initial-fmt
(incf count
)) " " title
)
2023 (format "<a href=\"#%s\">%s %s</a>"
2024 (org-export-solidify-link-text label
)
2025 (format initial-fmt
(incf count
))
2029 "\n</ul>\n</div>\n</div>"))))
2031 (defun org-html-list-of-tables (info)
2032 "Build a list of tables.
2033 INFO is a plist used as a communication channel. Return the list
2034 of tables as a string, or nil if it is empty."
2035 (let ((lol-entries (org-export-collect-tables info
)))
2037 (concat "<div id=\"list-of-tables\">\n"
2038 (format "<h%d>%s</h%d>\n"
2039 org-html-toplevel-hlevel
2040 (org-html--translate "List of Tables" info
)
2041 org-html-toplevel-hlevel
)
2042 "<div id=\"text-list-of-tables\">\n<ul>\n"
2044 (initial-fmt (org-html--translate "Table %d:" info
)))
2047 (let ((label (org-element-property :name entry
))
2050 (or (org-export-get-caption entry t
)
2051 (org-export-get-caption entry
))
2056 (concat (format initial-fmt
(incf count
)) " " title
)
2057 (format "<a href=\"#%s\">%s %s</a>"
2058 (org-export-solidify-link-text label
)
2059 (format initial-fmt
(incf count
))
2063 "\n</ul>\n</div>\n</div>"))))
2066 ;;; Transcode Functions
2070 (defun org-html-bold (bold contents info
)
2071 "Transcode BOLD from Org to HTML.
2072 CONTENTS is the text with bold markup. INFO is a plist holding
2073 contextual information."
2074 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
2079 (defun org-html-center-block (center-block contents info
)
2080 "Transcode a CENTER-BLOCK element from Org to HTML.
2081 CONTENTS holds the contents of the block. INFO is a plist
2082 holding contextual information."
2083 (format "<div class=\"center\">\n%s</div>" contents
))
2087 (defun org-html-clock (clock contents info
)
2088 "Transcode a CLOCK element from Org to HTML.
2089 CONTENTS is nil. INFO is a plist used as a communication
2092 <span class=\"timestamp-wrapper\">
2093 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2098 (org-element-property :raw-value
2099 (org-element-property :value clock
)))
2100 (let ((time (org-element-property :duration clock
)))
2101 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2105 (defun org-html-code (code contents info
)
2106 "Transcode CODE from Org to HTML.
2107 CONTENTS is nil. INFO is a plist holding contextual
2109 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
2110 (org-html-encode-plain-text (org-element-property :value code
))))
2114 (defun org-html-drawer (drawer contents info
)
2115 "Transcode a DRAWER element from Org to HTML.
2116 CONTENTS holds the contents of the block. INFO is a plist
2117 holding contextual information."
2118 (if (functionp org-html-format-drawer-function
)
2119 (funcall org-html-format-drawer-function
2120 (org-element-property :drawer-name drawer
)
2122 ;; If there's no user defined function: simply
2123 ;; display contents of the drawer.
2128 (defun org-html-dynamic-block (dynamic-block contents info
)
2129 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2130 CONTENTS holds the contents of the block. INFO is a plist
2131 holding contextual information. See `org-export-data'."
2136 (defun org-html-entity (entity contents info
)
2137 "Transcode an ENTITY object from Org to HTML.
2138 CONTENTS are the definition itself. INFO is a plist holding
2139 contextual information."
2140 (org-element-property :html entity
))
2144 (defun org-html-example-block (example-block contents info
)
2145 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2146 CONTENTS is nil. INFO is a plist holding contextual
2148 (if (org-export-read-attribute :attr_html example-block
:textarea
)
2149 (org-html--textarea-block example-block
)
2150 (format "<pre class=\"example\">\n%s</pre>"
2151 (org-html-format-code example-block info
))))
2155 (defun org-html-export-snippet (export-snippet contents info
)
2156 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2157 CONTENTS is nil. INFO is a plist holding contextual
2159 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2160 (org-element-property :value export-snippet
)))
2164 (defun org-html-export-block (export-block contents info
)
2165 "Transcode a EXPORT-BLOCK element from Org to HTML.
2166 CONTENTS is nil. INFO is a plist holding contextual information."
2167 (when (string= (org-element-property :type export-block
) "HTML")
2168 (org-remove-indentation (org-element-property :value export-block
))))
2172 (defun org-html-fixed-width (fixed-width contents info
)
2173 "Transcode a FIXED-WIDTH element from Org to HTML.
2174 CONTENTS is nil. INFO is a plist holding contextual information."
2175 (format "<pre class=\"example\">\n%s</pre>"
2176 (org-html-do-format-code
2177 (org-remove-indentation
2178 (org-element-property :value fixed-width
)))))
2180 ;;;; Footnote Reference
2182 (defun org-html-footnote-reference (footnote-reference contents info
)
2183 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2184 CONTENTS is nil. INFO is a plist holding contextual information."
2186 ;; Insert separator between two footnotes in a row.
2187 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2188 (when (eq (org-element-type prev
) 'footnote-reference
)
2189 org-html-footnote-separator
))
2191 ((not (org-export-footnote-first-reference-p footnote-reference info
))
2192 (org-html-format-footnote-reference
2193 (org-export-get-footnote-number footnote-reference info
)
2195 ;; Inline definitions are secondary strings.
2196 ((eq (org-element-property :type footnote-reference
) 'inline
)
2197 (org-html-format-footnote-reference
2198 (org-export-get-footnote-number footnote-reference info
)
2200 ;; Non-inline footnotes definitions are full Org data.
2201 (t (org-html-format-footnote-reference
2202 (org-export-get-footnote-number footnote-reference info
)
2207 (defun org-html-format-headline--wrap
2208 (headline info
&optional format-function
&rest extra-keys
)
2209 "Transcode a HEADLINE element from Org to HTML.
2210 CONTENTS holds the contents of the headline. INFO is a plist
2211 holding contextual information."
2212 (let* ((level (+ (org-export-get-relative-level headline info
)
2213 (1- org-html-toplevel-hlevel
)))
2214 (headline-number (org-export-get-headline-number headline info
))
2215 (section-number (and (not (org-export-low-level-p headline info
))
2216 (org-export-numbered-headline-p headline info
)
2217 (mapconcat 'number-to-string
2218 headline-number
".")))
2219 (todo (and (plist-get info
:with-todo-keywords
)
2220 (let ((todo (org-element-property :todo-keyword headline
)))
2221 (and todo
(org-export-data todo info
)))))
2222 (todo-type (and todo
(org-element-property :todo-type headline
)))
2223 (priority (and (plist-get info
:with-priority
)
2224 (org-element-property :priority headline
)))
2225 (text (org-export-data (org-element-property :title headline
) info
))
2226 (tags (and (plist-get info
:with-tags
)
2227 (org-export-get-tags headline info
)))
2228 (headline-label (or (org-element-property :CUSTOM_ID headline
)
2229 (concat "sec-" (mapconcat 'number-to-string
2230 headline-number
"-"))))
2231 (format-function (cond
2232 ((functionp format-function
) format-function
)
2233 ((functionp org-html-format-headline-function
)
2235 (lambda (todo todo-type priority text tags
2237 (funcall org-html-format-headline-function
2238 todo todo-type priority text tags
))))
2239 (t 'org-html-format-headline
))))
2240 (apply format-function
2241 todo todo-type priority text tags
2242 :headline-label headline-label
:level level
2243 :section-number section-number extra-keys
)))
2245 (defun org-html-headline (headline contents info
)
2246 "Transcode a HEADLINE element from Org to HTML.
2247 CONTENTS holds the contents of the headline. INFO is a plist
2248 holding contextual information."
2250 (setq contents
(or contents
""))
2251 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2252 (level (org-export-get-relative-level headline info
))
2253 (text (org-export-data (org-element-property :title headline
) info
))
2254 (todo (and (plist-get info
:with-todo-keywords
)
2255 (let ((todo (org-element-property :todo-keyword headline
)))
2256 (and todo
(org-export-data todo info
)))))
2257 (todo-type (and todo
(org-element-property :todo-type headline
)))
2258 (tags (and (plist-get info
:with-tags
)
2259 (org-export-get-tags headline info
)))
2260 (priority (and (plist-get info
:with-priority
)
2261 (org-element-property :priority headline
)))
2262 (section-number (and (org-export-numbered-headline-p headline info
)
2263 (mapconcat 'number-to-string
2264 (org-export-get-headline-number
2265 headline info
) ".")))
2266 ;; Create the headline text.
2267 (full-text (org-html-format-headline--wrap headline info
)))
2269 ;; Case 1: This is a footnote section: ignore it.
2270 ((org-element-property :footnote-section-p headline
) nil
)
2271 ;; Case 2. This is a deep sub-tree: export it as a list item.
2272 ;; Also export as items headlines for which no section
2273 ;; format has been found.
2274 ((org-export-low-level-p headline info
)
2275 ;; Build the real contents of the sub-tree.
2276 (let* ((type (if numberedp
'ordered
'unordered
))
2277 (itemized-body (org-html-format-list-item
2278 contents type nil info nil full-text
)))
2280 (and (org-export-first-sibling-p headline info
)
2281 (org-html-begin-plain-list type
))
2283 (and (org-export-last-sibling-p headline info
)
2284 (org-html-end-plain-list type
)))))
2285 ;; Case 3. Standard headline. Export it as a section.
2287 (let* ((section-number (mapconcat 'number-to-string
2288 (org-export-get-headline-number
2289 headline info
) "-"))
2291 (list (org-element-property :CUSTOM_ID headline
)
2292 (concat "sec-" section-number
)
2293 (org-element-property :ID headline
))))
2294 (preferred-id (car ids
))
2295 (extra-ids (cdr ids
))
2296 (extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2297 (level1 (+ level
(1- org-html-toplevel-hlevel
)))
2298 (first-content (car (org-element-contents headline
))))
2299 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2300 (org-html--container headline info
)
2301 (format "outline-container-%s"
2302 (or (org-element-property :CUSTOM_ID headline
)
2303 (concat "sec-" section-number
)))
2304 (concat (format "outline-%d" level1
) (and extra-class
" ")
2306 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2311 (let ((id (org-export-solidify-link-text
2312 (if (org-uuidgen-p x
) (concat "ID-" x
)
2314 (org-html--anchor id
)))
2318 ;; When there is no section, pretend there is an empty
2319 ;; one to get the correct <div class="outline- ...>
2320 ;; which is needed by `org-info.js'.
2321 (if (not (eq (org-element-type first-content
) 'section
))
2322 (concat (org-html-section first-content
"" info
)
2325 (org-html--container headline info
)))))))
2327 (defun org-html--container (headline info
)
2328 (or (org-element-property :HTML_CONTAINER headline
)
2329 (if (= 1 (org-export-get-relative-level headline info
))
2330 (plist-get info
:html-container
)
2333 ;;;; Horizontal Rule
2335 (defun org-html-horizontal-rule (horizontal-rule contents info
)
2336 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2337 CONTENTS is nil. INFO is a plist holding contextual information."
2338 (org-html-close-tag "hr" nil info
))
2340 ;;;; Inline Src Block
2342 (defun org-html-inline-src-block (inline-src-block contents info
)
2343 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2344 CONTENTS holds the contents of the item. INFO is a plist holding
2345 contextual information."
2346 (let* ((org-lang (org-element-property :language inline-src-block
))
2347 (code (org-element-property :value inline-src-block
)))
2348 (error "Cannot export inline src block")))
2352 (defun org-html-format-section (text class
&optional id
)
2353 "Format a section with TEXT into a HTML div with CLASS and ID."
2354 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
2355 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
2357 (defun org-html-inlinetask (inlinetask contents info
)
2358 "Transcode an INLINETASK element from Org to HTML.
2359 CONTENTS holds the contents of the block. INFO is a plist
2360 holding contextual information."
2362 ;; If `org-html-format-inlinetask-function' is provided, call it
2363 ;; with appropriate arguments.
2364 ((functionp org-html-format-inlinetask-function
)
2365 (let ((format-function
2367 (lambda (todo todo-type priority text tags
2368 &key contents
&allow-other-keys
)
2369 (funcall org-html-format-inlinetask-function
2370 todo todo-type priority text tags contents
)))))
2371 (org-html-format-headline--wrap
2372 inlinetask info format-function
:contents contents
)))
2373 ;; Otherwise, use a default template.
2374 (t (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2375 (org-html-format-headline--wrap inlinetask info
)
2376 (org-html-close-tag "br" nil info
)
2381 (defun org-html-italic (italic contents info
)
2382 "Transcode ITALIC from Org to HTML.
2383 CONTENTS is the text with italic markup. INFO is a plist holding
2384 contextual information."
2385 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
2389 (defun org-html-checkbox (checkbox)
2390 "Format CHECKBOX into HTML."
2391 (case checkbox
(on "<code>[X]</code>")
2392 (off "<code>[ ]</code>")
2393 (trans "<code>[-]</code>")
2396 (defun org-html-format-list-item (contents type checkbox info
2397 &optional term-counter-id
2399 "Format a list item into HTML."
2400 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" ")))
2401 (br (org-html-close-tag "br" nil info
)))
2405 (let* ((counter term-counter-id
)
2406 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2408 (format "<li%s>" extra
)
2409 (when headline
(concat headline br
)))))
2411 (let* ((id term-counter-id
)
2412 (extra (if id
(format " id=\"%s\"" id
) "")))
2414 (format "<li%s>" extra
)
2415 (when headline
(concat headline br
)))))
2417 (let* ((term term-counter-id
))
2418 (setq term
(or term
"(no term)"))
2419 ;; Check-boxes in descriptive lists are associated to tag.
2420 (concat (format "<dt> %s </dt>"
2421 (concat checkbox term
))
2423 (unless (eq type
'descriptive
) checkbox
)
2428 (descriptive "</dd>")))))
2430 (defun org-html-item (item contents info
)
2431 "Transcode an ITEM element from Org to HTML.
2432 CONTENTS holds the contents of the item. INFO is a plist holding
2433 contextual information."
2434 (let* ((plain-list (org-export-get-parent item
))
2435 (type (org-element-property :type plain-list
))
2436 (counter (org-element-property :counter item
))
2437 (checkbox (org-element-property :checkbox item
))
2438 (tag (let ((tag (org-element-property :tag item
)))
2439 (and tag
(org-export-data tag info
)))))
2440 (org-html-format-list-item
2441 contents type checkbox info
(or tag counter
))))
2445 (defun org-html-keyword (keyword contents info
)
2446 "Transcode a KEYWORD element from Org to HTML.
2447 CONTENTS is nil. INFO is a plist holding contextual information."
2448 (let ((key (org-element-property :key keyword
))
2449 (value (org-element-property :value keyword
)))
2451 ((string= key
"HTML") value
)
2452 ((string= key
"TOC")
2453 (let ((value (downcase value
)))
2455 ((string-match "\\<headlines\\>" value
)
2456 (let ((depth (or (and (string-match "[0-9]+" value
)
2457 (string-to-number (match-string 0 value
)))
2458 (plist-get info
:with-toc
))))
2459 (org-html-toc depth info
)))
2460 ((string= "listings" value
) (org-html-list-of-listings info
))
2461 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2463 ;;;; Latex Environment
2465 (defun org-html-format-latex (latex-frag processing-type
)
2466 "Format a LaTeX fragment LATEX-FRAG into HTML."
2467 (let ((cache-relpath "") (cache-dir ""))
2468 (unless (eq processing-type
'mathjax
)
2469 (let ((bfn (or (buffer-file-name)
2471 (expand-file-name "latex" temporary-file-directory
)))))
2474 (file-name-sans-extension
2475 (file-name-nondirectory bfn
)))
2476 cache-dir
(file-name-directory bfn
))))
2479 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2480 nil nil processing-type
)
2483 (defun org-html-latex-environment (latex-environment contents info
)
2484 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2485 CONTENTS is nil. INFO is a plist holding contextual information."
2486 (let ((processing-type (plist-get info
:with-latex
))
2487 (latex-frag (org-remove-indentation
2488 (org-element-property :value latex-environment
)))
2489 (caption (org-export-data
2490 (org-export-get-caption latex-environment
) info
))
2492 (label (org-element-property :name latex-environment
)))
2494 ((memq processing-type
'(t mathjax
))
2495 (org-html-format-latex latex-frag
'mathjax
))
2496 ((eq processing-type
'dvipng
)
2497 (let* ((formula-link (org-html-format-latex
2498 latex-frag processing-type
)))
2499 (when (and formula-link
2500 (string-match "file:\\([^]]*\\)" formula-link
))
2501 (org-html-format-inline-image
2502 (match-string 1 formula-link
) info caption label attr t
))))
2507 (defun org-html-latex-fragment (latex-fragment contents info
)
2508 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2509 CONTENTS is nil. INFO is a plist holding contextual information."
2510 (let ((latex-frag (org-element-property :value latex-fragment
))
2511 (processing-type (plist-get info
:with-latex
)))
2512 (case processing-type
2514 (org-html-format-latex latex-frag
'mathjax
))
2516 (let* ((formula-link (org-html-format-latex
2517 latex-frag processing-type
)))
2518 (when (and formula-link
2519 (string-match "file:\\([^]]*\\)" formula-link
))
2520 (org-html-format-inline-image
2521 (match-string 1 formula-link
) info
))))
2526 (defun org-html-line-break (line-break contents info
)
2527 "Transcode a LINE-BREAK object from Org to HTML.
2528 CONTENTS is nil. INFO is a plist holding contextual information."
2529 (concat (org-html-close-tag "br" nil info
) "\n"))
2533 (defun org-html-link--inline-image (link desc info
)
2534 "Return HTML code for an inline image.
2536 LINK is the link pointing to the inline image. INFO is a plist
2537 used as a communication channel.
2539 Inline images can have these attributes:
2541 #+ATTR_HTML: :width 100px :height 100px :alt \"Alt description\"."
2542 (let* ((type (org-element-property :type link
))
2543 (raw-path (org-element-property :path link
))
2544 (path (cond ((member type
'("http" "https"))
2545 (concat type
":" raw-path
))
2546 ((file-name-absolute-p raw-path
)
2547 (expand-file-name raw-path
))
2549 (parent (org-export-get-parent-element link
))
2551 (let ((raw (org-export-data (org-export-get-caption parent
) info
))
2552 (org-html-standalone-image-predicate 'org-html--has-caption-p
))
2553 (if (not (org-string-nw-p raw
)) raw
2554 (concat (format (org-html--translate "Figure %d:" info
)
2555 (org-export-get-ordinal
2556 link info nil
'org-html-standalone-image-p
))
2558 (label (org-element-property :name parent
)))
2559 ;; Return proper string, depending on DISPOSITION.
2560 (org-html-format-inline-image
2561 path info caption label
2562 (org-html--make-attribute-string
2563 (org-export-read-attribute :attr_html parent
))
2564 (org-html-standalone-image-p link info
))))
2566 (defvar org-html-standalone-image-predicate
)
2567 (defun org-html-standalone-image-p (element info
&optional predicate
)
2568 "Test if ELEMENT is a standalone image for the purpose HTML export.
2569 INFO is a plist holding contextual information.
2571 Return non-nil, if ELEMENT is of type paragraph and it's sole
2572 content, save for whitespaces, is a link that qualifies as an
2575 Return non-nil, if ELEMENT is of type link and it's containing
2576 paragraph has no other content save for leading and trailing
2579 Return nil, otherwise.
2581 Bind `org-html-standalone-image-predicate' to constrain
2582 paragraph further. For example, to check for only captioned
2583 standalone images, do the following.
2585 \(setq org-html-standalone-image-predicate
2586 \(lambda \(paragraph\)
2587 \(org-element-property :caption paragraph\)\)\)"
2588 (let ((paragraph (case (org-element-type element
)
2590 (link (and (org-export-inline-image-p
2591 element org-html-inline-image-rules
)
2592 (org-export-get-parent element
)))
2594 (when (eq (org-element-type paragraph
) 'paragraph
)
2595 (when (or (not (and (boundp 'org-html-standalone-image-predicate
)
2596 (functionp org-html-standalone-image-predicate
)))
2597 (funcall org-html-standalone-image-predicate paragraph
))
2598 (let ((contents (org-element-contents paragraph
)))
2599 (loop for x in contents
2600 with inline-image-count
= 0
2602 ((eq (org-element-type x
) 'plain-text
)
2603 (not (org-string-nw-p x
)))
2604 ((eq (org-element-type x
) 'link
)
2605 (when (org-export-inline-image-p
2606 x org-html-inline-image-rules
)
2607 (= (incf inline-image-count
) 1)))
2610 (defun org-html-link (link desc info
)
2611 "Transcode a LINK object from Org to HTML.
2613 DESC is the description part of the link, or the empty string.
2614 INFO is a plist holding contextual information. See
2616 (let* ((home (org-trim (plist-get info
:html-link-home
)))
2617 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2618 (link-org-files-as-html-maybe
2620 (lambda (raw-path info
)
2621 "Treat links to `file.org' as links to `file.html', if needed.
2622 See `org-html-link-org-files-as-html'."
2624 ((and org-html-link-org-files-as-html
2626 (downcase (file-name-extension raw-path
"."))))
2627 (concat (file-name-sans-extension raw-path
) "."
2628 (plist-get info
:html-extension
)))
2630 (type (org-element-property :type link
))
2631 (raw-path (org-element-property :path link
))
2632 ;; Ensure DESC really exists, or set it to nil.
2633 (desc (org-string-nw-p desc
))
2636 ((member type
'("http" "https" "ftp" "mailto"))
2637 (concat type
":" raw-path
))
2638 ((string= type
"file")
2639 ;; Treat links to ".org" files as ".html", if needed.
2641 (funcall link-org-files-as-html-maybe raw-path info
))
2642 ;; If file path is absolute, prepend it with protocol
2643 ;; component - "file://".
2644 (cond ((file-name-absolute-p raw-path
)
2646 (concat "file://" (expand-file-name
2648 ((and home use-abs-url
)
2649 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2650 ;; Add search option, if any. A search option can be
2651 ;; relative to a custom-id or a headline title. Any other
2652 ;; option is ignored.
2653 (let ((option (org-element-property :search-option link
)))
2654 (cond ((not option
) raw-path
)
2655 ((eq (aref option
0) ?
#) (concat raw-path option
))
2656 ;; External fuzzy link: try to resolve it if path
2657 ;; belongs to current project, if any.
2658 ((eq (aref option
0) ?
*)
2662 (org-publish-resolve-external-fuzzy-link
2663 (org-element-property :path link
) option
)))
2664 (and numbers
(concat "#sec-"
2665 (mapconcat 'number-to-string
2669 ;; Extract attributes from parent's paragraph. HACK: Only do
2670 ;; this for the first link in parent. This is needed as long
2671 ;; as attributes cannot be set on a per link basis.
2673 (let ((parent (org-export-get-parent-element link
)))
2674 (if (not (eq (org-element-map parent
'link
'identity info t
) link
))
2676 (let ((att (org-html--make-attribute-string
2677 (org-export-read-attribute :attr_html parent
))))
2678 (cond ((not (org-string-nw-p att
)) "")
2679 ((and desc
(string-match (regexp-quote att
) desc
)) "")
2680 (t (concat " " att
)))))))
2684 ((and (or (eq t org-html-inline-images
)
2685 (and org-html-inline-images
(not desc
)))
2686 (org-export-inline-image-p link org-html-inline-image-rules
))
2687 (org-html-link--inline-image link desc info
))
2688 ;; Radio target: Transcode target's contents and use them as
2689 ;; link's description.
2690 ((string= type
"radio")
2691 (let ((destination (org-export-resolve-radio-link link info
)))
2693 (format "<a href=\"#%s\"%s>%s</a>"
2694 (org-export-solidify-link-text path
)
2696 (org-export-data (org-element-contents destination
) info
)))))
2697 ;; Links pointing to a headline: Find destination and build
2698 ;; appropriate referencing command.
2699 ((member type
'("custom-id" "fuzzy" "id"))
2700 (let ((destination (if (string= type
"fuzzy")
2701 (org-export-resolve-fuzzy-link link info
)
2702 (org-export-resolve-id-link link info
))))
2703 (case (org-element-type destination
)
2704 ;; ID link points to an external file.
2706 (let ((fragment (concat "ID-" path
))
2707 ;; Treat links to ".org" files as ".html", if needed.
2708 (path (funcall link-org-files-as-html-maybe
2710 (format "<a href=\"%s#%s\"%s>%s</a>"
2711 path fragment attributes
(or desc destination
))))
2712 ;; Fuzzy link points nowhere.
2717 (org-element-property :raw-link link
) info
))))
2718 ;; Link points to a headline.
2721 ;; What href to use?
2723 ;; Case 1: Headline is linked via it's CUSTOM_ID
2724 ;; property. Use CUSTOM_ID.
2725 ((string= type
"custom-id")
2726 (org-element-property :CUSTOM_ID destination
))
2727 ;; Case 2: Headline is linked via it's ID property
2728 ;; or through other means. Use the default href.
2729 ((member type
'("id" "fuzzy"))
2731 (mapconcat 'number-to-string
2732 (org-export-get-headline-number
2733 destination info
) "-")))
2734 (t (error "Shouldn't reach here"))))
2735 ;; What description to use?
2737 ;; Case 1: Headline is numbered and LINK has no
2738 ;; description. Display section number.
2739 (if (and (org-export-numbered-headline-p destination info
)
2741 (mapconcat 'number-to-string
2742 (org-export-get-headline-number
2743 destination info
) ".")
2744 ;; Case 2: Either the headline is un-numbered or
2745 ;; LINK has a custom description. Display LINK's
2746 ;; description or headline's title.
2747 (or desc
(org-export-data (org-element-property
2748 :title destination
) info
)))))
2749 (format "<a href=\"#%s\"%s>%s</a>"
2750 (org-export-solidify-link-text href
) attributes desc
)))
2751 ;; Fuzzy link points to a target or an element.
2753 (let* ((path (org-export-solidify-link-text path
))
2754 (org-html-standalone-image-predicate 'org-html--has-caption-p
)
2757 ((org-html-standalone-image-p destination info
)
2758 (org-export-get-ordinal
2759 (org-element-map destination
'link
2761 info
'link
'org-html-standalone-image-p
))
2762 (t (org-export-get-ordinal
2763 destination info nil
'org-html--has-caption-p
))))
2765 ((not number
) "No description for this link")
2766 ((numberp number
) (number-to-string number
))
2767 (t (mapconcat 'number-to-string number
".")))))
2768 (format "<a href=\"#%s\"%s>%s</a>" path attributes desc
))))))
2769 ;; Coderef: replace link with the reference name or the
2770 ;; equivalent line number.
2771 ((string= type
"coderef")
2772 (let ((fragment (concat "coderef-" path
)))
2773 (format "<a href=\"#%s\"%s%s>%s</a>"
2776 (format (concat "class=\"coderef\""
2777 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2778 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2781 (format (org-export-get-coderef-format path desc
)
2782 (org-export-resolve-coderef path info
)))))
2783 ;; Link type is handled by a special function.
2784 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2785 (funcall protocol
(org-link-unescape path
) desc
'html
))
2786 ;; External link with a description part.
2787 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2788 ;; External link without a description part.
2789 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2790 ;; No path, only description. Try to do something useful.
2791 (t (format "<i>%s</i>" desc
)))))
2795 (defun org-html-paragraph (paragraph contents info
)
2796 "Transcode a PARAGRAPH element from Org to HTML.
2797 CONTENTS is the contents of the paragraph, as a string. INFO is
2798 the plist used as a communication channel."
2799 (let* ((parent (org-export-get-parent paragraph
))
2800 (parent-type (org-element-type parent
))
2801 (style '((footnote-definition " class=\"footpara\"")))
2802 (extra (or (cadr (assoc parent-type style
)) "")))
2804 ((and (eq (org-element-type parent
) 'item
)
2805 (= (org-element-property :begin paragraph
)
2806 (org-element-property :contents-begin parent
)))
2807 ;; leading paragraph in a list item have no tags
2809 ((org-html-standalone-image-p paragraph info
)
2812 (t (format "<p%s>\n%s</p>" extra contents
)))))
2816 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2817 ;; the correct value for the item counter
2818 (defun org-html-begin-plain-list (type &optional arg1
)
2819 "Insert the beginning of the HTML list depending on TYPE.
2820 When ARG1 is a string, use it as the start parameter for ordered
2824 (format "<ol class=\"org-ol\"%s>"
2825 (if arg1
(format " start=\"%d\"" arg1
) "")))
2826 (unordered "<ul class=\"org-ul\">")
2827 (descriptive "<dl class=\"org-dl\">")))
2829 (defun org-html-end-plain-list (type)
2830 "Insert the end of the HTML list depending on TYPE."
2834 (descriptive "</dl>")))
2836 (defun org-html-plain-list (plain-list contents info
)
2837 "Transcode a PLAIN-LIST element from Org to HTML.
2838 CONTENTS is the contents of the list. INFO is a plist holding
2839 contextual information."
2840 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2841 (type (org-element-property :type plain-list
)))
2843 (org-html-begin-plain-list type
)
2844 contents
(org-html-end-plain-list type
))))
2848 (defun org-html-convert-special-strings (string)
2849 "Convert special characters in STRING to HTML."
2850 (let ((all org-html-special-string-regexps
)
2852 (while (setq a
(pop all
))
2853 (setq re
(car a
) rpl
(cdr a
) start
0)
2854 (while (string-match re string start
)
2855 (setq string
(replace-match rpl t nil string
))))
2858 (defun org-html-encode-plain-text (text)
2859 "Convert plain text characters from TEXT to HTML equivalent.
2860 Possible conversions are set in `org-html-protect-char-alist'."
2863 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2864 org-html-protect-char-alist
)
2867 (defun org-html-plain-text (text info
)
2868 "Transcode a TEXT string from Org to HTML.
2869 TEXT is the string to transcode. INFO is a plist holding
2870 contextual information."
2871 (let ((output text
))
2872 ;; Protect following characters: <, >, &.
2873 (setq output
(org-html-encode-plain-text output
))
2874 ;; Handle smart quotes. Be sure to provide original string since
2875 ;; OUTPUT may have been modified.
2876 (when (plist-get info
:with-smart-quotes
)
2877 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2878 ;; Handle special strings.
2879 (when (plist-get info
:with-special-strings
)
2880 (setq output
(org-html-convert-special-strings output
)))
2881 ;; Handle break preservation if required.
2882 (when (plist-get info
:preserve-breaks
)
2884 (replace-regexp-in-string
2885 "\\(\\\\\\\\\\)?[ \t]*\n"
2886 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
2893 (defun org-html-planning (planning contents info
)
2894 "Transcode a PLANNING element from Org to HTML.
2895 CONTENTS is nil. INFO is a plist used as a communication
2897 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2899 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2904 (let ((closed (org-element-property :closed planning
)))
2906 (format span-fmt org-closed-string
2908 (org-element-property :raw-value closed
)))))
2909 (let ((deadline (org-element-property :deadline planning
)))
2911 (format span-fmt org-deadline-string
2913 (org-element-property :raw-value deadline
)))))
2914 (let ((scheduled (org-element-property :scheduled planning
)))
2916 (format span-fmt org-scheduled-string
2918 (org-element-property :raw-value scheduled
)))))))
2921 ;;;; Property Drawer
2923 (defun org-html-property-drawer (property-drawer contents info
)
2924 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2925 CONTENTS is nil. INFO is a plist holding contextual
2927 ;; The property drawer isn't exported but we want separating blank
2928 ;; lines nonetheless.
2933 (defun org-html-quote-block (quote-block contents info
)
2934 "Transcode a QUOTE-BLOCK element from Org to HTML.
2935 CONTENTS holds the contents of the block. INFO is a plist
2936 holding contextual information."
2937 (format "<blockquote>\n%s</blockquote>" contents
))
2941 (defun org-html-quote-section (quote-section contents info
)
2942 "Transcode a QUOTE-SECTION element from Org to HTML.
2943 CONTENTS is nil. INFO is a plist holding contextual information."
2944 (let ((value (org-remove-indentation
2945 (org-element-property :value quote-section
))))
2946 (when value
(format "<pre>\n%s</pre>" value
))))
2950 (defun org-html-section (section contents info
)
2951 "Transcode a SECTION element from Org to HTML.
2952 CONTENTS holds the contents of the section. INFO is a plist
2953 holding contextual information."
2954 (let ((parent (org-export-get-parent-headline section
)))
2955 ;; Before first headline: no container, just return CONTENTS.
2956 (if (not parent
) contents
2957 ;; Get div's class and id references.
2958 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2959 (1- org-html-toplevel-hlevel
)))
2963 (org-export-get-headline-number parent info
) "-")))
2964 ;; Build return value.
2965 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2967 (or (org-element-property :CUSTOM_ID parent
) section-number
)
2972 (defun org-html-radio-target (radio-target text info
)
2973 "Transcode a RADIO-TARGET object from Org to HTML.
2974 TEXT is the text of the target. INFO is a plist holding
2975 contextual information."
2976 (let ((id (org-export-solidify-link-text
2977 (org-element-property :value radio-target
))))
2978 (org-html--anchor id text
)))
2982 (defun org-html-special-block (special-block contents info
)
2983 "Transcode a SPECIAL-BLOCK element from Org to HTML.
2984 CONTENTS holds the contents of the block. INFO is a plist
2985 holding contextual information."
2986 (let* ((block-type (downcase
2987 (org-element-property :type special-block
)))
2988 (contents (or contents
""))
2989 (html5-fancy (and (org-html-html5-p info
)
2990 (plist-get info
:html-html5-fancy
)
2991 (member block-type org-html-html5-elements
)))
2992 (attributes (org-export-read-attribute :attr_html special-block
)))
2994 (let ((class (plist-get attributes
:class
)))
2995 (setq attributes
(plist-put attributes
:class
2996 (if class
(concat class
" " block-type
)
2998 (setq attributes
(org-html--make-attribute-string attributes
))
2999 (when (not (equal attributes
""))
3000 (setq attributes
(concat " " attributes
)))
3002 (format "<%s%s>\n%s</%s>" block-type attributes
3003 contents block-type
)
3004 (format "<div%s>\n%s\n</div>" attributes contents
))))
3008 (defun org-html-src-block (src-block contents info
)
3009 "Transcode a SRC-BLOCK element from Org to HTML.
3010 CONTENTS holds the contents of the item. INFO is a plist holding
3011 contextual information."
3012 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3013 (org-html--textarea-block src-block
)
3014 (let ((lang (org-element-property :language src-block
))
3015 (caption (org-export-get-caption src-block
))
3016 (code (org-html-format-code src-block info
))
3017 (label (let ((lbl (org-element-property :name src-block
)))
3019 (format " id=\"%s\""
3020 (org-export-solidify-link-text lbl
))))))
3021 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3023 "<div class=\"org-src-container\">\n%s%s\n</div>"
3024 (if (not caption
) ""
3025 (format "<label class=\"org-src-name\">%s</label>"
3026 (org-export-data caption info
)))
3027 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3029 ;;;; Statistics Cookie
3031 (defun org-html-statistics-cookie (statistics-cookie contents info
)
3032 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3033 CONTENTS is nil. INFO is a plist holding contextual information."
3034 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3035 (format "<code>%s</code>" cookie-value
)))
3039 (defun org-html-strike-through (strike-through contents info
)
3040 "Transcode STRIKE-THROUGH from Org to HTML.
3041 CONTENTS is the text with strike-through markup. INFO is a plist
3042 holding contextual information."
3043 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
3048 (defun org-html-subscript (subscript contents info
)
3049 "Transcode a SUBSCRIPT object from Org to HTML.
3050 CONTENTS is the contents of the object. INFO is a plist holding
3051 contextual information."
3052 (format "<sub>%s</sub>" contents
))
3056 (defun org-html-superscript (superscript contents info
)
3057 "Transcode a SUPERSCRIPT object from Org to HTML.
3058 CONTENTS is the contents of the object. INFO is a plist holding
3059 contextual information."
3060 (format "<sup>%s</sup>" contents
))
3064 (defun org-html-table-cell (table-cell contents info
)
3065 "Transcode a TABLE-CELL element from Org to HTML.
3066 CONTENTS is nil. INFO is a plist used as a communication
3068 (let* ((table-row (org-export-get-parent table-cell
))
3069 (table (org-export-get-parent-table table-cell
))
3071 (if (not org-html-table-align-individual-fields
) ""
3072 (format (if (and (boundp 'org-html-format-table-no-css
)
3073 org-html-format-table-no-css
)
3074 " align=\"%s\"" " class=\"%s\"")
3075 (org-export-table-cell-alignment table-cell info
)))))
3076 (when (or (not contents
) (string= "" (org-trim contents
)))
3077 (setq contents
" "))
3079 ((and (org-export-table-has-header-p table info
)
3080 (= 1 (org-export-table-row-group table-row info
)))
3081 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
3082 contents
(cdr org-html-table-header-tags
)))
3083 ((and org-html-table-use-header-tags-for-first-column
3084 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3085 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
3086 contents
(cdr org-html-table-header-tags
)))
3087 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
3088 contents
(cdr org-html-table-data-tags
))))))
3092 (defun org-html-table-row (table-row contents info
)
3093 "Transcode a TABLE-ROW element from Org to HTML.
3094 CONTENTS is the contents of the row. INFO is a plist used as a
3095 communication channel."
3096 ;; Rules are ignored since table separators are deduced from
3097 ;; borders of the current row.
3098 (when (eq (org-element-property :type table-row
) 'standard
)
3099 (let* ((rowgroup-number (org-export-table-row-group table-row info
))
3100 (row-number (org-export-table-row-number table-row info
))
3102 (org-export-table-row-starts-rowgroup-p table-row info
))
3104 (org-export-table-row-ends-rowgroup-p table-row info
))
3105 ;; `top-row-p' and `end-rowgroup-p' are not used directly
3106 ;; but should be set so that `org-html-table-row-tags' can
3107 ;; use them (see the docstring of this variable.)
3108 (top-row-p (and (equal start-rowgroup-p
'(top))
3109 (equal end-rowgroup-p
'(below top
))))
3110 (bottom-row-p (and (equal start-rowgroup-p
'(above))
3111 (equal end-rowgroup-p
'(bottom above
))))
3114 ;; Case 1: Row belongs to second or subsequent rowgroups.
3115 ((not (= 1 rowgroup-number
))
3116 '("<tbody>" .
"\n</tbody>"))
3117 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
3118 ((org-export-table-has-header-p
3119 (org-export-get-parent-table table-row
) info
)
3120 '("<thead>" .
"\n</thead>"))
3121 ;; Case 2: Row is from first and only row group.
3122 (t '("<tbody>" .
"\n</tbody>")))))
3124 ;; Begin a rowgroup?
3125 (when start-rowgroup-p
(car rowgroup-tags
))
3127 (concat "\n" (eval (car org-html-table-row-tags
))
3130 (eval (cdr org-html-table-row-tags
)))
3132 (when end-rowgroup-p
(cdr rowgroup-tags
))))))
3136 (defun org-html-table-first-row-data-cells (table info
)
3137 "Transcode the first row of TABLE.
3138 INFO is a plist used as a communication channel."
3140 (org-element-map table
'table-row
3142 (unless (eq (org-element-property :type row
) 'rule
) row
))
3144 (special-column-p (org-export-table-has-special-column-p table
)))
3145 (if (not special-column-p
) (org-element-contents table-row
)
3146 (cdr (org-element-contents table-row
)))))
3148 (defun org-html-table--table.el-table
(table info
)
3149 "Format table.el tables into HTML.
3150 INFO is a plist used as a communication channel."
3151 (when (eq (org-element-property :type table
) 'table.el
)
3153 (let ((outbuf (with-current-buffer
3154 (get-buffer-create "*org-export-table*")
3155 (erase-buffer) (current-buffer))))
3157 (insert (org-element-property :value table
))
3159 (re-search-forward "^[ \t]*|[^|]" nil t
)
3160 (table-generate-source 'html outbuf
))
3161 (with-current-buffer outbuf
3162 (prog1 (org-trim (buffer-string))
3165 (defun org-html-table (table contents info
)
3166 "Transcode a TABLE element from Org to HTML.
3167 CONTENTS is the contents of the table. INFO is a plist holding
3168 contextual information."
3169 (case (org-element-property :type table
)
3170 ;; Case 1: table.el table. Convert it using appropriate tools.
3171 (table.el
(org-html-table--table.el-table table info
))
3172 ;; Case 2: Standard table.
3174 (let* ((label (org-element-property :name table
))
3175 (caption (org-export-get-caption table
))
3176 (number (org-export-get-ordinal
3177 table info nil
'org-html--has-caption-p
))
3179 (org-html--make-attribute-string
3181 (and label
(list :id
(org-export-solidify-link-text label
)))
3182 (and (not (org-html-html5-p info
))
3183 (plist-get info
:html-table-attributes
))
3184 (org-export-read-attribute :attr_html table
))))
3186 (if (and (boundp 'org-html-format-table-no-css
)
3187 org-html-format-table-no-css
)
3188 "align=\"%s\"" "class=\"%s\""))
3191 (lambda (table info
)
3193 (lambda (table-cell)
3194 (let ((alignment (org-export-table-cell-alignment
3197 ;; Begin a colgroup?
3198 (when (org-export-table-cell-starts-colgroup-p
3201 ;; Add a column. Also specify it's alignment.
3204 "col" (concat " " (format alignspec alignment
)) info
))
3206 (when (org-export-table-cell-ends-colgroup-p
3209 (org-html-table-first-row-data-cells table info
) "\n")))))
3210 (format "<table%s>\n%s\n%s\n%s</table>"
3211 (if (equal attributes
"") "" (concat " " attributes
))
3212 (if (not caption
) ""
3213 (format (if org-html-table-caption-above
3214 "<caption align=\"above\">%s</caption>"
3215 "<caption align=\"bottom\">%s</caption>")
3217 (format (org-html--translate "Table %d:" info
) number
)
3218 " " (org-export-data caption info
))))
3219 (funcall table-column-specs table info
)
3224 (defun org-html-target (target contents info
)
3225 "Transcode a TARGET object from Org to HTML.
3226 CONTENTS is nil. INFO is a plist holding contextual
3228 (let ((id (org-export-solidify-link-text
3229 (org-element-property :value target
))))
3230 (org-html--anchor id
)))
3234 (defun org-html-timestamp (timestamp contents info
)
3235 "Transcode a TIMESTAMP object from Org to HTML.
3236 CONTENTS is nil. INFO is a plist holding contextual
3238 (let ((value (org-html-plain-text
3239 (org-timestamp-translate timestamp
) info
)))
3240 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3241 (replace-regexp-in-string "--" "–" value
))))
3245 (defun org-html-underline (underline contents info
)
3246 "Transcode UNDERLINE from Org to HTML.
3247 CONTENTS is the text with underline markup. INFO is a plist
3248 holding contextual information."
3249 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
3254 (defun org-html-verbatim (verbatim contents info
)
3255 "Transcode VERBATIM from Org to HTML.
3256 CONTENTS is nil. INFO is a plist holding contextual
3258 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
3259 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3263 (defun org-html-verse-block (verse-block contents info
)
3264 "Transcode a VERSE-BLOCK element from Org to HTML.
3265 CONTENTS is verse block contents. INFO is a plist holding
3266 contextual information."
3267 ;; Replace each newline character with line break. Also replace
3268 ;; each blank line with a line break.
3269 (setq contents
(replace-regexp-in-string
3270 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3271 (replace-regexp-in-string
3272 "\\(\\\\\\\\\\)?[ \t]*\n"
3273 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3274 ;; Replace each white space at beginning of a line with a
3275 ;; non-breaking space.
3276 (while (string-match "^[ \t]+" contents
)
3277 (let* ((num-ws (length (match-string 0 contents
)))
3278 (ws (let (out) (dotimes (i num-ws out
)
3279 (setq out
(concat out
" "))))))
3280 (setq contents
(replace-match ws nil t contents
))))
3281 (format "<p class=\"verse\">\n%s</p>" contents
))
3284 ;;; Filter Functions
3286 (defun org-html-final-function (contents backend info
)
3287 "Filter to indent the HTML and convert HTML entities."
3292 (indent-region (point-min) (point-max)))
3293 (when org-html-use-unicode-chars
3295 (mm-url-decode-entities))
3296 (buffer-substring-no-properties (point-min) (point-max))))
3299 ;;; End-user functions
3302 (defun org-html-export-as-html
3303 (&optional async subtreep visible-only body-only ext-plist
)
3304 "Export current buffer to an HTML buffer.
3306 If narrowing is active in the current buffer, only export its
3309 If a region is active, export that region.
3311 A non-nil optional argument ASYNC means the process should happen
3312 asynchronously. The resulting buffer should be accessible
3313 through the `org-export-stack' interface.
3315 When optional argument SUBTREEP is non-nil, export the sub-tree
3316 at point, extracting information from the headline properties
3319 When optional argument VISIBLE-ONLY is non-nil, don't export
3320 contents of hidden elements.
3322 When optional argument BODY-ONLY is non-nil, only write code
3323 between \"<body>\" and \"</body>\" tags.
3325 EXT-PLIST, when provided, is a property list with external
3326 parameters overriding Org default settings, but still inferior to
3327 file-local settings.
3329 Export is done in a buffer named \"*Org HTML Export*\", which
3330 will be displayed when `org-export-show-temporary-export-buffer'
3334 (org-export-async-start
3336 (with-current-buffer (get-buffer-create "*Org HTML Export*")
3339 (goto-char (point-min))
3341 (org-export-add-to-stack (current-buffer) 'html
)))
3342 `(org-export-as 'html
,subtreep
,visible-only
,body-only
',ext-plist
))
3343 (let ((outbuf (org-export-to-buffer
3344 'html
"*Org HTML Export*"
3345 subtreep visible-only body-only ext-plist
)))
3347 (with-current-buffer outbuf
(set-auto-mode t
))
3348 (when org-export-show-temporary-export-buffer
3349 (switch-to-buffer-other-window outbuf
)))))
3352 (defun org-html-convert-region-to-html ()
3353 "Assume the current region has org-mode syntax, and convert it to HTML.
3354 This can be used in any buffer. For example, you can write an
3355 itemized list in org-mode syntax in an HTML buffer and use this
3356 command to convert it."
3358 (org-export-replace-region-by 'html
))
3361 (defun org-html-export-to-html
3362 (&optional async subtreep visible-only body-only ext-plist
)
3363 "Export current buffer to a HTML file.
3365 If narrowing is active in the current buffer, only export its
3368 If a region is active, export that region.
3370 A non-nil optional argument ASYNC means the process should happen
3371 asynchronously. The resulting file should be accessible through
3372 the `org-export-stack' interface.
3374 When optional argument SUBTREEP is non-nil, export the sub-tree
3375 at point, extracting information from the headline properties
3378 When optional argument VISIBLE-ONLY is non-nil, don't export
3379 contents of hidden elements.
3381 When optional argument BODY-ONLY is non-nil, only write code
3382 between \"<body>\" and \"</body>\" tags.
3384 EXT-PLIST, when provided, is a property list with external
3385 parameters overriding Org default settings, but still inferior to
3386 file-local settings.
3388 Return output file's name."
3390 (let* ((extension (concat "." org-html-extension
))
3391 (file (org-export-output-file-name extension subtreep
))
3392 (org-export-coding-system org-html-coding-system
))
3394 (org-export-async-start
3395 (lambda (f) (org-export-add-to-stack f
'html
))
3396 (let ((org-export-coding-system org-html-coding-system
))
3399 'html
,file
,subtreep
,visible-only
,body-only
',ext-plist
))))
3400 (let ((org-export-coding-system org-html-coding-system
))
3402 'html file subtreep visible-only body-only ext-plist
)))))
3405 (defun org-html-publish-to-html (plist filename pub-dir
)
3406 "Publish an org file to HTML.
3408 FILENAME is the filename of the Org file to be published. PLIST
3409 is the property list for the given project. PUB-DIR is the
3410 publishing directory.
3412 Return output file name."
3413 (org-publish-org-to 'html filename
3414 (concat "." (or (plist-get plist
:html-extension
)
3415 org-html-extension
"html"))
3421 ;;;; org-format-table-html
3422 ;;;; org-format-org-table-html
3423 ;;;; org-format-table-table-html
3424 ;;;; org-table-number-fraction
3425 ;;;; org-table-number-regexp
3426 ;;;; org-html-inline-image-extensions
3427 ;;;; org-export-preferred-target-alist
3428 ;;;; class for anchors
3429 ;;;; org-export-mark-todo-in-toc
3430 ;;;; org-html-format-org-link
3431 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
3432 ;;;; alt = (file-name-nondirectory path)
3437 ;; generated-autoload-file: "org-loaddefs.el"
3440 ;;; ox-html.el ends here