1 ;;; ox-html.el --- HTML Back-End for Org Export Engine
3 ;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Jambunathan K <kjambunathan at gmail dot com>
7 ;; Keywords: outlines, hypermedia, calendar, wp
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This library implements a HTML back-end for Org generic exporter.
27 ;; See Org manual for more information.
35 (require 'format-spec
)
36 (eval-when-compile (require 'cl
) (require 'table nil
'noerror
))
39 ;;; Function Declarations
41 (declare-function org-id-find-id-file
"org-id" (id))
42 (declare-function htmlize-region
"ext:htmlize" (beg end
))
43 (declare-function org-pop-to-buffer-same-window
44 "org-compat" (&optional buffer-or-name norecord label
))
45 (declare-function mm-url-decode-entities
"mm-url" ())
49 (org-export-define-backend 'html
50 '((bold . org-html-bold
)
51 (center-block . org-html-center-block
)
52 (clock . org-html-clock
)
53 (code . org-html-code
)
54 (drawer . org-html-drawer
)
55 (dynamic-block . org-html-dynamic-block
)
56 (entity . org-html-entity
)
57 (example-block . org-html-example-block
)
58 (export-block . org-html-export-block
)
59 (export-snippet . org-html-export-snippet
)
60 (fixed-width . org-html-fixed-width
)
61 (footnote-definition . org-html-footnote-definition
)
62 (footnote-reference . org-html-footnote-reference
)
63 (headline . org-html-headline
)
64 (horizontal-rule . org-html-horizontal-rule
)
65 (inline-src-block . org-html-inline-src-block
)
66 (inlinetask . org-html-inlinetask
)
67 (inner-template . org-html-inner-template
)
68 (italic . org-html-italic
)
69 (item . org-html-item
)
70 (keyword . org-html-keyword
)
71 (latex-environment . org-html-latex-environment
)
72 (latex-fragment . org-html-latex-fragment
)
73 (line-break . org-html-line-break
)
74 (link . org-html-link
)
75 (node-property . org-html-node-property
)
76 (paragraph . org-html-paragraph
)
77 (plain-list . org-html-plain-list
)
78 (plain-text . org-html-plain-text
)
79 (planning . org-html-planning
)
80 (property-drawer . org-html-property-drawer
)
81 (quote-block . org-html-quote-block
)
82 (radio-target . org-html-radio-target
)
83 (section . org-html-section
)
84 (special-block . org-html-special-block
)
85 (src-block . org-html-src-block
)
86 (statistics-cookie . org-html-statistics-cookie
)
87 (strike-through . org-html-strike-through
)
88 (subscript . org-html-subscript
)
89 (superscript . org-html-superscript
)
90 (table . org-html-table
)
91 (table-cell . org-html-table-cell
)
92 (table-row . org-html-table-row
)
93 (target . org-html-target
)
94 (template . org-html-template
)
95 (timestamp . org-html-timestamp
)
96 (underline . org-html-underline
)
97 (verbatim . org-html-verbatim
)
98 (verse-block . org-html-verse-block
))
100 :filters-alist
'((:filter-options . org-html-infojs-install-script
)
101 (:filter-final-output . org-html-final-function
))
103 '(?h
"Export to HTML"
104 ((?H
"As HTML buffer" org-html-export-as-html
)
105 (?h
"As HTML file" org-html-export-to-html
)
106 (?o
"As HTML file and open"
108 (if a
(org-html-export-to-html t s v b
)
109 (org-open-file (org-html-export-to-html nil s v b
)))))))
111 '((:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
112 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
113 (:description
"DESCRIPTION" nil nil newline
)
114 (:keywords
"KEYWORDS" nil nil space
)
115 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
116 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
117 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
118 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
119 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
120 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
121 (:html-postamble nil
"html-postamble" org-html-postamble
)
122 (:html-preamble nil
"html-preamble" org-html-preamble
)
123 (:html-head
"HTML_HEAD" nil org-html-head newline
)
124 (:html-head-extra
"HTML_HEAD_EXTRA" nil org-html-head-extra newline
)
125 (:subtitle
"SUBTITLE" nil nil parse
)
126 (:html-head-include-default-style
127 nil
"html-style" org-html-head-include-default-style
)
128 (:html-head-include-scripts nil
"html-scripts" org-html-head-include-scripts
)
129 (:html-allow-name-attribute-in-anchors
130 nil nil org-html-allow-name-attribute-in-anchors
)
131 (:html-divs nil nil org-html-divs
)
132 (:html-checkbox-type nil nil org-html-checkbox-type
)
133 (:html-extension nil nil org-html-extension
)
134 (:html-footnote-format nil nil org-html-footnote-format
)
135 (:html-footnote-separator nil nil org-html-footnote-separator
)
136 (:html-footnotes-section nil nil org-html-footnotes-section
)
137 (:html-format-drawer-function nil nil org-html-format-drawer-function
)
138 (:html-format-headline-function nil nil org-html-format-headline-function
)
139 (:html-format-inlinetask-function
140 nil nil org-html-format-inlinetask-function
)
141 (:html-home
/up-format nil nil org-html-home
/up-format
)
142 (:html-indent nil nil org-html-indent
)
143 (:html-infojs-options nil nil org-html-infojs-options
)
144 (:html-infojs-template nil nil org-html-infojs-template
)
145 (:html-inline-image-rules nil nil org-html-inline-image-rules
)
146 (:html-link-org-files-as-html nil nil org-html-link-org-files-as-html
)
147 (:html-mathjax-options nil nil org-html-mathjax-options
)
148 (:html-mathjax-template nil nil org-html-mathjax-template
)
149 (:html-metadata-timestamp-format nil nil org-html-metadata-timestamp-format
)
150 (:html-postamble-format nil nil org-html-postamble-format
)
151 (:html-preamble-format nil nil org-html-preamble-format
)
152 (:html-table-align-individual-fields
153 nil nil org-html-table-align-individual-fields
)
154 (:html-table-caption-above nil nil org-html-table-caption-above
)
155 (:html-table-data-tags nil nil org-html-table-data-tags
)
156 (:html-table-header-tags nil nil org-html-table-header-tags
)
157 (:html-table-use-header-tags-for-first-column
158 nil nil org-html-table-use-header-tags-for-first-column
)
159 (:html-tag-class-prefix nil nil org-html-tag-class-prefix
)
160 (:html-text-markup-alist nil nil org-html-text-markup-alist
)
161 (:html-todo-kwd-class-prefix nil nil org-html-todo-kwd-class-prefix
)
162 (:html-toplevel-hlevel nil nil org-html-toplevel-hlevel
)
163 (:html-use-infojs nil nil org-html-use-infojs
)
164 (:html-use-unicode-chars nil nil org-html-use-unicode-chars
)
165 (:html-validation-link nil nil org-html-validation-link
)
166 (:html-viewport nil nil org-html-viewport
)
167 (:html-inline-images nil nil org-html-inline-images
)
168 (:html-table-attributes nil nil org-html-table-default-attributes
)
169 (:html-table-row-tags nil nil org-html-table-row-tags
)
170 (:html-xml-declaration nil nil org-html-xml-declaration
)
171 (:infojs-opt
"INFOJS_OPT" nil nil
)
172 ;; Redefine regular options.
173 (:creator
"CREATOR" nil org-html-creator-string
)
174 (:with-latex nil
"tex" org-html-with-latex
)
175 ;; Retrieve LaTeX header for fragments.
176 (:latex-header
"LATEX_HEADER" nil nil newline
)))
179 ;;; Internal Variables
181 (defvar org-html-format-table-no-css
)
182 (defvar htmlize-buffer-places
) ; from htmlize.el
184 (defvar org-html--pre
/postamble-class
"status"
185 "CSS class used for pre/postamble")
187 (defconst org-html-doctype-alist
188 '(("html4-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
189 \"http://www.w3.org/TR/html4/strict.dtd\">")
190 ("html4-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
191 \"http://www.w3.org/TR/html4/loose.dtd\">")
192 ("html4-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
193 \"http://www.w3.org/TR/html4/frameset.dtd\">")
195 ("xhtml-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
196 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
197 ("xhtml-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
198 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
199 ("xhtml-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
200 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
201 ("xhtml-11" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
202 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
204 ("html5" .
"<!DOCTYPE html>")
205 ("xhtml5" .
"<!DOCTYPE html>"))
206 "An alist mapping (x)html flavors to specific doctypes.")
208 (defconst org-html-html5-elements
209 '("article" "aside" "audio" "canvas" "details" "figcaption"
210 "figure" "footer" "header" "menu" "meter" "nav" "output"
211 "progress" "section" "video")
212 "New elements in html5.
214 For blocks that should contain headlines, use the HTML_CONTAINER
215 property on the headline itself.")
217 (defconst org-html-special-string-regexps
218 '(("\\\\-" .
"­") ; shy
219 ("---\\([^-]\\)" .
"—\\1") ; mdash
220 ("--\\([^-]\\)" .
"–\\1") ; ndash
221 ("\\.\\.\\." .
"…")) ; hellip
222 "Regular expressions for special string conversion.")
224 (defconst org-html-scripts
225 "<script type=\"text/javascript\">
227 @licstart The following is the entire license notice for the
228 JavaScript code in this tag.
230 Copyright (C) 2012-2013 Free Software Foundation, Inc.
232 The JavaScript code in this tag is free software: you can
233 redistribute it and/or modify it under the terms of the GNU
234 General Public License (GNU GPL) as published by the Free Software
235 Foundation, either version 3 of the License, or (at your option)
236 any later version. The code is distributed WITHOUT ANY WARRANTY;
237 without even the implied warranty of MERCHANTABILITY or FITNESS
238 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
240 As additional permission under GNU GPL version 3 section 7, you
241 may distribute non-source (e.g., minimized or compacted) forms of
242 that code without the copy of the GNU GPL normally required by
243 section 4, provided you include this license notice and a URL
244 through which recipients can access the Corresponding Source.
247 @licend The above is the entire license notice
248 for the JavaScript code in this tag.
250 <!--/*--><![CDATA[/*><!--*/
251 function CodeHighlightOn(elem, id)
253 var target = document.getElementById(id);
255 elem.cacheClassElem = elem.className;
256 elem.cacheClassTarget = target.className;
257 target.className = \"code-highlighted\";
258 elem.className = \"code-highlighted\";
261 function CodeHighlightOff(elem, id)
263 var target = document.getElementById(id);
264 if(elem.cacheClassElem)
265 elem.className = elem.cacheClassElem;
266 if(elem.cacheClassTarget)
267 target.className = elem.cacheClassTarget;
271 "Basic JavaScript that is needed by HTML files produced by Org mode.")
273 (defconst org-html-style-default
274 "<style type=\"text/css\">
275 <!--/*--><![CDATA[/*><!--*/
276 .title { text-align: center;
277 margin-bottom: .2em; }
278 .subtitle { text-align: center;
282 .todo { font-family: monospace; color: red; }
283 .done { font-family: monospace; color: green; }
284 .priority { font-family: monospace; color: orange; }
285 .tag { background-color: #eee; font-family: monospace;
286 padding: 2px; font-size: 80%; font-weight: normal; }
287 .timestamp { color: #bebebe; }
288 .timestamp-kwd { color: #5f9ea0; }
289 .org-right { margin-left: auto; margin-right: 0px; text-align: right; }
290 .org-left { margin-left: 0px; margin-right: auto; text-align: left; }
291 .org-center { margin-left: auto; margin-right: auto; text-align: center; }
292 .underline { text-decoration: underline; }
293 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
294 p.verse { margin-left: 3%; }
296 border: 1px solid #ccc;
297 box-shadow: 3px 3px 3px #eee;
299 font-family: monospace;
311 background-color: white;
315 border: 1px solid black;
317 pre.src:hover:before { display: inline;}
318 pre.src-sh:before { content: 'sh'; }
319 pre.src-bash:before { content: 'sh'; }
320 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
321 pre.src-R:before { content: 'R'; }
322 pre.src-perl:before { content: 'Perl'; }
323 pre.src-java:before { content: 'Java'; }
324 pre.src-sql:before { content: 'SQL'; }
326 table { border-collapse:collapse; }
327 caption.t-above { caption-side: top; }
328 caption.t-bottom { caption-side: bottom; }
329 td, th { vertical-align:top; }
330 th.org-right { text-align: center; }
331 th.org-left { text-align: center; }
332 th.org-center { text-align: center; }
333 td.org-right { text-align: right; }
334 td.org-left { text-align: left; }
335 td.org-center { text-align: center; }
336 dt { font-weight: bold; }
337 .footpara:nth-child(2) { display: inline; }
338 .footpara { display: block; }
339 .footdef { margin-bottom: 1em; }
340 .figure { padding: 1em; }
341 .figure p { text-align: center; }
344 border: 2px solid gray;
349 { text-align: right; font-size: 70%; white-space: nowrap; }
350 textarea { overflow-x: auto; }
351 .linenr { font-size: smaller }
352 .code-highlighted { background-color: #ffff00; }
353 .org-info-js_info-navigation { border-style: none; }
354 #org-info-js_console-label
355 { font-size: 10px; font-weight: bold; white-space: nowrap; }
356 .org-info-js_search-highlight
357 { background-color: #ffff00; color: #000000; font-weight: bold; }
360 "The default style specification for exported HTML files.
361 You can use `org-html-head' and `org-html-head-extra' to add to
362 this style. If you don't want to include this default style,
363 customize `org-html-head-include-default-style'.")
366 ;;; User Configuration Variables
368 (defgroup org-export-html nil
369 "Options for exporting Org mode files to HTML."
370 :tag
"Org Export HTML"
375 (defvar org-html-infojs-opts-table
376 '((path PATH
"http://orgmode.org/org-info.js")
380 (tdepth TOC_DEPTH
"max")
381 (sdepth SECTION_DEPTH
"max")
382 (mouse MOUSE_HINT
"underline")
383 (buttons VIEW_BUTTONS
"0")
385 (up LINK_UP
:html-link-up
)
386 (home LINK_HOME
:html-link-home
))
387 "JavaScript options, long form for script, default values.")
389 (defcustom org-html-use-infojs
'when-configured
390 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
391 This option can be nil or t to never or always use the script.
392 It can also be the symbol `when-configured', meaning that the
393 script will be linked into the export file if and only if there
394 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
395 `org-html-infojs-options'."
396 :group
'org-export-html
398 :package-version
'(Org .
"8.0")
400 (const :tag
"Never" nil
)
401 (const :tag
"When configured in buffer" when-configured
)
402 (const :tag
"Always" t
)))
404 (defcustom org-html-infojs-options
405 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
406 "Options settings for the INFOJS JavaScript.
407 Each of the options must have an entry in `org-html-infojs-opts-table'.
408 The value can either be a string that will be passed to the script, or
409 a property. This property is then assumed to be a property that is defined
410 by the Export/Publishing setup of Org.
411 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
412 means to use the maximum value consistent with other options."
413 :group
'org-export-html
415 :package-version
'(Org .
"8.0")
417 `(set :greedy t
:inline t
420 (list 'cons
(list 'const
(car x
))
422 (symbol :tag
"Publishing/Export property")
423 (string :tag
"Value"))))
424 org-html-infojs-opts-table
)))
426 (defcustom org-html-infojs-template
427 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
430 * @source: %SCRIPT_PATH
432 * @licstart The following is the entire license notice for the
433 * JavaScript code in %SCRIPT_PATH.
435 * Copyright (C) 2012-2013 Free Software Foundation, Inc.
438 * The JavaScript code in this tag is free software: you can
439 * redistribute it and/or modify it under the terms of the GNU
440 * General Public License (GNU GPL) as published by the Free Software
441 * Foundation, either version 3 of the License, or (at your option)
442 * any later version. The code is distributed WITHOUT ANY WARRANTY;
443 * without even the implied warranty of MERCHANTABILITY or FITNESS
444 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
446 * As additional permission under GNU GPL version 3 section 7, you
447 * may distribute non-source (e.g., minimized or compacted) forms of
448 * that code without the copy of the GNU GPL normally required by
449 * section 4, provided you include this license notice and a URL
450 * through which recipients can access the Corresponding Source.
452 * @licend The above is the entire license notice
453 * for the JavaScript code in %SCRIPT_PATH.
458 <script type=\"text/javascript\">
461 @licstart The following is the entire license notice for the
462 JavaScript code in this tag.
464 Copyright (C) 2012-2013 Free Software Foundation, Inc.
466 The JavaScript code in this tag is free software: you can
467 redistribute it and/or modify it under the terms of the GNU
468 General Public License (GNU GPL) as published by the Free Software
469 Foundation, either version 3 of the License, or (at your option)
470 any later version. The code is distributed WITHOUT ANY WARRANTY;
471 without even the implied warranty of MERCHANTABILITY or FITNESS
472 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
474 As additional permission under GNU GPL version 3 section 7, you
475 may distribute non-source (e.g., minimized or compacted) forms of
476 that code without the copy of the GNU GPL normally required by
477 section 4, provided you include this license notice and a URL
478 through which recipients can access the Corresponding Source.
481 @licend The above is the entire license notice
482 for the JavaScript code in this tag.
485 <!--/*--><![CDATA[/*><!--*/
487 org_html_manager.setup(); // activate after the parameters are set
490 "The template for the export style additions when org-info.js is used.
491 Option settings will replace the %MANAGER-OPTIONS cookie."
492 :group
'org-export-html
494 :package-version
'(Org .
"8.0")
497 (defun org-html-infojs-install-script (exp-plist backend
)
498 "Install script in export options when appropriate.
499 EXP-PLIST is a plist containing export options. BACKEND is the
500 export back-end currently used."
501 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
502 (not (plist-get exp-plist
:html-use-infojs
))
503 (and (eq (plist-get exp-plist
:html-use-infojs
) 'when-configured
)
504 (let ((opt (plist-get exp-plist
:infojs-opt
)))
507 (string-match "\\<view:nil\\>" opt
)))))
508 (let* ((template (plist-get exp-plist
:html-infojs-template
))
509 (ptoc (plist-get exp-plist
:with-toc
))
510 (hlevels (plist-get exp-plist
:headline-levels
))
512 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
513 (options (plist-get exp-plist
:infojs-opt
))
514 (infojs-opt (plist-get exp-plist
:html-infojs-options
))
515 (table org-html-infojs-opts-table
)
517 (dolist (entry table
)
518 (let* ((opt (car entry
))
520 ;; Compute default values for script option OPT from
521 ;; `org-html-infojs-options' variable.
523 (let ((default (cdr (assq opt infojs-opt
))))
524 (if (and (symbolp default
) (not (memq default
'(t nil
))))
525 (plist-get exp-plist default
)
527 ;; Value set through INFOJS_OPT keyword has precedence
528 ;; over the default one.
529 (val (if (and options
530 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
532 (match-string 1 options
)
536 (replace-regexp-in-string
537 "%SCRIPT_PATH" val template t t
)))
538 (sdepth (when (integerp (read val
))
539 (setq sdepth
(min (read val
) sdepth
))))
540 (tdepth (when (integerp (read val
))
541 (setq tdepth
(min (read val
) tdepth
))))
544 ((or (eq val t
) (equal val
"t")) "1")
545 ((or (eq val nil
) (equal val
"nil")) "0")
547 (t (format "%s" val
))))
548 (push (cons var val
) style
)))))
549 ;; Now we set the depth of the *generated* TOC to SDEPTH,
550 ;; because the toc will actually determine the splitting. How
551 ;; much of the toc will actually be displayed is governed by the
553 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
554 ;; The table of contents should not show more sections than we
556 (setq tdepth
(min tdepth sdepth
))
557 (push (cons "TOC_DEPTH" tdepth
) style
)
558 ;; Build style string.
559 (setq style
(mapconcat
561 (format "org_html_manager.set(\"%s\", \"%s\");"
564 (when (and style
(> (length style
) 0))
565 (and (string-match "%MANAGER_OPTIONS" template
)
566 (setq style
(replace-match style t t template
))
569 exp-plist
:html-head-extra
570 (concat (or (plist-get exp-plist
:html-head-extra
) "")
573 ;; This script absolutely needs the table of contents, so we
574 ;; change that setting.
575 (unless (plist-get exp-plist
:with-toc
)
576 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
577 ;; Return the modified property list.
582 (defcustom org-html-text-markup-alist
583 '((bold .
"<b>%s</b>")
584 (code .
"<code>%s</code>")
585 (italic .
"<i>%s</i>")
586 (strike-through .
"<del>%s</del>")
587 (underline .
"<span class=\"underline\">%s</span>")
588 (verbatim .
"<code>%s</code>"))
589 "Alist of HTML expressions to convert text markup.
591 The key must be a symbol among `bold', `code', `italic',
592 `strike-through', `underline' and `verbatim'. The value is
593 a formatting string to wrap fontified text with.
595 If no association can be found for a given markup, text will be
597 :group
'org-export-html
599 :package-version
'(Org .
"8.0")
600 :type
'(alist :key-type
(symbol :tag
"Markup type")
601 :value-type
(string :tag
"Format string"))
602 :options
'(bold code italic strike-through underline verbatim
))
604 (defcustom org-html-indent nil
605 "Non-nil means to indent the generated HTML.
606 Warning: non-nil may break indentation of source code blocks."
607 :group
'org-export-html
609 :package-version
'(Org .
"8.0")
612 (defcustom org-html-use-unicode-chars nil
613 "Non-nil means to use unicode characters instead of HTML entities."
614 :group
'org-export-html
616 :package-version
'(Org .
"8.0")
621 (defcustom org-html-format-drawer-function
(lambda (name contents
) contents
)
622 "Function called to format a drawer in HTML code.
624 The function must accept two parameters:
625 NAME the drawer name, like \"LOGBOOK\"
626 CONTENTS the contents of the drawer.
628 The function should return the string to be exported.
630 For example, the variable could be set to the following function
631 in order to mimic default behaviour:
633 The default value simply returns the value of CONTENTS."
634 :group
'org-export-html
636 :package-version
'(Org .
"8.0")
641 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
642 <h2 class=\"footnotes\">%s: </h2>
643 <div id=\"text-footnotes\">
647 "Format for the footnotes section.
648 Should contain a two instances of %s. The first will be replaced with the
649 language-specific word for \"Footnotes\", the second one will be replaced
650 by the footnotes themselves."
651 :group
'org-export-html
654 (defcustom org-html-footnote-format
"<sup>%s</sup>"
655 "The format for the footnote reference.
656 %s will be replaced by the footnote reference itself."
657 :group
'org-export-html
660 (defcustom org-html-footnote-separator
"<sup>, </sup>"
661 "Text used to separate footnotes."
662 :group
'org-export-html
667 (defcustom org-html-toplevel-hlevel
2
668 "The <H> level for level 1 headings in HTML export.
669 This is also important for the classes that will be wrapped around headlines
670 and outline structure. If this variable is 1, the top-level headlines will
671 be <h1>, and the corresponding classes will be outline-1, section-number-1,
672 and outline-text-1. If this is 2, all of these will get a 2 instead.
673 The default for this variable is 2, because we use <h1> for formatting the
675 :group
'org-export-html
678 (defcustom org-html-format-headline-function
679 'org-html-format-headline-default-function
680 "Function to format headline text.
682 This function will be called with six arguments:
683 TODO the todo keyword (string or nil).
684 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
685 PRIORITY the priority of the headline (integer or nil)
686 TEXT the main headline text (string).
687 TAGS the tags (string or nil).
688 INFO the export options (plist).
690 The function result will be used in the section format string."
691 :group
'org-export-html
693 :package-version
'(Org .
"8.3")
698 (defcustom org-html-allow-name-attribute-in-anchors nil
699 "When nil, do not set \"name\" attribute in anchors.
700 By default, when appropriate, anchors are formatted with \"id\"
701 but without \"name\" attribute."
702 :group
'org-export-html
704 :package-version
'(Org .
"8.0")
709 (defcustom org-html-format-inlinetask-function
710 'org-html-format-inlinetask-default-function
711 "Function called to format an inlinetask in HTML code.
713 The function must accept seven parameters:
714 TODO the todo keyword, as a string
715 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
716 PRIORITY the inlinetask priority, as a string
717 NAME the inlinetask name, as a string.
718 TAGS the inlinetask tags, as a list of strings.
719 CONTENTS the contents of the inlinetask, as a string.
720 INFO the export options, as a plist
722 The function should return the string to be exported."
723 :group
'org-export-html
725 :package-version
'(Org .
"8.3")
730 (defcustom org-html-with-latex org-export-with-latex
731 "Non-nil means process LaTeX math snippets.
733 When set, the exporter will process LaTeX environments and
736 This option can also be set with the +OPTIONS line,
737 e.g. \"tex:mathjax\". Allowed values are:
739 nil Ignore math snippets.
740 `verbatim' Keep everything in verbatim
741 `dvipng' Process the LaTeX fragments to images. This will also
742 include processing of non-math environments.
743 `imagemagick' Convert the LaTeX fragments to pdf files and use
744 imagemagick to convert pdf files to png files.
745 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
747 t Synonym for `mathjax'."
748 :group
'org-export-html
750 :package-version
'(Org .
"8.0")
752 (const :tag
"Do not process math in any way" nil
)
753 (const :tag
"Use dvipng to make images" dvipng
)
754 (const :tag
"Use imagemagick to make images" imagemagick
)
755 (const :tag
"Use MathJax to display math" mathjax
)
756 (const :tag
"Leave math verbatim" verbatim
)))
758 ;;;; Links :: Generic
760 (defcustom org-html-link-org-files-as-html t
761 "Non-nil means make file links to `file.org' point to `file.html'.
762 When `org-mode' is exporting an `org-mode' file to HTML, links to
763 non-html files are directly put into a href tag in HTML.
764 However, links to other Org-mode files (recognized by the
765 extension `.org.) should become links to the corresponding html
766 file, assuming that the linked `org-mode' file will also be
768 When nil, the links still point to the plain `.org' file."
769 :group
'org-export-html
772 ;;;; Links :: Inline images
774 (defcustom org-html-inline-images t
775 "Non-nil means inline images into exported HTML pages.
776 This is done using an <img> tag. When nil, an anchor with href is used to
778 :group
'org-export-html
780 :package-version
'(Org .
"8.1")
783 (defcustom org-html-inline-image-rules
784 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
785 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
786 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
787 "Rules characterizing image files that can be inlined into HTML.
788 A rule consists in an association whose key is the type of link
789 to consider, and value is a regexp that will be matched against
791 :group
'org-export-html
793 :package-version
'(Org .
"8.0")
794 :type
'(alist :key-type
(string :tag
"Type")
795 :value-type
(regexp :tag
"Path")))
799 (defvar org-html-protect-char-alist
803 "Alist of characters to be converted by `org-html-encode-plain-text'.")
807 (defcustom org-html-htmlize-output-type
'inline-css
808 "Output type to be used by htmlize when formatting code snippets.
809 Choices are `css' to export the CSS selectors only,`inline-css'
810 to export the CSS attribute values inline in the HTML or `nil' to
811 export plain text. We use as default `inline-css', in order to
812 make the resulting HTML self-containing.
814 However, this will fail when using Emacs in batch mode for export, because
815 then no rich font definitions are in place. It will also not be good if
816 people with different Emacs setup contribute HTML files to a website,
817 because the fonts will represent the individual setups. In these cases,
818 it is much better to let Org/Htmlize assign classes only, and to use
819 a style file to define the look of these classes.
820 To get a start for your css file, start Emacs session and make sure that
821 all the faces you are interested in are defined, for example by loading files
822 in all modes you want. Then, use the command
823 \\[org-html-htmlize-generate-css] to extract class definitions."
824 :group
'org-export-html
825 :type
'(choice (const css
) (const inline-css
) (const nil
)))
827 (defcustom org-html-htmlize-font-prefix
"org-"
828 "The prefix for CSS class names for htmlize font specifications."
829 :group
'org-export-html
834 (defcustom org-html-table-default-attributes
835 '(:border
"2" :cellspacing
"0" :cellpadding
"6" :rules
"groups" :frame
"hsides")
836 "Default attributes and values which will be used in table tags.
837 This is a plist where attributes are symbols, starting with
838 colons, and values are strings.
840 When exporting to HTML5, these values will be disregarded."
841 :group
'org-export-html
843 :package-version
'(Org .
"8.0")
844 :type
'(plist :key-type
(symbol :tag
"Property")
845 :value-type
(string :tag
"Value")))
847 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
848 "The opening and ending tags for table header fields.
849 This is customizable so that alignment options can be specified.
850 The first %s will be filled with the scope of the field, either row or col.
851 The second %s will be replaced by a style entry to align the field.
852 See also the variable `org-html-table-use-header-tags-for-first-column'.
853 See also the variable `org-html-table-align-individual-fields'."
854 :group
'org-export-html
855 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
857 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
858 "The opening and ending tags for table data fields.
859 This is customizable so that alignment options can be specified.
860 The first %s will be filled with the scope of the field, either row or col.
861 The second %s will be replaced by a style entry to align the field.
862 See also the variable `org-html-table-align-individual-fields'."
863 :group
'org-export-html
864 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
866 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
867 "The opening and ending tags for table rows.
868 This is customizable so that alignment options can be specified.
869 Instead of strings, these can be Lisp forms that will be
870 evaluated for each row in order to construct the table row tags.
872 During evaluation, these variables will be dynamically bound so that
875 `row-number': row number (0 is the first row)
876 `rowgroup-number': group number of current row
877 `start-rowgroup-p': non-nil means the row starts a group
878 `end-rowgroup-p': non-nil means the row ends a group
879 `top-row-p': non-nil means this is the top row
880 `bottom-row-p': non-nil means this is the bottom row
884 \(setq org-html-table-row-tags
885 (cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
886 (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
887 (t (if (= (mod row-number 2) 1)
888 \"<tr class=\\\"tr-odd\\\">\"
889 \"<tr class=\\\"tr-even\\\">\")))
892 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
893 and the bottom row, and otherwise alternate between \"tr-odd\" and
894 \"tr-even\" for odd and even rows."
895 :group
'org-export-html
897 (choice :tag
"Opening tag"
898 (string :tag
"Specify")
900 (choice :tag
"Closing tag"
901 (string :tag
"Specify")
904 (defcustom org-html-table-align-individual-fields t
905 "Non-nil means attach style attributes for alignment to each table field.
906 When nil, alignment will only be specified in the column tags, but this
907 is ignored by some browsers (like Firefox, Safari). Opera does it right
909 :group
'org-export-html
912 (defcustom org-html-table-use-header-tags-for-first-column nil
913 "Non-nil means format column one in tables with header tags.
914 When nil, also column one will use data tags."
915 :group
'org-export-html
918 (defcustom org-html-table-caption-above t
919 "When non-nil, place caption string at the beginning of the table.
920 Otherwise, place it near the end."
921 :group
'org-export-html
926 (defcustom org-html-tag-class-prefix
""
927 "Prefix to class names for TODO keywords.
928 Each tag gets a class given by the tag itself, with this prefix.
929 The default prefix is empty because it is nice to just use the keyword
930 as a class name. But if you get into conflicts with other, existing
931 CSS classes, then this prefix can be very useful."
932 :group
'org-export-html
935 ;;;; Template :: Generic
937 (defcustom org-html-extension
"html"
938 "The extension for exported HTML files."
939 :group
'org-export-html
942 (defcustom org-html-xml-declaration
943 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
944 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
945 "The extension for exported HTML files.
946 %s will be replaced with the charset of the exported file.
947 This may be a string, or an alist with export extensions
948 and corresponding declarations.
950 This declaration only applies when exporting to XHTML."
951 :group
'org-export-html
953 (string :tag
"Single declaration")
954 (repeat :tag
"Dependent on extension"
955 (cons (string :tag
"Extension")
956 (string :tag
"Declaration")))))
958 (defcustom org-html-coding-system
'utf-8
959 "Coding system for HTML export.
960 Use utf-8 as the default value."
961 :group
'org-export-html
963 :package-version
'(Org .
"8.0")
964 :type
'coding-system
)
966 (defcustom org-html-doctype
"xhtml-strict"
967 "Document type definition to use for exported HTML files.
968 Can be set with the in-buffer HTML_DOCTYPE property or for
969 publishing, with :html-doctype."
970 :group
'org-export-html
972 :package-version
'(Org .
"8.0")
975 (mapcar (lambda (x) `(const ,(car x
))) org-html-doctype-alist
)
976 '((string :tag
"Custom doctype" ))))
978 (defcustom org-html-html5-fancy nil
979 "Non-nil means using new HTML5 elements.
980 This variable is ignored for anything other than HTML5 export.
982 For compatibility with Internet Explorer, it's probably a good
983 idea to download some form of the html5shiv (for instance
984 https://code.google.com/p/html5shiv/) and add it to your
985 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
986 versions 8 and below."
987 :group
'org-export-html
989 :package-version
'(Org .
"8.0")
992 (defcustom org-html-container-element
"div"
993 "HTML element to use for wrapping top level sections.
994 Can be set with the in-buffer HTML_CONTAINER property or for
995 publishing, with :html-container.
997 Note that changing the default will prevent you from using
998 org-info.js for your website."
999 :group
'org-export-html
1001 :package-version
'(Org .
"8.0")
1004 (defcustom org-html-divs
1005 '((preamble "div" "preamble")
1006 (content "div" "content")
1007 (postamble "div" "postamble"))
1008 "Alist of the three section elements for HTML export.
1009 The car of each entry is one of 'preamble, 'content or 'postamble.
1010 The cdrs of each entry are the ELEMENT_TYPE and ID for each
1011 section of the exported document.
1013 Note that changing the default will prevent you from using
1014 org-info.js for your website."
1015 :group
'org-export-html
1017 :package-version
'(Org .
"8.0")
1018 :type
'(list :greedy t
1019 (list :tag
"Preamble"
1020 (const :format
"" preamble
)
1021 (string :tag
"element") (string :tag
" id"))
1022 (list :tag
"Content"
1023 (const :format
"" content
)
1024 (string :tag
"element") (string :tag
" id"))
1025 (list :tag
"Postamble" (const :format
"" postamble
)
1026 (string :tag
" id") (string :tag
"element"))))
1028 (defconst org-html-checkbox-types
1030 ((on .
"☑") (off .
"☐") (trans .
"☐")))
1032 ((on .
"<code>[X]</code>")
1033 (off .
"<code>[ ]</code>")
1034 (trans .
"<code>[-]</code>")))
1036 ((on .
"<input type='checkbox' checked='checked' />")
1037 (off .
"<input type='checkbox' />")
1038 (trans .
"<input type='checkbox' />"))))
1039 "Alist of checkbox types.
1040 The cdr of each entry is an alist list three checkbox types for
1041 HTML export: `on', `off' and `trans'.
1044 `unicode' Unicode characters (HTML entities)
1045 `ascii' ASCII characters
1046 `html' HTML checkboxes
1048 Note that only the ascii characters implement tri-state
1049 checkboxes. The other two use the `off' checkbox for `trans'.")
1051 (defcustom org-html-checkbox-type
'ascii
1052 "The type of checkboxes to use for HTML export.
1053 See `org-html-checkbox-types' for for the values used for each
1055 :group
'org-export-html
1057 :package-version
'(Org .
"8.0")
1059 (const :tag
"ASCII characters" ascii
)
1060 (const :tag
"Unicode characters" unicode
)
1061 (const :tag
"HTML checkboxes" html
)))
1063 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
1064 "Format used for timestamps in preamble, postamble and metadata.
1065 See `format-time-string' for more information on its components."
1066 :group
'org-export-html
1068 :package-version
'(Org .
"8.0")
1071 ;;;; Template :: Mathjax
1073 (defcustom org-html-mathjax-options
1074 '((path "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" )
1078 (linebreaks "false")
1081 (multlinewidth "85%")
1084 "Options for MathJax setup.
1086 Alist of the following elements. All values are strings.
1088 path The path to MathJax.
1089 scale Scaling with HTML-CSS, MathML and SVG output engines.
1090 align How to align display math: left, center, or right.
1091 font The font to use with HTML-CSS and SVG output. As of MathJax 2.5
1092 the following values are understood: \"TeX\", \"STIX-Web\",
1093 \"Asana-Math\", \"Neo-Euler\", \"Gyre-Pagella\",
1094 \"Gyre-Termes\", and \"Latin-Modern\".
1095 linebreaks Let MathJax perform automatic linebreaks. Valid values
1096 are \"true\" and \"false\".
1097 indent If align is not center, how far from the left/right side?
1098 Valid values are \"left\" and \"right\"
1099 multlinewidth The width of the multline environment.
1100 autonumber How to number equations. Valid values are \"None\",
1101 \"all\" and \"AMS Math\".
1102 tagindent The amount tags are indented.
1103 tagside Which side to show tags/labels on. Valid values are
1104 \"left\" and \"right\"
1106 You can also customize this for each buffer, using something like
1108 #+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
1110 For further information about MathJax options, see the MathJax documentation:
1112 http://docs.mathjax.org/
1114 Please note that by using the default CDN one must agree with
1115 MathJax CDN Terms of Service.
1117 http://www.mathjax.org/mathjax-cdn-terms-of-service.html"
1118 :group
'org-export-html
1119 :package-version
'(Org .
"8.3")
1120 :type
'(list :greedy t
1121 (list :tag
"path (the path from where to load MathJax.js)"
1122 (const :format
" " path
) (string))
1123 (list :tag
"scale (scaling for the displayed math)"
1124 (const :format
" " scale
) (string))
1125 (list :tag
"align (alignment of displayed equations)"
1126 (const :format
" " align
) (string))
1127 (list :tag
"font (used to display math)"
1128 (const :format
" " font
)
1129 (choice (const "TeX")
1131 (const "Asana-Math")
1133 (const "Gyre-Pagella")
1134 (const "Gyre-Termes")
1135 (const "Latin-Modern")))
1136 (list :tag
"linebreaks (automatic line-breaking)"
1137 (const :format
" " linebreaks
)
1138 (choice (const "true")
1140 (list :tag
"autonumber (when should equations be numbered)"
1141 (const :format
" " autonumber
)
1142 (choice (const "AMS")
1145 (list :tag
"indent (indentation with left or right alignment)"
1146 (const :format
" " indent
) (string))
1147 (list :tag
"multlinewidth (width to use for the multline environment)"
1148 (const :format
" " multlinewidth
) (string))
1149 (list :tag
"tagindent (the indentation of tags from left or right)"
1150 (const :format
" " tagindent
) (string))
1151 (list :tag
"tagside (location of tags)"
1152 (const :format
" " tagside
)
1153 (choice (const "left")
1156 (defcustom org-html-mathjax-template
1157 "<script type=\"text/x-mathjax-config\">
1158 MathJax.Hub.Config({
1159 displayAlign: \"%ALIGN\",
1160 displayIndent: \"%INDENT\",
1162 \"HTML-CSS\": { scale: %SCALE,
1163 linebreaks: { automatic: \"%LINEBREAKS\" },
1166 SVG: {scale: %SCALE,
1167 linebreaks: { automatic: \"%LINEBREAKS\" },
1169 NativeMML: {scale: %SCALE},
1170 TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"},
1171 MultLineWidth: \"%MULTLINEWIDTH\",
1172 TagSide: \"%TAGSIDE\",
1173 TagIndent: \"%TAGINDENT\"
1177 <script type=\"text/javascript\"
1178 src=\"%PATH\"></script>"
1179 "The MathJax template. See also `org-html-mathjax-options'."
1180 :group
'org-export-html
1183 ;;;; Template :: Postamble
1185 (defcustom org-html-postamble
'auto
1186 "Non-nil means insert a postamble in HTML export.
1188 When set to 'auto, check against the
1189 `org-export-with-author/email/creator/date' variables to set the
1190 content of the postamble. When set to a string, use this string
1191 as the postamble. When t, insert a string as defined by the
1192 formatting string in `org-html-postamble-format'.
1194 When set to a function, apply this function and insert the
1195 returned string. The function takes the property list of export
1196 options as its only argument.
1198 Setting :html-postamble in publishing projects will take
1199 precedence over this variable."
1200 :group
'org-export-html
1201 :type
'(choice (const :tag
"No postamble" nil
)
1202 (const :tag
"Auto postamble" auto
)
1203 (const :tag
"Default formatting string" t
)
1204 (string :tag
"Custom formatting string")
1205 (function :tag
"Function (must return a string)")))
1207 (defcustom org-html-postamble-format
1208 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1209 <p class=\"date\">Date: %d</p>
1210 <p class=\"creator\">%c</p>
1211 <p class=\"validation\">%v</p>"))
1212 "Alist of languages and format strings for the HTML postamble.
1214 The first element of each list is the language code, as used for
1215 the LANGUAGE keyword. See `org-export-default-language'.
1217 The second element of each list is a format string to format the
1218 postamble itself. This format string can contain these elements:
1220 %t stands for the title.
1221 %s stands for the subtitle.
1222 %a stands for the author's name.
1223 %e stands for the author's email.
1224 %d stands for the date.
1225 %c will be replaced by `org-html-creator-string'.
1226 %v will be replaced by `org-html-validation-link'.
1227 %T will be replaced by the export time.
1228 %C will be replaced by the last modification time.
1230 If you need to use a \"%\" character, you need to escape it
1232 :group
'org-export-html
1234 (list (string :tag
"Language")
1235 (string :tag
"Format string"))))
1237 (defcustom org-html-validation-link
1238 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1239 "Link to HTML validation service."
1240 :group
'org-export-html
1243 (defcustom org-html-creator-string
1244 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1246 (if (fboundp 'org-version
) (org-version) "unknown version"))
1247 "Information about the creator of the HTML document.
1248 This option can also be set on with the CREATOR keyword."
1249 :group
'org-export-html
1251 :package-version
'(Org .
"8.0")
1252 :type
'(string :tag
"Creator string"))
1254 ;;;; Template :: Preamble
1256 (defcustom org-html-preamble t
1257 "Non-nil means insert a preamble in HTML export.
1259 When t, insert a string as defined by the formatting string in
1260 `org-html-preamble-format'. When set to a string, use this
1261 formatting string instead (see `org-html-postamble-format' for an
1262 example of such a formatting string).
1264 When set to a function, apply this function and insert the
1265 returned string. The function takes the property list of export
1266 options as its only argument.
1268 Setting :html-preamble in publishing projects will take
1269 precedence over this variable."
1270 :group
'org-export-html
1271 :type
'(choice (const :tag
"No preamble" nil
)
1272 (const :tag
"Default preamble" t
)
1273 (string :tag
"Custom formatting string")
1274 (function :tag
"Function (must return a string)")))
1276 (defcustom org-html-preamble-format
'(("en" ""))
1277 "Alist of languages and format strings for the HTML preamble.
1279 The first element of each list is the language code, as used for
1280 the LANGUAGE keyword. See `org-export-default-language'.
1282 The second element of each list is a format string to format the
1283 preamble itself. This format string can contain these elements:
1285 %t stands for the title.
1286 %s stands for the subtitle.
1287 %a stands for the author's name.
1288 %e stands for the author's email.
1289 %d stands for the date.
1290 %c will be replaced by `org-html-creator-string'.
1291 %v will be replaced by `org-html-validation-link'.
1292 %T will be replaced by the export time.
1293 %C will be replaced by the last modification time.
1295 If you need to use a \"%\" character, you need to escape it
1298 See the default value of `org-html-postamble-format' for an
1300 :group
'org-export-html
1302 (list (string :tag
"Language")
1303 (string :tag
"Format string"))))
1305 (defcustom org-html-link-up
""
1306 "Where should the \"UP\" link of exported HTML pages lead?"
1307 :group
'org-export-html
1308 :type
'(string :tag
"File or URL"))
1310 (defcustom org-html-link-home
""
1311 "Where should the \"HOME\" link of exported HTML pages lead?"
1312 :group
'org-export-html
1313 :type
'(string :tag
"File or URL"))
1315 (defcustom org-html-link-use-abs-url nil
1316 "Should we prepend relative links with HTML_LINK_HOME?"
1317 :group
'org-export-html
1319 :package-version
'(Org .
"8.1")
1322 (defcustom org-html-home
/up-format
1323 "<div id=\"org-div-home-and-up\">
1324 <a accesskey=\"h\" href=\"%s\"> UP </a>
1326 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1328 "Snippet used to insert the HOME and UP links.
1329 This is a format string, the first %s will receive the UP link,
1330 the second the HOME link. If both `org-html-link-up' and
1331 `org-html-link-home' are empty, the entire snippet will be
1333 :group
'org-export-html
1336 ;;;; Template :: Scripts
1338 (define-obsolete-variable-alias
1339 'org-html-style-include-scripts
'org-html-head-include-scripts
"24.4")
1340 (defcustom org-html-head-include-scripts t
1341 "Non-nil means include the JavaScript snippets in exported HTML files.
1342 The actual script is defined in `org-html-scripts' and should
1344 :group
'org-export-html
1346 :package-version
'(Org .
"8.0")
1349 ;;;; Template :: Styles
1351 (define-obsolete-variable-alias
1352 'org-html-style-include-default
'org-html-head-include-default-style
"24.4")
1353 (defcustom org-html-head-include-default-style t
1354 "Non-nil means include the default style in exported HTML files.
1355 The actual style is defined in `org-html-style-default' and
1356 should not be modified. Use `org-html-head' to use your own
1358 :group
'org-export-html
1360 :package-version
'(Org .
"8.0")
1363 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1365 (define-obsolete-variable-alias 'org-html-style
'org-html-head
"24.4")
1366 (defcustom org-html-head
""
1367 "Org-wide head definitions for exported HTML files.
1369 This variable can contain the full HTML structure to provide a
1370 style, including the surrounding HTML tags. You can consider
1371 including definitions for the following classes: title, todo,
1372 done, timestamp, timestamp-kwd, tag, target.
1374 For example, a valid value would be:
1376 <style type=\"text/css\">
1378 p { font-weight: normal; color: gray; }
1379 h1 { color: black; }
1380 .title { text-align: center; }
1381 .todo, .timestamp-kwd { color: red; }
1382 .done { color: green; }
1386 If you want to refer to an external style, use something like
1388 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1390 As the value of this option simply gets inserted into the HTML
1391 <head> header, you can use it to add any arbitrary text to the
1394 You can set this on a per-file basis using #+HTML_HEAD:,
1395 or for publication projects using the :html-head property."
1396 :group
'org-export-html
1398 :package-version
'(Org .
"8.0")
1401 (put 'org-html-head
'safe-local-variable
'stringp
)
1403 (defcustom org-html-head-extra
""
1404 "More head information to add in the HTML output.
1406 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1407 or for publication projects using the :html-head-extra property."
1408 :group
'org-export-html
1410 :package-version
'(Org .
"8.0")
1413 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1415 ;;;; Template :: Viewport
1417 (defcustom org-html-viewport
'((width "device-width")
1422 "Viewport options for mobile-optimized sites.
1424 The following values are recognized
1426 width Size of the viewport.
1427 initial-scale Zoom level when the page is first loaded.
1428 minimum-scale Minimum allowed zoom level.
1429 maximum-scale Maximum allowed zoom level.
1430 user-scalable Whether zoom can be changed.
1432 The viewport meta tag is inserted if this variable is non-nil.
1434 See the following site for a reference:
1435 https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag"
1436 :group
'org-export-html
1438 :package-version
'(Org .
"8.3")
1439 :type
'(list :greedy t
1440 (list :tag
"Width of viewport"
1441 (const :format
" " width
)
1442 (choice (const :tag
"unset" "")
1444 (list :tag
"Initial scale"
1445 (const :format
" " initial-scale
)
1446 (choice (const :tag
"unset" "")
1448 (list :tag
"Minimum scale/zoom"
1449 (const :format
" " minimum-scale
)
1450 (choice (const :tag
"unset" "")
1452 (list :tag
"Maximum scale/zoom"
1453 (const :format
" " maximum-scale
)
1454 (choice (const :tag
"unset" "")
1456 (list :tag
"User scalable/zoomable"
1457 (const :format
" " user-scalable
)
1458 (choice (const :tag
"unset" "")
1464 (defcustom org-html-todo-kwd-class-prefix
""
1465 "Prefix to class names for TODO keywords.
1466 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1467 The default prefix is empty because it is nice to just use the keyword
1468 as a class name. But if you get into conflicts with other, existing
1469 CSS classes, then this prefix can be very useful."
1470 :group
'org-export-html
1474 ;;; Internal Functions
1476 (defun org-html-xhtml-p (info)
1477 (let ((dt (downcase (plist-get info
:html-doctype
))))
1478 (string-match-p "xhtml" dt
)))
1480 (defun org-html-html5-p (info)
1481 (let ((dt (downcase (plist-get info
:html-doctype
))))
1482 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1484 (defun org-html-close-tag (tag attr info
)
1485 (concat "<" tag
" " attr
1486 (if (org-html-xhtml-p info
) " />" ">")))
1488 (defun org-html-doctype (info)
1489 "Return correct html doctype tag from `org-html-doctype-alist',
1490 or the literal value of :html-doctype from INFO if :html-doctype
1491 is not found in the alist.
1492 INFO is a plist used as a communication channel."
1493 (let ((dt (plist-get info
:html-doctype
)))
1494 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1496 (defun org-html--make-attribute-string (attributes)
1497 "Return a list of attributes, as a string.
1498 ATTRIBUTES is a plist where values are either strings or nil. An
1499 attributes with a nil value will be omitted from the result."
1501 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1502 (cond ((null item
) (pop output
))
1503 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1504 (t (let ((key (car output
))
1505 (value (replace-regexp-in-string
1506 "\"" """ (org-html-encode-plain-text item
))))
1507 (setcar output
(format "%s=\"%s\"" key value
))))))))
1509 (defun org-html--wrap-image (contents info
&optional caption label
)
1510 "Wrap CONTENTS string within an appropriate environment for images.
1511 INFO is a plist used as a communication channel. When optional
1512 arguments CAPTION and LABEL are given, use them for caption and
1514 (let ((html5-fancy (and (org-html-html5-p info
)
1515 (plist-get info
:html-html5-fancy
))))
1516 (format (if html5-fancy
"\n<figure%s>%s%s\n</figure>"
1517 "\n<div%s class=\"figure\">%s%s\n</div>")
1519 (if (org-string-nw-p label
) (format " id=\"%s\"" label
) "")
1521 (format "\n<p>%s</p>" contents
)
1523 (if (not (org-string-nw-p caption
)) ""
1524 (format (if html5-fancy
"\n<figcaption>%s</figcaption>"
1528 (defun org-html--format-image (source attributes info
)
1529 "Return \"img\" tag with given SOURCE and ATTRIBUTES.
1530 SOURCE is a string specifying the location of the image.
1531 ATTRIBUTES is a plist, as returned by
1532 `org-export-read-attribute'. INFO is a plist used as
1533 a communication channel."
1534 (if (string= "svg" (file-name-extension source
))
1535 (org-html--svg-image source attributes info
)
1538 (org-html--make-attribute-string
1541 :alt
(if (string-match-p "^ltxpng/" source
)
1542 (org-html-encode-plain-text
1543 (org-find-text-property-in-string 'org-latex-src source
))
1544 (file-name-nondirectory source
)))
1548 (defun org-html--svg-image (source attributes info
)
1549 "Return \"object\" appropriate for embedding svg file SOURCE
1550 with assoicated ATTRIBUTES. INFO is a plist used as a
1551 communication channel.
1553 The special attribute \"fallback\" can be used to specify a fallback
1554 image file to use if the object embedding is not supported."
1555 (let ((fallback (plist-get attributes
:fallback
))
1556 (attrs (org-html--make-attribute-string
1557 (plist-put attributes
:fallback nil
))))
1558 (format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>"
1562 "img" (format "src=\"%s\" %s" fallback attrs
) info
)
1563 "Sorry, your browser does not support SVG."))))
1565 (defun org-html--textarea-block (element)
1566 "Transcode ELEMENT into a textarea block.
1567 ELEMENT is either a src block or an example block."
1568 (let* ((code (car (org-export-unravel-code element
)))
1569 (attr (org-export-read-attribute :attr_html element
)))
1570 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1571 (or (plist-get attr
:width
) 80)
1572 (or (plist-get attr
:height
) (org-count-lines code
))
1575 (defun org-html--has-caption-p (element &optional info
)
1576 "Non-nil when ELEMENT has a caption affiliated keyword.
1577 INFO is a plist used as a communication channel. This function
1578 is meant to be used as a predicate for `org-export-get-ordinal' or
1579 a value to `org-html-standalone-image-predicate'."
1580 (org-element-property :caption element
))
1584 (defun org-html-htmlize-region-for-paste (beg end
)
1585 "Convert the region between BEG and END to HTML, using htmlize.el.
1586 This is much like `htmlize-region-for-paste', only that it uses
1587 the settings define in the org-... variables."
1588 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1589 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1590 (htmlbuf (htmlize-region beg end
)))
1592 (with-current-buffer htmlbuf
1593 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1594 (plist-get htmlize-buffer-places
'content-end
)))
1595 (kill-buffer htmlbuf
))))
1598 (defun org-html-htmlize-generate-css ()
1599 "Create the CSS for all font definitions in the current Emacs session.
1600 Use this to create face definitions in your CSS style file that can then
1601 be used by code snippets transformed by htmlize.
1602 This command just produces a buffer that contains class definitions for all
1603 faces used in the current Emacs session. You can copy and paste the ones you
1604 need into your CSS file.
1606 If you then set `org-html-htmlize-output-type' to `css', calls
1607 to the function `org-html-htmlize-region-for-paste' will
1608 produce code that uses these same face definitions."
1611 (and (get-buffer "*html*") (kill-buffer "*html*"))
1613 (let ((fl (face-list))
1614 (htmlize-css-name-prefix "org-")
1615 (htmlize-output-type 'css
)
1617 (while (setq f
(pop fl
)
1618 i
(and f
(face-attribute f
:inherit
)))
1619 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1620 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1621 (htmlize-region (point-min) (point-max))))
1622 (org-pop-to-buffer-same-window "*html*")
1623 (goto-char (point-min))
1624 (if (re-search-forward "<style" nil t
)
1625 (delete-region (point-min) (match-beginning 0)))
1626 (if (re-search-forward "</style>" nil t
)
1627 (delete-region (1+ (match-end 0)) (point-max)))
1628 (beginning-of-line 1)
1629 (if (looking-at " +") (replace-match ""))
1630 (goto-char (point-min)))
1632 (defun org-html--make-string (n string
)
1633 "Build a string by concatenating N times STRING."
1634 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1636 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1637 "Turn todo keyword KWD into a valid class name.
1638 Replaces invalid characters with \"_\"."
1640 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1641 (setq kwd
(replace-match "_" t t kwd
))))
1644 (defun org-html-footnote-section (info)
1645 "Format the footnote section.
1646 INFO is a plist used as a communication channel."
1647 (let* ((fn-alist (org-export-collect-footnote-definitions info
))
1649 (loop for
(n type raw
) in fn-alist collect
1650 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1651 (org-trim (org-export-data raw info
))
1652 (format "<p class=\"footpara\">%s</p>"
1653 (org-trim (org-export-data raw info
))))))))
1656 (plist-get info
:html-footnotes-section
)
1657 (org-html--translate "Footnotes" info
)
1662 (let ((n (car fn
)) (def (cdr fn
)))
1664 "<div class=\"footdef\">%s %s</div>\n"
1666 (plist-get info
:html-footnote-format
)
1670 (format " class=\"footnum\" href=\"#fnr.%d\"" n
)
1679 (defun org-html--build-meta-info (info)
1680 "Return meta tags for exported document.
1681 INFO is a plist used as a communication channel."
1682 (let ((protect-string
1684 (replace-regexp-in-string
1685 "\"" """ (org-html-encode-plain-text str
))))
1686 (title (org-export-data (plist-get info
:title
) info
))
1687 (author (and (plist-get info
:with-author
)
1688 (let ((auth (plist-get info
:author
)))
1690 ;; Return raw Org syntax, skipping non
1691 ;; exportable objects.
1692 (org-element-interpret-data
1693 (org-element-map auth
1694 (cons 'plain-text org-element-all-objects
)
1695 'identity info
))))))
1696 (description (plist-get info
:description
))
1697 (keywords (plist-get info
:keywords
))
1698 (charset (or (and org-html-coding-system
1699 (fboundp 'coding-system-get
)
1700 (coding-system-get org-html-coding-system
1704 (format "<title>%s</title>\n" title
)
1705 (when (plist-get info
:time-stamp-file
)
1708 (plist-get info
:html-metadata-timestamp-format
)
1711 (if (org-html-html5-p info
)
1712 (org-html-close-tag "meta" " charset=\"%s\"" info
)
1714 "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1717 (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info
)
1719 (and (org-string-nw-p author
)
1721 (org-html-close-tag "meta"
1722 (format " name=\"author\" content=\"%s\""
1723 (funcall protect-string author
))
1726 (and (org-string-nw-p description
)
1728 (org-html-close-tag "meta"
1729 (format " name=\"description\" content=\"%s\"\n"
1730 (funcall protect-string description
))
1733 (and (org-string-nw-p keywords
)
1735 (org-html-close-tag "meta"
1736 (format " name=\"keywords\" content=\"%s\""
1737 (funcall protect-string keywords
))
1740 (let ((viewport-options
1741 (org-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell
)))
1742 (plist-get info
:html-viewport
))))
1743 (and viewport-options
1747 (format " name=\"viewport\" content=\"%s\""
1749 (lambda (elm) (format "%s=%s" (car elm
) (cadr elm
)))
1750 viewport-options
", "))
1754 (defun org-html--build-head (info)
1755 "Return information for the <head>..</head> of the HTML output.
1756 INFO is a plist used as a communication channel."
1757 (org-element-normalize-string
1759 (when (plist-get info
:html-head-include-default-style
)
1760 (org-element-normalize-string org-html-style-default
))
1761 (org-element-normalize-string (plist-get info
:html-head
))
1762 (org-element-normalize-string (plist-get info
:html-head-extra
))
1763 (when (and (plist-get info
:html-htmlized-css-url
)
1764 (eq org-html-htmlize-output-type
'css
))
1765 (org-html-close-tag "link"
1766 (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1767 (plist-get info
:html-htmlized-css-url
))
1769 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1771 (defun org-html--build-mathjax-config (info)
1772 "Insert the user setup into the mathjax template.
1773 INFO is a plist used as a communication channel."
1774 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1775 (org-element-map (plist-get info
:parse-tree
)
1776 '(latex-fragment latex-environment
) 'identity info t
))
1777 (let ((template (plist-get info
:html-mathjax-template
))
1778 (options (plist-get info
:html-mathjax-options
))
1779 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1783 (setq name
(car e
) val
(nth 1 e
))
1784 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1785 (setq val
(car (read-from-string
1786 (substring in-buffer
(match-end 0))))))
1787 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1788 (while (string-match (concat "%" (upcase (symbol-name name
))) template
)
1789 (setq template
(replace-match val t t template
))))
1791 ;; Return the modified template.
1792 (org-element-normalize-string template
))))
1794 (defun org-html-format-spec (info)
1795 "Return format specification for elements that can be
1796 used in the preamble or postamble."
1797 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1798 (?s .
,(org-export-data (plist-get info
:subtitle
) info
))
1799 (?d .
,(org-export-data (org-export-get-date info
) info
))
1800 (?T .
,(format-time-string
1801 (plist-get info
:html-metadata-timestamp-format
)))
1802 (?a .
,(org-export-data (plist-get info
:author
) info
))
1805 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1806 (split-string (plist-get info
:email
) ",+ *")
1808 (?c .
,(plist-get info
:creator
))
1809 (?C .
,(let ((file (plist-get info
:input-file
)))
1811 (plist-get info
:html-metadata-timestamp-format
)
1812 (if file
(nth 5 (file-attributes file
)) (current-time)))))
1813 (?v .
,(or (plist-get info
:html-validation-link
) ""))))
1815 (defun org-html--build-pre/postamble
(type info
)
1816 "Return document preamble or postamble as a string, or nil.
1817 TYPE is either 'preamble or 'postamble, INFO is a plist used as a
1818 communication channel."
1819 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1820 (spec (org-html-format-spec info
)))
1822 (let ((section-contents
1823 (if (functionp section
) (funcall section info
)
1825 ((stringp section
) (format-spec section spec
))
1827 (let ((date (cdr (assq ?d spec
)))
1828 (author (cdr (assq ?a spec
)))
1829 (email (cdr (assq ?e spec
)))
1830 (creator (cdr (assq ?c spec
)))
1831 (timestamp (cdr (assq ?T spec
)))
1832 (validation-link (cdr (assq ?v spec
))))
1834 (when (and (plist-get info
:with-date
)
1835 (org-string-nw-p date
))
1836 (format "<p class=\"date\">%s: %s</p>\n"
1837 (org-html--translate "Date" info
)
1839 (when (and (plist-get info
:with-author
)
1840 (org-string-nw-p author
))
1841 (format "<p class=\"author\">%s: %s</p>\n"
1842 (org-html--translate "Author" info
)
1844 (when (and (plist-get info
:with-email
)
1845 (org-string-nw-p email
))
1846 (format "<p class=\"email\">%s: %s</p>\n"
1847 (org-html--translate "Email" info
)
1849 (when (plist-get info
:time-stamp-file
)
1851 "<p class=\"date\">%s: %s</p>\n"
1852 (org-html--translate "Created" info
)
1854 (plist-get info
:html-metadata-timestamp-format
))))
1855 (when (plist-get info
:with-creator
)
1856 (format "<p class=\"creator\">%s</p>\n" creator
))
1857 (format "<p class=\"validation\">%s</p>\n"
1861 (plist-get info
:language
)
1863 (format "org-html-%s-format" type
)))))
1868 (intern (format "org-html-%s-format" type
))))))
1870 (let ((div (assq type
(plist-get info
:html-divs
))))
1871 (when (org-string-nw-p section-contents
)
1873 (format "<%s id=\"%s\" class=\"%s\">\n"
1876 org-html--pre
/postamble-class
)
1877 (org-element-normalize-string section-contents
)
1878 (format "</%s>\n" (nth 1 div
)))))))))
1880 (defun org-html-inner-template (contents info
)
1881 "Return body of document string after HTML conversion.
1882 CONTENTS is the transcoded contents string. INFO is a plist
1883 holding export options."
1885 ;; Table of contents.
1886 (let ((depth (plist-get info
:with-toc
)))
1887 (when depth
(org-html-toc depth info
)))
1888 ;; Document contents.
1890 ;; Footnotes section.
1891 (org-html-footnote-section info
)))
1893 (defun org-html-template (contents info
)
1894 "Return complete document string after HTML conversion.
1895 CONTENTS is the transcoded contents string. INFO is a plist
1896 holding export options."
1898 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1899 (let* ((xml-declaration (plist-get info
:html-xml-declaration
))
1900 (decl (or (and (stringp xml-declaration
) xml-declaration
)
1901 (cdr (assoc (plist-get info
:html-extension
)
1903 (cdr (assoc "html" xml-declaration
))
1905 (when (not (or (not decl
) (string= "" decl
)))
1908 (or (and org-html-coding-system
1909 (fboundp 'coding-system-get
)
1910 (coding-system-get org-html-coding-system
'mime-charset
))
1912 (org-html-doctype info
)
1915 (when (org-html-xhtml-p info
)
1917 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1918 (plist-get info
:language
) (plist-get info
:language
)))
1921 (org-html--build-meta-info info
)
1922 (org-html--build-head info
)
1923 (org-html--build-mathjax-config info
)
1926 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1927 (link-home (org-trim (plist-get info
:html-link-home
))))
1928 (unless (and (string= link-up
"") (string= link-home
""))
1929 (format (plist-get info
:html-home
/up-format
)
1930 (or link-up link-home
)
1931 (or link-home link-up
))))
1933 (org-html--build-pre/postamble
'preamble info
)
1934 ;; Document contents.
1935 (let ((div (assq 'content
(plist-get info
:html-divs
))))
1936 (format "<%s id=\"%s\">\n" (nth 1 div
) (nth 2 div
)))
1938 (when (plist-get info
:with-title
)
1939 (let ((title (plist-get info
:title
))
1940 (subtitle (plist-get info
:subtitle
)))
1943 (if (plist-get info
:html-html5-fancy
)
1944 "<header>\n<h1 class=\"title\">%s</h1>\n%s</header>"
1945 "<h1 class=\"title\">%s%s</h1>\n")
1946 (org-export-data title info
)
1949 (if (plist-get info
:html-html5-fancy
)
1950 "<p class=\"subtitle\">%s</p>\n"
1951 "\n<br>\n<span class=\"subtitle\">%s</span>\n")
1952 (org-export-data subtitle info
))
1955 (format "</%s>\n" (nth 1 (assq 'content
(plist-get info
:html-divs
))))
1957 (org-html--build-pre/postamble
'postamble info
)
1958 ;; Closing document.
1959 "</body>\n</html>"))
1961 (defun org-html--translate (s info
)
1962 "Translate string S according to specified language.
1963 INFO is a plist used as a communication channel."
1964 (org-export-translate s
:html info
))
1968 (defun org-html--anchor (id desc attributes info
)
1969 "Format a HTML anchor."
1970 (let* ((name (and (plist-get info
:html-allow-name-attribute-in-anchors
) id
))
1971 (attributes (concat (and id
(format " id=\"%s\"" id
))
1972 (and name
(format " name=\"%s\"" name
))
1974 (format "<a%s>%s</a>" attributes
(or desc
""))))
1978 (defun org-html--todo (todo info
)
1979 "Format TODO keywords into HTML."
1981 (format "<span class=\"%s %s%s\">%s</span>"
1982 (if (member todo org-done-keywords
) "done" "todo")
1983 (plist-get info
:html-todo-kwd-class-prefix
)
1984 (org-html-fix-class-name todo
)
1989 (defun org-html--priority (priority info
)
1990 "Format a priority into HTML.
1991 PRIORITY is the character code of the priority or nil. INFO is
1992 a plist containing export options."
1993 (and priority
(format "<span class=\"priority\">[%c]</span>" priority
)))
1997 (defun org-html--tags (tags info
)
1998 "Format TAGS into HTML.
1999 INFO is a plist containing export options."
2001 (format "<span class=\"tag\">%s</span>"
2004 (format "<span class=\"%s\">%s</span>"
2005 (concat (plist-get info
:html-tag-class-prefix
)
2006 (org-html-fix-class-name tag
))
2012 (defun org-html-fontify-code (code lang
)
2013 "Color CODE with htmlize library.
2014 CODE is a string representing the source code to colorize. LANG
2015 is the language used for CODE, as a string, or nil."
2018 ;; Case 1: No lang. Possibly an example block.
2020 ;; Simple transcoding.
2021 (org-html-encode-plain-text code
))
2022 ;; Case 2: No htmlize or an inferior version of htmlize
2023 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
2025 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
2026 ;; Simple transcoding.
2027 (org-html-encode-plain-text code
))
2028 ;; Case 3: plain text explicitly set
2029 ((not org-html-htmlize-output-type
)
2030 ;; Simple transcoding.
2031 (org-html-encode-plain-text code
))
2034 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
2035 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
2037 ;; Case 1: Language is not associated with any Emacs mode
2038 ((not (functionp lang-mode
))
2039 ;; Simple transcoding.
2040 (org-html-encode-plain-text code
))
2041 ;; Case 2: Default. Fontify code.
2044 (setq code
(with-temp-buffer
2045 ;; Switch to language-specific mode.
2047 ;; Disable fci-mode if present
2048 (when (and (fboundp 'fci-mode
)
2049 (require 'fill-column-indicator nil
'noerror
))
2054 ;; Remove formatting on newline characters.
2056 (let ((beg (point-min))
2059 (while (progn (end-of-line) (< (point) end
))
2060 (put-text-property (point) (1+ (point)) 'face nil
)
2063 (set-buffer-modified-p nil
)
2065 (org-html-htmlize-region-for-paste
2066 (point-min) (point-max))))
2067 ;; Strip any enclosing <pre></pre> tags.
2068 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
2069 (end (and beg
(string-match "</pre>\\'" code
))))
2070 (if (and beg end
) (substring code beg end
) code
)))))))))
2072 (defun org-html-do-format-code
2073 (code &optional lang refs retain-labels num-start
)
2074 "Format CODE string as source code.
2075 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
2076 respectively, the language of the source code, as a string, an
2077 alist between line numbers and references (as returned by
2078 `org-export-unravel-code'), a boolean specifying if labels should
2079 appear in the source code, and the number associated to the first
2081 (let* ((code-lines (org-split-string code
"\n"))
2082 (code-length (length code-lines
))
2086 (length (number-to-string (+ code-length num-start
))))))
2087 (code (org-html-fontify-code code lang
)))
2088 (org-export-format-code
2090 (lambda (loc line-num ref
)
2093 ;; Add line number, if needed.
2095 (format "<span class=\"linenr\">%s</span>"
2096 (format num-fmt line-num
)))
2097 ;; Transcoded src line.
2099 ;; Add label, if needed.
2100 (when (and ref retain-labels
) (format " (%s)" ref
))))
2101 ;; Mark transcoded line as an anchor, if needed.
2103 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
2107 (defun org-html-format-code (element info
)
2108 "Format contents of ELEMENT as source code.
2109 ELEMENT is either an example block or a src block. INFO is
2110 a plist used as a communication channel."
2111 (let* ((lang (org-element-property :language element
))
2112 ;; Extract code and references.
2113 (code-info (org-export-unravel-code element
))
2114 (code (car code-info
))
2115 (refs (cdr code-info
))
2116 ;; Does the src block contain labels?
2117 (retain-labels (org-element-property :retain-labels element
))
2118 ;; Does it have line numbers?
2119 (num-start (case (org-element-property :number-lines element
)
2120 (continued (org-export-get-loc element info
))
2122 (org-html-do-format-code code lang refs retain-labels num-start
)))
2125 ;;; Tables of Contents
2127 (defun org-html-toc (depth info
&optional scope
)
2128 "Build a table of contents.
2129 DEPTH is an integer specifying the depth of the table. INFO is
2130 a plist used as a communication channel. Optional argument SCOPE
2131 is an element defining the scope of the table. Return the table
2132 of contents as a string, or nil if it is empty."
2134 (mapcar (lambda (headline)
2135 (cons (org-html--format-toc-headline headline info
)
2136 (org-export-get-relative-level headline info
)))
2137 (org-export-collect-headlines info depth scope
))))
2139 (let ((toc (concat "<div id=\"text-table-of-contents\">"
2140 (org-html--toc-text toc-entries
)
2143 (let ((outer-tag (if (and (org-html-html5-p info
)
2144 (plist-get info
:html-html5-fancy
))
2147 (concat (format "<%s id=\"table-of-contents\">\n" outer-tag
)
2148 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2149 (format "<h%d>%s</h%d>\n"
2151 (org-html--translate "Table of Contents" info
)
2154 (format "</%s>\n" outer-tag
))))))))
2156 (defun org-html--toc-text (toc-entries)
2157 "Return innards of a table of contents, as a string.
2158 TOC-ENTRIES is an alist where key is an entry title, as a string,
2159 and value is its relative level, as an integer."
2160 (let* ((prev-level (1- (cdar toc-entries
)))
2161 (start-level prev-level
))
2165 (let ((headline (car entry
))
2166 (level (cdr entry
)))
2168 (let* ((cnt (- level prev-level
))
2169 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
2171 (setq prev-level level
)
2173 (org-html--make-string
2174 times
(cond ((> cnt
0) "\n<ul>\n<li>")
2175 ((< cnt
0) "</li>\n</ul>\n")))
2176 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
2179 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
2181 (defun org-html--format-toc-headline (headline info
)
2182 "Return an appropriate table of contents entry for HEADLINE.
2183 INFO is a plist used as a communication channel."
2184 (let* ((headline-number (org-export-get-headline-number headline info
))
2185 (todo (and (plist-get info
:with-todo-keywords
)
2186 (let ((todo (org-element-property :todo-keyword headline
)))
2187 (and todo
(org-export-data todo info
)))))
2188 (todo-type (and todo
(org-element-property :todo-type headline
)))
2189 (priority (and (plist-get info
:with-priority
)
2190 (org-element-property :priority headline
)))
2191 (text (org-export-data-with-backend
2192 (org-export-get-alt-title headline info
)
2193 ;; Create an anonymous back-end that will ignore any
2194 ;; footnote-reference, link, radio-target and target
2195 ;; in table of contents.
2196 (org-export-create-backend
2198 :transcoders
'((footnote-reference . ignore
)
2199 (link .
(lambda (object c i
) c
))
2200 (radio-target .
(lambda (object c i
) c
))
2203 (tags (and (eq (plist-get info
:with-tags
) t
)
2204 (org-export-get-tags headline info
))))
2205 (format "<a href=\"#%s\">%s</a>"
2207 (org-export-get-reference headline info
)
2210 (and (not (org-export-low-level-p headline info
))
2211 (org-export-numbered-headline-p headline info
)
2212 (concat (mapconcat #'number-to-string headline-number
".")
2214 (apply (plist-get info
:html-format-headline-function
)
2215 todo todo-type priority text tags
:section-number nil
)))))
2217 (defun org-html-list-of-listings (info)
2218 "Build a list of listings.
2219 INFO is a plist used as a communication channel. Return the list
2220 of listings as a string, or nil if it is empty."
2221 (let ((lol-entries (org-export-collect-listings info
)))
2223 (concat "<div id=\"list-of-listings\">\n"
2224 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2225 (format "<h%d>%s</h%d>\n"
2227 (org-html--translate "List of Listings" info
)
2229 "<div id=\"text-list-of-listings\">\n<ul>\n"
2231 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2232 (org-html--translate "Listing %d:" info
))))
2235 (let ((label (and (org-element-property :name entry
)
2236 (org-export-get-reference entry info
)))
2239 (or (org-export-get-caption entry t
)
2240 (org-export-get-caption entry
))
2245 (concat (format initial-fmt
(incf count
)) " " title
)
2246 (format "<a href=\"#%s\">%s %s</a>"
2248 (format initial-fmt
(incf count
))
2252 "\n</ul>\n</div>\n</div>"))))
2254 (defun org-html-list-of-tables (info)
2255 "Build a list of tables.
2256 INFO is a plist used as a communication channel. Return the list
2257 of tables as a string, or nil if it is empty."
2258 (let ((lol-entries (org-export-collect-tables info
)))
2260 (concat "<div id=\"list-of-tables\">\n"
2261 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2262 (format "<h%d>%s</h%d>\n"
2264 (org-html--translate "List of Tables" info
)
2266 "<div id=\"text-list-of-tables\">\n<ul>\n"
2268 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2269 (org-html--translate "Table %d:" info
))))
2272 (let ((label (and (org-element-property :name entry
)
2273 (org-export-get-reference entry info
)))
2276 (or (org-export-get-caption entry t
)
2277 (org-export-get-caption entry
))
2282 (concat (format initial-fmt
(incf count
)) " " title
)
2283 (format "<a href=\"#%s\">%s %s</a>"
2285 (format initial-fmt
(incf count
))
2289 "\n</ul>\n</div>\n</div>"))))
2292 ;;; Transcode Functions
2296 (defun org-html-bold (bold contents info
)
2297 "Transcode BOLD from Org to HTML.
2298 CONTENTS is the text with bold markup. INFO is a plist holding
2299 contextual information."
2300 (format (or (cdr (assq 'bold
(plist-get info
:html-text-markup-alist
))) "%s")
2305 (defun org-html-center-block (center-block contents info
)
2306 "Transcode a CENTER-BLOCK element from Org to HTML.
2307 CONTENTS holds the contents of the block. INFO is a plist
2308 holding contextual information."
2309 (format "<div class=\"center\">\n%s</div>" contents
))
2313 (defun org-html-clock (clock contents info
)
2314 "Transcode a CLOCK element from Org to HTML.
2315 CONTENTS is nil. INFO is a plist used as a communication
2318 <span class=\"timestamp-wrapper\">
2319 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2323 (org-timestamp-translate (org-element-property :value clock
))
2324 (let ((time (org-element-property :duration clock
)))
2325 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2329 (defun org-html-code (code contents info
)
2330 "Transcode CODE from Org to HTML.
2331 CONTENTS is nil. INFO is a plist holding contextual
2333 (format (or (cdr (assq 'code
(plist-get info
:html-text-markup-alist
))) "%s")
2334 (org-html-encode-plain-text (org-element-property :value code
))))
2338 (defun org-html-drawer (drawer contents info
)
2339 "Transcode a DRAWER element from Org to HTML.
2340 CONTENTS holds the contents of the block. INFO is a plist
2341 holding contextual information."
2342 (funcall (plist-get info
:html-format-drawer-function
)
2343 (org-element-property :drawer-name drawer
)
2348 (defun org-html-dynamic-block (dynamic-block contents info
)
2349 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2350 CONTENTS holds the contents of the block. INFO is a plist
2351 holding contextual information. See `org-export-data'."
2356 (defun org-html-entity (entity contents info
)
2357 "Transcode an ENTITY object from Org to HTML.
2358 CONTENTS are the definition itself. INFO is a plist holding
2359 contextual information."
2360 (org-element-property :html entity
))
2364 (defun org-html-example-block (example-block contents info
)
2365 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2366 CONTENTS is nil. INFO is a plist holding contextual
2368 (if (org-export-read-attribute :attr_html example-block
:textarea
)
2369 (org-html--textarea-block example-block
)
2370 (format "<pre class=\"example\">\n%s</pre>"
2371 (org-html-format-code example-block info
))))
2375 (defun org-html-export-snippet (export-snippet contents info
)
2376 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2377 CONTENTS is nil. INFO is a plist holding contextual
2379 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2380 (org-element-property :value export-snippet
)))
2384 (defun org-html-export-block (export-block contents info
)
2385 "Transcode a EXPORT-BLOCK element from Org to HTML.
2386 CONTENTS is nil. INFO is a plist holding contextual information."
2387 (when (string= (org-element-property :type export-block
) "HTML")
2388 (org-remove-indentation (org-element-property :value export-block
))))
2392 (defun org-html-fixed-width (fixed-width contents info
)
2393 "Transcode a FIXED-WIDTH element from Org to HTML.
2394 CONTENTS is nil. INFO is a plist holding contextual information."
2395 (format "<pre class=\"example\">\n%s</pre>"
2396 (org-html-do-format-code
2397 (org-remove-indentation
2398 (org-element-property :value fixed-width
)))))
2400 ;;;; Footnote Reference
2402 (defun org-html-footnote-reference (footnote-reference contents info
)
2403 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2404 CONTENTS is nil. INFO is a plist holding contextual information."
2406 ;; Insert separator between two footnotes in a row.
2407 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2408 (when (eq (org-element-type prev
) 'footnote-reference
)
2409 (plist-get info
:html-footnote-separator
)))
2410 (let* ((n (org-export-get-footnote-number footnote-reference info
))
2411 (id (format "fnr.%d%s"
2413 (if (org-export-footnote-first-reference-p
2414 footnote-reference info
)
2418 (plist-get info
:html-footnote-format
)
2420 id n
(format " class=\"footref\" href=\"#fn.%d\"" n
) info
)))))
2424 (defun org-html-headline (headline contents info
)
2425 "Transcode a HEADLINE element from Org to HTML.
2426 CONTENTS holds the contents of the headline. INFO is a plist
2427 holding contextual information."
2428 (unless (org-element-property :footnote-section-p headline
)
2429 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2430 (numbers (org-export-get-headline-number headline info
))
2431 (section-number (and numbers
2432 (mapconcat #'number-to-string numbers
"-")))
2433 (level (+ (org-export-get-relative-level headline info
)
2434 (1- (plist-get info
:html-toplevel-hlevel
))))
2435 (todo (and (plist-get info
:with-todo-keywords
)
2436 (let ((todo (org-element-property :todo-keyword headline
)))
2437 (and todo
(org-export-data todo info
)))))
2438 (todo-type (and todo
(org-element-property :todo-type headline
)))
2439 (priority (and (plist-get info
:with-priority
)
2440 (org-element-property :priority headline
)))
2441 (text (org-export-data (org-element-property :title headline
) info
))
2442 (tags (and (plist-get info
:with-tags
)
2443 (org-export-get-tags headline info
)))
2444 (full-text (funcall (plist-get info
:html-format-headline-function
)
2445 todo todo-type priority text tags info
))
2446 (contents (or contents
""))
2448 (list (org-element-property :CUSTOM_ID headline
)
2449 (org-export-get-reference headline info
)
2450 (org-element-property :ID headline
))))
2451 (preferred-id (car ids
))
2456 (if (org-uuidgen-p id
) (concat "ID-" id
) id
)
2459 (if (org-export-low-level-p headline info
)
2460 ;; This is a deep sub-tree: export it as a list item.
2461 (let* ((type (if numberedp
'ordered
'unordered
))
2463 (org-html-format-list-item
2464 contents type nil info nil
2465 (concat (org-html--anchor preferred-id nil nil info
)
2468 (concat (and (org-export-first-sibling-p headline info
)
2469 (org-html-begin-plain-list type
))
2471 (and (org-export-last-sibling-p headline info
)
2472 (org-html-end-plain-list type
))))
2473 (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2474 (first-content (car (org-element-contents headline
))))
2475 ;; Standard headline. Export it as a section.
2476 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2477 (org-html--container headline info
)
2478 (concat "outline-container-"
2479 (org-export-get-reference headline info
))
2480 (concat (format "outline-%d" level
)
2481 (and extra-class
" ")
2483 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2490 "<span class=\"section-number-%d\">%s</span> "
2492 (mapconcat #'number-to-string numbers
".")))
2495 ;; When there is no section, pretend there is an
2496 ;; empty one to get the correct <div
2497 ;; class="outline-...> which is needed by
2499 (if (eq (org-element-type first-content
) 'section
) contents
2500 (concat (org-html-section first-content
"" info
) contents
))
2501 (org-html--container headline info
)))))))
2503 (defun org-html-format-headline-default-function
2504 (todo todo-type priority text tags info
)
2505 "Default format function for a headline.
2506 See `org-html-format-headline-function' for details."
2507 (let ((todo (org-html--todo todo info
))
2508 (priority (org-html--priority priority info
))
2509 (tags (org-html--tags tags info
)))
2510 (concat todo
(and todo
" ")
2511 priority
(and priority
" ")
2513 (and tags
"   ") tags
)))
2515 (defun org-html--container (headline info
)
2516 (or (org-element-property :HTML_CONTAINER headline
)
2517 (if (= 1 (org-export-get-relative-level headline info
))
2518 (plist-get info
:html-container
)
2521 ;;;; Horizontal Rule
2523 (defun org-html-horizontal-rule (horizontal-rule contents info
)
2524 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2525 CONTENTS is nil. INFO is a plist holding contextual information."
2526 (org-html-close-tag "hr" nil info
))
2528 ;;;; Inline Src Block
2530 (defun org-html-inline-src-block (inline-src-block contents info
)
2531 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2532 CONTENTS holds the contents of the item. INFO is a plist holding
2533 contextual information."
2534 (let ((lang (org-element-property :language inline-src-block
))
2535 (code (org-html-format-code inline-src-block info
))
2537 (let ((lbl (and (org-element-property :name inline-src-block
)
2538 (org-export-get-reference inline-src-block info
))))
2539 (if (not lbl
) "" (format " id=\"%s\"" lbl
)))))
2540 (format "<code class=\"src src-%s\"%s>%s</code>" lang label code
)))
2544 (defun org-html-inlinetask (inlinetask contents info
)
2545 "Transcode an INLINETASK element from Org to HTML.
2546 CONTENTS holds the contents of the block. INFO is a plist
2547 holding contextual information."
2548 (let* ((todo (and (plist-get info
:with-todo-keywords
)
2549 (let ((todo (org-element-property :todo-keyword inlinetask
)))
2550 (and todo
(org-export-data todo info
)))))
2551 (todo-type (and todo
(org-element-property :todo-type inlinetask
)))
2552 (priority (and (plist-get info
:with-priority
)
2553 (org-element-property :priority inlinetask
)))
2554 (text (org-export-data (org-element-property :title inlinetask
) info
))
2555 (tags (and (plist-get info
:with-tags
)
2556 (org-export-get-tags inlinetask info
))))
2557 (funcall (plist-get info
:html-format-inlinetask-function
)
2558 todo todo-type priority text tags contents info
)))
2560 (defun org-html-format-inlinetask-default-function
2561 (todo todo-type priority text tags contents info
)
2562 "Default format function for a inlinetasks.
2563 See `org-html-format-inlinetask-function' for details."
2564 (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2565 (org-html-format-headline-default-function
2566 todo todo-type priority text tags info
)
2567 (org-html-close-tag "br" nil info
)
2572 (defun org-html-italic (italic contents info
)
2573 "Transcode ITALIC from Org to HTML.
2574 CONTENTS is the text with italic markup. INFO is a plist holding
2575 contextual information."
2577 (or (cdr (assq 'italic
(plist-get info
:html-text-markup-alist
))) "%s")
2582 (defun org-html-checkbox (checkbox info
)
2583 "Format CHECKBOX into HTML.
2584 INFO is a plist holding contextual information. See
2585 `org-html-checkbox-type' for customization options."
2587 (cdr (assq (plist-get info
:html-checkbox-type
)
2588 org-html-checkbox-types
)))))
2590 (defun org-html-format-list-item (contents type checkbox info
2591 &optional term-counter-id
2593 "Format a list item into HTML."
2594 (let ((class (if checkbox
2595 (format " class=\"%s\""
2596 (symbol-name checkbox
)) ""))
2597 (checkbox (concat (org-html-checkbox checkbox info
)
2598 (and checkbox
" ")))
2599 (br (org-html-close-tag "br" nil info
)))
2603 (let* ((counter term-counter-id
)
2604 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2606 (format "<li%s%s>" class extra
)
2607 (when headline
(concat headline br
)))))
2609 (let* ((id term-counter-id
)
2610 (extra (if id
(format " id=\"%s\"" id
) "")))
2612 (format "<li%s%s>" class extra
)
2613 (when headline
(concat headline br
)))))
2615 (let* ((term term-counter-id
))
2616 (setq term
(or term
"(no term)"))
2617 ;; Check-boxes in descriptive lists are associated to tag.
2618 (concat (format "<dt%s>%s</dt>"
2619 class
(concat checkbox term
))
2621 (unless (eq type
'descriptive
) checkbox
)
2622 (and contents
(org-trim contents
))
2626 (descriptive "</dd>")))))
2628 (defun org-html-item (item contents info
)
2629 "Transcode an ITEM element from Org to HTML.
2630 CONTENTS holds the contents of the item. INFO is a plist holding
2631 contextual information."
2632 (let* ((plain-list (org-export-get-parent item
))
2633 (type (org-element-property :type plain-list
))
2634 (counter (org-element-property :counter item
))
2635 (checkbox (org-element-property :checkbox item
))
2636 (tag (let ((tag (org-element-property :tag item
)))
2637 (and tag
(org-export-data tag info
)))))
2638 (org-html-format-list-item
2639 contents type checkbox info
(or tag counter
))))
2643 (defun org-html-keyword (keyword contents info
)
2644 "Transcode a KEYWORD element from Org to HTML.
2645 CONTENTS is nil. INFO is a plist holding contextual information."
2646 (let ((key (org-element-property :key keyword
))
2647 (value (org-element-property :value keyword
)))
2649 ((string= key
"HTML") value
)
2650 ((string= key
"TOC")
2651 (let ((case-fold-search t
))
2653 ((string-match "\\<headlines\\>" value
)
2654 (let ((depth (and (string-match "\\<[0-9]+\\>" value
)
2655 (string-to-number (match-string 0 value
))))
2656 (localp (org-string-match-p "\\<local\\>" value
)))
2657 (org-html-toc depth info
(and localp keyword
))))
2658 ((string= "listings" value
) (org-html-list-of-listings info
))
2659 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2661 ;;;; Latex Environment
2663 (defun org-html-format-latex (latex-frag processing-type info
)
2664 "Format a LaTeX fragment LATEX-FRAG into HTML.
2665 PROCESSING-TYPE designates the tool used for conversion. It is
2666 a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil
2667 and t. See `org-html-with-latex' for more information. INFO is
2668 a plist containing export properties."
2669 (let ((cache-relpath "") (cache-dir ""))
2670 (unless (eq processing-type
'mathjax
)
2671 (let ((bfn (or (buffer-file-name)
2673 (expand-file-name "latex" temporary-file-directory
))))
2675 (let ((header (plist-get info
:latex-header
)))
2678 (lambda (line) (concat "#+LATEX_HEADER: " line
))
2679 (org-split-string header
"\n")
2684 (file-name-sans-extension
2685 (file-name-nondirectory bfn
)))
2686 cache-dir
(file-name-directory bfn
))
2687 ;; Re-create LaTeX environment from original buffer in
2688 ;; temporary buffer so that dvipng/imagemagick can properly
2689 ;; turn the fragment into an image.
2690 (setq latex-frag
(concat latex-header latex-frag
))))
2693 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2694 nil processing-type
)
2697 (defun org-html-latex-environment (latex-environment contents info
)
2698 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2699 CONTENTS is nil. INFO is a plist holding contextual information."
2700 (let ((processing-type (plist-get info
:with-latex
))
2701 (latex-frag (org-remove-indentation
2702 (org-element-property :value latex-environment
)))
2703 (attributes (org-export-read-attribute :attr_html latex-environment
)))
2704 (case processing-type
2706 (org-html-format-latex latex-frag
'mathjax info
))
2707 ((dvipng imagemagick
)
2709 (org-html-format-latex latex-frag processing-type info
)))
2710 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2711 ;; Do not provide a caption or a name to be consistent with
2712 ;; `mathjax' handling.
2713 (org-html--wrap-image
2714 (org-html--format-image
2715 (match-string 1 formula-link
) attributes info
) info
))))
2720 (defun org-html-latex-fragment (latex-fragment contents info
)
2721 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2722 CONTENTS is nil. INFO is a plist holding contextual information."
2723 (let ((latex-frag (org-element-property :value latex-fragment
))
2724 (processing-type (plist-get info
:with-latex
)))
2725 (case processing-type
2727 (org-html-format-latex latex-frag
'mathjax info
))
2728 ((dvipng imagemagick
)
2730 (org-html-format-latex latex-frag processing-type info
)))
2731 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2732 (org-html--format-image (match-string 1 formula-link
) nil info
))))
2737 (defun org-html-line-break (line-break contents info
)
2738 "Transcode a LINE-BREAK object from Org to HTML.
2739 CONTENTS is nil. INFO is a plist holding contextual information."
2740 (concat (org-html-close-tag "br" nil info
) "\n"))
2744 (defun org-html-inline-image-p (link info
)
2745 "Non-nil when LINK is meant to appear as an image.
2746 INFO is a plist used as a communication channel. LINK is an
2747 inline image when it has no description and targets an image
2748 file (see `org-html-inline-image-rules' for more information), or
2749 if its description is a single link targeting an image file."
2750 (if (not (org-element-contents link
))
2751 (org-export-inline-image-p
2752 link
(plist-get info
:html-inline-image-rules
))
2754 (let ((link-count 0))
2755 (org-element-map (org-element-contents link
)
2756 (cons 'plain-text org-element-all-objects
)
2758 (case (org-element-type obj
)
2759 (plain-text (org-string-nw-p obj
))
2760 (link (if (= link-count
1) t
2762 (not (org-export-inline-image-p
2763 obj
(plist-get info
:html-inline-image-rules
)))))
2767 (defvar org-html-standalone-image-predicate
)
2768 (defun org-html-standalone-image-p (element info
)
2769 "Non-nil if ELEMENT is a standalone image.
2771 INFO is a plist holding contextual information.
2773 An element or object is a standalone image when
2775 - its type is `paragraph' and its sole content, save for white
2776 spaces, is a link that qualifies as an inline image;
2778 - its type is `link' and its containing paragraph has no other
2779 content save white spaces.
2781 Bind `org-html-standalone-image-predicate' to constrain paragraph
2782 further. For example, to check for only captioned standalone
2785 \(lambda (paragraph) (org-element-property :caption paragraph))"
2786 (let ((paragraph (case (org-element-type element
)
2788 (link (org-export-get-parent element
)))))
2789 (and (eq (org-element-type paragraph
) 'paragraph
)
2790 (or (not (fboundp 'org-html-standalone-image-predicate
))
2791 (funcall org-html-standalone-image-predicate paragraph
))
2793 (let ((link-count 0))
2794 (org-element-map (org-element-contents paragraph
)
2795 (cons 'plain-text org-element-all-objects
)
2797 (when (case (org-element-type obj
)
2798 (plain-text (org-string-nw-p obj
))
2799 (link (or (> (incf link-count
) 1)
2800 (not (org-html-inline-image-p obj info
))))
2804 (= link-count
1))))))
2806 (defun org-html-link (link desc info
)
2807 "Transcode a LINK object from Org to HTML.
2809 DESC is the description part of the link, or the empty string.
2810 INFO is a plist holding contextual information. See
2812 (let* ((home (when (plist-get info
:html-link-home
)
2813 (org-trim (plist-get info
:html-link-home
))))
2814 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2815 (link-org-files-as-html-maybe
2817 (lambda (raw-path info
)
2818 "Treat links to `file.org' as links to `file.html', if needed.
2819 See `org-html-link-org-files-as-html'."
2821 ((and (plist-get info
:html-link-org-files-as-html
)
2823 (downcase (file-name-extension raw-path
"."))))
2824 (concat (file-name-sans-extension raw-path
) "."
2825 (plist-get info
:html-extension
)))
2827 (type (org-element-property :type link
))
2828 (raw-path (org-element-property :path link
))
2829 ;; Ensure DESC really exists, or set it to nil.
2830 (desc (org-string-nw-p desc
))
2833 ((member type
'("http" "https" "ftp" "mailto"))
2834 (org-html-encode-plain-text
2835 (org-link-escape-browser
2836 (org-link-unescape (concat type
":" raw-path
)))))
2837 ((string= type
"file")
2838 ;; Treat links to ".org" files as ".html", if needed.
2840 (funcall link-org-files-as-html-maybe raw-path info
))
2841 ;; If file path is absolute, prepend it with protocol
2842 ;; component - "file://".
2844 ((file-name-absolute-p raw-path
)
2845 (setq raw-path
(org-export-file-uri raw-path
)))
2846 ((and home use-abs-url
)
2847 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2848 ;; Add search option, if any. A search option can be
2849 ;; relative to a custom-id, a headline title a name,
2850 ;; a target or a radio-target.
2851 (let ((option (org-element-property :search-option link
)))
2852 (if (not option
) raw-path
2855 (org-publish-resolve-external-link
2857 (org-element-property :path link
))))))
2859 ;; Extract attributes from parent's paragraph. HACK: Only do
2860 ;; this for the first link in parent (inner image link for
2861 ;; inline images). This is needed as long as attributes
2862 ;; cannot be set on a per link basis.
2864 (let* ((parent (org-export-get-parent-element link
))
2865 (link (let ((container (org-export-get-parent link
)))
2866 (if (and (eq (org-element-type container
) 'link
)
2867 (org-html-inline-image-p link info
))
2870 (and (eq (org-element-map parent
'link
'identity info t
) link
)
2871 (org-export-read-attribute :attr_html parent
))))
2873 (let ((attr (org-html--make-attribute-string attributes-plist
)))
2874 (if (org-string-nw-p attr
) (concat " " attr
) ""))))
2876 ;; Link type is handled by a special function.
2877 ((org-export-custom-protocol-maybe link desc
'html
))
2879 ((and (plist-get info
:html-inline-images
)
2880 (org-export-inline-image-p
2881 link
(plist-get info
:html-inline-image-rules
)))
2882 (org-html--format-image path attributes-plist info
))
2883 ;; Radio target: Transcode target's contents and use them as
2884 ;; link's description.
2885 ((string= type
"radio")
2886 (let ((destination (org-export-resolve-radio-link link info
)))
2887 (if (not destination
) desc
2888 (format "<a href=\"#%s\"%s>%s</a>"
2889 (org-export-get-reference destination info
)
2892 ;; Links pointing to a headline: Find destination and build
2893 ;; appropriate referencing command.
2894 ((member type
'("custom-id" "fuzzy" "id"))
2895 (let ((destination (if (string= type
"fuzzy")
2896 (org-export-resolve-fuzzy-link link info
)
2897 (org-export-resolve-id-link link info
))))
2898 (case (org-element-type destination
)
2899 ;; ID link points to an external file.
2901 (let ((fragment (concat "ID-" path
))
2902 ;; Treat links to ".org" files as ".html", if needed.
2903 (path (funcall link-org-files-as-html-maybe
2905 (format "<a href=\"%s#%s\"%s>%s</a>"
2906 path fragment attributes
(or desc destination
))))
2907 ;; Fuzzy link points nowhere.
2912 (org-element-property :raw-link link
) info
))))
2913 ;; Link points to a headline.
2915 (let ((href (org-export-get-reference destination info
))
2916 ;; What description to use?
2918 ;; Case 1: Headline is numbered and LINK has no
2919 ;; description. Display section number.
2920 (if (and (org-export-numbered-headline-p destination info
)
2922 (mapconcat #'number-to-string
2923 (org-export-get-headline-number
2924 destination info
) ".")
2925 ;; Case 2: Either the headline is un-numbered or
2926 ;; LINK has a custom description. Display LINK's
2927 ;; description or headline's title.
2930 (org-element-property :title destination
) info
)))))
2931 (format "<a href=\"#%s\"%s>%s</a>" href attributes desc
)))
2932 ;; Fuzzy link points to a target or an element.
2934 (let* ((ref (org-export-get-reference destination info
))
2935 (org-html-standalone-image-predicate
2936 #'org-html--has-caption-p
)
2939 ((org-html-standalone-image-p destination info
)
2940 (org-export-get-ordinal
2941 (org-element-map destination
'link
2943 info
'link
'org-html-standalone-image-p
))
2944 (t (org-export-get-ordinal
2945 destination info nil
'org-html--has-caption-p
))))
2947 ((not number
) "No description for this link")
2948 ((numberp number
) (number-to-string number
))
2949 (t (mapconcat #'number-to-string number
".")))))
2950 (format "<a href=\"#%s\"%s>%s</a>" ref attributes desc
))))))
2951 ;; Coderef: replace link with the reference name or the
2952 ;; equivalent line number.
2953 ((string= type
"coderef")
2954 (let ((fragment (concat "coderef-" path
)))
2955 (format "<a href=\"#%s\"%s%s>%s</a>"
2958 (format (concat "class=\"coderef\""
2959 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2960 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2963 (format (org-export-get-coderef-format path desc
)
2964 (org-export-resolve-coderef path info
)))))
2965 ;; External link with a description part.
2966 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2967 ;; External link without a description part.
2968 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2969 ;; No path, only description. Try to do something useful.
2970 (t (format "<i>%s</i>" desc
)))))
2974 (defun org-html-node-property (node-property contents info
)
2975 "Transcode a NODE-PROPERTY element from Org to HTML.
2976 CONTENTS is nil. INFO is a plist holding contextual
2979 (org-element-property :key node-property
)
2980 (let ((value (org-element-property :value node-property
)))
2981 (if value
(concat " " value
) ""))))
2985 (defun org-html-paragraph (paragraph contents info
)
2986 "Transcode a PARAGRAPH element from Org to HTML.
2987 CONTENTS is the contents of the paragraph, as a string. INFO is
2988 the plist used as a communication channel."
2989 (let* ((parent (org-export-get-parent paragraph
))
2990 (parent-type (org-element-type parent
))
2991 (style '((footnote-definition " class=\"footpara\"")
2992 (org-data " class=\"footpara\"")))
2993 (attributes (org-html--make-attribute-string
2994 (org-export-read-attribute :attr_html paragraph
)))
2995 (extra (or (cadr (assq parent-type style
)) "")))
2997 ((and (eq parent-type
'item
)
2998 (not (org-export-get-previous-element paragraph info
))
2999 (let ((followers (org-export-get-next-element paragraph info
2)))
3000 (and (not (cdr followers
))
3001 (memq (org-element-type (car followers
)) '(nil plain-list
)))))
3002 ;; First paragraph in an item has no tag if it is alone or
3003 ;; followed, at most, by a sub-list.
3005 ((org-html-standalone-image-p paragraph info
)
3006 ;; Standalone image.
3008 (let ((raw (org-export-data
3009 (org-export-get-caption paragraph
) info
))
3010 (org-html-standalone-image-predicate
3011 'org-html--has-caption-p
))
3012 (if (not (org-string-nw-p raw
)) raw
3014 "<span class=\"figure-number\">"
3015 (format (org-html--translate "Figure %d:" info
)
3016 (org-export-get-ordinal
3017 (org-element-map paragraph
'link
3019 info nil
'org-html-standalone-image-p
))
3021 (label (and (org-element-property :name paragraph
)
3022 (org-export-get-reference paragraph info
))))
3023 (org-html--wrap-image contents info caption label
)))
3024 ;; Regular paragraph.
3025 (t (format "<p%s%s>\n%s</p>"
3026 (if (org-string-nw-p attributes
)
3027 (concat " " attributes
) "")
3032 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
3033 ;; the correct value for the item counter
3034 (defun org-html-begin-plain-list (type &optional arg1
)
3035 "Insert the beginning of the HTML list depending on TYPE.
3036 When ARG1 is a string, use it as the start parameter for ordered
3040 (format "<ol class=\"org-ol\"%s>"
3041 (if arg1
(format " start=\"%d\"" arg1
) "")))
3042 (unordered "<ul class=\"org-ul\">")
3043 (descriptive "<dl class=\"org-dl\">")))
3045 (defun org-html-end-plain-list (type)
3046 "Insert the end of the HTML list depending on TYPE."
3050 (descriptive "</dl>")))
3052 (defun org-html-plain-list (plain-list contents info
)
3053 "Transcode a PLAIN-LIST element from Org to HTML.
3054 CONTENTS is the contents of the list. INFO is a plist holding
3055 contextual information."
3056 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
3057 (type (org-element-property :type plain-list
)))
3059 (org-html-begin-plain-list type
)
3060 contents
(org-html-end-plain-list type
))))
3064 (defun org-html-convert-special-strings (string)
3065 "Convert special characters in STRING to HTML."
3066 (let ((all org-html-special-string-regexps
)
3068 (while (setq a
(pop all
))
3069 (setq re
(car a
) rpl
(cdr a
) start
0)
3070 (while (string-match re string start
)
3071 (setq string
(replace-match rpl t nil string
))))
3074 (defun org-html-encode-plain-text (text)
3075 "Convert plain text characters from TEXT to HTML equivalent.
3076 Possible conversions are set in `org-html-protect-char-alist'."
3077 (dolist (pair org-html-protect-char-alist text
)
3078 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
))))
3080 (defun org-html-plain-text (text info
)
3081 "Transcode a TEXT string from Org to HTML.
3082 TEXT is the string to transcode. INFO is a plist holding
3083 contextual information."
3084 (let ((output text
))
3085 ;; Protect following characters: <, >, &.
3086 (setq output
(org-html-encode-plain-text output
))
3087 ;; Handle smart quotes. Be sure to provide original string since
3088 ;; OUTPUT may have been modified.
3089 (when (plist-get info
:with-smart-quotes
)
3090 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
3091 ;; Handle special strings.
3092 (when (plist-get info
:with-special-strings
)
3093 (setq output
(org-html-convert-special-strings output
)))
3094 ;; Handle break preservation if required.
3095 (when (plist-get info
:preserve-breaks
)
3097 (replace-regexp-in-string
3098 "\\(\\\\\\\\\\)?[ \t]*\n"
3099 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
3106 (defun org-html-planning (planning contents info
)
3107 "Transcode a PLANNING element from Org to HTML.
3108 CONTENTS is nil. INFO is a plist used as a communication
3110 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
3112 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
3117 (let ((closed (org-element-property :closed planning
)))
3119 (format span-fmt org-closed-string
3120 (org-timestamp-translate closed
))))
3121 (let ((deadline (org-element-property :deadline planning
)))
3123 (format span-fmt org-deadline-string
3124 (org-timestamp-translate deadline
))))
3125 (let ((scheduled (org-element-property :scheduled planning
)))
3127 (format span-fmt org-scheduled-string
3128 (org-timestamp-translate scheduled
))))))
3131 ;;;; Property Drawer
3133 (defun org-html-property-drawer (property-drawer contents info
)
3134 "Transcode a PROPERTY-DRAWER element from Org to HTML.
3135 CONTENTS holds the contents of the drawer. INFO is a plist
3136 holding contextual information."
3137 (and (org-string-nw-p contents
)
3138 (format "<pre class=\"example\">\n%s</pre>" contents
)))
3142 (defun org-html-quote-block (quote-block contents info
)
3143 "Transcode a QUOTE-BLOCK element from Org to HTML.
3144 CONTENTS holds the contents of the block. INFO is a plist
3145 holding contextual information."
3146 (format "<blockquote>\n%s</blockquote>" contents
))
3150 (defun org-html-section (section contents info
)
3151 "Transcode a SECTION element from Org to HTML.
3152 CONTENTS holds the contents of the section. INFO is a plist
3153 holding contextual information."
3154 (let ((parent (org-export-get-parent-headline section
)))
3155 ;; Before first headline: no container, just return CONTENTS.
3156 (if (not parent
) contents
3157 ;; Get div's class and id references.
3158 (let* ((class-num (+ (org-export-get-relative-level parent info
)
3159 (1- (plist-get info
:html-toplevel-hlevel
))))
3161 (and (org-export-numbered-headline-p parent info
)
3164 (org-export-get-headline-number parent info
) "-"))))
3165 ;; Build return value.
3166 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
3168 (or (org-element-property :CUSTOM_ID parent
)
3170 (org-export-get-reference parent info
))
3171 (or contents
""))))))
3175 (defun org-html-radio-target (radio-target text info
)
3176 "Transcode a RADIO-TARGET object from Org to HTML.
3177 TEXT is the text of the target. INFO is a plist holding
3178 contextual information."
3179 (let ((ref (org-export-get-reference radio-target info
)))
3180 (org-html--anchor ref text nil info
)))
3184 (defun org-html-special-block (special-block contents info
)
3185 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3186 CONTENTS holds the contents of the block. INFO is a plist
3187 holding contextual information."
3188 (let* ((block-type (org-element-property :type special-block
))
3189 (contents (or contents
""))
3190 (html5-fancy (and (org-html-html5-p info
)
3191 (plist-get info
:html-html5-fancy
)
3192 (member block-type org-html-html5-elements
)))
3193 (attributes (org-export-read-attribute :attr_html special-block
)))
3195 (let ((class (plist-get attributes
:class
)))
3196 (setq attributes
(plist-put attributes
:class
3197 (if class
(concat class
" " block-type
)
3199 (setq attributes
(org-html--make-attribute-string attributes
))
3200 (when (not (equal attributes
""))
3201 (setq attributes
(concat " " attributes
)))
3203 (format "<%s%s>\n%s</%s>" block-type attributes
3204 contents block-type
)
3205 (format "<div%s>\n%s\n</div>" attributes contents
))))
3209 (defun org-html-src-block (src-block contents info
)
3210 "Transcode a SRC-BLOCK element from Org to HTML.
3211 CONTENTS holds the contents of the item. INFO is a plist holding
3212 contextual information."
3213 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3214 (org-html--textarea-block src-block
)
3215 (let ((lang (org-element-property :language src-block
))
3216 (caption (org-export-get-caption src-block
))
3217 (code (org-html-format-code src-block info
))
3218 (label (let ((lbl (and (org-element-property :name src-block
)
3219 (org-export-get-reference src-block info
))))
3220 (if lbl
(format " id=\"%s\"" lbl
) ""))))
3221 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3223 "<div class=\"org-src-container\">\n%s%s\n</div>"
3224 (if (not caption
) ""
3225 (format "<label class=\"org-src-name\">%s</label>"
3226 (org-export-data caption info
)))
3227 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3229 ;;;; Statistics Cookie
3231 (defun org-html-statistics-cookie (statistics-cookie contents info
)
3232 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3233 CONTENTS is nil. INFO is a plist holding contextual information."
3234 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3235 (format "<code>%s</code>" cookie-value
)))
3239 (defun org-html-strike-through (strike-through contents info
)
3240 "Transcode STRIKE-THROUGH from Org to HTML.
3241 CONTENTS is the text with strike-through markup. INFO is a plist
3242 holding contextual information."
3244 (or (cdr (assq 'strike-through
(plist-get info
:html-text-markup-alist
)))
3250 (defun org-html-subscript (subscript contents info
)
3251 "Transcode a SUBSCRIPT object from Org to HTML.
3252 CONTENTS is the contents of the object. INFO is a plist holding
3253 contextual information."
3254 (format "<sub>%s</sub>" contents
))
3258 (defun org-html-superscript (superscript contents info
)
3259 "Transcode a SUPERSCRIPT object from Org to HTML.
3260 CONTENTS is the contents of the object. INFO is a plist holding
3261 contextual information."
3262 (format "<sup>%s</sup>" contents
))
3266 (defun org-html-table-cell (table-cell contents info
)
3267 "Transcode a TABLE-CELL element from Org to HTML.
3268 CONTENTS is nil. INFO is a plist used as a communication
3270 (let* ((table-row (org-export-get-parent table-cell
))
3271 (table (org-export-get-parent-table table-cell
))
3273 (if (not (plist-get info
:html-table-align-individual-fields
)) ""
3274 (format (if (and (boundp 'org-html-format-table-no-css
)
3275 org-html-format-table-no-css
)
3276 " align=\"%s\"" " class=\"org-%s\"")
3277 (org-export-table-cell-alignment table-cell info
)))))
3278 (when (or (not contents
) (string= "" (org-trim contents
)))
3279 (setq contents
" "))
3281 ((and (org-export-table-has-header-p table info
)
3282 (= 1 (org-export-table-row-group table-row info
)))
3283 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3284 (concat "\n" (format (car header-tags
) "col" cell-attrs
)
3286 (cdr header-tags
))))
3287 ((and (plist-get info
:html-table-use-header-tags-for-first-column
)
3288 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3289 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3290 (concat "\n" (format (car header-tags
) "row" cell-attrs
)
3292 (cdr header-tags
))))
3293 (t (let ((data-tags (plist-get info
:html-table-data-tags
)))
3294 (concat "\n" (format (car data-tags
) cell-attrs
)
3296 (cdr data-tags
)))))))
3300 (defun org-html-table-row (table-row contents info
)
3301 "Transcode a TABLE-ROW element from Org to HTML.
3302 CONTENTS is the contents of the row. INFO is a plist used as a
3303 communication channel."
3304 ;; Rules are ignored since table separators are deduced from
3305 ;; borders of the current row.
3306 (when (eq (org-element-property :type table-row
) 'standard
)
3307 (let* ((rowgroup-number (org-export-table-row-group table-row info
))
3308 (row-number (org-export-table-row-number table-row info
))
3310 (org-export-table-row-starts-rowgroup-p table-row info
))
3312 (org-export-table-row-ends-rowgroup-p table-row info
))
3313 ;; `top-row-p' and `end-rowgroup-p' are not used directly
3314 ;; but should be set so that `org-html-table-row-tags' can
3315 ;; use them (see the docstring of this variable.)
3316 (top-row-p (and (equal start-rowgroup-p
'(top))
3317 (equal end-rowgroup-p
'(below top
))))
3318 (bottom-row-p (and (equal start-rowgroup-p
'(above))
3319 (equal end-rowgroup-p
'(bottom above
))))
3322 ;; Case 1: Row belongs to second or subsequent rowgroups.
3323 ((not (= 1 rowgroup-number
))
3324 '("<tbody>" .
"\n</tbody>"))
3325 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
3326 ((org-export-table-has-header-p
3327 (org-export-get-parent-table table-row
) info
)
3328 '("<thead>" .
"\n</thead>"))
3329 ;; Case 2: Row is from first and only row group.
3330 (t '("<tbody>" .
"\n</tbody>")))))
3332 ;; Begin a rowgroup?
3333 (when start-rowgroup-p
(car rowgroup-tags
))
3335 (concat "\n" (eval (car (plist-get info
:html-table-row-tags
)))
3338 (eval (cdr (plist-get info
:html-table-row-tags
))))
3340 (when end-rowgroup-p
(cdr rowgroup-tags
))))))
3344 (defun org-html-table-first-row-data-cells (table info
)
3345 "Transcode the first row of TABLE.
3346 INFO is a plist used as a communication channel."
3348 (org-element-map table
'table-row
3350 (unless (eq (org-element-property :type row
) 'rule
) row
))
3352 (special-column-p (org-export-table-has-special-column-p table
)))
3353 (if (not special-column-p
) (org-element-contents table-row
)
3354 (cdr (org-element-contents table-row
)))))
3356 (defun org-html-table--table.el-table
(table info
)
3357 "Format table.el tables into HTML.
3358 INFO is a plist used as a communication channel."
3359 (when (eq (org-element-property :type table
) 'table.el
)
3361 (let ((outbuf (with-current-buffer
3362 (get-buffer-create "*org-export-table*")
3363 (erase-buffer) (current-buffer))))
3365 (insert (org-element-property :value table
))
3367 (re-search-forward "^[ \t]*|[^|]" nil t
)
3368 (table-generate-source 'html outbuf
))
3369 (with-current-buffer outbuf
3370 (prog1 (org-trim (buffer-string))
3373 (defun org-html-table (table contents info
)
3374 "Transcode a TABLE element from Org to HTML.
3375 CONTENTS is the contents of the table. INFO is a plist holding
3376 contextual information."
3377 (case (org-element-property :type table
)
3378 ;; Case 1: table.el table. Convert it using appropriate tools.
3379 (table.el
(org-html-table--table.el-table table info
))
3380 ;; Case 2: Standard table.
3382 (let* ((caption (org-export-get-caption table
))
3383 (number (org-export-get-ordinal
3384 table info nil
#'org-html--has-caption-p
))
3386 (org-html--make-attribute-string
3388 (and (org-element-property :name table
)
3389 (list :id
(org-export-get-reference table info
)))
3390 (and (not (org-html-html5-p info
))
3391 (plist-get info
:html-table-attributes
))
3392 (org-export-read-attribute :attr_html table
))))
3394 (if (and (boundp 'org-html-format-table-no-css
)
3395 org-html-format-table-no-css
)
3396 "align=\"%s\"" "class=\"org-%s\""))
3399 (lambda (table info
)
3401 (lambda (table-cell)
3402 (let ((alignment (org-export-table-cell-alignment
3405 ;; Begin a colgroup?
3406 (when (org-export-table-cell-starts-colgroup-p
3409 ;; Add a column. Also specify it's alignment.
3412 "col" (concat " " (format alignspec alignment
)) info
))
3414 (when (org-export-table-cell-ends-colgroup-p
3417 (org-html-table-first-row-data-cells table info
) "\n")))))
3418 (format "<table%s>\n%s\n%s\n%s</table>"
3419 (if (equal attributes
"") "" (concat " " attributes
))
3420 (if (not caption
) ""
3421 (format (if (plist-get info
:html-table-caption-above
)
3422 "<caption class=\"t-above\">%s</caption>"
3423 "<caption class=\"t-bottom\">%s</caption>")
3425 "<span class=\"table-number\">"
3426 (format (org-html--translate "Table %d:" info
) number
)
3427 "</span> " (org-export-data caption info
))))
3428 (funcall table-column-specs table info
)
3433 (defun org-html-target (target contents info
)
3434 "Transcode a TARGET object from Org to HTML.
3435 CONTENTS is nil. INFO is a plist holding contextual
3437 (let ((ref (org-export-get-reference target info
)))
3438 (org-html--anchor ref nil nil info
)))
3442 (defun org-html-timestamp (timestamp contents info
)
3443 "Transcode a TIMESTAMP object from Org to HTML.
3444 CONTENTS is nil. INFO is a plist holding contextual
3446 (let ((value (org-html-plain-text (org-timestamp-translate timestamp
) info
)))
3447 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3448 (replace-regexp-in-string "--" "–" value
))))
3452 (defun org-html-underline (underline contents info
)
3453 "Transcode UNDERLINE from Org to HTML.
3454 CONTENTS is the text with underline markup. INFO is a plist
3455 holding contextual information."
3456 (format (or (cdr (assq 'underline
(plist-get info
:html-text-markup-alist
)))
3462 (defun org-html-verbatim (verbatim contents info
)
3463 "Transcode VERBATIM from Org to HTML.
3464 CONTENTS is nil. INFO is a plist holding contextual
3466 (format (or (cdr (assq 'verbatim
(plist-get info
:html-text-markup-alist
))) "%s")
3467 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3471 (defun org-html-verse-block (verse-block contents info
)
3472 "Transcode a VERSE-BLOCK element from Org to HTML.
3473 CONTENTS is verse block contents. INFO is a plist holding
3474 contextual information."
3475 ;; Replace each newline character with line break. Also replace
3476 ;; each blank line with a line break.
3477 (setq contents
(replace-regexp-in-string
3478 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3479 (replace-regexp-in-string
3480 "\\(\\\\\\\\\\)?[ \t]*\n"
3481 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3482 ;; Replace each white space at beginning of a line with a
3483 ;; non-breaking space.
3484 (while (string-match "^[ \t]+" contents
)
3485 (let* ((num-ws (length (match-string 0 contents
)))
3486 (ws (let (out) (dotimes (i num-ws out
)
3487 (setq out
(concat out
" "))))))
3488 (setq contents
(replace-match ws nil t contents
))))
3489 (format "<p class=\"verse\">\n%s</p>" contents
))
3492 ;;; Filter Functions
3494 (defun org-html-final-function (contents backend info
)
3495 "Filter to indent the HTML and convert HTML entities."
3499 (if (plist-get info
:html-indent
)
3500 (indent-region (point-min) (point-max)))
3501 (when (plist-get info
:html-use-unicode-chars
)
3503 (mm-url-decode-entities))
3504 (buffer-substring-no-properties (point-min) (point-max))))
3507 ;;; End-user functions
3510 (defun org-html-export-as-html
3511 (&optional async subtreep visible-only body-only ext-plist
)
3512 "Export current buffer to an HTML buffer.
3514 If narrowing is active in the current buffer, only export its
3517 If a region is active, export that region.
3519 A non-nil optional argument ASYNC means the process should happen
3520 asynchronously. The resulting buffer should be accessible
3521 through the `org-export-stack' interface.
3523 When optional argument SUBTREEP is non-nil, export the sub-tree
3524 at point, extracting information from the headline properties
3527 When optional argument VISIBLE-ONLY is non-nil, don't export
3528 contents of hidden elements.
3530 When optional argument BODY-ONLY is non-nil, only write code
3531 between \"<body>\" and \"</body>\" tags.
3533 EXT-PLIST, when provided, is a property list with external
3534 parameters overriding Org default settings, but still inferior to
3535 file-local settings.
3537 Export is done in a buffer named \"*Org HTML Export*\", which
3538 will be displayed when `org-export-show-temporary-export-buffer'
3541 (org-export-to-buffer 'html
"*Org HTML Export*"
3542 async subtreep visible-only body-only ext-plist
3543 (lambda () (set-auto-mode t
))))
3546 (defun org-html-convert-region-to-html ()
3547 "Assume the current region has org-mode syntax, and convert it to HTML.
3548 This can be used in any buffer. For example, you can write an
3549 itemized list in org-mode syntax in an HTML buffer and use this
3550 command to convert it."
3552 (org-export-replace-region-by 'html
))
3555 (defun org-html-export-to-html
3556 (&optional async subtreep visible-only body-only ext-plist
)
3557 "Export current buffer to a HTML file.
3559 If narrowing is active in the current buffer, only export its
3562 If a region is active, export that region.
3564 A non-nil optional argument ASYNC means the process should happen
3565 asynchronously. The resulting file should be accessible through
3566 the `org-export-stack' interface.
3568 When optional argument SUBTREEP is non-nil, export the sub-tree
3569 at point, extracting information from the headline properties
3572 When optional argument VISIBLE-ONLY is non-nil, don't export
3573 contents of hidden elements.
3575 When optional argument BODY-ONLY is non-nil, only write code
3576 between \"<body>\" and \"</body>\" tags.
3578 EXT-PLIST, when provided, is a property list with external
3579 parameters overriding Org default settings, but still inferior to
3580 file-local settings.
3582 Return output file's name."
3584 (let* ((extension (concat "." (or (plist-get ext-plist
:html-extension
)
3587 (file (org-export-output-file-name extension subtreep
))
3588 (org-export-coding-system org-html-coding-system
))
3589 (org-export-to-file 'html file
3590 async subtreep visible-only body-only ext-plist
)))
3593 (defun org-html-publish-to-html (plist filename pub-dir
)
3594 "Publish an org file to HTML.
3596 FILENAME is the filename of the Org file to be published. PLIST
3597 is the property list for the given project. PUB-DIR is the
3598 publishing directory.
3600 Return output file name."
3601 (org-publish-org-to 'html filename
3602 (concat "." (or (plist-get plist
:html-extension
)
3611 ;; generated-autoload-file: "org-loaddefs.el"
3614 ;;; ox-html.el ends here