1 ;;; ox-html.el --- HTML Back-End for Org Export Engine -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Jambunathan K <kjambunathan at gmail dot com>
7 ;; Keywords: outlines, hypermedia, calendar, wp
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This library implements a HTML back-end for Org generic exporter.
27 ;; See Org manual for more information.
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-final-output . org-html-final-function
))
106 '(?h
"Export to HTML"
107 ((?H
"As HTML buffer" org-html-export-as-html
)
108 (?h
"As HTML file" org-html-export-to-html
)
109 (?o
"As HTML file and open"
111 (if a
(org-html-export-to-html t s v b
)
112 (org-open-file (org-html-export-to-html nil s v b
)))))))
114 '((:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
115 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
116 (:description
"DESCRIPTION" nil nil newline
)
117 (:keywords
"KEYWORDS" nil nil space
)
118 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
119 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
120 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
121 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
122 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
123 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
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-matlab:before { content: 'MATLAB'; }
343 pre.src-mscgen:before { content: 'Mscgen'; }
344 pre.src-ocaml:before { content: 'Objective Caml'; }
345 pre.src-octave:before { content: 'Octave'; }
346 pre.src-org:before { content: 'Org mode'; }
347 pre.src-oz:before { content: 'OZ'; }
348 pre.src-plantuml:before { content: 'Plantuml'; }
349 pre.src-processing:before { content: 'Processing.js'; }
350 pre.src-python:before { content: 'Python'; }
351 pre.src-R:before { content: 'R'; }
352 pre.src-ruby:before { content: 'Ruby'; }
353 pre.src-sass:before { content: 'Sass'; }
354 pre.src-scheme:before { content: 'Scheme'; }
355 pre.src-screen:before { content: 'Gnu Screen'; }
356 pre.src-sed:before { content: 'Sed'; }
357 pre.src-sh:before { content: 'shell'; }
358 pre.src-sql:before { content: 'SQL'; }
359 pre.src-sqlite:before { content: 'SQLite'; }
360 /* additional languages in org.el's org-babel-load-languages alist */
361 pre.src-forth:before { content: 'Forth'; }
362 pre.src-io:before { content: 'IO'; }
363 pre.src-J:before { content: 'J'; }
364 pre.src-makefile:before { content: 'Makefile'; }
365 pre.src-maxima:before { content: 'Maxima'; }
366 pre.src-perl:before { content: 'Perl'; }
367 pre.src-picolisp:before { content: 'Pico Lisp'; }
368 pre.src-scala:before { content: 'Scala'; }
369 pre.src-shell:before { content: 'Shell Script'; }
370 pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
371 /* additional language identifiers per \"defun org-babel-execute\"
373 pre.src-cpp:before { content: 'C++'; }
374 pre.src-abc:before { content: 'ABC'; }
375 pre.src-coq:before { content: 'Coq'; }
376 pre.src-groovy:before { content: 'Groovy'; }
377 /* additional language identifiers from org-babel-shell-names in
378 ob-shell.el: ob-shell is the only babel language using a lambda to put
379 the execution function name together. */
380 pre.src-bash:before { content: 'bash'; }
381 pre.src-csh:before { content: 'csh'; }
382 pre.src-ash:before { content: 'ash'; }
383 pre.src-dash:before { content: 'dash'; }
384 pre.src-ksh:before { content: 'ksh'; }
385 pre.src-mksh:before { content: 'mksh'; }
386 pre.src-posh:before { content: 'posh'; }
387 /* Additional Emacs modes also supported by the LaTeX listings package */
388 pre.src-ada:before { content: 'Ada'; }
389 pre.src-asm:before { content: 'Assembler'; }
390 pre.src-caml:before { content: 'Caml'; }
391 pre.src-delphi:before { content: 'Delphi'; }
392 pre.src-html:before { content: 'HTML'; }
393 pre.src-idl:before { content: 'IDL'; }
394 pre.src-mercury:before { content: 'Mercury'; }
395 pre.src-metapost:before { content: 'MetaPost'; }
396 pre.src-modula-2:before { content: 'Modula-2'; }
397 pre.src-pascal:before { content: 'Pascal'; }
398 pre.src-ps:before { content: 'PostScript'; }
399 pre.src-prolog:before { content: 'Prolog'; }
400 pre.src-simula:before { content: 'Simula'; }
401 pre.src-tcl:before { content: 'tcl'; }
402 pre.src-tex:before { content: 'TeX'; }
403 pre.src-plain-tex:before { content: 'Plain TeX'; }
404 pre.src-verilog:before { content: 'Verilog'; }
405 pre.src-vhdl:before { content: 'VHDL'; }
406 pre.src-xml:before { content: 'XML'; }
407 pre.src-nxml:before { content: 'XML'; }
408 /* add a generic configuration mode; LaTeX export needs an additional
409 (add-to-list 'org-latex-listings-langs '(conf \" \")) in .emacs */
410 pre.src-conf:before { content: 'Configuration File'; }
412 table { border-collapse:collapse; }
413 caption.t-above { caption-side: top; }
414 caption.t-bottom { caption-side: bottom; }
415 td, th { vertical-align:top; }
416 th.org-right { text-align: center; }
417 th.org-left { text-align: center; }
418 th.org-center { text-align: center; }
419 td.org-right { text-align: right; }
420 td.org-left { text-align: left; }
421 td.org-center { text-align: center; }
422 dt { font-weight: bold; }
423 .footpara { display: inline; }
424 .footdef { margin-bottom: 1em; }
425 .figure { padding: 1em; }
426 .figure p { text-align: center; }
429 border: 2px solid gray;
434 { text-align: right; font-size: 70%; white-space: nowrap; }
435 textarea { overflow-x: auto; }
436 .linenr { font-size: smaller }
437 .code-highlighted { background-color: #ffff00; }
438 .org-info-js_info-navigation { border-style: none; }
439 #org-info-js_console-label
440 { font-size: 10px; font-weight: bold; white-space: nowrap; }
441 .org-info-js_search-highlight
442 { background-color: #ffff00; color: #000000; font-weight: bold; }
445 "The default style specification for exported HTML files.
446 You can use `org-html-head' and `org-html-head-extra' to add to
447 this style. If you don't want to include this default style,
448 customize `org-html-head-include-default-style'.")
451 ;;; User Configuration Variables
453 (defgroup org-export-html nil
454 "Options for exporting Org mode files to HTML."
455 :tag
"Org Export HTML"
460 (defvar org-html-infojs-opts-table
461 '((path PATH
"http://orgmode.org/org-info.js")
465 (tdepth TOC_DEPTH
"max")
466 (sdepth SECTION_DEPTH
"max")
467 (mouse MOUSE_HINT
"underline")
468 (buttons VIEW_BUTTONS
"0")
470 (up LINK_UP
:html-link-up
)
471 (home LINK_HOME
:html-link-home
))
472 "JavaScript options, long form for script, default values.")
474 (defcustom org-html-use-infojs
'when-configured
475 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
476 This option can be nil or t to never or always use the script.
477 It can also be the symbol `when-configured', meaning that the
478 script will be linked into the export file if and only if there
479 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
480 `org-html-infojs-options'."
481 :group
'org-export-html
483 :package-version
'(Org .
"8.0")
485 (const :tag
"Never" nil
)
486 (const :tag
"When configured in buffer" when-configured
)
487 (const :tag
"Always" t
)))
489 (defcustom org-html-infojs-options
490 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
491 "Options settings for the INFOJS JavaScript.
492 Each of the options must have an entry in `org-html-infojs-opts-table'.
493 The value can either be a string that will be passed to the script, or
494 a property. This property is then assumed to be a property that is defined
495 by the Export/Publishing setup of Org.
496 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
497 means to use the maximum value consistent with other options."
498 :group
'org-export-html
500 :package-version
'(Org .
"8.0")
502 `(set :greedy t
:inline t
505 (list 'cons
(list 'const
(car x
))
507 (symbol :tag
"Publishing/Export property")
508 (string :tag
"Value"))))
509 org-html-infojs-opts-table
)))
511 (defcustom org-html-infojs-template
512 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
515 * @source: %SCRIPT_PATH
517 * @licstart The following is the entire license notice for the
518 * JavaScript code in %SCRIPT_PATH.
520 * Copyright (C) 2012-2013 Free Software Foundation, Inc.
523 * The JavaScript code in this tag is free software: you can
524 * redistribute it and/or modify it under the terms of the GNU
525 * General Public License (GNU GPL) as published by the Free Software
526 * Foundation, either version 3 of the License, or (at your option)
527 * any later version. The code is distributed WITHOUT ANY WARRANTY;
528 * without even the implied warranty of MERCHANTABILITY or FITNESS
529 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
531 * As additional permission under GNU GPL version 3 section 7, you
532 * may distribute non-source (e.g., minimized or compacted) forms of
533 * that code without the copy of the GNU GPL normally required by
534 * section 4, provided you include this license notice and a URL
535 * through which recipients can access the Corresponding Source.
537 * @licend The above is the entire license notice
538 * for the JavaScript code in %SCRIPT_PATH.
543 <script type=\"text/javascript\">
546 @licstart The following is the entire license notice for the
547 JavaScript code in this tag.
549 Copyright (C) 2012-2013 Free Software Foundation, Inc.
551 The JavaScript code in this tag is free software: you can
552 redistribute it and/or modify it under the terms of the GNU
553 General Public License (GNU GPL) as published by the Free Software
554 Foundation, either version 3 of the License, or (at your option)
555 any later version. The code is distributed WITHOUT ANY WARRANTY;
556 without even the implied warranty of MERCHANTABILITY or FITNESS
557 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
559 As additional permission under GNU GPL version 3 section 7, you
560 may distribute non-source (e.g., minimized or compacted) forms of
561 that code without the copy of the GNU GPL normally required by
562 section 4, provided you include this license notice and a URL
563 through which recipients can access the Corresponding Source.
566 @licend The above is the entire license notice
567 for the JavaScript code in this tag.
570 <!--/*--><![CDATA[/*><!--*/
572 org_html_manager.setup(); // activate after the parameters are set
575 "The template for the export style additions when org-info.js is used.
576 Option settings will replace the %MANAGER-OPTIONS cookie."
577 :group
'org-export-html
579 :package-version
'(Org .
"8.0")
582 (defun org-html-infojs-install-script (exp-plist _backend
)
583 "Install script in export options when appropriate.
584 EXP-PLIST is a plist containing export options. BACKEND is the
585 export back-end currently used."
586 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
587 (not (plist-get exp-plist
:html-use-infojs
))
588 (and (eq (plist-get exp-plist
:html-use-infojs
) 'when-configured
)
589 (let ((opt (plist-get exp-plist
:infojs-opt
)))
592 (string-match "\\<view:nil\\>" opt
)))))
593 (let* ((template (plist-get exp-plist
:html-infojs-template
))
594 (ptoc (plist-get exp-plist
:with-toc
))
595 (hlevels (plist-get exp-plist
:headline-levels
))
597 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
598 (options (plist-get exp-plist
:infojs-opt
))
599 (infojs-opt (plist-get exp-plist
:html-infojs-options
))
600 (table org-html-infojs-opts-table
)
602 (dolist (entry table
)
603 (let* ((opt (car entry
))
605 ;; Compute default values for script option OPT from
606 ;; `org-html-infojs-options' variable.
608 (let ((default (cdr (assq opt infojs-opt
))))
609 (if (and (symbolp default
) (not (memq default
'(t nil
))))
610 (plist-get exp-plist default
)
612 ;; Value set through INFOJS_OPT keyword has precedence
613 ;; over the default one.
614 (val (if (and options
615 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
617 (match-string 1 options
)
620 (`path
(setq template
621 (replace-regexp-in-string
622 "%SCRIPT_PATH" val template t t
)))
623 (`sdepth
(when (integerp (read val
))
624 (setq sdepth
(min (read val
) sdepth
))))
625 (`tdepth
(when (integerp (read val
))
626 (setq tdepth
(min (read val
) tdepth
))))
629 ((or (eq val t
) (equal val
"t")) "1")
630 ((or (eq val nil
) (equal val
"nil")) "0")
632 (t (format "%s" val
))))
633 (push (cons var val
) style
)))))
634 ;; Now we set the depth of the *generated* TOC to SDEPTH,
635 ;; because the toc will actually determine the splitting. How
636 ;; much of the toc will actually be displayed is governed by the
638 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
639 ;; The table of contents should not show more sections than we
641 (setq tdepth
(min tdepth sdepth
))
642 (push (cons "TOC_DEPTH" tdepth
) style
)
643 ;; Build style string.
644 (setq style
(mapconcat
646 (format "org_html_manager.set(\"%s\", \"%s\");"
649 (when (and style
(> (length style
) 0))
650 (and (string-match "%MANAGER_OPTIONS" template
)
651 (setq style
(replace-match style t t template
))
654 exp-plist
:html-head-extra
655 (concat (or (plist-get exp-plist
:html-head-extra
) "")
658 ;; This script absolutely needs the table of contents, so we
659 ;; change that setting.
660 (unless (plist-get exp-plist
:with-toc
)
661 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
662 ;; Return the modified property list.
667 (defcustom org-html-text-markup-alist
668 '((bold .
"<b>%s</b>")
669 (code .
"<code>%s</code>")
670 (italic .
"<i>%s</i>")
671 (strike-through .
"<del>%s</del>")
672 (underline .
"<span class=\"underline\">%s</span>")
673 (verbatim .
"<code>%s</code>"))
674 "Alist of HTML expressions to convert text markup.
676 The key must be a symbol among `bold', `code', `italic',
677 `strike-through', `underline' and `verbatim'. The value is
678 a formatting string to wrap fontified text with.
680 If no association can be found for a given markup, text will be
682 :group
'org-export-html
684 :package-version
'(Org .
"8.0")
685 :type
'(alist :key-type
(symbol :tag
"Markup type")
686 :value-type
(string :tag
"Format string"))
687 :options
'(bold code italic strike-through underline verbatim
))
689 (defcustom org-html-indent nil
690 "Non-nil means to indent the generated HTML.
691 Warning: non-nil may break indentation of source code blocks."
692 :group
'org-export-html
694 :package-version
'(Org .
"8.0")
699 (defcustom org-html-format-drawer-function
(lambda (_name contents
) contents
)
700 "Function called to format a drawer in HTML code.
702 The function must accept two parameters:
703 NAME the drawer name, like \"LOGBOOK\"
704 CONTENTS the contents of the drawer.
706 The function should return the string to be exported.
708 For example, the variable could be set to the following function
709 in order to mimic default behavior:
711 The default value simply returns the value of CONTENTS."
712 :group
'org-export-html
714 :package-version
'(Org .
"8.0")
719 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
720 <h2 class=\"footnotes\">%s: </h2>
721 <div id=\"text-footnotes\">
725 "Format for the footnotes section.
726 Should contain a two instances of %s. The first will be replaced with the
727 language-specific word for \"Footnotes\", the second one will be replaced
728 by the footnotes themselves."
729 :group
'org-export-html
732 (defcustom org-html-footnote-format
"<sup>%s</sup>"
733 "The format for the footnote reference.
734 %s will be replaced by the footnote reference itself."
735 :group
'org-export-html
738 (defcustom org-html-footnote-separator
"<sup>, </sup>"
739 "Text used to separate footnotes."
740 :group
'org-export-html
745 (defcustom org-html-toplevel-hlevel
2
746 "The <H> level for level 1 headings in HTML export.
747 This is also important for the classes that will be wrapped around headlines
748 and outline structure. If this variable is 1, the top-level headlines will
749 be <h1>, and the corresponding classes will be outline-1, section-number-1,
750 and outline-text-1. If this is 2, all of these will get a 2 instead.
751 The default for this variable is 2, because we use <h1> for formatting the
753 :group
'org-export-html
756 (defcustom org-html-format-headline-function
757 'org-html-format-headline-default-function
758 "Function to format headline text.
760 This function will be called with six arguments:
761 TODO the todo keyword (string or nil).
762 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
763 PRIORITY the priority of the headline (integer or nil)
764 TEXT the main headline text (string).
765 TAGS the tags (string or nil).
766 INFO the export options (plist).
768 The function result will be used in the section format string."
769 :group
'org-export-html
771 :package-version
'(Org .
"8.3")
776 (defcustom org-html-allow-name-attribute-in-anchors nil
777 "When nil, do not set \"name\" attribute in anchors.
778 By default, when appropriate, anchors are formatted with \"id\"
779 but without \"name\" attribute."
780 :group
'org-export-html
782 :package-version
'(Org .
"8.0")
787 (defcustom org-html-format-inlinetask-function
788 'org-html-format-inlinetask-default-function
789 "Function called to format an inlinetask in HTML code.
791 The function must accept seven parameters:
792 TODO the todo keyword, as a string
793 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
794 PRIORITY the inlinetask priority, as a string
795 NAME the inlinetask name, as a string.
796 TAGS the inlinetask tags, as a list of strings.
797 CONTENTS the contents of the inlinetask, as a string.
798 INFO the export options, as a plist
800 The function should return the string to be exported."
801 :group
'org-export-html
803 :package-version
'(Org .
"8.3")
808 (defcustom org-html-with-latex org-export-with-latex
809 "Non-nil means process LaTeX math snippets.
811 When set, the exporter will process LaTeX environments and
814 This option can also be set with the +OPTIONS line,
815 e.g. \"tex:mathjax\". Allowed values are:
817 nil Ignore math snippets.
818 `verbatim' Keep everything in verbatim
819 `mathjax', t Do MathJax preprocessing and arrange for MathJax.js to
821 SYMBOL Any symbol defined in `org-preview-latex-process-alist',
823 :group
'org-export-html
825 :package-version
'(Org .
"8.0")
827 (const :tag
"Do not process math in any way" nil
)
828 (const :tag
"Leave math verbatim" verbatim
)
829 (const :tag
"Use MathJax to display math" mathjax
)
830 (symbol :tag
"Convert to image to display math" :value dvipng
)))
832 ;;;; Links :: Generic
834 (defcustom org-html-link-org-files-as-html t
835 "Non-nil means make file links to `file.org' point to `file.html'.
836 When `org-mode' is exporting an `org-mode' file to HTML, links to
837 non-html files are directly put into a href tag in HTML.
838 However, links to other Org-mode files (recognized by the
839 extension `.org') should become links to the corresponding html
840 file, assuming that the linked `org-mode' file will also be
842 When nil, the links still point to the plain `.org' file."
843 :group
'org-export-html
846 ;;;; Links :: Inline images
848 (defcustom org-html-inline-images t
849 "Non-nil means inline images into exported HTML pages.
850 This is done using an <img> tag. When nil, an anchor with href is used to
852 :group
'org-export-html
854 :package-version
'(Org .
"8.1")
857 (defcustom org-html-inline-image-rules
858 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
859 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
860 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
861 "Rules characterizing image files that can be inlined into HTML.
862 A rule consists in an association whose key is the type of link
863 to consider, and value is a regexp that will be matched against
865 :group
'org-export-html
867 :package-version
'(Org .
"8.0")
868 :type
'(alist :key-type
(string :tag
"Type")
869 :value-type
(regexp :tag
"Path")))
873 (defvar org-html-protect-char-alist
877 "Alist of characters to be converted by `org-html-encode-plain-text'.")
881 (defcustom org-html-htmlize-output-type
'inline-css
882 "Output type to be used by htmlize when formatting code snippets.
883 Choices are `css' to export the CSS selectors only,`inline-css'
884 to export the CSS attribute values inline in the HTML or `nil' to
885 export plain text. We use as default `inline-css', in order to
886 make the resulting HTML self-containing.
888 However, this will fail when using Emacs in batch mode for export, because
889 then no rich font definitions are in place. It will also not be good if
890 people with different Emacs setup contribute HTML files to a website,
891 because the fonts will represent the individual setups. In these cases,
892 it is much better to let Org/Htmlize assign classes only, and to use
893 a style file to define the look of these classes.
894 To get a start for your css file, start Emacs session and make sure that
895 all the faces you are interested in are defined, for example by loading files
896 in all modes you want. Then, use the command
897 \\[org-html-htmlize-generate-css] to extract class definitions."
898 :group
'org-export-html
899 :type
'(choice (const css
) (const inline-css
) (const nil
)))
901 (defcustom org-html-htmlize-font-prefix
"org-"
902 "The prefix for CSS class names for htmlize font specifications."
903 :group
'org-export-html
908 (defcustom org-html-table-default-attributes
909 '(:border
"2" :cellspacing
"0" :cellpadding
"6" :rules
"groups" :frame
"hsides")
910 "Default attributes and values which will be used in table tags.
911 This is a plist where attributes are symbols, starting with
912 colons, and values are strings.
914 When exporting to HTML5, these values will be disregarded."
915 :group
'org-export-html
917 :package-version
'(Org .
"8.0")
918 :type
'(plist :key-type
(symbol :tag
"Property")
919 :value-type
(string :tag
"Value")))
921 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
922 "The opening and ending tags for table header fields.
923 This is customizable so that alignment options can be specified.
924 The first %s will be filled with the scope of the field, either row or col.
925 The second %s will be replaced by a style entry to align the field.
926 See also the variable `org-html-table-use-header-tags-for-first-column'.
927 See also the variable `org-html-table-align-individual-fields'."
928 :group
'org-export-html
929 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
931 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
932 "The opening and ending tags for table data fields.
933 This is customizable so that alignment options can be specified.
934 The first %s will be filled with the scope of the field, either row or col.
935 The second %s will be replaced by a style entry to align the field.
936 See also the variable `org-html-table-align-individual-fields'."
937 :group
'org-export-html
938 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
940 (defcustom org-html-table-row-open-tag
"<tr>"
941 "The opening tag for table rows.
942 This is customizable so that alignment options can be specified.
943 Instead of strings, these can be a Lisp function that will be
944 evaluated for each row in order to construct the table row tags.
946 The function will be called with these arguments:
948 `number': row number (0 is the first row)
949 `group-number': group number of current row
950 `start-group-p': non-nil means the row starts a group
951 `end-group-p': non-nil means the row ends a group
952 `topp': non-nil means this is the top row
953 `bottomp': non-nil means this is the bottom row
957 \(setq org-html-table-row-open-tag
958 \(lambda (number group-number start-group-p end-group-p topp bottomp)
959 \(cond (topp \"<tr class=\\\"tr-top\\\">\")
960 \(bottomp \"<tr class=\\\"tr-bottom\\\">\")
961 \(t (if (= (mod number 2) 1)
962 \"<tr class=\\\"tr-odd\\\">\"
963 \"<tr class=\\\"tr-even\\\">\")))))
965 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
966 and the bottom row, and otherwise alternate between \"tr-odd\" and
967 \"tr-even\" for odd and even rows."
968 :group
'org-export-html
969 :type
'(choice :tag
"Opening tag"
970 (string :tag
"Specify")
973 (defcustom org-html-table-row-close-tag
"</tr>"
974 "The closing tag for table rows.
975 This is customizable so that alignment options can be specified.
976 Instead of strings, this can be a Lisp function that will be
977 evaluated for each row in order to construct the table row tags.
979 See documentation of `org-html-table-row-open-tag'."
980 :group
'org-export-html
981 :type
'(choice :tag
"Closing tag"
982 (string :tag
"Specify")
985 (defcustom org-html-table-align-individual-fields t
986 "Non-nil means attach style attributes for alignment to each table field.
987 When nil, alignment will only be specified in the column tags, but this
988 is ignored by some browsers (like Firefox, Safari). Opera does it right
990 :group
'org-export-html
993 (defcustom org-html-table-use-header-tags-for-first-column nil
994 "Non-nil means format column one in tables with header tags.
995 When nil, also column one will use data tags."
996 :group
'org-export-html
999 (defcustom org-html-table-caption-above t
1000 "When non-nil, place caption string at the beginning of the table.
1001 Otherwise, place it near the end."
1002 :group
'org-export-html
1007 (defcustom org-html-tag-class-prefix
""
1008 "Prefix to class names for TODO keywords.
1009 Each tag gets a class given by the tag itself, with this prefix.
1010 The default prefix is empty because it is nice to just use the keyword
1011 as a class name. But if you get into conflicts with other, existing
1012 CSS classes, then this prefix can be very useful."
1013 :group
'org-export-html
1016 ;;;; Template :: Generic
1018 (defcustom org-html-extension
"html"
1019 "The extension for exported HTML files."
1020 :group
'org-export-html
1023 (defcustom org-html-xml-declaration
1024 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
1025 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
1026 "The extension for exported HTML files.
1027 %s will be replaced with the charset of the exported file.
1028 This may be a string, or an alist with export extensions
1029 and corresponding declarations.
1031 This declaration only applies when exporting to XHTML."
1032 :group
'org-export-html
1034 (string :tag
"Single declaration")
1035 (repeat :tag
"Dependent on extension"
1036 (cons (string :tag
"Extension")
1037 (string :tag
"Declaration")))))
1039 (defcustom org-html-coding-system
'utf-8
1040 "Coding system for HTML export.
1041 Use utf-8 as the default value."
1042 :group
'org-export-html
1044 :package-version
'(Org .
"8.0")
1045 :type
'coding-system
)
1047 (defcustom org-html-doctype
"xhtml-strict"
1048 "Document type definition to use for exported HTML files.
1049 Can be set with the in-buffer HTML_DOCTYPE property or for
1050 publishing, with :html-doctype."
1051 :group
'org-export-html
1053 :package-version
'(Org .
"8.0")
1056 (mapcar (lambda (x) `(const ,(car x
))) org-html-doctype-alist
)
1057 '((string :tag
"Custom doctype" ))))
1059 (defcustom org-html-html5-fancy nil
1060 "Non-nil means using new HTML5 elements.
1061 This variable is ignored for anything other than HTML5 export.
1063 For compatibility with Internet Explorer, it's probably a good
1064 idea to download some form of the html5shiv (for instance
1065 https://code.google.com/p/html5shiv/) and add it to your
1066 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
1067 versions 8 and below."
1068 :group
'org-export-html
1070 :package-version
'(Org .
"8.0")
1073 (defcustom org-html-container-element
"div"
1074 "HTML element to use for wrapping top level sections.
1075 Can be set with the in-buffer HTML_CONTAINER property or for
1076 publishing, with :html-container.
1078 Note that changing the default will prevent you from using
1079 org-info.js for your website."
1080 :group
'org-export-html
1082 :package-version
'(Org .
"8.0")
1085 (defcustom org-html-divs
1086 '((preamble "div" "preamble")
1087 (content "div" "content")
1088 (postamble "div" "postamble"))
1089 "Alist of the three section elements for HTML export.
1090 The car of each entry is one of `preamble', `content' or `postamble'.
1091 The cdrs of each entry are the ELEMENT_TYPE and ID for each
1092 section of the exported document.
1094 Note that changing the default will prevent you from using
1095 org-info.js for your website."
1096 :group
'org-export-html
1098 :package-version
'(Org .
"8.0")
1099 :type
'(list :greedy t
1100 (list :tag
"Preamble"
1101 (const :format
"" preamble
)
1102 (string :tag
"element") (string :tag
" id"))
1103 (list :tag
"Content"
1104 (const :format
"" content
)
1105 (string :tag
"element") (string :tag
" id"))
1106 (list :tag
"Postamble" (const :format
"" postamble
)
1107 (string :tag
" id") (string :tag
"element"))))
1109 (defconst org-html-checkbox-types
1111 ((on .
"☑") (off .
"☐") (trans .
"☐")))
1113 ((on .
"<code>[X]</code>")
1114 (off .
"<code>[ ]</code>")
1115 (trans .
"<code>[-]</code>")))
1117 ((on .
"<input type='checkbox' checked='checked' />")
1118 (off .
"<input type='checkbox' />")
1119 (trans .
"<input type='checkbox' />"))))
1120 "Alist of checkbox types.
1121 The cdr of each entry is an alist list three checkbox types for
1122 HTML export: `on', `off' and `trans'.
1125 `unicode' Unicode characters (HTML entities)
1126 `ascii' ASCII characters
1127 `html' HTML checkboxes
1129 Note that only the ascii characters implement tri-state
1130 checkboxes. The other two use the `off' checkbox for `trans'.")
1132 (defcustom org-html-checkbox-type
'ascii
1133 "The type of checkboxes to use for HTML export.
1134 See `org-html-checkbox-types' for for the values used for each
1136 :group
'org-export-html
1138 :package-version
'(Org .
"8.0")
1140 (const :tag
"ASCII characters" ascii
)
1141 (const :tag
"Unicode characters" unicode
)
1142 (const :tag
"HTML checkboxes" html
)))
1144 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
1145 "Format used for timestamps in preamble, postamble and metadata.
1146 See `format-time-string' for more information on its components."
1147 :group
'org-export-html
1149 :package-version
'(Org .
"8.0")
1152 ;;;; Template :: Mathjax
1154 (defcustom org-html-mathjax-options
1155 '((path "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" )
1159 (linebreaks "false")
1162 (multlinewidth "85%")
1165 "Options for MathJax setup.
1167 Alist of the following elements. All values are strings.
1169 path The path to MathJax.
1170 scale Scaling with HTML-CSS, MathML and SVG output engines.
1171 align How to align display math: left, center, or right.
1172 font The font to use with HTML-CSS and SVG output. As of MathJax 2.5
1173 the following values are understood: \"TeX\", \"STIX-Web\",
1174 \"Asana-Math\", \"Neo-Euler\", \"Gyre-Pagella\",
1175 \"Gyre-Termes\", and \"Latin-Modern\".
1176 linebreaks Let MathJax perform automatic linebreaks. Valid values
1177 are \"true\" and \"false\".
1178 indent If align is not center, how far from the left/right side?
1179 Valid values are \"left\" and \"right\"
1180 multlinewidth The width of the multline environment.
1181 autonumber How to number equations. Valid values are \"None\",
1182 \"all\" and \"AMS Math\".
1183 tagindent The amount tags are indented.
1184 tagside Which side to show tags/labels on. Valid values are
1185 \"left\" and \"right\"
1187 You can also customize this for each buffer, using something like
1189 #+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
1191 For further information about MathJax options, see the MathJax documentation:
1193 http://docs.mathjax.org/
1195 Please note that by using the default CDN one must agree with
1196 MathJax CDN Terms of Service.
1198 http://www.mathjax.org/mathjax-cdn-terms-of-service.html"
1199 :group
'org-export-html
1200 :package-version
'(Org .
"8.3")
1201 :type
'(list :greedy t
1202 (list :tag
"path (the path from where to load MathJax.js)"
1203 (const :format
" " path
) (string))
1204 (list :tag
"scale (scaling for the displayed math)"
1205 (const :format
" " scale
) (string))
1206 (list :tag
"align (alignment of displayed equations)"
1207 (const :format
" " align
) (string))
1208 (list :tag
"font (used to display math)"
1209 (const :format
" " font
)
1210 (choice (const "TeX")
1212 (const "Asana-Math")
1214 (const "Gyre-Pagella")
1215 (const "Gyre-Termes")
1216 (const "Latin-Modern")))
1217 (list :tag
"linebreaks (automatic line-breaking)"
1218 (const :format
" " linebreaks
)
1219 (choice (const "true")
1221 (list :tag
"autonumber (when should equations be numbered)"
1222 (const :format
" " autonumber
)
1223 (choice (const "AMS")
1226 (list :tag
"indent (indentation with left or right alignment)"
1227 (const :format
" " indent
) (string))
1228 (list :tag
"multlinewidth (width to use for the multline environment)"
1229 (const :format
" " multlinewidth
) (string))
1230 (list :tag
"tagindent (the indentation of tags from left or right)"
1231 (const :format
" " tagindent
) (string))
1232 (list :tag
"tagside (location of tags)"
1233 (const :format
" " tagside
)
1234 (choice (const "left")
1237 (defcustom org-html-mathjax-template
1238 "<script type=\"text/x-mathjax-config\">
1239 MathJax.Hub.Config({
1240 displayAlign: \"%ALIGN\",
1241 displayIndent: \"%INDENT\",
1243 \"HTML-CSS\": { scale: %SCALE,
1244 linebreaks: { automatic: \"%LINEBREAKS\" },
1247 SVG: {scale: %SCALE,
1248 linebreaks: { automatic: \"%LINEBREAKS\" },
1250 NativeMML: {scale: %SCALE},
1251 TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"},
1252 MultLineWidth: \"%MULTLINEWIDTH\",
1253 TagSide: \"%TAGSIDE\",
1254 TagIndent: \"%TAGINDENT\"
1258 <script type=\"text/javascript\"
1259 src=\"%PATH\"></script>"
1260 "The MathJax template. See also `org-html-mathjax-options'."
1261 :group
'org-export-html
1264 ;;;; Template :: Postamble
1266 (defcustom org-html-postamble
'auto
1267 "Non-nil means insert a postamble in HTML export.
1269 When set to `auto', check against the
1270 `org-export-with-author/email/creator/date' variables to set the
1271 content of the postamble. When set to a string, use this string
1272 as the postamble. When t, insert a string as defined by the
1273 formatting string in `org-html-postamble-format'.
1275 When set to a function, apply this function and insert the
1276 returned string. The function takes the property list of export
1277 options as its only argument.
1279 Setting :html-postamble in publishing projects will take
1280 precedence over this variable."
1281 :group
'org-export-html
1282 :type
'(choice (const :tag
"No postamble" nil
)
1283 (const :tag
"Auto postamble" auto
)
1284 (const :tag
"Default formatting string" t
)
1285 (string :tag
"Custom formatting string")
1286 (function :tag
"Function (must return a string)")))
1288 (defcustom org-html-postamble-format
1289 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1290 <p class=\"date\">Date: %d</p>
1291 <p class=\"creator\">%c</p>
1292 <p class=\"validation\">%v</p>"))
1293 "Alist of languages and format strings for the HTML postamble.
1295 The first element of each list is the language code, as used for
1296 the LANGUAGE keyword. See `org-export-default-language'.
1298 The second element of each list is a format string to format the
1299 postamble itself. This format string can contain these elements:
1301 %t stands for the title.
1302 %s stands for the subtitle.
1303 %a stands for the author's name.
1304 %e stands for the author's email.
1305 %d stands for the date.
1306 %c will be replaced by `org-html-creator-string'.
1307 %v will be replaced by `org-html-validation-link'.
1308 %T will be replaced by the export time.
1309 %C will be replaced by the last modification time.
1311 If you need to use a \"%\" character, you need to escape it
1313 :group
'org-export-html
1315 (list (string :tag
"Language")
1316 (string :tag
"Format string"))))
1318 (defcustom org-html-validation-link
1319 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1320 "Link to HTML validation service."
1321 :group
'org-export-html
1324 (defcustom org-html-creator-string
1325 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1327 (if (fboundp 'org-version
) (org-version) "unknown version"))
1328 "Information about the creator of the HTML document.
1329 This option can also be set on with the CREATOR keyword."
1330 :group
'org-export-html
1332 :package-version
'(Org .
"8.0")
1333 :type
'(string :tag
"Creator string"))
1335 ;;;; Template :: Preamble
1337 (defcustom org-html-preamble t
1338 "Non-nil means insert a preamble in HTML export.
1340 When t, insert a string as defined by the formatting string in
1341 `org-html-preamble-format'. When set to a string, use this
1342 formatting string instead (see `org-html-postamble-format' for an
1343 example of such a formatting string).
1345 When set to a function, apply this function and insert the
1346 returned string. The function takes the property list of export
1347 options as its only argument.
1349 Setting :html-preamble in publishing projects will take
1350 precedence over this variable."
1351 :group
'org-export-html
1352 :type
'(choice (const :tag
"No preamble" nil
)
1353 (const :tag
"Default preamble" t
)
1354 (string :tag
"Custom formatting string")
1355 (function :tag
"Function (must return a string)")))
1357 (defcustom org-html-preamble-format
'(("en" ""))
1358 "Alist of languages and format strings for the HTML preamble.
1360 The first element of each list is the language code, as used for
1361 the LANGUAGE keyword. See `org-export-default-language'.
1363 The second element of each list is a format string to format the
1364 preamble itself. This format string can contain these elements:
1366 %t stands for the title.
1367 %s stands for the subtitle.
1368 %a stands for the author's name.
1369 %e stands for the author's email.
1370 %d stands for the date.
1371 %c will be replaced by `org-html-creator-string'.
1372 %v will be replaced by `org-html-validation-link'.
1373 %T will be replaced by the export time.
1374 %C will be replaced by the last modification time.
1376 If you need to use a \"%\" character, you need to escape it
1379 See the default value of `org-html-postamble-format' for an
1381 :group
'org-export-html
1383 (list (string :tag
"Language")
1384 (string :tag
"Format string"))))
1386 (defcustom org-html-link-up
""
1387 "Where should the \"UP\" link of exported HTML pages lead?"
1388 :group
'org-export-html
1389 :type
'(string :tag
"File or URL"))
1391 (defcustom org-html-link-home
""
1392 "Where should the \"HOME\" link of exported HTML pages lead?"
1393 :group
'org-export-html
1394 :type
'(string :tag
"File or URL"))
1396 (defcustom org-html-link-use-abs-url nil
1397 "Should we prepend relative links with HTML_LINK_HOME?"
1398 :group
'org-export-html
1400 :package-version
'(Org .
"8.1")
1403 (defcustom org-html-home
/up-format
1404 "<div id=\"org-div-home-and-up\">
1405 <a accesskey=\"h\" href=\"%s\"> UP </a>
1407 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1409 "Snippet used to insert the HOME and UP links.
1410 This is a format string, the first %s will receive the UP link,
1411 the second the HOME link. If both `org-html-link-up' and
1412 `org-html-link-home' are empty, the entire snippet will be
1414 :group
'org-export-html
1417 ;;;; Template :: Scripts
1419 (defcustom org-html-head-include-scripts t
1420 "Non-nil means include the JavaScript snippets in exported HTML files.
1421 The actual script is defined in `org-html-scripts' and should
1423 :group
'org-export-html
1425 :package-version
'(Org .
"8.0")
1428 ;;;; Template :: Styles
1430 (defcustom org-html-head-include-default-style t
1431 "Non-nil means include the default style in exported HTML files.
1432 The actual style is defined in `org-html-style-default' and
1433 should not be modified. Use `org-html-head' to use your own
1435 :group
'org-export-html
1437 :package-version
'(Org .
"8.0")
1440 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1442 (defcustom org-html-head
""
1443 "Org-wide head definitions for exported HTML files.
1445 This variable can contain the full HTML structure to provide a
1446 style, including the surrounding HTML tags. You can consider
1447 including definitions for the following classes: title, todo,
1448 done, timestamp, timestamp-kwd, tag, target.
1450 For example, a valid value would be:
1452 <style type=\"text/css\">
1454 p { font-weight: normal; color: gray; }
1455 h1 { color: black; }
1456 .title { text-align: center; }
1457 .todo, .timestamp-kwd { color: red; }
1458 .done { color: green; }
1462 If you want to refer to an external style, use something like
1464 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1466 As the value of this option simply gets inserted into the HTML
1467 <head> header, you can use it to add any arbitrary text to the
1470 You can set this on a per-file basis using #+HTML_HEAD:,
1471 or for publication projects using the :html-head property."
1472 :group
'org-export-html
1474 :package-version
'(Org .
"8.0")
1477 (put 'org-html-head
'safe-local-variable
'stringp
)
1479 (defcustom org-html-head-extra
""
1480 "More head information to add in the HTML output.
1482 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1483 or for publication projects using the :html-head-extra property."
1484 :group
'org-export-html
1486 :package-version
'(Org .
"8.0")
1489 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1491 ;;;; Template :: Viewport
1493 (defcustom org-html-viewport
'((width "device-width")
1498 "Viewport options for mobile-optimized sites.
1500 The following values are recognized
1502 width Size of the viewport.
1503 initial-scale Zoom level when the page is first loaded.
1504 minimum-scale Minimum allowed zoom level.
1505 maximum-scale Maximum allowed zoom level.
1506 user-scalable Whether zoom can be changed.
1508 The viewport meta tag is inserted if this variable is non-nil.
1510 See the following site for a reference:
1511 https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag"
1512 :group
'org-export-html
1514 :package-version
'(Org .
"8.3")
1515 :type
'(choice (const :tag
"Disable" nil
)
1517 (list :tag
"Width of viewport"
1518 (const :format
" " width
)
1519 (choice (const :tag
"unset" "")
1521 (list :tag
"Initial scale"
1522 (const :format
" " initial-scale
)
1523 (choice (const :tag
"unset" "")
1525 (list :tag
"Minimum scale/zoom"
1526 (const :format
" " minimum-scale
)
1527 (choice (const :tag
"unset" "")
1529 (list :tag
"Maximum scale/zoom"
1530 (const :format
" " maximum-scale
)
1531 (choice (const :tag
"unset" "")
1533 (list :tag
"User scalable/zoomable"
1534 (const :format
" " user-scalable
)
1535 (choice (const :tag
"unset" "")
1537 (const "false"))))))
1541 (defcustom org-html-todo-kwd-class-prefix
""
1542 "Prefix to class names for TODO keywords.
1543 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1544 The default prefix is empty because it is nice to just use the keyword
1545 as a class name. But if you get into conflicts with other, existing
1546 CSS classes, then this prefix can be very useful."
1547 :group
'org-export-html
1551 ;;; Internal Functions
1553 (defun org-html-xhtml-p (info)
1554 (let ((dt (downcase (plist-get info
:html-doctype
))))
1555 (string-match-p "xhtml" dt
)))
1557 (defun org-html-html5-p (info)
1558 (let ((dt (downcase (plist-get info
:html-doctype
))))
1559 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1561 (defun org-html--html5-fancy-p (info)
1562 "Non-nil when exporting to HTML5 with fancy elements.
1563 INFO is the current state of the export process, as a plist."
1564 (and (plist-get info
:html-html5-fancy
)
1565 (org-html-html5-p info
)))
1567 (defun org-html-close-tag (tag attr info
)
1568 (concat "<" tag
" " attr
1569 (if (org-html-xhtml-p info
) " />" ">")))
1571 (defun org-html-doctype (info)
1572 "Return correct html doctype tag from `org-html-doctype-alist',
1573 or the literal value of :html-doctype from INFO if :html-doctype
1574 is not found in the alist.
1575 INFO is a plist used as a communication channel."
1576 (let ((dt (plist-get info
:html-doctype
)))
1577 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1579 (defun org-html--make-attribute-string (attributes)
1580 "Return a list of attributes, as a string.
1581 ATTRIBUTES is a plist where values are either strings or nil. An
1582 attributes with a nil value will be omitted from the result."
1584 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1585 (cond ((null item
) (pop output
))
1586 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1587 (t (let ((key (car output
))
1588 (value (replace-regexp-in-string
1589 "\"" """ (org-html-encode-plain-text item
))))
1590 (setcar output
(format "%s=\"%s\"" key value
))))))))
1592 (defun org-html--wrap-image (contents info
&optional caption label
)
1593 "Wrap CONTENTS string within an appropriate environment for images.
1594 INFO is a plist used as a communication channel. When optional
1595 arguments CAPTION and LABEL are given, use them for caption and
1597 (let ((html5-fancy (org-html--html5-fancy-p info
)))
1598 (format (if html5-fancy
"\n<figure%s>%s%s\n</figure>"
1599 "\n<div%s class=\"figure\">%s%s\n</div>")
1601 (if (org-string-nw-p label
) (format " id=\"%s\"" label
) "")
1603 (format "\n<p>%s</p>" contents
)
1605 (if (not (org-string-nw-p caption
)) ""
1606 (format (if html5-fancy
"\n<figcaption>%s</figcaption>"
1610 (defun org-html--format-image (source attributes info
)
1611 "Return \"img\" tag with given SOURCE and ATTRIBUTES.
1612 SOURCE is a string specifying the location of the image.
1613 ATTRIBUTES is a plist, as returned by
1614 `org-export-read-attribute'. INFO is a plist used as
1615 a communication channel."
1616 (if (string= "svg" (file-name-extension source
))
1617 (org-html--svg-image source attributes info
)
1620 (org-html--make-attribute-string
1623 :alt
(if (string-match-p "^ltxpng/" source
)
1624 (org-html-encode-plain-text
1625 (org-find-text-property-in-string 'org-latex-src source
))
1626 (file-name-nondirectory source
)))
1630 (defun org-html--svg-image (source attributes info
)
1631 "Return \"object\" appropriate for embedding svg file SOURCE
1632 with assoicated ATTRIBUTES. INFO is a plist used as a
1633 communication channel.
1635 The special attribute \"fallback\" can be used to specify a fallback
1636 image file to use if the object embedding is not supported."
1637 (let ((fallback (plist-get attributes
:fallback
))
1638 (attrs (org-html--make-attribute-string
1639 (plist-put attributes
:fallback nil
))))
1640 (format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>"
1644 "img" (format "src=\"%s\" %s" fallback attrs
) info
)
1645 "Sorry, your browser does not support SVG."))))
1647 (defun org-html--textarea-block (element)
1648 "Transcode ELEMENT into a textarea block.
1649 ELEMENT is either a src block or an example block."
1650 (let* ((code (car (org-export-unravel-code element
)))
1651 (attr (org-export-read-attribute :attr_html element
)))
1652 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1653 (or (plist-get attr
:width
) 80)
1654 (or (plist-get attr
:height
) (org-count-lines code
))
1657 (defun org-html--has-caption-p (element &optional _info
)
1658 "Non-nil when ELEMENT has a caption affiliated keyword.
1659 INFO is a plist used as a communication channel. This function
1660 is meant to be used as a predicate for `org-export-get-ordinal' or
1661 a value to `org-html-standalone-image-predicate'."
1662 (org-element-property :caption element
))
1666 (defun org-html-htmlize-region-for-paste (beg end
)
1667 "Convert the region between BEG and END to HTML, using htmlize.el.
1668 This is much like `htmlize-region-for-paste', only that it uses
1669 the settings define in the org-... variables."
1670 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1671 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1672 (htmlbuf (htmlize-region beg end
)))
1674 (with-current-buffer htmlbuf
1675 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1676 (plist-get htmlize-buffer-places
'content-end
)))
1677 (kill-buffer htmlbuf
))))
1680 (defun org-html-htmlize-generate-css ()
1681 "Create the CSS for all font definitions in the current Emacs session.
1682 Use this to create face definitions in your CSS style file that can then
1683 be used by code snippets transformed by htmlize.
1684 This command just produces a buffer that contains class definitions for all
1685 faces used in the current Emacs session. You can copy and paste the ones you
1686 need into your CSS file.
1688 If you then set `org-html-htmlize-output-type' to `css', calls
1689 to the function `org-html-htmlize-region-for-paste' will
1690 produce code that uses these same face definitions."
1693 (and (get-buffer "*html*") (kill-buffer "*html*"))
1695 (let ((fl (face-list))
1696 (htmlize-css-name-prefix "org-")
1697 (htmlize-output-type 'css
)
1699 (while (setq f
(pop fl
)
1700 i
(and f
(face-attribute f
:inherit
)))
1701 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1702 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1703 (htmlize-region (point-min) (point-max))))
1704 (pop-to-buffer-same-window "*html*")
1705 (goto-char (point-min))
1706 (if (re-search-forward "<style" nil t
)
1707 (delete-region (point-min) (match-beginning 0)))
1708 (if (re-search-forward "</style>" nil t
)
1709 (delete-region (1+ (match-end 0)) (point-max)))
1710 (beginning-of-line 1)
1711 (if (looking-at " +") (replace-match ""))
1712 (goto-char (point-min)))
1714 (defun org-html--make-string (n string
)
1715 "Build a string by concatenating N times STRING."
1716 (let (out) (dotimes (_ n out
) (setq out
(concat string out
)))))
1718 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1719 "Turn todo keyword KWD into a valid class name.
1720 Replaces invalid characters with \"_\"."
1722 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1723 (setq kwd
(replace-match "_" t t kwd
))))
1726 (defun org-html-footnote-section (info)
1727 "Format the footnote section.
1728 INFO is a plist used as a communication channel."
1729 (let* ((fn-alist (org-export-collect-footnote-definitions info
))
1731 (cl-loop for
(n _type raw
) in fn-alist collect
1732 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1733 (org-trim (org-export-data raw info
))
1734 (format "<div class=\"footpara\">%s</div>"
1735 (org-trim (org-export-data raw info
))))))))
1738 (plist-get info
:html-footnotes-section
)
1739 (org-html--translate "Footnotes" info
)
1744 (let ((n (car fn
)) (def (cdr fn
)))
1746 "<div class=\"footdef\">%s %s</div>\n"
1748 (plist-get info
:html-footnote-format
)
1752 (format " class=\"footnum\" href=\"#fnr.%d\"" n
)
1761 (defun org-html--build-meta-info (info)
1762 "Return meta tags for exported document.
1763 INFO is a plist used as a communication channel."
1764 (let ((protect-string
1766 (replace-regexp-in-string
1767 "\"" """ (org-html-encode-plain-text str
))))
1768 (title (org-export-data (plist-get info
:title
) info
))
1769 (author (and (plist-get info
:with-author
)
1770 (let ((auth (plist-get info
:author
)))
1772 ;; Return raw Org syntax, skipping non
1773 ;; exportable objects.
1774 (org-element-interpret-data
1775 (org-element-map auth
1776 (cons 'plain-text org-element-all-objects
)
1777 'identity info
))))))
1778 (description (plist-get info
:description
))
1779 (keywords (plist-get info
:keywords
))
1780 (charset (or (and org-html-coding-system
1781 (fboundp 'coding-system-get
)
1782 (coding-system-get org-html-coding-system
1786 (when (plist-get info
:time-stamp-file
)
1789 (plist-get info
:html-metadata-timestamp-format
)
1792 (if (org-html-html5-p info
)
1793 (org-html-close-tag "meta" "charset=\"%s\"" info
)
1795 "meta" "http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1798 (let ((viewport-options
1799 (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell
)))
1800 (plist-get info
:html-viewport
))))
1801 (and viewport-options
1805 (format "name=\"viewport\" content=\"%s\""
1807 (lambda (elm) (format "%s=%s" (car elm
) (cadr elm
)))
1808 viewport-options
", "))
1811 (format "<title>%s</title>\n" title
)
1812 (org-html-close-tag "meta" "name=\"generator\" content=\"Org-mode\"" info
)
1814 (and (org-string-nw-p author
)
1816 (org-html-close-tag "meta"
1817 (format "name=\"author\" content=\"%s\""
1818 (funcall protect-string author
))
1821 (and (org-string-nw-p description
)
1823 (org-html-close-tag "meta"
1824 (format "name=\"description\" content=\"%s\"\n"
1825 (funcall protect-string description
))
1828 (and (org-string-nw-p keywords
)
1830 (org-html-close-tag "meta"
1831 (format "name=\"keywords\" content=\"%s\""
1832 (funcall protect-string keywords
))
1836 (defun org-html--build-head (info)
1837 "Return information for the <head>..</head> of the HTML output.
1838 INFO is a plist used as a communication channel."
1839 (org-element-normalize-string
1841 (when (plist-get info
:html-head-include-default-style
)
1842 (org-element-normalize-string org-html-style-default
))
1843 (org-element-normalize-string (plist-get info
:html-head
))
1844 (org-element-normalize-string (plist-get info
:html-head-extra
))
1845 (when (and (plist-get info
:html-htmlized-css-url
)
1846 (eq org-html-htmlize-output-type
'css
))
1847 (org-html-close-tag "link"
1848 (format "rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1849 (plist-get info
:html-htmlized-css-url
))
1851 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1853 (defun org-html--build-mathjax-config (info)
1854 "Insert the user setup into the mathjax template.
1855 INFO is a plist used as a communication channel."
1856 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1857 (org-element-map (plist-get info
:parse-tree
)
1858 '(latex-fragment latex-environment
) 'identity info t
))
1859 (let ((template (plist-get info
:html-mathjax-template
))
1860 (options (plist-get info
:html-mathjax-options
))
1861 (in-buffer (or (plist-get info
:html-mathjax
) "")))
1862 (dolist (e options
(org-element-normalize-string template
))
1863 (let ((name (car e
))
1865 (when (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1867 (car (read-from-string (substring in-buffer
(match-end 0))))))
1868 (unless (stringp val
) (setq val
(format "%s" val
)))
1869 (while (string-match (concat "%" (upcase (symbol-name name
)))
1871 (setq template
(replace-match val t t template
))))))))
1873 (defun org-html-format-spec (info)
1874 "Return format specification for elements that can be
1875 used in the preamble or postamble."
1876 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1877 (?s .
,(org-export-data (plist-get info
:subtitle
) info
))
1878 (?d .
,(org-export-data (org-export-get-date info
) info
))
1879 (?T .
,(format-time-string
1880 (plist-get info
:html-metadata-timestamp-format
)))
1881 (?a .
,(org-export-data (plist-get info
:author
) info
))
1884 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1885 (split-string (plist-get info
:email
) ",+ *")
1887 (?c .
,(plist-get info
:creator
))
1888 (?C .
,(let ((file (plist-get info
:input-file
)))
1890 (plist-get info
:html-metadata-timestamp-format
)
1891 (when file
(nth 5 (file-attributes file
))))))
1892 (?v .
,(or (plist-get info
:html-validation-link
) ""))))
1894 (defun org-html--build-pre/postamble
(type info
)
1895 "Return document preamble or postamble as a string, or nil.
1896 TYPE is either `preamble' or `postamble', INFO is a plist used as a
1897 communication channel."
1898 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1899 (spec (org-html-format-spec info
)))
1901 (let ((section-contents
1902 (if (functionp section
) (funcall section info
)
1904 ((stringp section
) (format-spec section spec
))
1906 (let ((date (cdr (assq ?d spec
)))
1907 (author (cdr (assq ?a spec
)))
1908 (email (cdr (assq ?e spec
)))
1909 (creator (cdr (assq ?c spec
)))
1910 (validation-link (cdr (assq ?v spec
))))
1912 (when (and (plist-get info
:with-date
)
1913 (org-string-nw-p date
))
1914 (format "<p class=\"date\">%s: %s</p>\n"
1915 (org-html--translate "Date" info
)
1917 (when (and (plist-get info
:with-author
)
1918 (org-string-nw-p author
))
1919 (format "<p class=\"author\">%s: %s</p>\n"
1920 (org-html--translate "Author" info
)
1922 (when (and (plist-get info
:with-email
)
1923 (org-string-nw-p email
))
1924 (format "<p class=\"email\">%s: %s</p>\n"
1925 (org-html--translate "Email" info
)
1927 (when (plist-get info
:time-stamp-file
)
1929 "<p class=\"date\">%s: %s</p>\n"
1930 (org-html--translate "Created" info
)
1932 (plist-get info
:html-metadata-timestamp-format
))))
1933 (when (plist-get info
:with-creator
)
1934 (format "<p class=\"creator\">%s</p>\n" creator
))
1935 (format "<p class=\"validation\">%s</p>\n"
1938 (or (cadr (assoc-string
1939 (plist-get info
:language
)
1941 (format "org-html-%s-format" type
)))
1947 (intern (format "org-html-%s-format" type
)))
1950 (let ((div (assq type
(plist-get info
:html-divs
))))
1951 (when (org-string-nw-p section-contents
)
1953 (format "<%s id=\"%s\" class=\"%s\">\n"
1956 org-html--pre
/postamble-class
)
1957 (org-element-normalize-string section-contents
)
1958 (format "</%s>\n" (nth 1 div
)))))))))
1960 (defun org-html-inner-template (contents info
)
1961 "Return body of document string after HTML conversion.
1962 CONTENTS is the transcoded contents string. INFO is a plist
1963 holding export options."
1965 ;; Table of contents.
1966 (let ((depth (plist-get info
:with-toc
)))
1967 (when depth
(org-html-toc depth info
)))
1968 ;; Document contents.
1970 ;; Footnotes section.
1971 (org-html-footnote-section info
)))
1973 (defun org-html-template (contents info
)
1974 "Return complete document string after HTML conversion.
1975 CONTENTS is the transcoded contents string. INFO is a plist
1976 holding export options."
1978 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1979 (let* ((xml-declaration (plist-get info
:html-xml-declaration
))
1980 (decl (or (and (stringp xml-declaration
) xml-declaration
)
1981 (cdr (assoc (plist-get info
:html-extension
)
1983 (cdr (assoc "html" xml-declaration
))
1985 (when (not (or (not decl
) (string= "" decl
)))
1988 (or (and org-html-coding-system
1989 (fboundp 'coding-system-get
)
1990 (coding-system-get org-html-coding-system
'mime-charset
))
1992 (org-html-doctype info
)
1995 (cond ((org-html-xhtml-p info
)
1997 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1998 (plist-get info
:language
) (plist-get info
:language
)))
1999 ((org-html-html5-p info
)
2000 (format " lang=\"%s\"" (plist-get info
:language
))))
2003 (org-html--build-meta-info info
)
2004 (org-html--build-head info
)
2005 (org-html--build-mathjax-config info
)
2008 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
2009 (link-home (org-trim (plist-get info
:html-link-home
))))
2010 (unless (and (string= link-up
"") (string= link-home
""))
2011 (format (plist-get info
:html-home
/up-format
)
2012 (or link-up link-home
)
2013 (or link-home link-up
))))
2015 (org-html--build-pre/postamble
'preamble info
)
2016 ;; Document contents.
2017 (let ((div (assq 'content
(plist-get info
:html-divs
))))
2018 (format "<%s id=\"%s\">\n" (nth 1 div
) (nth 2 div
)))
2020 (when (plist-get info
:with-title
)
2021 (let ((title (plist-get info
:title
))
2022 (subtitle (plist-get info
:subtitle
))
2023 (html5-fancy (org-html--html5-fancy-p info
)))
2027 "<header>\n<h1 class=\"title\">%s</h1>\n%s</header>"
2028 "<h1 class=\"title\">%s%s</h1>\n")
2029 (org-export-data title info
)
2033 "<p class=\"subtitle\">%s</p>\n"
2034 "\n<br>\n<span class=\"subtitle\">%s</span>\n")
2035 (org-export-data subtitle info
))
2038 (format "</%s>\n" (nth 1 (assq 'content
(plist-get info
:html-divs
))))
2040 (org-html--build-pre/postamble
'postamble info
)
2041 ;; Closing document.
2042 "</body>\n</html>"))
2044 (defun org-html--translate (s info
)
2045 "Translate string S according to specified language.
2046 INFO is a plist used as a communication channel."
2047 (org-export-translate s
:html info
))
2051 (defun org-html--anchor (id desc attributes info
)
2052 "Format a HTML anchor."
2053 (let* ((name (and (plist-get info
:html-allow-name-attribute-in-anchors
) id
))
2054 (attributes (concat (and id
(format " id=\"%s\"" id
))
2055 (and name
(format " name=\"%s\"" name
))
2057 (format "<a%s>%s</a>" attributes
(or desc
""))))
2061 (defun org-html--todo (todo info
)
2062 "Format TODO keywords into HTML."
2064 (format "<span class=\"%s %s%s\">%s</span>"
2065 (if (member todo org-done-keywords
) "done" "todo")
2066 (or (plist-get info
:html-todo-kwd-class-prefix
) "")
2067 (org-html-fix-class-name todo
)
2072 (defun org-html--priority (priority _info
)
2073 "Format a priority into HTML.
2074 PRIORITY is the character code of the priority or nil. INFO is
2075 a plist containing export options."
2076 (and priority
(format "<span class=\"priority\">[%c]</span>" priority
)))
2080 (defun org-html--tags (tags info
)
2081 "Format TAGS into HTML.
2082 INFO is a plist containing export options."
2084 (format "<span class=\"tag\">%s</span>"
2087 (format "<span class=\"%s\">%s</span>"
2088 (concat (plist-get info
:html-tag-class-prefix
)
2089 (org-html-fix-class-name tag
))
2095 (defun org-html-fontify-code (code lang
)
2096 "Color CODE with htmlize library.
2097 CODE is a string representing the source code to colorize. LANG
2098 is the language used for CODE, as a string, or nil."
2101 ;; Case 1: No lang. Possibly an example block.
2103 ;; Simple transcoding.
2104 (org-html-encode-plain-text code
))
2105 ;; Case 2: No htmlize or an inferior version of htmlize
2106 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
2108 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
2109 ;; Simple transcoding.
2110 (org-html-encode-plain-text code
))
2111 ;; Case 3: plain text explicitly set
2112 ((not org-html-htmlize-output-type
)
2113 ;; Simple transcoding.
2114 (org-html-encode-plain-text code
))
2117 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
2118 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
2120 ;; Case 1: Language is not associated with any Emacs mode
2121 ((not (functionp lang-mode
))
2122 ;; Simple transcoding.
2123 (org-html-encode-plain-text code
))
2124 ;; Case 2: Default. Fontify code.
2128 (let ((output-type org-html-htmlize-output-type
)
2129 (font-prefix org-html-htmlize-font-prefix
))
2131 ;; Switch to language-specific mode.
2135 (org-font-lock-ensure)
2136 ;; Remove formatting on newline characters.
2138 (let ((beg (point-min))
2141 (while (progn (end-of-line) (< (point) end
))
2142 (put-text-property (point) (1+ (point)) 'face nil
)
2145 (set-buffer-modified-p nil
)
2147 (let ((org-html-htmlize-output-type output-type
)
2148 (org-html-htmlize-font-prefix font-prefix
))
2149 (org-html-htmlize-region-for-paste
2150 (point-min) (point-max))))))
2151 ;; Strip any enclosing <pre></pre> tags.
2152 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
2153 (end (and beg
(string-match "</pre>\\'" code
))))
2154 (if (and beg end
) (substring code beg end
) code
)))))))))
2156 (defun org-html-do-format-code
2157 (code &optional lang refs retain-labels num-start
)
2158 "Format CODE string as source code.
2159 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
2160 respectively, the language of the source code, as a string, an
2161 alist between line numbers and references (as returned by
2162 `org-export-unravel-code'), a boolean specifying if labels should
2163 appear in the source code, and the number associated to the first
2165 (let* ((code-lines (org-split-string code
"\n"))
2166 (code-length (length code-lines
))
2170 (length (number-to-string (+ code-length num-start
))))))
2171 (code (org-html-fontify-code code lang
)))
2172 (org-export-format-code
2174 (lambda (loc line-num ref
)
2177 ;; Add line number, if needed.
2179 (format "<span class=\"linenr\">%s</span>"
2180 (format num-fmt line-num
)))
2181 ;; Transcoded src line.
2183 ;; Add label, if needed.
2184 (when (and ref retain-labels
) (format " (%s)" ref
))))
2185 ;; Mark transcoded line as an anchor, if needed.
2187 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
2191 (defun org-html-format-code (element info
)
2192 "Format contents of ELEMENT as source code.
2193 ELEMENT is either an example block or a src block. INFO is
2194 a plist used as a communication channel."
2195 (let* ((lang (org-element-property :language element
))
2196 ;; Extract code and references.
2197 (code-info (org-export-unravel-code element
))
2198 (code (car code-info
))
2199 (refs (cdr code-info
))
2200 ;; Does the src block contain labels?
2201 (retain-labels (org-element-property :retain-labels element
))
2202 ;; Does it have line numbers?
2203 (num-start (org-export-get-loc element info
)))
2204 (org-html-do-format-code code lang refs retain-labels num-start
)))
2207 ;;; Tables of Contents
2209 (defun org-html-toc (depth info
&optional scope
)
2210 "Build a table of contents.
2211 DEPTH is an integer specifying the depth of the table. INFO is
2212 a plist used as a communication channel. Optional argument SCOPE
2213 is an element defining the scope of the table. Return the table
2214 of contents as a string, or nil if it is empty."
2216 (mapcar (lambda (headline)
2217 (cons (org-html--format-toc-headline headline info
)
2218 (org-export-get-relative-level headline info
)))
2219 (org-export-collect-headlines info depth scope
))))
2221 (let ((toc (concat "<div id=\"text-table-of-contents\">"
2222 (org-html--toc-text toc-entries
)
2225 (let ((outer-tag (if (org-html--html5-fancy-p info
)
2228 (concat (format "<%s id=\"table-of-contents\">\n" outer-tag
)
2229 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2230 (format "<h%d>%s</h%d>\n"
2232 (org-html--translate "Table of Contents" info
)
2235 (format "</%s>\n" outer-tag
))))))))
2237 (defun org-html--toc-text (toc-entries)
2238 "Return innards of a table of contents, as a string.
2239 TOC-ENTRIES is an alist where key is an entry title, as a string,
2240 and value is its relative level, as an integer."
2241 (let* ((prev-level (1- (cdar toc-entries
)))
2242 (start-level prev-level
))
2246 (let ((headline (car entry
))
2247 (level (cdr entry
)))
2249 (let* ((cnt (- level prev-level
))
2250 (times (if (> cnt
0) (1- cnt
) (- cnt
))))
2251 (setq prev-level level
)
2253 (org-html--make-string
2254 times
(cond ((> cnt
0) "\n<ul>\n<li>")
2255 ((< cnt
0) "</li>\n</ul>\n")))
2256 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
2259 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
2261 (defun org-html--format-toc-headline (headline info
)
2262 "Return an appropriate table of contents entry for HEADLINE.
2263 INFO is a plist used as a communication channel."
2264 (let* ((headline-number (org-export-get-headline-number headline info
))
2265 (todo (and (plist-get info
:with-todo-keywords
)
2266 (let ((todo (org-element-property :todo-keyword headline
)))
2267 (and todo
(org-export-data todo info
)))))
2268 (todo-type (and todo
(org-element-property :todo-type headline
)))
2269 (priority (and (plist-get info
:with-priority
)
2270 (org-element-property :priority headline
)))
2271 (text (org-export-data-with-backend
2272 (org-export-get-alt-title headline info
)
2273 ;; Create an anonymous back-end that will ignore any
2274 ;; footnote-reference, link, radio-target and target
2275 ;; in table of contents.
2276 (org-export-create-backend
2278 :transcoders
'((footnote-reference . ignore
)
2279 (link .
(lambda (object c i
) c
))
2280 (radio-target .
(lambda (object c i
) c
))
2283 (tags (and (eq (plist-get info
:with-tags
) t
)
2284 (org-export-get-tags headline info
))))
2285 (format "<a href=\"#%s\">%s</a>"
2287 (or (org-element-property :CUSTOM_ID headline
)
2288 (org-export-get-reference headline info
))
2291 (and (not (org-export-low-level-p headline info
))
2292 (org-export-numbered-headline-p headline info
)
2293 (concat (mapconcat #'number-to-string headline-number
".")
2295 (apply (plist-get info
:html-format-headline-function
)
2296 todo todo-type priority text tags
:section-number nil
)))))
2298 (defun org-html-list-of-listings (info)
2299 "Build a list of listings.
2300 INFO is a plist used as a communication channel. Return the list
2301 of listings as a string, or nil if it is empty."
2302 (let ((lol-entries (org-export-collect-listings info
)))
2304 (concat "<div id=\"list-of-listings\">\n"
2305 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2306 (format "<h%d>%s</h%d>\n"
2308 (org-html--translate "List of Listings" info
)
2310 "<div id=\"text-list-of-listings\">\n<ul>\n"
2312 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2313 (org-html--translate "Listing %d:" info
))))
2316 (let ((label (and (org-element-property :name entry
)
2317 (org-export-get-reference entry info
)))
2320 (or (org-export-get-caption entry t
)
2321 (org-export-get-caption entry
))
2326 (concat (format initial-fmt
(cl-incf count
))
2329 (format "<a href=\"#%s\">%s %s</a>"
2331 (format initial-fmt
(cl-incf count
))
2335 "\n</ul>\n</div>\n</div>"))))
2337 (defun org-html-list-of-tables (info)
2338 "Build a list of tables.
2339 INFO is a plist used as a communication channel. Return the list
2340 of tables as a string, or nil if it is empty."
2341 (let ((lol-entries (org-export-collect-tables info
)))
2343 (concat "<div id=\"list-of-tables\">\n"
2344 (let ((top-level (plist-get info
:html-toplevel-hlevel
)))
2345 (format "<h%d>%s</h%d>\n"
2347 (org-html--translate "List of Tables" info
)
2349 "<div id=\"text-list-of-tables\">\n<ul>\n"
2351 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2352 (org-html--translate "Table %d:" info
))))
2355 (let ((label (and (org-element-property :name entry
)
2356 (org-export-get-reference entry info
)))
2359 (or (org-export-get-caption entry t
)
2360 (org-export-get-caption entry
))
2365 (concat (format initial-fmt
(cl-incf count
))
2368 (format "<a href=\"#%s\">%s %s</a>"
2370 (format initial-fmt
(cl-incf count
))
2374 "\n</ul>\n</div>\n</div>"))))
2377 ;;; Transcode Functions
2381 (defun org-html-bold (_bold contents info
)
2382 "Transcode BOLD from Org to HTML.
2383 CONTENTS is the text with bold markup. INFO is a plist holding
2384 contextual information."
2385 (format (or (cdr (assq 'bold
(plist-get info
:html-text-markup-alist
))) "%s")
2390 (defun org-html-center-block (_center-block contents _info
)
2391 "Transcode a CENTER-BLOCK element from Org to HTML.
2392 CONTENTS holds the contents of the block. INFO is a plist
2393 holding contextual information."
2394 (format "<div class=\"org-center\">\n%s</div>" contents
))
2398 (defun org-html-clock (clock _contents _info
)
2399 "Transcode a CLOCK element from Org to HTML.
2400 CONTENTS is nil. INFO is a plist used as a communication
2403 <span class=\"timestamp-wrapper\">
2404 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2408 (org-timestamp-translate (org-element-property :value clock
))
2409 (let ((time (org-element-property :duration clock
)))
2410 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2414 (defun org-html-code (code _contents info
)
2415 "Transcode CODE from Org to HTML.
2416 CONTENTS is nil. INFO is a plist holding contextual
2418 (format (or (cdr (assq 'code
(plist-get info
:html-text-markup-alist
))) "%s")
2419 (org-html-encode-plain-text (org-element-property :value code
))))
2423 (defun org-html-drawer (drawer contents info
)
2424 "Transcode a DRAWER element from Org to HTML.
2425 CONTENTS holds the contents of the block. INFO is a plist
2426 holding contextual information."
2427 (funcall (plist-get info
:html-format-drawer-function
)
2428 (org-element-property :drawer-name drawer
)
2433 (defun org-html-dynamic-block (_dynamic-block contents _info
)
2434 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2435 CONTENTS holds the contents of the block. INFO is a plist
2436 holding contextual information. See `org-export-data'."
2441 (defun org-html-entity (entity _contents _info
)
2442 "Transcode an ENTITY object from Org to HTML.
2443 CONTENTS are the definition itself. INFO is a plist holding
2444 contextual information."
2445 (org-element-property :html entity
))
2449 (defun org-html-example-block (example-block _contents info
)
2450 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2451 CONTENTS is nil. INFO is a plist holding contextual
2453 (let ((attributes (org-export-read-attribute :attr_html example-block
)))
2454 (if (plist-get attributes
:textarea
)
2455 (org-html--textarea-block example-block
)
2456 (format "<pre class=\"example\"%s>\n%s</pre>"
2457 (let* ((name (org-element-property :name example-block
))
2458 (a (org-html--make-attribute-string
2459 (if (or (not name
) (plist-member attributes
:id
))
2461 (plist-put attributes
:id name
)))))
2462 (if (org-string-nw-p a
) (concat " " a
) ""))
2463 (org-html-format-code example-block info
)))))
2467 (defun org-html-export-snippet (export-snippet _contents _info
)
2468 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2469 CONTENTS is nil. INFO is a plist holding contextual
2471 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2472 (org-element-property :value export-snippet
)))
2476 (defun org-html-export-block (export-block _contents _info
)
2477 "Transcode a EXPORT-BLOCK element from Org to HTML.
2478 CONTENTS is nil. INFO is a plist holding contextual information."
2479 (when (string= (org-element-property :type export-block
) "HTML")
2480 (org-remove-indentation (org-element-property :value export-block
))))
2484 (defun org-html-fixed-width (fixed-width _contents _info
)
2485 "Transcode a FIXED-WIDTH element from Org to HTML.
2486 CONTENTS is nil. INFO is a plist holding contextual information."
2487 (format "<pre class=\"example\">\n%s</pre>"
2488 (org-html-do-format-code
2489 (org-remove-indentation
2490 (org-element-property :value fixed-width
)))))
2492 ;;;; Footnote Reference
2494 (defun org-html-footnote-reference (footnote-reference _contents info
)
2495 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2496 CONTENTS is nil. INFO is a plist holding contextual information."
2498 ;; Insert separator between two footnotes in a row.
2499 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2500 (when (eq (org-element-type prev
) 'footnote-reference
)
2501 (plist-get info
:html-footnote-separator
)))
2502 (let* ((n (org-export-get-footnote-number footnote-reference info
))
2503 (id (format "fnr.%d%s"
2505 (if (org-export-footnote-first-reference-p
2506 footnote-reference info
)
2510 (plist-get info
:html-footnote-format
)
2512 id n
(format " class=\"footref\" href=\"#fn.%d\"" n
) info
)))))
2516 (defun org-html-headline (headline contents info
)
2517 "Transcode a HEADLINE element from Org to HTML.
2518 CONTENTS holds the contents of the headline. INFO is a plist
2519 holding contextual information."
2520 (unless (org-element-property :footnote-section-p headline
)
2521 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2522 (numbers (org-export-get-headline-number headline info
))
2523 (level (+ (org-export-get-relative-level headline info
)
2524 (1- (plist-get info
:html-toplevel-hlevel
))))
2525 (todo (and (plist-get info
:with-todo-keywords
)
2526 (let ((todo (org-element-property :todo-keyword headline
)))
2527 (and todo
(org-export-data todo info
)))))
2528 (todo-type (and todo
(org-element-property :todo-type headline
)))
2529 (priority (and (plist-get info
:with-priority
)
2530 (org-element-property :priority headline
)))
2531 (text (org-export-data (org-element-property :title headline
) info
))
2532 (tags (and (plist-get info
:with-tags
)
2533 (org-export-get-tags headline info
)))
2534 (full-text (funcall (plist-get info
:html-format-headline-function
)
2535 todo todo-type priority text tags info
))
2536 (contents (or contents
""))
2538 (list (org-element-property :CUSTOM_ID headline
)
2539 (org-export-get-reference headline info
)
2540 (org-element-property :ID headline
))))
2541 (preferred-id (car ids
))
2546 (if (org-uuidgen-p id
) (concat "ID-" id
) id
)
2549 (if (org-export-low-level-p headline info
)
2550 ;; This is a deep sub-tree: export it as a list item.
2551 (let* ((type (if numberedp
'ordered
'unordered
))
2553 (org-html-format-list-item
2554 contents type nil info nil
2555 (concat (org-html--anchor preferred-id nil nil info
)
2558 (concat (and (org-export-first-sibling-p headline info
)
2559 (org-html-begin-plain-list type
))
2561 (and (org-export-last-sibling-p headline info
)
2562 (org-html-end-plain-list type
))))
2563 (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2564 (first-content (car (org-element-contents headline
))))
2565 ;; Standard headline. Export it as a section.
2566 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2567 (org-html--container headline info
)
2568 (concat "outline-container-"
2569 (org-export-get-reference headline info
))
2570 (concat (format "outline-%d" level
)
2571 (and extra-class
" ")
2573 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2580 "<span class=\"section-number-%d\">%s</span> "
2582 (mapconcat #'number-to-string numbers
".")))
2585 ;; When there is no section, pretend there is an
2586 ;; empty one to get the correct <div
2587 ;; class="outline-...> which is needed by
2589 (if (eq (org-element-type first-content
) 'section
) contents
2590 (concat (org-html-section first-content
"" info
) contents
))
2591 (org-html--container headline info
)))))))
2593 (defun org-html-format-headline-default-function
2594 (todo _todo-type priority text tags info
)
2595 "Default format function for a headline.
2596 See `org-html-format-headline-function' for details."
2597 (let ((todo (org-html--todo todo info
))
2598 (priority (org-html--priority priority info
))
2599 (tags (org-html--tags tags info
)))
2600 (concat todo
(and todo
" ")
2601 priority
(and priority
" ")
2603 (and tags
"   ") tags
)))
2605 (defun org-html--container (headline info
)
2606 (or (org-element-property :HTML_CONTAINER headline
)
2607 (if (= 1 (org-export-get-relative-level headline info
))
2608 (plist-get info
:html-container
)
2611 ;;;; Horizontal Rule
2613 (defun org-html-horizontal-rule (_horizontal-rule _contents info
)
2614 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2615 CONTENTS is nil. INFO is a plist holding contextual information."
2616 (org-html-close-tag "hr" nil info
))
2618 ;;;; Inline Src Block
2620 (defun org-html-inline-src-block (inline-src-block _contents info
)
2621 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2622 CONTENTS holds the contents of the item. INFO is a plist holding
2623 contextual information."
2624 (let ((lang (org-element-property :language inline-src-block
))
2625 (code (org-html-format-code inline-src-block info
))
2627 (let ((lbl (and (org-element-property :name inline-src-block
)
2628 (org-export-get-reference inline-src-block info
))))
2629 (if (not lbl
) "" (format " id=\"%s\"" lbl
)))))
2630 (format "<code class=\"src src-%s\"%s>%s</code>" lang label code
)))
2634 (defun org-html-inlinetask (inlinetask contents info
)
2635 "Transcode an INLINETASK element from Org to HTML.
2636 CONTENTS holds the contents of the block. INFO is a plist
2637 holding contextual information."
2638 (let* ((todo (and (plist-get info
:with-todo-keywords
)
2639 (let ((todo (org-element-property :todo-keyword inlinetask
)))
2640 (and todo
(org-export-data todo info
)))))
2641 (todo-type (and todo
(org-element-property :todo-type inlinetask
)))
2642 (priority (and (plist-get info
:with-priority
)
2643 (org-element-property :priority inlinetask
)))
2644 (text (org-export-data (org-element-property :title inlinetask
) info
))
2645 (tags (and (plist-get info
:with-tags
)
2646 (org-export-get-tags inlinetask info
))))
2647 (funcall (plist-get info
:html-format-inlinetask-function
)
2648 todo todo-type priority text tags contents info
)))
2650 (defun org-html-format-inlinetask-default-function
2651 (todo todo-type priority text tags contents info
)
2652 "Default format function for a inlinetasks.
2653 See `org-html-format-inlinetask-function' for details."
2654 (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2655 (org-html-format-headline-default-function
2656 todo todo-type priority text tags info
)
2657 (org-html-close-tag "br" nil info
)
2662 (defun org-html-italic (_italic contents info
)
2663 "Transcode ITALIC from Org to HTML.
2664 CONTENTS is the text with italic markup. INFO is a plist holding
2665 contextual information."
2667 (or (cdr (assq 'italic
(plist-get info
:html-text-markup-alist
))) "%s")
2672 (defun org-html-checkbox (checkbox info
)
2673 "Format CHECKBOX into HTML.
2674 INFO is a plist holding contextual information. See
2675 `org-html-checkbox-type' for customization options."
2677 (cdr (assq (plist-get info
:html-checkbox-type
)
2678 org-html-checkbox-types
)))))
2680 (defun org-html-format-list-item (contents type checkbox info
2681 &optional term-counter-id
2683 "Format a list item into HTML."
2684 (let ((class (if checkbox
2685 (format " class=\"%s\""
2686 (symbol-name checkbox
)) ""))
2687 (checkbox (concat (org-html-checkbox checkbox info
)
2688 (and checkbox
" ")))
2689 (br (org-html-close-tag "br" nil info
)))
2693 (let* ((counter term-counter-id
)
2694 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2696 (format "<li%s%s>" class extra
)
2697 (when headline
(concat headline br
)))))
2699 (let* ((id term-counter-id
)
2700 (extra (if id
(format " id=\"%s\"" id
) "")))
2702 (format "<li%s%s>" class extra
)
2703 (when headline
(concat headline br
)))))
2705 (let* ((term term-counter-id
))
2706 (setq term
(or term
"(no term)"))
2707 ;; Check-boxes in descriptive lists are associated to tag.
2708 (concat (format "<dt%s>%s</dt>"
2709 class
(concat checkbox term
))
2711 (unless (eq type
'descriptive
) checkbox
)
2712 (and contents
(org-trim contents
))
2715 (`unordered
"</li>")
2716 (`descriptive
"</dd>")))))
2718 (defun org-html-item (item contents info
)
2719 "Transcode an ITEM element from Org to HTML.
2720 CONTENTS holds the contents of the item. INFO is a plist holding
2721 contextual information."
2722 (let* ((plain-list (org-export-get-parent item
))
2723 (type (org-element-property :type plain-list
))
2724 (counter (org-element-property :counter item
))
2725 (checkbox (org-element-property :checkbox item
))
2726 (tag (let ((tag (org-element-property :tag item
)))
2727 (and tag
(org-export-data tag info
)))))
2728 (org-html-format-list-item
2729 contents type checkbox info
(or tag counter
))))
2733 (defun org-html-keyword (keyword _contents info
)
2734 "Transcode a KEYWORD element from Org to HTML.
2735 CONTENTS is nil. INFO is a plist holding contextual information."
2736 (let ((key (org-element-property :key keyword
))
2737 (value (org-element-property :value keyword
)))
2739 ((string= key
"HTML") value
)
2740 ((string= key
"TOC")
2741 (let ((case-fold-search t
))
2743 ((string-match "\\<headlines\\>" value
)
2744 (let ((depth (and (string-match "\\<[0-9]+\\>" value
)
2745 (string-to-number (match-string 0 value
))))
2746 (localp (string-match-p "\\<local\\>" value
)))
2747 (org-html-toc depth info
(and localp keyword
))))
2748 ((string= "listings" value
) (org-html-list-of-listings info
))
2749 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2751 ;;;; Latex Environment
2753 (defun org-html-format-latex (latex-frag processing-type info
)
2754 "Format a LaTeX fragment LATEX-FRAG into HTML.
2755 PROCESSING-TYPE designates the tool used for conversion. It can
2756 be `mathjax', `verbatim', nil, t or symbols in
2757 `org-preview-latex-process-alist', e.g., `dvipng', `dvisvgm' or
2758 `imagemagick'. See `org-html-with-latex' for more information.
2759 INFO is a plist containing export properties."
2760 (let ((cache-relpath "") (cache-dir ""))
2761 (unless (eq processing-type
'mathjax
)
2762 (let ((bfn (or (buffer-file-name)
2764 (expand-file-name "latex" temporary-file-directory
))))
2766 (let ((header (plist-get info
:latex-header
)))
2769 (lambda (line) (concat "#+LATEX_HEADER: " line
))
2770 (org-split-string header
"\n")
2774 (concat (file-name-as-directory org-preview-latex-image-directory
)
2775 (file-name-sans-extension
2776 (file-name-nondirectory bfn
)))
2777 cache-dir
(file-name-directory bfn
))
2778 ;; Re-create LaTeX environment from original buffer in
2779 ;; temporary buffer so that dvipng/imagemagick can properly
2780 ;; turn the fragment into an image.
2781 (setq latex-frag
(concat latex-header latex-frag
))))
2784 (org-format-latex cache-relpath nil nil cache-dir nil
2785 "Creating LaTeX Image..." nil processing-type
)
2788 (defun org-html-latex-environment (latex-environment _contents info
)
2789 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2790 CONTENTS is nil. INFO is a plist holding contextual information."
2791 (let ((processing-type (plist-get info
:with-latex
))
2792 (latex-frag (org-remove-indentation
2793 (org-element-property :value latex-environment
)))
2794 (attributes (org-export-read-attribute :attr_html latex-environment
)))
2796 ((memq processing-type
'(t mathjax
))
2797 (org-html-format-latex latex-frag
'mathjax info
))
2798 ((assq processing-type org-preview-latex-process-alist
)
2800 (org-html-format-latex latex-frag processing-type info
)))
2801 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2802 ;; Do not provide a caption or a name to be consistent with
2803 ;; `mathjax' handling.
2804 (org-html--wrap-image
2805 (org-html--format-image
2806 (match-string 1 formula-link
) attributes info
) info
))))
2811 (defun org-html-latex-fragment (latex-fragment _contents info
)
2812 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2813 CONTENTS is nil. INFO is a plist holding contextual information."
2814 (let ((latex-frag (org-element-property :value latex-fragment
))
2815 (processing-type (plist-get info
:with-latex
)))
2817 ((memq processing-type
'(t mathjax
))
2818 (org-html-format-latex latex-frag
'mathjax info
))
2819 ((assq processing-type org-preview-latex-process-alist
)
2821 (org-html-format-latex latex-frag processing-type info
)))
2822 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2823 (org-html--format-image (match-string 1 formula-link
) nil info
))))
2828 (defun org-html-line-break (_line-break _contents info
)
2829 "Transcode a LINE-BREAK object from Org to HTML.
2830 CONTENTS is nil. INFO is a plist holding contextual information."
2831 (concat (org-html-close-tag "br" nil info
) "\n"))
2835 (defun org-html-inline-image-p (link info
)
2836 "Non-nil when LINK is meant to appear as an image.
2837 INFO is a plist used as a communication channel. LINK is an
2838 inline image when it has no description and targets an image
2839 file (see `org-html-inline-image-rules' for more information), or
2840 if its description is a single link targeting an image file."
2841 (if (not (org-element-contents link
))
2842 (org-export-inline-image-p
2843 link
(plist-get info
:html-inline-image-rules
))
2845 (let ((link-count 0))
2846 (org-element-map (org-element-contents link
)
2847 (cons 'plain-text org-element-all-objects
)
2849 (pcase (org-element-type obj
)
2850 (`plain-text
(org-string-nw-p obj
))
2851 (`link
(if (= link-count
1) t
2852 (cl-incf link-count
)
2853 (not (org-export-inline-image-p
2854 obj
(plist-get info
:html-inline-image-rules
)))))
2858 (defvar org-html-standalone-image-predicate
)
2859 (defun org-html-standalone-image-p (element info
)
2860 "Non-nil if ELEMENT is a standalone image.
2862 INFO is a plist holding contextual information.
2864 An element or object is a standalone image when
2866 - its type is `paragraph' and its sole content, save for white
2867 spaces, is a link that qualifies as an inline image;
2869 - its type is `link' and its containing paragraph has no other
2870 content save white spaces.
2872 Bind `org-html-standalone-image-predicate' to constrain paragraph
2873 further. For example, to check for only captioned standalone
2876 (lambda (paragraph) (org-element-property :caption paragraph))"
2877 (let ((paragraph (pcase (org-element-type element
)
2878 (`paragraph element
)
2879 (`link
(org-export-get-parent element
)))))
2880 (and (eq (org-element-type paragraph
) 'paragraph
)
2881 (or (not (fboundp 'org-html-standalone-image-predicate
))
2882 (funcall org-html-standalone-image-predicate paragraph
))
2884 (let ((link-count 0))
2885 (org-element-map (org-element-contents paragraph
)
2886 (cons 'plain-text org-element-all-objects
)
2888 (when (pcase (org-element-type obj
)
2889 (`plain-text
(org-string-nw-p obj
))
2890 (`link
(or (> (cl-incf link-count
) 1)
2891 (not (org-html-inline-image-p obj info
))))
2895 (= link-count
1))))))
2897 (defun org-html-link (link desc info
)
2898 "Transcode a LINK object from Org to HTML.
2899 DESC is the description part of the link, or the empty string.
2900 INFO is a plist holding contextual information. See
2902 (let* ((home (when (plist-get info
:html-link-home
)
2903 (org-trim (plist-get info
:html-link-home
))))
2904 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2905 (link-org-files-as-html-maybe
2906 (lambda (raw-path info
)
2907 ;; Treat links to `file.org' as links to `file.html', if
2908 ;; needed. See `org-html-link-org-files-as-html'.
2910 ((and (plist-get info
:html-link-org-files-as-html
)
2912 (downcase (file-name-extension raw-path
"."))))
2913 (concat (file-name-sans-extension raw-path
) "."
2914 (plist-get info
:html-extension
)))
2916 (type (org-element-property :type link
))
2917 (raw-path (org-element-property :path link
))
2918 ;; Ensure DESC really exists, or set it to nil.
2919 (desc (org-string-nw-p desc
))
2922 ((member type
'("http" "https" "ftp" "mailto" "news"))
2923 (url-encode-url (org-link-unescape (concat type
":" raw-path
))))
2924 ((string= type
"file")
2925 ;; Treat links to ".org" files as ".html", if needed.
2927 (funcall link-org-files-as-html-maybe raw-path info
))
2928 ;; If file path is absolute, prepend it with protocol
2929 ;; component - "file://".
2931 ((file-name-absolute-p raw-path
)
2932 (setq raw-path
(org-export-file-uri raw-path
)))
2933 ((and home use-abs-url
)
2934 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2935 ;; Add search option, if any. A search option can be
2936 ;; relative to a custom-id, a headline title, a name or
2938 (let ((option (org-element-property :search-option link
)))
2939 (cond ((not option
) raw-path
)
2940 ;; Since HTML back-end use custom-id value as-is,
2941 ;; resolving is them is trivial.
2942 ((eq (string-to-char option
) ?
#) (concat raw-path option
))
2946 (org-publish-resolve-external-link
2948 (org-element-property :path link
)))))))
2950 ;; Extract attributes from parent's paragraph. HACK: Only do
2951 ;; this for the first link in parent (inner image link for
2952 ;; inline images). This is needed as long as attributes
2953 ;; cannot be set on a per link basis.
2955 (let* ((parent (org-export-get-parent-element link
))
2956 (link (let ((container (org-export-get-parent link
)))
2957 (if (and (eq (org-element-type container
) 'link
)
2958 (org-html-inline-image-p link info
))
2961 (and (eq (org-element-map parent
'link
'identity info t
) link
)
2962 (org-export-read-attribute :attr_html parent
))))
2964 (let ((attr (org-html--make-attribute-string attributes-plist
)))
2965 (if (org-string-nw-p attr
) (concat " " attr
) ""))))
2967 ;; Link type is handled by a special function.
2968 ((org-export-custom-protocol-maybe link desc
'html
))
2970 ((and (plist-get info
:html-inline-images
)
2971 (org-export-inline-image-p
2972 link
(plist-get info
:html-inline-image-rules
)))
2973 (org-html--format-image path attributes-plist info
))
2974 ;; Radio target: Transcode target's contents and use them as
2975 ;; link's description.
2976 ((string= type
"radio")
2977 (let ((destination (org-export-resolve-radio-link link info
)))
2978 (if (not destination
) desc
2979 (format "<a href=\"#%s\"%s>%s</a>"
2980 (org-export-get-reference destination info
)
2983 ;; Links pointing to a headline: Find destination and build
2984 ;; appropriate referencing command.
2985 ((member type
'("custom-id" "fuzzy" "id"))
2986 (let ((destination (if (string= type
"fuzzy")
2987 (org-export-resolve-fuzzy-link link info
)
2988 (org-export-resolve-id-link link info
))))
2989 (pcase (org-element-type destination
)
2990 ;; ID link points to an external file.
2992 (let ((fragment (concat "ID-" path
))
2993 ;; Treat links to ".org" files as ".html", if needed.
2994 (path (funcall link-org-files-as-html-maybe
2996 (format "<a href=\"%s#%s\"%s>%s</a>"
2997 path fragment attributes
(or desc destination
))))
2998 ;; Fuzzy link points nowhere.
3003 (org-element-property :raw-link link
) info
))))
3004 ;; Link points to a headline.
3006 (let ((href (or (org-element-property :CUSTOM_ID destination
)
3007 (org-export-get-reference destination info
)))
3008 ;; What description to use?
3010 ;; Case 1: Headline is numbered and LINK has no
3011 ;; description. Display section number.
3012 (if (and (org-export-numbered-headline-p destination info
)
3014 (mapconcat #'number-to-string
3015 (org-export-get-headline-number
3016 destination info
) ".")
3017 ;; Case 2: Either the headline is un-numbered or
3018 ;; LINK has a custom description. Display LINK's
3019 ;; description or headline's title.
3022 (org-element-property :title destination
) info
)))))
3023 (format "<a href=\"#%s\"%s>%s</a>" href attributes desc
)))
3024 ;; Fuzzy link points to a target or an element.
3026 (let* ((ref (org-export-get-reference destination info
))
3027 (org-html-standalone-image-predicate
3028 #'org-html--has-caption-p
)
3031 ((org-html-standalone-image-p destination info
)
3032 (org-export-get-ordinal
3033 (org-element-map destination
'link
3035 info
'link
'org-html-standalone-image-p
))
3036 (t (org-export-get-ordinal
3037 destination info nil
'org-html--has-caption-p
))))
3039 ((not number
) "No description for this link")
3040 ((numberp number
) (number-to-string number
))
3041 (t (mapconcat #'number-to-string number
".")))))
3042 (format "<a href=\"#%s\"%s>%s</a>" ref attributes desc
))))))
3043 ;; Coderef: replace link with the reference name or the
3044 ;; equivalent line number.
3045 ((string= type
"coderef")
3046 (let ((fragment (concat "coderef-" (org-html-encode-plain-text path
))))
3047 (format "<a href=\"#%s\"%s%s>%s</a>"
3049 (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, \
3050 '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
3053 (format (org-export-get-coderef-format path desc
)
3054 (org-export-resolve-coderef path info
)))))
3055 ;; External link with a description part.
3056 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>"
3057 (org-html-encode-plain-text path
)
3060 ;; External link without a description part.
3061 (path (let ((path (org-html-encode-plain-text path
)))
3062 (format "<a href=\"%s\"%s>%s</a>"
3065 (org-link-unescape path
))))
3066 ;; No path, only description. Try to do something useful.
3067 (t (format "<i>%s</i>" desc
)))))
3071 (defun org-html-node-property (node-property _contents _info
)
3072 "Transcode a NODE-PROPERTY element from Org to HTML.
3073 CONTENTS is nil. INFO is a plist holding contextual
3076 (org-element-property :key node-property
)
3077 (let ((value (org-element-property :value node-property
)))
3078 (if value
(concat " " value
) ""))))
3082 (defun org-html-paragraph (paragraph contents info
)
3083 "Transcode a PARAGRAPH element from Org to HTML.
3084 CONTENTS is the contents of the paragraph, as a string. INFO is
3085 the plist used as a communication channel."
3086 (let* ((parent (org-export-get-parent paragraph
))
3087 (parent-type (org-element-type parent
))
3088 (style '((footnote-definition " class=\"footpara\"")
3089 (org-data " class=\"footpara\"")))
3090 (attributes (org-html--make-attribute-string
3091 (org-export-read-attribute :attr_html paragraph
)))
3092 (extra (or (cadr (assq parent-type style
)) "")))
3094 ((and (eq parent-type
'item
)
3095 (not (org-export-get-previous-element paragraph info
))
3096 (let ((followers (org-export-get-next-element paragraph info
2)))
3097 (and (not (cdr followers
))
3098 (memq (org-element-type (car followers
)) '(nil plain-list
)))))
3099 ;; First paragraph in an item has no tag if it is alone or
3100 ;; followed, at most, by a sub-list.
3102 ((org-html-standalone-image-p paragraph info
)
3103 ;; Standalone image.
3105 (let ((raw (org-export-data
3106 (org-export-get-caption paragraph
) info
))
3107 (org-html-standalone-image-predicate
3108 'org-html--has-caption-p
))
3109 (if (not (org-string-nw-p raw
)) raw
3111 "<span class=\"figure-number\">"
3112 (format (org-html--translate "Figure %d:" info
)
3113 (org-export-get-ordinal
3114 (org-element-map paragraph
'link
3116 info nil
'org-html-standalone-image-p
))
3118 (label (and (org-element-property :name paragraph
)
3119 (org-export-get-reference paragraph info
))))
3120 (org-html--wrap-image contents info caption label
)))
3121 ;; Regular paragraph.
3122 (t (format "<p%s%s>\n%s</p>"
3123 (if (org-string-nw-p attributes
)
3124 (concat " " attributes
) "")
3129 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
3130 ;; the correct value for the item counter
3131 (defun org-html-begin-plain-list (type &optional arg1
)
3132 "Insert the beginning of the HTML list depending on TYPE.
3133 When ARG1 is a string, use it as the start parameter for ordered
3137 (format "<ol class=\"org-ol\"%s>"
3138 (if arg1
(format " start=\"%d\"" arg1
) "")))
3139 (`unordered
"<ul class=\"org-ul\">")
3140 (`descriptive
"<dl class=\"org-dl\">")))
3142 (defun org-html-end-plain-list (type)
3143 "Insert the end of the HTML list depending on TYPE."
3146 (`unordered
"</ul>")
3147 (`descriptive
"</dl>")))
3149 (defun org-html-plain-list (plain-list contents _info
)
3150 "Transcode a PLAIN-LIST element from Org to HTML.
3151 CONTENTS is the contents of the list. INFO is a plist holding
3152 contextual information."
3153 (let ((type (org-element-property :type plain-list
)))
3155 (org-html-begin-plain-list type
)
3156 contents
(org-html-end-plain-list type
))))
3160 (defun org-html-convert-special-strings (string)
3161 "Convert special characters in STRING to HTML."
3162 (dolist (a org-html-special-string-regexps string
)
3165 (setq string
(replace-regexp-in-string re rpl string t
)))))
3167 (defun org-html-encode-plain-text (text)
3168 "Convert plain text characters from TEXT to HTML equivalent.
3169 Possible conversions are set in `org-html-protect-char-alist'."
3170 (dolist (pair org-html-protect-char-alist text
)
3171 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
))))
3173 (defun org-html-plain-text (text info
)
3174 "Transcode a TEXT string from Org to HTML.
3175 TEXT is the string to transcode. INFO is a plist holding
3176 contextual information."
3177 (let ((output text
))
3178 ;; Protect following characters: <, >, &.
3179 (setq output
(org-html-encode-plain-text output
))
3180 ;; Handle smart quotes. Be sure to provide original string since
3181 ;; OUTPUT may have been modified.
3182 (when (plist-get info
:with-smart-quotes
)
3183 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
3184 ;; Handle special strings.
3185 (when (plist-get info
:with-special-strings
)
3186 (setq output
(org-html-convert-special-strings output
)))
3187 ;; Handle break preservation if required.
3188 (when (plist-get info
:preserve-breaks
)
3190 (replace-regexp-in-string
3191 "\\(\\\\\\\\\\)?[ \t]*\n"
3192 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
3199 (defun org-html-planning (planning _contents info
)
3200 "Transcode a PLANNING element from Org to HTML.
3201 CONTENTS is nil. INFO is a plist used as a communication
3204 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
3208 (let ((timestamp (cdr pair
)))
3210 (let ((string (car pair
)))
3211 (format "<span class=\"timestamp-kwd\">%s</span> \
3212 <span class=\"timestamp\">%s</span> "
3214 (org-html-plain-text (org-timestamp-translate timestamp
)
3216 `((,org-closed-string .
,(org-element-property :closed planning
))
3217 (,org-deadline-string .
,(org-element-property :deadline planning
))
3218 (,org-scheduled-string .
,(org-element-property :scheduled planning
)))
3221 ;;;; Property Drawer
3223 (defun org-html-property-drawer (_property-drawer contents _info
)
3224 "Transcode a PROPERTY-DRAWER element from Org to HTML.
3225 CONTENTS holds the contents of the drawer. INFO is a plist
3226 holding contextual information."
3227 (and (org-string-nw-p contents
)
3228 (format "<pre class=\"example\">\n%s</pre>" contents
)))
3232 (defun org-html-quote-block (quote-block contents _info
)
3233 "Transcode a QUOTE-BLOCK element from Org to HTML.
3234 CONTENTS holds the contents of the block. INFO is a plist
3235 holding contextual information."
3236 (format "<blockquote%s>\n%s</blockquote>"
3237 (let* ((name (org-element-property :name quote-block
))
3238 (attributes (org-export-read-attribute :attr_html quote-block
))
3239 (a (org-html--make-attribute-string
3240 (if (or (not name
) (plist-member attributes
:id
))
3242 (plist-put attributes
:id name
)))))
3243 (if (org-string-nw-p a
) (concat " " a
) ""))
3248 (defun org-html-section (section contents info
)
3249 "Transcode a SECTION element from Org to HTML.
3250 CONTENTS holds the contents of the section. INFO is a plist
3251 holding contextual information."
3252 (let ((parent (org-export-get-parent-headline section
)))
3253 ;; Before first headline: no container, just return CONTENTS.
3254 (if (not parent
) contents
3255 ;; Get div's class and id references.
3256 (let* ((class-num (+ (org-export-get-relative-level parent info
)
3257 (1- (plist-get info
:html-toplevel-hlevel
))))
3259 (and (org-export-numbered-headline-p parent info
)
3262 (org-export-get-headline-number parent info
) "-"))))
3263 ;; Build return value.
3264 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
3266 (or (org-element-property :CUSTOM_ID parent
)
3268 (org-export-get-reference parent info
))
3269 (or contents
""))))))
3273 (defun org-html-radio-target (radio-target text info
)
3274 "Transcode a RADIO-TARGET object from Org to HTML.
3275 TEXT is the text of the target. INFO is a plist holding
3276 contextual information."
3277 (let ((ref (org-export-get-reference radio-target info
)))
3278 (org-html--anchor ref text nil info
)))
3282 (defun org-html-special-block (special-block contents info
)
3283 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3284 CONTENTS holds the contents of the block. INFO is a plist
3285 holding contextual information."
3286 (let* ((block-type (org-element-property :type special-block
))
3287 (html5-fancy (and (org-html--html5-fancy-p info
)
3288 (member block-type org-html-html5-elements
)))
3289 (attributes (org-export-read-attribute :attr_html special-block
)))
3291 (let ((class (plist-get attributes
:class
)))
3292 (setq attributes
(plist-put attributes
:class
3293 (if class
(concat class
" " block-type
)
3295 (let* ((contents (or contents
""))
3296 (name (org-element-property :name special-block
))
3297 (a (org-html--make-attribute-string
3298 (if (or (not name
) (plist-member attributes
:id
))
3300 (plist-put attributes
:id name
))))
3301 (str (if (org-string-nw-p a
) (concat " " a
) "")))
3303 (format "<%s%s>\n%s</%s>" block-type str contents block-type
)
3304 (format "<div%s>\n%s\n</div>" str contents
)))))
3308 (defun org-html-src-block (src-block _contents info
)
3309 "Transcode a SRC-BLOCK element from Org to HTML.
3310 CONTENTS holds the contents of the item. INFO is a plist holding
3311 contextual information."
3312 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3313 (org-html--textarea-block src-block
)
3314 (let ((lang (org-element-property :language src-block
))
3315 (caption (org-export-get-caption src-block
))
3316 (code (org-html-format-code src-block info
))
3317 (label (let ((lbl (and (org-element-property :name src-block
)
3318 (org-export-get-reference src-block info
))))
3319 (if lbl
(format " id=\"%s\"" lbl
) ""))))
3320 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3322 "<div class=\"org-src-container\">\n%s%s\n</div>"
3323 (if (not caption
) ""
3324 (format "<label class=\"org-src-name\">%s</label>"
3325 (org-export-data caption info
)))
3326 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3328 ;;;; Statistics Cookie
3330 (defun org-html-statistics-cookie (statistics-cookie _contents _info
)
3331 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3332 CONTENTS is nil. INFO is a plist holding contextual information."
3333 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3334 (format "<code>%s</code>" cookie-value
)))
3338 (defun org-html-strike-through (_strike-through contents info
)
3339 "Transcode STRIKE-THROUGH from Org to HTML.
3340 CONTENTS is the text with strike-through markup. INFO is a plist
3341 holding contextual information."
3343 (or (cdr (assq 'strike-through
(plist-get info
:html-text-markup-alist
)))
3349 (defun org-html-subscript (_subscript contents _info
)
3350 "Transcode a SUBSCRIPT object from Org to HTML.
3351 CONTENTS is the contents of the object. INFO is a plist holding
3352 contextual information."
3353 (format "<sub>%s</sub>" contents
))
3357 (defun org-html-superscript (_superscript contents _info
)
3358 "Transcode a SUPERSCRIPT object from Org to HTML.
3359 CONTENTS is the contents of the object. INFO is a plist holding
3360 contextual information."
3361 (format "<sup>%s</sup>" contents
))
3365 (defun org-html-table-cell (table-cell contents info
)
3366 "Transcode a TABLE-CELL element from Org to HTML.
3367 CONTENTS is nil. INFO is a plist used as a communication
3369 (let* ((table-row (org-export-get-parent table-cell
))
3370 (table (org-export-get-parent-table table-cell
))
3372 (if (not (plist-get info
:html-table-align-individual-fields
)) ""
3373 (format (if (and (boundp 'org-html-format-table-no-css
)
3374 org-html-format-table-no-css
)
3375 " align=\"%s\"" " class=\"org-%s\"")
3376 (org-export-table-cell-alignment table-cell info
)))))
3377 (when (or (not contents
) (string= "" (org-trim contents
)))
3378 (setq contents
" "))
3380 ((and (org-export-table-has-header-p table info
)
3381 (= 1 (org-export-table-row-group table-row info
)))
3382 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3383 (concat "\n" (format (car header-tags
) "col" cell-attrs
)
3385 (cdr header-tags
))))
3386 ((and (plist-get info
:html-table-use-header-tags-for-first-column
)
3387 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3388 (let ((header-tags (plist-get info
:html-table-header-tags
)))
3389 (concat "\n" (format (car header-tags
) "row" cell-attrs
)
3391 (cdr header-tags
))))
3392 (t (let ((data-tags (plist-get info
:html-table-data-tags
)))
3393 (concat "\n" (format (car data-tags
) cell-attrs
)
3395 (cdr data-tags
)))))))
3399 (defun org-html-table-row (table-row contents info
)
3400 "Transcode a TABLE-ROW element from Org to HTML.
3401 CONTENTS is the contents of the row. INFO is a plist used as a
3402 communication channel."
3403 ;; Rules are ignored since table separators are deduced from
3404 ;; borders of the current row.
3405 (when (eq (org-element-property :type table-row
) 'standard
)
3406 (let* ((group (org-export-table-row-group table-row info
))
3407 (number (org-export-table-row-number table-row info
))
3409 (org-export-table-row-starts-rowgroup-p table-row info
))
3411 (org-export-table-row-ends-rowgroup-p table-row info
))
3412 (topp (and (equal start-group-p
'(top))
3413 (equal end-group-p
'(below top
))))
3414 (bottomp (and (equal start-group-p
'(above))
3415 (equal end-group-p
'(bottom above
))))
3417 (pcase (plist-get info
:html-table-row-open-tag
)
3418 ((and accessor
(pred functionp
))
3420 number group start-group-p end-group-p topp bottomp
))
3421 (accessor accessor
)))
3423 (pcase (plist-get info
:html-table-row-close-tag
)
3424 ((and accessor
(pred functionp
))
3426 number group start-group-p end-group-p topp bottomp
))
3427 (accessor accessor
)))
3430 ;; Row belongs to second or subsequent groups.
3431 ((not (= 1 group
)) '("<tbody>" .
"\n</tbody>"))
3432 ;; Row is from first group. Table has >=1 groups.
3433 ((org-export-table-has-header-p
3434 (org-export-get-parent-table table-row
) info
)
3435 '("<thead>" .
"\n</thead>"))
3436 ;; Row is from first and only group.
3437 (t '("<tbody>" .
"\n</tbody>")))))
3438 (concat (and start-group-p
(car group-tags
))
3444 (and end-group-p
(cdr group-tags
))))))
3448 (defun org-html-table-first-row-data-cells (table info
)
3449 "Transcode the first row of TABLE.
3450 INFO is a plist used as a communication channel."
3452 (org-element-map table
'table-row
3454 (unless (eq (org-element-property :type row
) 'rule
) row
))
3456 (special-column-p (org-export-table-has-special-column-p table
)))
3457 (if (not special-column-p
) (org-element-contents table-row
)
3458 (cdr (org-element-contents table-row
)))))
3460 (defun org-html-table--table.el-table
(table _info
)
3461 "Format table.el tables into HTML.
3462 INFO is a plist used as a communication channel."
3463 (when (eq (org-element-property :type table
) 'table.el
)
3465 (let ((outbuf (with-current-buffer
3466 (get-buffer-create "*org-export-table*")
3467 (erase-buffer) (current-buffer))))
3469 (insert (org-element-property :value table
))
3471 (re-search-forward "^[ \t]*|[^|]" nil t
)
3472 (table-generate-source 'html outbuf
))
3473 (with-current-buffer outbuf
3474 (prog1 (org-trim (buffer-string))
3477 (defun org-html-table (table contents info
)
3478 "Transcode a TABLE element from Org to HTML.
3479 CONTENTS is the contents of the table. INFO is a plist holding
3480 contextual information."
3481 (if (eq (org-element-property :type table
) 'table.el
)
3482 ;; "table.el" table. Convert it using appropriate tools.
3483 (org-html-table--table.el-table table info
)
3485 (let* ((caption (org-export-get-caption table
))
3486 (number (org-export-get-ordinal
3487 table info nil
#'org-html--has-caption-p
))
3489 (org-html--make-attribute-string
3491 (and (org-element-property :name table
)
3492 (list :id
(org-export-get-reference table info
)))
3493 (and (not (org-html-html5-p info
))
3494 (plist-get info
:html-table-attributes
))
3495 (org-export-read-attribute :attr_html table
))))
3497 (if (bound-and-true-p org-html-format-table-no-css
)
3499 "class=\"org-%s\""))
3501 (lambda (table info
)
3503 (lambda (table-cell)
3504 (let ((alignment (org-export-table-cell-alignment
3507 ;; Begin a colgroup?
3508 (when (org-export-table-cell-starts-colgroup-p
3511 ;; Add a column. Also specify its alignment.
3514 "col" (concat " " (format alignspec alignment
)) info
))
3516 (when (org-export-table-cell-ends-colgroup-p
3519 (org-html-table-first-row-data-cells table info
) "\n"))))
3520 (format "<table%s>\n%s\n%s\n%s</table>"
3521 (if (equal attributes
"") "" (concat " " attributes
))
3522 (if (not caption
) ""
3523 (format (if (plist-get info
:html-table-caption-above
)
3524 "<caption class=\"t-above\">%s</caption>"
3525 "<caption class=\"t-bottom\">%s</caption>")
3527 "<span class=\"table-number\">"
3528 (format (org-html--translate "Table %d:" info
) number
)
3529 "</span> " (org-export-data caption info
))))
3530 (funcall table-column-specs table info
)
3535 (defun org-html-target (target _contents info
)
3536 "Transcode a TARGET object from Org to HTML.
3537 CONTENTS is nil. INFO is a plist holding contextual
3539 (let ((ref (org-export-get-reference target info
)))
3540 (org-html--anchor ref nil nil info
)))
3544 (defun org-html-timestamp (timestamp _contents info
)
3545 "Transcode a TIMESTAMP object from Org to HTML.
3546 CONTENTS is nil. INFO is a plist holding contextual
3548 (let ((value (org-html-plain-text (org-timestamp-translate timestamp
) info
)))
3549 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3550 (replace-regexp-in-string "--" "–" value
))))
3554 (defun org-html-underline (_underline contents info
)
3555 "Transcode UNDERLINE from Org to HTML.
3556 CONTENTS is the text with underline markup. INFO is a plist
3557 holding contextual information."
3558 (format (or (cdr (assq 'underline
(plist-get info
:html-text-markup-alist
)))
3564 (defun org-html-verbatim (verbatim _contents info
)
3565 "Transcode VERBATIM from Org to HTML.
3566 CONTENTS is nil. INFO is a plist holding contextual
3568 (format (or (cdr (assq 'verbatim
(plist-get info
:html-text-markup-alist
))) "%s")
3569 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3573 (defun org-html-verse-block (_verse-block contents info
)
3574 "Transcode a VERSE-BLOCK element from Org to HTML.
3575 CONTENTS is verse block contents. INFO is a plist holding
3576 contextual information."
3577 ;; Replace each newline character with line break. Also replace
3578 ;; each blank line with a line break.
3579 (setq contents
(replace-regexp-in-string
3580 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3581 (replace-regexp-in-string
3582 "\\(\\\\\\\\\\)?[ \t]*\n"
3583 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3584 ;; Replace each white space at beginning of a line with a
3585 ;; non-breaking space.
3586 (while (string-match "^[ \t]+" contents
)
3587 (let* ((num-ws (length (match-string 0 contents
)))
3588 (ws (org-html--make-string num-ws
" ")))
3589 (setq contents
(replace-match ws nil t contents
))))
3590 (format "<p class=\"verse\">\n%s</p>" contents
))
3593 ;;; Filter Functions
3595 (defun org-html-final-function (contents _backend info
)
3596 "Filter to indent the HTML and convert HTML entities."
3600 (if (plist-get info
:html-indent
)
3601 (indent-region (point-min) (point-max)))
3602 (buffer-substring-no-properties (point-min) (point-max))))
3605 ;;; End-user functions
3608 (defun org-html-export-as-html
3609 (&optional async subtreep visible-only body-only ext-plist
)
3610 "Export current buffer to an HTML buffer.
3612 If narrowing is active in the current buffer, only export its
3615 If a region is active, export that region.
3617 A non-nil optional argument ASYNC means the process should happen
3618 asynchronously. The resulting buffer should be accessible
3619 through the `org-export-stack' interface.
3621 When optional argument SUBTREEP is non-nil, export the sub-tree
3622 at point, extracting information from the headline properties
3625 When optional argument VISIBLE-ONLY is non-nil, don't export
3626 contents of hidden elements.
3628 When optional argument BODY-ONLY is non-nil, only write code
3629 between \"<body>\" and \"</body>\" tags.
3631 EXT-PLIST, when provided, is a property list with external
3632 parameters overriding Org default settings, but still inferior to
3633 file-local settings.
3635 Export is done in a buffer named \"*Org HTML Export*\", which
3636 will be displayed when `org-export-show-temporary-export-buffer'
3639 (org-export-to-buffer 'html
"*Org HTML Export*"
3640 async subtreep visible-only body-only ext-plist
3641 (lambda () (set-auto-mode t
))))
3644 (defun org-html-convert-region-to-html ()
3645 "Assume the current region has org-mode syntax, and convert it to HTML.
3646 This can be used in any buffer. For example, you can write an
3647 itemized list in org-mode syntax in an HTML buffer and use this
3648 command to convert it."
3650 (org-export-replace-region-by 'html
))
3653 (defun org-html-export-to-html
3654 (&optional async subtreep visible-only body-only ext-plist
)
3655 "Export current buffer to a HTML file.
3657 If narrowing is active in the current buffer, only export its
3660 If a region is active, export that region.
3662 A non-nil optional argument ASYNC means the process should happen
3663 asynchronously. The resulting file should be accessible through
3664 the `org-export-stack' interface.
3666 When optional argument SUBTREEP is non-nil, export the sub-tree
3667 at point, extracting information from the headline properties
3670 When optional argument VISIBLE-ONLY is non-nil, don't export
3671 contents of hidden elements.
3673 When optional argument BODY-ONLY is non-nil, only write code
3674 between \"<body>\" and \"</body>\" tags.
3676 EXT-PLIST, when provided, is a property list with external
3677 parameters overriding Org default settings, but still inferior to
3678 file-local settings.
3680 Return output file's name."
3682 (let* ((extension (concat "." (or (plist-get ext-plist
:html-extension
)
3685 (file (org-export-output-file-name extension subtreep
))
3686 (org-export-coding-system org-html-coding-system
))
3687 (org-export-to-file 'html file
3688 async subtreep visible-only body-only ext-plist
)))
3691 (defun org-html-publish-to-html (plist filename pub-dir
)
3692 "Publish an org file to HTML.
3694 FILENAME is the filename of the Org file to be published. PLIST
3695 is the property list for the given project. PUB-DIR is the
3696 publishing directory.
3698 Return output file name."
3699 (org-publish-org-to 'html filename
3700 (concat "." (or (plist-get plist
:html-extension
)
3709 ;; generated-autoload-file: "org-loaddefs.el"
3712 ;;; ox-html.el ends here