1 ;;; ox-html.el --- HTML Back-End for Org Export Engine -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2011-2016 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
))
105 :filters-alist
'((:filter-options . org-html-infojs-install-script
)
106 (:filter-final-output . org-html-final-function
))
108 '(?h
"Export to HTML"
109 ((?H
"As HTML buffer" org-html-export-as-html
)
110 (?h
"As HTML file" org-html-export-to-html
)
111 (?o
"As HTML file and open"
113 (if a
(org-html-export-to-html t s v b
)
114 (org-open-file (org-html-export-to-html nil s v b
)))))))
116 '((:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
117 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
118 (:description
"DESCRIPTION" nil nil newline
)
119 (:keywords
"KEYWORDS" nil nil space
)
120 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
121 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
122 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
123 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
124 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
125 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
126 (:html-postamble nil
"html-postamble" org-html-postamble
)
127 (:html-preamble nil
"html-preamble" org-html-preamble
)
128 (:html-head
"HTML_HEAD" nil org-html-head newline
)
129 (:html-head-extra
"HTML_HEAD_EXTRA" nil org-html-head-extra newline
)
130 (:subtitle
"SUBTITLE" nil nil parse
)
131 (:html-head-include-default-style
132 nil
"html-style" org-html-head-include-default-style
)
133 (:html-head-include-scripts nil
"html-scripts" org-html-head-include-scripts
)
134 (:html-allow-name-attribute-in-anchors
135 nil nil org-html-allow-name-attribute-in-anchors
)
136 (:html-divs nil nil org-html-divs
)
137 (:html-checkbox-type nil nil org-html-checkbox-type
)
138 (:html-extension nil nil org-html-extension
)
139 (:html-footnote-format nil nil org-html-footnote-format
)
140 (:html-footnote-separator nil nil org-html-footnote-separator
)
141 (:html-footnotes-section nil nil org-html-footnotes-section
)
142 (:html-format-drawer-function nil nil org-html-format-drawer-function
)
143 (:html-format-headline-function nil nil org-html-format-headline-function
)
144 (:html-format-inlinetask-function
145 nil nil org-html-format-inlinetask-function
)
146 (:html-home
/up-format nil nil org-html-home
/up-format
)
147 (:html-indent nil nil org-html-indent
)
148 (:html-infojs-options nil nil org-html-infojs-options
)
149 (:html-infojs-template nil nil org-html-infojs-template
)
150 (:html-inline-image-rules nil nil org-html-inline-image-rules
)
151 (:html-link-org-files-as-html nil nil org-html-link-org-files-as-html
)
152 (:html-mathjax-options nil nil org-html-mathjax-options
)
153 (:html-mathjax-template nil nil org-html-mathjax-template
)
154 (:html-metadata-timestamp-format nil nil org-html-metadata-timestamp-format
)
155 (:html-postamble-format nil nil org-html-postamble-format
)
156 (:html-preamble-format nil nil org-html-preamble-format
)
157 (:html-table-align-individual-fields
158 nil nil org-html-table-align-individual-fields
)
159 (:html-table-caption-above nil nil org-html-table-caption-above
)
160 (:html-table-data-tags nil nil org-html-table-data-tags
)
161 (:html-table-header-tags nil nil org-html-table-header-tags
)
162 (:html-table-use-header-tags-for-first-column
163 nil nil org-html-table-use-header-tags-for-first-column
)
164 (:html-tag-class-prefix nil nil org-html-tag-class-prefix
)
165 (:html-text-markup-alist nil nil org-html-text-markup-alist
)
166 (:html-todo-kwd-class-prefix nil nil org-html-todo-kwd-class-prefix
)
167 (:html-toplevel-hlevel nil nil org-html-toplevel-hlevel
)
168 (:html-use-infojs nil nil org-html-use-infojs
)
169 (:html-validation-link nil nil org-html-validation-link
)
170 (:html-viewport nil nil org-html-viewport
)
171 (:html-inline-images nil nil org-html-inline-images
)
172 (:html-table-attributes nil nil org-html-table-default-attributes
)
173 (:html-table-row-open-tag nil nil org-html-table-row-open-tag
)
174 (:html-table-row-close-tag nil nil org-html-table-row-close-tag
)
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-open-tag
"<tr>"
864 "The opening tag for table rows.
865 This is customizable so that alignment options can be specified.
866 Instead of strings, these can be a Lisp function that will be
867 evaluated for each row in order to construct the table row tags.
869 The function will be called with these arguments:
871 `number': row number (0 is the first row)
872 `group-number': group number of current row
873 `start-group-p': non-nil means the row starts a group
874 `end-group-p': non-nil means the row ends a group
875 `topp': non-nil means this is the top row
876 `bottomp': non-nil means this is the bottom row
880 \(setq org-html-table-row-open-tag
881 \(lambda (number group-number start-group-p end-group-p topp bottomp)
882 \(cond (topp \"<tr class=\\\"tr-top\\\">\")
883 \(bottomp \"<tr class=\\\"tr-bottom\\\">\")
884 \(t (if (= (mod number 2) 1)
885 \"<tr class=\\\"tr-odd\\\">\"
886 \"<tr class=\\\"tr-even\\\">\")))))
888 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
889 and the bottom row, and otherwise alternate between \"tr-odd\" and
890 \"tr-even\" for odd and even rows."
891 :group
'org-export-html
892 :type
'(choice :tag
"Opening tag"
893 (string :tag
"Specify")
896 (defcustom org-html-table-row-close-tag
"</tr>"
897 "The closing tag for table rows.
898 This is customizable so that alignment options can be specified.
899 Instead of strings, this can be a Lisp function that will be
900 evaluated for each row in order to construct the table row tags.
902 See documentation of `org-html-table-row-open-tag'."
903 :group
'org-export-html
904 :type
'(choice :tag
"Closing tag"
905 (string :tag
"Specify")
908 (defcustom org-html-table-align-individual-fields t
909 "Non-nil means attach style attributes for alignment to each table field.
910 When nil, alignment will only be specified in the column tags, but this
911 is ignored by some browsers (like Firefox, Safari). Opera does it right
913 :group
'org-export-html
916 (defcustom org-html-table-use-header-tags-for-first-column nil
917 "Non-nil means format column one in tables with header tags.
918 When nil, also column one will use data tags."
919 :group
'org-export-html
922 (defcustom org-html-table-caption-above t
923 "When non-nil, place caption string at the beginning of the table.
924 Otherwise, place it near the end."
925 :group
'org-export-html
930 (defcustom org-html-tag-class-prefix
""
931 "Prefix to class names for TODO keywords.
932 Each tag gets a class given by the tag itself, with this prefix.
933 The default prefix is empty because it is nice to just use the keyword
934 as a class name. But if you get into conflicts with other, existing
935 CSS classes, then this prefix can be very useful."
936 :group
'org-export-html
939 ;;;; Template :: Generic
941 (defcustom org-html-extension
"html"
942 "The extension for exported HTML files."
943 :group
'org-export-html
946 (defcustom org-html-xml-declaration
947 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
948 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
949 "The extension for exported HTML files.
950 %s will be replaced with the charset of the exported file.
951 This may be a string, or an alist with export extensions
952 and corresponding declarations.
954 This declaration only applies when exporting to XHTML."
955 :group
'org-export-html
957 (string :tag
"Single declaration")
958 (repeat :tag
"Dependent on extension"
959 (cons (string :tag
"Extension")
960 (string :tag
"Declaration")))))
962 (defcustom org-html-coding-system
'utf-8
963 "Coding system for HTML export.
964 Use utf-8 as the default value."
965 :group
'org-export-html
967 :package-version
'(Org .
"8.0")
968 :type
'coding-system
)
970 (defcustom org-html-doctype
"xhtml-strict"
971 "Document type definition to use for exported HTML files.
972 Can be set with the in-buffer HTML_DOCTYPE property or for
973 publishing, with :html-doctype."
974 :group
'org-export-html
976 :package-version
'(Org .
"8.0")
979 (mapcar (lambda (x) `(const ,(car x
))) org-html-doctype-alist
)
980 '((string :tag
"Custom doctype" ))))
982 (defcustom org-html-html5-fancy nil
983 "Non-nil means using new HTML5 elements.
984 This variable is ignored for anything other than HTML5 export.
986 For compatibility with Internet Explorer, it's probably a good
987 idea to download some form of the html5shiv (for instance
988 https://code.google.com/p/html5shiv/) and add it to your
989 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
990 versions 8 and below."
991 :group
'org-export-html
993 :package-version
'(Org .
"8.0")
996 (defcustom org-html-container-element
"div"
997 "HTML element to use for wrapping top level sections.
998 Can be set with the in-buffer HTML_CONTAINER property or for
999 publishing, with :html-container.
1001 Note that changing the default will prevent you from using
1002 org-info.js for your website."
1003 :group
'org-export-html
1005 :package-version
'(Org .
"8.0")
1008 (defcustom org-html-divs
1009 '((preamble "div" "preamble")
1010 (content "div" "content")
1011 (postamble "div" "postamble"))
1012 "Alist of the three section elements for HTML export.
1013 The car of each entry is one of `preamble', `content' or `postamble'.
1014 The cdrs of each entry are the ELEMENT_TYPE and ID for each
1015 section of the exported document.
1017 Note that changing the default will prevent you from using
1018 org-info.js for your website."
1019 :group
'org-export-html
1021 :package-version
'(Org .
"8.0")
1022 :type
'(list :greedy t
1023 (list :tag
"Preamble"
1024 (const :format
"" preamble
)
1025 (string :tag
"element") (string :tag
" id"))
1026 (list :tag
"Content"
1027 (const :format
"" content
)
1028 (string :tag
"element") (string :tag
" id"))
1029 (list :tag
"Postamble" (const :format
"" postamble
)
1030 (string :tag
" id") (string :tag
"element"))))
1032 (defconst org-html-checkbox-types
1034 ((on .
"☑") (off .
"☐") (trans .
"☐")))
1036 ((on .
"<code>[X]</code>")
1037 (off .
"<code>[ ]</code>")
1038 (trans .
"<code>[-]</code>")))
1040 ((on .
"<input type='checkbox' checked='checked' />")
1041 (off .
"<input type='checkbox' />")
1042 (trans .
"<input type='checkbox' />"))))
1043 "Alist of checkbox types.
1044 The cdr of each entry is an alist list three checkbox types for
1045 HTML export: `on', `off' and `trans'.
1048 `unicode' Unicode characters (HTML entities)
1049 `ascii' ASCII characters
1050 `html' HTML checkboxes
1052 Note that only the ascii characters implement tri-state
1053 checkboxes. The other two use the `off' checkbox for `trans'.")
1055 (defcustom org-html-checkbox-type
'ascii
1056 "The type of checkboxes to use for HTML export.
1057 See `org-html-checkbox-types' for for the values used for each
1059 :group
'org-export-html
1061 :package-version
'(Org .
"8.0")
1063 (const :tag
"ASCII characters" ascii
)
1064 (const :tag
"Unicode characters" unicode
)
1065 (const :tag
"HTML checkboxes" html
)))
1067 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
1068 "Format used for timestamps in preamble, postamble and metadata.
1069 See `format-time-string' for more information on its components."
1070 :group
'org-export-html
1072 :package-version
'(Org .
"8.0")
1075 ;;;; Template :: Mathjax
1077 (defcustom org-html-mathjax-options
1078 '((path "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" )
1082 (linebreaks "false")
1085 (multlinewidth "85%")
1088 "Options for MathJax setup.
1090 Alist of the following elements. All values are strings.
1092 path The path to MathJax.
1093 scale Scaling with HTML-CSS, MathML and SVG output engines.
1094 align How to align display math: left, center, or right.
1095 font The font to use with HTML-CSS and SVG output. As of MathJax 2.5
1096 the following values are understood: \"TeX\", \"STIX-Web\",
1097 \"Asana-Math\", \"Neo-Euler\", \"Gyre-Pagella\",
1098 \"Gyre-Termes\", and \"Latin-Modern\".
1099 linebreaks Let MathJax perform automatic linebreaks. Valid values
1100 are \"true\" and \"false\".
1101 indent If align is not center, how far from the left/right side?
1102 Valid values are \"left\" and \"right\"
1103 multlinewidth The width of the multline environment.
1104 autonumber How to number equations. Valid values are \"None\",
1105 \"all\" and \"AMS Math\".
1106 tagindent The amount tags are indented.
1107 tagside Which side to show tags/labels on. Valid values are
1108 \"left\" and \"right\"
1110 You can also customize this for each buffer, using something like
1112 #+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
1114 For further information about MathJax options, see the MathJax documentation:
1116 http://docs.mathjax.org/
1118 Please note that by using the default CDN one must agree with
1119 MathJax CDN Terms of Service.
1121 http://www.mathjax.org/mathjax-cdn-terms-of-service.html"
1122 :group
'org-export-html
1123 :package-version
'(Org .
"8.3")
1124 :type
'(list :greedy t
1125 (list :tag
"path (the path from where to load MathJax.js)"
1126 (const :format
" " path
) (string))
1127 (list :tag
"scale (scaling for the displayed math)"
1128 (const :format
" " scale
) (string))
1129 (list :tag
"align (alignment of displayed equations)"
1130 (const :format
" " align
) (string))
1131 (list :tag
"font (used to display math)"
1132 (const :format
" " font
)
1133 (choice (const "TeX")
1135 (const "Asana-Math")
1137 (const "Gyre-Pagella")
1138 (const "Gyre-Termes")
1139 (const "Latin-Modern")))
1140 (list :tag
"linebreaks (automatic line-breaking)"
1141 (const :format
" " linebreaks
)
1142 (choice (const "true")
1144 (list :tag
"autonumber (when should equations be numbered)"
1145 (const :format
" " autonumber
)
1146 (choice (const "AMS")
1149 (list :tag
"indent (indentation with left or right alignment)"
1150 (const :format
" " indent
) (string))
1151 (list :tag
"multlinewidth (width to use for the multline environment)"
1152 (const :format
" " multlinewidth
) (string))
1153 (list :tag
"tagindent (the indentation of tags from left or right)"
1154 (const :format
" " tagindent
) (string))
1155 (list :tag
"tagside (location of tags)"
1156 (const :format
" " tagside
)
1157 (choice (const "left")
1160 (defcustom org-html-mathjax-template
1161 "<script type=\"text/x-mathjax-config\">
1162 MathJax.Hub.Config({
1163 displayAlign: \"%ALIGN\",
1164 displayIndent: \"%INDENT\",
1166 \"HTML-CSS\": { scale: %SCALE,
1167 linebreaks: { automatic: \"%LINEBREAKS\" },
1170 SVG: {scale: %SCALE,
1171 linebreaks: { automatic: \"%LINEBREAKS\" },
1173 NativeMML: {scale: %SCALE},
1174 TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"},
1175 MultLineWidth: \"%MULTLINEWIDTH\",
1176 TagSide: \"%TAGSIDE\",
1177 TagIndent: \"%TAGINDENT\"
1181 <script type=\"text/javascript\"
1182 src=\"%PATH\"></script>"
1183 "The MathJax template. See also `org-html-mathjax-options'."
1184 :group
'org-export-html
1187 ;;;; Template :: Postamble
1189 (defcustom org-html-postamble
'auto
1190 "Non-nil means insert a postamble in HTML export.
1192 When set to `auto', check against the
1193 `org-export-with-author/email/creator/date' variables to set the
1194 content of the postamble. When set to a string, use this string
1195 as the postamble. When t, insert a string as defined by the
1196 formatting string in `org-html-postamble-format'.
1198 When set to a function, apply this function and insert the
1199 returned string. The function takes the property list of export
1200 options as its only argument.
1202 Setting :html-postamble in publishing projects will take
1203 precedence over this variable."
1204 :group
'org-export-html
1205 :type
'(choice (const :tag
"No postamble" nil
)
1206 (const :tag
"Auto postamble" auto
)
1207 (const :tag
"Default formatting string" t
)
1208 (string :tag
"Custom formatting string")
1209 (function :tag
"Function (must return a string)")))
1211 (defcustom org-html-postamble-format
1212 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1213 <p class=\"date\">Date: %d</p>
1214 <p class=\"creator\">%c</p>
1215 <p class=\"validation\">%v</p>"))
1216 "Alist of languages and format strings for the HTML postamble.
1218 The first element of each list is the language code, as used for
1219 the LANGUAGE keyword. See `org-export-default-language'.
1221 The second element of each list is a format string to format the
1222 postamble itself. This format string can contain these elements:
1224 %t stands for the title.
1225 %s stands for the subtitle.
1226 %a stands for the author's name.
1227 %e stands for the author's email.
1228 %d stands for the date.
1229 %c will be replaced by `org-html-creator-string'.
1230 %v will be replaced by `org-html-validation-link'.
1231 %T will be replaced by the export time.
1232 %C will be replaced by the last modification time.
1234 If you need to use a \"%\" character, you need to escape it
1236 :group
'org-export-html
1238 (list (string :tag
"Language")
1239 (string :tag
"Format string"))))
1241 (defcustom org-html-validation-link
1242 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1243 "Link to HTML validation service."
1244 :group
'org-export-html
1247 (defcustom org-html-creator-string
1248 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1250 (if (fboundp 'org-version
) (org-version) "unknown version"))
1251 "Information about the creator of the HTML document.
1252 This option can also be set on with the CREATOR keyword."
1253 :group
'org-export-html
1255 :package-version
'(Org .
"8.0")
1256 :type
'(string :tag
"Creator string"))
1258 ;;;; Template :: Preamble
1260 (defcustom org-html-preamble t
1261 "Non-nil means insert a preamble in HTML export.
1263 When t, insert a string as defined by the formatting string in
1264 `org-html-preamble-format'. When set to a string, use this
1265 formatting string instead (see `org-html-postamble-format' for an
1266 example of such a formatting string).
1268 When set to a function, apply this function and insert the
1269 returned string. The function takes the property list of export
1270 options as its only argument.
1272 Setting :html-preamble in publishing projects will take
1273 precedence over this variable."
1274 :group
'org-export-html
1275 :type
'(choice (const :tag
"No preamble" nil
)
1276 (const :tag
"Default preamble" t
)
1277 (string :tag
"Custom formatting string")
1278 (function :tag
"Function (must return a string)")))
1280 (defcustom org-html-preamble-format
'(("en" ""))
1281 "Alist of languages and format strings for the HTML preamble.
1283 The first element of each list is the language code, as used for
1284 the LANGUAGE keyword. See `org-export-default-language'.
1286 The second element of each list is a format string to format the
1287 preamble itself. This format string can contain these elements:
1289 %t stands for the title.
1290 %s stands for the subtitle.
1291 %a stands for the author's name.
1292 %e stands for the author's email.
1293 %d stands for the date.
1294 %c will be replaced by `org-html-creator-string'.
1295 %v will be replaced by `org-html-validation-link'.
1296 %T will be replaced by the export time.
1297 %C will be replaced by the last modification time.
1299 If you need to use a \"%\" character, you need to escape it
1302 See the default value of `org-html-postamble-format' for an
1304 :group
'org-export-html
1306 (list (string :tag
"Language")
1307 (string :tag
"Format string"))))
1309 (defcustom org-html-link-up
""
1310 "Where should the \"UP\" link of exported HTML pages lead?"
1311 :group
'org-export-html
1312 :type
'(string :tag
"File or URL"))
1314 (defcustom org-html-link-home
""
1315 "Where should the \"HOME\" link of exported HTML pages lead?"
1316 :group
'org-export-html
1317 :type
'(string :tag
"File or URL"))
1319 (defcustom org-html-link-use-abs-url nil
1320 "Should we prepend relative links with HTML_LINK_HOME?"
1321 :group
'org-export-html
1323 :package-version
'(Org .
"8.1")
1326 (defcustom org-html-home
/up-format
1327 "<div id=\"org-div-home-and-up\">
1328 <a accesskey=\"h\" href=\"%s\"> UP </a>
1330 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1332 "Snippet used to insert the HOME and UP links.
1333 This is a format string, the first %s will receive the UP link,
1334 the second the HOME link. If both `org-html-link-up' and
1335 `org-html-link-home' are empty, the entire snippet will be
1337 :group
'org-export-html
1340 ;;;; Template :: Scripts
1342 (define-obsolete-variable-alias
1343 'org-html-style-include-scripts
'org-html-head-include-scripts
"24.4")
1344 (defcustom org-html-head-include-scripts t
1345 "Non-nil means include the JavaScript snippets in exported HTML files.
1346 The actual script is defined in `org-html-scripts' and should
1348 :group
'org-export-html
1350 :package-version
'(Org .
"8.0")
1353 ;;;; Template :: Styles
1355 (define-obsolete-variable-alias
1356 'org-html-style-include-default
'org-html-head-include-default-style
"24.4")
1357 (defcustom org-html-head-include-default-style t
1358 "Non-nil means include the default style in exported HTML files.
1359 The actual style is defined in `org-html-style-default' and
1360 should not be modified. Use `org-html-head' to use your own
1362 :group
'org-export-html
1364 :package-version
'(Org .
"8.0")
1367 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1369 (define-obsolete-variable-alias 'org-html-style
'org-html-head
"24.4")
1370 (defcustom org-html-head
""
1371 "Org-wide head definitions for exported HTML files.
1373 This variable can contain the full HTML structure to provide a
1374 style, including the surrounding HTML tags. You can consider
1375 including definitions for the following classes: title, todo,
1376 done, timestamp, timestamp-kwd, tag, target.
1378 For example, a valid value would be:
1380 <style type=\"text/css\">
1382 p { font-weight: normal; color: gray; }
1383 h1 { color: black; }
1384 .title { text-align: center; }
1385 .todo, .timestamp-kwd { color: red; }
1386 .done { color: green; }
1390 If you want to refer to an external style, use something like
1392 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1394 As the value of this option simply gets inserted into the HTML
1395 <head> header, you can use it to add any arbitrary text to the
1398 You can set this on a per-file basis using #+HTML_HEAD:,
1399 or for publication projects using the :html-head property."
1400 :group
'org-export-html
1402 :package-version
'(Org .
"8.0")
1405 (put 'org-html-head
'safe-local-variable
'stringp
)
1407 (defcustom org-html-head-extra
""
1408 "More head information to add in the HTML output.
1410 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1411 or for publication projects using the :html-head-extra property."
1412 :group
'org-export-html
1414 :package-version
'(Org .
"8.0")
1417 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1419 ;;;; Template :: Viewport
1421 (defcustom org-html-viewport
'((width "device-width")
1426 "Viewport options for mobile-optimized sites.
1428 The following values are recognized
1430 width Size of the viewport.
1431 initial-scale Zoom level when the page is first loaded.
1432 minimum-scale Minimum allowed zoom level.
1433 maximum-scale Maximum allowed zoom level.
1434 user-scalable Whether zoom can be changed.
1436 The viewport meta tag is inserted if this variable is non-nil.
1438 See the following site for a reference:
1439 https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag"
1440 :group
'org-export-html
1442 :package-version
'(Org .
"8.3")
1443 :type
'(choice (const :tag
"Disable" nil
)
1445 (list :tag
"Width of viewport"
1446 (const :format
" " width
)
1447 (choice (const :tag
"unset" "")
1449 (list :tag
"Initial scale"
1450 (const :format
" " initial-scale
)
1451 (choice (const :tag
"unset" "")
1453 (list :tag
"Minimum scale/zoom"
1454 (const :format
" " minimum-scale
)
1455 (choice (const :tag
"unset" "")
1457 (list :tag
"Maximum scale/zoom"
1458 (const :format
" " maximum-scale
)
1459 (choice (const :tag
"unset" "")
1461 (list :tag
"User scalable/zoomable"
1462 (const :format
" " user-scalable
)
1463 (choice (const :tag
"unset" "")
1465 (const "false"))))))
1469 (defcustom org-html-todo-kwd-class-prefix
""
1470 "Prefix to class names for TODO keywords.
1471 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1472 The default prefix is empty because it is nice to just use the keyword
1473 as a class name. But if you get into conflicts with other, existing
1474 CSS classes, then this prefix can be very useful."
1475 :group
'org-export-html
1479 ;;; Internal Functions
1481 (defun org-html-xhtml-p (info)
1482 (let ((dt (downcase (plist-get info
:html-doctype
))))
1483 (string-match-p "xhtml" dt
)))
1485 (defun org-html-html5-p (info)
1486 (let ((dt (downcase (plist-get info
:html-doctype
))))
1487 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1489 (defun org-html--html5-fancy-p (info)
1490 "Non-nil when exporting to HTML5 with fancy elements.
1491 INFO is the current state of the export process, as a plist."
1492 (and (plist-get info
:html-html5-fancy
)
1493 (org-html-html5-p info
)))
1495 (defun org-html-close-tag (tag attr info
)
1496 (concat "<" tag
" " attr
1497 (if (org-html-xhtml-p info
) " />" ">")))
1499 (defun org-html-doctype (info)
1500 "Return correct html doctype tag from `org-html-doctype-alist',
1501 or the literal value of :html-doctype from INFO if :html-doctype
1502 is not found in the alist.
1503 INFO is a plist used as a communication channel."
1504 (let ((dt (plist-get info
:html-doctype
)))
1505 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1507 (defun org-html--make-attribute-string (attributes)
1508 "Return a list of attributes, as a string.
1509 ATTRIBUTES is a plist where values are either strings or nil. An
1510 attributes with a nil value will be omitted from the result."
1512 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1513 (cond ((null item
) (pop output
))
1514 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1515 (t (let ((key (car output
))
1516 (value (replace-regexp-in-string
1517 "\"" """ (org-html-encode-plain-text item
))))
1518 (setcar output
(format "%s=\"%s\"" key value
))))))))
1520 (defun org-html--wrap-image (contents info
&optional caption label
)
1521 "Wrap CONTENTS string within an appropriate environment for images.
1522 INFO is a plist used as a communication channel. When optional
1523 arguments CAPTION and LABEL are given, use them for caption and
1525 (let ((html5-fancy (org-html--html5-fancy-p info
)))
1526 (format (if html5-fancy
"\n<figure%s>%s%s\n</figure>"
1527 "\n<div%s class=\"figure\">%s%s\n</div>")
1529 (if (org-string-nw-p label
) (format " id=\"%s\"" label
) "")
1531 (format "\n<p>%s</p>" contents
)
1533 (if (not (org-string-nw-p caption
)) ""
1534 (format (if html5-fancy
"\n<figcaption>%s</figcaption>"
1538 (defun org-html--format-image (source attributes info
)
1539 "Return \"img\" tag with given SOURCE and ATTRIBUTES.
1540 SOURCE is a string specifying the location of the image.
1541 ATTRIBUTES is a plist, as returned by
1542 `org-export-read-attribute'. INFO is a plist used as
1543 a communication channel."
1544 (if (string= "svg" (file-name-extension source
))
1545 (org-html--svg-image source attributes info
)
1548 (org-html--make-attribute-string
1551 :alt
(if (string-match-p "^ltxpng/" source
)
1552 (org-html-encode-plain-text
1553 (org-find-text-property-in-string 'org-latex-src source
))
1554 (file-name-nondirectory source
)))
1558 (defun org-html--svg-image (source attributes info
)
1559 "Return \"object\" appropriate for embedding svg file SOURCE
1560 with assoicated ATTRIBUTES. INFO is a plist used as a
1561 communication channel.
1563 The special attribute \"fallback\" can be used to specify a fallback
1564 image file to use if the object embedding is not supported."
1565 (let ((fallback (plist-get attributes
:fallback
))
1566 (attrs (org-html--make-attribute-string
1567 (plist-put attributes
:fallback nil
))))
1568 (format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>"
1572 "img" (format "src=\"%s\" %s" fallback attrs
) info
)
1573 "Sorry, your browser does not support SVG."))))
1575 (defun org-html--textarea-block (element)
1576 "Transcode ELEMENT into a textarea block.
1577 ELEMENT is either a src block or an example block."
1578 (let* ((code (car (org-export-unravel-code element
)))
1579 (attr (org-export-read-attribute :attr_html element
)))
1580 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1581 (or (plist-get attr
:width
) 80)
1582 (or (plist-get attr
:height
) (org-count-lines code
))
1585 (defun org-html--has-caption-p (element &optional _info
)
1586 "Non-nil when ELEMENT has a caption affiliated keyword.
1587 INFO is a plist used as a communication channel. This function
1588 is meant to be used as a predicate for `org-export-get-ordinal' or
1589 a value to `org-html-standalone-image-predicate'."
1590 (org-element-property :caption element
))
1594 (defun org-html-htmlize-region-for-paste (beg end
)
1595 "Convert the region between BEG and END to HTML, using htmlize.el.
1596 This is much like `htmlize-region-for-paste', only that it uses
1597 the settings define in the org-... variables."
1598 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1599 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1600 (htmlbuf (htmlize-region beg end
)))
1602 (with-current-buffer htmlbuf
1603 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1604 (plist-get htmlize-buffer-places
'content-end
)))
1605 (kill-buffer htmlbuf
))))
1608 (defun org-html-htmlize-generate-css ()
1609 "Create the CSS for all font definitions in the current Emacs session.
1610 Use this to create face definitions in your CSS style file that can then
1611 be used by code snippets transformed by htmlize.
1612 This command just produces a buffer that contains class definitions for all
1613 faces used in the current Emacs session. You can copy and paste the ones you
1614 need into your CSS file.
1616 If you then set `org-html-htmlize-output-type' to `css', calls
1617 to the function `org-html-htmlize-region-for-paste' will
1618 produce code that uses these same face definitions."
1621 (and (get-buffer "*html*") (kill-buffer "*html*"))
1623 (let ((fl (face-list))
1624 (htmlize-css-name-prefix "org-")
1625 (htmlize-output-type 'css
)
1627 (while (setq f
(pop fl
)
1628 i
(and f
(face-attribute f
:inherit
)))
1629 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1630 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1631 (htmlize-region (point-min) (point-max))))
1632 (org-pop-to-buffer-same-window "*html*")
1633 (goto-char (point-min))
1634 (if (re-search-forward "<style" nil t
)
1635 (delete-region (point-min) (match-beginning 0)))
1636 (if (re-search-forward "</style>" nil t
)
1637 (delete-region (1+ (match-end 0)) (point-max)))
1638 (beginning-of-line 1)
1639 (if (looking-at " +") (replace-match ""))
1640 (goto-char (point-min)))
1642 (defun org-html--make-string (n string
)
1643 "Build a string by concatenating N times STRING."
1644 (let (out) (dotimes (_ n out
) (setq out
(concat string out
)))))
1646 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1647 "Turn todo keyword KWD into a valid class name.
1648 Replaces invalid characters with \"_\"."
1650 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1651 (setq kwd
(replace-match "_" t t kwd
))))
1654 (defun org-html-footnote-section (info)
1655 "Format the footnote section.
1656 INFO is a plist used as a communication channel."
1657 (let* ((fn-alist (org-export-collect-footnote-definitions info
))
1659 (loop for
(n _type raw
) in fn-alist collect
1660 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1661 (org-trim (org-export-data raw info
))
1662 (format "<div class=\"footpara\">%s</div>"
1663 (org-trim (org-export-data raw info
))))))))
1666 (plist-get info
:html-footnotes-section
)
1667 (org-html--translate "Footnotes" info
)
1672 (let ((n (car fn
)) (def (cdr fn
)))
1674 "<div class=\"footdef\">%s %s</div>\n"
1676 (plist-get info
:html-footnote-format
)
1680 (format " class=\"footnum\" href=\"#fnr.%d\"" n
)
1689 (defun org-html--build-meta-info (info)
1690 "Return meta tags for exported document.
1691 INFO is a plist used as a communication channel."
1692 (let ((protect-string
1694 (replace-regexp-in-string
1695 "\"" """ (org-html-encode-plain-text str
))))
1696 (title (org-export-data (plist-get info
:title
) info
))
1697 (author (and (plist-get info
:with-author
)
1698 (let ((auth (plist-get info
:author
)))
1700 ;; Return raw Org syntax, skipping non
1701 ;; exportable objects.
1702 (org-element-interpret-data
1703 (org-element-map auth
1704 (cons 'plain-text org-element-all-objects
)
1705 'identity info
))))))
1706 (description (plist-get info
:description
))
1707 (keywords (plist-get info
:keywords
))
1708 (charset (or (and org-html-coding-system
1709 (fboundp 'coding-system-get
)
1710 (coding-system-get org-html-coding-system
1714 (when (plist-get info
:time-stamp-file
)
1717 (plist-get info
:html-metadata-timestamp-format
)
1720 (if (org-html-html5-p info
)
1721 (org-html-close-tag "meta" "charset=\"%s\"" info
)
1723 "meta" "http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1726 (let ((viewport-options
1727 (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell
)))
1728 (plist-get info
:html-viewport
))))
1729 (and viewport-options
1733 (format "name=\"viewport\" content=\"%s\""
1735 (lambda (elm) (format "%s=%s" (car elm
) (cadr elm
)))
1736 viewport-options
", "))
1739 (format "<title>%s</title>\n" title
)
1740 (org-html-close-tag "meta" "name=\"generator\" content=\"Org-mode\"" info
)
1742 (and (org-string-nw-p author
)
1744 (org-html-close-tag "meta"
1745 (format "name=\"author\" content=\"%s\""
1746 (funcall protect-string author
))
1749 (and (org-string-nw-p description
)
1751 (org-html-close-tag "meta"
1752 (format "name=\"description\" content=\"%s\"\n"
1753 (funcall protect-string description
))
1756 (and (org-string-nw-p keywords
)
1758 (org-html-close-tag "meta"
1759 (format "name=\"keywords\" content=\"%s\""
1760 (funcall protect-string keywords
))
1764 (defun org-html--build-head (info)
1765 "Return information for the <head>..</head> of the HTML output.
1766 INFO is a plist used as a communication channel."
1767 (org-element-normalize-string
1769 (when (plist-get info
:html-head-include-default-style
)
1770 (org-element-normalize-string org-html-style-default
))
1771 (org-element-normalize-string (plist-get info
:html-head
))
1772 (org-element-normalize-string (plist-get info
:html-head-extra
))
1773 (when (and (plist-get info
:html-htmlized-css-url
)
1774 (eq org-html-htmlize-output-type
'css
))
1775 (org-html-close-tag "link"
1776 (format "rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1777 (plist-get info
:html-htmlized-css-url
))
1779 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1781 (defun org-html--build-mathjax-config (info)
1782 "Insert the user setup into the mathjax template.
1783 INFO is a plist used as a communication channel."
1784 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1785 (org-element-map (plist-get info
:parse-tree
)
1786 '(latex-fragment latex-environment
) 'identity info t
))
1787 (let ((template (plist-get info
:html-mathjax-template
))
1788 (options (plist-get info
:html-mathjax-options
))
1789 (in-buffer (or (plist-get info
:html-mathjax
) "")))
1790 (dolist (e options
(org-element-normalize-string template
))
1791 (let ((name (car e
))
1793 (when (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1795 (car (read-from-string (substring in-buffer
(match-end 0))))))
1796 (unless (stringp val
) (setq val
(format "%s" val
)))
1797 (while (string-match (concat "%" (upcase (symbol-name name
)))
1799 (setq template
(replace-match val t t template
))))))))
1801 (defun org-html-format-spec (info)
1802 "Return format specification for elements that can be
1803 used in the preamble or postamble."
1804 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1805 (?s .
,(org-export-data (plist-get info
:subtitle
) info
))
1806 (?d .
,(org-export-data (org-export-get-date info
) info
))
1807 (?T .
,(format-time-string
1808 (plist-get info
:html-metadata-timestamp-format
)))
1809 (?a .
,(org-export-data (plist-get info
:author
) info
))
1812 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1813 (split-string (plist-get info
:email
) ",+ *")
1815 (?c .
,(plist-get info
:creator
))
1816 (?C .
,(let ((file (plist-get info
:input-file
)))
1818 (plist-get info
:html-metadata-timestamp-format
)
1819 (when file
(nth 5 (file-attributes file
))))))
1820 (?v .
,(or (plist-get info
:html-validation-link
) ""))))
1822 (defun org-html--build-pre/postamble
(type info
)
1823 "Return document preamble or postamble as a string, or nil.
1824 TYPE is either `preamble' or `postamble', INFO is a plist used as a
1825 communication channel."
1826 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1827 (spec (org-html-format-spec info
)))
1829 (let ((section-contents
1830 (if (functionp section
) (funcall section info
)
1832 ((stringp section
) (format-spec section spec
))
1834 (let ((date (cdr (assq ?d spec
)))
1835 (author (cdr (assq ?a spec
)))
1836 (email (cdr (assq ?e spec
)))
1837 (creator (cdr (assq ?c spec
)))
1838 (validation-link (cdr (assq ?v spec
))))
1840 (when (and (plist-get info
:with-date
)
1841 (org-string-nw-p date
))
1842 (format "<p class=\"date\">%s: %s</p>\n"
1843 (org-html--translate "Date" info
)
1845 (when (and (plist-get info
:with-author
)
1846 (org-string-nw-p author
))
1847 (format "<p class=\"author\">%s: %s</p>\n"
1848 (org-html--translate "Author" info
)
1850 (when (and (plist-get info
:with-email
)
1851 (org-string-nw-p email
))
1852 (format "<p class=\"email\">%s: %s</p>\n"
1853 (org-html--translate "Email" info
)
1855 (when (plist-get info
:time-stamp-file
)
1857 "<p class=\"date\">%s: %s</p>\n"
1858 (org-html--translate "Created" info
)
1860 (plist-get info
:html-metadata-timestamp-format
))))
1861 (when (plist-get info
:with-creator
)
1862 (format "<p class=\"creator\">%s</p>\n" creator
))
1863 (format "<p class=\"validation\">%s</p>\n"
1867 (plist-get info
:language
)
1869 (format "org-html-%s-format" type
)))))
1874 (intern (format "org-html-%s-format" type
))))))
1876 (let ((div (assq type
(plist-get info
:html-divs
))))
1877 (when (org-string-nw-p section-contents
)
1879 (format "<%s id=\"%s\" class=\"%s\">\n"
1882 org-html--pre
/postamble-class
)
1883 (org-element-normalize-string section-contents
)
1884 (format "</%s>\n" (nth 1 div
)))))))))
1886 (defun org-html-inner-template (contents info
)
1887 "Return body of document string after HTML conversion.
1888 CONTENTS is the transcoded contents string. INFO is a plist
1889 holding export options."
1891 ;; Table of contents.
1892 (let ((depth (plist-get info
:with-toc
)))
1893 (when depth
(org-html-toc depth info
)))
1894 ;; Document contents.
1896 ;; Footnotes section.
1897 (org-html-footnote-section info
)))
1899 (defun org-html-template (contents info
)
1900 "Return complete document string after HTML conversion.
1901 CONTENTS is the transcoded contents string. INFO is a plist
1902 holding export options."
1904 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1905 (let* ((xml-declaration (plist-get info
:html-xml-declaration
))
1906 (decl (or (and (stringp xml-declaration
) xml-declaration
)
1907 (cdr (assoc (plist-get info
:html-extension
)
1909 (cdr (assoc "html" xml-declaration
))
1911 (when (not (or (not decl
) (string= "" decl
)))
1914 (or (and org-html-coding-system
1915 (fboundp 'coding-system-get
)
1916 (coding-system-get org-html-coding-system
'mime-charset
))
1918 (org-html-doctype info
)
1921 (cond ((org-html-xhtml-p info
)
1923 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1924 (plist-get info
:language
) (plist-get info
:language
)))
1925 ((org-html-html5-p info
)
1926 (format " lang=\"%s\"" (plist-get info
:language
))))
1929 (org-html--build-meta-info info
)
1930 (org-html--build-head info
)
1931 (org-html--build-mathjax-config info
)
1934 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1935 (link-home (org-trim (plist-get info
:html-link-home
))))
1936 (unless (and (string= link-up
"") (string= link-home
""))
1937 (format (plist-get info
:html-home
/up-format
)
1938 (or link-up link-home
)
1939 (or link-home link-up
))))
1941 (org-html--build-pre/postamble
'preamble info
)
1942 ;; Document contents.
1943 (let ((div (assq 'content
(plist-get info
:html-divs
))))
1944 (format "<%s id=\"%s\">\n" (nth 1 div
) (nth 2 div
)))
1946 (when (plist-get info
:with-title
)
1947 (let ((title (plist-get info
:title
))
1948 (subtitle (plist-get info
:subtitle
))
1949 (html5-fancy (org-html--html5-fancy-p info
)))
1953 "<header>\n<h1 class=\"title\">%s</h1>\n%s</header>"
1954 "<h1 class=\"title\">%s%s</h1>\n")
1955 (org-export-data title info
)
1959 "<p class=\"subtitle\">%s</p>\n"
1960 "\n<br>\n<span class=\"subtitle\">%s</span>\n")
1961 (org-export-data subtitle info
))
1964 (format "</%s>\n" (nth 1 (assq 'content
(plist-get info
:html-divs
))))
1966 (org-html--build-pre/postamble
'postamble info
)
1967 ;; Closing document.
1968 "</body>\n</html>"))
1970 (defun org-html--translate (s info
)
1971 "Translate string S according to specified language.
1972 INFO is a plist used as a communication channel."
1973 (org-export-translate s
:html info
))
1977 (defun org-html--anchor (id desc attributes info
)
1978 "Format a HTML anchor."
1979 (let* ((name (and (plist-get info
:html-allow-name-attribute-in-anchors
) id
))
1980 (attributes (concat (and id
(format " id=\"%s\"" id
))
1981 (and name
(format " name=\"%s\"" name
))
1983 (format "<a%s>%s</a>" attributes
(or desc
""))))
1987 (defun org-html--todo (todo info
)
1988 "Format TODO keywords into HTML."
1990 (format "<span class=\"%s %s%s\">%s</span>"
1991 (if (member todo org-done-keywords
) "done" "todo")
1992 (or (plist-get info
:html-todo-kwd-class-prefix
) "")
1993 (org-html-fix-class-name todo
)
1998 (defun org-html--priority (priority _info
)
1999 "Format a priority into HTML.
2000 PRIORITY is the character code of the priority or nil. INFO is
2001 a plist containing export options."
2002 (and priority
(format "<span class=\"priority\">[%c]</span>" priority
)))
2006 (defun org-html--tags (tags info
)
2007 "Format TAGS into HTML.
2008 INFO is a plist containing export options."
2010 (format "<span class=\"tag\">%s</span>"
2013 (format "<span class=\"%s\">%s</span>"
2014 (concat (plist-get info
:html-tag-class-prefix
)
2015 (org-html-fix-class-name tag
))
2021 (defun org-html-fontify-code (code lang
)
2022 "Color CODE with htmlize library.
2023 CODE is a string representing the source code to colorize. LANG
2024 is the language used for CODE, as a string, or nil."
2027 ;; Case 1: No lang. Possibly an example block.
2029 ;; Simple transcoding.
2030 (org-html-encode-plain-text code
))
2031 ;; Case 2: No htmlize or an inferior version of htmlize
2032 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
2034 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
2035 ;; Simple transcoding.
2036 (org-html-encode-plain-text code
))
2037 ;; Case 3: plain text explicitly set
2038 ((not org-html-htmlize-output-type
)
2039 ;; Simple transcoding.
2040 (org-html-encode-plain-text code
))
2043 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
2044 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
2046 ;; Case 1: Language is not associated with any Emacs mode
2047 ((not (functionp lang-mode
))
2048 ;; Simple transcoding.
2049 (org-html-encode-plain-text code
))
2050 ;; Case 2: Default. Fontify code.
2054 (let ((output-type org-html-htmlize-output-type
)
2055 (font-prefix org-html-htmlize-font-prefix
))
2057 ;; Switch to language-specific mode.
2061 (org-font-lock-ensure)
2062 ;; Remove formatting on newline characters.
2064 (let ((beg (point-min))
2067 (while (progn (end-of-line) (< (point) end
))
2068 (put-text-property (point) (1+ (point)) 'face nil
)
2071 (set-buffer-modified-p nil
)
2073 (let ((org-html-htmlize-output-type output-type
)
2074 (org-html-htmlize-font-prefix font-prefix
))
2075 (org-html-htmlize-region-for-paste
2076 (point-min) (point-max))))))
2077 ;; Strip any enclosing <pre></pre> tags.
2078 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
2079 (end (and beg
(string-match "</pre>\\'" code
))))
2080 (if (and beg end
) (substring code beg end
) code
)))))))))
2082 (defun org-html-do-format-code
2083 (code &optional lang refs retain-labels num-start
)
2084 "Format CODE string as source code.
2085 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
2086 respectively, the language of the source code, as a string, an
2087 alist between line numbers and references (as returned by
2088 `org-export-unravel-code'), a boolean specifying if labels should
2089 appear in the source code, and the number associated to the first
2091 (let* ((code-lines (org-split-string code
"\n"))
2092 (code-length (length code-lines
))
2096 (length (number-to-string (+ code-length num-start
))))))
2097 (code (org-html-fontify-code code lang
)))
2098 (org-export-format-code
2100 (lambda (loc line-num ref
)
2103 ;; Add line number, if needed.
2105 (format "<span class=\"linenr\">%s</span>"
2106 (format num-fmt line-num
)))
2107 ;; Transcoded src line.
2109 ;; Add label, if needed.
2110 (when (and ref retain-labels
) (format " (%s)" ref
))))
2111 ;; Mark transcoded line as an anchor, if needed.
2113 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
2117 (defun org-html-format-code (element info
)
2118 "Format contents of ELEMENT as source code.
2119 ELEMENT is either an example block or a src block. INFO is
2120 a plist used as a communication channel."
2121 (let* ((lang (org-element-property :language element
))
2122 ;; Extract code and references.
2123 (code-info (org-export-unravel-code element
))
2124 (code (car code-info
))
2125 (refs (cdr code-info
))
2126 ;; Does the src block contain labels?
2127 (retain-labels (org-element-property :retain-labels element
))
2128 ;; Does it have line numbers?
2129 (num-start (case (org-element-property :number-lines element
)
2130 (continued (org-export-get-loc element info
))
2132 (org-html-do-format-code code lang refs retain-labels num-start
)))
2135 ;;; Tables of Contents
2137 (defun org-html-toc (depth info
&optional scope
)
2138 "Build a table of contents.
2139 DEPTH is an integer specifying the depth of the table. INFO is
2140 a plist used as a communication channel. Optional argument SCOPE
2141 is an element defining the scope of the table. Return the table
2142 of contents as a string, or nil if it is empty."
2144 (mapcar (lambda (headline)
2145 (cons (org-html--format-toc-headline headline info
)
2146 (org-export-get-relative-level headline info
)))
2147 (org-export-collect-headlines info depth scope
))))
2149 (let ((toc (concat "<div id=\"text-table-of-contents\">"
2150 (org-html--toc-text toc-entries
)
2153 (let ((outer-tag (if (org-html--html5-fancy-p info
)
2156 (concat (format "<%s id=\"table-of-contents\">\n" outer-tag
)
2157 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2158 (format "<h%d>%s</h%d>\n"
2160 (org-html--translate "Table of Contents" info
)
2163 (format "</%s>\n" outer-tag
))))))))
2165 (defun org-html--toc-text (toc-entries)
2166 "Return innards of a table of contents, as a string.
2167 TOC-ENTRIES is an alist where key is an entry title, as a string,
2168 and value is its relative level, as an integer."
2169 (let* ((prev-level (1- (cdar toc-entries
)))
2170 (start-level prev-level
))
2174 (let ((headline (car entry
))
2175 (level (cdr entry
)))
2177 (let* ((cnt (- level prev-level
))
2178 (times (if (> cnt
0) (1- cnt
) (- cnt
))))
2179 (setq prev-level level
)
2181 (org-html--make-string
2182 times
(cond ((> cnt
0) "\n<ul>\n<li>")
2183 ((< cnt
0) "</li>\n</ul>\n")))
2184 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
2187 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
2189 (defun org-html--format-toc-headline (headline info
)
2190 "Return an appropriate table of contents entry for HEADLINE.
2191 INFO is a plist used as a communication channel."
2192 (let* ((headline-number (org-export-get-headline-number headline info
))
2193 (todo (and (plist-get info
:with-todo-keywords
)
2194 (let ((todo (org-element-property :todo-keyword headline
)))
2195 (and todo
(org-export-data todo info
)))))
2196 (todo-type (and todo
(org-element-property :todo-type headline
)))
2197 (priority (and (plist-get info
:with-priority
)
2198 (org-element-property :priority headline
)))
2199 (text (org-export-data-with-backend
2200 (org-export-get-alt-title headline info
)
2201 ;; Create an anonymous back-end that will ignore any
2202 ;; footnote-reference, link, radio-target and target
2203 ;; in table of contents.
2204 (org-export-create-backend
2206 :transcoders
'((footnote-reference . ignore
)
2207 (link .
(lambda (object c i
) c
))
2208 (radio-target .
(lambda (object c i
) c
))
2211 (tags (and (eq (plist-get info
:with-tags
) t
)
2212 (org-export-get-tags headline info
))))
2213 (format "<a href=\"#%s\">%s</a>"
2215 (or (org-element-property :CUSTOM_ID headline
)
2216 (org-export-get-reference headline info
))
2219 (and (not (org-export-low-level-p headline info
))
2220 (org-export-numbered-headline-p headline info
)
2221 (concat (mapconcat #'number-to-string headline-number
".")
2223 (apply (plist-get info
:html-format-headline-function
)
2224 todo todo-type priority text tags
:section-number nil
)))))
2226 (defun org-html-list-of-listings (info)
2227 "Build a list of listings.
2228 INFO is a plist used as a communication channel. Return the list
2229 of listings as a string, or nil if it is empty."
2230 (let ((lol-entries (org-export-collect-listings info
)))
2232 (concat "<div id=\"list-of-listings\">\n"
2233 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2234 (format "<h%d>%s</h%d>\n"
2236 (org-html--translate "List of Listings" info
)
2238 "<div id=\"text-list-of-listings\">\n<ul>\n"
2240 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2241 (org-html--translate "Listing %d:" info
))))
2244 (let ((label (and (org-element-property :name entry
)
2245 (org-export-get-reference entry info
)))
2248 (or (org-export-get-caption entry t
)
2249 (org-export-get-caption entry
))
2254 (concat (format initial-fmt
(incf count
)) " " title
)
2255 (format "<a href=\"#%s\">%s %s</a>"
2257 (format initial-fmt
(incf count
))
2261 "\n</ul>\n</div>\n</div>"))))
2263 (defun org-html-list-of-tables (info)
2264 "Build a list of tables.
2265 INFO is a plist used as a communication channel. Return the list
2266 of tables as a string, or nil if it is empty."
2267 (let ((lol-entries (org-export-collect-tables info
)))
2269 (concat "<div id=\"list-of-tables\">\n"
2270 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2271 (format "<h%d>%s</h%d>\n"
2273 (org-html--translate "List of Tables" info
)
2275 "<div id=\"text-list-of-tables\">\n<ul>\n"
2277 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2278 (org-html--translate "Table %d:" info
))))
2281 (let ((label (and (org-element-property :name entry
)
2282 (org-export-get-reference entry info
)))
2285 (or (org-export-get-caption entry t
)
2286 (org-export-get-caption entry
))
2291 (concat (format initial-fmt
(incf count
)) " " title
)
2292 (format "<a href=\"#%s\">%s %s</a>"
2294 (format initial-fmt
(incf count
))
2298 "\n</ul>\n</div>\n</div>"))))
2301 ;;; Transcode Functions
2305 (defun org-html-bold (_bold contents info
)
2306 "Transcode BOLD from Org to HTML.
2307 CONTENTS is the text with bold markup. INFO is a plist holding
2308 contextual information."
2309 (format (or (cdr (assq 'bold
(plist-get info
:html-text-markup-alist
))) "%s")
2314 (defun org-html-center-block (_center-block contents _info
)
2315 "Transcode a CENTER-BLOCK element from Org to HTML.
2316 CONTENTS holds the contents of the block. INFO is a plist
2317 holding contextual information."
2318 (format "<div class=\"org-center\">\n%s</div>" contents
))
2322 (defun org-html-clock (clock _contents _info
)
2323 "Transcode a CLOCK element from Org to HTML.
2324 CONTENTS is nil. INFO is a plist used as a communication
2327 <span class=\"timestamp-wrapper\">
2328 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2332 (org-timestamp-translate (org-element-property :value clock
))
2333 (let ((time (org-element-property :duration clock
)))
2334 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2338 (defun org-html-code (code _contents info
)
2339 "Transcode CODE from Org to HTML.
2340 CONTENTS is nil. INFO is a plist holding contextual
2342 (format (or (cdr (assq 'code
(plist-get info
:html-text-markup-alist
))) "%s")
2343 (org-html-encode-plain-text (org-element-property :value code
))))
2347 (defun org-html-drawer (drawer contents info
)
2348 "Transcode a DRAWER element from Org to HTML.
2349 CONTENTS holds the contents of the block. INFO is a plist
2350 holding contextual information."
2351 (funcall (plist-get info
:html-format-drawer-function
)
2352 (org-element-property :drawer-name drawer
)
2357 (defun org-html-dynamic-block (_dynamic-block contents _info
)
2358 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2359 CONTENTS holds the contents of the block. INFO is a plist
2360 holding contextual information. See `org-export-data'."
2365 (defun org-html-entity (entity _contents _info
)
2366 "Transcode an ENTITY object from Org to HTML.
2367 CONTENTS are the definition itself. INFO is a plist holding
2368 contextual information."
2369 (org-element-property :html entity
))
2373 (defun org-html-example-block (example-block _contents info
)
2374 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2375 CONTENTS is nil. INFO is a plist holding contextual
2377 (let ((attributes (org-export-read-attribute :attr_html example-block
)))
2378 (if (plist-get attributes
:textarea
)
2379 (org-html--textarea-block example-block
)
2380 (format "<pre class=\"example\"%s>\n%s</pre>"
2381 (let* ((name (org-element-property :name example-block
))
2382 (a (org-html--make-attribute-string
2383 (if (or (not name
) (plist-member attributes
:id
))
2385 (plist-put attributes
:id name
)))))
2386 (if (org-string-nw-p a
) (concat " " a
) ""))
2387 (org-html-format-code example-block info
)))))
2391 (defun org-html-export-snippet (export-snippet _contents _info
)
2392 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2393 CONTENTS is nil. INFO is a plist holding contextual
2395 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2396 (org-element-property :value export-snippet
)))
2400 (defun org-html-export-block (export-block _contents _info
)
2401 "Transcode a EXPORT-BLOCK element from Org to HTML.
2402 CONTENTS is nil. INFO is a plist holding contextual information."
2403 (when (string= (org-element-property :type export-block
) "HTML")
2404 (org-remove-indentation (org-element-property :value export-block
))))
2408 (defun org-html-fixed-width (fixed-width _contents _info
)
2409 "Transcode a FIXED-WIDTH element from Org to HTML.
2410 CONTENTS is nil. INFO is a plist holding contextual information."
2411 (format "<pre class=\"example\">\n%s</pre>"
2412 (org-html-do-format-code
2413 (org-remove-indentation
2414 (org-element-property :value fixed-width
)))))
2416 ;;;; Footnote Reference
2418 (defun org-html-footnote-reference (footnote-reference _contents info
)
2419 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2420 CONTENTS is nil. INFO is a plist holding contextual information."
2422 ;; Insert separator between two footnotes in a row.
2423 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2424 (when (eq (org-element-type prev
) 'footnote-reference
)
2425 (plist-get info
:html-footnote-separator
)))
2426 (let* ((n (org-export-get-footnote-number footnote-reference info
))
2427 (id (format "fnr.%d%s"
2429 (if (org-export-footnote-first-reference-p
2430 footnote-reference info
)
2434 (plist-get info
:html-footnote-format
)
2436 id n
(format " class=\"footref\" href=\"#fn.%d\"" n
) info
)))))
2440 (defun org-html-headline (headline contents info
)
2441 "Transcode a HEADLINE element from Org to HTML.
2442 CONTENTS holds the contents of the headline. INFO is a plist
2443 holding contextual information."
2444 (unless (org-element-property :footnote-section-p headline
)
2445 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2446 (numbers (org-export-get-headline-number headline info
))
2447 (level (+ (org-export-get-relative-level headline info
)
2448 (1- (plist-get info
:html-toplevel-hlevel
))))
2449 (todo (and (plist-get info
:with-todo-keywords
)
2450 (let ((todo (org-element-property :todo-keyword headline
)))
2451 (and todo
(org-export-data todo info
)))))
2452 (todo-type (and todo
(org-element-property :todo-type headline
)))
2453 (priority (and (plist-get info
:with-priority
)
2454 (org-element-property :priority headline
)))
2455 (text (org-export-data (org-element-property :title headline
) info
))
2456 (tags (and (plist-get info
:with-tags
)
2457 (org-export-get-tags headline info
)))
2458 (full-text (funcall (plist-get info
:html-format-headline-function
)
2459 todo todo-type priority text tags info
))
2460 (contents (or contents
""))
2462 (list (org-element-property :CUSTOM_ID headline
)
2463 (org-export-get-reference headline info
)
2464 (org-element-property :ID headline
))))
2465 (preferred-id (car ids
))
2470 (if (org-uuidgen-p id
) (concat "ID-" id
) id
)
2473 (if (org-export-low-level-p headline info
)
2474 ;; This is a deep sub-tree: export it as a list item.
2475 (let* ((type (if numberedp
'ordered
'unordered
))
2477 (org-html-format-list-item
2478 contents type nil info nil
2479 (concat (org-html--anchor preferred-id nil nil info
)
2482 (concat (and (org-export-first-sibling-p headline info
)
2483 (org-html-begin-plain-list type
))
2485 (and (org-export-last-sibling-p headline info
)
2486 (org-html-end-plain-list type
))))
2487 (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2488 (first-content (car (org-element-contents headline
))))
2489 ;; Standard headline. Export it as a section.
2490 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2491 (org-html--container headline info
)
2492 (concat "outline-container-"
2493 (org-export-get-reference headline info
))
2494 (concat (format "outline-%d" level
)
2495 (and extra-class
" ")
2497 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2504 "<span class=\"section-number-%d\">%s</span> "
2506 (mapconcat #'number-to-string numbers
".")))
2509 ;; When there is no section, pretend there is an
2510 ;; empty one to get the correct <div
2511 ;; class="outline-...> which is needed by
2513 (if (eq (org-element-type first-content
) 'section
) contents
2514 (concat (org-html-section first-content
"" info
) contents
))
2515 (org-html--container headline info
)))))))
2517 (defun org-html-format-headline-default-function
2518 (todo _todo-type priority text tags info
)
2519 "Default format function for a headline.
2520 See `org-html-format-headline-function' for details."
2521 (let ((todo (org-html--todo todo info
))
2522 (priority (org-html--priority priority info
))
2523 (tags (org-html--tags tags info
)))
2524 (concat todo
(and todo
" ")
2525 priority
(and priority
" ")
2527 (and tags
"   ") tags
)))
2529 (defun org-html--container (headline info
)
2530 (or (org-element-property :HTML_CONTAINER headline
)
2531 (if (= 1 (org-export-get-relative-level headline info
))
2532 (plist-get info
:html-container
)
2535 ;;;; Horizontal Rule
2537 (defun org-html-horizontal-rule (_horizontal-rule _contents info
)
2538 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2539 CONTENTS is nil. INFO is a plist holding contextual information."
2540 (org-html-close-tag "hr" nil info
))
2542 ;;;; Inline Src Block
2544 (defun org-html-inline-src-block (inline-src-block _contents info
)
2545 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2546 CONTENTS holds the contents of the item. INFO is a plist holding
2547 contextual information."
2548 (let ((lang (org-element-property :language inline-src-block
))
2549 (code (org-html-format-code inline-src-block info
))
2551 (let ((lbl (and (org-element-property :name inline-src-block
)
2552 (org-export-get-reference inline-src-block info
))))
2553 (if (not lbl
) "" (format " id=\"%s\"" lbl
)))))
2554 (format "<code class=\"src src-%s\"%s>%s</code>" lang label code
)))
2558 (defun org-html-inlinetask (inlinetask contents info
)
2559 "Transcode an INLINETASK element from Org to HTML.
2560 CONTENTS holds the contents of the block. INFO is a plist
2561 holding contextual information."
2562 (let* ((todo (and (plist-get info
:with-todo-keywords
)
2563 (let ((todo (org-element-property :todo-keyword inlinetask
)))
2564 (and todo
(org-export-data todo info
)))))
2565 (todo-type (and todo
(org-element-property :todo-type inlinetask
)))
2566 (priority (and (plist-get info
:with-priority
)
2567 (org-element-property :priority inlinetask
)))
2568 (text (org-export-data (org-element-property :title inlinetask
) info
))
2569 (tags (and (plist-get info
:with-tags
)
2570 (org-export-get-tags inlinetask info
))))
2571 (funcall (plist-get info
:html-format-inlinetask-function
)
2572 todo todo-type priority text tags contents info
)))
2574 (defun org-html-format-inlinetask-default-function
2575 (todo todo-type priority text tags contents info
)
2576 "Default format function for a inlinetasks.
2577 See `org-html-format-inlinetask-function' for details."
2578 (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2579 (org-html-format-headline-default-function
2580 todo todo-type priority text tags info
)
2581 (org-html-close-tag "br" nil info
)
2586 (defun org-html-italic (_italic contents info
)
2587 "Transcode ITALIC from Org to HTML.
2588 CONTENTS is the text with italic markup. INFO is a plist holding
2589 contextual information."
2591 (or (cdr (assq 'italic
(plist-get info
:html-text-markup-alist
))) "%s")
2596 (defun org-html-checkbox (checkbox info
)
2597 "Format CHECKBOX into HTML.
2598 INFO is a plist holding contextual information. See
2599 `org-html-checkbox-type' for customization options."
2601 (cdr (assq (plist-get info
:html-checkbox-type
)
2602 org-html-checkbox-types
)))))
2604 (defun org-html-format-list-item (contents type checkbox info
2605 &optional term-counter-id
2607 "Format a list item into HTML."
2608 (let ((class (if checkbox
2609 (format " class=\"%s\""
2610 (symbol-name checkbox
)) ""))
2611 (checkbox (concat (org-html-checkbox checkbox info
)
2612 (and checkbox
" ")))
2613 (br (org-html-close-tag "br" nil info
)))
2617 (let* ((counter term-counter-id
)
2618 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2620 (format "<li%s%s>" class extra
)
2621 (when headline
(concat headline br
)))))
2623 (let* ((id term-counter-id
)
2624 (extra (if id
(format " id=\"%s\"" id
) "")))
2626 (format "<li%s%s>" class extra
)
2627 (when headline
(concat headline br
)))))
2629 (let* ((term term-counter-id
))
2630 (setq term
(or term
"(no term)"))
2631 ;; Check-boxes in descriptive lists are associated to tag.
2632 (concat (format "<dt%s>%s</dt>"
2633 class
(concat checkbox term
))
2635 (unless (eq type
'descriptive
) checkbox
)
2636 (and contents
(org-trim contents
))
2640 (descriptive "</dd>")))))
2642 (defun org-html-item (item contents info
)
2643 "Transcode an ITEM element from Org to HTML.
2644 CONTENTS holds the contents of the item. INFO is a plist holding
2645 contextual information."
2646 (let* ((plain-list (org-export-get-parent item
))
2647 (type (org-element-property :type plain-list
))
2648 (counter (org-element-property :counter item
))
2649 (checkbox (org-element-property :checkbox item
))
2650 (tag (let ((tag (org-element-property :tag item
)))
2651 (and tag
(org-export-data tag info
)))))
2652 (org-html-format-list-item
2653 contents type checkbox info
(or tag counter
))))
2657 (defun org-html-keyword (keyword _contents info
)
2658 "Transcode a KEYWORD element from Org to HTML.
2659 CONTENTS is nil. INFO is a plist holding contextual information."
2660 (let ((key (org-element-property :key keyword
))
2661 (value (org-element-property :value keyword
)))
2663 ((string= key
"HTML") value
)
2664 ((string= key
"TOC")
2665 (let ((case-fold-search t
))
2667 ((string-match "\\<headlines\\>" value
)
2668 (let ((depth (and (string-match "\\<[0-9]+\\>" value
)
2669 (string-to-number (match-string 0 value
))))
2670 (localp (org-string-match-p "\\<local\\>" value
)))
2671 (org-html-toc depth info
(and localp keyword
))))
2672 ((string= "listings" value
) (org-html-list-of-listings info
))
2673 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2675 ;;;; Latex Environment
2677 (defun org-html-format-latex (latex-frag processing-type info
)
2678 "Format a LaTeX fragment LATEX-FRAG into HTML.
2679 PROCESSING-TYPE designates the tool used for conversion. It is
2680 a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil
2681 and t. See `org-html-with-latex' for more information. INFO is
2682 a plist containing export properties."
2683 (let ((cache-relpath "") (cache-dir ""))
2684 (unless (eq processing-type
'mathjax
)
2685 (let ((bfn (or (buffer-file-name)
2687 (expand-file-name "latex" temporary-file-directory
))))
2689 (let ((header (plist-get info
:latex-header
)))
2692 (lambda (line) (concat "#+LATEX_HEADER: " line
))
2693 (org-split-string header
"\n")
2698 (file-name-sans-extension
2699 (file-name-nondirectory bfn
)))
2700 cache-dir
(file-name-directory bfn
))
2701 ;; Re-create LaTeX environment from original buffer in
2702 ;; temporary buffer so that dvipng/imagemagick can properly
2703 ;; turn the fragment into an image.
2704 (setq latex-frag
(concat latex-header latex-frag
))))
2707 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2708 nil processing-type
)
2711 (defun org-html-latex-environment (latex-environment _contents info
)
2712 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2713 CONTENTS is nil. INFO is a plist holding contextual information."
2714 (let ((processing-type (plist-get info
:with-latex
))
2715 (latex-frag (org-remove-indentation
2716 (org-element-property :value latex-environment
)))
2717 (attributes (org-export-read-attribute :attr_html latex-environment
)))
2718 (case processing-type
2720 (org-html-format-latex latex-frag
'mathjax info
))
2721 ((dvipng imagemagick
)
2723 (org-html-format-latex latex-frag processing-type info
)))
2724 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2725 ;; Do not provide a caption or a name to be consistent with
2726 ;; `mathjax' handling.
2727 (org-html--wrap-image
2728 (org-html--format-image
2729 (match-string 1 formula-link
) attributes info
) info
))))
2734 (defun org-html-latex-fragment (latex-fragment _contents info
)
2735 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2736 CONTENTS is nil. INFO is a plist holding contextual information."
2737 (let ((latex-frag (org-element-property :value latex-fragment
))
2738 (processing-type (plist-get info
:with-latex
)))
2739 (case processing-type
2741 (org-html-format-latex latex-frag
'mathjax info
))
2742 ((dvipng imagemagick
)
2744 (org-html-format-latex latex-frag processing-type info
)))
2745 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2746 (org-html--format-image (match-string 1 formula-link
) nil info
))))
2751 (defun org-html-line-break (_line-break _contents info
)
2752 "Transcode a LINE-BREAK object from Org to HTML.
2753 CONTENTS is nil. INFO is a plist holding contextual information."
2754 (concat (org-html-close-tag "br" nil info
) "\n"))
2758 (defun org-html-inline-image-p (link info
)
2759 "Non-nil when LINK is meant to appear as an image.
2760 INFO is a plist used as a communication channel. LINK is an
2761 inline image when it has no description and targets an image
2762 file (see `org-html-inline-image-rules' for more information), or
2763 if its description is a single link targeting an image file."
2764 (if (not (org-element-contents link
))
2765 (org-export-inline-image-p
2766 link
(plist-get info
:html-inline-image-rules
))
2768 (let ((link-count 0))
2769 (org-element-map (org-element-contents link
)
2770 (cons 'plain-text org-element-all-objects
)
2772 (case (org-element-type obj
)
2773 (plain-text (org-string-nw-p obj
))
2774 (link (if (= link-count
1) t
2776 (not (org-export-inline-image-p
2777 obj
(plist-get info
:html-inline-image-rules
)))))
2781 (defvar org-html-standalone-image-predicate
)
2782 (defun org-html-standalone-image-p (element info
)
2783 "Non-nil if ELEMENT is a standalone image.
2785 INFO is a plist holding contextual information.
2787 An element or object is a standalone image when
2789 - its type is `paragraph' and its sole content, save for white
2790 spaces, is a link that qualifies as an inline image;
2792 - its type is `link' and its containing paragraph has no other
2793 content save white spaces.
2795 Bind `org-html-standalone-image-predicate' to constrain paragraph
2796 further. For example, to check for only captioned standalone
2799 (lambda (paragraph) (org-element-property :caption paragraph))"
2800 (let ((paragraph (case (org-element-type element
)
2802 (link (org-export-get-parent element
)))))
2803 (and (eq (org-element-type paragraph
) 'paragraph
)
2804 (or (not (fboundp 'org-html-standalone-image-predicate
))
2805 (funcall org-html-standalone-image-predicate paragraph
))
2807 (let ((link-count 0))
2808 (org-element-map (org-element-contents paragraph
)
2809 (cons 'plain-text org-element-all-objects
)
2811 (when (case (org-element-type obj
)
2812 (plain-text (org-string-nw-p obj
))
2813 (link (or (> (incf link-count
) 1)
2814 (not (org-html-inline-image-p obj info
))))
2818 (= link-count
1))))))
2820 (defun org-html-link (link desc info
)
2821 "Transcode a LINK object from Org to HTML.
2822 DESC is the description part of the link, or the empty string.
2823 INFO is a plist holding contextual information. See
2825 (let* ((home (when (plist-get info
:html-link-home
)
2826 (org-trim (plist-get info
:html-link-home
))))
2827 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2828 (link-org-files-as-html-maybe
2829 (lambda (raw-path info
)
2830 ;; Treat links to `file.org' as links to `file.html', if
2831 ;; needed. See `org-html-link-org-files-as-html'.
2833 ((and (plist-get info
:html-link-org-files-as-html
)
2835 (downcase (file-name-extension raw-path
"."))))
2836 (concat (file-name-sans-extension raw-path
) "."
2837 (plist-get info
:html-extension
)))
2839 (type (org-element-property :type link
))
2840 (raw-path (org-element-property :path link
))
2841 ;; Ensure DESC really exists, or set it to nil.
2842 (desc (org-string-nw-p desc
))
2845 ((member type
'("http" "https" "ftp" "mailto" "news"))
2846 (org-link-escape-browser
2847 (org-link-unescape (concat type
":" raw-path
))))
2848 ((string= type
"file")
2849 ;; Treat links to ".org" files as ".html", if needed.
2851 (funcall link-org-files-as-html-maybe raw-path info
))
2852 ;; If file path is absolute, prepend it with protocol
2853 ;; component - "file://".
2855 ((file-name-absolute-p raw-path
)
2856 (setq raw-path
(org-export-file-uri raw-path
)))
2857 ((and home use-abs-url
)
2858 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2859 ;; Add search option, if any. A search option can be
2860 ;; relative to a custom-id, a headline title, a name or
2862 (let ((option (org-element-property :search-option link
)))
2863 (cond ((not option
) raw-path
)
2864 ;; Since HTML back-end use custom-id value as-is,
2865 ;; resolving is them is trivial.
2866 ((eq (string-to-char option
) ?
#) (concat raw-path option
))
2870 (org-publish-resolve-external-link
2872 (org-element-property :path link
)))))))
2874 ;; Extract attributes from parent's paragraph. HACK: Only do
2875 ;; this for the first link in parent (inner image link for
2876 ;; inline images). This is needed as long as attributes
2877 ;; cannot be set on a per link basis.
2879 (let* ((parent (org-export-get-parent-element link
))
2880 (link (let ((container (org-export-get-parent link
)))
2881 (if (and (eq (org-element-type container
) 'link
)
2882 (org-html-inline-image-p link info
))
2885 (and (eq (org-element-map parent
'link
'identity info t
) link
)
2886 (org-export-read-attribute :attr_html parent
))))
2888 (let ((attr (org-html--make-attribute-string attributes-plist
)))
2889 (if (org-string-nw-p attr
) (concat " " attr
) ""))))
2891 ;; Link type is handled by a special function.
2892 ((org-export-custom-protocol-maybe link desc
'html
))
2894 ((and (plist-get info
:html-inline-images
)
2895 (org-export-inline-image-p
2896 link
(plist-get info
:html-inline-image-rules
)))
2897 (org-html--format-image path attributes-plist info
))
2898 ;; Radio target: Transcode target's contents and use them as
2899 ;; link's description.
2900 ((string= type
"radio")
2901 (let ((destination (org-export-resolve-radio-link link info
)))
2902 (if (not destination
) desc
2903 (format "<a href=\"#%s\"%s>%s</a>"
2904 (org-export-get-reference destination info
)
2907 ;; Links pointing to a headline: Find destination and build
2908 ;; appropriate referencing command.
2909 ((member type
'("custom-id" "fuzzy" "id"))
2910 (let ((destination (if (string= type
"fuzzy")
2911 (org-export-resolve-fuzzy-link link info
)
2912 (org-export-resolve-id-link link info
))))
2913 (case (org-element-type destination
)
2914 ;; ID link points to an external file.
2916 (let ((fragment (concat "ID-" path
))
2917 ;; Treat links to ".org" files as ".html", if needed.
2918 (path (funcall link-org-files-as-html-maybe
2920 (format "<a href=\"%s#%s\"%s>%s</a>"
2921 path fragment attributes
(or desc destination
))))
2922 ;; Fuzzy link points nowhere.
2927 (org-element-property :raw-link link
) info
))))
2928 ;; Link points to a headline.
2930 (let ((href (or (org-element-property :CUSTOM_ID destination
)
2931 (org-export-get-reference destination info
)))
2932 ;; What description to use?
2934 ;; Case 1: Headline is numbered and LINK has no
2935 ;; description. Display section number.
2936 (if (and (org-export-numbered-headline-p destination info
)
2938 (mapconcat #'number-to-string
2939 (org-export-get-headline-number
2940 destination info
) ".")
2941 ;; Case 2: Either the headline is un-numbered or
2942 ;; LINK has a custom description. Display LINK's
2943 ;; description or headline's title.
2946 (org-element-property :title destination
) info
)))))
2947 (format "<a href=\"#%s\"%s>%s</a>" href attributes desc
)))
2948 ;; Fuzzy link points to a target or an element.
2950 (let* ((ref (org-export-get-reference destination info
))
2951 (org-html-standalone-image-predicate
2952 #'org-html--has-caption-p
)
2955 ((org-html-standalone-image-p destination info
)
2956 (org-export-get-ordinal
2957 (org-element-map destination
'link
2959 info
'link
'org-html-standalone-image-p
))
2960 (t (org-export-get-ordinal
2961 destination info nil
'org-html--has-caption-p
))))
2963 ((not number
) "No description for this link")
2964 ((numberp number
) (number-to-string number
))
2965 (t (mapconcat #'number-to-string number
".")))))
2966 (format "<a href=\"#%s\"%s>%s</a>" ref attributes desc
))))))
2967 ;; Coderef: replace link with the reference name or the
2968 ;; equivalent line number.
2969 ((string= type
"coderef")
2970 (let ((fragment (concat "coderef-" (org-html-encode-plain-text path
))))
2971 (format "<a href=\"#%s\"%s%s>%s</a>"
2973 (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, \
2974 '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
2977 (format (org-export-get-coderef-format path desc
)
2978 (org-export-resolve-coderef path info
)))))
2979 ;; External link with a description part.
2980 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>"
2981 (org-html-encode-plain-text path
)
2984 ;; External link without a description part.
2985 (path (let ((path (org-html-encode-plain-text path
)))
2986 (format "<a href=\"%s\"%s>%s</a>" path attributes path
)))
2987 ;; No path, only description. Try to do something useful.
2988 (t (format "<i>%s</i>" desc
)))))
2992 (defun org-html-node-property (node-property _contents _info
)
2993 "Transcode a NODE-PROPERTY element from Org to HTML.
2994 CONTENTS is nil. INFO is a plist holding contextual
2997 (org-element-property :key node-property
)
2998 (let ((value (org-element-property :value node-property
)))
2999 (if value
(concat " " value
) ""))))
3003 (defun org-html-paragraph (paragraph contents info
)
3004 "Transcode a PARAGRAPH element from Org to HTML.
3005 CONTENTS is the contents of the paragraph, as a string. INFO is
3006 the plist used as a communication channel."
3007 (let* ((parent (org-export-get-parent paragraph
))
3008 (parent-type (org-element-type parent
))
3009 (style '((footnote-definition " class=\"footpara\"")
3010 (org-data " class=\"footpara\"")))
3011 (attributes (org-html--make-attribute-string
3012 (org-export-read-attribute :attr_html paragraph
)))
3013 (extra (or (cadr (assq parent-type style
)) "")))
3015 ((and (eq parent-type
'item
)
3016 (not (org-export-get-previous-element paragraph info
))
3017 (let ((followers (org-export-get-next-element paragraph info
2)))
3018 (and (not (cdr followers
))
3019 (memq (org-element-type (car followers
)) '(nil plain-list
)))))
3020 ;; First paragraph in an item has no tag if it is alone or
3021 ;; followed, at most, by a sub-list.
3023 ((org-html-standalone-image-p paragraph info
)
3024 ;; Standalone image.
3026 (let ((raw (org-export-data
3027 (org-export-get-caption paragraph
) info
))
3028 (org-html-standalone-image-predicate
3029 'org-html--has-caption-p
))
3030 (if (not (org-string-nw-p raw
)) raw
3032 "<span class=\"figure-number\">"
3033 (format (org-html--translate "Figure %d:" info
)
3034 (org-export-get-ordinal
3035 (org-element-map paragraph
'link
3037 info nil
'org-html-standalone-image-p
))
3039 (label (and (org-element-property :name paragraph
)
3040 (org-export-get-reference paragraph info
))))
3041 (org-html--wrap-image contents info caption label
)))
3042 ;; Regular paragraph.
3043 (t (format "<p%s%s>\n%s</p>"
3044 (if (org-string-nw-p attributes
)
3045 (concat " " attributes
) "")
3050 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
3051 ;; the correct value for the item counter
3052 (defun org-html-begin-plain-list (type &optional arg1
)
3053 "Insert the beginning of the HTML list depending on TYPE.
3054 When ARG1 is a string, use it as the start parameter for ordered
3058 (format "<ol class=\"org-ol\"%s>"
3059 (if arg1
(format " start=\"%d\"" arg1
) "")))
3060 (unordered "<ul class=\"org-ul\">")
3061 (descriptive "<dl class=\"org-dl\">")))
3063 (defun org-html-end-plain-list (type)
3064 "Insert the end of the HTML list depending on TYPE."
3068 (descriptive "</dl>")))
3070 (defun org-html-plain-list (plain-list contents _info
)
3071 "Transcode a PLAIN-LIST element from Org to HTML.
3072 CONTENTS is the contents of the list. INFO is a plist holding
3073 contextual information."
3074 (let ((type (org-element-property :type plain-list
)))
3076 (org-html-begin-plain-list type
)
3077 contents
(org-html-end-plain-list type
))))
3081 (defun org-html-convert-special-strings (string)
3082 "Convert special characters in STRING to HTML."
3083 (dolist (a org-html-special-string-regexps string
)
3086 (setq string
(replace-regexp-in-string re rpl string t
)))))
3088 (defun org-html-encode-plain-text (text)
3089 "Convert plain text characters from TEXT to HTML equivalent.
3090 Possible conversions are set in `org-html-protect-char-alist'."
3091 (dolist (pair org-html-protect-char-alist text
)
3092 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
))))
3094 (defun org-html-plain-text (text info
)
3095 "Transcode a TEXT string from Org to HTML.
3096 TEXT is the string to transcode. INFO is a plist holding
3097 contextual information."
3098 (let ((output text
))
3099 ;; Protect following characters: <, >, &.
3100 (setq output
(org-html-encode-plain-text output
))
3101 ;; Handle smart quotes. Be sure to provide original string since
3102 ;; OUTPUT may have been modified.
3103 (when (plist-get info
:with-smart-quotes
)
3104 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
3105 ;; Handle special strings.
3106 (when (plist-get info
:with-special-strings
)
3107 (setq output
(org-html-convert-special-strings output
)))
3108 ;; Handle break preservation if required.
3109 (when (plist-get info
:preserve-breaks
)
3111 (replace-regexp-in-string
3112 "\\(\\\\\\\\\\)?[ \t]*\n"
3113 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
3120 (defun org-html-planning (planning _contents info
)
3121 "Transcode a PLANNING element from Org to HTML.
3122 CONTENTS is nil. INFO is a plist used as a communication
3125 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
3129 (let ((timestamp (cdr pair
)))
3131 (let ((string (car pair
)))
3132 (format "<span class=\"timestamp-kwd\">%s</span> \
3133 <span class=\"timestamp\">%s</span> "
3135 (org-html-plain-text (org-timestamp-translate timestamp
)
3137 `((,org-closed-string .
,(org-element-property :closed planning
))
3138 (,org-deadline-string .
,(org-element-property :deadline planning
))
3139 (,org-scheduled-string .
,(org-element-property :scheduled planning
)))
3142 ;;;; Property Drawer
3144 (defun org-html-property-drawer (_property-drawer contents _info
)
3145 "Transcode a PROPERTY-DRAWER element from Org to HTML.
3146 CONTENTS holds the contents of the drawer. INFO is a plist
3147 holding contextual information."
3148 (and (org-string-nw-p contents
)
3149 (format "<pre class=\"example\">\n%s</pre>" contents
)))
3153 (defun org-html-quote-block (quote-block contents _info
)
3154 "Transcode a QUOTE-BLOCK element from Org to HTML.
3155 CONTENTS holds the contents of the block. INFO is a plist
3156 holding contextual information."
3157 (format "<blockquote%s>\n%s</blockquote>"
3158 (let* ((name (org-element-property :name quote-block
))
3159 (attributes (org-export-read-attribute :attr_html quote-block
))
3160 (a (org-html--make-attribute-string
3161 (if (or (not name
) (plist-member attributes
:id
))
3163 (plist-put attributes
:id name
)))))
3164 (if (org-string-nw-p a
) (concat " " a
) ""))
3169 (defun org-html-section (section contents info
)
3170 "Transcode a SECTION element from Org to HTML.
3171 CONTENTS holds the contents of the section. INFO is a plist
3172 holding contextual information."
3173 (let ((parent (org-export-get-parent-headline section
)))
3174 ;; Before first headline: no container, just return CONTENTS.
3175 (if (not parent
) contents
3176 ;; Get div's class and id references.
3177 (let* ((class-num (+ (org-export-get-relative-level parent info
)
3178 (1- (plist-get info
:html-toplevel-hlevel
))))
3180 (and (org-export-numbered-headline-p parent info
)
3183 (org-export-get-headline-number parent info
) "-"))))
3184 ;; Build return value.
3185 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
3187 (or (org-element-property :CUSTOM_ID parent
)
3189 (org-export-get-reference parent info
))
3190 (or contents
""))))))
3194 (defun org-html-radio-target (radio-target text info
)
3195 "Transcode a RADIO-TARGET object from Org to HTML.
3196 TEXT is the text of the target. INFO is a plist holding
3197 contextual information."
3198 (let ((ref (org-export-get-reference radio-target info
)))
3199 (org-html--anchor ref text nil info
)))
3203 (defun org-html-special-block (special-block contents info
)
3204 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3205 CONTENTS holds the contents of the block. INFO is a plist
3206 holding contextual information."
3207 (let* ((block-type (org-element-property :type special-block
))
3208 (html5-fancy (and (org-html--html5-fancy-p info
)
3209 (member block-type org-html-html5-elements
)))
3210 (attributes (org-export-read-attribute :attr_html special-block
)))
3212 (let ((class (plist-get attributes
:class
)))
3213 (setq attributes
(plist-put attributes
:class
3214 (if class
(concat class
" " block-type
)
3216 (let* ((contents (or contents
""))
3217 (name (org-element-property :name special-block
))
3218 (a (org-html--make-attribute-string
3219 (if (or (not name
) (plist-member attributes
:id
))
3221 (plist-put attributes
:id name
))))
3222 (str (if (org-string-nw-p a
) (concat " " a
) "")))
3224 (format "<%s%s>\n%s</%s>" block-type str contents block-type
)
3225 (format "<div%s>\n%s\n</div>" str contents
)))))
3229 (defun org-html-src-block (src-block _contents info
)
3230 "Transcode a SRC-BLOCK element from Org to HTML.
3231 CONTENTS holds the contents of the item. INFO is a plist holding
3232 contextual information."
3233 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3234 (org-html--textarea-block src-block
)
3235 (let ((lang (org-element-property :language src-block
))
3236 (caption (org-export-get-caption src-block
))
3237 (code (org-html-format-code src-block info
))
3238 (label (let ((lbl (and (org-element-property :name src-block
)
3239 (org-export-get-reference src-block info
))))
3240 (if lbl
(format " id=\"%s\"" lbl
) ""))))
3241 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3243 "<div class=\"org-src-container\">\n%s%s\n</div>"
3244 (if (not caption
) ""
3245 (format "<label class=\"org-src-name\">%s</label>"
3246 (org-export-data caption info
)))
3247 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3249 ;;;; Statistics Cookie
3251 (defun org-html-statistics-cookie (statistics-cookie _contents _info
)
3252 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3253 CONTENTS is nil. INFO is a plist holding contextual information."
3254 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3255 (format "<code>%s</code>" cookie-value
)))
3259 (defun org-html-strike-through (_strike-through contents info
)
3260 "Transcode STRIKE-THROUGH from Org to HTML.
3261 CONTENTS is the text with strike-through markup. INFO is a plist
3262 holding contextual information."
3264 (or (cdr (assq 'strike-through
(plist-get info
:html-text-markup-alist
)))
3270 (defun org-html-subscript (_subscript contents _info
)
3271 "Transcode a SUBSCRIPT object from Org to HTML.
3272 CONTENTS is the contents of the object. INFO is a plist holding
3273 contextual information."
3274 (format "<sub>%s</sub>" contents
))
3278 (defun org-html-superscript (_superscript contents _info
)
3279 "Transcode a SUPERSCRIPT object from Org to HTML.
3280 CONTENTS is the contents of the object. INFO is a plist holding
3281 contextual information."
3282 (format "<sup>%s</sup>" contents
))
3286 (defun org-html-table-cell (table-cell contents info
)
3287 "Transcode a TABLE-CELL element from Org to HTML.
3288 CONTENTS is nil. INFO is a plist used as a communication
3290 (let* ((table-row (org-export-get-parent table-cell
))
3291 (table (org-export-get-parent-table table-cell
))
3293 (if (not (plist-get info
:html-table-align-individual-fields
)) ""
3294 (format (if (and (boundp 'org-html-format-table-no-css
)
3295 org-html-format-table-no-css
)
3296 " align=\"%s\"" " class=\"org-%s\"")
3297 (org-export-table-cell-alignment table-cell info
)))))
3298 (when (or (not contents
) (string= "" (org-trim contents
)))
3299 (setq contents
" "))
3301 ((and (org-export-table-has-header-p table info
)
3302 (= 1 (org-export-table-row-group table-row info
)))
3303 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3304 (concat "\n" (format (car header-tags
) "col" cell-attrs
)
3306 (cdr header-tags
))))
3307 ((and (plist-get info
:html-table-use-header-tags-for-first-column
)
3308 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3309 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3310 (concat "\n" (format (car header-tags
) "row" cell-attrs
)
3312 (cdr header-tags
))))
3313 (t (let ((data-tags (plist-get info
:html-table-data-tags
)))
3314 (concat "\n" (format (car data-tags
) cell-attrs
)
3316 (cdr data-tags
)))))))
3320 (defun org-html-table-row (table-row contents info
)
3321 "Transcode a TABLE-ROW element from Org to HTML.
3322 CONTENTS is the contents of the row. INFO is a plist used as a
3323 communication channel."
3324 ;; Rules are ignored since table separators are deduced from
3325 ;; borders of the current row.
3326 (when (eq (org-element-property :type table-row
) 'standard
)
3327 (let* ((group (org-export-table-row-group table-row info
))
3328 (number (org-export-table-row-number table-row info
))
3330 (org-export-table-row-starts-rowgroup-p table-row info
))
3332 (org-export-table-row-ends-rowgroup-p table-row info
))
3333 (topp (and (equal start-group-p
'(top))
3334 (equal end-group-p
'(below top
))))
3335 (bottomp (and (equal start-group-p
'(above))
3336 (equal end-group-p
'(bottom above
))))
3338 (pcase (plist-get info
:html-table-row-open-tag
)
3339 ((and accessor
(pred functionp
))
3341 number group start-group-p end-group-p topp bottomp
))
3342 (accessor accessor
)))
3344 (pcase (plist-get info
:html-table-row-close-tag
)
3345 ((and accessor
(pred functionp
))
3347 number group start-group-p end-group-p topp bottomp
))
3348 (accessor accessor
)))
3351 ;; Row belongs to second or subsequent groups.
3352 ((not (= 1 group
)) '("<tbody>" .
"\n</tbody>"))
3353 ;; Row is from first group. Table has >=1 groups.
3354 ((org-export-table-has-header-p
3355 (org-export-get-parent-table table-row
) info
)
3356 '("<thead>" .
"\n</thead>"))
3357 ;; Row is from first and only group.
3358 (t '("<tbody>" .
"\n</tbody>")))))
3359 (concat (and start-group-p
(car group-tags
))
3365 (and end-group-p
(cdr group-tags
))))))
3369 (defun org-html-table-first-row-data-cells (table info
)
3370 "Transcode the first row of TABLE.
3371 INFO is a plist used as a communication channel."
3373 (org-element-map table
'table-row
3375 (unless (eq (org-element-property :type row
) 'rule
) row
))
3377 (special-column-p (org-export-table-has-special-column-p table
)))
3378 (if (not special-column-p
) (org-element-contents table-row
)
3379 (cdr (org-element-contents table-row
)))))
3381 (defun org-html-table--table.el-table
(table _info
)
3382 "Format table.el tables into HTML.
3383 INFO is a plist used as a communication channel."
3384 (when (eq (org-element-property :type table
) 'table.el
)
3386 (let ((outbuf (with-current-buffer
3387 (get-buffer-create "*org-export-table*")
3388 (erase-buffer) (current-buffer))))
3390 (insert (org-element-property :value table
))
3392 (re-search-forward "^[ \t]*|[^|]" nil t
)
3393 (table-generate-source 'html outbuf
))
3394 (with-current-buffer outbuf
3395 (prog1 (org-trim (buffer-string))
3398 (defun org-html-table (table contents info
)
3399 "Transcode a TABLE element from Org to HTML.
3400 CONTENTS is the contents of the table. INFO is a plist holding
3401 contextual information."
3402 (case (org-element-property :type table
)
3403 ;; Case 1: table.el table. Convert it using appropriate tools.
3404 (table.el
(org-html-table--table.el-table table info
))
3405 ;; Case 2: Standard table.
3407 (let* ((caption (org-export-get-caption table
))
3408 (number (org-export-get-ordinal
3409 table info nil
#'org-html--has-caption-p
))
3411 (org-html--make-attribute-string
3413 (and (org-element-property :name table
)
3414 (list :id
(org-export-get-reference table info
)))
3415 (and (not (org-html-html5-p info
))
3416 (plist-get info
:html-table-attributes
))
3417 (org-export-read-attribute :attr_html table
))))
3419 (if (and (boundp 'org-html-format-table-no-css
)
3420 org-html-format-table-no-css
)
3421 "align=\"%s\"" "class=\"org-%s\""))
3424 (lambda (table info
)
3426 (lambda (table-cell)
3427 (let ((alignment (org-export-table-cell-alignment
3430 ;; Begin a colgroup?
3431 (when (org-export-table-cell-starts-colgroup-p
3434 ;; Add a column. Also specify its alignment.
3437 "col" (concat " " (format alignspec alignment
)) info
))
3439 (when (org-export-table-cell-ends-colgroup-p
3442 (org-html-table-first-row-data-cells table info
) "\n")))))
3443 (format "<table%s>\n%s\n%s\n%s</table>"
3444 (if (equal attributes
"") "" (concat " " attributes
))
3445 (if (not caption
) ""
3446 (format (if (plist-get info
:html-table-caption-above
)
3447 "<caption class=\"t-above\">%s</caption>"
3448 "<caption class=\"t-bottom\">%s</caption>")
3450 "<span class=\"table-number\">"
3451 (format (org-html--translate "Table %d:" info
) number
)
3452 "</span> " (org-export-data caption info
))))
3453 (funcall table-column-specs table info
)
3458 (defun org-html-target (target _contents info
)
3459 "Transcode a TARGET object from Org to HTML.
3460 CONTENTS is nil. INFO is a plist holding contextual
3462 (let ((ref (org-export-get-reference target info
)))
3463 (org-html--anchor ref nil nil info
)))
3467 (defun org-html-timestamp (timestamp _contents info
)
3468 "Transcode a TIMESTAMP object from Org to HTML.
3469 CONTENTS is nil. INFO is a plist holding contextual
3471 (let ((value (org-html-plain-text (org-timestamp-translate timestamp
) info
)))
3472 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3473 (replace-regexp-in-string "--" "–" value
))))
3477 (defun org-html-underline (_underline contents info
)
3478 "Transcode UNDERLINE from Org to HTML.
3479 CONTENTS is the text with underline markup. INFO is a plist
3480 holding contextual information."
3481 (format (or (cdr (assq 'underline
(plist-get info
:html-text-markup-alist
)))
3487 (defun org-html-verbatim (verbatim _contents info
)
3488 "Transcode VERBATIM from Org to HTML.
3489 CONTENTS is nil. INFO is a plist holding contextual
3491 (format (or (cdr (assq 'verbatim
(plist-get info
:html-text-markup-alist
))) "%s")
3492 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3496 (defun org-html-verse-block (_verse-block contents info
)
3497 "Transcode a VERSE-BLOCK element from Org to HTML.
3498 CONTENTS is verse block contents. INFO is a plist holding
3499 contextual information."
3500 ;; Replace each newline character with line break. Also replace
3501 ;; each blank line with a line break.
3502 (setq contents
(replace-regexp-in-string
3503 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3504 (replace-regexp-in-string
3505 "\\(\\\\\\\\\\)?[ \t]*\n"
3506 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3507 ;; Replace each white space at beginning of a line with a
3508 ;; non-breaking space.
3509 (while (string-match "^[ \t]+" contents
)
3510 (let* ((num-ws (length (match-string 0 contents
)))
3511 (ws (org-html--make-string num-ws
" ")))
3512 (setq contents
(replace-match ws nil t contents
))))
3513 (format "<p class=\"verse\">\n%s</p>" contents
))
3516 ;;; Filter Functions
3518 (defun org-html-final-function (contents _backend info
)
3519 "Filter to indent the HTML and convert HTML entities."
3523 (if (plist-get info
:html-indent
)
3524 (indent-region (point-min) (point-max)))
3525 (buffer-substring-no-properties (point-min) (point-max))))
3528 ;;; End-user functions
3531 (defun org-html-export-as-html
3532 (&optional async subtreep visible-only body-only ext-plist
)
3533 "Export current buffer to an HTML buffer.
3535 If narrowing is active in the current buffer, only export its
3538 If a region is active, export that region.
3540 A non-nil optional argument ASYNC means the process should happen
3541 asynchronously. The resulting buffer should be accessible
3542 through the `org-export-stack' interface.
3544 When optional argument SUBTREEP is non-nil, export the sub-tree
3545 at point, extracting information from the headline properties
3548 When optional argument VISIBLE-ONLY is non-nil, don't export
3549 contents of hidden elements.
3551 When optional argument BODY-ONLY is non-nil, only write code
3552 between \"<body>\" and \"</body>\" tags.
3554 EXT-PLIST, when provided, is a property list with external
3555 parameters overriding Org default settings, but still inferior to
3556 file-local settings.
3558 Export is done in a buffer named \"*Org HTML Export*\", which
3559 will be displayed when `org-export-show-temporary-export-buffer'
3562 (org-export-to-buffer 'html
"*Org HTML Export*"
3563 async subtreep visible-only body-only ext-plist
3564 (lambda () (set-auto-mode t
))))
3567 (defun org-html-convert-region-to-html ()
3568 "Assume the current region has org-mode syntax, and convert it to HTML.
3569 This can be used in any buffer. For example, you can write an
3570 itemized list in org-mode syntax in an HTML buffer and use this
3571 command to convert it."
3573 (org-export-replace-region-by 'html
))
3576 (defun org-html-export-to-html
3577 (&optional async subtreep visible-only body-only ext-plist
)
3578 "Export current buffer to a HTML file.
3580 If narrowing is active in the current buffer, only export its
3583 If a region is active, export that region.
3585 A non-nil optional argument ASYNC means the process should happen
3586 asynchronously. The resulting file should be accessible through
3587 the `org-export-stack' interface.
3589 When optional argument SUBTREEP is non-nil, export the sub-tree
3590 at point, extracting information from the headline properties
3593 When optional argument VISIBLE-ONLY is non-nil, don't export
3594 contents of hidden elements.
3596 When optional argument BODY-ONLY is non-nil, only write code
3597 between \"<body>\" and \"</body>\" tags.
3599 EXT-PLIST, when provided, is a property list with external
3600 parameters overriding Org default settings, but still inferior to
3601 file-local settings.
3603 Return output file's name."
3605 (let* ((extension (concat "." (or (plist-get ext-plist
:html-extension
)
3608 (file (org-export-output-file-name extension subtreep
))
3609 (org-export-coding-system org-html-coding-system
))
3610 (org-export-to-file 'html file
3611 async subtreep visible-only body-only ext-plist
)))
3614 (defun org-html-publish-to-html (plist filename pub-dir
)
3615 "Publish an org file to HTML.
3617 FILENAME is the filename of the Org file to be published. PLIST
3618 is the property list for the given project. PUB-DIR is the
3619 publishing directory.
3621 Return output file name."
3622 (org-publish-org-to 'html filename
3623 (concat "." (or (plist-get plist
:html-extension
)
3632 ;; generated-autoload-file: "org-loaddefs.el"
3635 ;;; ox-html.el ends here