1 ;;; ox-html.el --- HTML Back-End for Org Export Engine -*- lexical-binding: t; -*-
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
))
40 ;;; Function Declarations
42 (declare-function org-id-find-id-file
"org-id" (id))
43 (declare-function htmlize-region
"ext:htmlize" (beg end
))
44 (declare-function org-pop-to-buffer-same-window
45 "org-compat" (&optional buffer-or-name norecord label
))
46 (declare-function mm-url-decode-entities
"mm-url" ())
48 (defvar htmlize-css-name-prefix
)
49 (defvar htmlize-output-type
)
50 (defvar htmlize-output-type
)
51 (defvar htmlize-css-name-prefix
)
55 (org-export-define-backend 'html
56 '((bold . org-html-bold
)
57 (center-block . org-html-center-block
)
58 (clock . org-html-clock
)
59 (code . org-html-code
)
60 (drawer . org-html-drawer
)
61 (dynamic-block . org-html-dynamic-block
)
62 (entity . org-html-entity
)
63 (example-block . org-html-example-block
)
64 (export-block . org-html-export-block
)
65 (export-snippet . org-html-export-snippet
)
66 (fixed-width . org-html-fixed-width
)
67 (footnote-definition . org-html-footnote-definition
)
68 (footnote-reference . org-html-footnote-reference
)
69 (headline . org-html-headline
)
70 (horizontal-rule . org-html-horizontal-rule
)
71 (inline-src-block . org-html-inline-src-block
)
72 (inlinetask . org-html-inlinetask
)
73 (inner-template . org-html-inner-template
)
74 (italic . org-html-italic
)
75 (item . org-html-item
)
76 (keyword . org-html-keyword
)
77 (latex-environment . org-html-latex-environment
)
78 (latex-fragment . org-html-latex-fragment
)
79 (line-break . org-html-line-break
)
80 (link . org-html-link
)
81 (node-property . org-html-node-property
)
82 (paragraph . org-html-paragraph
)
83 (plain-list . org-html-plain-list
)
84 (plain-text . org-html-plain-text
)
85 (planning . org-html-planning
)
86 (property-drawer . org-html-property-drawer
)
87 (quote-block . org-html-quote-block
)
88 (radio-target . org-html-radio-target
)
89 (section . org-html-section
)
90 (special-block . org-html-special-block
)
91 (src-block . org-html-src-block
)
92 (statistics-cookie . org-html-statistics-cookie
)
93 (strike-through . org-html-strike-through
)
94 (subscript . org-html-subscript
)
95 (superscript . org-html-superscript
)
96 (table . org-html-table
)
97 (table-cell . org-html-table-cell
)
98 (table-row . org-html-table-row
)
99 (target . org-html-target
)
100 (template . org-html-template
)
101 (timestamp . org-html-timestamp
)
102 (underline . org-html-underline
)
103 (verbatim . org-html-verbatim
)
104 (verse-block . org-html-verse-block
))
106 :filters-alist
'((:filter-options . org-html-infojs-install-script
)
107 (:filter-final-output . org-html-final-function
))
109 '(?h
"Export to HTML"
110 ((?H
"As HTML buffer" org-html-export-as-html
)
111 (?h
"As HTML file" org-html-export-to-html
)
112 (?o
"As HTML file and open"
114 (if a
(org-html-export-to-html t s v b
)
115 (org-open-file (org-html-export-to-html nil s v b
)))))))
117 '((:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
118 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
119 (:description
"DESCRIPTION" nil nil newline
)
120 (:keywords
"KEYWORDS" nil nil space
)
121 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
122 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
123 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
124 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
125 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
126 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
127 (:html-postamble nil
"html-postamble" org-html-postamble
)
128 (:html-preamble nil
"html-preamble" org-html-preamble
)
129 (:html-head
"HTML_HEAD" nil org-html-head newline
)
130 (:html-head-extra
"HTML_HEAD_EXTRA" nil org-html-head-extra newline
)
131 (:subtitle
"SUBTITLE" nil nil parse
)
132 (:html-head-include-default-style
133 nil
"html-style" org-html-head-include-default-style
)
134 (:html-head-include-scripts nil
"html-scripts" org-html-head-include-scripts
)
135 (:html-allow-name-attribute-in-anchors
136 nil nil org-html-allow-name-attribute-in-anchors
)
137 (:html-divs nil nil org-html-divs
)
138 (:html-checkbox-type nil nil org-html-checkbox-type
)
139 (:html-extension nil nil org-html-extension
)
140 (:html-footnote-format nil nil org-html-footnote-format
)
141 (:html-footnote-separator nil nil org-html-footnote-separator
)
142 (:html-footnotes-section nil nil org-html-footnotes-section
)
143 (:html-format-drawer-function nil nil org-html-format-drawer-function
)
144 (:html-format-headline-function nil nil org-html-format-headline-function
)
145 (:html-format-inlinetask-function
146 nil nil org-html-format-inlinetask-function
)
147 (:html-home
/up-format nil nil org-html-home
/up-format
)
148 (:html-indent nil nil org-html-indent
)
149 (:html-infojs-options nil nil org-html-infojs-options
)
150 (:html-infojs-template nil nil org-html-infojs-template
)
151 (:html-inline-image-rules nil nil org-html-inline-image-rules
)
152 (:html-link-org-files-as-html nil nil org-html-link-org-files-as-html
)
153 (:html-mathjax-options nil nil org-html-mathjax-options
)
154 (:html-mathjax-template nil nil org-html-mathjax-template
)
155 (:html-metadata-timestamp-format nil nil org-html-metadata-timestamp-format
)
156 (:html-postamble-format nil nil org-html-postamble-format
)
157 (:html-preamble-format nil nil org-html-preamble-format
)
158 (:html-table-align-individual-fields
159 nil nil org-html-table-align-individual-fields
)
160 (:html-table-caption-above nil nil org-html-table-caption-above
)
161 (:html-table-data-tags nil nil org-html-table-data-tags
)
162 (:html-table-header-tags nil nil org-html-table-header-tags
)
163 (:html-table-use-header-tags-for-first-column
164 nil nil org-html-table-use-header-tags-for-first-column
)
165 (:html-tag-class-prefix nil nil org-html-tag-class-prefix
)
166 (:html-text-markup-alist nil nil org-html-text-markup-alist
)
167 (:html-todo-kwd-class-prefix nil nil org-html-todo-kwd-class-prefix
)
168 (:html-toplevel-hlevel nil nil org-html-toplevel-hlevel
)
169 (:html-use-infojs nil nil org-html-use-infojs
)
170 (:html-validation-link nil nil org-html-validation-link
)
171 (:html-viewport nil nil org-html-viewport
)
172 (:html-inline-images nil nil org-html-inline-images
)
173 (:html-table-attributes nil nil org-html-table-default-attributes
)
174 (:html-table-row-tags nil nil org-html-table-row-tags
)
175 (:html-xml-declaration nil nil org-html-xml-declaration
)
176 (:infojs-opt
"INFOJS_OPT" nil nil
)
177 ;; Redefine regular options.
178 (:creator
"CREATOR" nil org-html-creator-string
)
179 (:with-latex nil
"tex" org-html-with-latex
)
180 ;; Retrieve LaTeX header for fragments.
181 (:latex-header
"LATEX_HEADER" nil nil newline
)))
184 ;;; Internal Variables
186 (defvar org-html-format-table-no-css
)
187 (defvar htmlize-buffer-places
) ; from htmlize.el
189 (defvar org-html--pre
/postamble-class
"status"
190 "CSS class used for pre/postamble")
192 (defconst org-html-doctype-alist
193 '(("html4-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
194 \"http://www.w3.org/TR/html4/strict.dtd\">")
195 ("html4-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
196 \"http://www.w3.org/TR/html4/loose.dtd\">")
197 ("html4-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
198 \"http://www.w3.org/TR/html4/frameset.dtd\">")
200 ("xhtml-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
201 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
202 ("xhtml-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
203 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
204 ("xhtml-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
205 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
206 ("xhtml-11" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
207 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
209 ("html5" .
"<!DOCTYPE html>")
210 ("xhtml5" .
"<!DOCTYPE html>"))
211 "An alist mapping (x)html flavors to specific doctypes.")
213 (defconst org-html-html5-elements
214 '("article" "aside" "audio" "canvas" "details" "figcaption"
215 "figure" "footer" "header" "menu" "meter" "nav" "output"
216 "progress" "section" "video")
217 "New elements in html5.
219 For blocks that should contain headlines, use the HTML_CONTAINER
220 property on the headline itself.")
222 (defconst org-html-special-string-regexps
223 '(("\\\\-" .
"­") ; shy
224 ("---\\([^-]\\)" .
"—\\1") ; mdash
225 ("--\\([^-]\\)" .
"–\\1") ; ndash
226 ("\\.\\.\\." .
"…")) ; hellip
227 "Regular expressions for special string conversion.")
229 (defconst org-html-scripts
230 "<script type=\"text/javascript\">
232 @licstart The following is the entire license notice for the
233 JavaScript code in this tag.
235 Copyright (C) 2012-2013 Free Software Foundation, Inc.
237 The JavaScript code in this tag is free software: you can
238 redistribute it and/or modify it under the terms of the GNU
239 General Public License (GNU GPL) as published by the Free Software
240 Foundation, either version 3 of the License, or (at your option)
241 any later version. The code is distributed WITHOUT ANY WARRANTY;
242 without even the implied warranty of MERCHANTABILITY or FITNESS
243 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
245 As additional permission under GNU GPL version 3 section 7, you
246 may distribute non-source (e.g., minimized or compacted) forms of
247 that code without the copy of the GNU GPL normally required by
248 section 4, provided you include this license notice and a URL
249 through which recipients can access the Corresponding Source.
252 @licend The above is the entire license notice
253 for the JavaScript code in this tag.
255 <!--/*--><![CDATA[/*><!--*/
256 function CodeHighlightOn(elem, id)
258 var target = document.getElementById(id);
260 elem.cacheClassElem = elem.className;
261 elem.cacheClassTarget = target.className;
262 target.className = \"code-highlighted\";
263 elem.className = \"code-highlighted\";
266 function CodeHighlightOff(elem, id)
268 var target = document.getElementById(id);
269 if(elem.cacheClassElem)
270 elem.className = elem.cacheClassElem;
271 if(elem.cacheClassTarget)
272 target.className = elem.cacheClassTarget;
276 "Basic JavaScript that is needed by HTML files produced by Org mode.")
278 (defconst org-html-style-default
279 "<style type=\"text/css\">
280 <!--/*--><![CDATA[/*><!--*/
281 .title { text-align: center;
282 margin-bottom: .2em; }
283 .subtitle { text-align: center;
287 .todo { font-family: monospace; color: red; }
288 .done { font-family: monospace; color: green; }
289 .priority { font-family: monospace; color: orange; }
290 .tag { background-color: #eee; font-family: monospace;
291 padding: 2px; font-size: 80%; font-weight: normal; }
292 .timestamp { color: #bebebe; }
293 .timestamp-kwd { color: #5f9ea0; }
294 .org-right { margin-left: auto; margin-right: 0px; text-align: right; }
295 .org-left { margin-left: 0px; margin-right: auto; text-align: left; }
296 .org-center { margin-left: auto; margin-right: auto; text-align: center; }
297 .underline { text-decoration: underline; }
298 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
299 p.verse { margin-left: 3%; }
301 border: 1px solid #ccc;
302 box-shadow: 3px 3px 3px #eee;
304 font-family: monospace;
316 background-color: white;
320 border: 1px solid black;
322 pre.src:hover:before { display: inline;}
323 pre.src-sh:before { content: 'sh'; }
324 pre.src-bash:before { content: 'sh'; }
325 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
326 pre.src-R:before { content: 'R'; }
327 pre.src-perl:before { content: 'Perl'; }
328 pre.src-java:before { content: 'Java'; }
329 pre.src-sql:before { content: 'SQL'; }
331 table { border-collapse:collapse; }
332 caption.t-above { caption-side: top; }
333 caption.t-bottom { caption-side: bottom; }
334 td, th { vertical-align:top; }
335 th.org-right { text-align: center; }
336 th.org-left { text-align: center; }
337 th.org-center { text-align: center; }
338 td.org-right { text-align: right; }
339 td.org-left { text-align: left; }
340 td.org-center { text-align: center; }
341 dt { font-weight: bold; }
342 .footpara { display: inline; }
343 .footdef { margin-bottom: 1em; }
344 .figure { padding: 1em; }
345 .figure p { text-align: center; }
348 border: 2px solid gray;
353 { text-align: right; font-size: 70%; white-space: nowrap; }
354 textarea { overflow-x: auto; }
355 .linenr { font-size: smaller }
356 .code-highlighted { background-color: #ffff00; }
357 .org-info-js_info-navigation { border-style: none; }
358 #org-info-js_console-label
359 { font-size: 10px; font-weight: bold; white-space: nowrap; }
360 .org-info-js_search-highlight
361 { background-color: #ffff00; color: #000000; font-weight: bold; }
364 "The default style specification for exported HTML files.
365 You can use `org-html-head' and `org-html-head-extra' to add to
366 this style. If you don't want to include this default style,
367 customize `org-html-head-include-default-style'.")
370 ;;; User Configuration Variables
372 (defgroup org-export-html nil
373 "Options for exporting Org mode files to HTML."
374 :tag
"Org Export HTML"
379 (defvar org-html-infojs-opts-table
380 '((path PATH
"http://orgmode.org/org-info.js")
384 (tdepth TOC_DEPTH
"max")
385 (sdepth SECTION_DEPTH
"max")
386 (mouse MOUSE_HINT
"underline")
387 (buttons VIEW_BUTTONS
"0")
389 (up LINK_UP
:html-link-up
)
390 (home LINK_HOME
:html-link-home
))
391 "JavaScript options, long form for script, default values.")
393 (defcustom org-html-use-infojs
'when-configured
394 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
395 This option can be nil or t to never or always use the script.
396 It can also be the symbol `when-configured', meaning that the
397 script will be linked into the export file if and only if there
398 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
399 `org-html-infojs-options'."
400 :group
'org-export-html
402 :package-version
'(Org .
"8.0")
404 (const :tag
"Never" nil
)
405 (const :tag
"When configured in buffer" when-configured
)
406 (const :tag
"Always" t
)))
408 (defcustom org-html-infojs-options
409 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
410 "Options settings for the INFOJS JavaScript.
411 Each of the options must have an entry in `org-html-infojs-opts-table'.
412 The value can either be a string that will be passed to the script, or
413 a property. This property is then assumed to be a property that is defined
414 by the Export/Publishing setup of Org.
415 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
416 means to use the maximum value consistent with other options."
417 :group
'org-export-html
419 :package-version
'(Org .
"8.0")
421 `(set :greedy t
:inline t
424 (list 'cons
(list 'const
(car x
))
426 (symbol :tag
"Publishing/Export property")
427 (string :tag
"Value"))))
428 org-html-infojs-opts-table
)))
430 (defcustom org-html-infojs-template
431 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
434 * @source: %SCRIPT_PATH
436 * @licstart The following is the entire license notice for the
437 * JavaScript code in %SCRIPT_PATH.
439 * Copyright (C) 2012-2013 Free Software Foundation, Inc.
442 * The JavaScript code in this tag is free software: you can
443 * redistribute it and/or modify it under the terms of the GNU
444 * General Public License (GNU GPL) as published by the Free Software
445 * Foundation, either version 3 of the License, or (at your option)
446 * any later version. The code is distributed WITHOUT ANY WARRANTY;
447 * without even the implied warranty of MERCHANTABILITY or FITNESS
448 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
450 * As additional permission under GNU GPL version 3 section 7, you
451 * may distribute non-source (e.g., minimized or compacted) forms of
452 * that code without the copy of the GNU GPL normally required by
453 * section 4, provided you include this license notice and a URL
454 * through which recipients can access the Corresponding Source.
456 * @licend The above is the entire license notice
457 * for the JavaScript code in %SCRIPT_PATH.
462 <script type=\"text/javascript\">
465 @licstart The following is the entire license notice for the
466 JavaScript code in this tag.
468 Copyright (C) 2012-2013 Free Software Foundation, Inc.
470 The JavaScript code in this tag is free software: you can
471 redistribute it and/or modify it under the terms of the GNU
472 General Public License (GNU GPL) as published by the Free Software
473 Foundation, either version 3 of the License, or (at your option)
474 any later version. The code is distributed WITHOUT ANY WARRANTY;
475 without even the implied warranty of MERCHANTABILITY or FITNESS
476 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
478 As additional permission under GNU GPL version 3 section 7, you
479 may distribute non-source (e.g., minimized or compacted) forms of
480 that code without the copy of the GNU GPL normally required by
481 section 4, provided you include this license notice and a URL
482 through which recipients can access the Corresponding Source.
485 @licend The above is the entire license notice
486 for the JavaScript code in this tag.
489 <!--/*--><![CDATA[/*><!--*/
491 org_html_manager.setup(); // activate after the parameters are set
494 "The template for the export style additions when org-info.js is used.
495 Option settings will replace the %MANAGER-OPTIONS cookie."
496 :group
'org-export-html
498 :package-version
'(Org .
"8.0")
501 (defun org-html-infojs-install-script (exp-plist _backend
)
502 "Install script in export options when appropriate.
503 EXP-PLIST is a plist containing export options. BACKEND is the
504 export back-end currently used."
505 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
506 (not (plist-get exp-plist
:html-use-infojs
))
507 (and (eq (plist-get exp-plist
:html-use-infojs
) 'when-configured
)
508 (let ((opt (plist-get exp-plist
:infojs-opt
)))
511 (string-match "\\<view:nil\\>" opt
)))))
512 (let* ((template (plist-get exp-plist
:html-infojs-template
))
513 (ptoc (plist-get exp-plist
:with-toc
))
514 (hlevels (plist-get exp-plist
:headline-levels
))
516 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
517 (options (plist-get exp-plist
:infojs-opt
))
518 (infojs-opt (plist-get exp-plist
:html-infojs-options
))
519 (table org-html-infojs-opts-table
)
521 (dolist (entry table
)
522 (let* ((opt (car entry
))
524 ;; Compute default values for script option OPT from
525 ;; `org-html-infojs-options' variable.
527 (let ((default (cdr (assq opt infojs-opt
))))
528 (if (and (symbolp default
) (not (memq default
'(t nil
))))
529 (plist-get exp-plist default
)
531 ;; Value set through INFOJS_OPT keyword has precedence
532 ;; over the default one.
533 (val (if (and options
534 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
536 (match-string 1 options
)
540 (replace-regexp-in-string
541 "%SCRIPT_PATH" val template t t
)))
542 (sdepth (when (integerp (read val
))
543 (setq sdepth
(min (read val
) sdepth
))))
544 (tdepth (when (integerp (read val
))
545 (setq tdepth
(min (read val
) tdepth
))))
548 ((or (eq val t
) (equal val
"t")) "1")
549 ((or (eq val nil
) (equal val
"nil")) "0")
551 (t (format "%s" val
))))
552 (push (cons var val
) style
)))))
553 ;; Now we set the depth of the *generated* TOC to SDEPTH,
554 ;; because the toc will actually determine the splitting. How
555 ;; much of the toc will actually be displayed is governed by the
557 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
558 ;; The table of contents should not show more sections than we
560 (setq tdepth
(min tdepth sdepth
))
561 (push (cons "TOC_DEPTH" tdepth
) style
)
562 ;; Build style string.
563 (setq style
(mapconcat
565 (format "org_html_manager.set(\"%s\", \"%s\");"
568 (when (and style
(> (length style
) 0))
569 (and (string-match "%MANAGER_OPTIONS" template
)
570 (setq style
(replace-match style t t template
))
573 exp-plist
:html-head-extra
574 (concat (or (plist-get exp-plist
:html-head-extra
) "")
577 ;; This script absolutely needs the table of contents, so we
578 ;; change that setting.
579 (unless (plist-get exp-plist
:with-toc
)
580 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
581 ;; Return the modified property list.
586 (defcustom org-html-text-markup-alist
587 '((bold .
"<b>%s</b>")
588 (code .
"<code>%s</code>")
589 (italic .
"<i>%s</i>")
590 (strike-through .
"<del>%s</del>")
591 (underline .
"<span class=\"underline\">%s</span>")
592 (verbatim .
"<code>%s</code>"))
593 "Alist of HTML expressions to convert text markup.
595 The key must be a symbol among `bold', `code', `italic',
596 `strike-through', `underline' and `verbatim'. The value is
597 a formatting string to wrap fontified text with.
599 If no association can be found for a given markup, text will be
601 :group
'org-export-html
603 :package-version
'(Org .
"8.0")
604 :type
'(alist :key-type
(symbol :tag
"Markup type")
605 :value-type
(string :tag
"Format string"))
606 :options
'(bold code italic strike-through underline verbatim
))
608 (defcustom org-html-indent nil
609 "Non-nil means to indent the generated HTML.
610 Warning: non-nil may break indentation of source code blocks."
611 :group
'org-export-html
613 :package-version
'(Org .
"8.0")
618 (defcustom org-html-format-drawer-function
(lambda (_name contents
) contents
)
619 "Function called to format a drawer in HTML code.
621 The function must accept two parameters:
622 NAME the drawer name, like \"LOGBOOK\"
623 CONTENTS the contents of the drawer.
625 The function should return the string to be exported.
627 For example, the variable could be set to the following function
628 in order to mimic default behavior:
630 The default value simply returns the value of CONTENTS."
631 :group
'org-export-html
633 :package-version
'(Org .
"8.0")
638 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
639 <h2 class=\"footnotes\">%s: </h2>
640 <div id=\"text-footnotes\">
644 "Format for the footnotes section.
645 Should contain a two instances of %s. The first will be replaced with the
646 language-specific word for \"Footnotes\", the second one will be replaced
647 by the footnotes themselves."
648 :group
'org-export-html
651 (defcustom org-html-footnote-format
"<sup>%s</sup>"
652 "The format for the footnote reference.
653 %s will be replaced by the footnote reference itself."
654 :group
'org-export-html
657 (defcustom org-html-footnote-separator
"<sup>, </sup>"
658 "Text used to separate footnotes."
659 :group
'org-export-html
664 (defcustom org-html-toplevel-hlevel
2
665 "The <H> level for level 1 headings in HTML export.
666 This is also important for the classes that will be wrapped around headlines
667 and outline structure. If this variable is 1, the top-level headlines will
668 be <h1>, and the corresponding classes will be outline-1, section-number-1,
669 and outline-text-1. If this is 2, all of these will get a 2 instead.
670 The default for this variable is 2, because we use <h1> for formatting the
672 :group
'org-export-html
675 (defcustom org-html-format-headline-function
676 'org-html-format-headline-default-function
677 "Function to format headline text.
679 This function will be called with six arguments:
680 TODO the todo keyword (string or nil).
681 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
682 PRIORITY the priority of the headline (integer or nil)
683 TEXT the main headline text (string).
684 TAGS the tags (string or nil).
685 INFO the export options (plist).
687 The function result will be used in the section format string."
688 :group
'org-export-html
690 :package-version
'(Org .
"8.3")
695 (defcustom org-html-allow-name-attribute-in-anchors nil
696 "When nil, do not set \"name\" attribute in anchors.
697 By default, when appropriate, anchors are formatted with \"id\"
698 but without \"name\" attribute."
699 :group
'org-export-html
701 :package-version
'(Org .
"8.0")
706 (defcustom org-html-format-inlinetask-function
707 'org-html-format-inlinetask-default-function
708 "Function called to format an inlinetask in HTML code.
710 The function must accept seven parameters:
711 TODO the todo keyword, as a string
712 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
713 PRIORITY the inlinetask priority, as a string
714 NAME the inlinetask name, as a string.
715 TAGS the inlinetask tags, as a list of strings.
716 CONTENTS the contents of the inlinetask, as a string.
717 INFO the export options, as a plist
719 The function should return the string to be exported."
720 :group
'org-export-html
722 :package-version
'(Org .
"8.3")
727 (defcustom org-html-with-latex org-export-with-latex
728 "Non-nil means process LaTeX math snippets.
730 When set, the exporter will process LaTeX environments and
733 This option can also be set with the +OPTIONS line,
734 e.g. \"tex:mathjax\". Allowed values are:
736 nil Ignore math snippets.
737 `verbatim' Keep everything in verbatim
738 `dvipng' Process the LaTeX fragments to images. This will also
739 include processing of non-math environments.
740 `imagemagick' Convert the LaTeX fragments to pdf files and use
741 imagemagick to convert pdf files to png files.
742 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
744 t Synonym for `mathjax'."
745 :group
'org-export-html
747 :package-version
'(Org .
"8.0")
749 (const :tag
"Do not process math in any way" nil
)
750 (const :tag
"Use dvipng to make images" dvipng
)
751 (const :tag
"Use imagemagick to make images" imagemagick
)
752 (const :tag
"Use MathJax to display math" mathjax
)
753 (const :tag
"Leave math verbatim" verbatim
)))
755 ;;;; Links :: Generic
757 (defcustom org-html-link-org-files-as-html t
758 "Non-nil means make file links to `file.org' point to `file.html'.
759 When `org-mode' is exporting an `org-mode' file to HTML, links to
760 non-html files are directly put into a href tag in HTML.
761 However, links to other Org-mode files (recognized by the
762 extension `.org') should become links to the corresponding html
763 file, assuming that the linked `org-mode' file will also be
765 When nil, the links still point to the plain `.org' file."
766 :group
'org-export-html
769 ;;;; Links :: Inline images
771 (defcustom org-html-inline-images t
772 "Non-nil means inline images into exported HTML pages.
773 This is done using an <img> tag. When nil, an anchor with href is used to
775 :group
'org-export-html
777 :package-version
'(Org .
"8.1")
780 (defcustom org-html-inline-image-rules
781 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
782 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
783 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
784 "Rules characterizing image files that can be inlined into HTML.
785 A rule consists in an association whose key is the type of link
786 to consider, and value is a regexp that will be matched against
788 :group
'org-export-html
790 :package-version
'(Org .
"8.0")
791 :type
'(alist :key-type
(string :tag
"Type")
792 :value-type
(regexp :tag
"Path")))
796 (defvar org-html-protect-char-alist
800 "Alist of characters to be converted by `org-html-encode-plain-text'.")
804 (defcustom org-html-htmlize-output-type
'inline-css
805 "Output type to be used by htmlize when formatting code snippets.
806 Choices are `css' to export the CSS selectors only,`inline-css'
807 to export the CSS attribute values inline in the HTML or `nil' to
808 export plain text. We use as default `inline-css', in order to
809 make the resulting HTML self-containing.
811 However, this will fail when using Emacs in batch mode for export, because
812 then no rich font definitions are in place. It will also not be good if
813 people with different Emacs setup contribute HTML files to a website,
814 because the fonts will represent the individual setups. In these cases,
815 it is much better to let Org/Htmlize assign classes only, and to use
816 a style file to define the look of these classes.
817 To get a start for your css file, start Emacs session and make sure that
818 all the faces you are interested in are defined, for example by loading files
819 in all modes you want. Then, use the command
820 \\[org-html-htmlize-generate-css] to extract class definitions."
821 :group
'org-export-html
822 :type
'(choice (const css
) (const inline-css
) (const nil
)))
824 (defcustom org-html-htmlize-font-prefix
"org-"
825 "The prefix for CSS class names for htmlize font specifications."
826 :group
'org-export-html
831 (defcustom org-html-table-default-attributes
832 '(:border
"2" :cellspacing
"0" :cellpadding
"6" :rules
"groups" :frame
"hsides")
833 "Default attributes and values which will be used in table tags.
834 This is a plist where attributes are symbols, starting with
835 colons, and values are strings.
837 When exporting to HTML5, these values will be disregarded."
838 :group
'org-export-html
840 :package-version
'(Org .
"8.0")
841 :type
'(plist :key-type
(symbol :tag
"Property")
842 :value-type
(string :tag
"Value")))
844 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
845 "The opening and ending tags for table header fields.
846 This is customizable so that alignment options can be specified.
847 The first %s will be filled with the scope of the field, either row or col.
848 The second %s will be replaced by a style entry to align the field.
849 See also the variable `org-html-table-use-header-tags-for-first-column'.
850 See also the variable `org-html-table-align-individual-fields'."
851 :group
'org-export-html
852 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
854 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
855 "The opening and ending tags for table data fields.
856 This is customizable so that alignment options can be specified.
857 The first %s will be filled with the scope of the field, either row or col.
858 The second %s will be replaced by a style entry to align the field.
859 See also the variable `org-html-table-align-individual-fields'."
860 :group
'org-export-html
861 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
863 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
864 "The opening and ending tags for table rows.
865 This is customizable so that alignment options can be specified.
866 Instead of strings, these can be Lisp forms that will be
867 evaluated for each row in order to construct the table row tags.
869 During evaluation, these variables will be dynamically bound so that
872 `row-number': row number (0 is the first row)
873 `rowgroup-number': group number of current row
874 `start-rowgroup-p': non-nil means the row starts a group
875 `end-rowgroup-p': non-nil means the row ends a group
876 `top-row-p': non-nil means this is the top row
877 `bottom-row-p': non-nil means this is the bottom row
881 \(setq org-html-table-row-tags
882 (cons \\='(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
883 (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
884 (t (if (= (mod row-number 2) 1)
885 \"<tr class=\\\"tr-odd\\\">\"
886 \"<tr class=\\\"tr-even\\\">\")))
889 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
890 and the bottom row, and otherwise alternate between \"tr-odd\" and
891 \"tr-even\" for odd and even rows."
892 :group
'org-export-html
894 (choice :tag
"Opening tag"
895 (string :tag
"Specify")
897 (choice :tag
"Closing tag"
898 (string :tag
"Specify")
901 (defcustom org-html-table-align-individual-fields t
902 "Non-nil means attach style attributes for alignment to each table field.
903 When nil, alignment will only be specified in the column tags, but this
904 is ignored by some browsers (like Firefox, Safari). Opera does it right
906 :group
'org-export-html
909 (defcustom org-html-table-use-header-tags-for-first-column nil
910 "Non-nil means format column one in tables with header tags.
911 When nil, also column one will use data tags."
912 :group
'org-export-html
915 (defcustom org-html-table-caption-above t
916 "When non-nil, place caption string at the beginning of the table.
917 Otherwise, place it near the end."
918 :group
'org-export-html
923 (defcustom org-html-tag-class-prefix
""
924 "Prefix to class names for TODO keywords.
925 Each tag gets a class given by the tag itself, with this prefix.
926 The default prefix is empty because it is nice to just use the keyword
927 as a class name. But if you get into conflicts with other, existing
928 CSS classes, then this prefix can be very useful."
929 :group
'org-export-html
932 ;;;; Template :: Generic
934 (defcustom org-html-extension
"html"
935 "The extension for exported HTML files."
936 :group
'org-export-html
939 (defcustom org-html-xml-declaration
940 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
941 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
942 "The extension for exported HTML files.
943 %s will be replaced with the charset of the exported file.
944 This may be a string, or an alist with export extensions
945 and corresponding declarations.
947 This declaration only applies when exporting to XHTML."
948 :group
'org-export-html
950 (string :tag
"Single declaration")
951 (repeat :tag
"Dependent on extension"
952 (cons (string :tag
"Extension")
953 (string :tag
"Declaration")))))
955 (defcustom org-html-coding-system
'utf-8
956 "Coding system for HTML export.
957 Use utf-8 as the default value."
958 :group
'org-export-html
960 :package-version
'(Org .
"8.0")
961 :type
'coding-system
)
963 (defcustom org-html-doctype
"xhtml-strict"
964 "Document type definition to use for exported HTML files.
965 Can be set with the in-buffer HTML_DOCTYPE property or for
966 publishing, with :html-doctype."
967 :group
'org-export-html
969 :package-version
'(Org .
"8.0")
972 (mapcar (lambda (x) `(const ,(car x
))) org-html-doctype-alist
)
973 '((string :tag
"Custom doctype" ))))
975 (defcustom org-html-html5-fancy nil
976 "Non-nil means using new HTML5 elements.
977 This variable is ignored for anything other than HTML5 export.
979 For compatibility with Internet Explorer, it's probably a good
980 idea to download some form of the html5shiv (for instance
981 https://code.google.com/p/html5shiv/) and add it to your
982 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
983 versions 8 and below."
984 :group
'org-export-html
986 :package-version
'(Org .
"8.0")
989 (defcustom org-html-container-element
"div"
990 "HTML element to use for wrapping top level sections.
991 Can be set with the in-buffer HTML_CONTAINER property or for
992 publishing, with :html-container.
994 Note that changing the default will prevent you from using
995 org-info.js for your website."
996 :group
'org-export-html
998 :package-version
'(Org .
"8.0")
1001 (defcustom org-html-divs
1002 '((preamble "div" "preamble")
1003 (content "div" "content")
1004 (postamble "div" "postamble"))
1005 "Alist of the three section elements for HTML export.
1006 The car of each entry is one of `preamble', `content' or `postamble'.
1007 The cdrs of each entry are the ELEMENT_TYPE and ID for each
1008 section of the exported document.
1010 Note that changing the default will prevent you from using
1011 org-info.js for your website."
1012 :group
'org-export-html
1014 :package-version
'(Org .
"8.0")
1015 :type
'(list :greedy t
1016 (list :tag
"Preamble"
1017 (const :format
"" preamble
)
1018 (string :tag
"element") (string :tag
" id"))
1019 (list :tag
"Content"
1020 (const :format
"" content
)
1021 (string :tag
"element") (string :tag
" id"))
1022 (list :tag
"Postamble" (const :format
"" postamble
)
1023 (string :tag
" id") (string :tag
"element"))))
1025 (defconst org-html-checkbox-types
1027 ((on .
"☑") (off .
"☐") (trans .
"☐")))
1029 ((on .
"<code>[X]</code>")
1030 (off .
"<code>[ ]</code>")
1031 (trans .
"<code>[-]</code>")))
1033 ((on .
"<input type='checkbox' checked='checked' />")
1034 (off .
"<input type='checkbox' />")
1035 (trans .
"<input type='checkbox' />"))))
1036 "Alist of checkbox types.
1037 The cdr of each entry is an alist list three checkbox types for
1038 HTML export: `on', `off' and `trans'.
1041 `unicode' Unicode characters (HTML entities)
1042 `ascii' ASCII characters
1043 `html' HTML checkboxes
1045 Note that only the ascii characters implement tri-state
1046 checkboxes. The other two use the `off' checkbox for `trans'.")
1048 (defcustom org-html-checkbox-type
'ascii
1049 "The type of checkboxes to use for HTML export.
1050 See `org-html-checkbox-types' for for the values used for each
1052 :group
'org-export-html
1054 :package-version
'(Org .
"8.0")
1056 (const :tag
"ASCII characters" ascii
)
1057 (const :tag
"Unicode characters" unicode
)
1058 (const :tag
"HTML checkboxes" html
)))
1060 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
1061 "Format used for timestamps in preamble, postamble and metadata.
1062 See `format-time-string' for more information on its components."
1063 :group
'org-export-html
1065 :package-version
'(Org .
"8.0")
1068 ;;;; Template :: Mathjax
1070 (defcustom org-html-mathjax-options
1071 '((path "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" )
1075 (linebreaks "false")
1078 (multlinewidth "85%")
1081 "Options for MathJax setup.
1083 Alist of the following elements. All values are strings.
1085 path The path to MathJax.
1086 scale Scaling with HTML-CSS, MathML and SVG output engines.
1087 align How to align display math: left, center, or right.
1088 font The font to use with HTML-CSS and SVG output. As of MathJax 2.5
1089 the following values are understood: \"TeX\", \"STIX-Web\",
1090 \"Asana-Math\", \"Neo-Euler\", \"Gyre-Pagella\",
1091 \"Gyre-Termes\", and \"Latin-Modern\".
1092 linebreaks Let MathJax perform automatic linebreaks. Valid values
1093 are \"true\" and \"false\".
1094 indent If align is not center, how far from the left/right side?
1095 Valid values are \"left\" and \"right\"
1096 multlinewidth The width of the multline environment.
1097 autonumber How to number equations. Valid values are \"None\",
1098 \"all\" and \"AMS Math\".
1099 tagindent The amount tags are indented.
1100 tagside Which side to show tags/labels on. Valid values are
1101 \"left\" and \"right\"
1103 You can also customize this for each buffer, using something like
1105 #+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
1107 For further information about MathJax options, see the MathJax documentation:
1109 http://docs.mathjax.org/
1111 Please note that by using the default CDN one must agree with
1112 MathJax CDN Terms of Service.
1114 http://www.mathjax.org/mathjax-cdn-terms-of-service.html"
1115 :group
'org-export-html
1116 :package-version
'(Org .
"8.3")
1117 :type
'(list :greedy t
1118 (list :tag
"path (the path from where to load MathJax.js)"
1119 (const :format
" " path
) (string))
1120 (list :tag
"scale (scaling for the displayed math)"
1121 (const :format
" " scale
) (string))
1122 (list :tag
"align (alignment of displayed equations)"
1123 (const :format
" " align
) (string))
1124 (list :tag
"font (used to display math)"
1125 (const :format
" " font
)
1126 (choice (const "TeX")
1128 (const "Asana-Math")
1130 (const "Gyre-Pagella")
1131 (const "Gyre-Termes")
1132 (const "Latin-Modern")))
1133 (list :tag
"linebreaks (automatic line-breaking)"
1134 (const :format
" " linebreaks
)
1135 (choice (const "true")
1137 (list :tag
"autonumber (when should equations be numbered)"
1138 (const :format
" " autonumber
)
1139 (choice (const "AMS")
1142 (list :tag
"indent (indentation with left or right alignment)"
1143 (const :format
" " indent
) (string))
1144 (list :tag
"multlinewidth (width to use for the multline environment)"
1145 (const :format
" " multlinewidth
) (string))
1146 (list :tag
"tagindent (the indentation of tags from left or right)"
1147 (const :format
" " tagindent
) (string))
1148 (list :tag
"tagside (location of tags)"
1149 (const :format
" " tagside
)
1150 (choice (const "left")
1153 (defcustom org-html-mathjax-template
1154 "<script type=\"text/x-mathjax-config\">
1155 MathJax.Hub.Config({
1156 displayAlign: \"%ALIGN\",
1157 displayIndent: \"%INDENT\",
1159 \"HTML-CSS\": { scale: %SCALE,
1160 linebreaks: { automatic: \"%LINEBREAKS\" },
1163 SVG: {scale: %SCALE,
1164 linebreaks: { automatic: \"%LINEBREAKS\" },
1166 NativeMML: {scale: %SCALE},
1167 TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"},
1168 MultLineWidth: \"%MULTLINEWIDTH\",
1169 TagSide: \"%TAGSIDE\",
1170 TagIndent: \"%TAGINDENT\"
1174 <script type=\"text/javascript\"
1175 src=\"%PATH\"></script>"
1176 "The MathJax template. See also `org-html-mathjax-options'."
1177 :group
'org-export-html
1180 ;;;; Template :: Postamble
1182 (defcustom org-html-postamble
'auto
1183 "Non-nil means insert a postamble in HTML export.
1185 When set to `auto', check against the
1186 `org-export-with-author/email/creator/date' variables to set the
1187 content of the postamble. When set to a string, use this string
1188 as the postamble. When t, insert a string as defined by the
1189 formatting string in `org-html-postamble-format'.
1191 When set to a function, apply this function and insert the
1192 returned string. The function takes the property list of export
1193 options as its only argument.
1195 Setting :html-postamble in publishing projects will take
1196 precedence over this variable."
1197 :group
'org-export-html
1198 :type
'(choice (const :tag
"No postamble" nil
)
1199 (const :tag
"Auto postamble" auto
)
1200 (const :tag
"Default formatting string" t
)
1201 (string :tag
"Custom formatting string")
1202 (function :tag
"Function (must return a string)")))
1204 (defcustom org-html-postamble-format
1205 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1206 <p class=\"date\">Date: %d</p>
1207 <p class=\"creator\">%c</p>
1208 <p class=\"validation\">%v</p>"))
1209 "Alist of languages and format strings for the HTML postamble.
1211 The first element of each list is the language code, as used for
1212 the LANGUAGE keyword. See `org-export-default-language'.
1214 The second element of each list is a format string to format the
1215 postamble itself. This format string can contain these elements:
1217 %t stands for the title.
1218 %s stands for the subtitle.
1219 %a stands for the author's name.
1220 %e stands for the author's email.
1221 %d stands for the date.
1222 %c will be replaced by `org-html-creator-string'.
1223 %v will be replaced by `org-html-validation-link'.
1224 %T will be replaced by the export time.
1225 %C will be replaced by the last modification time.
1227 If you need to use a \"%\" character, you need to escape it
1229 :group
'org-export-html
1231 (list (string :tag
"Language")
1232 (string :tag
"Format string"))))
1234 (defcustom org-html-validation-link
1235 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1236 "Link to HTML validation service."
1237 :group
'org-export-html
1240 (defcustom org-html-creator-string
1241 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1243 (if (fboundp 'org-version
) (org-version) "unknown version"))
1244 "Information about the creator of the HTML document.
1245 This option can also be set on with the CREATOR keyword."
1246 :group
'org-export-html
1248 :package-version
'(Org .
"8.0")
1249 :type
'(string :tag
"Creator string"))
1251 ;;;; Template :: Preamble
1253 (defcustom org-html-preamble t
1254 "Non-nil means insert a preamble in HTML export.
1256 When t, insert a string as defined by the formatting string in
1257 `org-html-preamble-format'. When set to a string, use this
1258 formatting string instead (see `org-html-postamble-format' for an
1259 example of such a formatting string).
1261 When set to a function, apply this function and insert the
1262 returned string. The function takes the property list of export
1263 options as its only argument.
1265 Setting :html-preamble in publishing projects will take
1266 precedence over this variable."
1267 :group
'org-export-html
1268 :type
'(choice (const :tag
"No preamble" nil
)
1269 (const :tag
"Default preamble" t
)
1270 (string :tag
"Custom formatting string")
1271 (function :tag
"Function (must return a string)")))
1273 (defcustom org-html-preamble-format
'(("en" ""))
1274 "Alist of languages and format strings for the HTML preamble.
1276 The first element of each list is the language code, as used for
1277 the LANGUAGE keyword. See `org-export-default-language'.
1279 The second element of each list is a format string to format the
1280 preamble itself. This format string can contain these elements:
1282 %t stands for the title.
1283 %s stands for the subtitle.
1284 %a stands for the author's name.
1285 %e stands for the author's email.
1286 %d stands for the date.
1287 %c will be replaced by `org-html-creator-string'.
1288 %v will be replaced by `org-html-validation-link'.
1289 %T will be replaced by the export time.
1290 %C will be replaced by the last modification time.
1292 If you need to use a \"%\" character, you need to escape it
1295 See the default value of `org-html-postamble-format' for an
1297 :group
'org-export-html
1299 (list (string :tag
"Language")
1300 (string :tag
"Format string"))))
1302 (defcustom org-html-link-up
""
1303 "Where should the \"UP\" link of exported HTML pages lead?"
1304 :group
'org-export-html
1305 :type
'(string :tag
"File or URL"))
1307 (defcustom org-html-link-home
""
1308 "Where should the \"HOME\" link of exported HTML pages lead?"
1309 :group
'org-export-html
1310 :type
'(string :tag
"File or URL"))
1312 (defcustom org-html-link-use-abs-url nil
1313 "Should we prepend relative links with HTML_LINK_HOME?"
1314 :group
'org-export-html
1316 :package-version
'(Org .
"8.1")
1319 (defcustom org-html-home
/up-format
1320 "<div id=\"org-div-home-and-up\">
1321 <a accesskey=\"h\" href=\"%s\"> UP </a>
1323 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1325 "Snippet used to insert the HOME and UP links.
1326 This is a format string, the first %s will receive the UP link,
1327 the second the HOME link. If both `org-html-link-up' and
1328 `org-html-link-home' are empty, the entire snippet will be
1330 :group
'org-export-html
1333 ;;;; Template :: Scripts
1335 (define-obsolete-variable-alias
1336 'org-html-style-include-scripts
'org-html-head-include-scripts
"24.4")
1337 (defcustom org-html-head-include-scripts t
1338 "Non-nil means include the JavaScript snippets in exported HTML files.
1339 The actual script is defined in `org-html-scripts' and should
1341 :group
'org-export-html
1343 :package-version
'(Org .
"8.0")
1346 ;;;; Template :: Styles
1348 (define-obsolete-variable-alias
1349 'org-html-style-include-default
'org-html-head-include-default-style
"24.4")
1350 (defcustom org-html-head-include-default-style t
1351 "Non-nil means include the default style in exported HTML files.
1352 The actual style is defined in `org-html-style-default' and
1353 should not be modified. Use `org-html-head' to use your own
1355 :group
'org-export-html
1357 :package-version
'(Org .
"8.0")
1360 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1362 (define-obsolete-variable-alias 'org-html-style
'org-html-head
"24.4")
1363 (defcustom org-html-head
""
1364 "Org-wide head definitions for exported HTML files.
1366 This variable can contain the full HTML structure to provide a
1367 style, including the surrounding HTML tags. You can consider
1368 including definitions for the following classes: title, todo,
1369 done, timestamp, timestamp-kwd, tag, target.
1371 For example, a valid value would be:
1373 <style type=\"text/css\">
1375 p { font-weight: normal; color: gray; }
1376 h1 { color: black; }
1377 .title { text-align: center; }
1378 .todo, .timestamp-kwd { color: red; }
1379 .done { color: green; }
1383 If you want to refer to an external style, use something like
1385 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1387 As the value of this option simply gets inserted into the HTML
1388 <head> header, you can use it to add any arbitrary text to the
1391 You can set this on a per-file basis using #+HTML_HEAD:,
1392 or for publication projects using the :html-head property."
1393 :group
'org-export-html
1395 :package-version
'(Org .
"8.0")
1398 (put 'org-html-head
'safe-local-variable
'stringp
)
1400 (defcustom org-html-head-extra
""
1401 "More head information to add in the HTML output.
1403 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1404 or for publication projects using the :html-head-extra property."
1405 :group
'org-export-html
1407 :package-version
'(Org .
"8.0")
1410 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1412 ;;;; Template :: Viewport
1414 (defcustom org-html-viewport
'((width "device-width")
1419 "Viewport options for mobile-optimized sites.
1421 The following values are recognized
1423 width Size of the viewport.
1424 initial-scale Zoom level when the page is first loaded.
1425 minimum-scale Minimum allowed zoom level.
1426 maximum-scale Maximum allowed zoom level.
1427 user-scalable Whether zoom can be changed.
1429 The viewport meta tag is inserted if this variable is non-nil.
1431 See the following site for a reference:
1432 https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag"
1433 :group
'org-export-html
1435 :package-version
'(Org .
"8.3")
1436 :type
'(choice (const :tag
"Disable" nil
)
1438 (list :tag
"Width of viewport"
1439 (const :format
" " width
)
1440 (choice (const :tag
"unset" "")
1442 (list :tag
"Initial scale"
1443 (const :format
" " initial-scale
)
1444 (choice (const :tag
"unset" "")
1446 (list :tag
"Minimum scale/zoom"
1447 (const :format
" " minimum-scale
)
1448 (choice (const :tag
"unset" "")
1450 (list :tag
"Maximum scale/zoom"
1451 (const :format
" " maximum-scale
)
1452 (choice (const :tag
"unset" "")
1454 (list :tag
"User scalable/zoomable"
1455 (const :format
" " user-scalable
)
1456 (choice (const :tag
"unset" "")
1458 (const "false"))))))
1462 (defcustom org-html-todo-kwd-class-prefix
""
1463 "Prefix to class names for TODO keywords.
1464 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1465 The default prefix is empty because it is nice to just use the keyword
1466 as a class name. But if you get into conflicts with other, existing
1467 CSS classes, then this prefix can be very useful."
1468 :group
'org-export-html
1472 ;;; Internal Functions
1474 (defun org-html-xhtml-p (info)
1475 (let ((dt (downcase (plist-get info
:html-doctype
))))
1476 (string-match-p "xhtml" dt
)))
1478 (defun org-html-html5-p (info)
1479 (let ((dt (downcase (plist-get info
:html-doctype
))))
1480 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1482 (defun org-html--html5-fancy-p (info)
1483 "Non-nil when exporting to HTML5 with fancy elements.
1484 INFO is the current state of the export process, as a plist."
1485 (and (plist-get info
:html-html5-fancy
)
1486 (org-html-html5-p info
)))
1488 (defun org-html-close-tag (tag attr info
)
1489 (concat "<" tag
" " attr
1490 (if (org-html-xhtml-p info
) " />" ">")))
1492 (defun org-html-doctype (info)
1493 "Return correct html doctype tag from `org-html-doctype-alist',
1494 or the literal value of :html-doctype from INFO if :html-doctype
1495 is not found in the alist.
1496 INFO is a plist used as a communication channel."
1497 (let ((dt (plist-get info
:html-doctype
)))
1498 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1500 (defun org-html--make-attribute-string (attributes)
1501 "Return a list of attributes, as a string.
1502 ATTRIBUTES is a plist where values are either strings or nil. An
1503 attributes with a nil value will be omitted from the result."
1505 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1506 (cond ((null item
) (pop output
))
1507 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1508 (t (let ((key (car output
))
1509 (value (replace-regexp-in-string
1510 "\"" """ (org-html-encode-plain-text item
))))
1511 (setcar output
(format "%s=\"%s\"" key value
))))))))
1513 (defun org-html--wrap-image (contents info
&optional caption label
)
1514 "Wrap CONTENTS string within an appropriate environment for images.
1515 INFO is a plist used as a communication channel. When optional
1516 arguments CAPTION and LABEL are given, use them for caption and
1518 (let ((html5-fancy (org-html--html5-fancy-p info
)))
1519 (format (if html5-fancy
"\n<figure%s>%s%s\n</figure>"
1520 "\n<div%s class=\"figure\">%s%s\n</div>")
1522 (if (org-string-nw-p label
) (format " id=\"%s\"" label
) "")
1524 (format "\n<p>%s</p>" contents
)
1526 (if (not (org-string-nw-p caption
)) ""
1527 (format (if html5-fancy
"\n<figcaption>%s</figcaption>"
1531 (defun org-html--format-image (source attributes info
)
1532 "Return \"img\" tag with given SOURCE and ATTRIBUTES.
1533 SOURCE is a string specifying the location of the image.
1534 ATTRIBUTES is a plist, as returned by
1535 `org-export-read-attribute'. INFO is a plist used as
1536 a communication channel."
1537 (if (string= "svg" (file-name-extension source
))
1538 (org-html--svg-image source attributes info
)
1541 (org-html--make-attribute-string
1544 :alt
(if (string-match-p "^ltxpng/" source
)
1545 (org-html-encode-plain-text
1546 (org-find-text-property-in-string 'org-latex-src source
))
1547 (file-name-nondirectory source
)))
1551 (defun org-html--svg-image (source attributes info
)
1552 "Return \"object\" appropriate for embedding svg file SOURCE
1553 with assoicated ATTRIBUTES. INFO is a plist used as a
1554 communication channel.
1556 The special attribute \"fallback\" can be used to specify a fallback
1557 image file to use if the object embedding is not supported."
1558 (let ((fallback (plist-get attributes
:fallback
))
1559 (attrs (org-html--make-attribute-string
1560 (plist-put attributes
:fallback nil
))))
1561 (format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>"
1565 "img" (format "src=\"%s\" %s" fallback attrs
) info
)
1566 "Sorry, your browser does not support SVG."))))
1568 (defun org-html--textarea-block (element)
1569 "Transcode ELEMENT into a textarea block.
1570 ELEMENT is either a src block or an example block."
1571 (let* ((code (car (org-export-unravel-code element
)))
1572 (attr (org-export-read-attribute :attr_html element
)))
1573 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1574 (or (plist-get attr
:width
) 80)
1575 (or (plist-get attr
:height
) (org-count-lines code
))
1578 (defun org-html--has-caption-p (element &optional _info
)
1579 "Non-nil when ELEMENT has a caption affiliated keyword.
1580 INFO is a plist used as a communication channel. This function
1581 is meant to be used as a predicate for `org-export-get-ordinal' or
1582 a value to `org-html-standalone-image-predicate'."
1583 (org-element-property :caption element
))
1587 (defun org-html-htmlize-region-for-paste (beg end
)
1588 "Convert the region between BEG and END to HTML, using htmlize.el.
1589 This is much like `htmlize-region-for-paste', only that it uses
1590 the settings define in the org-... variables."
1591 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1592 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1593 (htmlbuf (htmlize-region beg end
)))
1595 (with-current-buffer htmlbuf
1596 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1597 (plist-get htmlize-buffer-places
'content-end
)))
1598 (kill-buffer htmlbuf
))))
1601 (defun org-html-htmlize-generate-css ()
1602 "Create the CSS for all font definitions in the current Emacs session.
1603 Use this to create face definitions in your CSS style file that can then
1604 be used by code snippets transformed by htmlize.
1605 This command just produces a buffer that contains class definitions for all
1606 faces used in the current Emacs session. You can copy and paste the ones you
1607 need into your CSS file.
1609 If you then set `org-html-htmlize-output-type' to `css', calls
1610 to the function `org-html-htmlize-region-for-paste' will
1611 produce code that uses these same face definitions."
1614 (and (get-buffer "*html*") (kill-buffer "*html*"))
1616 (let ((fl (face-list))
1617 (htmlize-css-name-prefix "org-")
1618 (htmlize-output-type 'css
)
1620 (while (setq f
(pop fl
)
1621 i
(and f
(face-attribute f
:inherit
)))
1622 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1623 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1624 (htmlize-region (point-min) (point-max))))
1625 (org-pop-to-buffer-same-window "*html*")
1626 (goto-char (point-min))
1627 (if (re-search-forward "<style" nil t
)
1628 (delete-region (point-min) (match-beginning 0)))
1629 (if (re-search-forward "</style>" nil t
)
1630 (delete-region (1+ (match-end 0)) (point-max)))
1631 (beginning-of-line 1)
1632 (if (looking-at " +") (replace-match ""))
1633 (goto-char (point-min)))
1635 (defun org-html--make-string (n string
)
1636 "Build a string by concatenating N times STRING."
1637 (let (out) (dotimes (_ n out
) (setq out
(concat string out
)))))
1639 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1640 "Turn todo keyword KWD into a valid class name.
1641 Replaces invalid characters with \"_\"."
1643 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1644 (setq kwd
(replace-match "_" t t kwd
))))
1647 (defun org-html-footnote-section (info)
1648 "Format the footnote section.
1649 INFO is a plist used as a communication channel."
1650 (let* ((fn-alist (org-export-collect-footnote-definitions info
))
1652 (loop for
(n _type raw
) in fn-alist collect
1653 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1654 (org-trim (org-export-data raw info
))
1655 (format "<div class=\"footpara\">%s</div>"
1656 (org-trim (org-export-data raw info
))))))))
1659 (plist-get info
:html-footnotes-section
)
1660 (org-html--translate "Footnotes" info
)
1665 (let ((n (car fn
)) (def (cdr fn
)))
1667 "<div class=\"footdef\">%s %s</div>\n"
1669 (plist-get info
:html-footnote-format
)
1673 (format " class=\"footnum\" href=\"#fnr.%d\"" n
)
1682 (defun org-html--build-meta-info (info)
1683 "Return meta tags for exported document.
1684 INFO is a plist used as a communication channel."
1685 (let ((protect-string
1687 (replace-regexp-in-string
1688 "\"" """ (org-html-encode-plain-text str
))))
1689 (title (org-export-data (plist-get info
:title
) info
))
1690 (author (and (plist-get info
:with-author
)
1691 (let ((auth (plist-get info
:author
)))
1693 ;; Return raw Org syntax, skipping non
1694 ;; exportable objects.
1695 (org-element-interpret-data
1696 (org-element-map auth
1697 (cons 'plain-text org-element-all-objects
)
1698 'identity info
))))))
1699 (description (plist-get info
:description
))
1700 (keywords (plist-get info
:keywords
))
1701 (charset (or (and org-html-coding-system
1702 (fboundp 'coding-system-get
)
1703 (coding-system-get org-html-coding-system
1707 (when (plist-get info
:time-stamp-file
)
1710 (plist-get info
:html-metadata-timestamp-format
)
1713 (if (org-html-html5-p info
)
1714 (org-html-close-tag "meta" " charset=\"%s\"" info
)
1716 "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1719 (let ((viewport-options
1720 (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell
)))
1721 (plist-get info
:html-viewport
))))
1722 (and viewport-options
1726 (format " name=\"viewport\" content=\"%s\""
1728 (lambda (elm) (format "%s=%s" (car elm
) (cadr elm
)))
1729 viewport-options
", "))
1732 (format "<title>%s</title>\n" title
)
1733 (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info
)
1735 (and (org-string-nw-p author
)
1737 (org-html-close-tag "meta"
1738 (format " name=\"author\" content=\"%s\""
1739 (funcall protect-string author
))
1742 (and (org-string-nw-p description
)
1744 (org-html-close-tag "meta"
1745 (format " name=\"description\" content=\"%s\"\n"
1746 (funcall protect-string description
))
1749 (and (org-string-nw-p keywords
)
1751 (org-html-close-tag "meta"
1752 (format " name=\"keywords\" content=\"%s\""
1753 (funcall protect-string keywords
))
1757 (defun org-html--build-head (info)
1758 "Return information for the <head>..</head> of the HTML output.
1759 INFO is a plist used as a communication channel."
1760 (org-element-normalize-string
1762 (when (plist-get info
:html-head-include-default-style
)
1763 (org-element-normalize-string org-html-style-default
))
1764 (org-element-normalize-string (plist-get info
:html-head
))
1765 (org-element-normalize-string (plist-get info
:html-head-extra
))
1766 (when (and (plist-get info
:html-htmlized-css-url
)
1767 (eq org-html-htmlize-output-type
'css
))
1768 (org-html-close-tag "link"
1769 (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1770 (plist-get info
:html-htmlized-css-url
))
1772 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1774 (defun org-html--build-mathjax-config (info)
1775 "Insert the user setup into the mathjax template.
1776 INFO is a plist used as a communication channel."
1777 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1778 (org-element-map (plist-get info
:parse-tree
)
1779 '(latex-fragment latex-environment
) 'identity info t
))
1780 (let ((template (plist-get info
:html-mathjax-template
))
1781 (options (plist-get info
:html-mathjax-options
))
1782 (in-buffer (or (plist-get info
:html-mathjax
) "")))
1783 (dolist (e options
(org-element-normalize-string template
))
1784 (let ((name (car e
))
1786 (when (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1788 (car (read-from-string (substring in-buffer
(match-end 0))))))
1789 (unless (stringp val
) (setq val
(format "%s" val
)))
1790 (while (string-match (concat "%" (upcase (symbol-name name
)))
1792 (setq template
(replace-match val t t template
))))))))
1794 (defun org-html-format-spec (info)
1795 "Return format specification for elements that can be
1796 used in the preamble or postamble."
1797 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1798 (?s .
,(org-export-data (plist-get info
:subtitle
) info
))
1799 (?d .
,(org-export-data (org-export-get-date info
) info
))
1800 (?T .
,(format-time-string
1801 (plist-get info
:html-metadata-timestamp-format
)))
1802 (?a .
,(org-export-data (plist-get info
:author
) info
))
1805 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1806 (split-string (plist-get info
:email
) ",+ *")
1808 (?c .
,(plist-get info
:creator
))
1809 (?C .
,(let ((file (plist-get info
:input-file
)))
1811 (plist-get info
:html-metadata-timestamp-format
)
1812 (when file
(nth 5 (file-attributes file
))))))
1813 (?v .
,(or (plist-get info
:html-validation-link
) ""))))
1815 (defun org-html--build-pre/postamble
(type info
)
1816 "Return document preamble or postamble as a string, or nil.
1817 TYPE is either `preamble' or `postamble', INFO is a plist used as a
1818 communication channel."
1819 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1820 (spec (org-html-format-spec info
)))
1822 (let ((section-contents
1823 (if (functionp section
) (funcall section info
)
1825 ((stringp section
) (format-spec section spec
))
1827 (let ((date (cdr (assq ?d spec
)))
1828 (author (cdr (assq ?a spec
)))
1829 (email (cdr (assq ?e spec
)))
1830 (creator (cdr (assq ?c spec
)))
1831 (validation-link (cdr (assq ?v spec
))))
1833 (when (and (plist-get info
:with-date
)
1834 (org-string-nw-p date
))
1835 (format "<p class=\"date\">%s: %s</p>\n"
1836 (org-html--translate "Date" info
)
1838 (when (and (plist-get info
:with-author
)
1839 (org-string-nw-p author
))
1840 (format "<p class=\"author\">%s: %s</p>\n"
1841 (org-html--translate "Author" info
)
1843 (when (and (plist-get info
:with-email
)
1844 (org-string-nw-p email
))
1845 (format "<p class=\"email\">%s: %s</p>\n"
1846 (org-html--translate "Email" info
)
1848 (when (plist-get info
:time-stamp-file
)
1850 "<p class=\"date\">%s: %s</p>\n"
1851 (org-html--translate "Created" info
)
1853 (plist-get info
:html-metadata-timestamp-format
))))
1854 (when (plist-get info
:with-creator
)
1855 (format "<p class=\"creator\">%s</p>\n" creator
))
1856 (format "<p class=\"validation\">%s</p>\n"
1860 (plist-get info
:language
)
1862 (format "org-html-%s-format" type
)))))
1867 (intern (format "org-html-%s-format" type
))))))
1869 (let ((div (assq type
(plist-get info
:html-divs
))))
1870 (when (org-string-nw-p section-contents
)
1872 (format "<%s id=\"%s\" class=\"%s\">\n"
1875 org-html--pre
/postamble-class
)
1876 (org-element-normalize-string section-contents
)
1877 (format "</%s>\n" (nth 1 div
)))))))))
1879 (defun org-html-inner-template (contents info
)
1880 "Return body of document string after HTML conversion.
1881 CONTENTS is the transcoded contents string. INFO is a plist
1882 holding export options."
1884 ;; Table of contents.
1885 (let ((depth (plist-get info
:with-toc
)))
1886 (when depth
(org-html-toc depth info
)))
1887 ;; Document contents.
1889 ;; Footnotes section.
1890 (org-html-footnote-section info
)))
1892 (defun org-html-template (contents info
)
1893 "Return complete document string after HTML conversion.
1894 CONTENTS is the transcoded contents string. INFO is a plist
1895 holding export options."
1897 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1898 (let* ((xml-declaration (plist-get info
:html-xml-declaration
))
1899 (decl (or (and (stringp xml-declaration
) xml-declaration
)
1900 (cdr (assoc (plist-get info
:html-extension
)
1902 (cdr (assoc "html" xml-declaration
))
1904 (when (not (or (not decl
) (string= "" decl
)))
1907 (or (and org-html-coding-system
1908 (fboundp 'coding-system-get
)
1909 (coding-system-get org-html-coding-system
'mime-charset
))
1911 (org-html-doctype info
)
1914 (when (org-html-xhtml-p info
)
1916 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1917 (plist-get info
:language
) (plist-get info
:language
)))
1920 (org-html--build-meta-info info
)
1921 (org-html--build-head info
)
1922 (org-html--build-mathjax-config info
)
1925 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1926 (link-home (org-trim (plist-get info
:html-link-home
))))
1927 (unless (and (string= link-up
"") (string= link-home
""))
1928 (format (plist-get info
:html-home
/up-format
)
1929 (or link-up link-home
)
1930 (or link-home link-up
))))
1932 (org-html--build-pre/postamble
'preamble info
)
1933 ;; Document contents.
1934 (let ((div (assq 'content
(plist-get info
:html-divs
))))
1935 (format "<%s id=\"%s\">\n" (nth 1 div
) (nth 2 div
)))
1937 (when (plist-get info
:with-title
)
1938 (let ((title (plist-get info
:title
))
1939 (subtitle (plist-get info
:subtitle
))
1940 (html5-fancy (org-html--html5-fancy-p info
)))
1944 "<header>\n<h1 class=\"title\">%s</h1>\n%s</header>"
1945 "<h1 class=\"title\">%s%s</h1>\n")
1946 (org-export-data title info
)
1950 "<p class=\"subtitle\">%s</p>\n"
1951 "\n<br>\n<span class=\"subtitle\">%s</span>\n")
1952 (org-export-data subtitle info
))
1955 (format "</%s>\n" (nth 1 (assq 'content
(plist-get info
:html-divs
))))
1957 (org-html--build-pre/postamble
'postamble info
)
1958 ;; Closing document.
1959 "</body>\n</html>"))
1961 (defun org-html--translate (s info
)
1962 "Translate string S according to specified language.
1963 INFO is a plist used as a communication channel."
1964 (org-export-translate s
:html info
))
1968 (defun org-html--anchor (id desc attributes info
)
1969 "Format a HTML anchor."
1970 (let* ((name (and (plist-get info
:html-allow-name-attribute-in-anchors
) id
))
1971 (attributes (concat (and id
(format " id=\"%s\"" id
))
1972 (and name
(format " name=\"%s\"" name
))
1974 (format "<a%s>%s</a>" attributes
(or desc
""))))
1978 (defun org-html--todo (todo info
)
1979 "Format TODO keywords into HTML."
1981 (format "<span class=\"%s %s%s\">%s</span>"
1982 (if (member todo org-done-keywords
) "done" "todo")
1983 (plist-get info
:html-todo-kwd-class-prefix
)
1984 (org-html-fix-class-name todo
)
1989 (defun org-html--priority (priority _info
)
1990 "Format a priority into HTML.
1991 PRIORITY is the character code of the priority or nil. INFO is
1992 a plist containing export options."
1993 (and priority
(format "<span class=\"priority\">[%c]</span>" priority
)))
1997 (defun org-html--tags (tags info
)
1998 "Format TAGS into HTML.
1999 INFO is a plist containing export options."
2001 (format "<span class=\"tag\">%s</span>"
2004 (format "<span class=\"%s\">%s</span>"
2005 (concat (plist-get info
:html-tag-class-prefix
)
2006 (org-html-fix-class-name tag
))
2012 (defun org-html-fontify-code (code lang
)
2013 "Color CODE with htmlize library.
2014 CODE is a string representing the source code to colorize. LANG
2015 is the language used for CODE, as a string, or nil."
2018 ;; Case 1: No lang. Possibly an example block.
2020 ;; Simple transcoding.
2021 (org-html-encode-plain-text code
))
2022 ;; Case 2: No htmlize or an inferior version of htmlize
2023 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
2025 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
2026 ;; Simple transcoding.
2027 (org-html-encode-plain-text code
))
2028 ;; Case 3: plain text explicitly set
2029 ((not org-html-htmlize-output-type
)
2030 ;; Simple transcoding.
2031 (org-html-encode-plain-text code
))
2034 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
2035 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
2037 ;; Case 1: Language is not associated with any Emacs mode
2038 ((not (functionp lang-mode
))
2039 ;; Simple transcoding.
2040 (org-html-encode-plain-text code
))
2041 ;; Case 2: Default. Fontify code.
2045 (let ((output-type org-html-htmlize-output-type
)
2046 (font-prefix org-html-htmlize-font-prefix
))
2048 ;; Switch to language-specific mode.
2053 ;; Remove formatting on newline characters.
2055 (let ((beg (point-min))
2058 (while (progn (end-of-line) (< (point) end
))
2059 (put-text-property (point) (1+ (point)) 'face nil
)
2062 (set-buffer-modified-p nil
)
2064 (let ((org-html-htmlize-output-type output-type
)
2065 (org-html-htmlize-font-prefix font-prefix
))
2066 (org-html-htmlize-region-for-paste
2067 (point-min) (point-max))))))
2068 ;; Strip any enclosing <pre></pre> tags.
2069 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
2070 (end (and beg
(string-match "</pre>\\'" code
))))
2071 (if (and beg end
) (substring code beg end
) code
)))))))))
2073 (defun org-html-do-format-code
2074 (code &optional lang refs retain-labels num-start
)
2075 "Format CODE string as source code.
2076 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
2077 respectively, the language of the source code, as a string, an
2078 alist between line numbers and references (as returned by
2079 `org-export-unravel-code'), a boolean specifying if labels should
2080 appear in the source code, and the number associated to the first
2082 (let* ((code-lines (org-split-string code
"\n"))
2083 (code-length (length code-lines
))
2087 (length (number-to-string (+ code-length num-start
))))))
2088 (code (org-html-fontify-code code lang
)))
2089 (org-export-format-code
2091 (lambda (loc line-num ref
)
2094 ;; Add line number, if needed.
2096 (format "<span class=\"linenr\">%s</span>"
2097 (format num-fmt line-num
)))
2098 ;; Transcoded src line.
2100 ;; Add label, if needed.
2101 (when (and ref retain-labels
) (format " (%s)" ref
))))
2102 ;; Mark transcoded line as an anchor, if needed.
2104 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
2108 (defun org-html-format-code (element info
)
2109 "Format contents of ELEMENT as source code.
2110 ELEMENT is either an example block or a src block. INFO is
2111 a plist used as a communication channel."
2112 (let* ((lang (org-element-property :language element
))
2113 ;; Extract code and references.
2114 (code-info (org-export-unravel-code element
))
2115 (code (car code-info
))
2116 (refs (cdr code-info
))
2117 ;; Does the src block contain labels?
2118 (retain-labels (org-element-property :retain-labels element
))
2119 ;; Does it have line numbers?
2120 (num-start (case (org-element-property :number-lines element
)
2121 (continued (org-export-get-loc element info
))
2123 (org-html-do-format-code code lang refs retain-labels num-start
)))
2126 ;;; Tables of Contents
2128 (defun org-html-toc (depth info
&optional scope
)
2129 "Build a table of contents.
2130 DEPTH is an integer specifying the depth of the table. INFO is
2131 a plist used as a communication channel. Optional argument SCOPE
2132 is an element defining the scope of the table. Return the table
2133 of contents as a string, or nil if it is empty."
2135 (mapcar (lambda (headline)
2136 (cons (org-html--format-toc-headline headline info
)
2137 (org-export-get-relative-level headline info
)))
2138 (org-export-collect-headlines info depth scope
))))
2140 (let ((toc (concat "<div id=\"text-table-of-contents\">"
2141 (org-html--toc-text toc-entries
)
2144 (let ((outer-tag (if (org-html--html5-fancy-p info
)
2147 (concat (format "<%s id=\"table-of-contents\">\n" outer-tag
)
2148 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2149 (format "<h%d>%s</h%d>\n"
2151 (org-html--translate "Table of Contents" info
)
2154 (format "</%s>\n" outer-tag
))))))))
2156 (defun org-html--toc-text (toc-entries)
2157 "Return innards of a table of contents, as a string.
2158 TOC-ENTRIES is an alist where key is an entry title, as a string,
2159 and value is its relative level, as an integer."
2160 (let* ((prev-level (1- (cdar toc-entries
)))
2161 (start-level prev-level
))
2165 (let ((headline (car entry
))
2166 (level (cdr entry
)))
2168 (let* ((cnt (- level prev-level
))
2169 (times (if (> cnt
0) (1- cnt
) (- cnt
))))
2170 (setq prev-level level
)
2172 (org-html--make-string
2173 times
(cond ((> cnt
0) "\n<ul>\n<li>")
2174 ((< cnt
0) "</li>\n</ul>\n")))
2175 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
2178 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
2180 (defun org-html--format-toc-headline (headline info
)
2181 "Return an appropriate table of contents entry for HEADLINE.
2182 INFO is a plist used as a communication channel."
2183 (let* ((headline-number (org-export-get-headline-number headline info
))
2184 (todo (and (plist-get info
:with-todo-keywords
)
2185 (let ((todo (org-element-property :todo-keyword headline
)))
2186 (and todo
(org-export-data todo info
)))))
2187 (todo-type (and todo
(org-element-property :todo-type headline
)))
2188 (priority (and (plist-get info
:with-priority
)
2189 (org-element-property :priority headline
)))
2190 (text (org-export-data-with-backend
2191 (org-export-get-alt-title headline info
)
2192 ;; Create an anonymous back-end that will ignore any
2193 ;; footnote-reference, link, radio-target and target
2194 ;; in table of contents.
2195 (org-export-create-backend
2197 :transcoders
'((footnote-reference . ignore
)
2198 (link .
(lambda (object c i
) c
))
2199 (radio-target .
(lambda (object c i
) c
))
2202 (tags (and (eq (plist-get info
:with-tags
) t
)
2203 (org-export-get-tags headline info
))))
2204 (format "<a href=\"#%s\">%s</a>"
2206 (or (org-element-property :CUSTOM_ID headline
)
2207 (org-export-get-reference headline info
))
2210 (and (not (org-export-low-level-p headline info
))
2211 (org-export-numbered-headline-p headline info
)
2212 (concat (mapconcat #'number-to-string headline-number
".")
2214 (apply (plist-get info
:html-format-headline-function
)
2215 todo todo-type priority text tags
:section-number nil
)))))
2217 (defun org-html-list-of-listings (info)
2218 "Build a list of listings.
2219 INFO is a plist used as a communication channel. Return the list
2220 of listings as a string, or nil if it is empty."
2221 (let ((lol-entries (org-export-collect-listings info
)))
2223 (concat "<div id=\"list-of-listings\">\n"
2224 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2225 (format "<h%d>%s</h%d>\n"
2227 (org-html--translate "List of Listings" info
)
2229 "<div id=\"text-list-of-listings\">\n<ul>\n"
2231 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2232 (org-html--translate "Listing %d:" info
))))
2235 (let ((label (and (org-element-property :name entry
)
2236 (org-export-get-reference entry info
)))
2239 (or (org-export-get-caption entry t
)
2240 (org-export-get-caption entry
))
2245 (concat (format initial-fmt
(incf count
)) " " title
)
2246 (format "<a href=\"#%s\">%s %s</a>"
2248 (format initial-fmt
(incf count
))
2252 "\n</ul>\n</div>\n</div>"))))
2254 (defun org-html-list-of-tables (info)
2255 "Build a list of tables.
2256 INFO is a plist used as a communication channel. Return the list
2257 of tables as a string, or nil if it is empty."
2258 (let ((lol-entries (org-export-collect-tables info
)))
2260 (concat "<div id=\"list-of-tables\">\n"
2261 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2262 (format "<h%d>%s</h%d>\n"
2264 (org-html--translate "List of Tables" info
)
2266 "<div id=\"text-list-of-tables\">\n<ul>\n"
2268 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2269 (org-html--translate "Table %d:" info
))))
2272 (let ((label (and (org-element-property :name entry
)
2273 (org-export-get-reference entry info
)))
2276 (or (org-export-get-caption entry t
)
2277 (org-export-get-caption entry
))
2282 (concat (format initial-fmt
(incf count
)) " " title
)
2283 (format "<a href=\"#%s\">%s %s</a>"
2285 (format initial-fmt
(incf count
))
2289 "\n</ul>\n</div>\n</div>"))))
2292 ;;; Transcode Functions
2296 (defun org-html-bold (_bold contents info
)
2297 "Transcode BOLD from Org to HTML.
2298 CONTENTS is the text with bold markup. INFO is a plist holding
2299 contextual information."
2300 (format (or (cdr (assq 'bold
(plist-get info
:html-text-markup-alist
))) "%s")
2305 (defun org-html-center-block (_center-block contents _info
)
2306 "Transcode a CENTER-BLOCK element from Org to HTML.
2307 CONTENTS holds the contents of the block. INFO is a plist
2308 holding contextual information."
2309 (format "<div class=\"org-center\">\n%s</div>" contents
))
2313 (defun org-html-clock (clock _contents _info
)
2314 "Transcode a CLOCK element from Org to HTML.
2315 CONTENTS is nil. INFO is a plist used as a communication
2318 <span class=\"timestamp-wrapper\">
2319 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2323 (org-timestamp-translate (org-element-property :value clock
))
2324 (let ((time (org-element-property :duration clock
)))
2325 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2329 (defun org-html-code (code _contents info
)
2330 "Transcode CODE from Org to HTML.
2331 CONTENTS is nil. INFO is a plist holding contextual
2333 (format (or (cdr (assq 'code
(plist-get info
:html-text-markup-alist
))) "%s")
2334 (org-html-encode-plain-text (org-element-property :value code
))))
2338 (defun org-html-drawer (drawer contents info
)
2339 "Transcode a DRAWER element from Org to HTML.
2340 CONTENTS holds the contents of the block. INFO is a plist
2341 holding contextual information."
2342 (funcall (plist-get info
:html-format-drawer-function
)
2343 (org-element-property :drawer-name drawer
)
2348 (defun org-html-dynamic-block (_dynamic-block contents _info
)
2349 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2350 CONTENTS holds the contents of the block. INFO is a plist
2351 holding contextual information. See `org-export-data'."
2356 (defun org-html-entity (entity _contents _info
)
2357 "Transcode an ENTITY object from Org to HTML.
2358 CONTENTS are the definition itself. INFO is a plist holding
2359 contextual information."
2360 (org-element-property :html entity
))
2364 (defun org-html-example-block (example-block _contents info
)
2365 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2366 CONTENTS is nil. INFO is a plist holding contextual
2368 (if (org-export-read-attribute :attr_html example-block
:textarea
)
2369 (org-html--textarea-block example-block
)
2370 (format "<pre class=\"example\">\n%s</pre>"
2371 (org-html-format-code example-block info
))))
2375 (defun org-html-export-snippet (export-snippet _contents _info
)
2376 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2377 CONTENTS is nil. INFO is a plist holding contextual
2379 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2380 (org-element-property :value export-snippet
)))
2384 (defun org-html-export-block (export-block _contents _info
)
2385 "Transcode a EXPORT-BLOCK element from Org to HTML.
2386 CONTENTS is nil. INFO is a plist holding contextual information."
2387 (when (string= (org-element-property :type export-block
) "HTML")
2388 (org-remove-indentation (org-element-property :value export-block
))))
2392 (defun org-html-fixed-width (fixed-width _contents _info
)
2393 "Transcode a FIXED-WIDTH element from Org to HTML.
2394 CONTENTS is nil. INFO is a plist holding contextual information."
2395 (format "<pre class=\"example\">\n%s</pre>"
2396 (org-html-do-format-code
2397 (org-remove-indentation
2398 (org-element-property :value fixed-width
)))))
2400 ;;;; Footnote Reference
2402 (defun org-html-footnote-reference (footnote-reference _contents info
)
2403 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2404 CONTENTS is nil. INFO is a plist holding contextual information."
2406 ;; Insert separator between two footnotes in a row.
2407 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2408 (when (eq (org-element-type prev
) 'footnote-reference
)
2409 (plist-get info
:html-footnote-separator
)))
2410 (let* ((n (org-export-get-footnote-number footnote-reference info
))
2411 (id (format "fnr.%d%s"
2413 (if (org-export-footnote-first-reference-p
2414 footnote-reference info
)
2418 (plist-get info
:html-footnote-format
)
2420 id n
(format " class=\"footref\" href=\"#fn.%d\"" n
) info
)))))
2424 (defun org-html-headline (headline contents info
)
2425 "Transcode a HEADLINE element from Org to HTML.
2426 CONTENTS holds the contents of the headline. INFO is a plist
2427 holding contextual information."
2428 (unless (org-element-property :footnote-section-p headline
)
2429 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2430 (numbers (org-export-get-headline-number headline info
))
2431 (level (+ (org-export-get-relative-level headline info
)
2432 (1- (plist-get info
:html-toplevel-hlevel
))))
2433 (todo (and (plist-get info
:with-todo-keywords
)
2434 (let ((todo (org-element-property :todo-keyword headline
)))
2435 (and todo
(org-export-data todo info
)))))
2436 (todo-type (and todo
(org-element-property :todo-type headline
)))
2437 (priority (and (plist-get info
:with-priority
)
2438 (org-element-property :priority headline
)))
2439 (text (org-export-data (org-element-property :title headline
) info
))
2440 (tags (and (plist-get info
:with-tags
)
2441 (org-export-get-tags headline info
)))
2442 (full-text (funcall (plist-get info
:html-format-headline-function
)
2443 todo todo-type priority text tags info
))
2444 (contents (or contents
""))
2446 (list (org-element-property :CUSTOM_ID headline
)
2447 (org-export-get-reference headline info
)
2448 (org-element-property :ID headline
))))
2449 (preferred-id (car ids
))
2454 (if (org-uuidgen-p id
) (concat "ID-" id
) id
)
2457 (if (org-export-low-level-p headline info
)
2458 ;; This is a deep sub-tree: export it as a list item.
2459 (let* ((type (if numberedp
'ordered
'unordered
))
2461 (org-html-format-list-item
2462 contents type nil info nil
2463 (concat (org-html--anchor preferred-id nil nil info
)
2466 (concat (and (org-export-first-sibling-p headline info
)
2467 (org-html-begin-plain-list type
))
2469 (and (org-export-last-sibling-p headline info
)
2470 (org-html-end-plain-list type
))))
2471 (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2472 (first-content (car (org-element-contents headline
))))
2473 ;; Standard headline. Export it as a section.
2474 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2475 (org-html--container headline info
)
2476 (concat "outline-container-"
2477 (org-export-get-reference headline info
))
2478 (concat (format "outline-%d" level
)
2479 (and extra-class
" ")
2481 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2488 "<span class=\"section-number-%d\">%s</span> "
2490 (mapconcat #'number-to-string numbers
".")))
2493 ;; When there is no section, pretend there is an
2494 ;; empty one to get the correct <div
2495 ;; class="outline-...> which is needed by
2497 (if (eq (org-element-type first-content
) 'section
) contents
2498 (concat (org-html-section first-content
"" info
) contents
))
2499 (org-html--container headline info
)))))))
2501 (defun org-html-format-headline-default-function
2502 (todo _todo-type priority text tags info
)
2503 "Default format function for a headline.
2504 See `org-html-format-headline-function' for details."
2505 (let ((todo (org-html--todo todo info
))
2506 (priority (org-html--priority priority info
))
2507 (tags (org-html--tags tags info
)))
2508 (concat todo
(and todo
" ")
2509 priority
(and priority
" ")
2511 (and tags
"   ") tags
)))
2513 (defun org-html--container (headline info
)
2514 (or (org-element-property :HTML_CONTAINER headline
)
2515 (if (= 1 (org-export-get-relative-level headline info
))
2516 (plist-get info
:html-container
)
2519 ;;;; Horizontal Rule
2521 (defun org-html-horizontal-rule (_horizontal-rule _contents info
)
2522 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2523 CONTENTS is nil. INFO is a plist holding contextual information."
2524 (org-html-close-tag "hr" nil info
))
2526 ;;;; Inline Src Block
2528 (defun org-html-inline-src-block (inline-src-block _contents info
)
2529 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2530 CONTENTS holds the contents of the item. INFO is a plist holding
2531 contextual information."
2532 (let ((lang (org-element-property :language inline-src-block
))
2533 (code (org-html-format-code inline-src-block info
))
2535 (let ((lbl (and (org-element-property :name inline-src-block
)
2536 (org-export-get-reference inline-src-block info
))))
2537 (if (not lbl
) "" (format " id=\"%s\"" lbl
)))))
2538 (format "<code class=\"src src-%s\"%s>%s</code>" lang label code
)))
2542 (defun org-html-inlinetask (inlinetask contents info
)
2543 "Transcode an INLINETASK element from Org to HTML.
2544 CONTENTS holds the contents of the block. INFO is a plist
2545 holding contextual information."
2546 (let* ((todo (and (plist-get info
:with-todo-keywords
)
2547 (let ((todo (org-element-property :todo-keyword inlinetask
)))
2548 (and todo
(org-export-data todo info
)))))
2549 (todo-type (and todo
(org-element-property :todo-type inlinetask
)))
2550 (priority (and (plist-get info
:with-priority
)
2551 (org-element-property :priority inlinetask
)))
2552 (text (org-export-data (org-element-property :title inlinetask
) info
))
2553 (tags (and (plist-get info
:with-tags
)
2554 (org-export-get-tags inlinetask info
))))
2555 (funcall (plist-get info
:html-format-inlinetask-function
)
2556 todo todo-type priority text tags contents info
)))
2558 (defun org-html-format-inlinetask-default-function
2559 (todo todo-type priority text tags contents info
)
2560 "Default format function for a inlinetasks.
2561 See `org-html-format-inlinetask-function' for details."
2562 (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2563 (org-html-format-headline-default-function
2564 todo todo-type priority text tags info
)
2565 (org-html-close-tag "br" nil info
)
2570 (defun org-html-italic (_italic contents info
)
2571 "Transcode ITALIC from Org to HTML.
2572 CONTENTS is the text with italic markup. INFO is a plist holding
2573 contextual information."
2575 (or (cdr (assq 'italic
(plist-get info
:html-text-markup-alist
))) "%s")
2580 (defun org-html-checkbox (checkbox info
)
2581 "Format CHECKBOX into HTML.
2582 INFO is a plist holding contextual information. See
2583 `org-html-checkbox-type' for customization options."
2585 (cdr (assq (plist-get info
:html-checkbox-type
)
2586 org-html-checkbox-types
)))))
2588 (defun org-html-format-list-item (contents type checkbox info
2589 &optional term-counter-id
2591 "Format a list item into HTML."
2592 (let ((class (if checkbox
2593 (format " class=\"%s\""
2594 (symbol-name checkbox
)) ""))
2595 (checkbox (concat (org-html-checkbox checkbox info
)
2596 (and checkbox
" ")))
2597 (br (org-html-close-tag "br" nil info
)))
2601 (let* ((counter term-counter-id
)
2602 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2604 (format "<li%s%s>" class extra
)
2605 (when headline
(concat headline br
)))))
2607 (let* ((id term-counter-id
)
2608 (extra (if id
(format " id=\"%s\"" id
) "")))
2610 (format "<li%s%s>" class extra
)
2611 (when headline
(concat headline br
)))))
2613 (let* ((term term-counter-id
))
2614 (setq term
(or term
"(no term)"))
2615 ;; Check-boxes in descriptive lists are associated to tag.
2616 (concat (format "<dt%s>%s</dt>"
2617 class
(concat checkbox term
))
2619 (unless (eq type
'descriptive
) checkbox
)
2620 (and contents
(org-trim contents
))
2624 (descriptive "</dd>")))))
2626 (defun org-html-item (item contents info
)
2627 "Transcode an ITEM element from Org to HTML.
2628 CONTENTS holds the contents of the item. INFO is a plist holding
2629 contextual information."
2630 (let* ((plain-list (org-export-get-parent item
))
2631 (type (org-element-property :type plain-list
))
2632 (counter (org-element-property :counter item
))
2633 (checkbox (org-element-property :checkbox item
))
2634 (tag (let ((tag (org-element-property :tag item
)))
2635 (and tag
(org-export-data tag info
)))))
2636 (org-html-format-list-item
2637 contents type checkbox info
(or tag counter
))))
2641 (defun org-html-keyword (keyword _contents info
)
2642 "Transcode a KEYWORD element from Org to HTML.
2643 CONTENTS is nil. INFO is a plist holding contextual information."
2644 (let ((key (org-element-property :key keyword
))
2645 (value (org-element-property :value keyword
)))
2647 ((string= key
"HTML") value
)
2648 ((string= key
"TOC")
2649 (let ((case-fold-search t
))
2651 ((string-match "\\<headlines\\>" value
)
2652 (let ((depth (and (string-match "\\<[0-9]+\\>" value
)
2653 (string-to-number (match-string 0 value
))))
2654 (localp (org-string-match-p "\\<local\\>" value
)))
2655 (org-html-toc depth info
(and localp keyword
))))
2656 ((string= "listings" value
) (org-html-list-of-listings info
))
2657 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2659 ;;;; Latex Environment
2661 (defun org-html-format-latex (latex-frag processing-type info
)
2662 "Format a LaTeX fragment LATEX-FRAG into HTML.
2663 PROCESSING-TYPE designates the tool used for conversion. It is
2664 a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil
2665 and t. See `org-html-with-latex' for more information. INFO is
2666 a plist containing export properties."
2667 (let ((cache-relpath "") (cache-dir ""))
2668 (unless (eq processing-type
'mathjax
)
2669 (let ((bfn (or (buffer-file-name)
2671 (expand-file-name "latex" temporary-file-directory
))))
2673 (let ((header (plist-get info
:latex-header
)))
2676 (lambda (line) (concat "#+LATEX_HEADER: " line
))
2677 (org-split-string header
"\n")
2682 (file-name-sans-extension
2683 (file-name-nondirectory bfn
)))
2684 cache-dir
(file-name-directory bfn
))
2685 ;; Re-create LaTeX environment from original buffer in
2686 ;; temporary buffer so that dvipng/imagemagick can properly
2687 ;; turn the fragment into an image.
2688 (setq latex-frag
(concat latex-header latex-frag
))))
2691 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2692 nil processing-type
)
2695 (defun org-html-latex-environment (latex-environment _contents info
)
2696 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2697 CONTENTS is nil. INFO is a plist holding contextual information."
2698 (let ((processing-type (plist-get info
:with-latex
))
2699 (latex-frag (org-remove-indentation
2700 (org-element-property :value latex-environment
)))
2701 (attributes (org-export-read-attribute :attr_html latex-environment
)))
2702 (case processing-type
2704 (org-html-format-latex latex-frag
'mathjax info
))
2705 ((dvipng imagemagick
)
2707 (org-html-format-latex latex-frag processing-type info
)))
2708 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2709 ;; Do not provide a caption or a name to be consistent with
2710 ;; `mathjax' handling.
2711 (org-html--wrap-image
2712 (org-html--format-image
2713 (match-string 1 formula-link
) attributes info
) info
))))
2718 (defun org-html-latex-fragment (latex-fragment _contents info
)
2719 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2720 CONTENTS is nil. INFO is a plist holding contextual information."
2721 (let ((latex-frag (org-element-property :value latex-fragment
))
2722 (processing-type (plist-get info
:with-latex
)))
2723 (case processing-type
2725 (org-html-format-latex latex-frag
'mathjax info
))
2726 ((dvipng imagemagick
)
2728 (org-html-format-latex latex-frag processing-type info
)))
2729 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2730 (org-html--format-image (match-string 1 formula-link
) nil info
))))
2735 (defun org-html-line-break (_line-break _contents info
)
2736 "Transcode a LINE-BREAK object from Org to HTML.
2737 CONTENTS is nil. INFO is a plist holding contextual information."
2738 (concat (org-html-close-tag "br" nil info
) "\n"))
2742 (defun org-html-inline-image-p (link info
)
2743 "Non-nil when LINK is meant to appear as an image.
2744 INFO is a plist used as a communication channel. LINK is an
2745 inline image when it has no description and targets an image
2746 file (see `org-html-inline-image-rules' for more information), or
2747 if its description is a single link targeting an image file."
2748 (if (not (org-element-contents link
))
2749 (org-export-inline-image-p
2750 link
(plist-get info
:html-inline-image-rules
))
2752 (let ((link-count 0))
2753 (org-element-map (org-element-contents link
)
2754 (cons 'plain-text org-element-all-objects
)
2756 (case (org-element-type obj
)
2757 (plain-text (org-string-nw-p obj
))
2758 (link (if (= link-count
1) t
2760 (not (org-export-inline-image-p
2761 obj
(plist-get info
:html-inline-image-rules
)))))
2765 (defvar org-html-standalone-image-predicate
)
2766 (defun org-html-standalone-image-p (element info
)
2767 "Non-nil if ELEMENT is a standalone image.
2769 INFO is a plist holding contextual information.
2771 An element or object is a standalone image when
2773 - its type is `paragraph' and its sole content, save for white
2774 spaces, is a link that qualifies as an inline image;
2776 - its type is `link' and its containing paragraph has no other
2777 content save white spaces.
2779 Bind `org-html-standalone-image-predicate' to constrain paragraph
2780 further. For example, to check for only captioned standalone
2783 (lambda (paragraph) (org-element-property :caption paragraph))"
2784 (let ((paragraph (case (org-element-type element
)
2786 (link (org-export-get-parent element
)))))
2787 (and (eq (org-element-type paragraph
) 'paragraph
)
2788 (or (not (fboundp 'org-html-standalone-image-predicate
))
2789 (funcall org-html-standalone-image-predicate paragraph
))
2791 (let ((link-count 0))
2792 (org-element-map (org-element-contents paragraph
)
2793 (cons 'plain-text org-element-all-objects
)
2795 (when (case (org-element-type obj
)
2796 (plain-text (org-string-nw-p obj
))
2797 (link (or (> (incf link-count
) 1)
2798 (not (org-html-inline-image-p obj info
))))
2802 (= link-count
1))))))
2804 (defun org-html-link (link desc info
)
2805 "Transcode a LINK object from Org to HTML.
2806 DESC is the description part of the link, or the empty string.
2807 INFO is a plist holding contextual information. See
2809 (let* ((home (when (plist-get info
:html-link-home
)
2810 (org-trim (plist-get info
:html-link-home
))))
2811 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2812 (link-org-files-as-html-maybe
2813 (lambda (raw-path info
)
2814 ;; Treat links to `file.org' as links to `file.html', if
2815 ;; needed. See `org-html-link-org-files-as-html'.
2817 ((and (plist-get info
:html-link-org-files-as-html
)
2819 (downcase (file-name-extension raw-path
"."))))
2820 (concat (file-name-sans-extension raw-path
) "."
2821 (plist-get info
:html-extension
)))
2823 (type (org-element-property :type link
))
2824 (raw-path (org-element-property :path link
))
2825 ;; Ensure DESC really exists, or set it to nil.
2826 (desc (org-string-nw-p desc
))
2829 ((member type
'("http" "https" "ftp" "mailto"))
2830 (org-link-escape-browser
2831 (org-link-unescape (concat type
":" raw-path
))))
2832 ((string= type
"file")
2833 ;; Treat links to ".org" files as ".html", if needed.
2835 (funcall link-org-files-as-html-maybe raw-path info
))
2836 ;; If file path is absolute, prepend it with protocol
2837 ;; component - "file://".
2839 ((file-name-absolute-p raw-path
)
2840 (setq raw-path
(org-export-file-uri raw-path
)))
2841 ((and home use-abs-url
)
2842 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2843 ;; Add search option, if any. A search option can be
2844 ;; relative to a custom-id, a headline title a name,
2845 ;; a target or a radio-target.
2846 (let ((option (org-element-property :search-option link
)))
2847 (if (not option
) raw-path
2850 (org-publish-resolve-external-link
2852 (org-element-property :path link
))))))
2854 ;; Extract attributes from parent's paragraph. HACK: Only do
2855 ;; this for the first link in parent (inner image link for
2856 ;; inline images). This is needed as long as attributes
2857 ;; cannot be set on a per link basis.
2859 (let* ((parent (org-export-get-parent-element link
))
2860 (link (let ((container (org-export-get-parent link
)))
2861 (if (and (eq (org-element-type container
) 'link
)
2862 (org-html-inline-image-p link info
))
2865 (and (eq (org-element-map parent
'link
'identity info t
) link
)
2866 (org-export-read-attribute :attr_html parent
))))
2868 (let ((attr (org-html--make-attribute-string attributes-plist
)))
2869 (if (org-string-nw-p attr
) (concat " " attr
) ""))))
2871 ;; Link type is handled by a special function.
2872 ((org-export-custom-protocol-maybe link desc
'html
))
2874 ((and (plist-get info
:html-inline-images
)
2875 (org-export-inline-image-p
2876 link
(plist-get info
:html-inline-image-rules
)))
2877 (org-html--format-image path attributes-plist info
))
2878 ;; Radio target: Transcode target's contents and use them as
2879 ;; link's description.
2880 ((string= type
"radio")
2881 (let ((destination (org-export-resolve-radio-link link info
)))
2882 (if (not destination
) desc
2883 (format "<a href=\"#%s\"%s>%s</a>"
2884 (org-export-get-reference destination info
)
2887 ;; Links pointing to a headline: Find destination and build
2888 ;; appropriate referencing command.
2889 ((member type
'("custom-id" "fuzzy" "id"))
2890 (let ((destination (if (string= type
"fuzzy")
2891 (org-export-resolve-fuzzy-link link info
)
2892 (org-export-resolve-id-link link info
))))
2893 (case (org-element-type destination
)
2894 ;; ID link points to an external file.
2896 (let ((fragment (concat "ID-" path
))
2897 ;; Treat links to ".org" files as ".html", if needed.
2898 (path (funcall link-org-files-as-html-maybe
2900 (format "<a href=\"%s#%s\"%s>%s</a>"
2901 path fragment attributes
(or desc destination
))))
2902 ;; Fuzzy link points nowhere.
2907 (org-element-property :raw-link link
) info
))))
2908 ;; Link points to a headline.
2910 (let ((href (or (org-element-property :CUSTOM_ID destination
)
2911 (org-export-get-reference destination info
)))
2912 ;; What description to use?
2914 ;; Case 1: Headline is numbered and LINK has no
2915 ;; description. Display section number.
2916 (if (and (org-export-numbered-headline-p destination info
)
2918 (mapconcat #'number-to-string
2919 (org-export-get-headline-number
2920 destination info
) ".")
2921 ;; Case 2: Either the headline is un-numbered or
2922 ;; LINK has a custom description. Display LINK's
2923 ;; description or headline's title.
2926 (org-element-property :title destination
) info
)))))
2927 (format "<a href=\"#%s\"%s>%s</a>" href attributes desc
)))
2928 ;; Fuzzy link points to a target or an element.
2930 (let* ((ref (org-export-get-reference destination info
))
2931 (org-html-standalone-image-predicate
2932 #'org-html--has-caption-p
)
2935 ((org-html-standalone-image-p destination info
)
2936 (org-export-get-ordinal
2937 (org-element-map destination
'link
2939 info
'link
'org-html-standalone-image-p
))
2940 (t (org-export-get-ordinal
2941 destination info nil
'org-html--has-caption-p
))))
2943 ((not number
) "No description for this link")
2944 ((numberp number
) (number-to-string number
))
2945 (t (mapconcat #'number-to-string number
".")))))
2946 (format "<a href=\"#%s\"%s>%s</a>" ref attributes desc
))))))
2947 ;; Coderef: replace link with the reference name or the
2948 ;; equivalent line number.
2949 ((string= type
"coderef")
2950 (let ((fragment (concat "coderef-" (org-html-encode-plain-text path
))))
2951 (format "<a href=\"#%s\"%s%s>%s</a>"
2953 (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, \
2954 '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
2957 (format (org-export-get-coderef-format path desc
)
2958 (org-export-resolve-coderef path info
)))))
2959 ;; External link with a description part.
2960 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>"
2961 (org-html-encode-plain-text path
)
2964 ;; External link without a description part.
2965 (path (format "<a href=\"%s\"%s>%s</a>"
2966 (org-html-encode-plain-text path
)
2969 ;; No path, only description. Try to do something useful.
2970 (t (format "<i>%s</i>" desc
)))))
2974 (defun org-html-node-property (node-property _contents _info
)
2975 "Transcode a NODE-PROPERTY element from Org to HTML.
2976 CONTENTS is nil. INFO is a plist holding contextual
2979 (org-element-property :key node-property
)
2980 (let ((value (org-element-property :value node-property
)))
2981 (if value
(concat " " value
) ""))))
2985 (defun org-html-paragraph (paragraph contents info
)
2986 "Transcode a PARAGRAPH element from Org to HTML.
2987 CONTENTS is the contents of the paragraph, as a string. INFO is
2988 the plist used as a communication channel."
2989 (let* ((parent (org-export-get-parent paragraph
))
2990 (parent-type (org-element-type parent
))
2991 (style '((footnote-definition " class=\"footpara\"")
2992 (org-data " class=\"footpara\"")))
2993 (attributes (org-html--make-attribute-string
2994 (org-export-read-attribute :attr_html paragraph
)))
2995 (extra (or (cadr (assq parent-type style
)) "")))
2997 ((and (eq parent-type
'item
)
2998 (not (org-export-get-previous-element paragraph info
))
2999 (let ((followers (org-export-get-next-element paragraph info
2)))
3000 (and (not (cdr followers
))
3001 (memq (org-element-type (car followers
)) '(nil plain-list
)))))
3002 ;; First paragraph in an item has no tag if it is alone or
3003 ;; followed, at most, by a sub-list.
3005 ((org-html-standalone-image-p paragraph info
)
3006 ;; Standalone image.
3008 (let ((raw (org-export-data
3009 (org-export-get-caption paragraph
) info
))
3010 (org-html-standalone-image-predicate
3011 'org-html--has-caption-p
))
3012 (if (not (org-string-nw-p raw
)) raw
3014 "<span class=\"figure-number\">"
3015 (format (org-html--translate "Figure %d:" info
)
3016 (org-export-get-ordinal
3017 (org-element-map paragraph
'link
3019 info nil
'org-html-standalone-image-p
))
3021 (label (and (org-element-property :name paragraph
)
3022 (org-export-get-reference paragraph info
))))
3023 (org-html--wrap-image contents info caption label
)))
3024 ;; Regular paragraph.
3025 (t (format "<p%s%s>\n%s</p>"
3026 (if (org-string-nw-p attributes
)
3027 (concat " " attributes
) "")
3032 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
3033 ;; the correct value for the item counter
3034 (defun org-html-begin-plain-list (type &optional arg1
)
3035 "Insert the beginning of the HTML list depending on TYPE.
3036 When ARG1 is a string, use it as the start parameter for ordered
3040 (format "<ol class=\"org-ol\"%s>"
3041 (if arg1
(format " start=\"%d\"" arg1
) "")))
3042 (unordered "<ul class=\"org-ul\">")
3043 (descriptive "<dl class=\"org-dl\">")))
3045 (defun org-html-end-plain-list (type)
3046 "Insert the end of the HTML list depending on TYPE."
3050 (descriptive "</dl>")))
3052 (defun org-html-plain-list (plain-list contents _info
)
3053 "Transcode a PLAIN-LIST element from Org to HTML.
3054 CONTENTS is the contents of the list. INFO is a plist holding
3055 contextual information."
3056 (let ((type (org-element-property :type plain-list
)))
3058 (org-html-begin-plain-list type
)
3059 contents
(org-html-end-plain-list type
))))
3063 (defun org-html-convert-special-strings (string)
3064 "Convert special characters in STRING to HTML."
3065 (dolist (a org-html-special-string-regexps string
)
3068 (setq string
(replace-regexp-in-string re rpl string t
)))))
3070 (defun org-html-encode-plain-text (text)
3071 "Convert plain text characters from TEXT to HTML equivalent.
3072 Possible conversions are set in `org-html-protect-char-alist'."
3073 (dolist (pair org-html-protect-char-alist text
)
3074 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
))))
3076 (defun org-html-plain-text (text info
)
3077 "Transcode a TEXT string from Org to HTML.
3078 TEXT is the string to transcode. INFO is a plist holding
3079 contextual information."
3080 (let ((output text
))
3081 ;; Protect following characters: <, >, &.
3082 (setq output
(org-html-encode-plain-text output
))
3083 ;; Handle smart quotes. Be sure to provide original string since
3084 ;; OUTPUT may have been modified.
3085 (when (plist-get info
:with-smart-quotes
)
3086 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
3087 ;; Handle special strings.
3088 (when (plist-get info
:with-special-strings
)
3089 (setq output
(org-html-convert-special-strings output
)))
3090 ;; Handle break preservation if required.
3091 (when (plist-get info
:preserve-breaks
)
3093 (replace-regexp-in-string
3094 "\\(\\\\\\\\\\)?[ \t]*\n"
3095 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
3102 (defun org-html-planning (planning _contents _info
)
3103 "Transcode a PLANNING element from Org to HTML.
3104 CONTENTS is nil. INFO is a plist used as a communication
3106 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
3108 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
3113 (let ((closed (org-element-property :closed planning
)))
3115 (format span-fmt org-closed-string
3116 (org-timestamp-translate closed
))))
3117 (let ((deadline (org-element-property :deadline planning
)))
3119 (format span-fmt org-deadline-string
3120 (org-timestamp-translate deadline
))))
3121 (let ((scheduled (org-element-property :scheduled planning
)))
3123 (format span-fmt org-scheduled-string
3124 (org-timestamp-translate scheduled
))))))
3127 ;;;; Property Drawer
3129 (defun org-html-property-drawer (_property-drawer contents _info
)
3130 "Transcode a PROPERTY-DRAWER element from Org to HTML.
3131 CONTENTS holds the contents of the drawer. INFO is a plist
3132 holding contextual information."
3133 (and (org-string-nw-p contents
)
3134 (format "<pre class=\"example\">\n%s</pre>" contents
)))
3138 (defun org-html-quote-block (_quote-block contents _info
)
3139 "Transcode a QUOTE-BLOCK element from Org to HTML.
3140 CONTENTS holds the contents of the block. INFO is a plist
3141 holding contextual information."
3142 (format "<blockquote>\n%s</blockquote>" contents
))
3146 (defun org-html-section (section contents info
)
3147 "Transcode a SECTION element from Org to HTML.
3148 CONTENTS holds the contents of the section. INFO is a plist
3149 holding contextual information."
3150 (let ((parent (org-export-get-parent-headline section
)))
3151 ;; Before first headline: no container, just return CONTENTS.
3152 (if (not parent
) contents
3153 ;; Get div's class and id references.
3154 (let* ((class-num (+ (org-export-get-relative-level parent info
)
3155 (1- (plist-get info
:html-toplevel-hlevel
))))
3157 (and (org-export-numbered-headline-p parent info
)
3160 (org-export-get-headline-number parent info
) "-"))))
3161 ;; Build return value.
3162 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
3164 (or (org-element-property :CUSTOM_ID parent
)
3166 (org-export-get-reference parent info
))
3167 (or contents
""))))))
3171 (defun org-html-radio-target (radio-target text info
)
3172 "Transcode a RADIO-TARGET object from Org to HTML.
3173 TEXT is the text of the target. INFO is a plist holding
3174 contextual information."
3175 (let ((ref (org-export-get-reference radio-target info
)))
3176 (org-html--anchor ref text nil info
)))
3180 (defun org-html-special-block (special-block contents info
)
3181 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3182 CONTENTS holds the contents of the block. INFO is a plist
3183 holding contextual information."
3184 (let* ((block-type (org-element-property :type special-block
))
3185 (contents (or contents
""))
3186 (html5-fancy (and (org-html--html5-fancy-p info
)
3187 (member block-type org-html-html5-elements
)))
3188 (attributes (org-export-read-attribute :attr_html special-block
)))
3190 (let ((class (plist-get attributes
:class
)))
3191 (setq attributes
(plist-put attributes
:class
3192 (if class
(concat class
" " block-type
)
3194 (setq attributes
(org-html--make-attribute-string attributes
))
3195 (when (not (equal attributes
""))
3196 (setq attributes
(concat " " attributes
)))
3198 (format "<%s%s>\n%s</%s>" block-type attributes
3199 contents block-type
)
3200 (format "<div%s>\n%s\n</div>" attributes contents
))))
3204 (defun org-html-src-block (src-block _contents info
)
3205 "Transcode a SRC-BLOCK element from Org to HTML.
3206 CONTENTS holds the contents of the item. INFO is a plist holding
3207 contextual information."
3208 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3209 (org-html--textarea-block src-block
)
3210 (let ((lang (org-element-property :language src-block
))
3211 (caption (org-export-get-caption src-block
))
3212 (code (org-html-format-code src-block info
))
3213 (label (let ((lbl (and (org-element-property :name src-block
)
3214 (org-export-get-reference src-block info
))))
3215 (if lbl
(format " id=\"%s\"" lbl
) ""))))
3216 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3218 "<div class=\"org-src-container\">\n%s%s\n</div>"
3219 (if (not caption
) ""
3220 (format "<label class=\"org-src-name\">%s</label>"
3221 (org-export-data caption info
)))
3222 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3224 ;;;; Statistics Cookie
3226 (defun org-html-statistics-cookie (statistics-cookie _contents _info
)
3227 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3228 CONTENTS is nil. INFO is a plist holding contextual information."
3229 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3230 (format "<code>%s</code>" cookie-value
)))
3234 (defun org-html-strike-through (_strike-through contents info
)
3235 "Transcode STRIKE-THROUGH from Org to HTML.
3236 CONTENTS is the text with strike-through markup. INFO is a plist
3237 holding contextual information."
3239 (or (cdr (assq 'strike-through
(plist-get info
:html-text-markup-alist
)))
3245 (defun org-html-subscript (_subscript contents _info
)
3246 "Transcode a SUBSCRIPT object from Org to HTML.
3247 CONTENTS is the contents of the object. INFO is a plist holding
3248 contextual information."
3249 (format "<sub>%s</sub>" contents
))
3253 (defun org-html-superscript (_superscript contents _info
)
3254 "Transcode a SUPERSCRIPT object from Org to HTML.
3255 CONTENTS is the contents of the object. INFO is a plist holding
3256 contextual information."
3257 (format "<sup>%s</sup>" contents
))
3261 (defun org-html-table-cell (table-cell contents info
)
3262 "Transcode a TABLE-CELL element from Org to HTML.
3263 CONTENTS is nil. INFO is a plist used as a communication
3265 (let* ((table-row (org-export-get-parent table-cell
))
3266 (table (org-export-get-parent-table table-cell
))
3268 (if (not (plist-get info
:html-table-align-individual-fields
)) ""
3269 (format (if (and (boundp 'org-html-format-table-no-css
)
3270 org-html-format-table-no-css
)
3271 " align=\"%s\"" " class=\"org-%s\"")
3272 (org-export-table-cell-alignment table-cell info
)))))
3273 (when (or (not contents
) (string= "" (org-trim contents
)))
3274 (setq contents
" "))
3276 ((and (org-export-table-has-header-p table info
)
3277 (= 1 (org-export-table-row-group table-row info
)))
3278 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3279 (concat "\n" (format (car header-tags
) "col" cell-attrs
)
3281 (cdr header-tags
))))
3282 ((and (plist-get info
:html-table-use-header-tags-for-first-column
)
3283 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3284 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3285 (concat "\n" (format (car header-tags
) "row" cell-attrs
)
3287 (cdr header-tags
))))
3288 (t (let ((data-tags (plist-get info
:html-table-data-tags
)))
3289 (concat "\n" (format (car data-tags
) cell-attrs
)
3291 (cdr data-tags
)))))))
3295 (defun org-html-table-row (table-row contents info
)
3296 "Transcode a TABLE-ROW element from Org to HTML.
3297 CONTENTS is the contents of the row. INFO is a plist used as a
3298 communication channel."
3299 ;; Rules are ignored since table separators are deduced from
3300 ;; borders of the current row.
3301 (when (eq (org-element-property :type table-row
) 'standard
)
3302 (let* ((rowgroup-number (org-export-table-row-group table-row info
))
3303 (row-number (org-export-table-row-number table-row info
))
3305 (org-export-table-row-starts-rowgroup-p table-row info
))
3307 (org-export-table-row-ends-rowgroup-p table-row info
))
3308 ;; `top-row-p' and `end-rowgroup-p' are not used directly
3309 ;; but should be set so that `org-html-table-row-tags' can
3310 ;; use them (see the docstring of this variable.)
3311 (top-row-p (and (equal start-rowgroup-p
'(top))
3312 (equal end-rowgroup-p
'(below top
))))
3313 (bottom-row-p (and (equal start-rowgroup-p
'(above))
3314 (equal end-rowgroup-p
'(bottom above
))))
3317 ;; Case 1: Row belongs to second or subsequent rowgroups.
3318 ((not (= 1 rowgroup-number
))
3319 '("<tbody>" .
"\n</tbody>"))
3320 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
3321 ((org-export-table-has-header-p
3322 (org-export-get-parent-table table-row
) info
)
3323 '("<thead>" .
"\n</thead>"))
3324 ;; Case 2: Row is from first and only row group.
3325 (t '("<tbody>" .
"\n</tbody>")))))
3326 ;; Silence byte-compiler.
3327 bottom-row-p top-row-p row-number
3329 ;; Begin a rowgroup?
3330 (when start-rowgroup-p
(car rowgroup-tags
))
3331 ;; Actual table row.
3332 (concat "\n" (eval (car (plist-get info
:html-table-row-tags
)) t
)
3335 (eval (cdr (plist-get info
:html-table-row-tags
)) t
))
3337 (when end-rowgroup-p
(cdr rowgroup-tags
))))))
3341 (defun org-html-table-first-row-data-cells (table info
)
3342 "Transcode the first row of TABLE.
3343 INFO is a plist used as a communication channel."
3345 (org-element-map table
'table-row
3347 (unless (eq (org-element-property :type row
) 'rule
) row
))
3349 (special-column-p (org-export-table-has-special-column-p table
)))
3350 (if (not special-column-p
) (org-element-contents table-row
)
3351 (cdr (org-element-contents table-row
)))))
3353 (defun org-html-table--table.el-table
(table _info
)
3354 "Format table.el tables into HTML.
3355 INFO is a plist used as a communication channel."
3356 (when (eq (org-element-property :type table
) 'table.el
)
3358 (let ((outbuf (with-current-buffer
3359 (get-buffer-create "*org-export-table*")
3360 (erase-buffer) (current-buffer))))
3362 (insert (org-element-property :value table
))
3364 (re-search-forward "^[ \t]*|[^|]" nil t
)
3365 (table-generate-source 'html outbuf
))
3366 (with-current-buffer outbuf
3367 (prog1 (org-trim (buffer-string))
3370 (defun org-html-table (table contents info
)
3371 "Transcode a TABLE element from Org to HTML.
3372 CONTENTS is the contents of the table. INFO is a plist holding
3373 contextual information."
3374 (case (org-element-property :type table
)
3375 ;; Case 1: table.el table. Convert it using appropriate tools.
3376 (table.el
(org-html-table--table.el-table table info
))
3377 ;; Case 2: Standard table.
3379 (let* ((caption (org-export-get-caption table
))
3380 (number (org-export-get-ordinal
3381 table info nil
#'org-html--has-caption-p
))
3383 (org-html--make-attribute-string
3385 (and (org-element-property :name table
)
3386 (list :id
(org-export-get-reference table info
)))
3387 (and (not (org-html-html5-p info
))
3388 (plist-get info
:html-table-attributes
))
3389 (org-export-read-attribute :attr_html table
))))
3391 (if (and (boundp 'org-html-format-table-no-css
)
3392 org-html-format-table-no-css
)
3393 "align=\"%s\"" "class=\"org-%s\""))
3396 (lambda (table info
)
3398 (lambda (table-cell)
3399 (let ((alignment (org-export-table-cell-alignment
3402 ;; Begin a colgroup?
3403 (when (org-export-table-cell-starts-colgroup-p
3406 ;; Add a column. Also specify it's alignment.
3409 "col" (concat " " (format alignspec alignment
)) info
))
3411 (when (org-export-table-cell-ends-colgroup-p
3414 (org-html-table-first-row-data-cells table info
) "\n")))))
3415 (format "<table%s>\n%s\n%s\n%s</table>"
3416 (if (equal attributes
"") "" (concat " " attributes
))
3417 (if (not caption
) ""
3418 (format (if (plist-get info
:html-table-caption-above
)
3419 "<caption class=\"t-above\">%s</caption>"
3420 "<caption class=\"t-bottom\">%s</caption>")
3422 "<span class=\"table-number\">"
3423 (format (org-html--translate "Table %d:" info
) number
)
3424 "</span> " (org-export-data caption info
))))
3425 (funcall table-column-specs table info
)
3430 (defun org-html-target (target _contents info
)
3431 "Transcode a TARGET object from Org to HTML.
3432 CONTENTS is nil. INFO is a plist holding contextual
3434 (let ((ref (org-export-get-reference target info
)))
3435 (org-html--anchor ref nil nil info
)))
3439 (defun org-html-timestamp (timestamp _contents info
)
3440 "Transcode a TIMESTAMP object from Org to HTML.
3441 CONTENTS is nil. INFO is a plist holding contextual
3443 (let ((value (org-html-plain-text (org-timestamp-translate timestamp
) info
)))
3444 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3445 (replace-regexp-in-string "--" "–" value
))))
3449 (defun org-html-underline (_underline contents info
)
3450 "Transcode UNDERLINE from Org to HTML.
3451 CONTENTS is the text with underline markup. INFO is a plist
3452 holding contextual information."
3453 (format (or (cdr (assq 'underline
(plist-get info
:html-text-markup-alist
)))
3459 (defun org-html-verbatim (verbatim _contents info
)
3460 "Transcode VERBATIM from Org to HTML.
3461 CONTENTS is nil. INFO is a plist holding contextual
3463 (format (or (cdr (assq 'verbatim
(plist-get info
:html-text-markup-alist
))) "%s")
3464 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3468 (defun org-html-verse-block (_verse-block contents info
)
3469 "Transcode a VERSE-BLOCK element from Org to HTML.
3470 CONTENTS is verse block contents. INFO is a plist holding
3471 contextual information."
3472 ;; Replace each newline character with line break. Also replace
3473 ;; each blank line with a line break.
3474 (setq contents
(replace-regexp-in-string
3475 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3476 (replace-regexp-in-string
3477 "\\(\\\\\\\\\\)?[ \t]*\n"
3478 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3479 ;; Replace each white space at beginning of a line with a
3480 ;; non-breaking space.
3481 (while (string-match "^[ \t]+" contents
)
3482 (let* ((num-ws (length (match-string 0 contents
)))
3483 (ws (org-html--make-string num-ws
" ")))
3484 (setq contents
(replace-match ws nil t contents
))))
3485 (format "<p class=\"verse\">\n%s</p>" contents
))
3488 ;;; Filter Functions
3490 (defun org-html-final-function (contents _backend info
)
3491 "Filter to indent the HTML and convert HTML entities."
3495 (if (plist-get info
:html-indent
)
3496 (indent-region (point-min) (point-max)))
3497 (buffer-substring-no-properties (point-min) (point-max))))
3500 ;;; End-user functions
3503 (defun org-html-export-as-html
3504 (&optional async subtreep visible-only body-only ext-plist
)
3505 "Export current buffer to an HTML buffer.
3507 If narrowing is active in the current buffer, only export its
3510 If a region is active, export that region.
3512 A non-nil optional argument ASYNC means the process should happen
3513 asynchronously. The resulting buffer should be accessible
3514 through the `org-export-stack' interface.
3516 When optional argument SUBTREEP is non-nil, export the sub-tree
3517 at point, extracting information from the headline properties
3520 When optional argument VISIBLE-ONLY is non-nil, don't export
3521 contents of hidden elements.
3523 When optional argument BODY-ONLY is non-nil, only write code
3524 between \"<body>\" and \"</body>\" tags.
3526 EXT-PLIST, when provided, is a property list with external
3527 parameters overriding Org default settings, but still inferior to
3528 file-local settings.
3530 Export is done in a buffer named \"*Org HTML Export*\", which
3531 will be displayed when `org-export-show-temporary-export-buffer'
3534 (org-export-to-buffer 'html
"*Org HTML Export*"
3535 async subtreep visible-only body-only ext-plist
3536 (lambda () (set-auto-mode t
))))
3539 (defun org-html-convert-region-to-html ()
3540 "Assume the current region has org-mode syntax, and convert it to HTML.
3541 This can be used in any buffer. For example, you can write an
3542 itemized list in org-mode syntax in an HTML buffer and use this
3543 command to convert it."
3545 (org-export-replace-region-by 'html
))
3548 (defun org-html-export-to-html
3549 (&optional async subtreep visible-only body-only ext-plist
)
3550 "Export current buffer to a HTML file.
3552 If narrowing is active in the current buffer, only export its
3555 If a region is active, export that region.
3557 A non-nil optional argument ASYNC means the process should happen
3558 asynchronously. The resulting file should be accessible through
3559 the `org-export-stack' interface.
3561 When optional argument SUBTREEP is non-nil, export the sub-tree
3562 at point, extracting information from the headline properties
3565 When optional argument VISIBLE-ONLY is non-nil, don't export
3566 contents of hidden elements.
3568 When optional argument BODY-ONLY is non-nil, only write code
3569 between \"<body>\" and \"</body>\" tags.
3571 EXT-PLIST, when provided, is a property list with external
3572 parameters overriding Org default settings, but still inferior to
3573 file-local settings.
3575 Return output file's name."
3577 (let* ((extension (concat "." (or (plist-get ext-plist
:html-extension
)
3580 (file (org-export-output-file-name extension subtreep
))
3581 (org-export-coding-system org-html-coding-system
))
3582 (org-export-to-file 'html file
3583 async subtreep visible-only body-only ext-plist
)))
3586 (defun org-html-publish-to-html (plist filename pub-dir
)
3587 "Publish an org file to HTML.
3589 FILENAME is the filename of the Org file to be published. PLIST
3590 is the property list for the given project. PUB-DIR is the
3591 publishing directory.
3593 Return output file name."
3594 (org-publish-org-to 'html filename
3595 (concat "." (or (plist-get plist
:html-extension
)
3604 ;; generated-autoload-file: "org-loaddefs.el"
3607 ;;; ox-html.el ends here