1 ;;; ox-html.el --- HTML Back-End for Org Export Engine
3 ;; Copyright (C) 2011-2015 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 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This library implements a HTML back-end for Org generic exporter.
27 ;; See Org manual for more information.
35 (require 'format-spec
)
36 (eval-when-compile (require 'cl
) (require 'table nil
'noerror
))
39 ;;; Function Declarations
41 (declare-function org-id-find-id-file
"org-id" (id))
42 (declare-function htmlize-region
"ext:htmlize" (beg end
))
43 (declare-function org-pop-to-buffer-same-window
44 "org-compat" (&optional buffer-or-name norecord label
))
45 (declare-function mm-url-decode-entities
"mm-url" ())
49 (org-export-define-backend 'html
50 '((bold . org-html-bold
)
51 (center-block . org-html-center-block
)
52 (clock . org-html-clock
)
53 (code . org-html-code
)
54 (drawer . org-html-drawer
)
55 (dynamic-block . org-html-dynamic-block
)
56 (entity . org-html-entity
)
57 (example-block . org-html-example-block
)
58 (export-block . org-html-export-block
)
59 (export-snippet . org-html-export-snippet
)
60 (fixed-width . org-html-fixed-width
)
61 (footnote-definition . org-html-footnote-definition
)
62 (footnote-reference . org-html-footnote-reference
)
63 (headline . org-html-headline
)
64 (horizontal-rule . org-html-horizontal-rule
)
65 (inline-src-block . org-html-inline-src-block
)
66 (inlinetask . org-html-inlinetask
)
67 (inner-template . org-html-inner-template
)
68 (italic . org-html-italic
)
69 (item . org-html-item
)
70 (keyword . org-html-keyword
)
71 (latex-environment . org-html-latex-environment
)
72 (latex-fragment . org-html-latex-fragment
)
73 (line-break . org-html-line-break
)
74 (link . org-html-link
)
75 (node-property . org-html-node-property
)
76 (paragraph . org-html-paragraph
)
77 (plain-list . org-html-plain-list
)
78 (plain-text . org-html-plain-text
)
79 (planning . org-html-planning
)
80 (property-drawer . org-html-property-drawer
)
81 (quote-block . org-html-quote-block
)
82 (radio-target . org-html-radio-target
)
83 (section . org-html-section
)
84 (special-block . org-html-special-block
)
85 (src-block . org-html-src-block
)
86 (statistics-cookie . org-html-statistics-cookie
)
87 (strike-through . org-html-strike-through
)
88 (subscript . org-html-subscript
)
89 (superscript . org-html-superscript
)
90 (table . org-html-table
)
91 (table-cell . org-html-table-cell
)
92 (table-row . org-html-table-row
)
93 (target . org-html-target
)
94 (template . org-html-template
)
95 (timestamp . org-html-timestamp
)
96 (underline . org-html-underline
)
97 (verbatim . org-html-verbatim
)
98 (verse-block . org-html-verse-block
))
100 :filters-alist
'((:filter-options . org-html-infojs-install-script
)
101 (:filter-final-output . org-html-final-function
))
103 '(?h
"Export to HTML"
104 ((?H
"As HTML buffer" org-html-export-as-html
)
105 (?h
"As HTML file" org-html-export-to-html
)
106 (?o
"As HTML file and open"
108 (if a
(org-html-export-to-html t s v b
)
109 (org-open-file (org-html-export-to-html nil s v b
)))))))
111 '((:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
112 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
113 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
114 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
115 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
116 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
117 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
118 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
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-postamble nil
"html-postamble" org-html-postamble
)
122 (:html-preamble nil
"html-preamble" org-html-preamble
)
123 (:html-head
"HTML_HEAD" nil org-html-head newline
)
124 (:html-head-extra
"HTML_HEAD_EXTRA" nil org-html-head-extra newline
)
125 (:html-head-include-default-style
126 nil
"html-style" org-html-head-include-default-style
)
127 (:html-head-include-scripts nil
"html-scripts" org-html-head-include-scripts
)
128 (:html-allow-name-attribute-in-anchors
129 nil nil org-html-allow-name-attribute-in-anchors
)
130 (:html-divs nil nil org-html-divs
)
131 (:html-checkbox-type nil nil org-html-checkbox-type
)
132 (:html-extension nil nil org-html-extension
)
133 (:html-footnote-format nil nil org-html-footnote-format
)
134 (:html-footnote-separator nil nil org-html-footnote-separator
)
135 (:html-footnotes-section nil nil org-html-footnotes-section
)
136 (:html-format-drawer-function nil nil org-html-format-drawer-function
)
137 (:html-format-headline-function nil nil org-html-format-headline-function
)
138 (:html-format-inlinetask-function
139 nil nil org-html-format-inlinetask-function
)
140 (:html-home
/up-format nil nil org-html-home
/up-format
)
141 (:html-indent nil nil org-html-indent
)
142 (:html-infojs-options nil nil org-html-infojs-options
)
143 (:html-infojs-template nil nil org-html-infojs-template
)
144 (:html-inline-image-rules nil nil org-html-inline-image-rules
)
145 (:html-link-org-files-as-html nil nil org-html-link-org-files-as-html
)
146 (:html-mathjax-options nil nil org-html-mathjax-options
)
147 (:html-mathjax-template nil nil org-html-mathjax-template
)
148 (:html-metadata-timestamp-format nil nil org-html-metadata-timestamp-format
)
149 (:html-postamble-format nil nil org-html-postamble-format
)
150 (:html-preamble-format nil nil org-html-preamble-format
)
151 (:html-table-align-individual-fields
152 nil nil org-html-table-align-individual-fields
)
153 (:html-table-caption-above nil nil org-html-table-caption-above
)
154 (:html-table-data-tags nil nil org-html-table-data-tags
)
155 (:html-table-header-tags nil nil org-html-table-header-tags
)
156 (:html-table-use-header-tags-for-first-column
157 nil nil org-html-table-use-header-tags-for-first-column
)
158 (:html-tag-class-prefix nil nil org-html-tag-class-prefix
)
159 (:html-text-markup-alist nil nil org-html-text-markup-alist
)
160 (:html-todo-kwd-class-prefix nil nil org-html-todo-kwd-class-prefix
)
161 (:html-toplevel-hlevel nil nil org-html-toplevel-hlevel
)
162 (:html-use-infojs nil nil org-html-use-infojs
)
163 (:html-use-unicode-chars nil nil org-html-use-unicode-chars
)
164 (:html-validation-link nil nil org-html-validation-link
)
165 (:html-inline-images nil nil org-html-inline-images
)
166 (:html-table-attributes nil nil org-html-table-default-attributes
)
167 (:html-table-row-tags nil nil org-html-table-row-tags
)
168 (:html-xml-declaration nil nil org-html-xml-declaration
)
169 (:infojs-opt
"INFOJS_OPT" nil nil
)
170 ;; Redefine regular options.
171 (:creator
"CREATOR" nil org-html-creator-string
)
172 (:with-latex nil
"tex" org-html-with-latex
)
173 ;; Retrieve LaTeX header for fragments.
174 (:latex-header
"LATEX_HEADER" nil nil newline
)))
177 ;;; Internal Variables
179 (defvar org-html-format-table-no-css
)
180 (defvar htmlize-buffer-places
) ; from htmlize.el
182 (defvar org-html--pre
/postamble-class
"status"
183 "CSS class used for pre/postamble")
185 (defconst org-html-doctype-alist
186 '(("html4-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
187 \"http://www.w3.org/TR/html4/strict.dtd\">")
188 ("html4-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
189 \"http://www.w3.org/TR/html4/loose.dtd\">")
190 ("html4-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
191 \"http://www.w3.org/TR/html4/frameset.dtd\">")
193 ("xhtml-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
194 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
195 ("xhtml-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
196 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
197 ("xhtml-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
198 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
199 ("xhtml-11" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
200 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
202 ("html5" .
"<!DOCTYPE html>")
203 ("xhtml5" .
"<!DOCTYPE html>"))
204 "An alist mapping (x)html flavors to specific doctypes.")
206 (defconst org-html-html5-elements
207 '("article" "aside" "audio" "canvas" "details" "figcaption"
208 "figure" "footer" "header" "menu" "meter" "nav" "output"
209 "progress" "section" "video")
210 "New elements in html5.
212 For blocks that should contain headlines, use the HTML_CONTAINER
213 property on the headline itself.")
215 (defconst org-html-special-string-regexps
216 '(("\\\\-" .
"­") ; shy
217 ("---\\([^-]\\)" .
"—\\1") ; mdash
218 ("--\\([^-]\\)" .
"–\\1") ; ndash
219 ("\\.\\.\\." .
"…")) ; hellip
220 "Regular expressions for special string conversion.")
222 (defconst org-html-scripts
223 "<script type=\"text/javascript\">
225 @licstart The following is the entire license notice for the
226 JavaScript code in this tag.
228 Copyright (C) 2012-2013 Free Software Foundation, Inc.
230 The JavaScript code in this tag is free software: you can
231 redistribute it and/or modify it under the terms of the GNU
232 General Public License (GNU GPL) as published by the Free Software
233 Foundation, either version 3 of the License, or (at your option)
234 any later version. The code is distributed WITHOUT ANY WARRANTY;
235 without even the implied warranty of MERCHANTABILITY or FITNESS
236 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
238 As additional permission under GNU GPL version 3 section 7, you
239 may distribute non-source (e.g., minimized or compacted) forms of
240 that code without the copy of the GNU GPL normally required by
241 section 4, provided you include this license notice and a URL
242 through which recipients can access the Corresponding Source.
245 @licend The above is the entire license notice
246 for the JavaScript code in this tag.
248 <!--/*--><![CDATA[/*><!--*/
249 function CodeHighlightOn(elem, id)
251 var target = document.getElementById(id);
253 elem.cacheClassElem = elem.className;
254 elem.cacheClassTarget = target.className;
255 target.className = \"code-highlighted\";
256 elem.className = \"code-highlighted\";
259 function CodeHighlightOff(elem, id)
261 var target = document.getElementById(id);
262 if(elem.cacheClassElem)
263 elem.className = elem.cacheClassElem;
264 if(elem.cacheClassTarget)
265 target.className = elem.cacheClassTarget;
269 "Basic JavaScript that is needed by HTML files produced by Org mode.")
271 (defconst org-html-style-default
272 "<style type=\"text/css\">
273 <!--/*--><![CDATA[/*><!--*/
274 .title { text-align: center; }
275 .todo { font-family: monospace; color: red; }
276 .done { font-family: monospace; color: green; }
277 .priority { font-family: monospace; color: orange; }
278 .tag { background-color: #eee; font-family: monospace;
279 padding: 2px; font-size: 80%; font-weight: normal; }
280 .timestamp { color: #bebebe; }
281 .timestamp-kwd { color: #5f9ea0; }
282 .right { margin-left: auto; margin-right: 0px; text-align: right; }
283 .left { margin-left: 0px; margin-right: auto; text-align: left; }
284 .center { margin-left: auto; margin-right: auto; text-align: center; }
285 .underline { text-decoration: underline; }
286 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
287 p.verse { margin-left: 3%; }
289 border: 1px solid #ccc;
290 box-shadow: 3px 3px 3px #eee;
292 font-family: monospace;
304 background-color: white;
308 border: 1px solid black;
310 pre.src:hover:before { display: inline;}
311 pre.src-sh:before { content: 'sh'; }
312 pre.src-bash:before { content: 'sh'; }
313 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
314 pre.src-R:before { content: 'R'; }
315 pre.src-perl:before { content: 'Perl'; }
316 pre.src-java:before { content: 'Java'; }
317 pre.src-sql:before { content: 'SQL'; }
319 table { border-collapse:collapse; }
320 caption.t-above { caption-side: top; }
321 caption.t-bottom { caption-side: bottom; }
322 td, th { vertical-align:top; }
323 th.right { text-align: center; }
324 th.left { text-align: center; }
325 th.center { text-align: center; }
326 td.right { text-align: right; }
327 td.left { text-align: left; }
328 td.center { text-align: center; }
329 dt { font-weight: bold; }
330 .footpara:nth-child(2) { display: inline; }
331 .footpara { display: block; }
332 .footdef { margin-bottom: 1em; }
333 .figure { padding: 1em; }
334 .figure p { text-align: center; }
337 border: 2px solid gray;
342 { text-align: right; font-size: 70%; white-space: nowrap; }
343 textarea { overflow-x: auto; }
344 .linenr { font-size: smaller }
345 .code-highlighted { background-color: #ffff00; }
346 .org-info-js_info-navigation { border-style: none; }
347 #org-info-js_console-label
348 { font-size: 10px; font-weight: bold; white-space: nowrap; }
349 .org-info-js_search-highlight
350 { background-color: #ffff00; color: #000000; font-weight: bold; }
353 "The default style specification for exported HTML files.
354 You can use `org-html-head' and `org-html-head-extra' to add to
355 this style. If you don't want to include this default style,
356 customize `org-html-head-include-default-style'.")
359 ;;; User Configuration Variables
361 (defgroup org-export-html nil
362 "Options for exporting Org mode files to HTML."
363 :tag
"Org Export HTML"
368 (defvar org-html-infojs-opts-table
369 '((path PATH
"http://orgmode.org/org-info.js")
373 (tdepth TOC_DEPTH
"max")
374 (sdepth SECTION_DEPTH
"max")
375 (mouse MOUSE_HINT
"underline")
376 (buttons VIEW_BUTTONS
"0")
378 (up LINK_UP
:html-link-up
)
379 (home LINK_HOME
:html-link-home
))
380 "JavaScript options, long form for script, default values.")
382 (defcustom org-html-use-infojs
'when-configured
383 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
384 This option can be nil or t to never or always use the script.
385 It can also be the symbol `when-configured', meaning that the
386 script will be linked into the export file if and only if there
387 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
388 `org-html-infojs-options'."
389 :group
'org-export-html
391 :package-version
'(Org .
"8.0")
393 (const :tag
"Never" nil
)
394 (const :tag
"When configured in buffer" when-configured
)
395 (const :tag
"Always" t
)))
397 (defcustom org-html-infojs-options
398 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
399 "Options settings for the INFOJS JavaScript.
400 Each of the options must have an entry in `org-html-infojs-opts-table'.
401 The value can either be a string that will be passed to the script, or
402 a property. This property is then assumed to be a property that is defined
403 by the Export/Publishing setup of Org.
404 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
405 means to use the maximum value consistent with other options."
406 :group
'org-export-html
408 :package-version
'(Org .
"8.0")
410 `(set :greedy t
:inline t
413 (list 'cons
(list 'const
(car x
))
415 (symbol :tag
"Publishing/Export property")
416 (string :tag
"Value"))))
417 org-html-infojs-opts-table
)))
419 (defcustom org-html-infojs-template
420 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
423 * @source: %SCRIPT_PATH
425 * @licstart The following is the entire license notice for the
426 * JavaScript code in %SCRIPT_PATH.
428 * Copyright (C) 2012-2013 Free Software Foundation, Inc.
431 * The JavaScript code in this tag is free software: you can
432 * redistribute it and/or modify it under the terms of the GNU
433 * General Public License (GNU GPL) as published by the Free Software
434 * Foundation, either version 3 of the License, or (at your option)
435 * any later version. The code is distributed WITHOUT ANY WARRANTY;
436 * without even the implied warranty of MERCHANTABILITY or FITNESS
437 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
439 * As additional permission under GNU GPL version 3 section 7, you
440 * may distribute non-source (e.g., minimized or compacted) forms of
441 * that code without the copy of the GNU GPL normally required by
442 * section 4, provided you include this license notice and a URL
443 * through which recipients can access the Corresponding Source.
445 * @licend The above is the entire license notice
446 * for the JavaScript code in %SCRIPT_PATH.
451 <script type=\"text/javascript\">
454 @licstart The following is the entire license notice for the
455 JavaScript code in this tag.
457 Copyright (C) 2012-2013 Free Software Foundation, Inc.
459 The JavaScript code in this tag is free software: you can
460 redistribute it and/or modify it under the terms of the GNU
461 General Public License (GNU GPL) as published by the Free Software
462 Foundation, either version 3 of the License, or (at your option)
463 any later version. The code is distributed WITHOUT ANY WARRANTY;
464 without even the implied warranty of MERCHANTABILITY or FITNESS
465 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
467 As additional permission under GNU GPL version 3 section 7, you
468 may distribute non-source (e.g., minimized or compacted) forms of
469 that code without the copy of the GNU GPL normally required by
470 section 4, provided you include this license notice and a URL
471 through which recipients can access the Corresponding Source.
474 @licend The above is the entire license notice
475 for the JavaScript code in this tag.
478 <!--/*--><![CDATA[/*><!--*/
480 org_html_manager.setup(); // activate after the parameters are set
483 "The template for the export style additions when org-info.js is used.
484 Option settings will replace the %MANAGER-OPTIONS cookie."
485 :group
'org-export-html
487 :package-version
'(Org .
"8.0")
490 (defun org-html-infojs-install-script (exp-plist backend
)
491 "Install script in export options when appropriate.
492 EXP-PLIST is a plist containing export options. BACKEND is the
493 export back-end currently used."
494 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
495 (not (plist-get exp-plist
:html-use-infojs
))
496 (and (eq (plist-get exp-plist
:html-use-infojs
) 'when-configured
)
497 (let ((opt (plist-get exp-plist
:infojs-opt
)))
500 (string-match "\\<view:nil\\>" opt
)))))
501 (let* ((template (plist-get exp-plist
:html-infojs-template
))
502 (ptoc (plist-get exp-plist
:with-toc
))
503 (hlevels (plist-get exp-plist
:headline-levels
))
505 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
506 (options (plist-get exp-plist
:infojs-opt
))
507 (infojs-opt (plist-get exp-plist
:html-infojs-options
))
508 (table org-html-infojs-opts-table
)
510 (dolist (entry table
)
511 (let* ((opt (car entry
))
513 ;; Compute default values for script option OPT from
514 ;; `org-html-infojs-options' variable.
516 (let ((default (cdr (assq opt infojs-opt
))))
517 (if (and (symbolp default
) (not (memq default
'(t nil
))))
518 (plist-get exp-plist default
)
520 ;; Value set through INFOJS_OPT keyword has precedence
521 ;; over the default one.
522 (val (if (and options
523 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
525 (match-string 1 options
)
529 (replace-regexp-in-string
530 "%SCRIPT_PATH" val template t t
)))
531 (sdepth (when (integerp (read val
))
532 (setq sdepth
(min (read val
) sdepth
))))
533 (tdepth (when (integerp (read val
))
534 (setq tdepth
(min (read val
) tdepth
))))
537 ((or (eq val t
) (equal val
"t")) "1")
538 ((or (eq val nil
) (equal val
"nil")) "0")
540 (t (format "%s" val
))))
541 (push (cons var val
) style
)))))
542 ;; Now we set the depth of the *generated* TOC to SDEPTH,
543 ;; because the toc will actually determine the splitting. How
544 ;; much of the toc will actually be displayed is governed by the
546 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
547 ;; The table of contents should not show more sections than we
549 (setq tdepth
(min tdepth sdepth
))
550 (push (cons "TOC_DEPTH" tdepth
) style
)
551 ;; Build style string.
552 (setq style
(mapconcat
554 (format "org_html_manager.set(\"%s\", \"%s\");"
557 (when (and style
(> (length style
) 0))
558 (and (string-match "%MANAGER_OPTIONS" template
)
559 (setq style
(replace-match style t t template
))
562 exp-plist
:html-head-extra
563 (concat (or (plist-get exp-plist
:html-head-extra
) "")
566 ;; This script absolutely needs the table of contents, so we
567 ;; change that setting.
568 (unless (plist-get exp-plist
:with-toc
)
569 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
570 ;; Return the modified property list.
575 (defcustom org-html-text-markup-alist
576 '((bold .
"<b>%s</b>")
577 (code .
"<code>%s</code>")
578 (italic .
"<i>%s</i>")
579 (strike-through .
"<del>%s</del>")
580 (underline .
"<span class=\"underline\">%s</span>")
581 (verbatim .
"<code>%s</code>"))
582 "Alist of HTML expressions to convert text markup.
584 The key must be a symbol among `bold', `code', `italic',
585 `strike-through', `underline' and `verbatim'. The value is
586 a formatting string to wrap fontified text with.
588 If no association can be found for a given markup, text will be
590 :group
'org-export-html
592 :package-version
'(Org .
"8.0")
593 :type
'(alist :key-type
(symbol :tag
"Markup type")
594 :value-type
(string :tag
"Format string"))
595 :options
'(bold code italic strike-through underline verbatim
))
597 (defcustom org-html-indent nil
598 "Non-nil means to indent the generated HTML.
599 Warning: non-nil may break indentation of source code blocks."
600 :group
'org-export-html
602 :package-version
'(Org .
"8.0")
605 (defcustom org-html-use-unicode-chars nil
606 "Non-nil means to use unicode characters instead of HTML entities."
607 :group
'org-export-html
609 :package-version
'(Org .
"8.0")
614 (defcustom org-html-format-drawer-function
(lambda (name contents
) contents
)
615 "Function called to format a drawer in HTML code.
617 The function must accept two parameters:
618 NAME the drawer name, like \"LOGBOOK\"
619 CONTENTS the contents of the drawer.
621 The function should return the string to be exported.
623 For example, the variable could be set to the following function
624 in order to mimic default behaviour:
626 The default value simply returns the value of CONTENTS."
627 :group
'org-export-html
629 :package-version
'(Org .
"8.0")
634 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
635 <h2 class=\"footnotes\">%s: </h2>
636 <div id=\"text-footnotes\">
640 "Format for the footnotes section.
641 Should contain a two instances of %s. The first will be replaced with the
642 language-specific word for \"Footnotes\", the second one will be replaced
643 by the footnotes themselves."
644 :group
'org-export-html
647 (defcustom org-html-footnote-format
"<sup>%s</sup>"
648 "The format for the footnote reference.
649 %s will be replaced by the footnote reference itself."
650 :group
'org-export-html
653 (defcustom org-html-footnote-separator
"<sup>, </sup>"
654 "Text used to separate footnotes."
655 :group
'org-export-html
660 (defcustom org-html-toplevel-hlevel
2
661 "The <H> level for level 1 headings in HTML export.
662 This is also important for the classes that will be wrapped around headlines
663 and outline structure. If this variable is 1, the top-level headlines will
664 be <h1>, and the corresponding classes will be outline-1, section-number-1,
665 and outline-text-1. If this is 2, all of these will get a 2 instead.
666 The default for this variable is 2, because we use <h1> for formatting the
668 :group
'org-export-html
671 (defcustom org-html-format-headline-function
672 'org-html-format-headline-default-function
673 "Function to format headline text.
675 This function will be called with six arguments:
676 TODO the todo keyword (string or nil).
677 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
678 PRIORITY the priority of the headline (integer or nil)
679 TEXT the main headline text (string).
680 TAGS the tags (string or nil).
681 INFO the export options (plist).
683 The function result will be used in the section format string."
684 :group
'org-export-html
686 :package-version
'(Org .
"8.3")
691 (defcustom org-html-allow-name-attribute-in-anchors nil
692 "When nil, do not set \"name\" attribute in anchors.
693 By default, when appropriate, anchors are formatted with \"id\"
694 but without \"name\" attribute."
695 :group
'org-export-html
697 :package-version
'(Org .
"8.0")
702 (defcustom org-html-format-inlinetask-function
703 'org-html-format-inlinetask-default-function
704 "Function called to format an inlinetask in HTML code.
706 The function must accept seven parameters:
707 TODO the todo keyword, as a string
708 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
709 PRIORITY the inlinetask priority, as a string
710 NAME the inlinetask name, as a string.
711 TAGS the inlinetask tags, as a list of strings.
712 CONTENTS the contents of the inlinetask, as a string.
713 INFO the export options, as a plist
715 The function should return the string to be exported."
716 :group
'org-export-html
718 :package-version
'(Org .
"8.3")
723 (defcustom org-html-with-latex org-export-with-latex
724 "Non-nil means process LaTeX math snippets.
726 When set, the exporter will process LaTeX environments and
729 This option can also be set with the +OPTIONS line,
730 e.g. \"tex:mathjax\". Allowed values are:
732 nil Ignore math snippets.
733 `verbatim' Keep everything in verbatim
734 `dvipng' Process the LaTeX fragments to images. This will also
735 include processing of non-math environments.
736 `imagemagick' Convert the LaTeX fragments to pdf files and use
737 imagemagick to convert pdf files to png files.
738 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
740 t Synonym for `mathjax'."
741 :group
'org-export-html
743 :package-version
'(Org .
"8.0")
745 (const :tag
"Do not process math in any way" nil
)
746 (const :tag
"Use dvipng to make images" dvipng
)
747 (const :tag
"Use imagemagick to make images" imagemagick
)
748 (const :tag
"Use MathJax to display math" mathjax
)
749 (const :tag
"Leave math verbatim" verbatim
)))
751 ;;;; Links :: Generic
753 (defcustom org-html-link-org-files-as-html t
754 "Non-nil means make file links to `file.org' point to `file.html'.
755 When `org-mode' is exporting an `org-mode' file to HTML, links to
756 non-html files are directly put into a href tag in HTML.
757 However, links to other Org-mode files (recognized by the
758 extension `.org.) should become links to the corresponding html
759 file, assuming that the linked `org-mode' file will also be
761 When nil, the links still point to the plain `.org' file."
762 :group
'org-export-html
765 ;;;; Links :: Inline images
767 (defcustom org-html-inline-images t
768 "Non-nil means inline images into exported HTML pages.
769 This is done using an <img> tag. When nil, an anchor with href is used to
771 :group
'org-export-html
773 :package-version
'(Org .
"8.1")
776 (defcustom org-html-inline-image-rules
777 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
778 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
779 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
780 "Rules characterizing image files that can be inlined into HTML.
781 A rule consists in an association whose key is the type of link
782 to consider, and value is a regexp that will be matched against
784 :group
'org-export-html
786 :package-version
'(Org .
"8.0")
787 :type
'(alist :key-type
(string :tag
"Type")
788 :value-type
(regexp :tag
"Path")))
792 (defvar org-html-protect-char-alist
796 "Alist of characters to be converted by `org-html-encode-plain-text'.")
800 (defcustom org-html-htmlize-output-type
'inline-css
801 "Output type to be used by htmlize when formatting code snippets.
802 Choices are `css' to export the CSS selectors only,`inline-css'
803 to export the CSS attribute values inline in the HTML or `nil' to
804 export plain text. We use as default `inline-css', in order to
805 make the resulting HTML self-containing.
807 However, this will fail when using Emacs in batch mode for export, because
808 then no rich font definitions are in place. It will also not be good if
809 people with different Emacs setup contribute HTML files to a website,
810 because the fonts will represent the individual setups. In these cases,
811 it is much better to let Org/Htmlize assign classes only, and to use
812 a style file to define the look of these classes.
813 To get a start for your css file, start Emacs session and make sure that
814 all the faces you are interested in are defined, for example by loading files
815 in all modes you want. Then, use the command
816 \\[org-html-htmlize-generate-css] to extract class definitions."
817 :group
'org-export-html
818 :type
'(choice (const css
) (const inline-css
) (const nil
)))
820 (defcustom org-html-htmlize-font-prefix
"org-"
821 "The prefix for CSS class names for htmlize font specifications."
822 :group
'org-export-html
827 (defcustom org-html-table-default-attributes
828 '(:border
"2" :cellspacing
"0" :cellpadding
"6" :rules
"groups" :frame
"hsides")
829 "Default attributes and values which will be used in table tags.
830 This is a plist where attributes are symbols, starting with
831 colons, and values are strings.
833 When exporting to HTML5, these values will be disregarded."
834 :group
'org-export-html
836 :package-version
'(Org .
"8.0")
837 :type
'(plist :key-type
(symbol :tag
"Property")
838 :value-type
(string :tag
"Value")))
840 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
841 "The opening and ending tags for table header fields.
842 This is customizable so that alignment options can be specified.
843 The first %s will be filled with the scope of the field, either row or col.
844 The second %s will be replaced by a style entry to align the field.
845 See also the variable `org-html-table-use-header-tags-for-first-column'.
846 See also the variable `org-html-table-align-individual-fields'."
847 :group
'org-export-html
848 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
850 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
851 "The opening and ending tags for table data fields.
852 This is customizable so that alignment options can be specified.
853 The first %s will be filled with the scope of the field, either row or col.
854 The second %s will be replaced by a style entry to align the field.
855 See also the variable `org-html-table-align-individual-fields'."
856 :group
'org-export-html
857 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
859 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
860 "The opening and ending tags for table rows.
861 This is customizable so that alignment options can be specified.
862 Instead of strings, these can be Lisp forms that will be
863 evaluated for each row in order to construct the table row tags.
865 During evaluation, these variables will be dynamically bound so that
868 `row-number': row number (0 is the first row)
869 `rowgroup-number': group number of current row
870 `start-rowgroup-p': non-nil means the row starts a group
871 `end-rowgroup-p': non-nil means the row ends a group
872 `top-row-p': non-nil means this is the top row
873 `bottom-row-p': non-nil means this is the bottom row
877 \(setq org-html-table-row-tags
878 (cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
879 (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
880 (t (if (= (mod row-number 2) 1)
881 \"<tr class=\\\"tr-odd\\\">\"
882 \"<tr class=\\\"tr-even\\\">\")))
885 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
886 and the bottom row, and otherwise alternate between \"tr-odd\" and
887 \"tr-even\" for odd and even rows."
888 :group
'org-export-html
890 (choice :tag
"Opening tag"
891 (string :tag
"Specify")
893 (choice :tag
"Closing tag"
894 (string :tag
"Specify")
897 (defcustom org-html-table-align-individual-fields t
898 "Non-nil means attach style attributes for alignment to each table field.
899 When nil, alignment will only be specified in the column tags, but this
900 is ignored by some browsers (like Firefox, Safari). Opera does it right
902 :group
'org-export-html
905 (defcustom org-html-table-use-header-tags-for-first-column nil
906 "Non-nil means format column one in tables with header tags.
907 When nil, also column one will use data tags."
908 :group
'org-export-html
911 (defcustom org-html-table-caption-above t
912 "When non-nil, place caption string at the beginning of the table.
913 Otherwise, place it near the end."
914 :group
'org-export-html
919 (defcustom org-html-tag-class-prefix
""
920 "Prefix to class names for TODO keywords.
921 Each tag gets a class given by the tag itself, with this prefix.
922 The default prefix is empty because it is nice to just use the keyword
923 as a class name. But if you get into conflicts with other, existing
924 CSS classes, then this prefix can be very useful."
925 :group
'org-export-html
928 ;;;; Template :: Generic
930 (defcustom org-html-extension
"html"
931 "The extension for exported HTML files."
932 :group
'org-export-html
935 (defcustom org-html-xml-declaration
936 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
937 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
938 "The extension for exported HTML files.
939 %s will be replaced with the charset of the exported file.
940 This may be a string, or an alist with export extensions
941 and corresponding declarations.
943 This declaration only applies when exporting to XHTML."
944 :group
'org-export-html
946 (string :tag
"Single declaration")
947 (repeat :tag
"Dependent on extension"
948 (cons (string :tag
"Extension")
949 (string :tag
"Declaration")))))
951 (defcustom org-html-coding-system
'utf-8
952 "Coding system for HTML export.
953 Use utf-8 as the default value."
954 :group
'org-export-html
956 :package-version
'(Org .
"8.0")
957 :type
'coding-system
)
959 (defcustom org-html-doctype
"xhtml-strict"
960 "Document type definition to use for exported HTML files.
961 Can be set with the in-buffer HTML_DOCTYPE property or for
962 publishing, with :html-doctype."
963 :group
'org-export-html
965 :package-version
'(Org .
"8.0")
968 (mapcar (lambda (x) `(const ,(car x
))) org-html-doctype-alist
)
969 '((string :tag
"Custom doctype" ))))
971 (defcustom org-html-html5-fancy nil
972 "Non-nil means using new HTML5 elements.
973 This variable is ignored for anything other than HTML5 export.
975 For compatibility with Internet Explorer, it's probably a good
976 idea to download some form of the html5shiv (for instance
977 https://code.google.com/p/html5shiv/) and add it to your
978 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
979 versions 8 and below."
980 :group
'org-export-html
982 :package-version
'(Org .
"8.0")
985 (defcustom org-html-container-element
"div"
986 "HTML element to use for wrapping top level sections.
987 Can be set with the in-buffer HTML_CONTAINER property or for
988 publishing, with :html-container.
990 Note that changing the default will prevent you from using
991 org-info.js for your website."
992 :group
'org-export-html
994 :package-version
'(Org .
"8.0")
997 (defcustom org-html-divs
998 '((preamble "div" "preamble")
999 (content "div" "content")
1000 (postamble "div" "postamble"))
1001 "Alist of the three section elements for HTML export.
1002 The car of each entry is one of 'preamble, 'content or 'postamble.
1003 The cdrs of each entry are the ELEMENT_TYPE and ID for each
1004 section of the exported document.
1006 Note that changing the default will prevent you from using
1007 org-info.js for your website."
1008 :group
'org-export-html
1010 :package-version
'(Org .
"8.0")
1011 :type
'(list :greedy t
1012 (list :tag
"Preamble"
1013 (const :format
"" preamble
)
1014 (string :tag
"element") (string :tag
" id"))
1015 (list :tag
"Content"
1016 (const :format
"" content
)
1017 (string :tag
"element") (string :tag
" id"))
1018 (list :tag
"Postamble" (const :format
"" postamble
)
1019 (string :tag
" id") (string :tag
"element"))))
1021 (defconst org-html-checkbox-types
1023 ((on .
"☑") (off .
"☐") (trans .
"☐")))
1025 ((on .
"<code>[X]</code>")
1026 (off .
"<code>[ ]</code>")
1027 (trans .
"<code>[-]</code>")))
1029 ((on .
"<input type='checkbox' checked='checked' />")
1030 (off .
"<input type='checkbox' />")
1031 (trans .
"<input type='checkbox' />"))))
1032 "Alist of checkbox types.
1033 The cdr of each entry is an alist list three checkbox types for
1034 HTML export: `on', `off' and `trans'.
1037 `unicode' Unicode characters (HTML entities)
1038 `ascii' ASCII characters
1039 `html' HTML checkboxes
1041 Note that only the ascii characters implement tri-state
1042 checkboxes. The other two use the `off' checkbox for `trans'.")
1044 (defcustom org-html-checkbox-type
'ascii
1045 "The type of checkboxes to use for HTML export.
1046 See `org-html-checkbox-types' for for the values used for each
1048 :group
'org-export-html
1050 :package-version
'(Org .
"8.0")
1052 (const :tag
"ASCII characters" ascii
)
1053 (const :tag
"Unicode characters" unicode
)
1054 (const :tag
"HTML checkboxes" html
)))
1056 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
1057 "Format used for timestamps in preamble, postamble and metadata.
1058 See `format-time-string' for more information on its components."
1059 :group
'org-export-html
1061 :package-version
'(Org .
"8.0")
1064 ;;;; Template :: Mathjax
1066 (defcustom org-html-mathjax-options
1067 '((path "http://orgmode.org/mathjax/MathJax.js")
1072 "Options for MathJax setup.
1074 path The path where to find MathJax
1075 scale Scaling for the HTML-CSS backend, usually between 100 and 133
1076 align How to align display math: left, center, or right
1077 indent If align is not center, how far from the left/right side?
1078 mathml Should a MathML player be used if available?
1079 This is faster and reduces bandwidth use, but currently
1080 sometimes has lower spacing quality. Therefore, the default is
1081 nil. When browsers get better, this switch can be flipped.
1083 You can also customize this for each buffer, using something like
1085 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
1086 :group
'org-export-html
1087 :type
'(list :greedy t
1088 (list :tag
"path (the path from where to load MathJax.js)"
1089 (const :format
" " path
) (string))
1090 (list :tag
"scale (scaling for the displayed math)"
1091 (const :format
" " scale
) (string))
1092 (list :tag
"align (alignment of displayed equations)"
1093 (const :format
" " align
) (string))
1094 (list :tag
"indent (indentation with left or right alignment)"
1095 (const :format
" " indent
) (string))
1096 (list :tag
"mathml (should MathML display be used is possible)"
1097 (const :format
" " mathml
) (boolean))))
1099 (defcustom org-html-mathjax-template
1100 "<script type=\"text/javascript\" src=\"%PATH\"></script>
1101 <script type=\"text/javascript\">
1102 <!--/*--><![CDATA[/*><!--*/
1103 MathJax.Hub.Config({
1104 // Only one of the two following lines, depending on user settings
1105 // First allows browser-native MathML display, second forces HTML/CSS
1106 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
1107 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
1108 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
1109 \"TeX/noUndefined.js\"],
1111 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
1112 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
1113 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
1114 ignoreClass: \"tex2jax_ignore\",
1115 processEscapes: false,
1116 processEnvironments: true,
1119 showProcessingMessages: true,
1120 displayAlign: \"%ALIGN\",
1121 displayIndent: \"%INDENT\",
1125 availableFonts: [\"STIX\",\"TeX\"],
1126 preferredFont: \"TeX\",
1142 "The MathJax setup for XHTML files."
1143 :group
'org-export-html
1146 ;;;; Template :: Postamble
1148 (defcustom org-html-postamble
'auto
1149 "Non-nil means insert a postamble in HTML export.
1151 When set to 'auto, check against the
1152 `org-export-with-author/email/creator/date' variables to set the
1153 content of the postamble. When set to a string, use this string
1154 as the postamble. When t, insert a string as defined by the
1155 formatting string in `org-html-postamble-format'.
1157 When set to a function, apply this function and insert the
1158 returned string. The function takes the property list of export
1159 options as its only argument.
1161 Setting :html-postamble in publishing projects will take
1162 precedence over this variable."
1163 :group
'org-export-html
1164 :type
'(choice (const :tag
"No postamble" nil
)
1165 (const :tag
"Auto postamble" auto
)
1166 (const :tag
"Default formatting string" t
)
1167 (string :tag
"Custom formatting string")
1168 (function :tag
"Function (must return a string)")))
1170 (defcustom org-html-postamble-format
1171 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1172 <p class=\"date\">Date: %d</p>
1173 <p class=\"creator\">%c</p>
1174 <p class=\"validation\">%v</p>"))
1175 "Alist of languages and format strings for the HTML postamble.
1177 The first element of each list is the language code, as used for
1178 the LANGUAGE keyword. See `org-export-default-language'.
1180 The second element of each list is a format string to format the
1181 postamble itself. This format string can contain these elements:
1183 %t stands for the title.
1184 %a stands for the author's name.
1185 %e stands for the author's email.
1186 %d stands for the date.
1187 %c will be replaced by `org-html-creator-string'.
1188 %v will be replaced by `org-html-validation-link'.
1189 %T will be replaced by the export time.
1190 %C will be replaced by the last modification time.
1192 If you need to use a \"%\" character, you need to escape it
1194 :group
'org-export-html
1196 (list (string :tag
"Language")
1197 (string :tag
"Format string"))))
1199 (defcustom org-html-validation-link
1200 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1201 "Link to HTML validation service."
1202 :group
'org-export-html
1205 (defcustom org-html-creator-string
1206 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1208 (if (fboundp 'org-version
) (org-version) "unknown version"))
1209 "Information about the creator of the HTML document.
1210 This option can also be set on with the CREATOR keyword."
1211 :group
'org-export-html
1213 :package-version
'(Org .
"8.0")
1214 :type
'(string :tag
"Creator string"))
1216 ;;;; Template :: Preamble
1218 (defcustom org-html-preamble t
1219 "Non-nil means insert a preamble in HTML export.
1221 When t, insert a string as defined by the formatting string in
1222 `org-html-preamble-format'. When set to a string, use this
1223 formatting string instead (see `org-html-postamble-format' for an
1224 example of such a formatting string).
1226 When set to a function, apply this function and insert the
1227 returned string. The function takes the property list of export
1228 options as its only argument.
1230 Setting :html-preamble in publishing projects will take
1231 precedence over this variable."
1232 :group
'org-export-html
1233 :type
'(choice (const :tag
"No preamble" nil
)
1234 (const :tag
"Default preamble" t
)
1235 (string :tag
"Custom formatting string")
1236 (function :tag
"Function (must return a string)")))
1238 (defcustom org-html-preamble-format
'(("en" ""))
1239 "Alist of languages and format strings for the HTML preamble.
1241 The first element of each list is the language code, as used for
1242 the LANGUAGE keyword. See `org-export-default-language'.
1244 The second element of each list is a format string to format the
1245 preamble itself. This format string can contain these elements:
1247 %t stands for the title.
1248 %a stands for the author's name.
1249 %e stands for the author's email.
1250 %d stands for the date.
1251 %c will be replaced by `org-html-creator-string'.
1252 %v will be replaced by `org-html-validation-link'.
1253 %T will be replaced by the export time.
1254 %C will be replaced by the last modification time.
1256 If you need to use a \"%\" character, you need to escape it
1259 See the default value of `org-html-postamble-format' for an
1261 :group
'org-export-html
1263 (list (string :tag
"Language")
1264 (string :tag
"Format string"))))
1266 (defcustom org-html-link-up
""
1267 "Where should the \"UP\" link of exported HTML pages lead?"
1268 :group
'org-export-html
1269 :type
'(string :tag
"File or URL"))
1271 (defcustom org-html-link-home
""
1272 "Where should the \"HOME\" link of exported HTML pages lead?"
1273 :group
'org-export-html
1274 :type
'(string :tag
"File or URL"))
1276 (defcustom org-html-link-use-abs-url nil
1277 "Should we prepend relative links with HTML_LINK_HOME?"
1278 :group
'org-export-html
1280 :package-version
'(Org .
"8.1")
1283 (defcustom org-html-home
/up-format
1284 "<div id=\"org-div-home-and-up\">
1285 <a accesskey=\"h\" href=\"%s\"> UP </a>
1287 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1289 "Snippet used to insert the HOME and UP links.
1290 This is a format string, the first %s will receive the UP link,
1291 the second the HOME link. If both `org-html-link-up' and
1292 `org-html-link-home' are empty, the entire snippet will be
1294 :group
'org-export-html
1297 ;;;; Template :: Scripts
1299 (define-obsolete-variable-alias
1300 'org-html-style-include-scripts
'org-html-head-include-scripts
"24.4")
1301 (defcustom org-html-head-include-scripts t
1302 "Non-nil means include the JavaScript snippets in exported HTML files.
1303 The actual script is defined in `org-html-scripts' and should
1305 :group
'org-export-html
1307 :package-version
'(Org .
"8.0")
1310 ;;;; Template :: Styles
1312 (define-obsolete-variable-alias
1313 'org-html-style-include-default
'org-html-head-include-default-style
"24.4")
1314 (defcustom org-html-head-include-default-style t
1315 "Non-nil means include the default style in exported HTML files.
1316 The actual style is defined in `org-html-style-default' and
1317 should not be modified. Use `org-html-head' to use your own
1319 :group
'org-export-html
1321 :package-version
'(Org .
"8.0")
1324 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1326 (define-obsolete-variable-alias 'org-html-style
'org-html-head
"24.4")
1327 (defcustom org-html-head
""
1328 "Org-wide head definitions for exported HTML files.
1330 This variable can contain the full HTML structure to provide a
1331 style, including the surrounding HTML tags. You can consider
1332 including definitions for the following classes: title, todo,
1333 done, timestamp, timestamp-kwd, tag, target.
1335 For example, a valid value would be:
1337 <style type=\"text/css\">
1339 p { font-weight: normal; color: gray; }
1340 h1 { color: black; }
1341 .title { text-align: center; }
1342 .todo, .timestamp-kwd { color: red; }
1343 .done { color: green; }
1347 If you want to refer to an external style, use something like
1349 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1351 As the value of this option simply gets inserted into the HTML
1352 <head> header, you can use it to add any arbitrary text to the
1355 You can set this on a per-file basis using #+HTML_HEAD:,
1356 or for publication projects using the :html-head property."
1357 :group
'org-export-html
1359 :package-version
'(Org .
"8.0")
1362 (put 'org-html-head
'safe-local-variable
'stringp
)
1364 (defcustom org-html-head-extra
""
1365 "More head information to add in the HTML output.
1367 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1368 or for publication projects using the :html-head-extra property."
1369 :group
'org-export-html
1371 :package-version
'(Org .
"8.0")
1374 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1378 (defcustom org-html-todo-kwd-class-prefix
""
1379 "Prefix to class names for TODO keywords.
1380 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1381 The default prefix is empty because it is nice to just use the keyword
1382 as a class name. But if you get into conflicts with other, existing
1383 CSS classes, then this prefix can be very useful."
1384 :group
'org-export-html
1388 ;;; Internal Functions
1390 (defun org-html-xhtml-p (info)
1391 (let ((dt (downcase (plist-get info
:html-doctype
))))
1392 (string-match-p "xhtml" dt
)))
1394 (defun org-html-html5-p (info)
1395 (let ((dt (downcase (plist-get info
:html-doctype
))))
1396 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1398 (defun org-html-close-tag (tag attr info
)
1399 (concat "<" tag
" " attr
1400 (if (org-html-xhtml-p info
) " />" ">")))
1402 (defun org-html-doctype (info)
1403 "Return correct html doctype tag from `org-html-doctype-alist',
1404 or the literal value of :html-doctype from INFO if :html-doctype
1405 is not found in the alist.
1406 INFO is a plist used as a communication channel."
1407 (let ((dt (plist-get info
:html-doctype
)))
1408 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1410 (defun org-html--make-attribute-string (attributes)
1411 "Return a list of attributes, as a string.
1412 ATTRIBUTES is a plist where values are either strings or nil. An
1413 attributes with a nil value will be omitted from the result."
1415 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1416 (cond ((null item
) (pop output
))
1417 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1418 (t (let ((key (car output
))
1419 (value (replace-regexp-in-string
1420 "\"" """ (org-html-encode-plain-text item
))))
1421 (setcar output
(format "%s=\"%s\"" key value
))))))))
1423 (defun org-html--wrap-image (contents info
&optional caption label
)
1424 "Wrap CONTENTS string within an appropriate environment for images.
1425 INFO is a plist used as a communication channel. When optional
1426 arguments CAPTION and LABEL are given, use them for caption and
1428 (let ((html5-fancy (and (org-html-html5-p info
)
1429 (plist-get info
:html-html5-fancy
))))
1430 (format (if html5-fancy
"\n<figure%s>%s%s\n</figure>"
1431 "\n<div%s class=\"figure\">%s%s\n</div>")
1433 (if (not (org-string-nw-p label
)) ""
1434 (format " id=\"%s\"" (org-export-solidify-link-text label
)))
1436 (format "\n<p>%s</p>" contents
)
1438 (if (not (org-string-nw-p caption
)) ""
1439 (format (if html5-fancy
"\n<figcaption>%s</figcaption>"
1443 (defun org-html--format-image (source attributes info
)
1444 "Return \"img\" tag with given SOURCE and ATTRIBUTES.
1445 SOURCE is a string specifying the location of the image.
1446 ATTRIBUTES is a plist, as returned by
1447 `org-export-read-attribute'. INFO is a plist used as
1448 a communication channel."
1449 (if (string= "svg" (file-name-extension source
))
1450 (org-html--svg-image source attributes info
)
1453 (org-html--make-attribute-string
1456 :alt
(if (string-match-p "^ltxpng/" source
)
1457 (org-html-encode-plain-text
1458 (org-find-text-property-in-string 'org-latex-src source
))
1459 (file-name-nondirectory source
)))
1463 (defun org-html--svg-image (source attributes info
)
1464 "Return \"object\" appropriate for embedding svg file SOURCE
1465 with assoicated ATTRIBUTES. INFO is a plist used as a
1466 communication channel.
1468 The special attribute \"fallback\" can be used to specify a fallback
1469 image file to use if the object embedding is not supported."
1470 (let ((fallback (plist-get attributes
:fallback
))
1471 (attrs (org-html--make-attribute-string
1472 (plist-put attributes
:fallback nil
))))
1473 (format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>"
1477 "img" (format "src=\"%s\" %s" fallback attrs
) info
)
1478 "Sorry, your browser does not support SVG."))))
1480 (defun org-html--textarea-block (element)
1481 "Transcode ELEMENT into a textarea block.
1482 ELEMENT is either a src block or an example block."
1483 (let* ((code (car (org-export-unravel-code element
)))
1484 (attr (org-export-read-attribute :attr_html element
)))
1485 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1486 (or (plist-get attr
:width
) 80)
1487 (or (plist-get attr
:height
) (org-count-lines code
))
1490 (defun org-html--has-caption-p (element &optional info
)
1491 "Non-nil when ELEMENT has a caption affiliated keyword.
1492 INFO is a plist used as a communication channel. This function
1493 is meant to be used as a predicate for `org-export-get-ordinal' or
1494 a value to `org-html-standalone-image-predicate'."
1495 (org-element-property :caption element
))
1499 (defun org-html-htmlize-region-for-paste (beg end
)
1500 "Convert the region between BEG and END to HTML, using htmlize.el.
1501 This is much like `htmlize-region-for-paste', only that it uses
1502 the settings define in the org-... variables."
1503 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1504 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1505 (htmlbuf (htmlize-region beg end
)))
1507 (with-current-buffer htmlbuf
1508 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1509 (plist-get htmlize-buffer-places
'content-end
)))
1510 (kill-buffer htmlbuf
))))
1513 (defun org-html-htmlize-generate-css ()
1514 "Create the CSS for all font definitions in the current Emacs session.
1515 Use this to create face definitions in your CSS style file that can then
1516 be used by code snippets transformed by htmlize.
1517 This command just produces a buffer that contains class definitions for all
1518 faces used in the current Emacs session. You can copy and paste the ones you
1519 need into your CSS file.
1521 If you then set `org-html-htmlize-output-type' to `css', calls
1522 to the function `org-html-htmlize-region-for-paste' will
1523 produce code that uses these same face definitions."
1526 (and (get-buffer "*html*") (kill-buffer "*html*"))
1528 (let ((fl (face-list))
1529 (htmlize-css-name-prefix "org-")
1530 (htmlize-output-type 'css
)
1532 (while (setq f
(pop fl
)
1533 i
(and f
(face-attribute f
:inherit
)))
1534 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1535 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1536 (htmlize-region (point-min) (point-max))))
1537 (org-pop-to-buffer-same-window "*html*")
1538 (goto-char (point-min))
1539 (if (re-search-forward "<style" nil t
)
1540 (delete-region (point-min) (match-beginning 0)))
1541 (if (re-search-forward "</style>" nil t
)
1542 (delete-region (1+ (match-end 0)) (point-max)))
1543 (beginning-of-line 1)
1544 (if (looking-at " +") (replace-match ""))
1545 (goto-char (point-min)))
1547 (defun org-html--make-string (n string
)
1548 "Build a string by concatenating N times STRING."
1549 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1551 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1552 "Turn todo keyword KWD into a valid class name.
1553 Replaces invalid characters with \"_\"."
1555 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1556 (setq kwd
(replace-match "_" t t kwd
))))
1559 (defun org-html-footnote-section (info)
1560 "Format the footnote section.
1561 INFO is a plist used as a communication channel."
1562 (let* ((fn-alist (org-export-collect-footnote-definitions info
))
1564 (loop for
(n type raw
) in fn-alist collect
1565 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1566 (org-trim (org-export-data raw info
))
1568 (org-trim (org-export-data raw info
))))))))
1571 (plist-get info
:html-footnotes-section
)
1572 (org-html--translate "Footnotes" info
)
1577 (let ((n (car fn
)) (def (cdr fn
)))
1579 "<div class=\"footdef\">%s %s</div>\n"
1581 (plist-get info
:html-footnote-format
)
1585 (format " class=\"footnum\" href=\"#fnr.%d\"" n
)
1594 (defun org-html--build-meta-info (info)
1595 "Return meta tags for exported document.
1596 INFO is a plist used as a communication channel."
1597 (let ((protect-string
1599 (replace-regexp-in-string
1600 "\"" """ (org-html-encode-plain-text str
))))
1601 (title (org-export-data (plist-get info
:title
) info
))
1602 (author (and (plist-get info
:with-author
)
1603 (let ((auth (plist-get info
:author
)))
1605 ;; Return raw Org syntax, skipping non
1606 ;; exportable objects.
1607 (org-element-interpret-data
1608 (org-element-map auth
1609 (cons 'plain-text org-element-all-objects
)
1610 'identity info
))))))
1611 (description (plist-get info
:description
))
1612 (keywords (plist-get info
:keywords
))
1613 (charset (or (and org-html-coding-system
1614 (fboundp 'coding-system-get
)
1615 (coding-system-get org-html-coding-system
1619 (format "<title>%s</title>\n" title
)
1620 (when (plist-get info
:time-stamp-file
)
1623 (plist-get info
:html-metadata-timestamp-format
)
1626 (if (org-html-html5-p info
)
1627 (org-html-close-tag "meta" " charset=\"%s\"" info
)
1629 "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1632 (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info
)
1634 (and (org-string-nw-p author
)
1636 (org-html-close-tag "meta"
1637 (format " name=\"author\" content=\"%s\""
1638 (funcall protect-string author
))
1641 (and (org-string-nw-p description
)
1643 (org-html-close-tag "meta"
1644 (format " name=\"description\" content=\"%s\"\n"
1645 (funcall protect-string description
))
1648 (and (org-string-nw-p keywords
)
1650 (org-html-close-tag "meta"
1651 (format " name=\"keywords\" content=\"%s\""
1652 (funcall protect-string keywords
))
1656 (defun org-html--build-head (info)
1657 "Return information for the <head>..</head> of the HTML output.
1658 INFO is a plist used as a communication channel."
1659 (org-element-normalize-string
1661 (when (plist-get info
:html-head-include-default-style
)
1662 (org-element-normalize-string org-html-style-default
))
1663 (org-element-normalize-string (plist-get info
:html-head
))
1664 (org-element-normalize-string (plist-get info
:html-head-extra
))
1665 (when (and (plist-get info
:html-htmlized-css-url
)
1666 (eq org-html-htmlize-output-type
'css
))
1667 (org-html-close-tag "link"
1668 (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1669 (plist-get info
:html-htmlized-css-url
))
1671 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1673 (defun org-html--build-mathjax-config (info)
1674 "Insert the user setup into the mathjax template.
1675 INFO is a plist used as a communication channel."
1676 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1677 (org-element-map (plist-get info
:parse-tree
)
1678 '(latex-fragment latex-environment
) 'identity info t
))
1679 (let ((template (plist-get info
:html-mathjax-template
))
1680 (options (plist-get info
:html-mathjax-options
))
1681 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1682 name val
(yes " ") (no "// ") x
)
1685 (setq name
(car e
) val
(nth 1 e
))
1686 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1687 (setq val
(car (read-from-string
1688 (substring in-buffer
(match-end 0))))))
1689 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1690 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1691 (setq template
(replace-match val t t template
))))
1693 (setq val
(nth 1 (assq 'mathml options
)))
1694 (if (string-match (concat "\\<mathml:") in-buffer
)
1695 (setq val
(car (read-from-string
1696 (substring in-buffer
(match-end 0))))))
1697 ;; Exchange prefixes depending on mathml setting.
1698 (if (not val
) (setq x yes yes no no x
))
1699 ;; Replace cookies to turn on or off the config/jax lines.
1700 (if (string-match ":MMLYES:" template
)
1701 (setq template
(replace-match yes t t template
)))
1702 (if (string-match ":MMLNO:" template
)
1703 (setq template
(replace-match no t t template
)))
1704 ;; Return the modified template.
1705 (org-element-normalize-string template
))))
1707 (defun org-html-format-spec (info)
1708 "Return format specification for elements that can be
1709 used in the preamble or postamble."
1710 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1711 (?d .
,(org-export-data (org-export-get-date info
) info
))
1712 (?T .
,(format-time-string
1713 (plist-get info
:html-metadata-timestamp-format
)))
1714 (?a .
,(org-export-data (plist-get info
:author
) info
))
1717 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1718 (split-string (plist-get info
:email
) ",+ *")
1720 (?c .
,(plist-get info
:creator
))
1721 (?C .
,(let ((file (plist-get info
:input-file
)))
1723 (plist-get info
:html-metadata-timestamp-format
)
1724 (if file
(nth 5 (file-attributes file
)) (current-time)))))
1725 (?v .
,(or (plist-get info
:html-validation-link
) ""))))
1727 (defun org-html--build-pre/postamble
(type info
)
1728 "Return document preamble or postamble as a string, or nil.
1729 TYPE is either 'preamble or 'postamble, INFO is a plist used as a
1730 communication channel."
1731 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1732 (spec (org-html-format-spec info
)))
1734 (let ((section-contents
1735 (if (functionp section
) (funcall section info
)
1737 ((stringp section
) (format-spec section spec
))
1739 (let ((date (cdr (assq ?d spec
)))
1740 (author (cdr (assq ?a spec
)))
1741 (email (cdr (assq ?e spec
)))
1742 (creator (cdr (assq ?c spec
)))
1743 (timestamp (cdr (assq ?T spec
)))
1744 (validation-link (cdr (assq ?v spec
))))
1746 (when (and (plist-get info
:with-date
)
1747 (org-string-nw-p date
))
1748 (format "<p class=\"date\">%s: %s</p>\n"
1749 (org-html--translate "Date" info
)
1751 (when (and (plist-get info
:with-author
)
1752 (org-string-nw-p author
))
1753 (format "<p class=\"author\">%s: %s</p>\n"
1754 (org-html--translate "Author" info
)
1756 (when (and (plist-get info
:with-email
)
1757 (org-string-nw-p email
))
1758 (format "<p class=\"email\">%s: %s</p>\n"
1759 (org-html--translate "Email" info
)
1761 (when (plist-get info
:time-stamp-file
)
1763 "<p class=\"date\">%s: %s</p>\n"
1764 (org-html--translate "Created" info
)
1766 (plist-get info
:html-metadata-timestamp-format
))))
1767 (when (plist-get info
:with-creator
)
1768 (format "<p class=\"creator\">%s</p>\n" creator
))
1769 (format "<p class=\"validation\">%s</p>\n"
1773 (plist-get info
:language
)
1775 (format "org-html-%s-format" type
)))))
1780 (intern (format "org-html-%s-format" type
))))))
1782 (let ((div (assq type
(plist-get info
:html-divs
))))
1783 (when (org-string-nw-p section-contents
)
1785 (format "<%s id=\"%s\" class=\"%s\">\n"
1788 org-html--pre
/postamble-class
)
1789 (org-element-normalize-string section-contents
)
1790 (format "</%s>\n" (nth 1 div
)))))))))
1792 (defun org-html-inner-template (contents info
)
1793 "Return body of document string after HTML conversion.
1794 CONTENTS is the transcoded contents string. INFO is a plist
1795 holding export options."
1797 ;; Table of contents.
1798 (let ((depth (plist-get info
:with-toc
)))
1799 (when depth
(org-html-toc depth info
)))
1800 ;; Document contents.
1802 ;; Footnotes section.
1803 (org-html-footnote-section info
)))
1805 (defun org-html-template (contents info
)
1806 "Return complete document string after HTML conversion.
1807 CONTENTS is the transcoded contents string. INFO is a plist
1808 holding export options."
1810 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1811 (let* ((xml-declaration (plist-get info
:html-xml-declaration
))
1812 (decl (or (and (stringp xml-declaration
) xml-declaration
)
1813 (cdr (assoc (plist-get info
:html-extension
)
1815 (cdr (assoc "html" xml-declaration
))
1817 (when (not (or (not decl
) (string= "" decl
)))
1820 (or (and org-html-coding-system
1821 (fboundp 'coding-system-get
)
1822 (coding-system-get org-html-coding-system
'mime-charset
))
1824 (org-html-doctype info
)
1827 (when (org-html-xhtml-p info
)
1829 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1830 (plist-get info
:language
) (plist-get info
:language
)))
1833 (org-html--build-meta-info info
)
1834 (org-html--build-head info
)
1835 (org-html--build-mathjax-config info
)
1838 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1839 (link-home (org-trim (plist-get info
:html-link-home
))))
1840 (unless (and (string= link-up
"") (string= link-home
""))
1841 (format (plist-get info
:html-home
/up-format
)
1842 (or link-up link-home
)
1843 (or link-home link-up
))))
1845 (org-html--build-pre/postamble
'preamble info
)
1846 ;; Document contents.
1847 (let ((div (assq 'content
(plist-get info
:html-divs
))))
1848 (format "<%s id=\"%s\">\n" (nth 1 div
) (nth 2 div
)))
1850 (when (plist-get info
:with-title
)
1851 (let ((title (plist-get info
:title
)))
1852 (format "<h1 class=\"title\">%s</h1>\n"
1853 (org-export-data (or title
"") info
))))
1855 (format "</%s>\n" (nth 1 (assq 'content
(plist-get info
:html-divs
))))
1857 (org-html--build-pre/postamble
'postamble info
)
1858 ;; Closing document.
1859 "</body>\n</html>"))
1861 (defun org-html--translate (s info
)
1862 "Translate string S according to specified language.
1863 INFO is a plist used as a communication channel."
1864 (org-export-translate s
:html info
))
1868 (defun org-html--anchor (id desc attributes info
)
1869 "Format a HTML anchor."
1870 (let* ((name (and (plist-get info
:html-allow-name-attribute-in-anchors
) id
))
1871 (attributes (concat (and id
(format " id=\"%s\"" id
))
1872 (and name
(format " name=\"%s\"" name
))
1874 (format "<a%s>%s</a>" attributes
(or desc
""))))
1878 (defun org-html--todo (todo info
)
1879 "Format TODO keywords into HTML."
1881 (format "<span class=\"%s %s%s\">%s</span>"
1882 (if (member todo org-done-keywords
) "done" "todo")
1883 (plist-get info
:html-todo-kwd-class-prefix
)
1884 (org-html-fix-class-name todo
)
1889 (defun org-html--priority (priority info
)
1890 "Format a priority into HTML.
1891 PRIORITY is the character code of the priority or nil. INFO is
1892 a plist containing export options."
1893 (and priority
(format "<span class=\"priority\">[%c]</span>" priority
)))
1897 (defun org-html--tags (tags info
)
1898 "Format TAGS into HTML.
1899 INFO is a plist containing export options."
1901 (format "<span class=\"tag\">%s</span>"
1904 (format "<span class=\"%s\">%s</span>"
1905 (concat (plist-get info
:html-tag-class-prefix
)
1906 (org-html-fix-class-name tag
))
1912 (defun org-html-fontify-code (code lang
)
1913 "Color CODE with htmlize library.
1914 CODE is a string representing the source code to colorize. LANG
1915 is the language used for CODE, as a string, or nil."
1918 ;; Case 1: No lang. Possibly an example block.
1920 ;; Simple transcoding.
1921 (org-html-encode-plain-text code
))
1922 ;; Case 2: No htmlize or an inferior version of htmlize
1923 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1925 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1926 ;; Simple transcoding.
1927 (org-html-encode-plain-text code
))
1928 ;; Case 3: plain text explicitly set
1929 ((not org-html-htmlize-output-type
)
1930 ;; Simple transcoding.
1931 (org-html-encode-plain-text code
))
1934 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1935 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1937 ;; Case 1: Language is not associated with any Emacs mode
1938 ((not (functionp lang-mode
))
1939 ;; Simple transcoding.
1940 (org-html-encode-plain-text code
))
1941 ;; Case 2: Default. Fontify code.
1944 (setq code
(with-temp-buffer
1945 ;; Switch to language-specific mode.
1947 ;; Disable fci-mode if present
1948 (when (and (fboundp 'fci-mode
)
1949 (require 'fill-column-indicator nil
'noerror
))
1954 ;; Remove formatting on newline characters.
1956 (let ((beg (point-min))
1959 (while (progn (end-of-line) (< (point) end
))
1960 (put-text-property (point) (1+ (point)) 'face nil
)
1963 (set-buffer-modified-p nil
)
1965 (org-html-htmlize-region-for-paste
1966 (point-min) (point-max))))
1967 ;; Strip any enclosing <pre></pre> tags.
1968 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
1969 (end (and beg
(string-match "</pre>\\'" code
))))
1970 (if (and beg end
) (substring code beg end
) code
)))))))))
1972 (defun org-html-do-format-code
1973 (code &optional lang refs retain-labels num-start
)
1974 "Format CODE string as source code.
1975 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1976 respectively, the language of the source code, as a string, an
1977 alist between line numbers and references (as returned by
1978 `org-export-unravel-code'), a boolean specifying if labels should
1979 appear in the source code, and the number associated to the first
1981 (let* ((code-lines (org-split-string code
"\n"))
1982 (code-length (length code-lines
))
1986 (length (number-to-string (+ code-length num-start
))))))
1987 (code (org-html-fontify-code code lang
)))
1988 (org-export-format-code
1990 (lambda (loc line-num ref
)
1993 ;; Add line number, if needed.
1995 (format "<span class=\"linenr\">%s</span>"
1996 (format num-fmt line-num
)))
1997 ;; Transcoded src line.
1999 ;; Add label, if needed.
2000 (when (and ref retain-labels
) (format " (%s)" ref
))))
2001 ;; Mark transcoded line as an anchor, if needed.
2003 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
2007 (defun org-html-format-code (element info
)
2008 "Format contents of ELEMENT as source code.
2009 ELEMENT is either an example block or a src block. INFO is
2010 a plist used as a communication channel."
2011 (let* ((lang (org-element-property :language element
))
2012 ;; Extract code and references.
2013 (code-info (org-export-unravel-code element
))
2014 (code (car code-info
))
2015 (refs (cdr code-info
))
2016 ;; Does the src block contain labels?
2017 (retain-labels (org-element-property :retain-labels element
))
2018 ;; Does it have line numbers?
2019 (num-start (case (org-element-property :number-lines element
)
2020 (continued (org-export-get-loc element info
))
2022 (org-html-do-format-code code lang refs retain-labels num-start
)))
2025 ;;; Tables of Contents
2027 (defun org-html-toc (depth info
&optional scope
)
2028 "Build a table of contents.
2029 DEPTH is an integer specifying the depth of the table. INFO is
2030 a plist used as a communication channel. Optional argument SCOPE
2031 is an element defining the scope of the table. Return the table
2032 of contents as a string, or nil if it is empty."
2034 (mapcar (lambda (headline)
2035 (cons (org-html--format-toc-headline headline info
)
2036 (org-export-get-relative-level headline info
)))
2037 (org-export-collect-headlines info depth scope
))))
2039 (let ((toc (concat "<div id=\"text-table-of-contents\">"
2040 (org-html--toc-text toc-entries
)
2043 (let ((outer-tag (if (and (org-html-html5-p info
)
2044 (plist-get info
:html-html5-fancy
))
2047 (concat (format "<%s id=\"table-of-contents\">\n" outer-tag
)
2048 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2049 (format "<h%d>%s</h%d>\n"
2051 (org-html--translate "Table of Contents" info
)
2054 (format "</%s>\n" outer-tag
))))))))
2056 (defun org-html--toc-text (toc-entries)
2057 "Return innards of a table of contents, as a string.
2058 TOC-ENTRIES is an alist where key is an entry title, as a string,
2059 and value is its relative level, as an integer."
2060 (let* ((prev-level (1- (cdar toc-entries
)))
2061 (start-level prev-level
))
2065 (let ((headline (car entry
))
2066 (level (cdr entry
)))
2068 (let* ((cnt (- level prev-level
))
2069 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
2071 (setq prev-level level
)
2073 (org-html--make-string
2074 times
(cond ((> cnt
0) "\n<ul>\n<li>")
2075 ((< cnt
0) "</li>\n</ul>\n")))
2076 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
2079 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
2081 (defun org-html--format-toc-headline (headline info
)
2082 "Return an appropriate table of contents entry for HEADLINE.
2083 INFO is a plist used as a communication channel."
2084 (let* ((headline-number (org-export-get-headline-number headline info
))
2085 (todo (and (plist-get info
:with-todo-keywords
)
2086 (let ((todo (org-element-property :todo-keyword headline
)))
2087 (and todo
(org-export-data todo info
)))))
2088 (todo-type (and todo
(org-element-property :todo-type headline
)))
2089 (priority (and (plist-get info
:with-priority
)
2090 (org-element-property :priority headline
)))
2091 (text (org-export-data-with-backend
2092 (org-export-get-alt-title headline info
)
2093 ;; Create an anonymous back-end that will ignore any
2094 ;; footnote-reference, link, radio-target and target
2095 ;; in table of contents.
2096 (org-export-create-backend
2098 :transcoders
'((footnote-reference . ignore
)
2099 (link .
(lambda (object c i
) c
))
2100 (radio-target .
(lambda (object c i
) c
))
2103 (tags (and (eq (plist-get info
:with-tags
) t
)
2104 (org-export-get-tags headline info
))))
2105 (format "<a href=\"#%s\">%s</a>"
2107 (org-export-solidify-link-text
2108 (or (org-element-property :CUSTOM_ID headline
)
2109 (org-export-get-headline-id headline info
)))
2112 (and (not (org-export-low-level-p headline info
))
2113 (org-export-numbered-headline-p headline info
)
2114 (concat (mapconcat #'number-to-string headline-number
".")
2116 (apply (plist-get info
:html-format-headline-function
)
2117 todo todo-type priority text tags
:section-number nil
)))))
2119 (defun org-html-list-of-listings (info)
2120 "Build a list of listings.
2121 INFO is a plist used as a communication channel. Return the list
2122 of listings as a string, or nil if it is empty."
2123 (let ((lol-entries (org-export-collect-listings info
)))
2125 (concat "<div id=\"list-of-listings\">\n"
2126 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2127 (format "<h%d>%s</h%d>\n"
2129 (org-html--translate "List of Listings" info
)
2131 "<div id=\"text-list-of-listings\">\n<ul>\n"
2133 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2134 (org-html--translate "Listing %d:" info
))))
2137 (let ((label (org-element-property :name entry
))
2140 (or (org-export-get-caption entry t
)
2141 (org-export-get-caption entry
))
2146 (concat (format initial-fmt
(incf count
)) " " title
)
2147 (format "<a href=\"#%s\">%s %s</a>"
2148 (org-export-solidify-link-text label
)
2149 (format initial-fmt
(incf count
))
2153 "\n</ul>\n</div>\n</div>"))))
2155 (defun org-html-list-of-tables (info)
2156 "Build a list of tables.
2157 INFO is a plist used as a communication channel. Return the list
2158 of tables as a string, or nil if it is empty."
2159 (let ((lol-entries (org-export-collect-tables info
)))
2161 (concat "<div id=\"list-of-tables\">\n"
2162 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2163 (format "<h%d>%s</h%d>\n"
2165 (org-html--translate "List of Tables" info
)
2167 "<div id=\"text-list-of-tables\">\n<ul>\n"
2169 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2170 (org-html--translate "Table %d:" info
))))
2173 (let ((label (org-element-property :name entry
))
2176 (or (org-export-get-caption entry t
)
2177 (org-export-get-caption entry
))
2182 (concat (format initial-fmt
(incf count
)) " " title
)
2183 (format "<a href=\"#%s\">%s %s</a>"
2184 (org-export-solidify-link-text label
)
2185 (format initial-fmt
(incf count
))
2189 "\n</ul>\n</div>\n</div>"))))
2192 ;;; Transcode Functions
2196 (defun org-html-bold (bold contents info
)
2197 "Transcode BOLD from Org to HTML.
2198 CONTENTS is the text with bold markup. INFO is a plist holding
2199 contextual information."
2200 (format (or (cdr (assq 'bold
(plist-get info
:html-text-markup-alist
))) "%s")
2205 (defun org-html-center-block (center-block contents info
)
2206 "Transcode a CENTER-BLOCK element from Org to HTML.
2207 CONTENTS holds the contents of the block. INFO is a plist
2208 holding contextual information."
2209 (format "<div class=\"center\">\n%s</div>" contents
))
2213 (defun org-html-clock (clock contents info
)
2214 "Transcode a CLOCK element from Org to HTML.
2215 CONTENTS is nil. INFO is a plist used as a communication
2218 <span class=\"timestamp-wrapper\">
2219 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2223 (org-timestamp-translate (org-element-property :value clock
))
2224 (let ((time (org-element-property :duration clock
)))
2225 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2229 (defun org-html-code (code contents info
)
2230 "Transcode CODE from Org to HTML.
2231 CONTENTS is nil. INFO is a plist holding contextual
2233 (format (or (cdr (assq 'code
(plist-get info
:html-text-markup-alist
))) "%s")
2234 (org-html-encode-plain-text (org-element-property :value code
))))
2238 (defun org-html-drawer (drawer contents info
)
2239 "Transcode a DRAWER element from Org to HTML.
2240 CONTENTS holds the contents of the block. INFO is a plist
2241 holding contextual information."
2242 (funcall (plist-get info
:html-format-drawer-function
)
2243 (org-element-property :drawer-name drawer
)
2248 (defun org-html-dynamic-block (dynamic-block contents info
)
2249 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2250 CONTENTS holds the contents of the block. INFO is a plist
2251 holding contextual information. See `org-export-data'."
2256 (defun org-html-entity (entity contents info
)
2257 "Transcode an ENTITY object from Org to HTML.
2258 CONTENTS are the definition itself. INFO is a plist holding
2259 contextual information."
2260 (org-element-property :html entity
))
2264 (defun org-html-example-block (example-block contents info
)
2265 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2266 CONTENTS is nil. INFO is a plist holding contextual
2268 (if (org-export-read-attribute :attr_html example-block
:textarea
)
2269 (org-html--textarea-block example-block
)
2270 (format "<pre class=\"example\">\n%s</pre>"
2271 (org-html-format-code example-block info
))))
2275 (defun org-html-export-snippet (export-snippet contents info
)
2276 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2277 CONTENTS is nil. INFO is a plist holding contextual
2279 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2280 (org-element-property :value export-snippet
)))
2284 (defun org-html-export-block (export-block contents info
)
2285 "Transcode a EXPORT-BLOCK element from Org to HTML.
2286 CONTENTS is nil. INFO is a plist holding contextual information."
2287 (when (string= (org-element-property :type export-block
) "HTML")
2288 (org-remove-indentation (org-element-property :value export-block
))))
2292 (defun org-html-fixed-width (fixed-width contents info
)
2293 "Transcode a FIXED-WIDTH element from Org to HTML.
2294 CONTENTS is nil. INFO is a plist holding contextual information."
2295 (format "<pre class=\"example\">\n%s</pre>"
2296 (org-html-do-format-code
2297 (org-remove-indentation
2298 (org-element-property :value fixed-width
)))))
2300 ;;;; Footnote Reference
2302 (defun org-html-footnote-reference (footnote-reference contents info
)
2303 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2304 CONTENTS is nil. INFO is a plist holding contextual information."
2306 ;; Insert separator between two footnotes in a row.
2307 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2308 (when (eq (org-element-type prev
) 'footnote-reference
)
2309 (plist-get info
:html-footnote-separator
)))
2310 (let* ((n (org-export-get-footnote-number footnote-reference info
))
2311 (id (format "fnr.%d%s"
2313 (if (org-export-footnote-first-reference-p
2314 footnote-reference info
)
2318 (plist-get info
:html-footnote-format
)
2320 id n
(format " class=\"footref\" href=\"#fn.%d\"" n
) info
)))))
2324 (defun org-html-headline (headline contents info
)
2325 "Transcode a HEADLINE element from Org to HTML.
2326 CONTENTS holds the contents of the headline. INFO is a plist
2327 holding contextual information."
2328 (unless (org-element-property :footnote-section-p headline
)
2329 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2330 (numbers (org-export-get-headline-number headline info
))
2331 (section-number (and numbers
2332 (mapconcat #'number-to-string numbers
"-")))
2333 (level (+ (org-export-get-relative-level headline info
)
2334 (1- (plist-get info
:html-toplevel-hlevel
))))
2335 (todo (and (plist-get info
:with-todo-keywords
)
2336 (let ((todo (org-element-property :todo-keyword headline
)))
2337 (and todo
(org-export-data todo info
)))))
2338 (todo-type (and todo
(org-element-property :todo-type headline
)))
2339 (priority (and (plist-get info
:with-priority
)
2340 (org-element-property :priority headline
)))
2341 (text (org-export-data (org-element-property :title headline
) info
))
2342 (tags (and (plist-get info
:with-tags
)
2343 (org-export-get-tags headline info
)))
2344 (full-text (funcall (plist-get info
:html-format-headline-function
)
2345 todo todo-type priority text tags info
))
2346 (contents (or contents
""))
2348 (list (org-element-property :CUSTOM_ID headline
)
2349 (org-export-get-headline-id headline info
)
2350 (org-element-property :ID headline
))))
2351 (preferred-id (car ids
))
2352 (extra-ids (mapconcat
2355 (org-export-solidify-link-text
2356 (if (org-uuidgen-p id
) (concat "ID-" id
) id
))
2359 (if (org-export-low-level-p headline info
)
2360 ;; This is a deep sub-tree: export it as a list item.
2361 (let* ((type (if numberedp
'ordered
'unordered
))
2363 (org-html-format-list-item
2364 contents type nil info nil
2365 (concat (org-html--anchor preferred-id nil nil info
)
2368 (concat (and (org-export-first-sibling-p headline info
)
2369 (org-html-begin-plain-list type
))
2371 (and (org-export-last-sibling-p headline info
)
2372 (org-html-end-plain-list type
))))
2373 (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2374 (first-content (car (org-element-contents headline
))))
2375 ;; Standard headline. Export it as a section.
2376 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2377 (org-html--container headline info
)
2378 (format "outline-container-%s"
2379 (or (org-element-property :CUSTOM_ID headline
)
2380 (org-export-get-headline-id headline info
)))
2381 (concat (format "outline-%d" level
)
2382 (and extra-class
" ")
2384 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2391 "<span class=\"section-number-%d\">%s</span> "
2393 (mapconcat #'number-to-string numbers
".")))
2396 ;; When there is no section, pretend there is an
2397 ;; empty one to get the correct <div
2398 ;; class="outline-...> which is needed by
2400 (if (eq (org-element-type first-content
) 'section
) contents
2401 (concat (org-html-section first-content
"" info
) contents
))
2402 (org-html--container headline info
)))))))
2404 (defun org-html-format-headline-default-function
2405 (todo todo-type priority text tags info
)
2406 "Default format function for a headline.
2407 See `org-html-format-headline-function' for details."
2408 (let ((todo (org-html--todo todo info
))
2409 (priority (org-html--priority priority info
))
2410 (tags (org-html--tags tags info
)))
2411 (concat todo
(and todo
" ")
2412 priority
(and priority
" ")
2414 (and tags
"   ") tags
)))
2416 (defun org-html--container (headline info
)
2417 (or (org-element-property :HTML_CONTAINER headline
)
2418 (if (= 1 (org-export-get-relative-level headline info
))
2419 (plist-get info
:html-container
)
2422 ;;;; Horizontal Rule
2424 (defun org-html-horizontal-rule (horizontal-rule contents info
)
2425 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2426 CONTENTS is nil. INFO is a plist holding contextual information."
2427 (org-html-close-tag "hr" nil info
))
2429 ;;;; Inline Src Block
2431 (defun org-html-inline-src-block (inline-src-block contents info
)
2432 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2433 CONTENTS holds the contents of the item. INFO is a plist holding
2434 contextual information."
2435 (let* ((org-lang (org-element-property :language inline-src-block
))
2436 (code (org-element-property :value inline-src-block
)))
2437 (let ((lang (org-element-property :language inline-src-block
))
2438 (code (org-html-format-code inline-src-block info
))
2439 (label (let ((lbl (org-element-property :name inline-src-block
)))
2441 (format " id=\"%s\""
2442 (org-export-solidify-link-text lbl
))))))
2443 (format "<code class=\"src src-%s\"%s>%s</code>" lang label code
))))
2447 (defun org-html-inlinetask (inlinetask contents info
)
2448 "Transcode an INLINETASK element from Org to HTML.
2449 CONTENTS holds the contents of the block. INFO is a plist
2450 holding contextual information."
2451 (let* ((todo (and (plist-get info
:with-todo-keywords
)
2452 (let ((todo (org-element-property :todo-keyword inlinetask
)))
2453 (and todo
(org-export-data todo info
)))))
2454 (todo-type (and todo
(org-element-property :todo-type inlinetask
)))
2455 (priority (and (plist-get info
:with-priority
)
2456 (org-element-property :priority inlinetask
)))
2457 (text (org-export-data (org-element-property :title inlinetask
) info
))
2458 (tags (and (plist-get info
:with-tags
)
2459 (org-export-get-tags inlinetask info
))))
2460 (funcall (plist-get info
:html-format-inlinetask-function
)
2461 todo todo-type priority text tags contents info
)))
2463 (defun org-html-format-inlinetask-default-function
2464 (todo todo-type priority text tags contents info
)
2465 "Default format function for a inlinetasks.
2466 See `org-html-format-inlinetask-function' for details."
2467 (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2468 (org-html-format-headline-default-function
2469 todo todo-type priority text tags info
)
2470 (org-html-close-tag "br" nil info
)
2475 (defun org-html-italic (italic contents info
)
2476 "Transcode ITALIC from Org to HTML.
2477 CONTENTS is the text with italic markup. INFO is a plist holding
2478 contextual information."
2480 (or (cdr (assq 'italic
(plist-get info
:html-text-markup-alist
))) "%s")
2485 (defun org-html-checkbox (checkbox info
)
2486 "Format CHECKBOX into HTML.
2487 INFO is a plist holding contextual information. See
2488 `org-html-checkbox-type' for customization options."
2490 (cdr (assq (plist-get info
:html-checkbox-type
)
2491 org-html-checkbox-types
)))))
2493 (defun org-html-format-list-item (contents type checkbox info
2494 &optional term-counter-id
2496 "Format a list item into HTML."
2497 (let ((class (if checkbox
2498 (format " class=\"%s\""
2499 (symbol-name checkbox
)) ""))
2500 (checkbox (concat (org-html-checkbox checkbox info
)
2501 (and checkbox
" ")))
2502 (br (org-html-close-tag "br" nil info
)))
2506 (let* ((counter term-counter-id
)
2507 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2509 (format "<li%s%s>" class extra
)
2510 (when headline
(concat headline br
)))))
2512 (let* ((id term-counter-id
)
2513 (extra (if id
(format " id=\"%s\"" id
) "")))
2515 (format "<li%s%s>" class extra
)
2516 (when headline
(concat headline br
)))))
2518 (let* ((term term-counter-id
))
2519 (setq term
(or term
"(no term)"))
2520 ;; Check-boxes in descriptive lists are associated to tag.
2521 (concat (format "<dt%s>%s</dt>"
2522 class
(concat checkbox term
))
2524 (unless (eq type
'descriptive
) checkbox
)
2525 (and contents
(org-trim contents
))
2529 (descriptive "</dd>")))))
2531 (defun org-html-item (item contents info
)
2532 "Transcode an ITEM element from Org to HTML.
2533 CONTENTS holds the contents of the item. INFO is a plist holding
2534 contextual information."
2535 (let* ((plain-list (org-export-get-parent item
))
2536 (type (org-element-property :type plain-list
))
2537 (counter (org-element-property :counter item
))
2538 (checkbox (org-element-property :checkbox item
))
2539 (tag (let ((tag (org-element-property :tag item
)))
2540 (and tag
(org-export-data tag info
)))))
2541 (org-html-format-list-item
2542 contents type checkbox info
(or tag counter
))))
2546 (defun org-html-keyword (keyword contents info
)
2547 "Transcode a KEYWORD element from Org to HTML.
2548 CONTENTS is nil. INFO is a plist holding contextual information."
2549 (let ((key (org-element-property :key keyword
))
2550 (value (org-element-property :value keyword
)))
2552 ((string= key
"HTML") value
)
2553 ((string= key
"TOC")
2554 (let ((case-fold-search t
))
2556 ((string-match "\\<headlines\\>" value
)
2557 (let ((depth (and (string-match "\\<[0-9]+\\>" value
)
2558 (string-to-number (match-string 0 value
))))
2559 (localp (org-string-match-p "\\<local\\>" value
)))
2560 (org-html-toc depth info
(and localp keyword
))))
2561 ((string= "listings" value
) (org-html-list-of-listings info
))
2562 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2564 ;;;; Latex Environment
2566 (defun org-html-format-latex (latex-frag processing-type info
)
2567 "Format a LaTeX fragment LATEX-FRAG into HTML.
2568 PROCESSING-TYPE designates the tool used for conversion. It is
2569 a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil
2570 and t. See `org-html-with-latex' for more information. INFO is
2571 a plist containing export properties."
2572 (let ((cache-relpath "") (cache-dir ""))
2573 (unless (eq processing-type
'mathjax
)
2574 (let ((bfn (or (buffer-file-name)
2576 (expand-file-name "latex" temporary-file-directory
))))
2578 (let ((header (plist-get info
:latex-header
)))
2581 (lambda (line) (concat "#+LATEX_HEADER: " line
))
2582 (org-split-string header
"\n")
2587 (file-name-sans-extension
2588 (file-name-nondirectory bfn
)))
2589 cache-dir
(file-name-directory bfn
))
2590 ;; Re-create LaTeX environment from original buffer in
2591 ;; temporary buffer so that dvipng/imagemagick can properly
2592 ;; turn the fragment into an image.
2593 (setq latex-frag
(concat latex-header latex-frag
))))
2596 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2597 nil processing-type
)
2600 (defun org-html-latex-environment (latex-environment contents info
)
2601 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2602 CONTENTS is nil. INFO is a plist holding contextual information."
2603 (let ((processing-type (plist-get info
:with-latex
))
2604 (latex-frag (org-remove-indentation
2605 (org-element-property :value latex-environment
)))
2606 (attributes (org-export-read-attribute :attr_html latex-environment
)))
2607 (case processing-type
2609 (org-html-format-latex latex-frag
'mathjax info
))
2610 ((dvipng imagemagick
)
2612 (org-html-format-latex latex-frag processing-type info
)))
2613 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2614 ;; Do not provide a caption or a name to be consistent with
2615 ;; `mathjax' handling.
2616 (org-html--wrap-image
2617 (org-html--format-image
2618 (match-string 1 formula-link
) attributes info
) info
))))
2623 (defun org-html-latex-fragment (latex-fragment contents info
)
2624 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2625 CONTENTS is nil. INFO is a plist holding contextual information."
2626 (let ((latex-frag (org-element-property :value latex-fragment
))
2627 (processing-type (plist-get info
:with-latex
)))
2628 (case processing-type
2630 (org-html-format-latex latex-frag
'mathjax info
))
2631 ((dvipng imagemagick
)
2633 (org-html-format-latex latex-frag processing-type info
)))
2634 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2635 (org-html--format-image (match-string 1 formula-link
) nil info
))))
2640 (defun org-html-line-break (line-break contents info
)
2641 "Transcode a LINE-BREAK object from Org to HTML.
2642 CONTENTS is nil. INFO is a plist holding contextual information."
2643 (concat (org-html-close-tag "br" nil info
) "\n"))
2647 (defun org-html-inline-image-p (link info
)
2648 "Non-nil when LINK is meant to appear as an image.
2649 INFO is a plist used as a communication channel. LINK is an
2650 inline image when it has no description and targets an image
2651 file (see `org-html-inline-image-rules' for more information), or
2652 if its description is a single link targeting an image file."
2653 (if (not (org-element-contents link
))
2654 (org-export-inline-image-p
2655 link
(plist-get info
:html-inline-image-rules
))
2657 (let ((link-count 0))
2658 (org-element-map (org-element-contents link
)
2659 (cons 'plain-text org-element-all-objects
)
2661 (case (org-element-type obj
)
2662 (plain-text (org-string-nw-p obj
))
2663 (link (if (= link-count
1) t
2665 (not (org-export-inline-image-p
2666 obj
(plist-get info
:html-inline-image-rules
)))))
2670 (defvar org-html-standalone-image-predicate
)
2671 (defun org-html-standalone-image-p (element info
)
2672 "Non-nil if ELEMENT is a standalone image.
2674 INFO is a plist holding contextual information.
2676 An element or object is a standalone image when
2678 - its type is `paragraph' and its sole content, save for white
2679 spaces, is a link that qualifies as an inline image;
2681 - its type is `link' and its containing paragraph has no other
2682 content save white spaces.
2684 Bind `org-html-standalone-image-predicate' to constrain paragraph
2685 further. For example, to check for only captioned standalone
2688 \(lambda (paragraph) (org-element-property :caption paragraph))"
2689 (let ((paragraph (case (org-element-type element
)
2691 (link (org-export-get-parent element
)))))
2692 (and (eq (org-element-type paragraph
) 'paragraph
)
2693 (or (not (fboundp 'org-html-standalone-image-predicate
))
2694 (funcall org-html-standalone-image-predicate paragraph
))
2696 (let ((link-count 0))
2697 (org-element-map (org-element-contents paragraph
)
2698 (cons 'plain-text org-element-all-objects
)
2700 (when (case (org-element-type obj
)
2701 (plain-text (org-string-nw-p obj
))
2702 (link (or (> (incf link-count
) 1)
2703 (not (org-html-inline-image-p obj info
))))
2707 (= link-count
1))))))
2709 (defun org-html-link (link desc info
)
2710 "Transcode a LINK object from Org to HTML.
2712 DESC is the description part of the link, or the empty string.
2713 INFO is a plist holding contextual information. See
2715 (let* ((home (when (plist-get info
:html-link-home
)
2716 (org-trim (plist-get info
:html-link-home
))))
2717 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2718 (link-org-files-as-html-maybe
2720 (lambda (raw-path info
)
2721 "Treat links to `file.org' as links to `file.html', if needed.
2722 See `org-html-link-org-files-as-html'."
2724 ((and (plist-get info
:html-link-org-files-as-html
)
2726 (downcase (file-name-extension raw-path
"."))))
2727 (concat (file-name-sans-extension raw-path
) "."
2728 (plist-get info
:html-extension
)))
2730 (type (org-element-property :type link
))
2731 (raw-path (org-element-property :path link
))
2732 ;; Ensure DESC really exists, or set it to nil.
2733 (desc (org-string-nw-p desc
))
2736 ((member type
'("http" "https" "ftp" "mailto"))
2737 (org-html-encode-plain-text
2738 (org-link-escape-browser
2739 (org-link-unescape (concat type
":" raw-path
)))))
2740 ((string= type
"file")
2741 ;; Treat links to ".org" files as ".html", if needed.
2743 (funcall link-org-files-as-html-maybe raw-path info
))
2744 ;; If file path is absolute, prepend it with protocol
2745 ;; component - "file:".
2747 ((file-name-absolute-p raw-path
)
2748 (setq raw-path
(concat "file:" raw-path
)))
2749 ((and home use-abs-url
)
2750 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2751 ;; Add search option, if any. A search option can be
2752 ;; relative to a custom-id or a headline title. Append
2753 ;; a hash sign to any unresolved option, as it might point
2755 (let ((option (org-element-property :search-option link
)))
2756 (cond ((not option
) raw-path
)
2757 ((eq (aref option
0) ?
#) (concat raw-path option
))
2760 (org-publish-resolve-external-fuzzy-link
2761 (org-element-property :path link
) option
)))
2763 (if (not destination
) (concat "#" option
)
2765 (mapconcat #'number-to-string
2766 destination
"-")))))))))
2768 ;; Extract attributes from parent's paragraph. HACK: Only do
2769 ;; this for the first link in parent (inner image link for
2770 ;; inline images). This is needed as long as attributes
2771 ;; cannot be set on a per link basis.
2773 (let* ((parent (org-export-get-parent-element link
))
2774 (link (let ((container (org-export-get-parent link
)))
2775 (if (and (eq (org-element-type container
) 'link
)
2776 (org-html-inline-image-p link info
))
2779 (and (eq (org-element-map parent
'link
'identity info t
) link
)
2780 (org-export-read-attribute :attr_html parent
))))
2782 (let ((attr (org-html--make-attribute-string attributes-plist
)))
2783 (if (org-string-nw-p attr
) (concat " " attr
) ""))))
2785 ;; Link type is handled by a special function.
2786 ((org-export-custom-protocol-maybe link desc info
))
2788 ((and (plist-get info
:html-inline-images
)
2789 (org-export-inline-image-p
2790 link
(plist-get info
:html-inline-image-rules
)))
2791 (org-html--format-image path attributes-plist info
))
2792 ;; Radio target: Transcode target's contents and use them as
2793 ;; link's description.
2794 ((string= type
"radio")
2795 (let ((destination (org-export-resolve-radio-link link info
)))
2796 (if (not destination
) desc
2797 (format "<a href=\"#%s\"%s>%s</a>"
2798 (org-export-solidify-link-text
2799 (org-element-property :value destination
))
2801 ;; Links pointing to a headline: Find destination and build
2802 ;; appropriate referencing command.
2803 ((member type
'("custom-id" "fuzzy" "id"))
2804 (let ((destination (if (string= type
"fuzzy")
2805 (org-export-resolve-fuzzy-link link info
)
2806 (org-export-resolve-id-link link info
))))
2807 (case (org-element-type destination
)
2808 ;; ID link points to an external file.
2810 (let ((fragment (concat "ID-" path
))
2811 ;; Treat links to ".org" files as ".html", if needed.
2812 (path (funcall link-org-files-as-html-maybe
2814 (format "<a href=\"%s#%s\"%s>%s</a>"
2815 path fragment attributes
(or desc destination
))))
2816 ;; Fuzzy link points nowhere.
2821 (org-element-property :raw-link link
) info
))))
2822 ;; Link points to a headline.
2824 (let ((href (or (and (string= type
"custom-id")
2825 (org-element-property :CUSTOM_ID destination
))
2826 (org-export-get-headline-id destination info
)))
2827 ;; What description to use?
2829 ;; Case 1: Headline is numbered and LINK has no
2830 ;; description. Display section number.
2831 (if (and (org-export-numbered-headline-p destination info
)
2833 (mapconcat 'number-to-string
2834 (org-export-get-headline-number
2835 destination info
) ".")
2836 ;; Case 2: Either the headline is un-numbered or
2837 ;; LINK has a custom description. Display LINK's
2838 ;; description or headline's title.
2839 (or desc
(org-export-data (org-element-property
2840 :title destination
) info
)))))
2841 (format "<a href=\"#%s\"%s>%s</a>"
2842 (org-export-solidify-link-text href
) attributes desc
)))
2843 ;; Fuzzy link points to a target or an element.
2845 (let* ((path (org-export-solidify-link-text path
))
2846 (org-html-standalone-image-predicate 'org-html--has-caption-p
)
2849 ((org-html-standalone-image-p destination info
)
2850 (org-export-get-ordinal
2851 (org-element-map destination
'link
2853 info
'link
'org-html-standalone-image-p
))
2854 (t (org-export-get-ordinal
2855 destination info nil
'org-html--has-caption-p
))))
2857 ((not number
) "No description for this link")
2858 ((numberp number
) (number-to-string number
))
2859 (t (mapconcat 'number-to-string number
".")))))
2860 (format "<a href=\"#%s\"%s>%s</a>" path attributes desc
))))))
2861 ;; Coderef: replace link with the reference name or the
2862 ;; equivalent line number.
2863 ((string= type
"coderef")
2864 (let ((fragment (concat "coderef-" path
)))
2865 (format "<a href=\"#%s\"%s%s>%s</a>"
2868 (format (concat "class=\"coderef\""
2869 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2870 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2873 (format (org-export-get-coderef-format path desc
)
2874 (org-export-resolve-coderef path info
)))))
2875 ;; External link with a description part.
2876 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2877 ;; External link without a description part.
2878 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2879 ;; No path, only description. Try to do something useful.
2880 (t (format "<i>%s</i>" desc
)))))
2884 (defun org-html-node-property (node-property contents info
)
2885 "Transcode a NODE-PROPERTY element from Org to HTML.
2886 CONTENTS is nil. INFO is a plist holding contextual
2889 (org-element-property :key node-property
)
2890 (let ((value (org-element-property :value node-property
)))
2891 (if value
(concat " " value
) ""))))
2895 (defun org-html-paragraph (paragraph contents info
)
2896 "Transcode a PARAGRAPH element from Org to HTML.
2897 CONTENTS is the contents of the paragraph, as a string. INFO is
2898 the plist used as a communication channel."
2899 (let* ((parent (org-export-get-parent paragraph
))
2900 (parent-type (org-element-type parent
))
2901 (style '((footnote-definition " class=\"footpara\"")))
2902 (attributes (org-html--make-attribute-string
2903 (org-export-read-attribute :attr_html paragraph
)))
2904 (extra (or (cadr (assoc parent-type style
)) "")))
2906 ((and (eq parent-type
'item
)
2907 (not (org-export-get-previous-element paragraph info
))
2908 (let ((followers (org-export-get-next-element paragraph info
2)))
2909 (and (not (cdr followers
))
2910 (memq (org-element-type (car followers
)) '(nil plain-list
)))))
2911 ;; First paragraph in an item has no tag if it is alone or
2912 ;; followed, at most, by a sub-list.
2914 ((org-html-standalone-image-p paragraph info
)
2915 ;; Standalone image.
2917 (let ((raw (org-export-data
2918 (org-export-get-caption paragraph
) info
))
2919 (org-html-standalone-image-predicate
2920 'org-html--has-caption-p
))
2921 (if (not (org-string-nw-p raw
)) raw
2923 "<span class=\"figure-number\">"
2924 (format (org-html--translate "Figure %d:" info
)
2925 (org-export-get-ordinal
2926 (org-element-map paragraph
'link
2928 info nil
'org-html-standalone-image-p
))
2930 (label (org-element-property :name paragraph
)))
2931 (org-html--wrap-image contents info caption label
)))
2932 ;; Regular paragraph.
2933 (t (format "<p%s%s>\n%s</p>"
2934 (if (org-string-nw-p attributes
)
2935 (concat " " attributes
) "")
2940 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2941 ;; the correct value for the item counter
2942 (defun org-html-begin-plain-list (type &optional arg1
)
2943 "Insert the beginning of the HTML list depending on TYPE.
2944 When ARG1 is a string, use it as the start parameter for ordered
2948 (format "<ol class=\"org-ol\"%s>"
2949 (if arg1
(format " start=\"%d\"" arg1
) "")))
2950 (unordered "<ul class=\"org-ul\">")
2951 (descriptive "<dl class=\"org-dl\">")))
2953 (defun org-html-end-plain-list (type)
2954 "Insert the end of the HTML list depending on TYPE."
2958 (descriptive "</dl>")))
2960 (defun org-html-plain-list (plain-list contents info
)
2961 "Transcode a PLAIN-LIST element from Org to HTML.
2962 CONTENTS is the contents of the list. INFO is a plist holding
2963 contextual information."
2964 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2965 (type (org-element-property :type plain-list
)))
2967 (org-html-begin-plain-list type
)
2968 contents
(org-html-end-plain-list type
))))
2972 (defun org-html-convert-special-strings (string)
2973 "Convert special characters in STRING to HTML."
2974 (let ((all org-html-special-string-regexps
)
2976 (while (setq a
(pop all
))
2977 (setq re
(car a
) rpl
(cdr a
) start
0)
2978 (while (string-match re string start
)
2979 (setq string
(replace-match rpl t nil string
))))
2982 (defun org-html-encode-plain-text (text)
2983 "Convert plain text characters from TEXT to HTML equivalent.
2984 Possible conversions are set in `org-html-protect-char-alist'."
2985 (dolist (pair org-html-protect-char-alist text
)
2986 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
))))
2988 (defun org-html-plain-text (text info
)
2989 "Transcode a TEXT string from Org to HTML.
2990 TEXT is the string to transcode. INFO is a plist holding
2991 contextual information."
2992 (let ((output text
))
2993 ;; Protect following characters: <, >, &.
2994 (setq output
(org-html-encode-plain-text output
))
2995 ;; Handle smart quotes. Be sure to provide original string since
2996 ;; OUTPUT may have been modified.
2997 (when (plist-get info
:with-smart-quotes
)
2998 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2999 ;; Handle special strings.
3000 (when (plist-get info
:with-special-strings
)
3001 (setq output
(org-html-convert-special-strings output
)))
3002 ;; Handle break preservation if required.
3003 (when (plist-get info
:preserve-breaks
)
3005 (replace-regexp-in-string
3006 "\\(\\\\\\\\\\)?[ \t]*\n"
3007 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
3014 (defun org-html-planning (planning contents info
)
3015 "Transcode a PLANNING element from Org to HTML.
3016 CONTENTS is nil. INFO is a plist used as a communication
3018 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
3020 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
3025 (let ((closed (org-element-property :closed planning
)))
3027 (format span-fmt org-closed-string
3028 (org-timestamp-translate closed
))))
3029 (let ((deadline (org-element-property :deadline planning
)))
3031 (format span-fmt org-deadline-string
3032 (org-timestamp-translate deadline
))))
3033 (let ((scheduled (org-element-property :scheduled planning
)))
3035 (format span-fmt org-scheduled-string
3036 (org-timestamp-translate scheduled
))))))
3039 ;;;; Property Drawer
3041 (defun org-html-property-drawer (property-drawer contents info
)
3042 "Transcode a PROPERTY-DRAWER element from Org to HTML.
3043 CONTENTS holds the contents of the drawer. INFO is a plist
3044 holding contextual information."
3045 (and (org-string-nw-p contents
)
3046 (format "<pre class=\"example\">\n%s</pre>" contents
)))
3050 (defun org-html-quote-block (quote-block contents info
)
3051 "Transcode a QUOTE-BLOCK element from Org to HTML.
3052 CONTENTS holds the contents of the block. INFO is a plist
3053 holding contextual information."
3054 (format "<blockquote>\n%s</blockquote>" contents
))
3058 (defun org-html-section (section contents info
)
3059 "Transcode a SECTION element from Org to HTML.
3060 CONTENTS holds the contents of the section. INFO is a plist
3061 holding contextual information."
3062 (let ((parent (org-export-get-parent-headline section
)))
3063 ;; Before first headline: no container, just return CONTENTS.
3064 (if (not parent
) contents
3065 ;; Get div's class and id references.
3066 (let* ((class-num (+ (org-export-get-relative-level parent info
)
3067 (1- (plist-get info
:html-toplevel-hlevel
))))
3069 (and (org-export-numbered-headline-p parent info
)
3072 (org-export-get-headline-number parent info
) "-"))))
3073 ;; Build return value.
3074 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
3076 (or (org-element-property :CUSTOM_ID parent
)
3078 (org-export-get-headline-id parent info
))
3079 (or contents
""))))))
3083 (defun org-html-radio-target (radio-target text info
)
3084 "Transcode a RADIO-TARGET object from Org to HTML.
3085 TEXT is the text of the target. INFO is a plist holding
3086 contextual information."
3087 (let ((id (org-export-solidify-link-text
3088 (org-element-property :value radio-target
))))
3089 (org-html--anchor id text nil info
)))
3093 (defun org-html-special-block (special-block contents info
)
3094 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3095 CONTENTS holds the contents of the block. INFO is a plist
3096 holding contextual information."
3097 (let* ((block-type (org-element-property :type special-block
))
3098 (contents (or contents
""))
3099 (html5-fancy (and (org-html-html5-p info
)
3100 (plist-get info
:html-html5-fancy
)
3101 (member block-type org-html-html5-elements
)))
3102 (attributes (org-export-read-attribute :attr_html special-block
)))
3104 (let ((class (plist-get attributes
:class
)))
3105 (setq attributes
(plist-put attributes
:class
3106 (if class
(concat class
" " block-type
)
3108 (setq attributes
(org-html--make-attribute-string attributes
))
3109 (when (not (equal attributes
""))
3110 (setq attributes
(concat " " attributes
)))
3112 (format "<%s%s>\n%s</%s>" block-type attributes
3113 contents block-type
)
3114 (format "<div%s>\n%s\n</div>" attributes contents
))))
3118 (defun org-html-src-block (src-block contents info
)
3119 "Transcode a SRC-BLOCK element from Org to HTML.
3120 CONTENTS holds the contents of the item. INFO is a plist holding
3121 contextual information."
3122 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3123 (org-html--textarea-block src-block
)
3124 (let ((lang (org-element-property :language src-block
))
3125 (caption (org-export-get-caption src-block
))
3126 (code (org-html-format-code src-block info
))
3127 (label (let ((lbl (org-element-property :name src-block
)))
3129 (format " id=\"%s\""
3130 (org-export-solidify-link-text lbl
))))))
3131 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3133 "<div class=\"org-src-container\">\n%s%s\n</div>"
3134 (if (not caption
) ""
3135 (format "<label class=\"org-src-name\">%s</label>"
3136 (org-export-data caption info
)))
3137 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3139 ;;;; Statistics Cookie
3141 (defun org-html-statistics-cookie (statistics-cookie contents info
)
3142 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3143 CONTENTS is nil. INFO is a plist holding contextual information."
3144 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3145 (format "<code>%s</code>" cookie-value
)))
3149 (defun org-html-strike-through (strike-through contents info
)
3150 "Transcode STRIKE-THROUGH from Org to HTML.
3151 CONTENTS is the text with strike-through markup. INFO is a plist
3152 holding contextual information."
3154 (or (cdr (assq 'strike-through
(plist-get info
:html-text-markup-alist
)))
3160 (defun org-html-subscript (subscript contents info
)
3161 "Transcode a SUBSCRIPT object from Org to HTML.
3162 CONTENTS is the contents of the object. INFO is a plist holding
3163 contextual information."
3164 (format "<sub>%s</sub>" contents
))
3168 (defun org-html-superscript (superscript contents info
)
3169 "Transcode a SUPERSCRIPT object from Org to HTML.
3170 CONTENTS is the contents of the object. INFO is a plist holding
3171 contextual information."
3172 (format "<sup>%s</sup>" contents
))
3176 (defun org-html-table-cell (table-cell contents info
)
3177 "Transcode a TABLE-CELL element from Org to HTML.
3178 CONTENTS is nil. INFO is a plist used as a communication
3180 (let* ((table-row (org-export-get-parent table-cell
))
3181 (table (org-export-get-parent-table table-cell
))
3183 (if (not (plist-get info
:html-table-align-individual-fields
)) ""
3184 (format (if (and (boundp 'org-html-format-table-no-css
)
3185 org-html-format-table-no-css
)
3186 " align=\"%s\"" " class=\"%s\"")
3187 (org-export-table-cell-alignment table-cell info
)))))
3188 (when (or (not contents
) (string= "" (org-trim contents
)))
3189 (setq contents
" "))
3191 ((and (org-export-table-has-header-p table info
)
3192 (= 1 (org-export-table-row-group table-row info
)))
3193 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3194 (concat "\n" (format (car header-tags
) "col" cell-attrs
)
3196 (cdr header-tags
))))
3197 ((and (plist-get info
:html-table-use-header-tags-for-first-column
)
3198 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3199 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3200 (concat "\n" (format (car header-tags
) "row" cell-attrs
)
3202 (cdr header-tags
))))
3203 (t (let ((data-tags (plist-get info
:html-table-data-tags
)))
3204 (concat "\n" (format (car data-tags
) cell-attrs
)
3206 (cdr data-tags
)))))))
3210 (defun org-html-table-row (table-row contents info
)
3211 "Transcode a TABLE-ROW element from Org to HTML.
3212 CONTENTS is the contents of the row. INFO is a plist used as a
3213 communication channel."
3214 ;; Rules are ignored since table separators are deduced from
3215 ;; borders of the current row.
3216 (when (eq (org-element-property :type table-row
) 'standard
)
3217 (let* ((rowgroup-number (org-export-table-row-group table-row info
))
3218 (row-number (org-export-table-row-number table-row info
))
3220 (org-export-table-row-starts-rowgroup-p table-row info
))
3222 (org-export-table-row-ends-rowgroup-p table-row info
))
3223 ;; `top-row-p' and `end-rowgroup-p' are not used directly
3224 ;; but should be set so that `org-html-table-row-tags' can
3225 ;; use them (see the docstring of this variable.)
3226 (top-row-p (and (equal start-rowgroup-p
'(top))
3227 (equal end-rowgroup-p
'(below top
))))
3228 (bottom-row-p (and (equal start-rowgroup-p
'(above))
3229 (equal end-rowgroup-p
'(bottom above
))))
3232 ;; Case 1: Row belongs to second or subsequent rowgroups.
3233 ((not (= 1 rowgroup-number
))
3234 '("<tbody>" .
"\n</tbody>"))
3235 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
3236 ((org-export-table-has-header-p
3237 (org-export-get-parent-table table-row
) info
)
3238 '("<thead>" .
"\n</thead>"))
3239 ;; Case 2: Row is from first and only row group.
3240 (t '("<tbody>" .
"\n</tbody>")))))
3242 ;; Begin a rowgroup?
3243 (when start-rowgroup-p
(car rowgroup-tags
))
3245 (concat "\n" (eval (car (plist-get info
:html-table-row-tags
)))
3248 (eval (cdr (plist-get info
:html-table-row-tags
))))
3250 (when end-rowgroup-p
(cdr rowgroup-tags
))))))
3254 (defun org-html-table-first-row-data-cells (table info
)
3255 "Transcode the first row of TABLE.
3256 INFO is a plist used as a communication channel."
3258 (org-element-map table
'table-row
3260 (unless (eq (org-element-property :type row
) 'rule
) row
))
3262 (special-column-p (org-export-table-has-special-column-p table
)))
3263 (if (not special-column-p
) (org-element-contents table-row
)
3264 (cdr (org-element-contents table-row
)))))
3266 (defun org-html-table--table.el-table
(table info
)
3267 "Format table.el tables into HTML.
3268 INFO is a plist used as a communication channel."
3269 (when (eq (org-element-property :type table
) 'table.el
)
3271 (let ((outbuf (with-current-buffer
3272 (get-buffer-create "*org-export-table*")
3273 (erase-buffer) (current-buffer))))
3275 (insert (org-element-property :value table
))
3277 (re-search-forward "^[ \t]*|[^|]" nil t
)
3278 (table-generate-source 'html outbuf
))
3279 (with-current-buffer outbuf
3280 (prog1 (org-trim (buffer-string))
3283 (defun org-html-table (table contents info
)
3284 "Transcode a TABLE element from Org to HTML.
3285 CONTENTS is the contents of the table. INFO is a plist holding
3286 contextual information."
3287 (case (org-element-property :type table
)
3288 ;; Case 1: table.el table. Convert it using appropriate tools.
3289 (table.el
(org-html-table--table.el-table table info
))
3290 ;; Case 2: Standard table.
3292 (let* ((label (org-element-property :name table
))
3293 (caption (org-export-get-caption table
))
3294 (number (org-export-get-ordinal
3295 table info nil
'org-html--has-caption-p
))
3297 (org-html--make-attribute-string
3299 (and label
(list :id
(org-export-solidify-link-text label
)))
3300 (and (not (org-html-html5-p info
))
3301 (plist-get info
:html-table-attributes
))
3302 (org-export-read-attribute :attr_html table
))))
3304 (if (and (boundp 'org-html-format-table-no-css
)
3305 org-html-format-table-no-css
)
3306 "align=\"%s\"" "class=\"%s\""))
3309 (lambda (table info
)
3311 (lambda (table-cell)
3312 (let ((alignment (org-export-table-cell-alignment
3315 ;; Begin a colgroup?
3316 (when (org-export-table-cell-starts-colgroup-p
3319 ;; Add a column. Also specify it's alignment.
3322 "col" (concat " " (format alignspec alignment
)) info
))
3324 (when (org-export-table-cell-ends-colgroup-p
3327 (org-html-table-first-row-data-cells table info
) "\n")))))
3328 (format "<table%s>\n%s\n%s\n%s</table>"
3329 (if (equal attributes
"") "" (concat " " attributes
))
3330 (if (not caption
) ""
3331 (format (if (plist-get info
:html-table-caption-above
)
3332 "<caption class=\"t-above\">%s</caption>"
3333 "<caption class=\"t-bottom\">%s</caption>")
3335 "<span class=\"table-number\">"
3336 (format (org-html--translate "Table %d:" info
) number
)
3337 "</span> " (org-export-data caption info
))))
3338 (funcall table-column-specs table info
)
3343 (defun org-html-target (target contents info
)
3344 "Transcode a TARGET object from Org to HTML.
3345 CONTENTS is nil. INFO is a plist holding contextual
3347 (let ((id (org-export-solidify-link-text
3348 (org-element-property :value target
))))
3349 (org-html--anchor id nil nil info
)))
3353 (defun org-html-timestamp (timestamp contents info
)
3354 "Transcode a TIMESTAMP object from Org to HTML.
3355 CONTENTS is nil. INFO is a plist holding contextual
3357 (let ((value (org-html-plain-text (org-timestamp-translate timestamp
) info
)))
3358 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3359 (replace-regexp-in-string "--" "–" value
))))
3363 (defun org-html-underline (underline contents info
)
3364 "Transcode UNDERLINE from Org to HTML.
3365 CONTENTS is the text with underline markup. INFO is a plist
3366 holding contextual information."
3367 (format (or (cdr (assq 'underline
(plist-get info
:html-text-markup-alist
)))
3373 (defun org-html-verbatim (verbatim contents info
)
3374 "Transcode VERBATIM from Org to HTML.
3375 CONTENTS is nil. INFO is a plist holding contextual
3377 (format (or (cdr (assq 'verbatim
(plist-get info
:html-text-markup-alist
))) "%s")
3378 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3382 (defun org-html-verse-block (verse-block contents info
)
3383 "Transcode a VERSE-BLOCK element from Org to HTML.
3384 CONTENTS is verse block contents. INFO is a plist holding
3385 contextual information."
3386 ;; Replace each newline character with line break. Also replace
3387 ;; each blank line with a line break.
3388 (setq contents
(replace-regexp-in-string
3389 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3390 (replace-regexp-in-string
3391 "\\(\\\\\\\\\\)?[ \t]*\n"
3392 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3393 ;; Replace each white space at beginning of a line with a
3394 ;; non-breaking space.
3395 (while (string-match "^[ \t]+" contents
)
3396 (let* ((num-ws (length (match-string 0 contents
)))
3397 (ws (let (out) (dotimes (i num-ws out
)
3398 (setq out
(concat out
" "))))))
3399 (setq contents
(replace-match ws nil t contents
))))
3400 (format "<p class=\"verse\">\n%s</p>" contents
))
3403 ;;; Filter Functions
3405 (defun org-html-final-function (contents backend info
)
3406 "Filter to indent the HTML and convert HTML entities."
3410 (if (plist-get info
:html-indent
)
3411 (indent-region (point-min) (point-max)))
3412 (when (plist-get info
:html-use-unicode-chars
)
3414 (mm-url-decode-entities))
3415 (buffer-substring-no-properties (point-min) (point-max))))
3418 ;;; End-user functions
3421 (defun org-html-export-as-html
3422 (&optional async subtreep visible-only body-only ext-plist
)
3423 "Export current buffer to an HTML buffer.
3425 If narrowing is active in the current buffer, only export its
3428 If a region is active, export that region.
3430 A non-nil optional argument ASYNC means the process should happen
3431 asynchronously. The resulting buffer should be accessible
3432 through the `org-export-stack' interface.
3434 When optional argument SUBTREEP is non-nil, export the sub-tree
3435 at point, extracting information from the headline properties
3438 When optional argument VISIBLE-ONLY is non-nil, don't export
3439 contents of hidden elements.
3441 When optional argument BODY-ONLY is non-nil, only write code
3442 between \"<body>\" and \"</body>\" tags.
3444 EXT-PLIST, when provided, is a property list with external
3445 parameters overriding Org default settings, but still inferior to
3446 file-local settings.
3448 Export is done in a buffer named \"*Org HTML Export*\", which
3449 will be displayed when `org-export-show-temporary-export-buffer'
3452 (org-export-to-buffer 'html
"*Org HTML Export*"
3453 async subtreep visible-only body-only ext-plist
3454 (lambda () (set-auto-mode t
))))
3457 (defun org-html-convert-region-to-html ()
3458 "Assume the current region has org-mode syntax, and convert it to HTML.
3459 This can be used in any buffer. For example, you can write an
3460 itemized list in org-mode syntax in an HTML buffer and use this
3461 command to convert it."
3463 (org-export-replace-region-by 'html
))
3466 (defun org-html-export-to-html
3467 (&optional async subtreep visible-only body-only ext-plist
)
3468 "Export current buffer to a HTML file.
3470 If narrowing is active in the current buffer, only export its
3473 If a region is active, export that region.
3475 A non-nil optional argument ASYNC means the process should happen
3476 asynchronously. The resulting file should be accessible through
3477 the `org-export-stack' interface.
3479 When optional argument SUBTREEP is non-nil, export the sub-tree
3480 at point, extracting information from the headline properties
3483 When optional argument VISIBLE-ONLY is non-nil, don't export
3484 contents of hidden elements.
3486 When optional argument BODY-ONLY is non-nil, only write code
3487 between \"<body>\" and \"</body>\" tags.
3489 EXT-PLIST, when provided, is a property list with external
3490 parameters overriding Org default settings, but still inferior to
3491 file-local settings.
3493 Return output file's name."
3495 (let* ((extension (concat "." (or (plist-get ext-plist
:html-extension
)
3498 (file (org-export-output-file-name extension subtreep
))
3499 (org-export-coding-system org-html-coding-system
))
3500 (org-export-to-file 'html file
3501 async subtreep visible-only body-only ext-plist
)))
3504 (defun org-html-publish-to-html (plist filename pub-dir
)
3505 "Publish an org file to HTML.
3507 FILENAME is the filename of the Org file to be published. PLIST
3508 is the property list for the given project. PUB-DIR is the
3509 publishing directory.
3511 Return output file name."
3512 (org-publish-org-to 'html filename
3513 (concat "." (or (plist-get plist
:html-extension
)
3522 ;; generated-autoload-file: "org-loaddefs.el"
3525 ;;; ox-html.el ends here