1 ;;; ox-html.el --- HTML Back-End for Org Export Engine -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2011-2017 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.
34 (require 'format-spec
)
40 ;;; Function Declarations
42 (declare-function org-id-find-id-file
"org-id" (id))
43 (declare-function htmlize-region
"ext:htmlize" (beg end
))
44 (declare-function mm-url-decode-entities
"mm-url" ())
46 (defvar htmlize-css-name-prefix
)
47 (defvar htmlize-output-type
)
48 (defvar htmlize-output-type
)
49 (defvar htmlize-css-name-prefix
)
53 (org-export-define-backend 'html
54 '((bold . org-html-bold
)
55 (center-block . org-html-center-block
)
56 (clock . org-html-clock
)
57 (code . org-html-code
)
58 (drawer . org-html-drawer
)
59 (dynamic-block . org-html-dynamic-block
)
60 (entity . org-html-entity
)
61 (example-block . org-html-example-block
)
62 (export-block . org-html-export-block
)
63 (export-snippet . org-html-export-snippet
)
64 (fixed-width . org-html-fixed-width
)
65 (footnote-definition . org-html-footnote-definition
)
66 (footnote-reference . org-html-footnote-reference
)
67 (headline . org-html-headline
)
68 (horizontal-rule . org-html-horizontal-rule
)
69 (inline-src-block . org-html-inline-src-block
)
70 (inlinetask . org-html-inlinetask
)
71 (inner-template . org-html-inner-template
)
72 (italic . org-html-italic
)
73 (item . org-html-item
)
74 (keyword . org-html-keyword
)
75 (latex-environment . org-html-latex-environment
)
76 (latex-fragment . org-html-latex-fragment
)
77 (line-break . org-html-line-break
)
78 (link . org-html-link
)
79 (node-property . org-html-node-property
)
80 (paragraph . org-html-paragraph
)
81 (plain-list . org-html-plain-list
)
82 (plain-text . org-html-plain-text
)
83 (planning . org-html-planning
)
84 (property-drawer . org-html-property-drawer
)
85 (quote-block . org-html-quote-block
)
86 (radio-target . org-html-radio-target
)
87 (section . org-html-section
)
88 (special-block . org-html-special-block
)
89 (src-block . org-html-src-block
)
90 (statistics-cookie . org-html-statistics-cookie
)
91 (strike-through . org-html-strike-through
)
92 (subscript . org-html-subscript
)
93 (superscript . org-html-superscript
)
94 (table . org-html-table
)
95 (table-cell . org-html-table-cell
)
96 (table-row . org-html-table-row
)
97 (target . org-html-target
)
98 (template . org-html-template
)
99 (timestamp . org-html-timestamp
)
100 (underline . org-html-underline
)
101 (verbatim . org-html-verbatim
)
102 (verse-block . org-html-verse-block
))
103 :filters-alist
'((:filter-options . org-html-infojs-install-script
)
104 (:filter-parse-tree . org-html-image-link-filter
)
105 (:filter-final-output . org-html-final-function
))
107 '(?h
"Export to HTML"
108 ((?H
"As HTML buffer" org-html-export-as-html
)
109 (?h
"As HTML file" org-html-export-to-html
)
110 (?o
"As HTML file and open"
112 (if a
(org-html-export-to-html t s v b
)
113 (org-open-file (org-html-export-to-html nil s v b
)))))))
115 '((:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
116 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
117 (:description
"DESCRIPTION" nil nil newline
)
118 (:keywords
"KEYWORDS" nil nil space
)
119 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
120 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
121 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
122 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
123 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
124 (:html-postamble nil
"html-postamble" org-html-postamble
)
125 (:html-preamble nil
"html-preamble" org-html-preamble
)
126 (:html-head
"HTML_HEAD" nil org-html-head newline
)
127 (:html-head-extra
"HTML_HEAD_EXTRA" nil org-html-head-extra newline
)
128 (:subtitle
"SUBTITLE" nil nil parse
)
129 (:html-head-include-default-style
130 nil
"html-style" org-html-head-include-default-style
)
131 (:html-head-include-scripts nil
"html-scripts" org-html-head-include-scripts
)
132 (:html-allow-name-attribute-in-anchors
133 nil nil org-html-allow-name-attribute-in-anchors
)
134 (:html-divs nil nil org-html-divs
)
135 (:html-checkbox-type nil nil org-html-checkbox-type
)
136 (:html-extension nil nil org-html-extension
)
137 (:html-footnote-format nil nil org-html-footnote-format
)
138 (:html-footnote-separator nil nil org-html-footnote-separator
)
139 (:html-footnotes-section nil nil org-html-footnotes-section
)
140 (:html-format-drawer-function nil nil org-html-format-drawer-function
)
141 (:html-format-headline-function nil nil org-html-format-headline-function
)
142 (:html-format-inlinetask-function
143 nil nil org-html-format-inlinetask-function
)
144 (:html-home
/up-format nil nil org-html-home
/up-format
)
145 (:html-indent nil nil org-html-indent
)
146 (:html-infojs-options nil nil org-html-infojs-options
)
147 (:html-infojs-template nil nil org-html-infojs-template
)
148 (:html-inline-image-rules nil nil org-html-inline-image-rules
)
149 (:html-link-org-files-as-html nil nil org-html-link-org-files-as-html
)
150 (:html-mathjax-options nil nil org-html-mathjax-options
)
151 (:html-mathjax-template nil nil org-html-mathjax-template
)
152 (:html-metadata-timestamp-format nil nil org-html-metadata-timestamp-format
)
153 (:html-postamble-format nil nil org-html-postamble-format
)
154 (:html-preamble-format nil nil org-html-preamble-format
)
155 (:html-table-align-individual-fields
156 nil nil org-html-table-align-individual-fields
)
157 (:html-table-caption-above nil nil org-html-table-caption-above
)
158 (:html-table-data-tags nil nil org-html-table-data-tags
)
159 (:html-table-header-tags nil nil org-html-table-header-tags
)
160 (:html-table-use-header-tags-for-first-column
161 nil nil org-html-table-use-header-tags-for-first-column
)
162 (:html-tag-class-prefix nil nil org-html-tag-class-prefix
)
163 (:html-text-markup-alist nil nil org-html-text-markup-alist
)
164 (:html-todo-kwd-class-prefix nil nil org-html-todo-kwd-class-prefix
)
165 (:html-toplevel-hlevel nil nil org-html-toplevel-hlevel
)
166 (:html-use-infojs nil nil org-html-use-infojs
)
167 (:html-validation-link nil nil org-html-validation-link
)
168 (:html-viewport nil nil org-html-viewport
)
169 (:html-inline-images nil nil org-html-inline-images
)
170 (:html-table-attributes nil nil org-html-table-default-attributes
)
171 (:html-table-row-open-tag nil nil org-html-table-row-open-tag
)
172 (:html-table-row-close-tag nil nil org-html-table-row-close-tag
)
173 (:html-xml-declaration nil nil org-html-xml-declaration
)
174 (:infojs-opt
"INFOJS_OPT" nil nil
)
175 ;; Redefine regular options.
176 (:creator
"CREATOR" nil org-html-creator-string
)
177 (:with-latex nil
"tex" org-html-with-latex
)
178 ;; Retrieve LaTeX header for fragments.
179 (:latex-header
"LATEX_HEADER" nil nil newline
)))
182 ;;; Internal Variables
184 (defvar org-html-format-table-no-css
)
185 (defvar htmlize-buffer-places
) ; from htmlize.el
187 (defvar org-html--pre
/postamble-class
"status"
188 "CSS class used for pre/postamble")
190 (defconst org-html-doctype-alist
191 '(("html4-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
192 \"http://www.w3.org/TR/html4/strict.dtd\">")
193 ("html4-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
194 \"http://www.w3.org/TR/html4/loose.dtd\">")
195 ("html4-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
196 \"http://www.w3.org/TR/html4/frameset.dtd\">")
198 ("xhtml-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
199 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
200 ("xhtml-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
201 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
202 ("xhtml-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
203 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
204 ("xhtml-11" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
205 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
207 ("html5" .
"<!DOCTYPE html>")
208 ("xhtml5" .
"<!DOCTYPE html>"))
209 "An alist mapping (x)html flavors to specific doctypes.")
211 (defconst org-html-html5-elements
212 '("article" "aside" "audio" "canvas" "details" "figcaption"
213 "figure" "footer" "header" "menu" "meter" "nav" "output"
214 "progress" "section" "video")
215 "New elements in html5.
217 For blocks that should contain headlines, use the HTML_CONTAINER
218 property on the headline itself.")
220 (defconst org-html-special-string-regexps
221 '(("\\\\-" .
"­") ; shy
222 ("---\\([^-]\\)" .
"—\\1") ; mdash
223 ("--\\([^-]\\)" .
"–\\1") ; ndash
224 ("\\.\\.\\." .
"…")) ; hellip
225 "Regular expressions for special string conversion.")
227 (defconst org-html-scripts
228 "<script type=\"text/javascript\">
230 @licstart The following is the entire license notice for the
231 JavaScript code in this tag.
233 Copyright (C) 2012-2013 Free Software Foundation, Inc.
235 The JavaScript code in this tag is free software: you can
236 redistribute it and/or modify it under the terms of the GNU
237 General Public License (GNU GPL) as published by the Free Software
238 Foundation, either version 3 of the License, or (at your option)
239 any later version. The code is distributed WITHOUT ANY WARRANTY;
240 without even the implied warranty of MERCHANTABILITY or FITNESS
241 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
243 As additional permission under GNU GPL version 3 section 7, you
244 may distribute non-source (e.g., minimized or compacted) forms of
245 that code without the copy of the GNU GPL normally required by
246 section 4, provided you include this license notice and a URL
247 through which recipients can access the Corresponding Source.
250 @licend The above is the entire license notice
251 for the JavaScript code in this tag.
253 <!--/*--><![CDATA[/*><!--*/
254 function CodeHighlightOn(elem, id)
256 var target = document.getElementById(id);
258 elem.cacheClassElem = elem.className;
259 elem.cacheClassTarget = target.className;
260 target.className = \"code-highlighted\";
261 elem.className = \"code-highlighted\";
264 function CodeHighlightOff(elem, id)
266 var target = document.getElementById(id);
267 if(elem.cacheClassElem)
268 elem.className = elem.cacheClassElem;
269 if(elem.cacheClassTarget)
270 target.className = elem.cacheClassTarget;
274 "Basic JavaScript that is needed by HTML files produced by Org mode.")
276 (defconst org-html-style-default
277 "<style type=\"text/css\">
278 <!--/*--><![CDATA[/*><!--*/
279 .title { text-align: center;
280 margin-bottom: .2em; }
281 .subtitle { text-align: center;
285 .todo { font-family: monospace; color: red; }
286 .done { font-family: monospace; color: green; }
287 .priority { font-family: monospace; color: orange; }
288 .tag { background-color: #eee; font-family: monospace;
289 padding: 2px; font-size: 80%; font-weight: normal; }
290 .timestamp { color: #bebebe; }
291 .timestamp-kwd { color: #5f9ea0; }
292 .org-right { margin-left: auto; margin-right: 0px; text-align: right; }
293 .org-left { margin-left: 0px; margin-right: auto; text-align: left; }
294 .org-center { margin-left: auto; margin-right: auto; text-align: center; }
295 .underline { text-decoration: underline; }
296 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
297 p.verse { margin-left: 3%; }
299 border: 1px solid #ccc;
300 box-shadow: 3px 3px 3px #eee;
302 font-family: monospace;
314 background-color: white;
318 border: 1px solid black;
320 pre.src:hover:before { display: inline;}
321 /* Languages per Org manual */
322 pre.src-asymptote:before { content: 'Asymptote'; }
323 pre.src-awk:before { content: 'Awk'; }
324 pre.src-C:before { content: 'C'; }
325 /* pre.src-C++ doesn't work in CSS */
326 pre.src-clojure:before { content: 'Clojure'; }
327 pre.src-css:before { content: 'CSS'; }
328 pre.src-D:before { content: 'D'; }
329 pre.src-ditaa:before { content: 'ditaa'; }
330 pre.src-dot:before { content: 'Graphviz'; }
331 pre.src-calc:before { content: 'Emacs Calc'; }
332 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
333 pre.src-fortran:before { content: 'Fortran'; }
334 pre.src-gnuplot:before { content: 'gnuplot'; }
335 pre.src-haskell:before { content: 'Haskell'; }
336 pre.src-java:before { content: 'Java'; }
337 pre.src-js:before { content: 'Javascript'; }
338 pre.src-latex:before { content: 'LaTeX'; }
339 pre.src-ledger:before { content: 'Ledger'; }
340 pre.src-lisp:before { content: 'Lisp'; }
341 pre.src-lilypond:before { content: 'Lilypond'; }
342 pre.src-lua:before { content: 'Lua'; }
343 pre.src-matlab:before { content: 'MATLAB'; }
344 pre.src-mscgen:before { content: 'Mscgen'; }
345 pre.src-ocaml:before { content: 'Objective Caml'; }
346 pre.src-octave:before { content: 'Octave'; }
347 pre.src-org:before { content: 'Org mode'; }
348 pre.src-oz:before { content: 'OZ'; }
349 pre.src-plantuml:before { content: 'Plantuml'; }
350 pre.src-processing:before { content: 'Processing.js'; }
351 pre.src-python:before { content: 'Python'; }
352 pre.src-R:before { content: 'R'; }
353 pre.src-ruby:before { content: 'Ruby'; }
354 pre.src-sass:before { content: 'Sass'; }
355 pre.src-scheme:before { content: 'Scheme'; }
356 pre.src-screen:before { content: 'Gnu Screen'; }
357 pre.src-sed:before { content: 'Sed'; }
358 pre.src-sh:before { content: 'shell'; }
359 pre.src-sql:before { content: 'SQL'; }
360 pre.src-sqlite:before { content: 'SQLite'; }
361 /* additional languages in org.el's org-babel-load-languages alist */
362 pre.src-forth:before { content: 'Forth'; }
363 pre.src-io:before { content: 'IO'; }
364 pre.src-J:before { content: 'J'; }
365 pre.src-makefile:before { content: 'Makefile'; }
366 pre.src-maxima:before { content: 'Maxima'; }
367 pre.src-perl:before { content: 'Perl'; }
368 pre.src-picolisp:before { content: 'Pico Lisp'; }
369 pre.src-scala:before { content: 'Scala'; }
370 pre.src-shell:before { content: 'Shell Script'; }
371 pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
372 /* additional language identifiers per \"defun org-babel-execute\"
374 pre.src-cpp:before { content: 'C++'; }
375 pre.src-abc:before { content: 'ABC'; }
376 pre.src-coq:before { content: 'Coq'; }
377 pre.src-groovy:before { content: 'Groovy'; }
378 /* additional language identifiers from org-babel-shell-names in
379 ob-shell.el: ob-shell is the only babel language using a lambda to put
380 the execution function name together. */
381 pre.src-bash:before { content: 'bash'; }
382 pre.src-csh:before { content: 'csh'; }
383 pre.src-ash:before { content: 'ash'; }
384 pre.src-dash:before { content: 'dash'; }
385 pre.src-ksh:before { content: 'ksh'; }
386 pre.src-mksh:before { content: 'mksh'; }
387 pre.src-posh:before { content: 'posh'; }
388 /* Additional Emacs modes also supported by the LaTeX listings package */
389 pre.src-ada:before { content: 'Ada'; }
390 pre.src-asm:before { content: 'Assembler'; }
391 pre.src-caml:before { content: 'Caml'; }
392 pre.src-delphi:before { content: 'Delphi'; }
393 pre.src-html:before { content: 'HTML'; }
394 pre.src-idl:before { content: 'IDL'; }
395 pre.src-mercury:before { content: 'Mercury'; }
396 pre.src-metapost:before { content: 'MetaPost'; }
397 pre.src-modula-2:before { content: 'Modula-2'; }
398 pre.src-pascal:before { content: 'Pascal'; }
399 pre.src-ps:before { content: 'PostScript'; }
400 pre.src-prolog:before { content: 'Prolog'; }
401 pre.src-simula:before { content: 'Simula'; }
402 pre.src-tcl:before { content: 'tcl'; }
403 pre.src-tex:before { content: 'TeX'; }
404 pre.src-plain-tex:before { content: 'Plain TeX'; }
405 pre.src-verilog:before { content: 'Verilog'; }
406 pre.src-vhdl:before { content: 'VHDL'; }
407 pre.src-xml:before { content: 'XML'; }
408 pre.src-nxml:before { content: 'XML'; }
409 /* add a generic configuration mode; LaTeX export needs an additional
410 (add-to-list 'org-latex-listings-langs '(conf \" \")) in .emacs */
411 pre.src-conf:before { content: 'Configuration File'; }
413 table { border-collapse:collapse; }
414 caption.t-above { caption-side: top; }
415 caption.t-bottom { caption-side: bottom; }
416 td, th { vertical-align:top; }
417 th.org-right { text-align: center; }
418 th.org-left { text-align: center; }
419 th.org-center { text-align: center; }
420 td.org-right { text-align: right; }
421 td.org-left { text-align: left; }
422 td.org-center { text-align: center; }
423 dt { font-weight: bold; }
424 .footpara { display: inline; }
425 .footdef { margin-bottom: 1em; }
426 .figure { padding: 1em; }
427 .figure p { text-align: center; }
430 border: 2px solid gray;
435 { text-align: right; font-size: 70%; white-space: nowrap; }
436 textarea { overflow-x: auto; }
437 .linenr { font-size: smaller }
438 .code-highlighted { background-color: #ffff00; }
439 .org-info-js_info-navigation { border-style: none; }
440 #org-info-js_console-label
441 { font-size: 10px; font-weight: bold; white-space: nowrap; }
442 .org-info-js_search-highlight
443 { background-color: #ffff00; color: #000000; font-weight: bold; }
444 .org-svg { width: 90%; }
447 "The default style specification for exported HTML files.
448 You can use `org-html-head' and `org-html-head-extra' to add to
449 this style. If you don't want to include this default style,
450 customize `org-html-head-include-default-style'.")
453 ;;; User Configuration Variables
455 (defgroup org-export-html nil
456 "Options for exporting Org mode files to HTML."
457 :tag
"Org Export HTML"
462 (defvar org-html-infojs-opts-table
463 '((path PATH
"http://orgmode.org/org-info.js")
467 (tdepth TOC_DEPTH
"max")
468 (sdepth SECTION_DEPTH
"max")
469 (mouse MOUSE_HINT
"underline")
470 (buttons VIEW_BUTTONS
"0")
472 (up LINK_UP
:html-link-up
)
473 (home LINK_HOME
:html-link-home
))
474 "JavaScript options, long form for script, default values.")
476 (defcustom org-html-use-infojs
'when-configured
477 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
478 This option can be nil or t to never or always use the script.
479 It can also be the symbol `when-configured', meaning that the
480 script will be linked into the export file if and only if there
481 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
482 `org-html-infojs-options'."
483 :group
'org-export-html
485 :package-version
'(Org .
"8.0")
487 (const :tag
"Never" nil
)
488 (const :tag
"When configured in buffer" when-configured
)
489 (const :tag
"Always" t
)))
491 (defcustom org-html-infojs-options
492 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
493 "Options settings for the INFOJS JavaScript.
494 Each of the options must have an entry in `org-html-infojs-opts-table'.
495 The value can either be a string that will be passed to the script, or
496 a property. This property is then assumed to be a property that is defined
497 by the Export/Publishing setup of Org.
498 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
499 means to use the maximum value consistent with other options."
500 :group
'org-export-html
502 :package-version
'(Org .
"8.0")
504 `(set :greedy t
:inline t
507 (list 'cons
(list 'const
(car x
))
509 (symbol :tag
"Publishing/Export property")
510 (string :tag
"Value"))))
511 org-html-infojs-opts-table
)))
513 (defcustom org-html-infojs-template
514 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
517 * @source: %SCRIPT_PATH
519 * @licstart The following is the entire license notice for the
520 * JavaScript code in %SCRIPT_PATH.
522 * Copyright (C) 2012-2013 Free Software Foundation, Inc.
525 * The JavaScript code in this tag is free software: you can
526 * redistribute it and/or modify it under the terms of the GNU
527 * General Public License (GNU GPL) as published by the Free Software
528 * Foundation, either version 3 of the License, or (at your option)
529 * any later version. The code is distributed WITHOUT ANY WARRANTY;
530 * without even the implied warranty of MERCHANTABILITY or FITNESS
531 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
533 * As additional permission under GNU GPL version 3 section 7, you
534 * may distribute non-source (e.g., minimized or compacted) forms of
535 * that code without the copy of the GNU GPL normally required by
536 * section 4, provided you include this license notice and a URL
537 * through which recipients can access the Corresponding Source.
539 * @licend The above is the entire license notice
540 * for the JavaScript code in %SCRIPT_PATH.
545 <script type=\"text/javascript\">
548 @licstart The following is the entire license notice for the
549 JavaScript code in this tag.
551 Copyright (C) 2012-2013 Free Software Foundation, Inc.
553 The JavaScript code in this tag is free software: you can
554 redistribute it and/or modify it under the terms of the GNU
555 General Public License (GNU GPL) as published by the Free Software
556 Foundation, either version 3 of the License, or (at your option)
557 any later version. The code is distributed WITHOUT ANY WARRANTY;
558 without even the implied warranty of MERCHANTABILITY or FITNESS
559 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
561 As additional permission under GNU GPL version 3 section 7, you
562 may distribute non-source (e.g., minimized or compacted) forms of
563 that code without the copy of the GNU GPL normally required by
564 section 4, provided you include this license notice and a URL
565 through which recipients can access the Corresponding Source.
568 @licend The above is the entire license notice
569 for the JavaScript code in this tag.
572 <!--/*--><![CDATA[/*><!--*/
574 org_html_manager.setup(); // activate after the parameters are set
577 "The template for the export style additions when org-info.js is used.
578 Option settings will replace the %MANAGER-OPTIONS cookie."
579 :group
'org-export-html
581 :package-version
'(Org .
"8.0")
584 (defun org-html-infojs-install-script (exp-plist _backend
)
585 "Install script in export options when appropriate.
586 EXP-PLIST is a plist containing export options. BACKEND is the
587 export back-end currently used."
588 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
589 (not (plist-get exp-plist
:html-use-infojs
))
590 (and (eq (plist-get exp-plist
:html-use-infojs
) 'when-configured
)
591 (let ((opt (plist-get exp-plist
:infojs-opt
)))
594 (string-match "\\<view:nil\\>" opt
)))))
595 (let* ((template (plist-get exp-plist
:html-infojs-template
))
596 (ptoc (plist-get exp-plist
:with-toc
))
597 (hlevels (plist-get exp-plist
:headline-levels
))
599 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
600 (options (plist-get exp-plist
:infojs-opt
))
601 (infojs-opt (plist-get exp-plist
:html-infojs-options
))
602 (table org-html-infojs-opts-table
)
604 (dolist (entry table
)
605 (let* ((opt (car entry
))
607 ;; Compute default values for script option OPT from
608 ;; `org-html-infojs-options' variable.
610 (let ((default (cdr (assq opt infojs-opt
))))
611 (if (and (symbolp default
) (not (memq default
'(t nil
))))
612 (plist-get exp-plist default
)
614 ;; Value set through INFOJS_OPT keyword has precedence
615 ;; over the default one.
616 (val (if (and options
617 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
619 (match-string 1 options
)
622 (`path
(setq template
623 (replace-regexp-in-string
624 "%SCRIPT_PATH" val template t t
)))
625 (`sdepth
(when (integerp (read val
))
626 (setq sdepth
(min (read val
) sdepth
))))
627 (`tdepth
(when (integerp (read val
))
628 (setq tdepth
(min (read val
) tdepth
))))
631 ((or (eq val t
) (equal val
"t")) "1")
632 ((or (eq val nil
) (equal val
"nil")) "0")
634 (t (format "%s" val
))))
635 (push (cons var val
) style
)))))
636 ;; Now we set the depth of the *generated* TOC to SDEPTH,
637 ;; because the toc will actually determine the splitting. How
638 ;; much of the toc will actually be displayed is governed by the
640 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
641 ;; The table of contents should not show more sections than we
643 (setq tdepth
(min tdepth sdepth
))
644 (push (cons "TOC_DEPTH" tdepth
) style
)
645 ;; Build style string.
646 (setq style
(mapconcat
648 (format "org_html_manager.set(\"%s\", \"%s\");"
651 (when (and style
(> (length style
) 0))
652 (and (string-match "%MANAGER_OPTIONS" template
)
653 (setq style
(replace-match style t t template
))
656 exp-plist
:html-head-extra
657 (concat (or (plist-get exp-plist
:html-head-extra
) "")
660 ;; This script absolutely needs the table of contents, so we
661 ;; change that setting.
662 (unless (plist-get exp-plist
:with-toc
)
663 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
664 ;; Return the modified property list.
669 (defcustom org-html-text-markup-alist
670 '((bold .
"<b>%s</b>")
671 (code .
"<code>%s</code>")
672 (italic .
"<i>%s</i>")
673 (strike-through .
"<del>%s</del>")
674 (underline .
"<span class=\"underline\">%s</span>")
675 (verbatim .
"<code>%s</code>"))
676 "Alist of HTML expressions to convert text markup.
678 The key must be a symbol among `bold', `code', `italic',
679 `strike-through', `underline' and `verbatim'. The value is
680 a formatting string to wrap fontified text with.
682 If no association can be found for a given markup, text will be
684 :group
'org-export-html
686 :package-version
'(Org .
"8.0")
687 :type
'(alist :key-type
(symbol :tag
"Markup type")
688 :value-type
(string :tag
"Format string"))
689 :options
'(bold code italic strike-through underline verbatim
))
691 (defcustom org-html-indent nil
692 "Non-nil means to indent the generated HTML.
693 Warning: non-nil may break indentation of source code blocks."
694 :group
'org-export-html
696 :package-version
'(Org .
"8.0")
701 (defcustom org-html-format-drawer-function
(lambda (_name contents
) contents
)
702 "Function called to format a drawer in HTML code.
704 The function must accept two parameters:
705 NAME the drawer name, like \"LOGBOOK\"
706 CONTENTS the contents of the drawer.
708 The function should return the string to be exported.
710 For example, the variable could be set to the following function
711 in order to mimic default behavior:
713 The default value simply returns the value of CONTENTS."
714 :group
'org-export-html
716 :package-version
'(Org .
"8.0")
721 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
722 <h2 class=\"footnotes\">%s: </h2>
723 <div id=\"text-footnotes\">
727 "Format for the footnotes section.
728 Should contain a two instances of %s. The first will be replaced with the
729 language-specific word for \"Footnotes\", the second one will be replaced
730 by the footnotes themselves."
731 :group
'org-export-html
734 (defcustom org-html-footnote-format
"<sup>%s</sup>"
735 "The format for the footnote reference.
736 %s will be replaced by the footnote reference itself."
737 :group
'org-export-html
740 (defcustom org-html-footnote-separator
"<sup>, </sup>"
741 "Text used to separate footnotes."
742 :group
'org-export-html
747 (defcustom org-html-toplevel-hlevel
2
748 "The <H> level for level 1 headings in HTML export.
749 This is also important for the classes that will be wrapped around headlines
750 and outline structure. If this variable is 1, the top-level headlines will
751 be <h1>, and the corresponding classes will be outline-1, section-number-1,
752 and outline-text-1. If this is 2, all of these will get a 2 instead.
753 The default for this variable is 2, because we use <h1> for formatting the
755 :group
'org-export-html
758 (defcustom org-html-format-headline-function
759 'org-html-format-headline-default-function
760 "Function to format headline text.
762 This function will be called with six arguments:
763 TODO the todo keyword (string or nil).
764 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
765 PRIORITY the priority of the headline (integer or nil)
766 TEXT the main headline text (string).
767 TAGS the tags (string or nil).
768 INFO the export options (plist).
770 The function result will be used in the section format string."
771 :group
'org-export-html
773 :package-version
'(Org .
"8.3")
778 (defcustom org-html-allow-name-attribute-in-anchors nil
779 "When nil, do not set \"name\" attribute in anchors.
780 By default, when appropriate, anchors are formatted with \"id\"
781 but without \"name\" attribute."
782 :group
'org-export-html
784 :package-version
'(Org .
"8.0")
789 (defcustom org-html-format-inlinetask-function
790 'org-html-format-inlinetask-default-function
791 "Function called to format an inlinetask in HTML code.
793 The function must accept seven parameters:
794 TODO the todo keyword, as a string
795 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
796 PRIORITY the inlinetask priority, as a string
797 NAME the inlinetask name, as a string.
798 TAGS the inlinetask tags, as a list of strings.
799 CONTENTS the contents of the inlinetask, as a string.
800 INFO the export options, as a plist
802 The function should return the string to be exported."
803 :group
'org-export-html
805 :package-version
'(Org .
"8.3")
810 (defcustom org-html-with-latex org-export-with-latex
811 "Non-nil means process LaTeX math snippets.
813 When set, the exporter will process LaTeX environments and
816 This option can also be set with the +OPTIONS line,
817 e.g. \"tex:mathjax\". Allowed values are:
819 nil Ignore math snippets.
820 `verbatim' Keep everything in verbatim
821 `mathjax', t Do MathJax preprocessing and arrange for MathJax.js to
823 SYMBOL Any symbol defined in `org-preview-latex-process-alist',
825 :group
'org-export-html
827 :package-version
'(Org .
"8.0")
829 (const :tag
"Do not process math in any way" nil
)
830 (const :tag
"Leave math verbatim" verbatim
)
831 (const :tag
"Use MathJax to display math" mathjax
)
832 (symbol :tag
"Convert to image to display math" :value dvipng
)))
834 ;;;; Links :: Generic
836 (defcustom org-html-link-org-files-as-html t
837 "Non-nil means make file links to `file.org' point to `file.html'.
838 When `org-mode' is exporting an `org-mode' file to HTML, links to
839 non-html files are directly put into a href tag in HTML.
840 However, links to other Org files (recognized by the extension
841 \".org\") should become links to the corresponding HTML
842 file, assuming that the linked `org-mode' file will also be
844 When nil, the links still point to the plain \".org\" file."
845 :group
'org-export-html
848 ;;;; Links :: Inline images
850 (defcustom org-html-inline-images t
851 "Non-nil means inline images into exported HTML pages.
852 This is done using an <img> tag. When nil, an anchor with href is used to
854 :group
'org-export-html
856 :package-version
'(Org .
"8.1")
859 (defcustom org-html-inline-image-rules
860 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
861 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
862 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
863 "Rules characterizing image files that can be inlined into HTML.
864 A rule consists in an association whose key is the type of link
865 to consider, and value is a regexp that will be matched against
867 :group
'org-export-html
869 :package-version
'(Org .
"8.0")
870 :type
'(alist :key-type
(string :tag
"Type")
871 :value-type
(regexp :tag
"Path")))
875 (defvar org-html-protect-char-alist
879 "Alist of characters to be converted by `org-html-encode-plain-text'.")
883 (defcustom org-html-htmlize-output-type
'inline-css
884 "Output type to be used by htmlize when formatting code snippets.
885 Choices are `css' to export the CSS selectors only,`inline-css'
886 to export the CSS attribute values inline in the HTML or `nil' to
887 export plain text. We use as default `inline-css', in order to
888 make the resulting HTML self-containing.
890 However, this will fail when using Emacs in batch mode for export, because
891 then no rich font definitions are in place. It will also not be good if
892 people with different Emacs setup contribute HTML files to a website,
893 because the fonts will represent the individual setups. In these cases,
894 it is much better to let Org/Htmlize assign classes only, and to use
895 a style file to define the look of these classes.
896 To get a start for your css file, start Emacs session and make sure that
897 all the faces you are interested in are defined, for example by loading files
898 in all modes you want. Then, use the command
899 `\\[org-html-htmlize-generate-css]' to extract class definitions."
900 :group
'org-export-html
901 :type
'(choice (const css
) (const inline-css
) (const nil
)))
903 (defcustom org-html-htmlize-font-prefix
"org-"
904 "The prefix for CSS class names for htmlize font specifications."
905 :group
'org-export-html
910 (defcustom org-html-table-default-attributes
911 '(:border
"2" :cellspacing
"0" :cellpadding
"6" :rules
"groups" :frame
"hsides")
912 "Default attributes and values which will be used in table tags.
913 This is a plist where attributes are symbols, starting with
914 colons, and values are strings.
916 When exporting to HTML5, these values will be disregarded."
917 :group
'org-export-html
919 :package-version
'(Org .
"8.0")
920 :type
'(plist :key-type
(symbol :tag
"Property")
921 :value-type
(string :tag
"Value")))
923 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
924 "The opening and ending tags for table header fields.
925 This is customizable so that alignment options can be specified.
926 The first %s will be filled with the scope of the field, either row or col.
927 The second %s will be replaced by a style entry to align the field.
928 See also the variable `org-html-table-use-header-tags-for-first-column'.
929 See also the variable `org-html-table-align-individual-fields'."
930 :group
'org-export-html
931 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
933 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
934 "The opening and ending tags for table data fields.
935 This is customizable so that alignment options can be specified.
936 The first %s will be filled with the scope of the field, either row or col.
937 The second %s will be replaced by a style entry to align the field.
938 See also the variable `org-html-table-align-individual-fields'."
939 :group
'org-export-html
940 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
942 (defcustom org-html-table-row-open-tag
"<tr>"
943 "The opening tag for table rows.
944 This is customizable so that alignment options can be specified.
945 Instead of strings, these can be a Lisp function that will be
946 evaluated for each row in order to construct the table row tags.
948 The function will be called with these arguments:
950 `number': row number (0 is the first row)
951 `group-number': group number of current row
952 `start-group?': non-nil means the row starts a group
953 `end-group?': non-nil means the row ends a group
954 `top?': non-nil means this is the top row
955 `bottom?': non-nil means this is the bottom row
959 (setq org-html-table-row-open-tag
960 (lambda (number group-number start-group? end-group-p top? bottom?)
961 (cond (top? \"<tr class=\\\"tr-top\\\">\")
962 (bottom? \"<tr class=\\\"tr-bottom\\\">\")
963 (t (if (= (mod number 2) 1)
964 \"<tr class=\\\"tr-odd\\\">\"
965 \"<tr class=\\\"tr-even\\\">\")))))
967 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
968 and the bottom row, and otherwise alternate between \"tr-odd\" and
969 \"tr-even\" for odd and even rows."
970 :group
'org-export-html
971 :type
'(choice :tag
"Opening tag"
972 (string :tag
"Specify")
975 (defcustom org-html-table-row-close-tag
"</tr>"
976 "The closing tag for table rows.
977 This is customizable so that alignment options can be specified.
978 Instead of strings, this can be a Lisp function that will be
979 evaluated for each row in order to construct the table row tags.
981 See documentation of `org-html-table-row-open-tag'."
982 :group
'org-export-html
983 :type
'(choice :tag
"Closing tag"
984 (string :tag
"Specify")
987 (defcustom org-html-table-align-individual-fields t
988 "Non-nil means attach style attributes for alignment to each table field.
989 When nil, alignment will only be specified in the column tags, but this
990 is ignored by some browsers (like Firefox, Safari). Opera does it right
992 :group
'org-export-html
995 (defcustom org-html-table-use-header-tags-for-first-column nil
996 "Non-nil means format column one in tables with header tags.
997 When nil, also column one will use data tags."
998 :group
'org-export-html
1001 (defcustom org-html-table-caption-above t
1002 "When non-nil, place caption string at the beginning of the table.
1003 Otherwise, place it near the end."
1004 :group
'org-export-html
1009 (defcustom org-html-tag-class-prefix
""
1010 "Prefix to class names for TODO keywords.
1011 Each tag gets a class given by the tag itself, with this prefix.
1012 The default prefix is empty because it is nice to just use the keyword
1013 as a class name. But if you get into conflicts with other, existing
1014 CSS classes, then this prefix can be very useful."
1015 :group
'org-export-html
1018 ;;;; Template :: Generic
1020 (defcustom org-html-extension
"html"
1021 "The extension for exported HTML files."
1022 :group
'org-export-html
1025 (defcustom org-html-xml-declaration
1026 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
1027 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
1028 "The extension for exported HTML files.
1029 %s will be replaced with the charset of the exported file.
1030 This may be a string, or an alist with export extensions
1031 and corresponding declarations.
1033 This declaration only applies when exporting to XHTML."
1034 :group
'org-export-html
1036 (string :tag
"Single declaration")
1037 (repeat :tag
"Dependent on extension"
1038 (cons (string :tag
"Extension")
1039 (string :tag
"Declaration")))))
1041 (defcustom org-html-coding-system
'utf-8
1042 "Coding system for HTML export.
1043 Use utf-8 as the default value."
1044 :group
'org-export-html
1046 :package-version
'(Org .
"8.0")
1047 :type
'coding-system
)
1049 (defcustom org-html-doctype
"xhtml-strict"
1050 "Document type definition to use for exported HTML files.
1051 Can be set with the in-buffer HTML_DOCTYPE property or for
1052 publishing, with :html-doctype."
1053 :group
'org-export-html
1055 :package-version
'(Org .
"8.0")
1058 (mapcar (lambda (x) `(const ,(car x
))) org-html-doctype-alist
)
1059 '((string :tag
"Custom doctype" ))))
1061 (defcustom org-html-html5-fancy nil
1062 "Non-nil means using new HTML5 elements.
1063 This variable is ignored for anything other than HTML5 export.
1065 For compatibility with Internet Explorer, it's probably a good
1066 idea to download some form of the html5shiv (for instance
1067 https://code.google.com/p/html5shiv/) and add it to your
1068 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
1069 versions 8 and below."
1070 :group
'org-export-html
1072 :package-version
'(Org .
"8.0")
1075 (defcustom org-html-container-element
"div"
1076 "HTML element to use for wrapping top level sections.
1077 Can be set with the in-buffer HTML_CONTAINER property or for
1078 publishing, with :html-container.
1080 Note that changing the default will prevent you from using
1081 org-info.js for your website."
1082 :group
'org-export-html
1084 :package-version
'(Org .
"8.0")
1087 (defcustom org-html-divs
1088 '((preamble "div" "preamble")
1089 (content "div" "content")
1090 (postamble "div" "postamble"))
1091 "Alist of the three section elements for HTML export.
1092 The car of each entry is one of `preamble', `content' or `postamble'.
1093 The cdrs of each entry are the ELEMENT_TYPE and ID for each
1094 section of the exported document.
1096 Note that changing the default will prevent you from using
1097 org-info.js for your website."
1098 :group
'org-export-html
1100 :package-version
'(Org .
"8.0")
1101 :type
'(list :greedy t
1102 (list :tag
"Preamble"
1103 (const :format
"" preamble
)
1104 (string :tag
"element") (string :tag
" id"))
1105 (list :tag
"Content"
1106 (const :format
"" content
)
1107 (string :tag
"element") (string :tag
" id"))
1108 (list :tag
"Postamble" (const :format
"" postamble
)
1109 (string :tag
" id") (string :tag
"element"))))
1111 (defconst org-html-checkbox-types
1113 ((on .
"☑") (off .
"☐") (trans .
"☐")))
1115 ((on .
"<code>[X]</code>")
1116 (off .
"<code>[ ]</code>")
1117 (trans .
"<code>[-]</code>")))
1119 ((on .
"<input type='checkbox' checked='checked' />")
1120 (off .
"<input type='checkbox' />")
1121 (trans .
"<input type='checkbox' />"))))
1122 "Alist of checkbox types.
1123 The cdr of each entry is an alist list three checkbox types for
1124 HTML export: `on', `off' and `trans'.
1127 `unicode' Unicode characters (HTML entities)
1128 `ascii' ASCII characters
1129 `html' HTML checkboxes
1131 Note that only the ascii characters implement tri-state
1132 checkboxes. The other two use the `off' checkbox for `trans'.")
1134 (defcustom org-html-checkbox-type
'ascii
1135 "The type of checkboxes to use for HTML export.
1136 See `org-html-checkbox-types' for for the values used for each
1138 :group
'org-export-html
1140 :package-version
'(Org .
"8.0")
1142 (const :tag
"ASCII characters" ascii
)
1143 (const :tag
"Unicode characters" unicode
)
1144 (const :tag
"HTML checkboxes" html
)))
1146 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
1147 "Format used for timestamps in preamble, postamble and metadata.
1148 See `format-time-string' for more information on its components."
1149 :group
'org-export-html
1151 :package-version
'(Org .
"8.0")
1154 ;;;; Template :: Mathjax
1156 (defcustom org-html-mathjax-options
1157 '((path "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" )
1161 (linebreaks "false")
1164 (multlinewidth "85%")
1167 "Options for MathJax setup.
1169 Alist of the following elements. All values are strings.
1171 path The path to MathJax.
1172 scale Scaling with HTML-CSS, MathML and SVG output engines.
1173 align How to align display math: left, center, or right.
1174 font The font to use with HTML-CSS and SVG output. As of MathJax 2.5
1175 the following values are understood: \"TeX\", \"STIX-Web\",
1176 \"Asana-Math\", \"Neo-Euler\", \"Gyre-Pagella\",
1177 \"Gyre-Termes\", and \"Latin-Modern\".
1178 linebreaks Let MathJax perform automatic linebreaks. Valid values
1179 are \"true\" and \"false\".
1180 indent If align is not center, how far from the left/right side?
1181 Valid values are \"left\" and \"right\"
1182 multlinewidth The width of the multline environment.
1183 autonumber How to number equations. Valid values are \"None\",
1184 \"all\" and \"AMS Math\".
1185 tagindent The amount tags are indented.
1186 tagside Which side to show tags/labels on. Valid values are
1187 \"left\" and \"right\"
1189 You can also customize this for each buffer, using something like
1191 #+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
1193 For further information about MathJax options, see the MathJax documentation:
1195 http://docs.mathjax.org/
1197 Please note that by using the default CDN one must agree with
1198 MathJax CDN Terms of Service.
1200 http://www.mathjax.org/mathjax-cdn-terms-of-service.html"
1201 :group
'org-export-html
1202 :package-version
'(Org .
"8.3")
1203 :type
'(list :greedy t
1204 (list :tag
"path (the path from where to load MathJax.js)"
1205 (const :format
" " path
) (string))
1206 (list :tag
"scale (scaling for the displayed math)"
1207 (const :format
" " scale
) (string))
1208 (list :tag
"align (alignment of displayed equations)"
1209 (const :format
" " align
) (string))
1210 (list :tag
"font (used to display math)"
1211 (const :format
" " font
)
1212 (choice (const "TeX")
1214 (const "Asana-Math")
1216 (const "Gyre-Pagella")
1217 (const "Gyre-Termes")
1218 (const "Latin-Modern")))
1219 (list :tag
"linebreaks (automatic line-breaking)"
1220 (const :format
" " linebreaks
)
1221 (choice (const "true")
1223 (list :tag
"autonumber (when should equations be numbered)"
1224 (const :format
" " autonumber
)
1225 (choice (const "AMS")
1228 (list :tag
"indent (indentation with left or right alignment)"
1229 (const :format
" " indent
) (string))
1230 (list :tag
"multlinewidth (width to use for the multline environment)"
1231 (const :format
" " multlinewidth
) (string))
1232 (list :tag
"tagindent (the indentation of tags from left or right)"
1233 (const :format
" " tagindent
) (string))
1234 (list :tag
"tagside (location of tags)"
1235 (const :format
" " tagside
)
1236 (choice (const "left")
1239 (defcustom org-html-mathjax-template
1240 "<script type=\"text/x-mathjax-config\">
1241 MathJax.Hub.Config({
1242 displayAlign: \"%ALIGN\",
1243 displayIndent: \"%INDENT\",
1245 \"HTML-CSS\": { scale: %SCALE,
1246 linebreaks: { automatic: \"%LINEBREAKS\" },
1249 SVG: {scale: %SCALE,
1250 linebreaks: { automatic: \"%LINEBREAKS\" },
1252 NativeMML: {scale: %SCALE},
1253 TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"},
1254 MultLineWidth: \"%MULTLINEWIDTH\",
1255 TagSide: \"%TAGSIDE\",
1256 TagIndent: \"%TAGINDENT\"
1260 <script type=\"text/javascript\"
1261 src=\"%PATH\"></script>"
1262 "The MathJax template. See also `org-html-mathjax-options'."
1263 :group
'org-export-html
1266 ;;;; Template :: Postamble
1268 (defcustom org-html-postamble
'auto
1269 "Non-nil means insert a postamble in HTML export.
1271 When set to `auto', check against the
1272 `org-export-with-author/email/creator/date' variables to set the
1273 content of the postamble. When set to a string, use this string
1274 as the postamble. When t, insert a string as defined by the
1275 formatting string in `org-html-postamble-format'.
1277 When set to a function, apply this function and insert the
1278 returned string. The function takes the property list of export
1279 options as its only argument.
1281 Setting :html-postamble in publishing projects will take
1282 precedence over this variable."
1283 :group
'org-export-html
1284 :type
'(choice (const :tag
"No postamble" nil
)
1285 (const :tag
"Auto postamble" auto
)
1286 (const :tag
"Default formatting string" t
)
1287 (string :tag
"Custom formatting string")
1288 (function :tag
"Function (must return a string)")))
1290 (defcustom org-html-postamble-format
1291 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1292 <p class=\"date\">Date: %d</p>
1293 <p class=\"creator\">%c</p>
1294 <p class=\"validation\">%v</p>"))
1295 "Alist of languages and format strings for the HTML postamble.
1297 The first element of each list is the language code, as used for
1298 the LANGUAGE keyword. See `org-export-default-language'.
1300 The second element of each list is a format string to format the
1301 postamble itself. This format string can contain these elements:
1303 %t stands for the title.
1304 %s stands for the subtitle.
1305 %a stands for the author's name.
1306 %e stands for the author's email.
1307 %d stands for the date.
1308 %c will be replaced by `org-html-creator-string'.
1309 %v will be replaced by `org-html-validation-link'.
1310 %T will be replaced by the export time.
1311 %C will be replaced by the last modification time.
1313 If you need to use a \"%\" character, you need to escape it
1315 :group
'org-export-html
1317 (list (string :tag
"Language")
1318 (string :tag
"Format string"))))
1320 (defcustom org-html-validation-link
1321 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1322 "Link to HTML validation service."
1323 :group
'org-export-html
1326 (defcustom org-html-creator-string
1327 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1329 (if (fboundp 'org-version
) (org-version) "unknown version"))
1330 "Information about the creator of the HTML document.
1331 This option can also be set on with the CREATOR keyword."
1332 :group
'org-export-html
1334 :package-version
'(Org .
"8.0")
1335 :type
'(string :tag
"Creator string"))
1337 ;;;; Template :: Preamble
1339 (defcustom org-html-preamble t
1340 "Non-nil means insert a preamble in HTML export.
1342 When t, insert a string as defined by the formatting string in
1343 `org-html-preamble-format'. When set to a string, use this
1344 formatting string instead (see `org-html-postamble-format' for an
1345 example of such a formatting string).
1347 When set to a function, apply this function and insert the
1348 returned string. The function takes the property list of export
1349 options as its only argument.
1351 Setting :html-preamble in publishing projects will take
1352 precedence over this variable."
1353 :group
'org-export-html
1354 :type
'(choice (const :tag
"No preamble" nil
)
1355 (const :tag
"Default preamble" t
)
1356 (string :tag
"Custom formatting string")
1357 (function :tag
"Function (must return a string)")))
1359 (defcustom org-html-preamble-format
'(("en" ""))
1360 "Alist of languages and format strings for the HTML preamble.
1362 The first element of each list is the language code, as used for
1363 the LANGUAGE keyword. See `org-export-default-language'.
1365 The second element of each list is a format string to format the
1366 preamble itself. This format string can contain these elements:
1368 %t stands for the title.
1369 %s stands for the subtitle.
1370 %a stands for the author's name.
1371 %e stands for the author's email.
1372 %d stands for the date.
1373 %c will be replaced by `org-html-creator-string'.
1374 %v will be replaced by `org-html-validation-link'.
1375 %T will be replaced by the export time.
1376 %C will be replaced by the last modification time.
1378 If you need to use a \"%\" character, you need to escape it
1381 See the default value of `org-html-postamble-format' for an
1383 :group
'org-export-html
1385 (list (string :tag
"Language")
1386 (string :tag
"Format string"))))
1388 (defcustom org-html-link-up
""
1389 "Where should the \"UP\" link of exported HTML pages lead?"
1390 :group
'org-export-html
1391 :type
'(string :tag
"File or URL"))
1393 (defcustom org-html-link-home
""
1394 "Where should the \"HOME\" link of exported HTML pages lead?"
1395 :group
'org-export-html
1396 :type
'(string :tag
"File or URL"))
1398 (defcustom org-html-link-use-abs-url nil
1399 "Should we prepend relative links with HTML_LINK_HOME?"
1400 :group
'org-export-html
1402 :package-version
'(Org .
"8.1")
1405 (defcustom org-html-home
/up-format
1406 "<div id=\"org-div-home-and-up\">
1407 <a accesskey=\"h\" href=\"%s\"> UP </a>
1409 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1411 "Snippet used to insert the HOME and UP links.
1412 This is a format string, the first %s will receive the UP link,
1413 the second the HOME link. If both `org-html-link-up' and
1414 `org-html-link-home' are empty, the entire snippet will be
1416 :group
'org-export-html
1419 ;;;; Template :: Scripts
1421 (defcustom org-html-head-include-scripts t
1422 "Non-nil means include the JavaScript snippets in exported HTML files.
1423 The actual script is defined in `org-html-scripts' and should
1425 :group
'org-export-html
1427 :package-version
'(Org .
"8.0")
1430 ;;;; Template :: Styles
1432 (defcustom org-html-head-include-default-style t
1433 "Non-nil means include the default style in exported HTML files.
1434 The actual style is defined in `org-html-style-default' and
1435 should not be modified. Use `org-html-head' to use your own
1437 :group
'org-export-html
1439 :package-version
'(Org .
"8.0")
1442 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1444 (defcustom org-html-head
""
1445 "Org-wide head definitions for exported HTML files.
1447 This variable can contain the full HTML structure to provide a
1448 style, including the surrounding HTML tags. You can consider
1449 including definitions for the following classes: title, todo,
1450 done, timestamp, timestamp-kwd, tag, target.
1452 For example, a valid value would be:
1454 <style type=\"text/css\">
1456 p { font-weight: normal; color: gray; }
1457 h1 { color: black; }
1458 .title { text-align: center; }
1459 .todo, .timestamp-kwd { color: red; }
1460 .done { color: green; }
1464 If you want to refer to an external style, use something like
1466 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1468 As the value of this option simply gets inserted into the HTML
1469 <head> header, you can use it to add any arbitrary text to the
1472 You can set this on a per-file basis using #+HTML_HEAD:,
1473 or for publication projects using the :html-head property."
1474 :group
'org-export-html
1476 :package-version
'(Org .
"8.0")
1479 (put 'org-html-head
'safe-local-variable
'stringp
)
1481 (defcustom org-html-head-extra
""
1482 "More head information to add in the HTML output.
1484 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1485 or for publication projects using the :html-head-extra property."
1486 :group
'org-export-html
1488 :package-version
'(Org .
"8.0")
1491 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1493 ;;;; Template :: Viewport
1495 (defcustom org-html-viewport
'((width "device-width")
1500 "Viewport options for mobile-optimized sites.
1502 The following values are recognized
1504 width Size of the viewport.
1505 initial-scale Zoom level when the page is first loaded.
1506 minimum-scale Minimum allowed zoom level.
1507 maximum-scale Maximum allowed zoom level.
1508 user-scalable Whether zoom can be changed.
1510 The viewport meta tag is inserted if this variable is non-nil.
1512 See the following site for a reference:
1513 https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag"
1514 :group
'org-export-html
1516 :package-version
'(Org .
"8.3")
1517 :type
'(choice (const :tag
"Disable" nil
)
1519 (list :tag
"Width of viewport"
1520 (const :format
" " width
)
1521 (choice (const :tag
"unset" "")
1523 (list :tag
"Initial scale"
1524 (const :format
" " initial-scale
)
1525 (choice (const :tag
"unset" "")
1527 (list :tag
"Minimum scale/zoom"
1528 (const :format
" " minimum-scale
)
1529 (choice (const :tag
"unset" "")
1531 (list :tag
"Maximum scale/zoom"
1532 (const :format
" " maximum-scale
)
1533 (choice (const :tag
"unset" "")
1535 (list :tag
"User scalable/zoomable"
1536 (const :format
" " user-scalable
)
1537 (choice (const :tag
"unset" "")
1539 (const "false"))))))
1543 (defcustom org-html-todo-kwd-class-prefix
""
1544 "Prefix to class names for TODO keywords.
1545 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1546 The default prefix is empty because it is nice to just use the keyword
1547 as a class name. But if you get into conflicts with other, existing
1548 CSS classes, then this prefix can be very useful."
1549 :group
'org-export-html
1553 ;;; Internal Functions
1555 (defun org-html-xhtml-p (info)
1556 (let ((dt (downcase (plist-get info
:html-doctype
))))
1557 (string-match-p "xhtml" dt
)))
1559 (defun org-html-html5-p (info)
1560 (let ((dt (downcase (plist-get info
:html-doctype
))))
1561 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1563 (defun org-html--html5-fancy-p (info)
1564 "Non-nil when exporting to HTML5 with fancy elements.
1565 INFO is the current state of the export process, as a plist."
1566 (and (plist-get info
:html-html5-fancy
)
1567 (org-html-html5-p info
)))
1569 (defun org-html-close-tag (tag attr info
)
1570 "Return close-tag for string TAG.
1571 ATTR specifies additional attributes. INFO is a property list
1572 containing current export state."
1574 (org-string-nw-p (concat " " attr
))
1575 (if (org-html-xhtml-p info
) " />" ">")))
1577 (defun org-html-doctype (info)
1578 "Return correct HTML doctype tag.
1579 INFO is a plist used as a communication channel. Doctype tag is
1580 extracted from `org-html-doctype-alist', or the literal value
1581 of :html-doctype from INFO if :html-doctype is not found in the
1583 (let ((dt (plist-get info
:html-doctype
)))
1584 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1586 (defun org-html--make-attribute-string (attributes)
1587 "Return a list of attributes, as a string.
1588 ATTRIBUTES is a plist where values are either strings or nil. An
1589 attribute with a nil value will be omitted from the result."
1591 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1592 (cond ((null item
) (pop output
))
1593 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1594 (t (let ((key (car output
))
1595 (value (replace-regexp-in-string
1596 "\"" """ (org-html-encode-plain-text item
))))
1597 (setcar output
(format "%s=\"%s\"" key value
))))))))
1599 (defun org-html--wrap-image (contents info
&optional caption label
)
1600 "Wrap CONTENTS string within an appropriate environment for images.
1601 INFO is a plist used as a communication channel. When optional
1602 arguments CAPTION and LABEL are given, use them for caption and
1604 (let ((html5-fancy (org-html--html5-fancy-p info
)))
1605 (format (if html5-fancy
"\n<figure%s>\n%s%s\n</figure>"
1606 "\n<div%s class=\"figure\">\n%s%s\n</div>")
1608 (if (org-string-nw-p label
) (format " id=\"%s\"" label
) "")
1610 (if html5-fancy contents
(format "<p>%s</p>" contents
))
1612 (if (not (org-string-nw-p caption
)) ""
1613 (format (if html5-fancy
"\n<figcaption>%s</figcaption>"
1617 (defun org-html--format-image (source attributes info
)
1618 "Return \"img\" tag with given SOURCE and ATTRIBUTES.
1619 SOURCE is a string specifying the location of the image.
1620 ATTRIBUTES is a plist, as returned by
1621 `org-export-read-attribute'. INFO is a plist used as
1622 a communication channel."
1623 (if (string= "svg" (file-name-extension source
))
1624 (org-html--svg-image source attributes info
)
1627 (org-html--make-attribute-string
1630 :alt
(if (string-match-p "^ltxpng/" source
)
1631 (org-html-encode-plain-text
1632 (org-find-text-property-in-string 'org-latex-src source
))
1633 (file-name-nondirectory source
)))
1637 (defun org-html--svg-image (source attributes info
)
1638 "Return \"object\" embedding svg file SOURCE with given ATTRIBUTES.
1639 INFO is a plist used as a communication channel.
1641 The special attribute \"fallback\" can be used to specify a
1642 fallback image file to use if the object embedding is not
1643 supported. CSS class \"org-svg\" is assigned as the class of the
1644 object unless a different class is specified with an attribute."
1645 (let ((fallback (plist-get attributes
:fallback
))
1646 (attrs (org-html--make-attribute-string
1648 ;; Remove fallback attribute, which is not meant to
1649 ;; appear directly in the attributes string, and
1650 ;; provide a default class if none is set.
1651 '(:class
"org-svg") attributes
'(:fallback nil
)))))
1652 (format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>"
1657 "img" (format "src=\"%s\" %s" fallback attrs
) info
)
1658 "Sorry, your browser does not support SVG."))))
1660 (defun org-html--textarea-block (element)
1661 "Transcode ELEMENT into a textarea block.
1662 ELEMENT is either a src block or an example block."
1663 (let* ((code (car (org-export-unravel-code element
)))
1664 (attr (org-export-read-attribute :attr_html element
)))
1665 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1666 (or (plist-get attr
:width
) 80)
1667 (or (plist-get attr
:height
) (org-count-lines code
))
1670 (defun org-html--has-caption-p (element &optional _info
)
1671 "Non-nil when ELEMENT has a caption affiliated keyword.
1672 INFO is a plist used as a communication channel. This function
1673 is meant to be used as a predicate for `org-export-get-ordinal' or
1674 a value to `org-html-standalone-image-predicate'."
1675 (org-element-property :caption element
))
1679 (defun org-html-htmlize-region-for-paste (beg end
)
1680 "Convert the region between BEG and END to HTML, using htmlize.el.
1681 This is much like `htmlize-region-for-paste', only that it uses
1682 the settings define in the org-... variables."
1683 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1684 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1685 (htmlbuf (htmlize-region beg end
)))
1687 (with-current-buffer htmlbuf
1688 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1689 (plist-get htmlize-buffer-places
'content-end
)))
1690 (kill-buffer htmlbuf
))))
1693 (defun org-html-htmlize-generate-css ()
1694 "Create the CSS for all font definitions in the current Emacs session.
1695 Use this to create face definitions in your CSS style file that can then
1696 be used by code snippets transformed by htmlize.
1697 This command just produces a buffer that contains class definitions for all
1698 faces used in the current Emacs session. You can copy and paste the ones you
1699 need into your CSS file.
1701 If you then set `org-html-htmlize-output-type' to `css', calls
1702 to the function `org-html-htmlize-region-for-paste' will
1703 produce code that uses these same face definitions."
1706 (and (get-buffer "*html*") (kill-buffer "*html*"))
1708 (let ((fl (face-list))
1709 (htmlize-css-name-prefix "org-")
1710 (htmlize-output-type 'css
)
1712 (while (setq f
(pop fl
)
1713 i
(and f
(face-attribute f
:inherit
)))
1714 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1715 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1716 (htmlize-region (point-min) (point-max))))
1717 (pop-to-buffer-same-window "*html*")
1718 (goto-char (point-min))
1719 (if (re-search-forward "<style" nil t
)
1720 (delete-region (point-min) (match-beginning 0)))
1721 (if (re-search-forward "</style>" nil t
)
1722 (delete-region (1+ (match-end 0)) (point-max)))
1723 (beginning-of-line 1)
1724 (if (looking-at " +") (replace-match ""))
1725 (goto-char (point-min)))
1727 (defun org-html--make-string (n string
)
1728 "Build a string by concatenating N times STRING."
1729 (let (out) (dotimes (_ n out
) (setq out
(concat string out
)))))
1731 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1732 "Turn todo keyword KWD into a valid class name.
1733 Replaces invalid characters with \"_\"."
1734 (replace-regexp-in-string "[^a-zA-Z0-9_]" "_" kwd nil t
))
1736 (defun org-html-footnote-section (info)
1737 "Format the footnote section.
1738 INFO is a plist used as a communication channel."
1739 (let* ((fn-alist (org-export-collect-footnote-definitions info
))
1741 (cl-loop for
(n _type raw
) in fn-alist collect
1742 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1743 (org-trim (org-export-data raw info
))
1744 (format "<div class=\"footpara\">%s</div>"
1745 (org-trim (org-export-data raw info
))))))))
1748 (plist-get info
:html-footnotes-section
)
1749 (org-html--translate "Footnotes" info
)
1754 (let ((n (car fn
)) (def (cdr fn
)))
1756 "<div class=\"footdef\">%s %s</div>\n"
1758 (plist-get info
:html-footnote-format
)
1762 (format " class=\"footnum\" href=\"#fnr.%d\"" n
)
1771 (defun org-html--build-meta-info (info)
1772 "Return meta tags for exported document.
1773 INFO is a plist used as a communication channel."
1774 (let ((protect-string
1776 (replace-regexp-in-string
1777 "\"" """ (org-html-encode-plain-text str
))))
1778 (title (org-export-data (plist-get info
:title
) info
))
1779 (author (and (plist-get info
:with-author
)
1780 (let ((auth (plist-get info
:author
)))
1782 ;; Return raw Org syntax, skipping non
1783 ;; exportable objects.
1784 (org-element-interpret-data
1785 (org-element-map auth
1786 (cons 'plain-text org-element-all-objects
)
1787 'identity info
))))))
1788 (description (plist-get info
:description
))
1789 (keywords (plist-get info
:keywords
))
1790 (charset (or (and org-html-coding-system
1791 (fboundp 'coding-system-get
)
1792 (coding-system-get org-html-coding-system
1796 (when (plist-get info
:time-stamp-file
)
1799 (plist-get info
:html-metadata-timestamp-format
)
1802 (if (org-html-html5-p info
)
1803 (org-html-close-tag "meta" "charset=\"%s\"" info
)
1805 "meta" "http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1808 (let ((viewport-options
1809 (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell
)))
1810 (plist-get info
:html-viewport
))))
1811 (and viewport-options
1815 (format "name=\"viewport\" content=\"%s\""
1817 (lambda (elm) (format "%s=%s" (car elm
) (cadr elm
)))
1818 viewport-options
", "))
1821 (format "<title>%s</title>\n" title
)
1822 (org-html-close-tag "meta" "name=\"generator\" content=\"Org mode\"" info
)
1824 (and (org-string-nw-p author
)
1826 (org-html-close-tag "meta"
1827 (format "name=\"author\" content=\"%s\""
1828 (funcall protect-string author
))
1831 (and (org-string-nw-p description
)
1833 (org-html-close-tag "meta"
1834 (format "name=\"description\" content=\"%s\"\n"
1835 (funcall protect-string description
))
1838 (and (org-string-nw-p keywords
)
1840 (org-html-close-tag "meta"
1841 (format "name=\"keywords\" content=\"%s\""
1842 (funcall protect-string keywords
))
1846 (defun org-html--build-head (info)
1847 "Return information for the <head>..</head> of the HTML output.
1848 INFO is a plist used as a communication channel."
1849 (org-element-normalize-string
1851 (when (plist-get info
:html-head-include-default-style
)
1852 (org-element-normalize-string org-html-style-default
))
1853 (org-element-normalize-string (plist-get info
:html-head
))
1854 (org-element-normalize-string (plist-get info
:html-head-extra
))
1855 (when (and (plist-get info
:html-htmlized-css-url
)
1856 (eq org-html-htmlize-output-type
'css
))
1857 (org-html-close-tag "link"
1858 (format "rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1859 (plist-get info
:html-htmlized-css-url
))
1861 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1863 (defun org-html--build-mathjax-config (info)
1864 "Insert the user setup into the mathjax template.
1865 INFO is a plist used as a communication channel."
1866 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1867 (org-element-map (plist-get info
:parse-tree
)
1868 '(latex-fragment latex-environment
) 'identity info t
))
1869 (let ((template (plist-get info
:html-mathjax-template
))
1870 (options (plist-get info
:html-mathjax-options
))
1871 (in-buffer (or (plist-get info
:html-mathjax
) "")))
1872 (dolist (e options
(org-element-normalize-string template
))
1873 (let ((name (car e
))
1875 (when (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1877 (car (read-from-string (substring in-buffer
(match-end 0))))))
1878 (unless (stringp val
) (setq val
(format "%s" val
)))
1879 (while (string-match (concat "%" (upcase (symbol-name name
)))
1881 (setq template
(replace-match val t t template
))))))))
1883 (defun org-html-format-spec (info)
1884 "Return format specification for preamble and postamble.
1885 INFO is a plist used as a communication channel."
1886 (let ((timestamp-format (plist-get info
:html-metadata-timestamp-format
)))
1887 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1888 (?s .
,(org-export-data (plist-get info
:subtitle
) info
))
1889 (?d .
,(org-export-data (org-export-get-date info timestamp-format
)
1891 (?T .
,(format-time-string timestamp-format
))
1892 (?a .
,(org-export-data (plist-get info
:author
) info
))
1894 (lambda (e) (format "<a href=\"mailto:%s\">%s</a>" e e
))
1895 (split-string (plist-get info
:email
) ",+ *")
1897 (?c .
,(plist-get info
:creator
))
1898 (?C .
,(let ((file (plist-get info
:input-file
)))
1899 (format-time-string timestamp-format
1900 (and file
(nth 5 (file-attributes file
))))))
1901 (?v .
,(or (plist-get info
:html-validation-link
) "")))))
1903 (defun org-html--build-pre/postamble
(type info
)
1904 "Return document preamble or postamble as a string, or nil.
1905 TYPE is either `preamble' or `postamble', INFO is a plist used as a
1906 communication channel."
1907 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1908 (spec (org-html-format-spec info
)))
1910 (let ((section-contents
1911 (if (functionp section
) (funcall section info
)
1913 ((stringp section
) (format-spec section spec
))
1915 (let ((date (cdr (assq ?d spec
)))
1916 (author (cdr (assq ?a spec
)))
1917 (email (cdr (assq ?e spec
)))
1918 (creator (cdr (assq ?c spec
)))
1919 (validation-link (cdr (assq ?v spec
))))
1921 (when (and (plist-get info
:with-date
)
1922 (org-string-nw-p date
))
1923 (format "<p class=\"date\">%s: %s</p>\n"
1924 (org-html--translate "Date" info
)
1926 (when (and (plist-get info
:with-author
)
1927 (org-string-nw-p author
))
1928 (format "<p class=\"author\">%s: %s</p>\n"
1929 (org-html--translate "Author" info
)
1931 (when (and (plist-get info
:with-email
)
1932 (org-string-nw-p email
))
1933 (format "<p class=\"email\">%s: %s</p>\n"
1934 (org-html--translate "Email" info
)
1936 (when (plist-get info
:time-stamp-file
)
1938 "<p class=\"date\">%s: %s</p>\n"
1939 (org-html--translate "Created" info
)
1941 (plist-get info
:html-metadata-timestamp-format
))))
1942 (when (plist-get info
:with-creator
)
1943 (format "<p class=\"creator\">%s</p>\n" creator
))
1944 (format "<p class=\"validation\">%s</p>\n"
1947 (or (cadr (assoc-string
1948 (plist-get info
:language
)
1950 (format "org-html-%s-format" type
)))
1956 (intern (format "org-html-%s-format" type
)))
1959 (let ((div (assq type
(plist-get info
:html-divs
))))
1960 (when (org-string-nw-p section-contents
)
1962 (format "<%s id=\"%s\" class=\"%s\">\n"
1965 org-html--pre
/postamble-class
)
1966 (org-element-normalize-string section-contents
)
1967 (format "</%s>\n" (nth 1 div
)))))))))
1969 (defun org-html-inner-template (contents info
)
1970 "Return body of document string after HTML conversion.
1971 CONTENTS is the transcoded contents string. INFO is a plist
1972 holding export options."
1974 ;; Table of contents.
1975 (let ((depth (plist-get info
:with-toc
)))
1976 (when depth
(org-html-toc depth info
)))
1977 ;; Document contents.
1979 ;; Footnotes section.
1980 (org-html-footnote-section info
)))
1982 (defun org-html-template (contents info
)
1983 "Return complete document string after HTML conversion.
1984 CONTENTS is the transcoded contents string. INFO is a plist
1985 holding export options."
1987 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1988 (let* ((xml-declaration (plist-get info
:html-xml-declaration
))
1989 (decl (or (and (stringp xml-declaration
) xml-declaration
)
1990 (cdr (assoc (plist-get info
:html-extension
)
1992 (cdr (assoc "html" xml-declaration
))
1994 (when (not (or (not decl
) (string= "" decl
)))
1997 (or (and org-html-coding-system
1998 (fboundp 'coding-system-get
)
1999 (coding-system-get org-html-coding-system
'mime-charset
))
2001 (org-html-doctype info
)
2004 (cond ((org-html-xhtml-p info
)
2006 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
2007 (plist-get info
:language
) (plist-get info
:language
)))
2008 ((org-html-html5-p info
)
2009 (format " lang=\"%s\"" (plist-get info
:language
))))
2012 (org-html--build-meta-info info
)
2013 (org-html--build-head info
)
2014 (org-html--build-mathjax-config info
)
2017 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
2018 (link-home (org-trim (plist-get info
:html-link-home
))))
2019 (unless (and (string= link-up
"") (string= link-home
""))
2020 (format (plist-get info
:html-home
/up-format
)
2021 (or link-up link-home
)
2022 (or link-home link-up
))))
2024 (org-html--build-pre/postamble
'preamble info
)
2025 ;; Document contents.
2026 (let ((div (assq 'content
(plist-get info
:html-divs
))))
2027 (format "<%s id=\"%s\">\n" (nth 1 div
) (nth 2 div
)))
2029 (when (plist-get info
:with-title
)
2030 (let ((title (plist-get info
:title
))
2031 (subtitle (plist-get info
:subtitle
))
2032 (html5-fancy (org-html--html5-fancy-p info
)))
2036 "<header>\n<h1 class=\"title\">%s</h1>\n%s</header>"
2037 "<h1 class=\"title\">%s%s</h1>\n")
2038 (org-export-data title info
)
2042 "<p class=\"subtitle\">%s</p>\n"
2043 "\n<br>\n<span class=\"subtitle\">%s</span>\n")
2044 (org-export-data subtitle info
))
2047 (format "</%s>\n" (nth 1 (assq 'content
(plist-get info
:html-divs
))))
2049 (org-html--build-pre/postamble
'postamble info
)
2050 ;; Closing document.
2051 "</body>\n</html>"))
2053 (defun org-html--translate (s info
)
2054 "Translate string S according to specified language.
2055 INFO is a plist used as a communication channel."
2056 (org-export-translate s
:html info
))
2060 (defun org-html--anchor (id desc attributes info
)
2061 "Format a HTML anchor."
2062 (let* ((name (and (plist-get info
:html-allow-name-attribute-in-anchors
) id
))
2063 (attributes (concat (and id
(format " id=\"%s\"" id
))
2064 (and name
(format " name=\"%s\"" name
))
2066 (format "<a%s>%s</a>" attributes
(or desc
""))))
2070 (defun org-html--todo (todo info
)
2071 "Format TODO keywords into HTML."
2073 (format "<span class=\"%s %s%s\">%s</span>"
2074 (if (member todo org-done-keywords
) "done" "todo")
2075 (or (plist-get info
:html-todo-kwd-class-prefix
) "")
2076 (org-html-fix-class-name todo
)
2081 (defun org-html--priority (priority _info
)
2082 "Format a priority into HTML.
2083 PRIORITY is the character code of the priority or nil. INFO is
2084 a plist containing export options."
2085 (and priority
(format "<span class=\"priority\">[%c]</span>" priority
)))
2089 (defun org-html--tags (tags info
)
2090 "Format TAGS into HTML.
2091 INFO is a plist containing export options."
2093 (format "<span class=\"tag\">%s</span>"
2096 (format "<span class=\"%s\">%s</span>"
2097 (concat (plist-get info
:html-tag-class-prefix
)
2098 (org-html-fix-class-name tag
))
2104 (defun org-html-fontify-code (code lang
)
2105 "Color CODE with htmlize library.
2106 CODE is a string representing the source code to colorize. LANG
2107 is the language used for CODE, as a string, or nil."
2110 ;; Case 1: No lang. Possibly an example block.
2112 ;; Simple transcoding.
2113 (org-html-encode-plain-text code
))
2114 ;; Case 2: No htmlize or an inferior version of htmlize
2115 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
2117 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
2118 ;; Simple transcoding.
2119 (org-html-encode-plain-text code
))
2120 ;; Case 3: plain text explicitly set
2121 ((not org-html-htmlize-output-type
)
2122 ;; Simple transcoding.
2123 (org-html-encode-plain-text code
))
2126 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
2127 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
2129 ;; Case 1: Language is not associated with any Emacs mode
2130 ((not (functionp lang-mode
))
2131 ;; Simple transcoding.
2132 (org-html-encode-plain-text code
))
2133 ;; Case 2: Default. Fontify code.
2137 (let ((output-type org-html-htmlize-output-type
)
2138 (font-prefix org-html-htmlize-font-prefix
))
2140 ;; Switch to language-specific mode.
2144 (org-font-lock-ensure)
2145 ;; Remove formatting on newline characters.
2147 (let ((beg (point-min))
2150 (while (progn (end-of-line) (< (point) end
))
2151 (put-text-property (point) (1+ (point)) 'face nil
)
2154 (set-buffer-modified-p nil
)
2156 (let ((org-html-htmlize-output-type output-type
)
2157 (org-html-htmlize-font-prefix font-prefix
))
2158 (org-html-htmlize-region-for-paste
2159 (point-min) (point-max))))))
2160 ;; Strip any enclosing <pre></pre> tags.
2161 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
2162 (end (and beg
(string-match "</pre>\\'" code
))))
2163 (if (and beg end
) (substring code beg end
) code
)))))))))
2165 (defun org-html-do-format-code
2166 (code &optional lang refs retain-labels num-start
)
2167 "Format CODE string as source code.
2168 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
2169 respectively, the language of the source code, as a string, an
2170 alist between line numbers and references (as returned by
2171 `org-export-unravel-code'), a boolean specifying if labels should
2172 appear in the source code, and the number associated to the first
2174 (let* ((code-lines (org-split-string code
"\n"))
2175 (code-length (length code-lines
))
2179 (length (number-to-string (+ code-length num-start
))))))
2180 (code (org-html-fontify-code code lang
)))
2181 (org-export-format-code
2183 (lambda (loc line-num ref
)
2186 ;; Add line number, if needed.
2188 (format "<span class=\"linenr\">%s</span>"
2189 (format num-fmt line-num
)))
2190 ;; Transcoded src line.
2192 ;; Add label, if needed.
2193 (when (and ref retain-labels
) (format " (%s)" ref
))))
2194 ;; Mark transcoded line as an anchor, if needed.
2196 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
2200 (defun org-html-format-code (element info
)
2201 "Format contents of ELEMENT as source code.
2202 ELEMENT is either an example block or a src block. INFO is
2203 a plist used as a communication channel."
2204 (let* ((lang (org-element-property :language element
))
2205 ;; Extract code and references.
2206 (code-info (org-export-unravel-code element
))
2207 (code (car code-info
))
2208 (refs (cdr code-info
))
2209 ;; Does the src block contain labels?
2210 (retain-labels (org-element-property :retain-labels element
))
2211 ;; Does it have line numbers?
2212 (num-start (org-export-get-loc element info
)))
2213 (org-html-do-format-code code lang refs retain-labels num-start
)))
2216 ;;; Tables of Contents
2218 (defun org-html-toc (depth info
&optional scope
)
2219 "Build a table of contents.
2220 DEPTH is an integer specifying the depth of the table. INFO is
2221 a plist used as a communication channel. Optional argument SCOPE
2222 is an element defining the scope of the table. Return the table
2223 of contents as a string, or nil if it is empty."
2225 (mapcar (lambda (headline)
2226 (cons (org-html--format-toc-headline headline info
)
2227 (org-export-get-relative-level headline info
)))
2228 (org-export-collect-headlines info depth scope
))))
2230 (let ((toc (concat "<div id=\"text-table-of-contents\">"
2231 (org-html--toc-text toc-entries
)
2234 (let ((outer-tag (if (org-html--html5-fancy-p info
)
2237 (concat (format "<%s id=\"table-of-contents\">\n" outer-tag
)
2238 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2239 (format "<h%d>%s</h%d>\n"
2241 (org-html--translate "Table of Contents" info
)
2244 (format "</%s>\n" outer-tag
))))))))
2246 (defun org-html--toc-text (toc-entries)
2247 "Return innards of a table of contents, as a string.
2248 TOC-ENTRIES is an alist where key is an entry title, as a string,
2249 and value is its relative level, as an integer."
2250 (let* ((prev-level (1- (cdar toc-entries
)))
2251 (start-level prev-level
))
2255 (let ((headline (car entry
))
2256 (level (cdr entry
)))
2258 (let* ((cnt (- level prev-level
))
2259 (times (if (> cnt
0) (1- cnt
) (- cnt
))))
2260 (setq prev-level level
)
2262 (org-html--make-string
2263 times
(cond ((> cnt
0) "\n<ul>\n<li>")
2264 ((< cnt
0) "</li>\n</ul>\n")))
2265 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
2268 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
2270 (defun org-html--format-toc-headline (headline info
)
2271 "Return an appropriate table of contents entry for HEADLINE.
2272 INFO is a plist used as a communication channel."
2273 (let* ((headline-number (org-export-get-headline-number headline info
))
2274 (todo (and (plist-get info
:with-todo-keywords
)
2275 (let ((todo (org-element-property :todo-keyword headline
)))
2276 (and todo
(org-export-data todo info
)))))
2277 (todo-type (and todo
(org-element-property :todo-type headline
)))
2278 (priority (and (plist-get info
:with-priority
)
2279 (org-element-property :priority headline
)))
2280 (text (org-export-data-with-backend
2281 (org-export-get-alt-title headline info
)
2282 ;; Create an anonymous back-end that will ignore any
2283 ;; footnote-reference, link, radio-target and target
2284 ;; in table of contents.
2285 (org-export-create-backend
2287 :transcoders
'((footnote-reference . ignore
)
2288 (link .
(lambda (object c i
) c
))
2289 (radio-target .
(lambda (object c i
) c
))
2292 (tags (and (eq (plist-get info
:with-tags
) t
)
2293 (org-export-get-tags headline info
))))
2294 (format "<a href=\"#%s\">%s</a>"
2296 (or (org-element-property :CUSTOM_ID headline
)
2297 (org-export-get-reference headline info
))
2300 (and (not (org-export-low-level-p headline info
))
2301 (org-export-numbered-headline-p headline info
)
2302 (concat (mapconcat #'number-to-string headline-number
".")
2304 (apply (plist-get info
:html-format-headline-function
)
2305 todo todo-type priority text tags
:section-number nil
)))))
2307 (defun org-html-list-of-listings (info)
2308 "Build a list of listings.
2309 INFO is a plist used as a communication channel. Return the list
2310 of listings as a string, or nil if it is empty."
2311 (let ((lol-entries (org-export-collect-listings info
)))
2313 (concat "<div id=\"list-of-listings\">\n"
2314 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2315 (format "<h%d>%s</h%d>\n"
2317 (org-html--translate "List of Listings" info
)
2319 "<div id=\"text-list-of-listings\">\n<ul>\n"
2321 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2322 (org-html--translate "Listing %d:" info
))))
2325 (let ((label (and (org-element-property :name entry
)
2326 (org-export-get-reference entry info
)))
2329 (or (org-export-get-caption entry t
)
2330 (org-export-get-caption entry
))
2335 (concat (format initial-fmt
(cl-incf count
))
2338 (format "<a href=\"#%s\">%s %s</a>"
2340 (format initial-fmt
(cl-incf count
))
2344 "\n</ul>\n</div>\n</div>"))))
2346 (defun org-html-list-of-tables (info)
2347 "Build a list of tables.
2348 INFO is a plist used as a communication channel. Return the list
2349 of tables as a string, or nil if it is empty."
2350 (let ((lol-entries (org-export-collect-tables info
)))
2352 (concat "<div id=\"list-of-tables\">\n"
2353 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2354 (format "<h%d>%s</h%d>\n"
2356 (org-html--translate "List of Tables" info
)
2358 "<div id=\"text-list-of-tables\">\n<ul>\n"
2360 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2361 (org-html--translate "Table %d:" info
))))
2364 (let ((label (and (org-element-property :name entry
)
2365 (org-export-get-reference entry info
)))
2368 (or (org-export-get-caption entry t
)
2369 (org-export-get-caption entry
))
2374 (concat (format initial-fmt
(cl-incf count
))
2377 (format "<a href=\"#%s\">%s %s</a>"
2379 (format initial-fmt
(cl-incf count
))
2383 "\n</ul>\n</div>\n</div>"))))
2386 ;;; Transcode Functions
2390 (defun org-html-bold (_bold contents info
)
2391 "Transcode BOLD from Org to HTML.
2392 CONTENTS is the text with bold markup. INFO is a plist holding
2393 contextual information."
2394 (format (or (cdr (assq 'bold
(plist-get info
:html-text-markup-alist
))) "%s")
2399 (defun org-html-center-block (_center-block contents _info
)
2400 "Transcode a CENTER-BLOCK element from Org to HTML.
2401 CONTENTS holds the contents of the block. INFO is a plist
2402 holding contextual information."
2403 (format "<div class=\"org-center\">\n%s</div>" contents
))
2407 (defun org-html-clock (clock _contents _info
)
2408 "Transcode a CLOCK element from Org to HTML.
2409 CONTENTS is nil. INFO is a plist used as a communication
2412 <span class=\"timestamp-wrapper\">
2413 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2417 (org-timestamp-translate (org-element-property :value clock
))
2418 (let ((time (org-element-property :duration clock
)))
2419 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2423 (defun org-html-code (code _contents info
)
2424 "Transcode CODE from Org to HTML.
2425 CONTENTS is nil. INFO is a plist holding contextual
2427 (format (or (cdr (assq 'code
(plist-get info
:html-text-markup-alist
))) "%s")
2428 (org-html-encode-plain-text (org-element-property :value code
))))
2432 (defun org-html-drawer (drawer contents info
)
2433 "Transcode a DRAWER element from Org to HTML.
2434 CONTENTS holds the contents of the block. INFO is a plist
2435 holding contextual information."
2436 (funcall (plist-get info
:html-format-drawer-function
)
2437 (org-element-property :drawer-name drawer
)
2442 (defun org-html-dynamic-block (_dynamic-block contents _info
)
2443 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2444 CONTENTS holds the contents of the block. INFO is a plist
2445 holding contextual information. See `org-export-data'."
2450 (defun org-html-entity (entity _contents _info
)
2451 "Transcode an ENTITY object from Org to HTML.
2452 CONTENTS are the definition itself. INFO is a plist holding
2453 contextual information."
2454 (org-element-property :html entity
))
2458 (defun org-html-example-block (example-block _contents info
)
2459 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2460 CONTENTS is nil. INFO is a plist holding contextual
2462 (let ((attributes (org-export-read-attribute :attr_html example-block
)))
2463 (if (plist-get attributes
:textarea
)
2464 (org-html--textarea-block example-block
)
2465 (format "<pre class=\"example\"%s>\n%s</pre>"
2466 (let* ((name (org-element-property :name example-block
))
2467 (a (org-html--make-attribute-string
2468 (if (or (not name
) (plist-member attributes
:id
))
2470 (plist-put attributes
:id name
)))))
2471 (if (org-string-nw-p a
) (concat " " a
) ""))
2472 (org-html-format-code example-block info
)))))
2476 (defun org-html-export-snippet (export-snippet _contents _info
)
2477 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2478 CONTENTS is nil. INFO is a plist holding contextual
2480 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2481 (org-element-property :value export-snippet
)))
2485 (defun org-html-export-block (export-block _contents _info
)
2486 "Transcode a EXPORT-BLOCK element from Org to HTML.
2487 CONTENTS is nil. INFO is a plist holding contextual information."
2488 (when (string= (org-element-property :type export-block
) "HTML")
2489 (org-remove-indentation (org-element-property :value export-block
))))
2493 (defun org-html-fixed-width (fixed-width _contents _info
)
2494 "Transcode a FIXED-WIDTH element from Org to HTML.
2495 CONTENTS is nil. INFO is a plist holding contextual information."
2496 (format "<pre class=\"example\">\n%s</pre>"
2497 (org-html-do-format-code
2498 (org-remove-indentation
2499 (org-element-property :value fixed-width
)))))
2501 ;;;; Footnote Reference
2503 (defun org-html-footnote-reference (footnote-reference _contents info
)
2504 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2505 CONTENTS is nil. INFO is a plist holding contextual information."
2507 ;; Insert separator between two footnotes in a row.
2508 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2509 (when (eq (org-element-type prev
) 'footnote-reference
)
2510 (plist-get info
:html-footnote-separator
)))
2511 (let* ((n (org-export-get-footnote-number footnote-reference info
))
2512 (id (format "fnr.%d%s"
2514 (if (org-export-footnote-first-reference-p
2515 footnote-reference info
)
2519 (plist-get info
:html-footnote-format
)
2521 id n
(format " class=\"footref\" href=\"#fn.%d\"" n
) info
)))))
2525 (defun org-html-headline (headline contents info
)
2526 "Transcode a HEADLINE element from Org to HTML.
2527 CONTENTS holds the contents of the headline. INFO is a plist
2528 holding contextual information."
2529 (unless (org-element-property :footnote-section-p headline
)
2530 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2531 (numbers (org-export-get-headline-number headline info
))
2532 (level (+ (org-export-get-relative-level headline info
)
2533 (1- (plist-get info
:html-toplevel-hlevel
))))
2534 (todo (and (plist-get info
:with-todo-keywords
)
2535 (let ((todo (org-element-property :todo-keyword headline
)))
2536 (and todo
(org-export-data todo info
)))))
2537 (todo-type (and todo
(org-element-property :todo-type headline
)))
2538 (priority (and (plist-get info
:with-priority
)
2539 (org-element-property :priority headline
)))
2540 (text (org-export-data (org-element-property :title headline
) info
))
2541 (tags (and (plist-get info
:with-tags
)
2542 (org-export-get-tags headline info
)))
2543 (full-text (funcall (plist-get info
:html-format-headline-function
)
2544 todo todo-type priority text tags info
))
2545 (contents (or contents
""))
2547 (list (org-element-property :CUSTOM_ID headline
)
2548 (org-export-get-reference headline info
)
2549 (org-element-property :ID headline
))))
2550 (preferred-id (car ids
))
2555 (if (org-uuidgen-p id
) (concat "ID-" id
) id
)
2558 (if (org-export-low-level-p headline info
)
2559 ;; This is a deep sub-tree: export it as a list item.
2560 (let* ((html-type (if numberedp
"ol" "ul")))
2562 (and (org-export-first-sibling-p headline info
)
2563 (apply #'format
"<%s class=\"org-%s\">\n"
2564 (make-list 2 html-type
)))
2565 (org-html-format-list-item
2566 contents
(if numberedp
'ordered
'unordered
)
2568 (concat (org-html--anchor preferred-id nil nil info
)
2571 (and (org-export-last-sibling-p headline info
)
2572 (format "</%s>\n" html-type
))))
2573 ;; Standard headline. Export it as a section.
2574 (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2575 (first-content (car (org-element-contents headline
))))
2576 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2577 (org-html--container headline info
)
2578 (concat "outline-container-"
2579 (org-export-get-reference headline info
))
2580 (concat (format "outline-%d" level
)
2581 (and extra-class
" ")
2583 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2590 "<span class=\"section-number-%d\">%s</span> "
2592 (mapconcat #'number-to-string numbers
".")))
2595 ;; When there is no section, pretend there is an
2596 ;; empty one to get the correct <div
2597 ;; class="outline-...> which is needed by
2599 (if (eq (org-element-type first-content
) 'section
) contents
2600 (concat (org-html-section first-content
"" info
) contents
))
2601 (org-html--container headline info
)))))))
2603 (defun org-html-format-headline-default-function
2604 (todo _todo-type priority text tags info
)
2605 "Default format function for a headline.
2606 See `org-html-format-headline-function' for details."
2607 (let ((todo (org-html--todo todo info
))
2608 (priority (org-html--priority priority info
))
2609 (tags (org-html--tags tags info
)))
2610 (concat todo
(and todo
" ")
2611 priority
(and priority
" ")
2613 (and tags
"   ") tags
)))
2615 (defun org-html--container (headline info
)
2616 (or (org-element-property :HTML_CONTAINER headline
)
2617 (if (= 1 (org-export-get-relative-level headline info
))
2618 (plist-get info
:html-container
)
2621 ;;;; Horizontal Rule
2623 (defun org-html-horizontal-rule (_horizontal-rule _contents info
)
2624 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2625 CONTENTS is nil. INFO is a plist holding contextual information."
2626 (org-html-close-tag "hr" nil info
))
2628 ;;;; Inline Src Block
2630 (defun org-html-inline-src-block (inline-src-block _contents info
)
2631 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2632 CONTENTS holds the contents of the item. INFO is a plist holding
2633 contextual information."
2634 (let ((lang (org-element-property :language inline-src-block
))
2635 (code (org-element-property :value inline-src-block
))
2637 (let ((lbl (and (org-element-property :name inline-src-block
)
2638 (org-export-get-reference inline-src-block info
))))
2639 (if (not lbl
) "" (format " id=\"%s\"" lbl
)))))
2640 (format "<code class=\"src src-%s\"%s>%s</code>" lang label code
)))
2644 (defun org-html-inlinetask (inlinetask contents info
)
2645 "Transcode an INLINETASK element from Org to HTML.
2646 CONTENTS holds the contents of the block. INFO is a plist
2647 holding contextual information."
2648 (let* ((todo (and (plist-get info
:with-todo-keywords
)
2649 (let ((todo (org-element-property :todo-keyword inlinetask
)))
2650 (and todo
(org-export-data todo info
)))))
2651 (todo-type (and todo
(org-element-property :todo-type inlinetask
)))
2652 (priority (and (plist-get info
:with-priority
)
2653 (org-element-property :priority inlinetask
)))
2654 (text (org-export-data (org-element-property :title inlinetask
) info
))
2655 (tags (and (plist-get info
:with-tags
)
2656 (org-export-get-tags inlinetask info
))))
2657 (funcall (plist-get info
:html-format-inlinetask-function
)
2658 todo todo-type priority text tags contents info
)))
2660 (defun org-html-format-inlinetask-default-function
2661 (todo todo-type priority text tags contents info
)
2662 "Default format function for a inlinetasks.
2663 See `org-html-format-inlinetask-function' for details."
2664 (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2665 (org-html-format-headline-default-function
2666 todo todo-type priority text tags info
)
2667 (org-html-close-tag "br" nil info
)
2672 (defun org-html-italic (_italic contents info
)
2673 "Transcode ITALIC from Org to HTML.
2674 CONTENTS is the text with italic markup. INFO is a plist holding
2675 contextual information."
2677 (or (cdr (assq 'italic
(plist-get info
:html-text-markup-alist
))) "%s")
2682 (defun org-html-checkbox (checkbox info
)
2683 "Format CHECKBOX into HTML.
2684 INFO is a plist holding contextual information. See
2685 `org-html-checkbox-type' for customization options."
2687 (cdr (assq (plist-get info
:html-checkbox-type
)
2688 org-html-checkbox-types
)))))
2690 (defun org-html-format-list-item (contents type checkbox info
2691 &optional term-counter-id
2693 "Format a list item into HTML."
2694 (let ((class (if checkbox
2695 (format " class=\"%s\""
2696 (symbol-name checkbox
)) ""))
2697 (checkbox (concat (org-html-checkbox checkbox info
)
2698 (and checkbox
" ")))
2699 (br (org-html-close-tag "br" nil info
))
2700 (extra-newline (if (and (org-string-nw-p contents
) headline
) "\n" "")))
2704 (let* ((counter term-counter-id
)
2705 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2707 (format "<li%s%s>" class extra
)
2708 (when headline
(concat headline br
)))))
2710 (let* ((id term-counter-id
)
2711 (extra (if id
(format " id=\"%s\"" id
) "")))
2713 (format "<li%s%s>" class extra
)
2714 (when headline
(concat headline br
)))))
2716 (let* ((term term-counter-id
))
2717 (setq term
(or term
"(no term)"))
2718 ;; Check-boxes in descriptive lists are associated to tag.
2719 (concat (format "<dt%s>%s</dt>"
2720 class
(concat checkbox term
))
2722 (unless (eq type
'descriptive
) checkbox
)
2724 (and (org-string-nw-p contents
) (org-trim contents
))
2728 (`unordered
"</li>")
2729 (`descriptive
"</dd>")))))
2731 (defun org-html-item (item contents info
)
2732 "Transcode an ITEM element from Org to HTML.
2733 CONTENTS holds the contents of the item. INFO is a plist holding
2734 contextual information."
2735 (let* ((plain-list (org-export-get-parent item
))
2736 (type (org-element-property :type plain-list
))
2737 (counter (org-element-property :counter item
))
2738 (checkbox (org-element-property :checkbox item
))
2739 (tag (let ((tag (org-element-property :tag item
)))
2740 (and tag
(org-export-data tag info
)))))
2741 (org-html-format-list-item
2742 contents type checkbox info
(or tag counter
))))
2746 (defun org-html-keyword (keyword _contents info
)
2747 "Transcode a KEYWORD element from Org to HTML.
2748 CONTENTS is nil. INFO is a plist holding contextual information."
2749 (let ((key (org-element-property :key keyword
))
2750 (value (org-element-property :value keyword
)))
2752 ((string= key
"HTML") value
)
2753 ((string= key
"TOC")
2754 (let ((case-fold-search t
))
2756 ((string-match "\\<headlines\\>" value
)
2757 (let ((depth (and (string-match "\\<[0-9]+\\>" value
)
2758 (string-to-number (match-string 0 value
))))
2759 (localp (string-match-p "\\<local\\>" value
)))
2760 (org-html-toc depth info
(and localp keyword
))))
2761 ((string= "listings" value
) (org-html-list-of-listings info
))
2762 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2764 ;;;; Latex Environment
2766 (defun org-html-format-latex (latex-frag processing-type info
)
2767 "Format a LaTeX fragment LATEX-FRAG into HTML.
2768 PROCESSING-TYPE designates the tool used for conversion. It can
2769 be `mathjax', `verbatim', nil, t or symbols in
2770 `org-preview-latex-process-alist', e.g., `dvipng', `dvisvgm' or
2771 `imagemagick'. See `org-html-with-latex' for more information.
2772 INFO is a plist containing export properties."
2773 (let ((cache-relpath "") (cache-dir ""))
2774 (unless (eq processing-type
'mathjax
)
2775 (let ((bfn (or (buffer-file-name)
2777 (expand-file-name "latex" temporary-file-directory
))))
2779 (let ((header (plist-get info
:latex-header
)))
2782 (lambda (line) (concat "#+LATEX_HEADER: " line
))
2783 (org-split-string header
"\n")
2787 (concat (file-name-as-directory org-preview-latex-image-directory
)
2788 (file-name-sans-extension
2789 (file-name-nondirectory bfn
)))
2790 cache-dir
(file-name-directory bfn
))
2791 ;; Re-create LaTeX environment from original buffer in
2792 ;; temporary buffer so that dvipng/imagemagick can properly
2793 ;; turn the fragment into an image.
2794 (setq latex-frag
(concat latex-header latex-frag
))))
2797 (org-format-latex cache-relpath nil nil cache-dir nil
2798 "Creating LaTeX Image..." nil processing-type
)
2801 (defun org-html-latex-environment (latex-environment _contents info
)
2802 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2803 CONTENTS is nil. INFO is a plist holding contextual information."
2804 (let ((processing-type (plist-get info
:with-latex
))
2805 (latex-frag (org-remove-indentation
2806 (org-element-property :value latex-environment
)))
2807 (attributes (org-export-read-attribute :attr_html latex-environment
)))
2809 ((memq processing-type
'(t mathjax
))
2810 (org-html-format-latex latex-frag
'mathjax info
))
2811 ((assq processing-type org-preview-latex-process-alist
)
2813 (org-html-format-latex latex-frag processing-type info
)))
2814 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2815 ;; Do not provide a caption or a name to be consistent with
2816 ;; `mathjax' handling.
2817 (org-html--wrap-image
2818 (org-html--format-image
2819 (match-string 1 formula-link
) attributes info
) info
))))
2824 (defun org-html-latex-fragment (latex-fragment _contents info
)
2825 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2826 CONTENTS is nil. INFO is a plist holding contextual information."
2827 (let ((latex-frag (org-element-property :value latex-fragment
))
2828 (processing-type (plist-get info
:with-latex
)))
2830 ((memq processing-type
'(t mathjax
))
2831 (org-html-format-latex latex-frag
'mathjax info
))
2832 ((assq processing-type org-preview-latex-process-alist
)
2834 (org-html-format-latex latex-frag processing-type info
)))
2835 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2836 (org-html--format-image (match-string 1 formula-link
) nil info
))))
2841 (defun org-html-line-break (_line-break _contents info
)
2842 "Transcode a LINE-BREAK object from Org to HTML.
2843 CONTENTS is nil. INFO is a plist holding contextual information."
2844 (concat (org-html-close-tag "br" nil info
) "\n"))
2848 (defun org-html-image-link-filter (data _backend info
)
2849 (org-export-insert-image-links data info org-html-inline-image-rules
))
2851 (defun org-html-inline-image-p (link info
)
2852 "Non-nil when LINK is meant to appear as an image.
2853 INFO is a plist used as a communication channel. LINK is an
2854 inline image when it has no description and targets an image
2855 file (see `org-html-inline-image-rules' for more information), or
2856 if its description is a single link targeting an image file."
2857 (if (not (org-element-contents link
))
2858 (org-export-inline-image-p
2859 link
(plist-get info
:html-inline-image-rules
))
2861 (let ((link-count 0))
2862 (org-element-map (org-element-contents link
)
2863 (cons 'plain-text org-element-all-objects
)
2865 (pcase (org-element-type obj
)
2866 (`plain-text
(org-string-nw-p obj
))
2867 (`link
(if (= link-count
1) t
2868 (cl-incf link-count
)
2869 (not (org-export-inline-image-p
2870 obj
(plist-get info
:html-inline-image-rules
)))))
2874 (defvar org-html-standalone-image-predicate
)
2875 (defun org-html-standalone-image-p (element info
)
2876 "Non-nil if ELEMENT is a standalone image.
2878 INFO is a plist holding contextual information.
2880 An element or object is a standalone image when
2882 - its type is `paragraph' and its sole content, save for white
2883 spaces, is a link that qualifies as an inline image;
2885 - its type is `link' and its containing paragraph has no other
2886 content save white spaces.
2888 Bind `org-html-standalone-image-predicate' to constrain paragraph
2889 further. For example, to check for only captioned standalone
2892 (lambda (paragraph) (org-element-property :caption paragraph))"
2893 (let ((paragraph (pcase (org-element-type element
)
2894 (`paragraph element
)
2895 (`link
(org-export-get-parent element
)))))
2896 (and (eq (org-element-type paragraph
) 'paragraph
)
2897 (or (not (fboundp 'org-html-standalone-image-predicate
))
2898 (funcall org-html-standalone-image-predicate paragraph
))
2900 (let ((link-count 0))
2901 (org-element-map (org-element-contents paragraph
)
2902 (cons 'plain-text org-element-all-objects
)
2904 (when (pcase (org-element-type obj
)
2905 (`plain-text
(org-string-nw-p obj
))
2906 (`link
(or (> (cl-incf link-count
) 1)
2907 (not (org-html-inline-image-p obj info
))))
2911 (= link-count
1))))))
2913 (defun org-html-link (link desc info
)
2914 "Transcode a LINK object from Org to HTML.
2915 DESC is the description part of the link, or the empty string.
2916 INFO is a plist holding contextual information. See
2918 (let* ((home (when (plist-get info
:html-link-home
)
2919 (org-trim (plist-get info
:html-link-home
))))
2920 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2921 (link-org-files-as-html-maybe
2922 (lambda (raw-path info
)
2923 ;; Treat links to `file.org' as links to `file.html', if
2924 ;; needed. See `org-html-link-org-files-as-html'.
2926 ((and (plist-get info
:html-link-org-files-as-html
)
2928 (downcase (file-name-extension raw-path
"."))))
2929 (concat (file-name-sans-extension raw-path
) "."
2930 (plist-get info
:html-extension
)))
2932 (type (org-element-property :type link
))
2933 (raw-path (org-element-property :path link
))
2934 ;; Ensure DESC really exists, or set it to nil.
2935 (desc (org-string-nw-p desc
))
2938 ((member type
'("http" "https" "ftp" "mailto" "news"))
2939 (url-encode-url (org-link-unescape (concat type
":" raw-path
))))
2940 ((string= type
"file")
2941 ;; Treat links to ".org" files as ".html", if needed.
2943 (funcall link-org-files-as-html-maybe raw-path info
))
2944 ;; If file path is absolute, prepend it with protocol
2945 ;; component - "file://".
2947 ((file-name-absolute-p raw-path
)
2948 (setq raw-path
(org-export-file-uri raw-path
)))
2949 ((and home use-abs-url
)
2950 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2951 ;; Add search option, if any. A search option can be
2952 ;; relative to a custom-id, a headline title, a name or
2954 (let ((option (org-element-property :search-option link
)))
2955 (cond ((not option
) raw-path
)
2956 ;; Since HTML back-end use custom-id value as-is,
2957 ;; resolving is them is trivial.
2958 ((eq (string-to-char option
) ?
#) (concat raw-path option
))
2962 (org-publish-resolve-external-link
2964 (org-element-property :path link
)))))))
2966 ;; Extract attributes from parent's paragraph. HACK: Only do
2967 ;; this for the first link in parent (inner image link for
2968 ;; inline images). This is needed as long as attributes
2969 ;; cannot be set on a per link basis.
2971 (let* ((parent (org-export-get-parent-element link
))
2972 (link (let ((container (org-export-get-parent link
)))
2973 (if (and (eq (org-element-type container
) 'link
)
2974 (org-html-inline-image-p link info
))
2977 (and (eq (org-element-map parent
'link
'identity info t
) link
)
2978 (org-export-read-attribute :attr_html parent
))))
2980 (let ((attr (org-html--make-attribute-string attributes-plist
)))
2981 (if (org-string-nw-p attr
) (concat " " attr
) ""))))
2983 ;; Link type is handled by a special function.
2984 ((org-export-custom-protocol-maybe link desc
'html
))
2986 ((and (plist-get info
:html-inline-images
)
2987 (org-export-inline-image-p
2988 link
(plist-get info
:html-inline-image-rules
)))
2989 (org-html--format-image path attributes-plist info
))
2990 ;; Radio target: Transcode target's contents and use them as
2991 ;; link's description.
2992 ((string= type
"radio")
2993 (let ((destination (org-export-resolve-radio-link link info
)))
2994 (if (not destination
) desc
2995 (format "<a href=\"#%s\"%s>%s</a>"
2996 (org-export-get-reference destination info
)
2999 ;; Links pointing to a headline: Find destination and build
3000 ;; appropriate referencing command.
3001 ((member type
'("custom-id" "fuzzy" "id"))
3002 (let ((destination (if (string= type
"fuzzy")
3003 (org-export-resolve-fuzzy-link link info
)
3004 (org-export-resolve-id-link link info
))))
3005 (pcase (org-element-type destination
)
3006 ;; ID link points to an external file.
3008 (let ((fragment (concat "ID-" path
))
3009 ;; Treat links to ".org" files as ".html", if needed.
3010 (path (funcall link-org-files-as-html-maybe
3012 (format "<a href=\"%s#%s\"%s>%s</a>"
3013 path fragment attributes
(or desc destination
))))
3014 ;; Fuzzy link points nowhere.
3019 (org-element-property :raw-link link
) info
))))
3020 ;; Link points to a headline.
3022 (let ((href (or (org-element-property :CUSTOM_ID destination
)
3023 (org-export-get-reference destination info
)))
3024 ;; What description to use?
3026 ;; Case 1: Headline is numbered and LINK has no
3027 ;; description. Display section number.
3028 (if (and (org-export-numbered-headline-p destination info
)
3030 (mapconcat #'number-to-string
3031 (org-export-get-headline-number
3032 destination info
) ".")
3033 ;; Case 2: Either the headline is un-numbered or
3034 ;; LINK has a custom description. Display LINK's
3035 ;; description or headline's title.
3038 (org-element-property :title destination
) info
)))))
3039 (format "<a href=\"#%s\"%s>%s</a>" href attributes desc
)))
3040 ;; Fuzzy link points to a target or an element.
3042 (let* ((ref (org-export-get-reference destination info
))
3043 (org-html-standalone-image-predicate
3044 #'org-html--has-caption-p
)
3047 ((org-html-standalone-image-p destination info
)
3048 (org-export-get-ordinal
3049 (org-element-map destination
'link
3051 info
'link
'org-html-standalone-image-p
))
3052 (t (org-export-get-ordinal
3053 destination info nil
'org-html--has-caption-p
))))
3055 ((not number
) "No description for this link")
3056 ((numberp number
) (number-to-string number
))
3057 (t (mapconcat #'number-to-string number
".")))))
3058 (format "<a href=\"#%s\"%s>%s</a>" ref attributes desc
))))))
3059 ;; Coderef: replace link with the reference name or the
3060 ;; equivalent line number.
3061 ((string= type
"coderef")
3062 (let ((fragment (concat "coderef-" (org-html-encode-plain-text path
))))
3063 (format "<a href=\"#%s\" %s%s>%s</a>"
3065 (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, \
3066 '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
3069 (format (org-export-get-coderef-format path desc
)
3070 (org-export-resolve-coderef path info
)))))
3071 ;; External link with a description part.
3072 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>"
3073 (org-html-encode-plain-text path
)
3076 ;; External link without a description part.
3077 (path (let ((path (org-html-encode-plain-text path
)))
3078 (format "<a href=\"%s\"%s>%s</a>"
3081 (org-link-unescape path
))))
3082 ;; No path, only description. Try to do something useful.
3083 (t (format "<i>%s</i>" desc
)))))
3087 (defun org-html-node-property (node-property _contents _info
)
3088 "Transcode a NODE-PROPERTY element from Org to HTML.
3089 CONTENTS is nil. INFO is a plist holding contextual
3092 (org-element-property :key node-property
)
3093 (let ((value (org-element-property :value node-property
)))
3094 (if value
(concat " " value
) ""))))
3098 (defun org-html-paragraph (paragraph contents info
)
3099 "Transcode a PARAGRAPH element from Org to HTML.
3100 CONTENTS is the contents of the paragraph, as a string. INFO is
3101 the plist used as a communication channel."
3102 (let* ((parent (org-export-get-parent paragraph
))
3103 (parent-type (org-element-type parent
))
3104 (style '((footnote-definition " class=\"footpara\"")
3105 (org-data " class=\"footpara\"")))
3106 (attributes (org-html--make-attribute-string
3107 (org-export-read-attribute :attr_html paragraph
)))
3108 (extra (or (cadr (assq parent-type style
)) "")))
3110 ((and (eq parent-type
'item
)
3111 (not (org-export-get-previous-element paragraph info
))
3112 (let ((followers (org-export-get-next-element paragraph info
2)))
3113 (and (not (cdr followers
))
3114 (memq (org-element-type (car followers
)) '(nil plain-list
)))))
3115 ;; First paragraph in an item has no tag if it is alone or
3116 ;; followed, at most, by a sub-list.
3118 ((org-html-standalone-image-p paragraph info
)
3119 ;; Standalone image.
3121 (let ((raw (org-export-data
3122 (org-export-get-caption paragraph
) info
))
3123 (org-html-standalone-image-predicate
3124 #'org-html--has-caption-p
))
3125 (if (not (org-string-nw-p raw
)) raw
3126 (concat "<span class=\"figure-number\">"
3127 (format (org-html--translate "Figure %d:" info
)
3128 (org-export-get-ordinal
3129 (org-element-map paragraph
'link
3131 info nil
#'org-html-standalone-image-p
))
3134 (label (and (org-element-property :name paragraph
)
3135 (org-export-get-reference paragraph info
))))
3136 (org-html--wrap-image contents info caption label
)))
3137 ;; Regular paragraph.
3138 (t (format "<p%s%s>\n%s</p>"
3139 (if (org-string-nw-p attributes
)
3140 (concat " " attributes
) "")
3145 (defun org-html-plain-list (plain-list contents _info
)
3146 "Transcode a PLAIN-LIST element from Org to HTML.
3147 CONTENTS is the contents of the list. INFO is a plist holding
3148 contextual information."
3149 (let* ((type (pcase (org-element-property :type plain-list
)
3153 (other (error "Unknown HTML list type: %s" other
))))
3154 (class (format "org-%s" type
))
3155 (attributes (org-export-read-attribute :attr_html plain-list
)))
3156 (format "<%s %s>\n%s</%s>"
3158 (org-html--make-attribute-string
3159 (plist-put attributes
:class
3161 (mapconcat #'identity
3162 (list class
(plist-get attributes
:class
))
3169 (defun org-html-convert-special-strings (string)
3170 "Convert special characters in STRING to HTML."
3171 (dolist (a org-html-special-string-regexps string
)
3174 (setq string
(replace-regexp-in-string re rpl string t
)))))
3176 (defun org-html-encode-plain-text (text)
3177 "Convert plain text characters from TEXT to HTML equivalent.
3178 Possible conversions are set in `org-html-protect-char-alist'."
3179 (dolist (pair org-html-protect-char-alist text
)
3180 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
))))
3182 (defun org-html-plain-text (text info
)
3183 "Transcode a TEXT string from Org to HTML.
3184 TEXT is the string to transcode. INFO is a plist holding
3185 contextual information."
3186 (let ((output text
))
3187 ;; Protect following characters: <, >, &.
3188 (setq output
(org-html-encode-plain-text output
))
3189 ;; Handle smart quotes. Be sure to provide original string since
3190 ;; OUTPUT may have been modified.
3191 (when (plist-get info
:with-smart-quotes
)
3192 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
3193 ;; Handle special strings.
3194 (when (plist-get info
:with-special-strings
)
3195 (setq output
(org-html-convert-special-strings output
)))
3196 ;; Handle break preservation if required.
3197 (when (plist-get info
:preserve-breaks
)
3199 (replace-regexp-in-string
3200 "\\(\\\\\\\\\\)?[ \t]*\n"
3201 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
3208 (defun org-html-planning (planning _contents info
)
3209 "Transcode a PLANNING element from Org to HTML.
3210 CONTENTS is nil. INFO is a plist used as a communication
3213 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
3217 (let ((timestamp (cdr pair
)))
3219 (let ((string (car pair
)))
3220 (format "<span class=\"timestamp-kwd\">%s</span> \
3221 <span class=\"timestamp\">%s</span> "
3223 (org-html-plain-text (org-timestamp-translate timestamp
)
3225 `((,org-closed-string .
,(org-element-property :closed planning
))
3226 (,org-deadline-string .
,(org-element-property :deadline planning
))
3227 (,org-scheduled-string .
,(org-element-property :scheduled planning
)))
3230 ;;;; Property Drawer
3232 (defun org-html-property-drawer (_property-drawer contents _info
)
3233 "Transcode a PROPERTY-DRAWER element from Org to HTML.
3234 CONTENTS holds the contents of the drawer. INFO is a plist
3235 holding contextual information."
3236 (and (org-string-nw-p contents
)
3237 (format "<pre class=\"example\">\n%s</pre>" contents
)))
3241 (defun org-html-quote-block (quote-block contents _info
)
3242 "Transcode a QUOTE-BLOCK element from Org to HTML.
3243 CONTENTS holds the contents of the block. INFO is a plist
3244 holding contextual information."
3245 (format "<blockquote%s>\n%s</blockquote>"
3246 (let* ((name (org-element-property :name quote-block
))
3247 (attributes (org-export-read-attribute :attr_html quote-block
))
3248 (a (org-html--make-attribute-string
3249 (if (or (not name
) (plist-member attributes
:id
))
3251 (plist-put attributes
:id name
)))))
3252 (if (org-string-nw-p a
) (concat " " a
) ""))
3257 (defun org-html-section (section contents info
)
3258 "Transcode a SECTION element from Org to HTML.
3259 CONTENTS holds the contents of the section. INFO is a plist
3260 holding contextual information."
3261 (let ((parent (org-export-get-parent-headline section
)))
3262 ;; Before first headline: no container, just return CONTENTS.
3263 (if (not parent
) contents
3264 ;; Get div's class and id references.
3265 (let* ((class-num (+ (org-export-get-relative-level parent info
)
3266 (1- (plist-get info
:html-toplevel-hlevel
))))
3268 (and (org-export-numbered-headline-p parent info
)
3271 (org-export-get-headline-number parent info
) "-"))))
3272 ;; Build return value.
3273 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>\n"
3275 (or (org-element-property :CUSTOM_ID parent
)
3277 (org-export-get-reference parent info
))
3278 (or contents
""))))))
3282 (defun org-html-radio-target (radio-target text info
)
3283 "Transcode a RADIO-TARGET object from Org to HTML.
3284 TEXT is the text of the target. INFO is a plist holding
3285 contextual information."
3286 (let ((ref (org-export-get-reference radio-target info
)))
3287 (org-html--anchor ref text nil info
)))
3291 (defun org-html-special-block (special-block contents info
)
3292 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3293 CONTENTS holds the contents of the block. INFO is a plist
3294 holding contextual information."
3295 (let* ((block-type (org-element-property :type special-block
))
3296 (html5-fancy (and (org-html--html5-fancy-p info
)
3297 (member block-type org-html-html5-elements
)))
3298 (attributes (org-export-read-attribute :attr_html special-block
)))
3300 (let ((class (plist-get attributes
:class
)))
3301 (setq attributes
(plist-put attributes
:class
3302 (if class
(concat class
" " block-type
)
3304 (let* ((contents (or contents
""))
3305 (name (org-element-property :name special-block
))
3306 (a (org-html--make-attribute-string
3307 (if (or (not name
) (plist-member attributes
:id
))
3309 (plist-put attributes
:id name
))))
3310 (str (if (org-string-nw-p a
) (concat " " a
) "")))
3312 (format "<%s%s>\n%s</%s>" block-type str contents block-type
)
3313 (format "<div%s>\n%s\n</div>" str contents
)))))
3317 (defun org-html-src-block (src-block _contents info
)
3318 "Transcode a SRC-BLOCK element from Org to HTML.
3319 CONTENTS holds the contents of the item. INFO is a plist holding
3320 contextual information."
3321 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3322 (org-html--textarea-block src-block
)
3323 (let ((lang (org-element-property :language src-block
))
3324 (code (org-html-format-code src-block info
))
3325 (label (let ((lbl (and (org-element-property :name src-block
)
3326 (org-export-get-reference src-block info
))))
3327 (if lbl
(format " id=\"%s\"" lbl
) ""))))
3328 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3329 (format "<div class=\"org-src-container\">\n%s%s\n</div>"
3331 (let ((caption (org-export-get-caption src-block
)))
3332 (if (not caption
) ""
3333 (let ((listing-number
3335 "<span class=\"listing-number\">%s </span>"
3337 (org-html--translate "Listing %d:" info
)
3338 (org-export-get-ordinal
3339 src-block info nil
#'org-html--has-caption-p
)))))
3340 (format "<label class=\"org-src-name\">%s%s</label>"
3342 (org-trim (org-export-data caption info
))))))
3344 (format "<pre class=\"src src-%s\"%s>%s</pre>"
3345 lang label code
))))))
3347 ;;;; Statistics Cookie
3349 (defun org-html-statistics-cookie (statistics-cookie _contents _info
)
3350 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3351 CONTENTS is nil. INFO is a plist holding contextual information."
3352 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3353 (format "<code>%s</code>" cookie-value
)))
3357 (defun org-html-strike-through (_strike-through contents info
)
3358 "Transcode STRIKE-THROUGH from Org to HTML.
3359 CONTENTS is the text with strike-through markup. INFO is a plist
3360 holding contextual information."
3362 (or (cdr (assq 'strike-through
(plist-get info
:html-text-markup-alist
)))
3368 (defun org-html-subscript (_subscript contents _info
)
3369 "Transcode a SUBSCRIPT object from Org to HTML.
3370 CONTENTS is the contents of the object. INFO is a plist holding
3371 contextual information."
3372 (format "<sub>%s</sub>" contents
))
3376 (defun org-html-superscript (_superscript contents _info
)
3377 "Transcode a SUPERSCRIPT object from Org to HTML.
3378 CONTENTS is the contents of the object. INFO is a plist holding
3379 contextual information."
3380 (format "<sup>%s</sup>" contents
))
3384 (defun org-html-table-cell (table-cell contents info
)
3385 "Transcode a TABLE-CELL element from Org to HTML.
3386 CONTENTS is nil. INFO is a plist used as a communication
3388 (let* ((table-row (org-export-get-parent table-cell
))
3389 (table (org-export-get-parent-table table-cell
))
3391 (if (not (plist-get info
:html-table-align-individual-fields
)) ""
3392 (format (if (and (boundp 'org-html-format-table-no-css
)
3393 org-html-format-table-no-css
)
3394 " align=\"%s\"" " class=\"org-%s\"")
3395 (org-export-table-cell-alignment table-cell info
)))))
3396 (when (or (not contents
) (string= "" (org-trim contents
)))
3397 (setq contents
" "))
3399 ((and (org-export-table-has-header-p table info
)
3400 (= 1 (org-export-table-row-group table-row info
)))
3401 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3402 (concat "\n" (format (car header-tags
) "col" cell-attrs
)
3404 (cdr header-tags
))))
3405 ((and (plist-get info
:html-table-use-header-tags-for-first-column
)
3406 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3407 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3408 (concat "\n" (format (car header-tags
) "row" cell-attrs
)
3410 (cdr header-tags
))))
3411 (t (let ((data-tags (plist-get info
:html-table-data-tags
)))
3412 (concat "\n" (format (car data-tags
) cell-attrs
)
3414 (cdr data-tags
)))))))
3418 (defun org-html-table-row (table-row contents info
)
3419 "Transcode a TABLE-ROW element from Org to HTML.
3420 CONTENTS is the contents of the row. INFO is a plist used as a
3421 communication channel."
3422 ;; Rules are ignored since table separators are deduced from
3423 ;; borders of the current row.
3424 (when (eq (org-element-property :type table-row
) 'standard
)
3425 (let* ((group (org-export-table-row-group table-row info
))
3426 (number (org-export-table-row-number table-row info
))
3428 (org-export-table-row-starts-rowgroup-p table-row info
))
3430 (org-export-table-row-ends-rowgroup-p table-row info
))
3431 (topp (and (equal start-group-p
'(top))
3432 (equal end-group-p
'(below top
))))
3433 (bottomp (and (equal start-group-p
'(above))
3434 (equal end-group-p
'(bottom above
))))
3436 (pcase (plist-get info
:html-table-row-open-tag
)
3437 ((and accessor
(pred functionp
))
3439 number group start-group-p end-group-p topp bottomp
))
3440 (accessor accessor
)))
3442 (pcase (plist-get info
:html-table-row-close-tag
)
3443 ((and accessor
(pred functionp
))
3445 number group start-group-p end-group-p topp bottomp
))
3446 (accessor accessor
)))
3449 ;; Row belongs to second or subsequent groups.
3450 ((not (= 1 group
)) '("<tbody>" .
"\n</tbody>"))
3451 ;; Row is from first group. Table has >=1 groups.
3452 ((org-export-table-has-header-p
3453 (org-export-get-parent-table table-row
) info
)
3454 '("<thead>" .
"\n</thead>"))
3455 ;; Row is from first and only group.
3456 (t '("<tbody>" .
"\n</tbody>")))))
3457 (concat (and start-group-p
(car group-tags
))
3463 (and end-group-p
(cdr group-tags
))))))
3467 (defun org-html-table-first-row-data-cells (table info
)
3468 "Transcode the first row of TABLE.
3469 INFO is a plist used as a communication channel."
3471 (org-element-map table
'table-row
3473 (unless (eq (org-element-property :type row
) 'rule
) row
))
3475 (special-column-p (org-export-table-has-special-column-p table
)))
3476 (if (not special-column-p
) (org-element-contents table-row
)
3477 (cdr (org-element-contents table-row
)))))
3479 (defun org-html-table--table.el-table
(table _info
)
3480 "Format table.el tables into HTML.
3481 INFO is a plist used as a communication channel."
3482 (when (eq (org-element-property :type table
) 'table.el
)
3484 (let ((outbuf (with-current-buffer
3485 (get-buffer-create "*org-export-table*")
3486 (erase-buffer) (current-buffer))))
3488 (insert (org-element-property :value table
))
3490 (re-search-forward "^[ \t]*|[^|]" nil t
)
3491 (table-generate-source 'html outbuf
))
3492 (with-current-buffer outbuf
3493 (prog1 (org-trim (buffer-string))
3496 (defun org-html-table (table contents info
)
3497 "Transcode a TABLE element from Org to HTML.
3498 CONTENTS is the contents of the table. INFO is a plist holding
3499 contextual information."
3500 (if (eq (org-element-property :type table
) 'table.el
)
3501 ;; "table.el" table. Convert it using appropriate tools.
3502 (org-html-table--table.el-table table info
)
3504 (let* ((caption (org-export-get-caption table
))
3505 (number (org-export-get-ordinal
3506 table info nil
#'org-html--has-caption-p
))
3508 (org-html--make-attribute-string
3510 (and (org-element-property :name table
)
3511 (list :id
(org-export-get-reference table info
)))
3512 (and (not (org-html-html5-p info
))
3513 (plist-get info
:html-table-attributes
))
3514 (org-export-read-attribute :attr_html table
))))
3516 (if (bound-and-true-p org-html-format-table-no-css
)
3518 "class=\"org-%s\""))
3520 (lambda (table info
)
3522 (lambda (table-cell)
3523 (let ((alignment (org-export-table-cell-alignment
3526 ;; Begin a colgroup?
3527 (when (org-export-table-cell-starts-colgroup-p
3530 ;; Add a column. Also specify its alignment.
3533 "col" (concat " " (format alignspec alignment
)) info
))
3535 (when (org-export-table-cell-ends-colgroup-p
3538 (org-html-table-first-row-data-cells table info
) "\n"))))
3539 (format "<table%s>\n%s\n%s\n%s</table>"
3540 (if (equal attributes
"") "" (concat " " attributes
))
3541 (if (not caption
) ""
3542 (format (if (plist-get info
:html-table-caption-above
)
3543 "<caption class=\"t-above\">%s</caption>"
3544 "<caption class=\"t-bottom\">%s</caption>")
3546 "<span class=\"table-number\">"
3547 (format (org-html--translate "Table %d:" info
) number
)
3548 "</span> " (org-export-data caption info
))))
3549 (funcall table-column-specs table info
)
3554 (defun org-html-target (target _contents info
)
3555 "Transcode a TARGET object from Org to HTML.
3556 CONTENTS is nil. INFO is a plist holding contextual
3558 (let ((ref (org-export-get-reference target info
)))
3559 (org-html--anchor ref nil nil info
)))
3563 (defun org-html-timestamp (timestamp _contents info
)
3564 "Transcode a TIMESTAMP object from Org to HTML.
3565 CONTENTS is nil. INFO is a plist holding contextual
3567 (let ((value (org-html-plain-text (org-timestamp-translate timestamp
) info
)))
3568 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3569 (replace-regexp-in-string "--" "–" value
))))
3573 (defun org-html-underline (_underline contents info
)
3574 "Transcode UNDERLINE from Org to HTML.
3575 CONTENTS is the text with underline markup. INFO is a plist
3576 holding contextual information."
3577 (format (or (cdr (assq 'underline
(plist-get info
:html-text-markup-alist
)))
3583 (defun org-html-verbatim (verbatim _contents info
)
3584 "Transcode VERBATIM from Org to HTML.
3585 CONTENTS is nil. INFO is a plist holding contextual
3587 (format (or (cdr (assq 'verbatim
(plist-get info
:html-text-markup-alist
))) "%s")
3588 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3592 (defun org-html-verse-block (_verse-block contents info
)
3593 "Transcode a VERSE-BLOCK element from Org to HTML.
3594 CONTENTS is verse block contents. INFO is a plist holding
3595 contextual information."
3596 (format "<p class=\"verse\">\n%s</p>"
3597 ;; Replace leading white spaces with non-breaking spaces.
3598 (replace-regexp-in-string
3599 "^[ \t]+" (lambda (m) (org-html--make-string (length m
) " "))
3600 ;; Replace each newline character with line break. Also
3601 ;; remove any trailing "br" close-tag so as to avoid
3603 (let* ((br (org-html-close-tag "br" nil info
))
3604 (re (format "\\(?:%s\\)?[ \t]*\n" (regexp-quote br
))))
3605 (replace-regexp-in-string re
(concat br
"\n") contents
)))))
3608 ;;; Filter Functions
3610 (defun org-html-final-function (contents _backend info
)
3611 "Filter to indent the HTML and convert HTML entities."
3615 (if (plist-get info
:html-indent
)
3616 (indent-region (point-min) (point-max)))
3617 (buffer-substring-no-properties (point-min) (point-max))))
3620 ;;; End-user functions
3623 (defun org-html-export-as-html
3624 (&optional async subtreep visible-only body-only ext-plist
)
3625 "Export current buffer to an HTML buffer.
3627 If narrowing is active in the current buffer, only export its
3630 If a region is active, export that region.
3632 A non-nil optional argument ASYNC means the process should happen
3633 asynchronously. The resulting buffer should be accessible
3634 through the `org-export-stack' interface.
3636 When optional argument SUBTREEP is non-nil, export the sub-tree
3637 at point, extracting information from the headline properties
3640 When optional argument VISIBLE-ONLY is non-nil, don't export
3641 contents of hidden elements.
3643 When optional argument BODY-ONLY is non-nil, only write code
3644 between \"<body>\" and \"</body>\" tags.
3646 EXT-PLIST, when provided, is a property list with external
3647 parameters overriding Org default settings, but still inferior to
3648 file-local settings.
3650 Export is done in a buffer named \"*Org HTML Export*\", which
3651 will be displayed when `org-export-show-temporary-export-buffer'
3654 (org-export-to-buffer 'html
"*Org HTML Export*"
3655 async subtreep visible-only body-only ext-plist
3656 (lambda () (set-auto-mode t
))))
3659 (defun org-html-convert-region-to-html ()
3660 "Assume the current region has Org syntax, and convert it to HTML.
3661 This can be used in any buffer. For example, you can write an
3662 itemized list in Org syntax in an HTML buffer and use this command
3665 (org-export-replace-region-by 'html
))
3668 (defun org-html-export-to-html
3669 (&optional async subtreep visible-only body-only ext-plist
)
3670 "Export current buffer to a HTML file.
3672 If narrowing is active in the current buffer, only export its
3675 If a region is active, export that region.
3677 A non-nil optional argument ASYNC means the process should happen
3678 asynchronously. The resulting file should be accessible through
3679 the `org-export-stack' interface.
3681 When optional argument SUBTREEP is non-nil, export the sub-tree
3682 at point, extracting information from the headline properties
3685 When optional argument VISIBLE-ONLY is non-nil, don't export
3686 contents of hidden elements.
3688 When optional argument BODY-ONLY is non-nil, only write code
3689 between \"<body>\" and \"</body>\" tags.
3691 EXT-PLIST, when provided, is a property list with external
3692 parameters overriding Org default settings, but still inferior to
3693 file-local settings.
3695 Return output file's name."
3697 (let* ((extension (concat "." (or (plist-get ext-plist
:html-extension
)
3700 (file (org-export-output-file-name extension subtreep
))
3701 (org-export-coding-system org-html-coding-system
))
3702 (org-export-to-file 'html file
3703 async subtreep visible-only body-only ext-plist
)))
3706 (defun org-html-publish-to-html (plist filename pub-dir
)
3707 "Publish an org file to HTML.
3709 FILENAME is the filename of the Org file to be published. PLIST
3710 is the property list for the given project. PUB-DIR is the
3711 publishing directory.
3713 Return output file name."
3714 (org-publish-org-to 'html filename
3715 (concat "." (or (plist-get plist
:html-extension
)
3724 ;; generated-autoload-file: "org-loaddefs.el"
3727 ;;; ox-html.el ends here