org-agenda: Fix `org-tags-view'
[org-mode.git] / lisp / ox-html.el
blob9c0ba65398edfd814e3b1d72e7232ad214e92caa
1 ;;; ox-html.el --- HTML Back-End for Org Export Engine -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Jambunathan K <kjambunathan at gmail dot com>
7 ;; Keywords: outlines, hypermedia, calendar, wp
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;; This library implements a HTML back-end for Org generic exporter.
27 ;; See Org manual for more information.
29 ;;; Code:
31 ;;; Dependencies
33 (require 'cl-lib)
34 (require 'format-spec)
35 (require 'ox)
36 (require 'ox-publish)
37 (require 'table)
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)
51 ;;; Define Back-End
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))
105 :menu-entry
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"
110 (lambda (a s v b)
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)))))))
113 :options-alist
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-postamble nil "html-postamble" org-html-postamble)
124 (:html-preamble nil "html-preamble" org-html-preamble)
125 (:html-head "HTML_HEAD" nil org-html-head newline)
126 (:html-head-extra "HTML_HEAD_EXTRA" nil org-html-head-extra newline)
127 (:subtitle "SUBTITLE" nil nil parse)
128 (:html-head-include-default-style
129 nil "html-style" org-html-head-include-default-style)
130 (:html-head-include-scripts nil "html-scripts" org-html-head-include-scripts)
131 (:html-allow-name-attribute-in-anchors
132 nil nil org-html-allow-name-attribute-in-anchors)
133 (:html-divs nil nil org-html-divs)
134 (:html-checkbox-type nil nil org-html-checkbox-type)
135 (:html-extension nil nil org-html-extension)
136 (:html-footnote-format nil nil org-html-footnote-format)
137 (:html-footnote-separator nil nil org-html-footnote-separator)
138 (:html-footnotes-section nil nil org-html-footnotes-section)
139 (:html-format-drawer-function nil nil org-html-format-drawer-function)
140 (:html-format-headline-function nil nil org-html-format-headline-function)
141 (:html-format-inlinetask-function
142 nil nil org-html-format-inlinetask-function)
143 (:html-home/up-format nil nil org-html-home/up-format)
144 (:html-indent nil nil org-html-indent)
145 (:html-infojs-options nil nil org-html-infojs-options)
146 (:html-infojs-template nil nil org-html-infojs-template)
147 (:html-inline-image-rules nil nil org-html-inline-image-rules)
148 (:html-link-org-files-as-html nil nil org-html-link-org-files-as-html)
149 (:html-mathjax-options nil nil org-html-mathjax-options)
150 (:html-mathjax-template nil nil org-html-mathjax-template)
151 (:html-metadata-timestamp-format nil nil org-html-metadata-timestamp-format)
152 (:html-postamble-format nil nil org-html-postamble-format)
153 (:html-preamble-format nil nil org-html-preamble-format)
154 (:html-table-align-individual-fields
155 nil nil org-html-table-align-individual-fields)
156 (:html-table-caption-above nil nil org-html-table-caption-above)
157 (:html-table-data-tags nil nil org-html-table-data-tags)
158 (:html-table-header-tags nil nil org-html-table-header-tags)
159 (:html-table-use-header-tags-for-first-column
160 nil nil org-html-table-use-header-tags-for-first-column)
161 (:html-tag-class-prefix nil nil org-html-tag-class-prefix)
162 (:html-text-markup-alist nil nil org-html-text-markup-alist)
163 (:html-todo-kwd-class-prefix nil nil org-html-todo-kwd-class-prefix)
164 (:html-toplevel-hlevel nil nil org-html-toplevel-hlevel)
165 (:html-use-infojs nil nil org-html-use-infojs)
166 (:html-validation-link nil nil org-html-validation-link)
167 (:html-viewport nil nil org-html-viewport)
168 (:html-inline-images nil nil org-html-inline-images)
169 (:html-table-attributes nil nil org-html-table-default-attributes)
170 (:html-table-row-open-tag nil nil org-html-table-row-open-tag)
171 (:html-table-row-close-tag nil nil org-html-table-row-close-tag)
172 (:html-xml-declaration nil nil org-html-xml-declaration)
173 (:infojs-opt "INFOJS_OPT" nil nil)
174 ;; Redefine regular options.
175 (:creator "CREATOR" nil org-html-creator-string)
176 (:with-latex nil "tex" org-html-with-latex)
177 ;; Retrieve LaTeX header for fragments.
178 (:latex-header "LATEX_HEADER" nil nil newline)))
181 ;;; Internal Variables
183 (defvar org-html-format-table-no-css)
184 (defvar htmlize-buffer-places) ; from htmlize.el
186 (defvar org-html--pre/postamble-class "status"
187 "CSS class used for pre/postamble")
189 (defconst org-html-doctype-alist
190 '(("html4-strict" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
191 \"http://www.w3.org/TR/html4/strict.dtd\">")
192 ("html4-transitional" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
193 \"http://www.w3.org/TR/html4/loose.dtd\">")
194 ("html4-frameset" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
195 \"http://www.w3.org/TR/html4/frameset.dtd\">")
197 ("xhtml-strict" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
198 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
199 ("xhtml-transitional" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
200 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
201 ("xhtml-frameset" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
202 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
203 ("xhtml-11" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
204 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
206 ("html5" . "<!DOCTYPE html>")
207 ("xhtml5" . "<!DOCTYPE html>"))
208 "An alist mapping (x)html flavors to specific doctypes.")
210 (defconst org-html-html5-elements
211 '("article" "aside" "audio" "canvas" "details" "figcaption"
212 "figure" "footer" "header" "menu" "meter" "nav" "output"
213 "progress" "section" "video")
214 "New elements in html5.
216 For blocks that should contain headlines, use the HTML_CONTAINER
217 property on the headline itself.")
219 (defconst org-html-special-string-regexps
220 '(("\\\\-" . "&#x00ad;") ; shy
221 ("---\\([^-]\\)" . "&#x2014;\\1") ; mdash
222 ("--\\([^-]\\)" . "&#x2013;\\1") ; ndash
223 ("\\.\\.\\." . "&#x2026;")) ; hellip
224 "Regular expressions for special string conversion.")
226 (defconst org-html-scripts
227 "<script type=\"text/javascript\">
229 @licstart The following is the entire license notice for the
230 JavaScript code in this tag.
232 Copyright (C) 2012-2017 Free Software Foundation, Inc.
234 The JavaScript code in this tag is free software: you can
235 redistribute it and/or modify it under the terms of the GNU
236 General Public License (GNU GPL) as published by the Free Software
237 Foundation, either version 3 of the License, or (at your option)
238 any later version. The code is distributed WITHOUT ANY WARRANTY;
239 without even the implied warranty of MERCHANTABILITY or FITNESS
240 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
242 As additional permission under GNU GPL version 3 section 7, you
243 may distribute non-source (e.g., minimized or compacted) forms of
244 that code without the copy of the GNU GPL normally required by
245 section 4, provided you include this license notice and a URL
246 through which recipients can access the Corresponding Source.
249 @licend The above is the entire license notice
250 for the JavaScript code in this tag.
252 <!--/*--><![CDATA[/*><!--*/
253 function CodeHighlightOn(elem, id)
255 var target = document.getElementById(id);
256 if(null != target) {
257 elem.cacheClassElem = elem.className;
258 elem.cacheClassTarget = target.className;
259 target.className = \"code-highlighted\";
260 elem.className = \"code-highlighted\";
263 function CodeHighlightOff(elem, id)
265 var target = document.getElementById(id);
266 if(elem.cacheClassElem)
267 elem.className = elem.cacheClassElem;
268 if(elem.cacheClassTarget)
269 target.className = elem.cacheClassTarget;
271 /*]]>*///-->
272 </script>"
273 "Basic JavaScript that is needed by HTML files produced by Org mode.")
275 (defconst org-html-style-default
276 "<style type=\"text/css\">
277 <!--/*--><![CDATA[/*><!--*/
278 .title { text-align: center;
279 margin-bottom: .2em; }
280 .subtitle { text-align: center;
281 font-size: medium;
282 font-weight: bold;
283 margin-top:0; }
284 .todo { font-family: monospace; color: red; }
285 .done { font-family: monospace; color: green; }
286 .priority { font-family: monospace; color: orange; }
287 .tag { background-color: #eee; font-family: monospace;
288 padding: 2px; font-size: 80%; font-weight: normal; }
289 .timestamp { color: #bebebe; }
290 .timestamp-kwd { color: #5f9ea0; }
291 .org-right { margin-left: auto; margin-right: 0px; text-align: right; }
292 .org-left { margin-left: 0px; margin-right: auto; text-align: left; }
293 .org-center { margin-left: auto; margin-right: auto; text-align: center; }
294 .underline { text-decoration: underline; }
295 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
296 p.verse { margin-left: 3%; }
297 pre {
298 border: 1px solid #ccc;
299 box-shadow: 3px 3px 3px #eee;
300 padding: 8pt;
301 font-family: monospace;
302 overflow: auto;
303 margin: 1.2em;
305 pre.src {
306 position: relative;
307 overflow: visible;
308 padding-top: 1.2em;
310 pre.src:before {
311 display: none;
312 position: absolute;
313 background-color: white;
314 top: -10px;
315 right: 10px;
316 padding: 3px;
317 border: 1px solid black;
319 pre.src:hover:before { display: inline;}
320 /* Languages per Org manual */
321 pre.src-asymptote:before { content: 'Asymptote'; }
322 pre.src-awk:before { content: 'Awk'; }
323 pre.src-C:before { content: 'C'; }
324 /* pre.src-C++ doesn't work in CSS */
325 pre.src-clojure:before { content: 'Clojure'; }
326 pre.src-css:before { content: 'CSS'; }
327 pre.src-D:before { content: 'D'; }
328 pre.src-ditaa:before { content: 'ditaa'; }
329 pre.src-dot:before { content: 'Graphviz'; }
330 pre.src-calc:before { content: 'Emacs Calc'; }
331 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
332 pre.src-fortran:before { content: 'Fortran'; }
333 pre.src-gnuplot:before { content: 'gnuplot'; }
334 pre.src-haskell:before { content: 'Haskell'; }
335 pre.src-java:before { content: 'Java'; }
336 pre.src-js:before { content: 'Javascript'; }
337 pre.src-latex:before { content: 'LaTeX'; }
338 pre.src-ledger:before { content: 'Ledger'; }
339 pre.src-lisp:before { content: 'Lisp'; }
340 pre.src-lilypond:before { content: 'Lilypond'; }
341 pre.src-lua:before { content: 'Lua'; }
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\"
372 in ob-*.el */
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; }
427 .inlinetask {
428 padding: 10px;
429 border: 2px solid gray;
430 margin: 10px;
431 background: #ffffcc;
433 #org-div-home-and-up
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; }
443 .org-svg { width: 90%; }
444 /*]]>*/-->
445 </style>"
446 "The default style specification for exported HTML files.
447 You can use `org-html-head' and `org-html-head-extra' to add to
448 this style. If you don't want to include this default style,
449 customize `org-html-head-include-default-style'.")
452 ;;; User Configuration Variables
454 (defgroup org-export-html nil
455 "Options for exporting Org mode files to HTML."
456 :tag "Org Export HTML"
457 :group 'org-export)
459 ;;;; Handle infojs
461 (defvar org-html-infojs-opts-table
462 '((path PATH "http://orgmode.org/org-info.js")
463 (view VIEW "info")
464 (toc TOC :with-toc)
465 (ftoc FIXED_TOC "0")
466 (tdepth TOC_DEPTH "max")
467 (sdepth SECTION_DEPTH "max")
468 (mouse MOUSE_HINT "underline")
469 (buttons VIEW_BUTTONS "0")
470 (ltoc LOCAL_TOC "1")
471 (up LINK_UP :html-link-up)
472 (home LINK_HOME :html-link-home))
473 "JavaScript options, long form for script, default values.")
475 (defcustom org-html-use-infojs 'when-configured
476 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
477 This option can be nil or t to never or always use the script.
478 It can also be the symbol `when-configured', meaning that the
479 script will be linked into the export file if and only if there
480 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
481 `org-html-infojs-options'."
482 :group 'org-export-html
483 :version "24.4"
484 :package-version '(Org . "8.0")
485 :type '(choice
486 (const :tag "Never" nil)
487 (const :tag "When configured in buffer" when-configured)
488 (const :tag "Always" t)))
490 (defcustom org-html-infojs-options
491 (mapcar (lambda (x) (cons (car x) (nth 2 x))) org-html-infojs-opts-table)
492 "Options settings for the INFOJS JavaScript.
493 Each of the options must have an entry in `org-html-infojs-opts-table'.
494 The value can either be a string that will be passed to the script, or
495 a property. This property is then assumed to be a property that is defined
496 by the Export/Publishing setup of Org.
497 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
498 means to use the maximum value consistent with other options."
499 :group 'org-export-html
500 :version "24.4"
501 :package-version '(Org . "8.0")
502 :type
503 `(set :greedy t :inline t
504 ,@(mapcar
505 (lambda (x)
506 (list 'cons (list 'const (car x))
507 '(choice
508 (symbol :tag "Publishing/Export property")
509 (string :tag "Value"))))
510 org-html-infojs-opts-table)))
512 (defcustom org-html-infojs-template
513 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
516 * @source: %SCRIPT_PATH
518 * @licstart The following is the entire license notice for the
519 * JavaScript code in %SCRIPT_PATH.
521 * Copyright (C) 2012-2013 Free Software Foundation, Inc.
524 * The JavaScript code in this tag is free software: you can
525 * redistribute it and/or modify it under the terms of the GNU
526 * General Public License (GNU GPL) as published by the Free Software
527 * Foundation, either version 3 of the License, or (at your option)
528 * any later version. The code is distributed WITHOUT ANY WARRANTY;
529 * without even the implied warranty of MERCHANTABILITY or FITNESS
530 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
532 * As additional permission under GNU GPL version 3 section 7, you
533 * may distribute non-source (e.g., minimized or compacted) forms of
534 * that code without the copy of the GNU GPL normally required by
535 * section 4, provided you include this license notice and a URL
536 * through which recipients can access the Corresponding Source.
538 * @licend The above is the entire license notice
539 * for the JavaScript code in %SCRIPT_PATH.
542 </script>
544 <script type=\"text/javascript\">
547 @licstart The following is the entire license notice for the
548 JavaScript code in this tag.
550 Copyright (C) 2012-2013 Free Software Foundation, Inc.
552 The JavaScript code in this tag is free software: you can
553 redistribute it and/or modify it under the terms of the GNU
554 General Public License (GNU GPL) as published by the Free Software
555 Foundation, either version 3 of the License, or (at your option)
556 any later version. The code is distributed WITHOUT ANY WARRANTY;
557 without even the implied warranty of MERCHANTABILITY or FITNESS
558 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
560 As additional permission under GNU GPL version 3 section 7, you
561 may distribute non-source (e.g., minimized or compacted) forms of
562 that code without the copy of the GNU GPL normally required by
563 section 4, provided you include this license notice and a URL
564 through which recipients can access the Corresponding Source.
567 @licend The above is the entire license notice
568 for the JavaScript code in this tag.
571 <!--/*--><![CDATA[/*><!--*/
572 %MANAGER_OPTIONS
573 org_html_manager.setup(); // activate after the parameters are set
574 /*]]>*///-->
575 </script>"
576 "The template for the export style additions when org-info.js is used.
577 Option settings will replace the %MANAGER-OPTIONS cookie."
578 :group 'org-export-html
579 :version "24.4"
580 :package-version '(Org . "8.0")
581 :type 'string)
583 (defun org-html-infojs-install-script (exp-plist _backend)
584 "Install script in export options when appropriate.
585 EXP-PLIST is a plist containing export options. BACKEND is the
586 export back-end currently used."
587 (unless (or (memq 'body-only (plist-get exp-plist :export-options))
588 (not (plist-get exp-plist :html-use-infojs))
589 (and (eq (plist-get exp-plist :html-use-infojs) 'when-configured)
590 (let ((opt (plist-get exp-plist :infojs-opt)))
591 (or (not opt)
592 (string= "" opt)
593 (string-match "\\<view:nil\\>" opt)))))
594 (let* ((template (plist-get exp-plist :html-infojs-template))
595 (ptoc (plist-get exp-plist :with-toc))
596 (hlevels (plist-get exp-plist :headline-levels))
597 (sdepth hlevels)
598 (tdepth (if (integerp ptoc) (min ptoc hlevels) hlevels))
599 (options (plist-get exp-plist :infojs-opt))
600 (infojs-opt (plist-get exp-plist :html-infojs-options))
601 (table org-html-infojs-opts-table)
602 style)
603 (dolist (entry table)
604 (let* ((opt (car entry))
605 (var (nth 1 entry))
606 ;; Compute default values for script option OPT from
607 ;; `org-html-infojs-options' variable.
608 (default
609 (let ((default (cdr (assq opt infojs-opt))))
610 (if (and (symbolp default) (not (memq default '(t nil))))
611 (plist-get exp-plist default)
612 default)))
613 ;; Value set through INFOJS_OPT keyword has precedence
614 ;; over the default one.
615 (val (if (and options
616 (string-match (format "\\<%s:\\(\\S-+\\)" opt)
617 options))
618 (match-string 1 options)
619 default)))
620 (pcase opt
621 (`path (setq template
622 (replace-regexp-in-string
623 "%SCRIPT_PATH" val template t t)))
624 (`sdepth (when (integerp (read val))
625 (setq sdepth (min (read val) sdepth))))
626 (`tdepth (when (integerp (read val))
627 (setq tdepth (min (read val) tdepth))))
628 (_ (setq val
629 (cond
630 ((or (eq val t) (equal val "t")) "1")
631 ((or (eq val nil) (equal val "nil")) "0")
632 ((stringp val) val)
633 (t (format "%s" val))))
634 (push (cons var val) style)))))
635 ;; Now we set the depth of the *generated* TOC to SDEPTH,
636 ;; because the toc will actually determine the splitting. How
637 ;; much of the toc will actually be displayed is governed by the
638 ;; TDEPTH option.
639 (setq exp-plist (plist-put exp-plist :with-toc sdepth))
640 ;; The table of contents should not show more sections than we
641 ;; generate.
642 (setq tdepth (min tdepth sdepth))
643 (push (cons "TOC_DEPTH" tdepth) style)
644 ;; Build style string.
645 (setq style (mapconcat
646 (lambda (x)
647 (format "org_html_manager.set(\"%s\", \"%s\");"
648 (car x) (cdr x)))
649 style "\n"))
650 (when (and style (> (length style) 0))
651 (and (string-match "%MANAGER_OPTIONS" template)
652 (setq style (replace-match style t t template))
653 (setq exp-plist
654 (plist-put
655 exp-plist :html-head-extra
656 (concat (or (plist-get exp-plist :html-head-extra) "")
657 "\n"
658 style)))))
659 ;; This script absolutely needs the table of contents, so we
660 ;; change that setting.
661 (unless (plist-get exp-plist :with-toc)
662 (setq exp-plist (plist-put exp-plist :with-toc t)))
663 ;; Return the modified property list.
664 exp-plist)))
666 ;;;; Bold, etc.
668 (defcustom org-html-text-markup-alist
669 '((bold . "<b>%s</b>")
670 (code . "<code>%s</code>")
671 (italic . "<i>%s</i>")
672 (strike-through . "<del>%s</del>")
673 (underline . "<span class=\"underline\">%s</span>")
674 (verbatim . "<code>%s</code>"))
675 "Alist of HTML expressions to convert text markup.
677 The key must be a symbol among `bold', `code', `italic',
678 `strike-through', `underline' and `verbatim'. The value is
679 a formatting string to wrap fontified text with.
681 If no association can be found for a given markup, text will be
682 returned as-is."
683 :group 'org-export-html
684 :version "24.4"
685 :package-version '(Org . "8.0")
686 :type '(alist :key-type (symbol :tag "Markup type")
687 :value-type (string :tag "Format string"))
688 :options '(bold code italic strike-through underline verbatim))
690 (defcustom org-html-indent nil
691 "Non-nil means to indent the generated HTML.
692 Warning: non-nil may break indentation of source code blocks."
693 :group 'org-export-html
694 :version "24.4"
695 :package-version '(Org . "8.0")
696 :type 'boolean)
698 ;;;; Drawers
700 (defcustom org-html-format-drawer-function (lambda (_name contents) contents)
701 "Function called to format a drawer in HTML code.
703 The function must accept two parameters:
704 NAME the drawer name, like \"LOGBOOK\"
705 CONTENTS the contents of the drawer.
707 The function should return the string to be exported.
709 For example, the variable could be set to the following function
710 in order to mimic default behavior:
712 The default value simply returns the value of CONTENTS."
713 :group 'org-export-html
714 :version "24.4"
715 :package-version '(Org . "8.0")
716 :type 'function)
718 ;;;; Footnotes
720 (defcustom org-html-footnotes-section "<div id=\"footnotes\">
721 <h2 class=\"footnotes\">%s: </h2>
722 <div id=\"text-footnotes\">
724 </div>
725 </div>"
726 "Format for the footnotes section.
727 Should contain a two instances of %s. The first will be replaced with the
728 language-specific word for \"Footnotes\", the second one will be replaced
729 by the footnotes themselves."
730 :group 'org-export-html
731 :type 'string)
733 (defcustom org-html-footnote-format "<sup>%s</sup>"
734 "The format for the footnote reference.
735 %s will be replaced by the footnote reference itself."
736 :group 'org-export-html
737 :type 'string)
739 (defcustom org-html-footnote-separator "<sup>, </sup>"
740 "Text used to separate footnotes."
741 :group 'org-export-html
742 :type 'string)
744 ;;;; Headline
746 (defcustom org-html-toplevel-hlevel 2
747 "The <H> level for level 1 headings in HTML export.
748 This is also important for the classes that will be wrapped around headlines
749 and outline structure. If this variable is 1, the top-level headlines will
750 be <h1>, and the corresponding classes will be outline-1, section-number-1,
751 and outline-text-1. If this is 2, all of these will get a 2 instead.
752 The default for this variable is 2, because we use <h1> for formatting the
753 document title."
754 :group 'org-export-html
755 :type 'integer)
757 (defcustom org-html-format-headline-function
758 'org-html-format-headline-default-function
759 "Function to format headline text.
761 This function will be called with six arguments:
762 TODO the todo keyword (string or nil).
763 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
764 PRIORITY the priority of the headline (integer or nil)
765 TEXT the main headline text (string).
766 TAGS the tags (string or nil).
767 INFO the export options (plist).
769 The function result will be used in the section format string."
770 :group 'org-export-html
771 :version "26.1"
772 :package-version '(Org . "8.3")
773 :type 'function)
775 ;;;; HTML-specific
777 (defcustom org-html-allow-name-attribute-in-anchors nil
778 "When nil, do not set \"name\" attribute in anchors.
779 By default, when appropriate, anchors are formatted with \"id\"
780 but without \"name\" attribute."
781 :group 'org-export-html
782 :version "24.4"
783 :package-version '(Org . "8.0")
784 :type 'boolean)
786 ;;;; Inlinetasks
788 (defcustom org-html-format-inlinetask-function
789 'org-html-format-inlinetask-default-function
790 "Function called to format an inlinetask in HTML code.
792 The function must accept seven parameters:
793 TODO the todo keyword, as a string
794 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
795 PRIORITY the inlinetask priority, as a string
796 NAME the inlinetask name, as a string.
797 TAGS the inlinetask tags, as a list of strings.
798 CONTENTS the contents of the inlinetask, as a string.
799 INFO the export options, as a plist
801 The function should return the string to be exported."
802 :group 'org-export-html
803 :version "26.1"
804 :package-version '(Org . "8.3")
805 :type 'function)
807 ;;;; LaTeX
809 (defcustom org-html-with-latex org-export-with-latex
810 "Non-nil means process LaTeX math snippets.
812 When set, the exporter will process LaTeX environments and
813 fragments.
815 This option can also be set with the +OPTIONS line,
816 e.g. \"tex:mathjax\". Allowed values are:
818 nil Ignore math snippets.
819 `verbatim' Keep everything in verbatim
820 `mathjax', t Do MathJax preprocessing and arrange for MathJax.js to
821 be loaded.
822 SYMBOL Any symbol defined in `org-preview-latex-process-alist',
823 e.g., `dvipng'."
824 :group 'org-export-html
825 :version "24.4"
826 :package-version '(Org . "8.0")
827 :type '(choice
828 (const :tag "Do not process math in any way" nil)
829 (const :tag "Leave math verbatim" verbatim)
830 (const :tag "Use MathJax to display math" mathjax)
831 (symbol :tag "Convert to image to display math" :value dvipng)))
833 ;;;; Links :: Generic
835 (defcustom org-html-link-org-files-as-html t
836 "Non-nil means make file links to `file.org' point to `file.html'.
837 When `org-mode' is exporting an `org-mode' file to HTML, links to
838 non-html files are directly put into a href tag in HTML.
839 However, links to other Org files (recognized by the extension
840 \".org\") should become links to the corresponding HTML
841 file, assuming that the linked `org-mode' file will also be
842 converted to HTML.
843 When nil, the links still point to the plain \".org\" file."
844 :group 'org-export-html
845 :type 'boolean)
847 ;;;; Links :: Inline images
849 (defcustom org-html-inline-images t
850 "Non-nil means inline images into exported HTML pages.
851 This is done using an <img> tag. When nil, an anchor with href is used to
852 link to the image."
853 :group 'org-export-html
854 :version "24.4"
855 :package-version '(Org . "8.1")
856 :type 'boolean)
858 (defcustom org-html-inline-image-rules
859 '(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
860 ("http" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
861 ("https" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
862 "Rules characterizing image files that can be inlined into HTML.
863 A rule consists in an association whose key is the type of link
864 to consider, and value is a regexp that will be matched against
865 link's path."
866 :group 'org-export-html
867 :version "24.4"
868 :package-version '(Org . "8.0")
869 :type '(alist :key-type (string :tag "Type")
870 :value-type (regexp :tag "Path")))
872 ;;;; Plain Text
874 (defvar org-html-protect-char-alist
875 '(("&" . "&amp;")
876 ("<" . "&lt;")
877 (">" . "&gt;"))
878 "Alist of characters to be converted by `org-html-encode-plain-text'.")
880 ;;;; Src Block
882 (defcustom org-html-htmlize-output-type 'inline-css
883 "Output type to be used by htmlize when formatting code snippets.
884 Choices are `css' to export the CSS selectors only,`inline-css'
885 to export the CSS attribute values inline in the HTML or `nil' to
886 export plain text. We use as default `inline-css', in order to
887 make the resulting HTML self-containing.
889 However, this will fail when using Emacs in batch mode for export, because
890 then no rich font definitions are in place. It will also not be good if
891 people with different Emacs setup contribute HTML files to a website,
892 because the fonts will represent the individual setups. In these cases,
893 it is much better to let Org/Htmlize assign classes only, and to use
894 a style file to define the look of these classes.
895 To get a start for your css file, start Emacs session and make sure that
896 all the faces you are interested in are defined, for example by loading files
897 in all modes you want. Then, use the command
898 `\\[org-html-htmlize-generate-css]' to extract class definitions."
899 :group 'org-export-html
900 :type '(choice (const css) (const inline-css) (const nil)))
902 (defcustom org-html-htmlize-font-prefix "org-"
903 "The prefix for CSS class names for htmlize font specifications."
904 :group 'org-export-html
905 :type 'string)
907 ;;;; Table
909 (defcustom org-html-table-default-attributes
910 '(:border "2" :cellspacing "0" :cellpadding "6" :rules "groups" :frame "hsides")
911 "Default attributes and values which will be used in table tags.
912 This is a plist where attributes are symbols, starting with
913 colons, and values are strings.
915 When exporting to HTML5, these values will be disregarded."
916 :group 'org-export-html
917 :version "24.4"
918 :package-version '(Org . "8.0")
919 :type '(plist :key-type (symbol :tag "Property")
920 :value-type (string :tag "Value")))
922 (defcustom org-html-table-header-tags '("<th scope=\"%s\"%s>" . "</th>")
923 "The opening and ending tags for table header fields.
924 This is customizable so that alignment options can be specified.
925 The first %s will be filled with the scope of the field, either row or col.
926 The second %s will be replaced by a style entry to align the field.
927 See also the variable `org-html-table-use-header-tags-for-first-column'.
928 See also the variable `org-html-table-align-individual-fields'."
929 :group 'org-export-html
930 :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
932 (defcustom org-html-table-data-tags '("<td%s>" . "</td>")
933 "The opening and ending tags for table data fields.
934 This is customizable so that alignment options can be specified.
935 The first %s will be filled with the scope of the field, either row or col.
936 The second %s will be replaced by a style entry to align the field.
937 See also the variable `org-html-table-align-individual-fields'."
938 :group 'org-export-html
939 :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
941 (defcustom org-html-table-row-open-tag "<tr>"
942 "The opening tag for table rows.
943 This is customizable so that alignment options can be specified.
944 Instead of strings, these can be a Lisp function that will be
945 evaluated for each row in order to construct the table row tags.
947 The function will be called with these arguments:
949 `number': row number (0 is the first row)
950 `group-number': group number of current row
951 `start-group?': non-nil means the row starts a group
952 `end-group?': non-nil means the row ends a group
953 `top?': non-nil means this is the top row
954 `bottom?': non-nil means this is the bottom row
956 For example:
958 (setq org-html-table-row-open-tag
959 (lambda (number group-number start-group? end-group-p top? bottom?)
960 (cond (top? \"<tr class=\\\"tr-top\\\">\")
961 (bottom? \"<tr class=\\\"tr-bottom\\\">\")
962 (t (if (= (mod number 2) 1)
963 \"<tr class=\\\"tr-odd\\\">\"
964 \"<tr class=\\\"tr-even\\\">\")))))
966 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
967 and the bottom row, and otherwise alternate between \"tr-odd\" and
968 \"tr-even\" for odd and even rows."
969 :group 'org-export-html
970 :type '(choice :tag "Opening tag"
971 (string :tag "Specify")
972 (function)))
974 (defcustom org-html-table-row-close-tag "</tr>"
975 "The closing tag for table rows.
976 This is customizable so that alignment options can be specified.
977 Instead of strings, this can be a Lisp function that will be
978 evaluated for each row in order to construct the table row tags.
980 See documentation of `org-html-table-row-open-tag'."
981 :group 'org-export-html
982 :type '(choice :tag "Closing tag"
983 (string :tag "Specify")
984 (function)))
986 (defcustom org-html-table-align-individual-fields t
987 "Non-nil means attach style attributes for alignment to each table field.
988 When nil, alignment will only be specified in the column tags, but this
989 is ignored by some browsers (like Firefox, Safari). Opera does it right
990 though."
991 :group 'org-export-html
992 :type 'boolean)
994 (defcustom org-html-table-use-header-tags-for-first-column nil
995 "Non-nil means format column one in tables with header tags.
996 When nil, also column one will use data tags."
997 :group 'org-export-html
998 :type 'boolean)
1000 (defcustom org-html-table-caption-above t
1001 "When non-nil, place caption string at the beginning of the table.
1002 Otherwise, place it near the end."
1003 :group 'org-export-html
1004 :type 'boolean)
1006 ;;;; Tags
1008 (defcustom org-html-tag-class-prefix ""
1009 "Prefix to class names for TODO keywords.
1010 Each tag gets a class given by the tag itself, with this prefix.
1011 The default prefix is empty because it is nice to just use the keyword
1012 as a class name. But if you get into conflicts with other, existing
1013 CSS classes, then this prefix can be very useful."
1014 :group 'org-export-html
1015 :type 'string)
1017 ;;;; Template :: Generic
1019 (defcustom org-html-extension "html"
1020 "The extension for exported HTML files."
1021 :group 'org-export-html
1022 :type 'string)
1024 (defcustom org-html-xml-declaration
1025 '(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
1026 ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
1027 "The extension for exported HTML files.
1028 %s will be replaced with the charset of the exported file.
1029 This may be a string, or an alist with export extensions
1030 and corresponding declarations.
1032 This declaration only applies when exporting to XHTML."
1033 :group 'org-export-html
1034 :type '(choice
1035 (string :tag "Single declaration")
1036 (repeat :tag "Dependent on extension"
1037 (cons (string :tag "Extension")
1038 (string :tag "Declaration")))))
1040 (defcustom org-html-coding-system 'utf-8
1041 "Coding system for HTML export.
1042 Use utf-8 as the default value."
1043 :group 'org-export-html
1044 :version "24.4"
1045 :package-version '(Org . "8.0")
1046 :type 'coding-system)
1048 (defcustom org-html-doctype "xhtml-strict"
1049 "Document type definition to use for exported HTML files.
1050 Can be set with the in-buffer HTML_DOCTYPE property or for
1051 publishing, with :html-doctype."
1052 :group 'org-export-html
1053 :version "24.4"
1054 :package-version '(Org . "8.0")
1055 :type (append
1056 '(choice)
1057 (mapcar (lambda (x) `(const ,(car x))) org-html-doctype-alist)
1058 '((string :tag "Custom doctype" ))))
1060 (defcustom org-html-html5-fancy nil
1061 "Non-nil means using new HTML5 elements.
1062 This variable is ignored for anything other than HTML5 export.
1064 For compatibility with Internet Explorer, it's probably a good
1065 idea to download some form of the html5shiv (for instance
1066 https://code.google.com/p/html5shiv/) and add it to your
1067 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
1068 versions 8 and below."
1069 :group 'org-export-html
1070 :version "24.4"
1071 :package-version '(Org . "8.0")
1072 :type 'boolean)
1074 (defcustom org-html-container-element "div"
1075 "HTML element to use for wrapping top level sections.
1076 Can be set with the in-buffer HTML_CONTAINER property or for
1077 publishing, with :html-container.
1079 Note that changing the default will prevent you from using
1080 org-info.js for your website."
1081 :group 'org-export-html
1082 :version "24.4"
1083 :package-version '(Org . "8.0")
1084 :type 'string)
1086 (defcustom org-html-divs
1087 '((preamble "div" "preamble")
1088 (content "div" "content")
1089 (postamble "div" "postamble"))
1090 "Alist of the three section elements for HTML export.
1091 The car of each entry is one of `preamble', `content' or `postamble'.
1092 The cdrs of each entry are the ELEMENT_TYPE and ID for each
1093 section of the exported document.
1095 Note that changing the default will prevent you from using
1096 org-info.js for your website."
1097 :group 'org-export-html
1098 :version "24.4"
1099 :package-version '(Org . "8.0")
1100 :type '(list :greedy t
1101 (list :tag "Preamble"
1102 (const :format "" preamble)
1103 (string :tag "element") (string :tag " id"))
1104 (list :tag "Content"
1105 (const :format "" content)
1106 (string :tag "element") (string :tag " id"))
1107 (list :tag "Postamble" (const :format "" postamble)
1108 (string :tag " id") (string :tag "element"))))
1110 (defconst org-html-checkbox-types
1111 '((unicode .
1112 ((on . "&#x2611;") (off . "&#x2610;") (trans . "&#x2610;")))
1113 (ascii .
1114 ((on . "<code>[X]</code>")
1115 (off . "<code>[&#xa0;]</code>")
1116 (trans . "<code>[-]</code>")))
1117 (html .
1118 ((on . "<input type='checkbox' checked='checked' />")
1119 (off . "<input type='checkbox' />")
1120 (trans . "<input type='checkbox' />"))))
1121 "Alist of checkbox types.
1122 The cdr of each entry is an alist list three checkbox types for
1123 HTML export: `on', `off' and `trans'.
1125 The choices are:
1126 `unicode' Unicode characters (HTML entities)
1127 `ascii' ASCII characters
1128 `html' HTML checkboxes
1130 Note that only the ascii characters implement tri-state
1131 checkboxes. The other two use the `off' checkbox for `trans'.")
1133 (defcustom org-html-checkbox-type 'ascii
1134 "The type of checkboxes to use for HTML export.
1135 See `org-html-checkbox-types' for for the values used for each
1136 option."
1137 :group 'org-export-html
1138 :version "24.4"
1139 :package-version '(Org . "8.0")
1140 :type '(choice
1141 (const :tag "ASCII characters" ascii)
1142 (const :tag "Unicode characters" unicode)
1143 (const :tag "HTML checkboxes" html)))
1145 (defcustom org-html-metadata-timestamp-format "%Y-%m-%d %a %H:%M"
1146 "Format used for timestamps in preamble, postamble and metadata.
1147 See `format-time-string' for more information on its components."
1148 :group 'org-export-html
1149 :version "24.4"
1150 :package-version '(Org . "8.0")
1151 :type 'string)
1153 ;;;; Template :: Mathjax
1155 (defcustom org-html-mathjax-options
1156 '((path "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML" )
1157 (scale "100")
1158 (align "center")
1159 (font "TeX")
1160 (linebreaks "false")
1161 (autonumber "AMS")
1162 (indent "0em")
1163 (multlinewidth "85%")
1164 (tagindent ".8em")
1165 (tagside "right"))
1166 "Options for MathJax setup.
1168 Alist of the following elements. All values are strings.
1170 path The path to MathJax.
1171 scale Scaling with HTML-CSS, MathML and SVG output engines.
1172 align How to align display math: left, center, or right.
1173 font The font to use with HTML-CSS and SVG output. As of MathJax 2.5
1174 the following values are understood: \"TeX\", \"STIX-Web\",
1175 \"Asana-Math\", \"Neo-Euler\", \"Gyre-Pagella\",
1176 \"Gyre-Termes\", and \"Latin-Modern\".
1177 linebreaks Let MathJax perform automatic linebreaks. Valid values
1178 are \"true\" and \"false\".
1179 indent If align is not center, how far from the left/right side?
1180 Valid values are \"left\" and \"right\"
1181 multlinewidth The width of the multline environment.
1182 autonumber How to number equations. Valid values are \"None\",
1183 \"all\" and \"AMS Math\".
1184 tagindent The amount tags are indented.
1185 tagside Which side to show tags/labels on. Valid values are
1186 \"left\" and \"right\"
1188 You can also customize this for each buffer, using something like
1190 #+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
1192 For further information about MathJax options, see the MathJax documentation:
1194 http://docs.mathjax.org/"
1195 :group 'org-export-html
1196 :package-version '(Org . "8.3")
1197 :type '(list :greedy t
1198 (list :tag "path (the path from where to load MathJax.js)"
1199 (const :format " " path) (string))
1200 (list :tag "scale (scaling for the displayed math)"
1201 (const :format " " scale) (string))
1202 (list :tag "align (alignment of displayed equations)"
1203 (const :format " " align) (string))
1204 (list :tag "font (used to display math)"
1205 (const :format " " font)
1206 (choice (const "TeX")
1207 (const "STIX-Web")
1208 (const "Asana-Math")
1209 (const "Neo-Euler")
1210 (const "Gyre-Pagella")
1211 (const "Gyre-Termes")
1212 (const "Latin-Modern")))
1213 (list :tag "linebreaks (automatic line-breaking)"
1214 (const :format " " linebreaks)
1215 (choice (const "true")
1216 (const "false")))
1217 (list :tag "autonumber (when should equations be numbered)"
1218 (const :format " " autonumber)
1219 (choice (const "AMS")
1220 (const "None")
1221 (const "All")))
1222 (list :tag "indent (indentation with left or right alignment)"
1223 (const :format " " indent) (string))
1224 (list :tag "multlinewidth (width to use for the multline environment)"
1225 (const :format " " multlinewidth) (string))
1226 (list :tag "tagindent (the indentation of tags from left or right)"
1227 (const :format " " tagindent) (string))
1228 (list :tag "tagside (location of tags)"
1229 (const :format " " tagside)
1230 (choice (const "left")
1231 (const "right")))))
1233 (defcustom org-html-mathjax-template
1234 "<script type=\"text/x-mathjax-config\">
1235 MathJax.Hub.Config({
1236 displayAlign: \"%ALIGN\",
1237 displayIndent: \"%INDENT\",
1239 \"HTML-CSS\": { scale: %SCALE,
1240 linebreaks: { automatic: \"%LINEBREAKS\" },
1241 webFont: \"%FONT\"
1243 SVG: {scale: %SCALE,
1244 linebreaks: { automatic: \"%LINEBREAKS\" },
1245 font: \"%FONT\"},
1246 NativeMML: {scale: %SCALE},
1247 TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"},
1248 MultLineWidth: \"%MULTLINEWIDTH\",
1249 TagSide: \"%TAGSIDE\",
1250 TagIndent: \"%TAGINDENT\"
1253 </script>
1254 <script type=\"text/javascript\"
1255 src=\"%PATH\"></script>"
1256 "The MathJax template. See also `org-html-mathjax-options'."
1257 :group 'org-export-html
1258 :type 'string)
1260 ;;;; Template :: Postamble
1262 (defcustom org-html-postamble 'auto
1263 "Non-nil means insert a postamble in HTML export.
1265 When set to `auto', check against the
1266 `org-export-with-author/email/creator/date' variables to set the
1267 content of the postamble. When set to a string, use this string
1268 as the postamble. When t, insert a string as defined by the
1269 formatting string in `org-html-postamble-format'.
1271 When set to a function, apply this function and insert the
1272 returned string. The function takes the property list of export
1273 options as its only argument.
1275 Setting :html-postamble in publishing projects will take
1276 precedence over this variable."
1277 :group 'org-export-html
1278 :type '(choice (const :tag "No postamble" nil)
1279 (const :tag "Auto postamble" auto)
1280 (const :tag "Default formatting string" t)
1281 (string :tag "Custom formatting string")
1282 (function :tag "Function (must return a string)")))
1284 (defcustom org-html-postamble-format
1285 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1286 <p class=\"date\">Date: %d</p>
1287 <p class=\"creator\">%c</p>
1288 <p class=\"validation\">%v</p>"))
1289 "Alist of languages and format strings for the HTML postamble.
1291 The first element of each list is the language code, as used for
1292 the LANGUAGE keyword. See `org-export-default-language'.
1294 The second element of each list is a format string to format the
1295 postamble itself. This format string can contain these elements:
1297 %t stands for the title.
1298 %s stands for the subtitle.
1299 %a stands for the author's name.
1300 %e stands for the author's email.
1301 %d stands for the date.
1302 %c will be replaced by `org-html-creator-string'.
1303 %v will be replaced by `org-html-validation-link'.
1304 %T will be replaced by the export time.
1305 %C will be replaced by the last modification time.
1307 If you need to use a \"%\" character, you need to escape it
1308 like that: \"%%\"."
1309 :group 'org-export-html
1310 :type '(repeat
1311 (list (string :tag "Language")
1312 (string :tag "Format string"))))
1314 (defcustom org-html-validation-link
1315 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1316 "Link to HTML validation service."
1317 :group 'org-export-html
1318 :type 'string)
1320 (defcustom org-html-creator-string
1321 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1322 emacs-version
1323 (if (fboundp 'org-version) (org-version) "unknown version"))
1324 "Information about the creator of the HTML document.
1325 This option can also be set on with the CREATOR keyword."
1326 :group 'org-export-html
1327 :version "24.4"
1328 :package-version '(Org . "8.0")
1329 :type '(string :tag "Creator string"))
1331 ;;;; Template :: Preamble
1333 (defcustom org-html-preamble t
1334 "Non-nil means insert a preamble in HTML export.
1336 When t, insert a string as defined by the formatting string in
1337 `org-html-preamble-format'. When set to a string, use this
1338 formatting string instead (see `org-html-postamble-format' for an
1339 example of such a formatting string).
1341 When set to a function, apply this function and insert the
1342 returned string. The function takes the property list of export
1343 options as its only argument.
1345 Setting :html-preamble in publishing projects will take
1346 precedence over this variable."
1347 :group 'org-export-html
1348 :type '(choice (const :tag "No preamble" nil)
1349 (const :tag "Default preamble" t)
1350 (string :tag "Custom formatting string")
1351 (function :tag "Function (must return a string)")))
1353 (defcustom org-html-preamble-format '(("en" ""))
1354 "Alist of languages and format strings for the HTML preamble.
1356 The first element of each list is the language code, as used for
1357 the LANGUAGE keyword. See `org-export-default-language'.
1359 The second element of each list is a format string to format the
1360 preamble itself. This format string can contain these elements:
1362 %t stands for the title.
1363 %s stands for the subtitle.
1364 %a stands for the author's name.
1365 %e stands for the author's email.
1366 %d stands for the date.
1367 %c will be replaced by `org-html-creator-string'.
1368 %v will be replaced by `org-html-validation-link'.
1369 %T will be replaced by the export time.
1370 %C will be replaced by the last modification time.
1372 If you need to use a \"%\" character, you need to escape it
1373 like that: \"%%\".
1375 See the default value of `org-html-postamble-format' for an
1376 example."
1377 :group 'org-export-html
1378 :type '(repeat
1379 (list (string :tag "Language")
1380 (string :tag "Format string"))))
1382 (defcustom org-html-link-up ""
1383 "Where should the \"UP\" link of exported HTML pages lead?"
1384 :group 'org-export-html
1385 :type '(string :tag "File or URL"))
1387 (defcustom org-html-link-home ""
1388 "Where should the \"HOME\" link of exported HTML pages lead?"
1389 :group 'org-export-html
1390 :type '(string :tag "File or URL"))
1392 (defcustom org-html-link-use-abs-url nil
1393 "Should we prepend relative links with HTML_LINK_HOME?"
1394 :group 'org-export-html
1395 :version "24.4"
1396 :package-version '(Org . "8.1")
1397 :type 'boolean)
1399 (defcustom org-html-home/up-format
1400 "<div id=\"org-div-home-and-up\">
1401 <a accesskey=\"h\" href=\"%s\"> UP </a>
1403 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1404 </div>"
1405 "Snippet used to insert the HOME and UP links.
1406 This is a format string, the first %s will receive the UP link,
1407 the second the HOME link. If both `org-html-link-up' and
1408 `org-html-link-home' are empty, the entire snippet will be
1409 ignored."
1410 :group 'org-export-html
1411 :type 'string)
1413 ;;;; Template :: Scripts
1415 (defcustom org-html-head-include-scripts t
1416 "Non-nil means include the JavaScript snippets in exported HTML files.
1417 The actual script is defined in `org-html-scripts' and should
1418 not be modified."
1419 :group 'org-export-html
1420 :version "24.4"
1421 :package-version '(Org . "8.0")
1422 :type 'boolean)
1424 ;;;; Template :: Styles
1426 (defcustom org-html-head-include-default-style t
1427 "Non-nil means include the default style in exported HTML files.
1428 The actual style is defined in `org-html-style-default' and
1429 should not be modified. Use `org-html-head' to use your own
1430 style information."
1431 :group 'org-export-html
1432 :version "24.4"
1433 :package-version '(Org . "8.0")
1434 :type 'boolean)
1435 ;;;###autoload
1436 (put 'org-html-head-include-default-style 'safe-local-variable 'booleanp)
1438 (defcustom org-html-head ""
1439 "Org-wide head definitions for exported HTML files.
1441 This variable can contain the full HTML structure to provide a
1442 style, including the surrounding HTML tags. You can consider
1443 including definitions for the following classes: title, todo,
1444 done, timestamp, timestamp-kwd, tag, target.
1446 For example, a valid value would be:
1448 <style type=\"text/css\">
1449 <![CDATA[
1450 p { font-weight: normal; color: gray; }
1451 h1 { color: black; }
1452 .title { text-align: center; }
1453 .todo, .timestamp-kwd { color: red; }
1454 .done { color: green; }
1456 </style>
1458 If you want to refer to an external style, use something like
1460 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1462 As the value of this option simply gets inserted into the HTML
1463 <head> header, you can use it to add any arbitrary text to the
1464 header.
1466 You can set this on a per-file basis using #+HTML_HEAD:,
1467 or for publication projects using the :html-head property."
1468 :group 'org-export-html
1469 :version "24.4"
1470 :package-version '(Org . "8.0")
1471 :type 'string)
1472 ;;;###autoload
1473 (put 'org-html-head 'safe-local-variable 'stringp)
1475 (defcustom org-html-head-extra ""
1476 "More head information to add in the HTML output.
1478 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1479 or for publication projects using the :html-head-extra property."
1480 :group 'org-export-html
1481 :version "24.4"
1482 :package-version '(Org . "8.0")
1483 :type 'string)
1484 ;;;###autoload
1485 (put 'org-html-head-extra 'safe-local-variable 'stringp)
1487 ;;;; Template :: Viewport
1489 (defcustom org-html-viewport '((width "device-width")
1490 (initial-scale "1")
1491 (minimum-scale "")
1492 (maximum-scale "")
1493 (user-scalable ""))
1494 "Viewport options for mobile-optimized sites.
1496 The following values are recognized
1498 width Size of the viewport.
1499 initial-scale Zoom level when the page is first loaded.
1500 minimum-scale Minimum allowed zoom level.
1501 maximum-scale Maximum allowed zoom level.
1502 user-scalable Whether zoom can be changed.
1504 The viewport meta tag is inserted if this variable is non-nil.
1506 See the following site for a reference:
1507 https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag"
1508 :group 'org-export-html
1509 :version "26.1"
1510 :package-version '(Org . "8.3")
1511 :type '(choice (const :tag "Disable" nil)
1512 (list :tag "Enable"
1513 (list :tag "Width of viewport"
1514 (const :format " " width)
1515 (choice (const :tag "unset" "")
1516 (string)))
1517 (list :tag "Initial scale"
1518 (const :format " " initial-scale)
1519 (choice (const :tag "unset" "")
1520 (string)))
1521 (list :tag "Minimum scale/zoom"
1522 (const :format " " minimum-scale)
1523 (choice (const :tag "unset" "")
1524 (string)))
1525 (list :tag "Maximum scale/zoom"
1526 (const :format " " maximum-scale)
1527 (choice (const :tag "unset" "")
1528 (string)))
1529 (list :tag "User scalable/zoomable"
1530 (const :format " " user-scalable)
1531 (choice (const :tag "unset" "")
1532 (const "true")
1533 (const "false"))))))
1535 ;;;; Todos
1537 (defcustom org-html-todo-kwd-class-prefix ""
1538 "Prefix to class names for TODO keywords.
1539 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1540 The default prefix is empty because it is nice to just use the keyword
1541 as a class name. But if you get into conflicts with other, existing
1542 CSS classes, then this prefix can be very useful."
1543 :group 'org-export-html
1544 :type 'string)
1547 ;;; Internal Functions
1549 (defun org-html-xhtml-p (info)
1550 (let ((dt (downcase (plist-get info :html-doctype))))
1551 (string-match-p "xhtml" dt)))
1553 (defun org-html-html5-p (info)
1554 (let ((dt (downcase (plist-get info :html-doctype))))
1555 (member dt '("html5" "xhtml5" "<!doctype html>"))))
1557 (defun org-html--html5-fancy-p (info)
1558 "Non-nil when exporting to HTML5 with fancy elements.
1559 INFO is the current state of the export process, as a plist."
1560 (and (plist-get info :html-html5-fancy)
1561 (org-html-html5-p info)))
1563 (defun org-html-close-tag (tag attr info)
1564 "Return close-tag for string TAG.
1565 ATTR specifies additional attributes. INFO is a property list
1566 containing current export state."
1567 (concat "<" tag
1568 (org-string-nw-p (concat " " attr))
1569 (if (org-html-xhtml-p info) " />" ">")))
1571 (defun org-html-doctype (info)
1572 "Return correct HTML doctype tag.
1573 INFO is a plist used as a communication channel. Doctype tag is
1574 extracted from `org-html-doctype-alist', or the literal value
1575 of :html-doctype from INFO if :html-doctype is not found in the
1576 alist."
1577 (let ((dt (plist-get info :html-doctype)))
1578 (or (cdr (assoc dt org-html-doctype-alist)) dt)))
1580 (defun org-html--make-attribute-string (attributes)
1581 "Return a list of attributes, as a string.
1582 ATTRIBUTES is a plist where values are either strings or nil. An
1583 attribute with a nil value will be omitted from the result."
1584 (let (output)
1585 (dolist (item attributes (mapconcat 'identity (nreverse output) " "))
1586 (cond ((null item) (pop output))
1587 ((symbolp item) (push (substring (symbol-name item) 1) output))
1588 (t (let ((key (car output))
1589 (value (replace-regexp-in-string
1590 "\"" "&quot;" (org-html-encode-plain-text item))))
1591 (setcar output (format "%s=\"%s\"" key value))))))))
1593 (defun org-html--wrap-image (contents info &optional caption label)
1594 "Wrap CONTENTS string within an appropriate environment for images.
1595 INFO is a plist used as a communication channel. When optional
1596 arguments CAPTION and LABEL are given, use them for caption and
1597 \"id\" attribute."
1598 (let ((html5-fancy (org-html--html5-fancy-p info)))
1599 (format (if html5-fancy "\n<figure%s>\n%s%s\n</figure>"
1600 "\n<div%s class=\"figure\">\n%s%s\n</div>")
1601 ;; ID.
1602 (if (org-string-nw-p label) (format " id=\"%s\"" label) "")
1603 ;; Contents.
1604 (if html5-fancy contents (format "<p>%s</p>" contents))
1605 ;; Caption.
1606 (if (not (org-string-nw-p caption)) ""
1607 (format (if html5-fancy "\n<figcaption>%s</figcaption>"
1608 "\n<p>%s</p>")
1609 caption)))))
1611 (defun org-html--format-image (source attributes info)
1612 "Return \"img\" tag with given SOURCE and ATTRIBUTES.
1613 SOURCE is a string specifying the location of the image.
1614 ATTRIBUTES is a plist, as returned by
1615 `org-export-read-attribute'. INFO is a plist used as
1616 a communication channel."
1617 (if (string= "svg" (file-name-extension source))
1618 (org-html--svg-image source attributes info)
1619 (org-html-close-tag
1620 "img"
1621 (org-html--make-attribute-string
1622 (org-combine-plists
1623 (list :src source
1624 :alt (if (string-match-p "^ltxpng/" source)
1625 (org-html-encode-plain-text
1626 (org-find-text-property-in-string 'org-latex-src source))
1627 (file-name-nondirectory source)))
1628 attributes))
1629 info)))
1631 (defun org-html--svg-image (source attributes info)
1632 "Return \"object\" embedding svg file SOURCE with given ATTRIBUTES.
1633 INFO is a plist used as a communication channel.
1635 The special attribute \"fallback\" can be used to specify a
1636 fallback image file to use if the object embedding is not
1637 supported. CSS class \"org-svg\" is assigned as the class of the
1638 object unless a different class is specified with an attribute."
1639 (let ((fallback (plist-get attributes :fallback))
1640 (attrs (org-html--make-attribute-string
1641 (org-combine-plists
1642 ;; Remove fallback attribute, which is not meant to
1643 ;; appear directly in the attributes string, and
1644 ;; provide a default class if none is set.
1645 '(:class "org-svg") attributes '(:fallback nil)))))
1646 (format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>"
1647 source
1648 attrs
1649 (if fallback
1650 (org-html-close-tag
1651 "img" (format "src=\"%s\" %s" fallback attrs) info)
1652 "Sorry, your browser does not support SVG."))))
1654 (defun org-html--textarea-block (element)
1655 "Transcode ELEMENT into a textarea block.
1656 ELEMENT is either a src block or an example block."
1657 (let* ((code (car (org-export-unravel-code element)))
1658 (attr (org-export-read-attribute :attr_html element)))
1659 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1660 (or (plist-get attr :width) 80)
1661 (or (plist-get attr :height) (org-count-lines code))
1662 code)))
1664 (defun org-html--has-caption-p (element &optional _info)
1665 "Non-nil when ELEMENT has a caption affiliated keyword.
1666 INFO is a plist used as a communication channel. This function
1667 is meant to be used as a predicate for `org-export-get-ordinal' or
1668 a value to `org-html-standalone-image-predicate'."
1669 (org-element-property :caption element))
1671 ;;;; Table
1673 (defun org-html-htmlize-region-for-paste (beg end)
1674 "Convert the region between BEG and END to HTML, using htmlize.el.
1675 This is much like `htmlize-region-for-paste', only that it uses
1676 the settings define in the org-... variables."
1677 (let* ((htmlize-output-type org-html-htmlize-output-type)
1678 (htmlize-css-name-prefix org-html-htmlize-font-prefix)
1679 (htmlbuf (htmlize-region beg end)))
1680 (unwind-protect
1681 (with-current-buffer htmlbuf
1682 (buffer-substring (plist-get htmlize-buffer-places 'content-start)
1683 (plist-get htmlize-buffer-places 'content-end)))
1684 (kill-buffer htmlbuf))))
1686 ;;;###autoload
1687 (defun org-html-htmlize-generate-css ()
1688 "Create the CSS for all font definitions in the current Emacs session.
1689 Use this to create face definitions in your CSS style file that can then
1690 be used by code snippets transformed by htmlize.
1691 This command just produces a buffer that contains class definitions for all
1692 faces used in the current Emacs session. You can copy and paste the ones you
1693 need into your CSS file.
1695 If you then set `org-html-htmlize-output-type' to `css', calls
1696 to the function `org-html-htmlize-region-for-paste' will
1697 produce code that uses these same face definitions."
1698 (interactive)
1699 (require 'htmlize)
1700 (and (get-buffer "*html*") (kill-buffer "*html*"))
1701 (with-temp-buffer
1702 (let ((fl (face-list))
1703 (htmlize-css-name-prefix "org-")
1704 (htmlize-output-type 'css)
1705 f i)
1706 (while (setq f (pop fl)
1707 i (and f (face-attribute f :inherit)))
1708 (when (and (symbolp f) (or (not i) (not (listp i))))
1709 (insert (org-add-props (copy-sequence "1") nil 'face f))))
1710 (htmlize-region (point-min) (point-max))))
1711 (pop-to-buffer-same-window "*html*")
1712 (goto-char (point-min))
1713 (if (re-search-forward "<style" nil t)
1714 (delete-region (point-min) (match-beginning 0)))
1715 (if (re-search-forward "</style>" nil t)
1716 (delete-region (1+ (match-end 0)) (point-max)))
1717 (beginning-of-line 1)
1718 (if (looking-at " +") (replace-match ""))
1719 (goto-char (point-min)))
1721 (defun org-html--make-string (n string)
1722 "Build a string by concatenating N times STRING."
1723 (let (out) (dotimes (_ n out) (setq out (concat string out)))))
1725 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1726 "Turn todo keyword KWD into a valid class name.
1727 Replaces invalid characters with \"_\"."
1728 (replace-regexp-in-string "[^a-zA-Z0-9_]" "_" kwd nil t))
1730 (defun org-html-footnote-section (info)
1731 "Format the footnote section.
1732 INFO is a plist used as a communication channel."
1733 (let* ((fn-alist (org-export-collect-footnote-definitions info))
1734 (fn-alist
1735 (cl-loop for (n _type raw) in fn-alist collect
1736 (cons n (if (eq (org-element-type raw) 'org-data)
1737 (org-trim (org-export-data raw info))
1738 (format "<div class=\"footpara\">%s</div>"
1739 (org-trim (org-export-data raw info))))))))
1740 (when fn-alist
1741 (format
1742 (plist-get info :html-footnotes-section)
1743 (org-html--translate "Footnotes" info)
1744 (format
1745 "\n%s\n"
1746 (mapconcat
1747 (lambda (fn)
1748 (let ((n (car fn)) (def (cdr fn)))
1749 (format
1750 "<div class=\"footdef\">%s %s</div>\n"
1751 (format
1752 (plist-get info :html-footnote-format)
1753 (org-html--anchor
1754 (format "fn.%d" n)
1756 (format " class=\"footnum\" href=\"#fnr.%d\"" n)
1757 info))
1758 def)))
1759 fn-alist
1760 "\n"))))))
1763 ;;; Template
1765 (defun org-html--build-meta-info (info)
1766 "Return meta tags for exported document.
1767 INFO is a plist used as a communication channel."
1768 (let ((protect-string
1769 (lambda (str)
1770 (replace-regexp-in-string
1771 "\"" "&quot;" (org-html-encode-plain-text str))))
1772 (title (org-export-data (plist-get info :title) info))
1773 (author (and (plist-get info :with-author)
1774 (let ((auth (plist-get info :author)))
1775 (and auth
1776 ;; Return raw Org syntax, skipping non
1777 ;; exportable objects.
1778 (org-element-interpret-data
1779 (org-element-map auth
1780 (cons 'plain-text org-element-all-objects)
1781 'identity info))))))
1782 (description (plist-get info :description))
1783 (keywords (plist-get info :keywords))
1784 (charset (or (and org-html-coding-system
1785 (fboundp 'coding-system-get)
1786 (coding-system-get org-html-coding-system
1787 'mime-charset))
1788 "iso-8859-1")))
1789 (concat
1790 (when (plist-get info :time-stamp-file)
1791 (format-time-string
1792 (concat "<!-- "
1793 (plist-get info :html-metadata-timestamp-format)
1794 " -->\n")))
1795 (format
1796 (if (org-html-html5-p info)
1797 (org-html-close-tag "meta" "charset=\"%s\"" info)
1798 (org-html-close-tag
1799 "meta" "http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1800 info))
1801 charset) "\n"
1802 (let ((viewport-options
1803 (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell)))
1804 (plist-get info :html-viewport))))
1805 (and viewport-options
1806 (concat
1807 (org-html-close-tag
1808 "meta"
1809 (format "name=\"viewport\" content=\"%s\""
1810 (mapconcat
1811 (lambda (elm) (format "%s=%s" (car elm) (cadr elm)))
1812 viewport-options ", "))
1813 info)
1814 "\n")))
1815 (format "<title>%s</title>\n" title)
1816 (org-html-close-tag "meta" "name=\"generator\" content=\"Org mode\"" info)
1817 "\n"
1818 (and (org-string-nw-p author)
1819 (concat
1820 (org-html-close-tag "meta"
1821 (format "name=\"author\" content=\"%s\""
1822 (funcall protect-string author))
1823 info)
1824 "\n"))
1825 (and (org-string-nw-p description)
1826 (concat
1827 (org-html-close-tag "meta"
1828 (format "name=\"description\" content=\"%s\"\n"
1829 (funcall protect-string description))
1830 info)
1831 "\n"))
1832 (and (org-string-nw-p keywords)
1833 (concat
1834 (org-html-close-tag "meta"
1835 (format "name=\"keywords\" content=\"%s\""
1836 (funcall protect-string keywords))
1837 info)
1838 "\n")))))
1840 (defun org-html--build-head (info)
1841 "Return information for the <head>..</head> of the HTML output.
1842 INFO is a plist used as a communication channel."
1843 (org-element-normalize-string
1844 (concat
1845 (when (plist-get info :html-head-include-default-style)
1846 (org-element-normalize-string org-html-style-default))
1847 (org-element-normalize-string (plist-get info :html-head))
1848 (org-element-normalize-string (plist-get info :html-head-extra))
1849 (when (and (plist-get info :html-htmlized-css-url)
1850 (eq org-html-htmlize-output-type 'css))
1851 (org-html-close-tag "link"
1852 (format "rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1853 (plist-get info :html-htmlized-css-url))
1854 info))
1855 (when (plist-get info :html-head-include-scripts) org-html-scripts))))
1857 (defun org-html--build-mathjax-config (info)
1858 "Insert the user setup into the mathjax template.
1859 INFO is a plist used as a communication channel."
1860 (when (and (memq (plist-get info :with-latex) '(mathjax t))
1861 (org-element-map (plist-get info :parse-tree)
1862 '(latex-fragment latex-environment) 'identity info t))
1863 (let ((template (plist-get info :html-mathjax-template))
1864 (options (plist-get info :html-mathjax-options))
1865 (in-buffer (or (plist-get info :html-mathjax) "")))
1866 (dolist (e options (org-element-normalize-string template))
1867 (let ((name (car e))
1868 (val (nth 1 e)))
1869 (when (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
1870 (setq val
1871 (car (read-from-string (substring in-buffer (match-end 0))))))
1872 (unless (stringp val) (setq val (format "%s" val)))
1873 (while (string-match (concat "%" (upcase (symbol-name name)))
1874 template)
1875 (setq template (replace-match val t t template))))))))
1877 (defun org-html-format-spec (info)
1878 "Return format specification for preamble and postamble.
1879 INFO is a plist used as a communication channel."
1880 (let ((timestamp-format (plist-get info :html-metadata-timestamp-format)))
1881 `((?t . ,(org-export-data (plist-get info :title) info))
1882 (?s . ,(org-export-data (plist-get info :subtitle) info))
1883 (?d . ,(org-export-data (org-export-get-date info timestamp-format)
1884 info))
1885 (?T . ,(format-time-string timestamp-format))
1886 (?a . ,(org-export-data (plist-get info :author) info))
1887 (?e . ,(mapconcat
1888 (lambda (e) (format "<a href=\"mailto:%s\">%s</a>" e e))
1889 (split-string (plist-get info :email) ",+ *")
1890 ", "))
1891 (?c . ,(plist-get info :creator))
1892 (?C . ,(let ((file (plist-get info :input-file)))
1893 (format-time-string timestamp-format
1894 (and file (nth 5 (file-attributes file))))))
1895 (?v . ,(or (plist-get info :html-validation-link) "")))))
1897 (defun org-html--build-pre/postamble (type info)
1898 "Return document preamble or postamble as a string, or nil.
1899 TYPE is either `preamble' or `postamble', INFO is a plist used as a
1900 communication channel."
1901 (let ((section (plist-get info (intern (format ":html-%s" type))))
1902 (spec (org-html-format-spec info)))
1903 (when section
1904 (let ((section-contents
1905 (if (functionp section) (funcall section info)
1906 (cond
1907 ((stringp section) (format-spec section spec))
1908 ((eq section 'auto)
1909 (let ((date (cdr (assq ?d spec)))
1910 (author (cdr (assq ?a spec)))
1911 (email (cdr (assq ?e spec)))
1912 (creator (cdr (assq ?c spec)))
1913 (validation-link (cdr (assq ?v spec))))
1914 (concat
1915 (when (and (plist-get info :with-date)
1916 (org-string-nw-p date))
1917 (format "<p class=\"date\">%s: %s</p>\n"
1918 (org-html--translate "Date" info)
1919 date))
1920 (when (and (plist-get info :with-author)
1921 (org-string-nw-p author))
1922 (format "<p class=\"author\">%s: %s</p>\n"
1923 (org-html--translate "Author" info)
1924 author))
1925 (when (and (plist-get info :with-email)
1926 (org-string-nw-p email))
1927 (format "<p class=\"email\">%s: %s</p>\n"
1928 (org-html--translate "Email" info)
1929 email))
1930 (when (plist-get info :time-stamp-file)
1931 (format
1932 "<p class=\"date\">%s: %s</p>\n"
1933 (org-html--translate "Created" info)
1934 (format-time-string
1935 (plist-get info :html-metadata-timestamp-format))))
1936 (when (plist-get info :with-creator)
1937 (format "<p class=\"creator\">%s</p>\n" creator))
1938 (format "<p class=\"validation\">%s</p>\n"
1939 validation-link))))
1940 (t (format-spec
1941 (or (cadr (assoc-string
1942 (plist-get info :language)
1943 (eval (intern
1944 (format "org-html-%s-format" type)))
1946 (cadr
1947 (assoc-string
1948 "en"
1949 (eval
1950 (intern (format "org-html-%s-format" type)))
1951 t)))
1952 spec))))))
1953 (let ((div (assq type (plist-get info :html-divs))))
1954 (when (org-string-nw-p section-contents)
1955 (concat
1956 (format "<%s id=\"%s\" class=\"%s\">\n"
1957 (nth 1 div)
1958 (nth 2 div)
1959 org-html--pre/postamble-class)
1960 (org-element-normalize-string section-contents)
1961 (format "</%s>\n" (nth 1 div)))))))))
1963 (defun org-html-inner-template (contents info)
1964 "Return body of document string after HTML conversion.
1965 CONTENTS is the transcoded contents string. INFO is a plist
1966 holding export options."
1967 (concat
1968 ;; Table of contents.
1969 (let ((depth (plist-get info :with-toc)))
1970 (when depth (org-html-toc depth info)))
1971 ;; Document contents.
1972 contents
1973 ;; Footnotes section.
1974 (org-html-footnote-section info)))
1976 (defun org-html-template (contents info)
1977 "Return complete document string after HTML conversion.
1978 CONTENTS is the transcoded contents string. INFO is a plist
1979 holding export options."
1980 (concat
1981 (when (and (not (org-html-html5-p info)) (org-html-xhtml-p info))
1982 (let* ((xml-declaration (plist-get info :html-xml-declaration))
1983 (decl (or (and (stringp xml-declaration) xml-declaration)
1984 (cdr (assoc (plist-get info :html-extension)
1985 xml-declaration))
1986 (cdr (assoc "html" xml-declaration))
1987 "")))
1988 (when (not (or (not decl) (string= "" decl)))
1989 (format "%s\n"
1990 (format decl
1991 (or (and org-html-coding-system
1992 (fboundp 'coding-system-get)
1993 (coding-system-get org-html-coding-system 'mime-charset))
1994 "iso-8859-1"))))))
1995 (org-html-doctype info)
1996 "\n"
1997 (concat "<html"
1998 (cond ((org-html-xhtml-p info)
1999 (format
2000 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
2001 (plist-get info :language) (plist-get info :language)))
2002 ((org-html-html5-p info)
2003 (format " lang=\"%s\"" (plist-get info :language))))
2004 ">\n")
2005 "<head>\n"
2006 (org-html--build-meta-info info)
2007 (org-html--build-head info)
2008 (org-html--build-mathjax-config info)
2009 "</head>\n"
2010 "<body>\n"
2011 (let ((link-up (org-trim (plist-get info :html-link-up)))
2012 (link-home (org-trim (plist-get info :html-link-home))))
2013 (unless (and (string= link-up "") (string= link-home ""))
2014 (format (plist-get info :html-home/up-format)
2015 (or link-up link-home)
2016 (or link-home link-up))))
2017 ;; Preamble.
2018 (org-html--build-pre/postamble 'preamble info)
2019 ;; Document contents.
2020 (let ((div (assq 'content (plist-get info :html-divs))))
2021 (format "<%s id=\"%s\">\n" (nth 1 div) (nth 2 div)))
2022 ;; Document title.
2023 (when (plist-get info :with-title)
2024 (let ((title (plist-get info :title))
2025 (subtitle (plist-get info :subtitle))
2026 (html5-fancy (org-html--html5-fancy-p info)))
2027 (when title
2028 (format
2029 (if html5-fancy
2030 "<header>\n<h1 class=\"title\">%s</h1>\n%s</header>"
2031 "<h1 class=\"title\">%s%s</h1>\n")
2032 (org-export-data title info)
2033 (if subtitle
2034 (format
2035 (if html5-fancy
2036 "<p class=\"subtitle\">%s</p>\n"
2037 "\n<br>\n<span class=\"subtitle\">%s</span>\n")
2038 (org-export-data subtitle info))
2039 "")))))
2040 contents
2041 (format "</%s>\n" (nth 1 (assq 'content (plist-get info :html-divs))))
2042 ;; Postamble.
2043 (org-html--build-pre/postamble 'postamble info)
2044 ;; Closing document.
2045 "</body>\n</html>"))
2047 (defun org-html--translate (s info)
2048 "Translate string S according to specified language.
2049 INFO is a plist used as a communication channel."
2050 (org-export-translate s :html info))
2052 ;;;; Anchor
2054 (defun org-html--anchor (id desc attributes info)
2055 "Format a HTML anchor."
2056 (let* ((name (and (plist-get info :html-allow-name-attribute-in-anchors) id))
2057 (attributes (concat (and id (format " id=\"%s\"" id))
2058 (and name (format " name=\"%s\"" name))
2059 attributes)))
2060 (format "<a%s>%s</a>" attributes (or desc ""))))
2062 ;;;; Todo
2064 (defun org-html--todo (todo info)
2065 "Format TODO keywords into HTML."
2066 (when todo
2067 (format "<span class=\"%s %s%s\">%s</span>"
2068 (if (member todo org-done-keywords) "done" "todo")
2069 (or (plist-get info :html-todo-kwd-class-prefix) "")
2070 (org-html-fix-class-name todo)
2071 todo)))
2073 ;;;; Priority
2075 (defun org-html--priority (priority _info)
2076 "Format a priority into HTML.
2077 PRIORITY is the character code of the priority or nil. INFO is
2078 a plist containing export options."
2079 (and priority (format "<span class=\"priority\">[%c]</span>" priority)))
2081 ;;;; Tags
2083 (defun org-html--tags (tags info)
2084 "Format TAGS into HTML.
2085 INFO is a plist containing export options."
2086 (when tags
2087 (format "<span class=\"tag\">%s</span>"
2088 (mapconcat
2089 (lambda (tag)
2090 (format "<span class=\"%s\">%s</span>"
2091 (concat (plist-get info :html-tag-class-prefix)
2092 (org-html-fix-class-name tag))
2093 tag))
2094 tags "&#xa0;"))))
2096 ;;;; Src Code
2098 (defun org-html-fontify-code (code lang)
2099 "Color CODE with htmlize library.
2100 CODE is a string representing the source code to colorize. LANG
2101 is the language used for CODE, as a string, or nil."
2102 (when code
2103 (cond
2104 ;; Case 1: No lang. Possibly an example block.
2105 ((not lang)
2106 ;; Simple transcoding.
2107 (org-html-encode-plain-text code))
2108 ;; Case 2: No htmlize or an inferior version of htmlize
2109 ((not (and (require 'htmlize nil t) (fboundp 'htmlize-region-for-paste)))
2110 ;; Emit a warning.
2111 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
2112 ;; Simple transcoding.
2113 (org-html-encode-plain-text code))
2114 ;; Case 3: plain text explicitly set
2115 ((not org-html-htmlize-output-type)
2116 ;; Simple transcoding.
2117 (org-html-encode-plain-text code))
2119 ;; Map language
2120 (setq lang (or (assoc-default lang org-src-lang-modes) lang))
2121 (let* ((lang-mode (and lang (intern (format "%s-mode" lang)))))
2122 (cond
2123 ;; Case 1: Language is not associated with any Emacs mode
2124 ((not (functionp lang-mode))
2125 ;; Simple transcoding.
2126 (org-html-encode-plain-text code))
2127 ;; Case 2: Default. Fontify code.
2129 ;; htmlize
2130 (setq code
2131 (let ((output-type org-html-htmlize-output-type)
2132 (font-prefix org-html-htmlize-font-prefix))
2133 (with-temp-buffer
2134 ;; Switch to language-specific mode.
2135 (funcall lang-mode)
2136 (insert code)
2137 ;; Fontify buffer.
2138 (org-font-lock-ensure)
2139 ;; Remove formatting on newline characters.
2140 (save-excursion
2141 (let ((beg (point-min))
2142 (end (point-max)))
2143 (goto-char beg)
2144 (while (progn (end-of-line) (< (point) end))
2145 (put-text-property (point) (1+ (point)) 'face nil)
2146 (forward-char 1))))
2147 (org-src-mode)
2148 (set-buffer-modified-p nil)
2149 ;; Htmlize region.
2150 (let ((org-html-htmlize-output-type output-type)
2151 (org-html-htmlize-font-prefix font-prefix))
2152 (org-html-htmlize-region-for-paste
2153 (point-min) (point-max))))))
2154 ;; Strip any enclosing <pre></pre> tags.
2155 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code) (match-end 0)))
2156 (end (and beg (string-match "</pre>\\'" code))))
2157 (if (and beg end) (substring code beg end) code)))))))))
2159 (defun org-html-do-format-code
2160 (code &optional lang refs retain-labels num-start)
2161 "Format CODE string as source code.
2162 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
2163 respectively, the language of the source code, as a string, an
2164 alist between line numbers and references (as returned by
2165 `org-export-unravel-code'), a boolean specifying if labels should
2166 appear in the source code, and the number associated to the first
2167 line of code."
2168 (let* ((code-lines (org-split-string code "\n"))
2169 (code-length (length code-lines))
2170 (num-fmt
2171 (and num-start
2172 (format "%%%ds: "
2173 (length (number-to-string (+ code-length num-start))))))
2174 (code (org-html-fontify-code code lang)))
2175 (org-export-format-code
2176 code
2177 (lambda (loc line-num ref)
2178 (setq loc
2179 (concat
2180 ;; Add line number, if needed.
2181 (when num-start
2182 (format "<span class=\"linenr\">%s</span>"
2183 (format num-fmt line-num)))
2184 ;; Transcoded src line.
2186 ;; Add label, if needed.
2187 (when (and ref retain-labels) (format " (%s)" ref))))
2188 ;; Mark transcoded line as an anchor, if needed.
2189 (if (not ref) loc
2190 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
2191 ref loc)))
2192 num-start refs)))
2194 (defun org-html-format-code (element info)
2195 "Format contents of ELEMENT as source code.
2196 ELEMENT is either an example block or a src block. INFO is
2197 a plist used as a communication channel."
2198 (let* ((lang (org-element-property :language element))
2199 ;; Extract code and references.
2200 (code-info (org-export-unravel-code element))
2201 (code (car code-info))
2202 (refs (cdr code-info))
2203 ;; Does the src block contain labels?
2204 (retain-labels (org-element-property :retain-labels element))
2205 ;; Does it have line numbers?
2206 (num-start (org-export-get-loc element info)))
2207 (org-html-do-format-code code lang refs retain-labels num-start)))
2210 ;;; Tables of Contents
2212 (defun org-html-toc (depth info &optional scope)
2213 "Build a table of contents.
2214 DEPTH is an integer specifying the depth of the table. INFO is
2215 a plist used as a communication channel. Optional argument SCOPE
2216 is an element defining the scope of the table. Return the table
2217 of contents as a string, or nil if it is empty."
2218 (let ((toc-entries
2219 (mapcar (lambda (headline)
2220 (cons (org-html--format-toc-headline headline info)
2221 (org-export-get-relative-level headline info)))
2222 (org-export-collect-headlines info depth scope))))
2223 (when toc-entries
2224 (let ((toc (concat "<div id=\"text-table-of-contents\">"
2225 (org-html--toc-text toc-entries)
2226 "</div>\n")))
2227 (if scope toc
2228 (let ((outer-tag (if (org-html--html5-fancy-p info)
2229 "nav"
2230 "div")))
2231 (concat (format "<%s id=\"table-of-contents\">\n" outer-tag)
2232 (let ((top-level (plist-get info :html-toplevel-hlevel)))
2233 (format "<h%d>%s</h%d>\n"
2234 top-level
2235 (org-html--translate "Table of Contents" info)
2236 top-level))
2238 (format "</%s>\n" outer-tag))))))))
2240 (defun org-html--toc-text (toc-entries)
2241 "Return innards of a table of contents, as a string.
2242 TOC-ENTRIES is an alist where key is an entry title, as a string,
2243 and value is its relative level, as an integer."
2244 (let* ((prev-level (1- (cdar toc-entries)))
2245 (start-level prev-level))
2246 (concat
2247 (mapconcat
2248 (lambda (entry)
2249 (let ((headline (car entry))
2250 (level (cdr entry)))
2251 (concat
2252 (let* ((cnt (- level prev-level))
2253 (times (if (> cnt 0) (1- cnt) (- cnt))))
2254 (setq prev-level level)
2255 (concat
2256 (org-html--make-string
2257 times (cond ((> cnt 0) "\n<ul>\n<li>")
2258 ((< cnt 0) "</li>\n</ul>\n")))
2259 (if (> cnt 0) "\n<ul>\n<li>" "</li>\n<li>")))
2260 headline)))
2261 toc-entries "")
2262 (org-html--make-string (- prev-level start-level) "</li>\n</ul>\n"))))
2264 (defun org-html--format-toc-headline (headline info)
2265 "Return an appropriate table of contents entry for HEADLINE.
2266 INFO is a plist used as a communication channel."
2267 (let* ((headline-number (org-export-get-headline-number headline info))
2268 (todo (and (plist-get info :with-todo-keywords)
2269 (let ((todo (org-element-property :todo-keyword headline)))
2270 (and todo (org-export-data todo info)))))
2271 (todo-type (and todo (org-element-property :todo-type headline)))
2272 (priority (and (plist-get info :with-priority)
2273 (org-element-property :priority headline)))
2274 (text (org-export-data-with-backend
2275 (org-export-get-alt-title headline info)
2276 ;; Create an anonymous back-end that will ignore any
2277 ;; footnote-reference, link, radio-target and target
2278 ;; in table of contents.
2279 (org-export-create-backend
2280 :parent 'html
2281 :transcoders '((footnote-reference . ignore)
2282 (link . (lambda (object c i) c))
2283 (radio-target . (lambda (object c i) c))
2284 (target . ignore)))
2285 info))
2286 (tags (and (eq (plist-get info :with-tags) t)
2287 (org-export-get-tags headline info))))
2288 (format "<a href=\"#%s\">%s</a>"
2289 ;; Label.
2290 (or (org-element-property :CUSTOM_ID headline)
2291 (org-export-get-reference headline info))
2292 ;; Body.
2293 (concat
2294 (and (not (org-export-low-level-p headline info))
2295 (org-export-numbered-headline-p headline info)
2296 (concat (mapconcat #'number-to-string headline-number ".")
2297 ". "))
2298 (apply (plist-get info :html-format-headline-function)
2299 todo todo-type priority text tags :section-number nil)))))
2301 (defun org-html-list-of-listings (info)
2302 "Build a list of listings.
2303 INFO is a plist used as a communication channel. Return the list
2304 of listings as a string, or nil if it is empty."
2305 (let ((lol-entries (org-export-collect-listings info)))
2306 (when lol-entries
2307 (concat "<div id=\"list-of-listings\">\n"
2308 (let ((top-level (plist-get info :html-toplevel-hlevel)))
2309 (format "<h%d>%s</h%d>\n"
2310 top-level
2311 (org-html--translate "List of Listings" info)
2312 top-level))
2313 "<div id=\"text-list-of-listings\">\n<ul>\n"
2314 (let ((count 0)
2315 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2316 (org-html--translate "Listing %d:" info))))
2317 (mapconcat
2318 (lambda (entry)
2319 (let ((label (and (org-element-property :name entry)
2320 (org-export-get-reference entry info)))
2321 (title (org-trim
2322 (org-export-data
2323 (or (org-export-get-caption entry t)
2324 (org-export-get-caption entry))
2325 info))))
2326 (concat
2327 "<li>"
2328 (if (not label)
2329 (concat (format initial-fmt (cl-incf count))
2331 title)
2332 (format "<a href=\"#%s\">%s %s</a>"
2333 label
2334 (format initial-fmt (cl-incf count))
2335 title))
2336 "</li>")))
2337 lol-entries "\n"))
2338 "\n</ul>\n</div>\n</div>"))))
2340 (defun org-html-list-of-tables (info)
2341 "Build a list of tables.
2342 INFO is a plist used as a communication channel. Return the list
2343 of tables as a string, or nil if it is empty."
2344 (let ((lol-entries (org-export-collect-tables info)))
2345 (when lol-entries
2346 (concat "<div id=\"list-of-tables\">\n"
2347 (let ((top-level (plist-get info :html-toplevel-hlevel)))
2348 (format "<h%d>%s</h%d>\n"
2349 top-level
2350 (org-html--translate "List of Tables" info)
2351 top-level))
2352 "<div id=\"text-list-of-tables\">\n<ul>\n"
2353 (let ((count 0)
2354 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2355 (org-html--translate "Table %d:" info))))
2356 (mapconcat
2357 (lambda (entry)
2358 (let ((label (and (org-element-property :name entry)
2359 (org-export-get-reference entry info)))
2360 (title (org-trim
2361 (org-export-data
2362 (or (org-export-get-caption entry t)
2363 (org-export-get-caption entry))
2364 info))))
2365 (concat
2366 "<li>"
2367 (if (not label)
2368 (concat (format initial-fmt (cl-incf count))
2370 title)
2371 (format "<a href=\"#%s\">%s %s</a>"
2372 label
2373 (format initial-fmt (cl-incf count))
2374 title))
2375 "</li>")))
2376 lol-entries "\n"))
2377 "\n</ul>\n</div>\n</div>"))))
2380 ;;; Transcode Functions
2382 ;;;; Bold
2384 (defun org-html-bold (_bold contents info)
2385 "Transcode BOLD from Org to HTML.
2386 CONTENTS is the text with bold markup. INFO is a plist holding
2387 contextual information."
2388 (format (or (cdr (assq 'bold (plist-get info :html-text-markup-alist))) "%s")
2389 contents))
2391 ;;;; Center Block
2393 (defun org-html-center-block (_center-block contents _info)
2394 "Transcode a CENTER-BLOCK element from Org to HTML.
2395 CONTENTS holds the contents of the block. INFO is a plist
2396 holding contextual information."
2397 (format "<div class=\"org-center\">\n%s</div>" contents))
2399 ;;;; Clock
2401 (defun org-html-clock (clock _contents _info)
2402 "Transcode a CLOCK element from Org to HTML.
2403 CONTENTS is nil. INFO is a plist used as a communication
2404 channel."
2405 (format "<p>
2406 <span class=\"timestamp-wrapper\">
2407 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2408 </span>
2409 </p>"
2410 org-clock-string
2411 (org-timestamp-translate (org-element-property :value clock))
2412 (let ((time (org-element-property :duration clock)))
2413 (and time (format " <span class=\"timestamp\">(%s)</span>" time)))))
2415 ;;;; Code
2417 (defun org-html-code (code _contents info)
2418 "Transcode CODE from Org to HTML.
2419 CONTENTS is nil. INFO is a plist holding contextual
2420 information."
2421 (format (or (cdr (assq 'code (plist-get info :html-text-markup-alist))) "%s")
2422 (org-html-encode-plain-text (org-element-property :value code))))
2424 ;;;; Drawer
2426 (defun org-html-drawer (drawer contents info)
2427 "Transcode a DRAWER element from Org to HTML.
2428 CONTENTS holds the contents of the block. INFO is a plist
2429 holding contextual information."
2430 (funcall (plist-get info :html-format-drawer-function)
2431 (org-element-property :drawer-name drawer)
2432 contents))
2434 ;;;; Dynamic Block
2436 (defun org-html-dynamic-block (_dynamic-block contents _info)
2437 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2438 CONTENTS holds the contents of the block. INFO is a plist
2439 holding contextual information. See `org-export-data'."
2440 contents)
2442 ;;;; Entity
2444 (defun org-html-entity (entity _contents _info)
2445 "Transcode an ENTITY object from Org to HTML.
2446 CONTENTS are the definition itself. INFO is a plist holding
2447 contextual information."
2448 (org-element-property :html entity))
2450 ;;;; Example Block
2452 (defun org-html-example-block (example-block _contents info)
2453 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2454 CONTENTS is nil. INFO is a plist holding contextual
2455 information."
2456 (let ((attributes (org-export-read-attribute :attr_html example-block)))
2457 (if (plist-get attributes :textarea)
2458 (org-html--textarea-block example-block)
2459 (format "<pre class=\"example\"%s>\n%s</pre>"
2460 (let* ((name (org-element-property :name example-block))
2461 (a (org-html--make-attribute-string
2462 (if (or (not name) (plist-member attributes :id))
2463 attributes
2464 (plist-put attributes :id name)))))
2465 (if (org-string-nw-p a) (concat " " a) ""))
2466 (org-html-format-code example-block info)))))
2468 ;;;; Export Snippet
2470 (defun org-html-export-snippet (export-snippet _contents _info)
2471 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2472 CONTENTS is nil. INFO is a plist holding contextual
2473 information."
2474 (when (eq (org-export-snippet-backend export-snippet) 'html)
2475 (org-element-property :value export-snippet)))
2477 ;;;; Export Block
2479 (defun org-html-export-block (export-block _contents _info)
2480 "Transcode a EXPORT-BLOCK element from Org to HTML.
2481 CONTENTS is nil. INFO is a plist holding contextual information."
2482 (when (string= (org-element-property :type export-block) "HTML")
2483 (org-remove-indentation (org-element-property :value export-block))))
2485 ;;;; Fixed Width
2487 (defun org-html-fixed-width (fixed-width _contents _info)
2488 "Transcode a FIXED-WIDTH element from Org to HTML.
2489 CONTENTS is nil. INFO is a plist holding contextual information."
2490 (format "<pre class=\"example\">\n%s</pre>"
2491 (org-html-do-format-code
2492 (org-remove-indentation
2493 (org-element-property :value fixed-width)))))
2495 ;;;; Footnote Reference
2497 (defun org-html-footnote-reference (footnote-reference _contents info)
2498 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2499 CONTENTS is nil. INFO is a plist holding contextual information."
2500 (concat
2501 ;; Insert separator between two footnotes in a row.
2502 (let ((prev (org-export-get-previous-element footnote-reference info)))
2503 (when (eq (org-element-type prev) 'footnote-reference)
2504 (plist-get info :html-footnote-separator)))
2505 (let* ((n (org-export-get-footnote-number footnote-reference info))
2506 (id (format "fnr.%d%s"
2508 (if (org-export-footnote-first-reference-p
2509 footnote-reference info)
2511 ".100"))))
2512 (format
2513 (plist-get info :html-footnote-format)
2514 (org-html--anchor
2515 id n (format " class=\"footref\" href=\"#fn.%d\"" n) info)))))
2517 ;;;; Headline
2519 (defun org-html-headline (headline contents info)
2520 "Transcode a HEADLINE element from Org to HTML.
2521 CONTENTS holds the contents of the headline. INFO is a plist
2522 holding contextual information."
2523 (unless (org-element-property :footnote-section-p headline)
2524 (let* ((numberedp (org-export-numbered-headline-p headline info))
2525 (numbers (org-export-get-headline-number headline info))
2526 (level (+ (org-export-get-relative-level headline info)
2527 (1- (plist-get info :html-toplevel-hlevel))))
2528 (todo (and (plist-get info :with-todo-keywords)
2529 (let ((todo (org-element-property :todo-keyword headline)))
2530 (and todo (org-export-data todo info)))))
2531 (todo-type (and todo (org-element-property :todo-type headline)))
2532 (priority (and (plist-get info :with-priority)
2533 (org-element-property :priority headline)))
2534 (text (org-export-data (org-element-property :title headline) info))
2535 (tags (and (plist-get info :with-tags)
2536 (org-export-get-tags headline info)))
2537 (full-text (funcall (plist-get info :html-format-headline-function)
2538 todo todo-type priority text tags info))
2539 (contents (or contents ""))
2540 (ids (delq nil
2541 (list (org-element-property :CUSTOM_ID headline)
2542 (org-export-get-reference headline info)
2543 (org-element-property :ID headline))))
2544 (preferred-id (car ids))
2545 (extra-ids
2546 (mapconcat
2547 (lambda (id)
2548 (org-html--anchor
2549 (if (org-uuidgen-p id) (concat "ID-" id) id)
2550 nil nil info))
2551 (cdr ids) "")))
2552 (if (org-export-low-level-p headline info)
2553 ;; This is a deep sub-tree: export it as a list item.
2554 (let* ((type (if numberedp 'ordered 'unordered))
2555 (itemized-body
2556 (org-html-format-list-item
2557 contents type nil info nil
2558 (concat (org-html--anchor preferred-id nil nil info)
2559 extra-ids
2560 full-text))))
2561 (concat (and (org-export-first-sibling-p headline info)
2562 (org-html-begin-plain-list type))
2563 itemized-body
2564 (and (org-export-last-sibling-p headline info)
2565 (org-html-end-plain-list type))))
2566 (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline))
2567 (first-content (car (org-element-contents headline))))
2568 ;; Standard headline. Export it as a section.
2569 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2570 (org-html--container headline info)
2571 (concat "outline-container-"
2572 (org-export-get-reference headline info))
2573 (concat (format "outline-%d" level)
2574 (and extra-class " ")
2575 extra-class)
2576 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2577 level
2578 preferred-id
2579 extra-ids
2580 (concat
2581 (and numberedp
2582 (format
2583 "<span class=\"section-number-%d\">%s</span> "
2584 level
2585 (mapconcat #'number-to-string numbers ".")))
2586 full-text)
2587 level)
2588 ;; When there is no section, pretend there is an
2589 ;; empty one to get the correct <div
2590 ;; class="outline-...> which is needed by
2591 ;; `org-info.js'.
2592 (if (eq (org-element-type first-content) 'section) contents
2593 (concat (org-html-section first-content "" info) contents))
2594 (org-html--container headline info)))))))
2596 (defun org-html-format-headline-default-function
2597 (todo _todo-type priority text tags info)
2598 "Default format function for a headline.
2599 See `org-html-format-headline-function' for details."
2600 (let ((todo (org-html--todo todo info))
2601 (priority (org-html--priority priority info))
2602 (tags (org-html--tags tags info)))
2603 (concat todo (and todo " ")
2604 priority (and priority " ")
2605 text
2606 (and tags "&#xa0;&#xa0;&#xa0;") tags)))
2608 (defun org-html--container (headline info)
2609 (or (org-element-property :HTML_CONTAINER headline)
2610 (if (= 1 (org-export-get-relative-level headline info))
2611 (plist-get info :html-container)
2612 "div")))
2614 ;;;; Horizontal Rule
2616 (defun org-html-horizontal-rule (_horizontal-rule _contents info)
2617 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2618 CONTENTS is nil. INFO is a plist holding contextual information."
2619 (org-html-close-tag "hr" nil info))
2621 ;;;; Inline Src Block
2623 (defun org-html-inline-src-block (inline-src-block _contents info)
2624 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2625 CONTENTS holds the contents of the item. INFO is a plist holding
2626 contextual information."
2627 (let* ((lang (org-element-property :language inline-src-block))
2628 (code (org-html-fontify-code
2629 (org-element-property :value inline-src-block)
2630 lang))
2631 (label
2632 (let ((lbl (and (org-element-property :name inline-src-block)
2633 (org-export-get-reference inline-src-block info))))
2634 (if (not lbl) "" (format " id=\"%s\"" lbl)))))
2635 (format "<code class=\"src src-%s\"%s>%s</code>" lang label code)))
2637 ;;;; Inlinetask
2639 (defun org-html-inlinetask (inlinetask contents info)
2640 "Transcode an INLINETASK element from Org to HTML.
2641 CONTENTS holds the contents of the block. INFO is a plist
2642 holding contextual information."
2643 (let* ((todo (and (plist-get info :with-todo-keywords)
2644 (let ((todo (org-element-property :todo-keyword inlinetask)))
2645 (and todo (org-export-data todo info)))))
2646 (todo-type (and todo (org-element-property :todo-type inlinetask)))
2647 (priority (and (plist-get info :with-priority)
2648 (org-element-property :priority inlinetask)))
2649 (text (org-export-data (org-element-property :title inlinetask) info))
2650 (tags (and (plist-get info :with-tags)
2651 (org-export-get-tags inlinetask info))))
2652 (funcall (plist-get info :html-format-inlinetask-function)
2653 todo todo-type priority text tags contents info)))
2655 (defun org-html-format-inlinetask-default-function
2656 (todo todo-type priority text tags contents info)
2657 "Default format function for a inlinetasks.
2658 See `org-html-format-inlinetask-function' for details."
2659 (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2660 (org-html-format-headline-default-function
2661 todo todo-type priority text tags info)
2662 (org-html-close-tag "br" nil info)
2663 contents))
2665 ;;;; Italic
2667 (defun org-html-italic (_italic contents info)
2668 "Transcode ITALIC from Org to HTML.
2669 CONTENTS is the text with italic markup. INFO is a plist holding
2670 contextual information."
2671 (format
2672 (or (cdr (assq 'italic (plist-get info :html-text-markup-alist))) "%s")
2673 contents))
2675 ;;;; Item
2677 (defun org-html-checkbox (checkbox info)
2678 "Format CHECKBOX into HTML.
2679 INFO is a plist holding contextual information. See
2680 `org-html-checkbox-type' for customization options."
2681 (cdr (assq checkbox
2682 (cdr (assq (plist-get info :html-checkbox-type)
2683 org-html-checkbox-types)))))
2685 (defun org-html-format-list-item (contents type checkbox info
2686 &optional term-counter-id
2687 headline)
2688 "Format a list item into HTML."
2689 (let ((class (if checkbox
2690 (format " class=\"%s\""
2691 (symbol-name checkbox)) ""))
2692 (checkbox (concat (org-html-checkbox checkbox info)
2693 (and checkbox " ")))
2694 (br (org-html-close-tag "br" nil info)))
2695 (concat
2696 (pcase type
2697 (`ordered
2698 (let* ((counter term-counter-id)
2699 (extra (if counter (format " value=\"%s\"" counter) "")))
2700 (concat
2701 (format "<li%s%s>" class extra)
2702 (when headline (concat headline br)))))
2703 (`unordered
2704 (let* ((id term-counter-id)
2705 (extra (if id (format " id=\"%s\"" id) "")))
2706 (concat
2707 (format "<li%s%s>" class extra)
2708 (when headline (concat headline br)))))
2709 (`descriptive
2710 (let* ((term term-counter-id))
2711 (setq term (or term "(no term)"))
2712 ;; Check-boxes in descriptive lists are associated to tag.
2713 (concat (format "<dt%s>%s</dt>"
2714 class (concat checkbox term))
2715 "<dd>"))))
2716 (unless (eq type 'descriptive) checkbox)
2717 (and contents (org-trim contents))
2718 (pcase type
2719 (`ordered "</li>")
2720 (`unordered "</li>")
2721 (`descriptive "</dd>")))))
2723 (defun org-html-item (item contents info)
2724 "Transcode an ITEM element from Org to HTML.
2725 CONTENTS holds the contents of the item. INFO is a plist holding
2726 contextual information."
2727 (let* ((plain-list (org-export-get-parent item))
2728 (type (org-element-property :type plain-list))
2729 (counter (org-element-property :counter item))
2730 (checkbox (org-element-property :checkbox item))
2731 (tag (let ((tag (org-element-property :tag item)))
2732 (and tag (org-export-data tag info)))))
2733 (org-html-format-list-item
2734 contents type checkbox info (or tag counter))))
2736 ;;;; Keyword
2738 (defun org-html-keyword (keyword _contents info)
2739 "Transcode a KEYWORD element from Org to HTML.
2740 CONTENTS is nil. INFO is a plist holding contextual information."
2741 (let ((key (org-element-property :key keyword))
2742 (value (org-element-property :value keyword)))
2743 (cond
2744 ((string= key "HTML") value)
2745 ((string= key "TOC")
2746 (let ((case-fold-search t))
2747 (cond
2748 ((string-match "\\<headlines\\>" value)
2749 (let ((depth (and (string-match "\\<[0-9]+\\>" value)
2750 (string-to-number (match-string 0 value))))
2751 (localp (string-match-p "\\<local\\>" value)))
2752 (org-html-toc depth info (and localp keyword))))
2753 ((string= "listings" value) (org-html-list-of-listings info))
2754 ((string= "tables" value) (org-html-list-of-tables info))))))))
2756 ;;;; Latex Environment
2758 (defun org-html-format-latex (latex-frag processing-type info)
2759 "Format a LaTeX fragment LATEX-FRAG into HTML.
2760 PROCESSING-TYPE designates the tool used for conversion. It can
2761 be `mathjax', `verbatim', nil, t or symbols in
2762 `org-preview-latex-process-alist', e.g., `dvipng', `dvisvgm' or
2763 `imagemagick'. See `org-html-with-latex' for more information.
2764 INFO is a plist containing export properties."
2765 (let ((cache-relpath "") (cache-dir ""))
2766 (unless (eq processing-type 'mathjax)
2767 (let ((bfn (or (buffer-file-name)
2768 (make-temp-name
2769 (expand-file-name "latex" temporary-file-directory))))
2770 (latex-header
2771 (let ((header (plist-get info :latex-header)))
2772 (and header
2773 (concat (mapconcat
2774 (lambda (line) (concat "#+LATEX_HEADER: " line))
2775 (org-split-string header "\n")
2776 "\n")
2777 "\n")))))
2778 (setq cache-relpath
2779 (concat (file-name-as-directory org-preview-latex-image-directory)
2780 (file-name-sans-extension
2781 (file-name-nondirectory bfn)))
2782 cache-dir (file-name-directory bfn))
2783 ;; Re-create LaTeX environment from original buffer in
2784 ;; temporary buffer so that dvipng/imagemagick can properly
2785 ;; turn the fragment into an image.
2786 (setq latex-frag (concat latex-header latex-frag))))
2787 (with-temp-buffer
2788 (insert latex-frag)
2789 (org-format-latex cache-relpath nil nil cache-dir nil
2790 "Creating LaTeX Image..." nil processing-type)
2791 (buffer-string))))
2793 (defun org-html-latex-environment (latex-environment _contents info)
2794 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2795 CONTENTS is nil. INFO is a plist holding contextual information."
2796 (let ((processing-type (plist-get info :with-latex))
2797 (latex-frag (org-remove-indentation
2798 (org-element-property :value latex-environment)))
2799 (attributes (org-export-read-attribute :attr_html latex-environment)))
2800 (cond
2801 ((memq processing-type '(t mathjax))
2802 (org-html-format-latex latex-frag 'mathjax info))
2803 ((assq processing-type org-preview-latex-process-alist)
2804 (let ((formula-link
2805 (org-html-format-latex latex-frag processing-type info)))
2806 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
2807 ;; Do not provide a caption or a name to be consistent with
2808 ;; `mathjax' handling.
2809 (org-html--wrap-image
2810 (org-html--format-image
2811 (match-string 1 formula-link) attributes info) info))))
2812 (t latex-frag))))
2814 ;;;; Latex Fragment
2816 (defun org-html-latex-fragment (latex-fragment _contents info)
2817 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2818 CONTENTS is nil. INFO is a plist holding contextual information."
2819 (let ((latex-frag (org-element-property :value latex-fragment))
2820 (processing-type (plist-get info :with-latex)))
2821 (cond
2822 ((memq processing-type '(t mathjax))
2823 (org-html-format-latex latex-frag 'mathjax info))
2824 ((assq processing-type org-preview-latex-process-alist)
2825 (let ((formula-link
2826 (org-html-format-latex latex-frag processing-type info)))
2827 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
2828 (org-html--format-image (match-string 1 formula-link) nil info))))
2829 (t latex-frag))))
2831 ;;;; Line Break
2833 (defun org-html-line-break (_line-break _contents info)
2834 "Transcode a LINE-BREAK object from Org to HTML.
2835 CONTENTS is nil. INFO is a plist holding contextual information."
2836 (concat (org-html-close-tag "br" nil info) "\n"))
2838 ;;;; Link
2840 (defun org-html-inline-image-p (link info)
2841 "Non-nil when LINK is meant to appear as an image.
2842 INFO is a plist used as a communication channel. LINK is an
2843 inline image when it has no description and targets an image
2844 file (see `org-html-inline-image-rules' for more information), or
2845 if its description is a single link targeting an image file."
2846 (if (not (org-element-contents link))
2847 (org-export-inline-image-p
2848 link (plist-get info :html-inline-image-rules))
2849 (not
2850 (let ((link-count 0))
2851 (org-element-map (org-element-contents link)
2852 (cons 'plain-text org-element-all-objects)
2853 (lambda (obj)
2854 (pcase (org-element-type obj)
2855 (`plain-text (org-string-nw-p obj))
2856 (`link (if (= link-count 1) t
2857 (cl-incf link-count)
2858 (not (org-export-inline-image-p
2859 obj (plist-get info :html-inline-image-rules)))))
2860 (_ t)))
2861 info t)))))
2863 (defvar org-html-standalone-image-predicate)
2864 (defun org-html-standalone-image-p (element info)
2865 "Non-nil if ELEMENT is a standalone image.
2867 INFO is a plist holding contextual information.
2869 An element or object is a standalone image when
2871 - its type is `paragraph' and its sole content, save for white
2872 spaces, is a link that qualifies as an inline image;
2874 - its type is `link' and its containing paragraph has no other
2875 content save white spaces.
2877 Bind `org-html-standalone-image-predicate' to constrain paragraph
2878 further. For example, to check for only captioned standalone
2879 images, set it to:
2881 (lambda (paragraph) (org-element-property :caption paragraph))"
2882 (let ((paragraph (pcase (org-element-type element)
2883 (`paragraph element)
2884 (`link (org-export-get-parent element)))))
2885 (and (eq (org-element-type paragraph) 'paragraph)
2886 (or (not (fboundp 'org-html-standalone-image-predicate))
2887 (funcall org-html-standalone-image-predicate paragraph))
2888 (catch 'exit
2889 (let ((link-count 0))
2890 (org-element-map (org-element-contents paragraph)
2891 (cons 'plain-text org-element-all-objects)
2892 (lambda (obj)
2893 (when (pcase (org-element-type obj)
2894 (`plain-text (org-string-nw-p obj))
2895 (`link (or (> (cl-incf link-count) 1)
2896 (not (org-html-inline-image-p obj info))))
2897 (_ t))
2898 (throw 'exit nil)))
2899 info nil 'link)
2900 (= link-count 1))))))
2902 (defun org-html-link (link desc info)
2903 "Transcode a LINK object from Org to HTML.
2904 DESC is the description part of the link, or the empty string.
2905 INFO is a plist holding contextual information. See
2906 `org-export-data'."
2907 (let* ((home (when (plist-get info :html-link-home)
2908 (org-trim (plist-get info :html-link-home))))
2909 (use-abs-url (plist-get info :html-link-use-abs-url))
2910 (link-org-files-as-html-maybe
2911 (lambda (raw-path info)
2912 ;; Treat links to `file.org' as links to `file.html', if
2913 ;; needed. See `org-html-link-org-files-as-html'.
2914 (cond
2915 ((and (plist-get info :html-link-org-files-as-html)
2916 (string= ".org"
2917 (downcase (file-name-extension raw-path "."))))
2918 (concat (file-name-sans-extension raw-path) "."
2919 (plist-get info :html-extension)))
2920 (t raw-path))))
2921 (type (org-element-property :type link))
2922 (raw-path (org-element-property :path link))
2923 ;; Ensure DESC really exists, or set it to nil.
2924 (desc (org-string-nw-p desc))
2925 (path
2926 (cond
2927 ((member type '("http" "https" "ftp" "mailto" "news"))
2928 (url-encode-url (org-link-unescape (concat type ":" raw-path))))
2929 ((string= type "file")
2930 ;; Treat links to ".org" files as ".html", if needed.
2931 (setq raw-path
2932 (funcall link-org-files-as-html-maybe raw-path info))
2933 ;; If file path is absolute, prepend it with protocol
2934 ;; component - "file://".
2935 (cond
2936 ((file-name-absolute-p raw-path)
2937 (setq raw-path (org-export-file-uri raw-path)))
2938 ((and home use-abs-url)
2939 (setq raw-path (concat (file-name-as-directory home) raw-path))))
2940 ;; Add search option, if any. A search option can be
2941 ;; relative to a custom-id, a headline title, a name or
2942 ;; a target.
2943 (let ((option (org-element-property :search-option link)))
2944 (cond ((not option) raw-path)
2945 ;; Since HTML back-end use custom-id value as-is,
2946 ;; resolving is them is trivial.
2947 ((eq (string-to-char option) ?#) (concat raw-path option))
2949 (concat raw-path
2951 (org-publish-resolve-external-link
2952 option
2953 (org-element-property :path link)))))))
2954 (t raw-path)))
2955 ;; Extract attributes from parent's paragraph. HACK: Only do
2956 ;; this for the first link in parent (inner image link for
2957 ;; inline images). This is needed as long as attributes
2958 ;; cannot be set on a per link basis.
2959 (attributes-plist
2960 (let* ((parent (org-export-get-parent-element link))
2961 (link (let ((container (org-export-get-parent link)))
2962 (if (and (eq (org-element-type container) 'link)
2963 (org-html-inline-image-p link info))
2964 container
2965 link))))
2966 (and (eq (org-element-map parent 'link 'identity info t) link)
2967 (org-export-read-attribute :attr_html parent))))
2968 (attributes
2969 (let ((attr (org-html--make-attribute-string attributes-plist)))
2970 (if (org-string-nw-p attr) (concat " " attr) ""))))
2971 (cond
2972 ;; Link type is handled by a special function.
2973 ((org-export-custom-protocol-maybe link desc 'html))
2974 ;; Image file.
2975 ((and (plist-get info :html-inline-images)
2976 (org-export-inline-image-p
2977 link (plist-get info :html-inline-image-rules)))
2978 (org-html--format-image path attributes-plist info))
2979 ;; Radio target: Transcode target's contents and use them as
2980 ;; link's description.
2981 ((string= type "radio")
2982 (let ((destination (org-export-resolve-radio-link link info)))
2983 (if (not destination) desc
2984 (format "<a href=\"#%s\"%s>%s</a>"
2985 (org-export-get-reference destination info)
2986 attributes
2987 desc))))
2988 ;; Links pointing to a headline: Find destination and build
2989 ;; appropriate referencing command.
2990 ((member type '("custom-id" "fuzzy" "id"))
2991 (let ((destination (if (string= type "fuzzy")
2992 (org-export-resolve-fuzzy-link link info)
2993 (org-export-resolve-id-link link info))))
2994 (pcase (org-element-type destination)
2995 ;; ID link points to an external file.
2996 (`plain-text
2997 (let ((fragment (concat "ID-" path))
2998 ;; Treat links to ".org" files as ".html", if needed.
2999 (path (funcall link-org-files-as-html-maybe
3000 destination info)))
3001 (format "<a href=\"%s#%s\"%s>%s</a>"
3002 path fragment attributes (or desc destination))))
3003 ;; Fuzzy link points nowhere.
3004 (`nil
3005 (format "<i>%s</i>"
3006 (or desc
3007 (org-export-data
3008 (org-element-property :raw-link link) info))))
3009 ;; Link points to a headline.
3010 (`headline
3011 (let ((href (or (org-element-property :CUSTOM_ID destination)
3012 (org-export-get-reference destination info)))
3013 ;; What description to use?
3014 (desc
3015 ;; Case 1: Headline is numbered and LINK has no
3016 ;; description. Display section number.
3017 (if (and (org-export-numbered-headline-p destination info)
3018 (not desc))
3019 (mapconcat #'number-to-string
3020 (org-export-get-headline-number
3021 destination info) ".")
3022 ;; Case 2: Either the headline is un-numbered or
3023 ;; LINK has a custom description. Display LINK's
3024 ;; description or headline's title.
3025 (or desc
3026 (org-export-data
3027 (org-element-property :title destination) info)))))
3028 (format "<a href=\"#%s\"%s>%s</a>" href attributes desc)))
3029 ;; Fuzzy link points to a target or an element.
3031 (let* ((ref (org-export-get-reference destination info))
3032 (org-html-standalone-image-predicate
3033 #'org-html--has-caption-p)
3034 (number (cond
3035 (desc nil)
3036 ((org-html-standalone-image-p destination info)
3037 (org-export-get-ordinal
3038 (org-element-map destination 'link
3039 #'identity info t)
3040 info 'link 'org-html-standalone-image-p))
3041 (t (org-export-get-ordinal
3042 destination info nil 'org-html--has-caption-p))))
3043 (desc (cond (desc)
3044 ((not number) "No description for this link")
3045 ((numberp number) (number-to-string number))
3046 (t (mapconcat #'number-to-string number ".")))))
3047 (format "<a href=\"#%s\"%s>%s</a>" ref attributes desc))))))
3048 ;; Coderef: replace link with the reference name or the
3049 ;; equivalent line number.
3050 ((string= type "coderef")
3051 (let ((fragment (concat "coderef-" (org-html-encode-plain-text path))))
3052 (format "<a href=\"#%s\" %s%s>%s</a>"
3053 fragment
3054 (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, \
3055 '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
3056 fragment fragment)
3057 attributes
3058 (format (org-export-get-coderef-format path desc)
3059 (org-export-resolve-coderef path info)))))
3060 ;; External link with a description part.
3061 ((and path desc) (format "<a href=\"%s\"%s>%s</a>"
3062 (org-html-encode-plain-text path)
3063 attributes
3064 desc))
3065 ;; External link without a description part.
3066 (path (let ((path (org-html-encode-plain-text path)))
3067 (format "<a href=\"%s\"%s>%s</a>"
3068 path
3069 attributes
3070 (org-link-unescape path))))
3071 ;; No path, only description. Try to do something useful.
3072 (t (format "<i>%s</i>" desc)))))
3074 ;;;; Node Property
3076 (defun org-html-node-property (node-property _contents _info)
3077 "Transcode a NODE-PROPERTY element from Org to HTML.
3078 CONTENTS is nil. INFO is a plist holding contextual
3079 information."
3080 (format "%s:%s"
3081 (org-element-property :key node-property)
3082 (let ((value (org-element-property :value node-property)))
3083 (if value (concat " " value) ""))))
3085 ;;;; Paragraph
3087 (defun org-html-paragraph (paragraph contents info)
3088 "Transcode a PARAGRAPH element from Org to HTML.
3089 CONTENTS is the contents of the paragraph, as a string. INFO is
3090 the plist used as a communication channel."
3091 (let* ((parent (org-export-get-parent paragraph))
3092 (parent-type (org-element-type parent))
3093 (style '((footnote-definition " class=\"footpara\"")
3094 (org-data " class=\"footpara\"")))
3095 (attributes (org-html--make-attribute-string
3096 (org-export-read-attribute :attr_html paragraph)))
3097 (extra (or (cadr (assq parent-type style)) "")))
3098 (cond
3099 ((and (eq parent-type 'item)
3100 (not (org-export-get-previous-element paragraph info))
3101 (let ((followers (org-export-get-next-element paragraph info 2)))
3102 (and (not (cdr followers))
3103 (memq (org-element-type (car followers)) '(nil plain-list)))))
3104 ;; First paragraph in an item has no tag if it is alone or
3105 ;; followed, at most, by a sub-list.
3106 contents)
3107 ((org-html-standalone-image-p paragraph info)
3108 ;; Standalone image.
3109 (let ((caption
3110 (let ((raw (org-export-data
3111 (org-export-get-caption paragraph) info))
3112 (org-html-standalone-image-predicate
3113 #'org-html--has-caption-p))
3114 (if (not (org-string-nw-p raw)) raw
3115 (concat "<span class=\"figure-number\">"
3116 (format (org-html--translate "Figure %d:" info)
3117 (org-export-get-ordinal
3118 (org-element-map paragraph 'link
3119 #'identity info t)
3120 info nil #'org-html-standalone-image-p))
3121 " </span>"
3122 raw))))
3123 (label (and (org-element-property :name paragraph)
3124 (org-export-get-reference paragraph info))))
3125 (org-html--wrap-image contents info caption label)))
3126 ;; Regular paragraph.
3127 (t (format "<p%s%s>\n%s</p>"
3128 (if (org-string-nw-p attributes)
3129 (concat " " attributes) "")
3130 extra contents)))))
3132 ;;;; Plain List
3134 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
3135 ;; the correct value for the item counter
3136 (defun org-html-begin-plain-list (type &optional arg1)
3137 "Insert the beginning of the HTML list depending on TYPE.
3138 When ARG1 is a string, use it as the start parameter for ordered
3139 lists."
3140 (pcase type
3141 (`ordered
3142 (format "<ol class=\"org-ol\"%s>"
3143 (if arg1 (format " start=\"%d\"" arg1) "")))
3144 (`unordered "<ul class=\"org-ul\">")
3145 (`descriptive "<dl class=\"org-dl\">")))
3147 (defun org-html-end-plain-list (type)
3148 "Insert the end of the HTML list depending on TYPE."
3149 (pcase type
3150 (`ordered "</ol>")
3151 (`unordered "</ul>")
3152 (`descriptive "</dl>")))
3154 (defun org-html-plain-list (plain-list contents _info)
3155 "Transcode a PLAIN-LIST element from Org to HTML.
3156 CONTENTS is the contents of the list. INFO is a plist holding
3157 contextual information."
3158 (let ((type (org-element-property :type plain-list)))
3159 (format "%s\n%s%s"
3160 (org-html-begin-plain-list type)
3161 contents (org-html-end-plain-list type))))
3163 ;;;; Plain Text
3165 (defun org-html-convert-special-strings (string)
3166 "Convert special characters in STRING to HTML."
3167 (dolist (a org-html-special-string-regexps string)
3168 (let ((re (car a))
3169 (rpl (cdr a)))
3170 (setq string (replace-regexp-in-string re rpl string t)))))
3172 (defun org-html-encode-plain-text (text)
3173 "Convert plain text characters from TEXT to HTML equivalent.
3174 Possible conversions are set in `org-html-protect-char-alist'."
3175 (dolist (pair org-html-protect-char-alist text)
3176 (setq text (replace-regexp-in-string (car pair) (cdr pair) text t t))))
3178 (defun org-html-plain-text (text info)
3179 "Transcode a TEXT string from Org to HTML.
3180 TEXT is the string to transcode. INFO is a plist holding
3181 contextual information."
3182 (let ((output text))
3183 ;; Protect following characters: <, >, &.
3184 (setq output (org-html-encode-plain-text output))
3185 ;; Handle smart quotes. Be sure to provide original string since
3186 ;; OUTPUT may have been modified.
3187 (when (plist-get info :with-smart-quotes)
3188 (setq output (org-export-activate-smart-quotes output :html info text)))
3189 ;; Handle special strings.
3190 (when (plist-get info :with-special-strings)
3191 (setq output (org-html-convert-special-strings output)))
3192 ;; Handle break preservation if required.
3193 (when (plist-get info :preserve-breaks)
3194 (setq output
3195 (replace-regexp-in-string
3196 "\\(\\\\\\\\\\)?[ \t]*\n"
3197 (concat (org-html-close-tag "br" nil info) "\n") output)))
3198 ;; Return value.
3199 output))
3202 ;; Planning
3204 (defun org-html-planning (planning _contents info)
3205 "Transcode a PLANNING element from Org to HTML.
3206 CONTENTS is nil. INFO is a plist used as a communication
3207 channel."
3208 (format
3209 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
3210 (org-trim
3211 (mapconcat
3212 (lambda (pair)
3213 (let ((timestamp (cdr pair)))
3214 (when timestamp
3215 (let ((string (car pair)))
3216 (format "<span class=\"timestamp-kwd\">%s</span> \
3217 <span class=\"timestamp\">%s</span> "
3218 string
3219 (org-html-plain-text (org-timestamp-translate timestamp)
3220 info))))))
3221 `((,org-closed-string . ,(org-element-property :closed planning))
3222 (,org-deadline-string . ,(org-element-property :deadline planning))
3223 (,org-scheduled-string . ,(org-element-property :scheduled planning)))
3224 ""))))
3226 ;;;; Property Drawer
3228 (defun org-html-property-drawer (_property-drawer contents _info)
3229 "Transcode a PROPERTY-DRAWER element from Org to HTML.
3230 CONTENTS holds the contents of the drawer. INFO is a plist
3231 holding contextual information."
3232 (and (org-string-nw-p contents)
3233 (format "<pre class=\"example\">\n%s</pre>" contents)))
3235 ;;;; Quote Block
3237 (defun org-html-quote-block (quote-block contents _info)
3238 "Transcode a QUOTE-BLOCK element from Org to HTML.
3239 CONTENTS holds the contents of the block. INFO is a plist
3240 holding contextual information."
3241 (format "<blockquote%s>\n%s</blockquote>"
3242 (let* ((name (org-element-property :name quote-block))
3243 (attributes (org-export-read-attribute :attr_html quote-block))
3244 (a (org-html--make-attribute-string
3245 (if (or (not name) (plist-member attributes :id))
3246 attributes
3247 (plist-put attributes :id name)))))
3248 (if (org-string-nw-p a) (concat " " a) ""))
3249 contents))
3251 ;;;; Section
3253 (defun org-html-section (section contents info)
3254 "Transcode a SECTION element from Org to HTML.
3255 CONTENTS holds the contents of the section. INFO is a plist
3256 holding contextual information."
3257 (let ((parent (org-export-get-parent-headline section)))
3258 ;; Before first headline: no container, just return CONTENTS.
3259 (if (not parent) contents
3260 ;; Get div's class and id references.
3261 (let* ((class-num (+ (org-export-get-relative-level parent info)
3262 (1- (plist-get info :html-toplevel-hlevel))))
3263 (section-number
3264 (and (org-export-numbered-headline-p parent info)
3265 (mapconcat
3266 #'number-to-string
3267 (org-export-get-headline-number parent info) "-"))))
3268 ;; Build return value.
3269 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
3270 class-num
3271 (or (org-element-property :CUSTOM_ID parent)
3272 section-number
3273 (org-export-get-reference parent info))
3274 (or contents ""))))))
3276 ;;;; Radio Target
3278 (defun org-html-radio-target (radio-target text info)
3279 "Transcode a RADIO-TARGET object from Org to HTML.
3280 TEXT is the text of the target. INFO is a plist holding
3281 contextual information."
3282 (let ((ref (org-export-get-reference radio-target info)))
3283 (org-html--anchor ref text nil info)))
3285 ;;;; Special Block
3287 (defun org-html-special-block (special-block contents info)
3288 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3289 CONTENTS holds the contents of the block. INFO is a plist
3290 holding contextual information."
3291 (let* ((block-type (org-element-property :type special-block))
3292 (html5-fancy (and (org-html--html5-fancy-p info)
3293 (member block-type org-html-html5-elements)))
3294 (attributes (org-export-read-attribute :attr_html special-block)))
3295 (unless html5-fancy
3296 (let ((class (plist-get attributes :class)))
3297 (setq attributes (plist-put attributes :class
3298 (if class (concat class " " block-type)
3299 block-type)))))
3300 (let* ((contents (or contents ""))
3301 (name (org-element-property :name special-block))
3302 (a (org-html--make-attribute-string
3303 (if (or (not name) (plist-member attributes :id))
3304 attributes
3305 (plist-put attributes :id name))))
3306 (str (if (org-string-nw-p a) (concat " " a) "")))
3307 (if html5-fancy
3308 (format "<%s%s>\n%s</%s>" block-type str contents block-type)
3309 (format "<div%s>\n%s\n</div>" str contents)))))
3311 ;;;; Src Block
3313 (defun org-html-src-block (src-block _contents info)
3314 "Transcode a SRC-BLOCK element from Org to HTML.
3315 CONTENTS holds the contents of the item. INFO is a plist holding
3316 contextual information."
3317 (if (org-export-read-attribute :attr_html src-block :textarea)
3318 (org-html--textarea-block src-block)
3319 (let ((lang (org-element-property :language src-block))
3320 (code (org-html-format-code src-block info))
3321 (label (let ((lbl (and (org-element-property :name src-block)
3322 (org-export-get-reference src-block info))))
3323 (if lbl (format " id=\"%s\"" lbl) ""))))
3324 (if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
3325 (format "<div class=\"org-src-container\">\n%s%s\n</div>"
3326 ;; Build caption.
3327 (let ((caption (org-export-get-caption src-block)))
3328 (if (not caption) ""
3329 (let ((listing-number
3330 (format
3331 "<span class=\"listing-number\">%s </span>"
3332 (format
3333 (org-html--translate "Listing %d:" info)
3334 (org-export-get-ordinal
3335 src-block info nil #'org-html--has-caption-p)))))
3336 (format "<label class=\"org-src-name\">%s%s</label>"
3337 listing-number
3338 (org-trim (org-export-data caption info))))))
3339 ;; Contents.
3340 (format "<pre class=\"src src-%s\"%s>%s</pre>"
3341 lang label code))))))
3343 ;;;; Statistics Cookie
3345 (defun org-html-statistics-cookie (statistics-cookie _contents _info)
3346 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3347 CONTENTS is nil. INFO is a plist holding contextual information."
3348 (let ((cookie-value (org-element-property :value statistics-cookie)))
3349 (format "<code>%s</code>" cookie-value)))
3351 ;;;; Strike-Through
3353 (defun org-html-strike-through (_strike-through contents info)
3354 "Transcode STRIKE-THROUGH from Org to HTML.
3355 CONTENTS is the text with strike-through markup. INFO is a plist
3356 holding contextual information."
3357 (format
3358 (or (cdr (assq 'strike-through (plist-get info :html-text-markup-alist)))
3359 "%s")
3360 contents))
3362 ;;;; Subscript
3364 (defun org-html-subscript (_subscript contents _info)
3365 "Transcode a SUBSCRIPT object from Org to HTML.
3366 CONTENTS is the contents of the object. INFO is a plist holding
3367 contextual information."
3368 (format "<sub>%s</sub>" contents))
3370 ;;;; Superscript
3372 (defun org-html-superscript (_superscript contents _info)
3373 "Transcode a SUPERSCRIPT object from Org to HTML.
3374 CONTENTS is the contents of the object. INFO is a plist holding
3375 contextual information."
3376 (format "<sup>%s</sup>" contents))
3378 ;;;; Table Cell
3380 (defun org-html-table-cell (table-cell contents info)
3381 "Transcode a TABLE-CELL element from Org to HTML.
3382 CONTENTS is nil. INFO is a plist used as a communication
3383 channel."
3384 (let* ((table-row (org-export-get-parent table-cell))
3385 (table (org-export-get-parent-table table-cell))
3386 (cell-attrs
3387 (if (not (plist-get info :html-table-align-individual-fields)) ""
3388 (format (if (and (boundp 'org-html-format-table-no-css)
3389 org-html-format-table-no-css)
3390 " align=\"%s\"" " class=\"org-%s\"")
3391 (org-export-table-cell-alignment table-cell info)))))
3392 (when (or (not contents) (string= "" (org-trim contents)))
3393 (setq contents "&#xa0;"))
3394 (cond
3395 ((and (org-export-table-has-header-p table info)
3396 (= 1 (org-export-table-row-group table-row info)))
3397 (let ((header-tags (plist-get info :html-table-header-tags)))
3398 (concat "\n" (format (car header-tags) "col" cell-attrs)
3399 contents
3400 (cdr header-tags))))
3401 ((and (plist-get info :html-table-use-header-tags-for-first-column)
3402 (zerop (cdr (org-export-table-cell-address table-cell info))))
3403 (let ((header-tags (plist-get info :html-table-header-tags)))
3404 (concat "\n" (format (car header-tags) "row" cell-attrs)
3405 contents
3406 (cdr header-tags))))
3407 (t (let ((data-tags (plist-get info :html-table-data-tags)))
3408 (concat "\n" (format (car data-tags) cell-attrs)
3409 contents
3410 (cdr data-tags)))))))
3412 ;;;; Table Row
3414 (defun org-html-table-row (table-row contents info)
3415 "Transcode a TABLE-ROW element from Org to HTML.
3416 CONTENTS is the contents of the row. INFO is a plist used as a
3417 communication channel."
3418 ;; Rules are ignored since table separators are deduced from
3419 ;; borders of the current row.
3420 (when (eq (org-element-property :type table-row) 'standard)
3421 (let* ((group (org-export-table-row-group table-row info))
3422 (number (org-export-table-row-number table-row info))
3423 (start-group-p
3424 (org-export-table-row-starts-rowgroup-p table-row info))
3425 (end-group-p
3426 (org-export-table-row-ends-rowgroup-p table-row info))
3427 (topp (and (equal start-group-p '(top))
3428 (equal end-group-p '(below top))))
3429 (bottomp (and (equal start-group-p '(above))
3430 (equal end-group-p '(bottom above))))
3431 (row-open-tag
3432 (pcase (plist-get info :html-table-row-open-tag)
3433 ((and accessor (pred functionp))
3434 (funcall accessor
3435 number group start-group-p end-group-p topp bottomp))
3436 (accessor accessor)))
3437 (row-close-tag
3438 (pcase (plist-get info :html-table-row-close-tag)
3439 ((and accessor (pred functionp))
3440 (funcall accessor
3441 number group start-group-p end-group-p topp bottomp))
3442 (accessor accessor)))
3443 (group-tags
3444 (cond
3445 ;; Row belongs to second or subsequent groups.
3446 ((not (= 1 group)) '("<tbody>" . "\n</tbody>"))
3447 ;; Row is from first group. Table has >=1 groups.
3448 ((org-export-table-has-header-p
3449 (org-export-get-parent-table table-row) info)
3450 '("<thead>" . "\n</thead>"))
3451 ;; Row is from first and only group.
3452 (t '("<tbody>" . "\n</tbody>")))))
3453 (concat (and start-group-p (car group-tags))
3454 (concat "\n"
3455 row-open-tag
3456 contents
3457 "\n"
3458 row-close-tag)
3459 (and end-group-p (cdr group-tags))))))
3461 ;;;; Table
3463 (defun org-html-table-first-row-data-cells (table info)
3464 "Transcode the first row of TABLE.
3465 INFO is a plist used as a communication channel."
3466 (let ((table-row
3467 (org-element-map table 'table-row
3468 (lambda (row)
3469 (unless (eq (org-element-property :type row) 'rule) row))
3470 info 'first-match))
3471 (special-column-p (org-export-table-has-special-column-p table)))
3472 (if (not special-column-p) (org-element-contents table-row)
3473 (cdr (org-element-contents table-row)))))
3475 (defun org-html-table--table.el-table (table _info)
3476 "Format table.el tables into HTML.
3477 INFO is a plist used as a communication channel."
3478 (when (eq (org-element-property :type table) 'table.el)
3479 (require 'table)
3480 (let ((outbuf (with-current-buffer
3481 (get-buffer-create "*org-export-table*")
3482 (erase-buffer) (current-buffer))))
3483 (with-temp-buffer
3484 (insert (org-element-property :value table))
3485 (goto-char 1)
3486 (re-search-forward "^[ \t]*|[^|]" nil t)
3487 (table-generate-source 'html outbuf))
3488 (with-current-buffer outbuf
3489 (prog1 (org-trim (buffer-string))
3490 (kill-buffer) )))))
3492 (defun org-html-table (table contents info)
3493 "Transcode a TABLE element from Org to HTML.
3494 CONTENTS is the contents of the table. INFO is a plist holding
3495 contextual information."
3496 (if (eq (org-element-property :type table) 'table.el)
3497 ;; "table.el" table. Convert it using appropriate tools.
3498 (org-html-table--table.el-table table info)
3499 ;; Standard table.
3500 (let* ((caption (org-export-get-caption table))
3501 (number (org-export-get-ordinal
3502 table info nil #'org-html--has-caption-p))
3503 (attributes
3504 (org-html--make-attribute-string
3505 (org-combine-plists
3506 (and (org-element-property :name table)
3507 (list :id (org-export-get-reference table info)))
3508 (and (not (org-html-html5-p info))
3509 (plist-get info :html-table-attributes))
3510 (org-export-read-attribute :attr_html table))))
3511 (alignspec
3512 (if (bound-and-true-p org-html-format-table-no-css)
3513 "align=\"%s\""
3514 "class=\"org-%s\""))
3515 (table-column-specs
3516 (lambda (table info)
3517 (mapconcat
3518 (lambda (table-cell)
3519 (let ((alignment (org-export-table-cell-alignment
3520 table-cell info)))
3521 (concat
3522 ;; Begin a colgroup?
3523 (when (org-export-table-cell-starts-colgroup-p
3524 table-cell info)
3525 "\n<colgroup>")
3526 ;; Add a column. Also specify its alignment.
3527 (format "\n%s"
3528 (org-html-close-tag
3529 "col" (concat " " (format alignspec alignment)) info))
3530 ;; End a colgroup?
3531 (when (org-export-table-cell-ends-colgroup-p
3532 table-cell info)
3533 "\n</colgroup>"))))
3534 (org-html-table-first-row-data-cells table info) "\n"))))
3535 (format "<table%s>\n%s\n%s\n%s</table>"
3536 (if (equal attributes "") "" (concat " " attributes))
3537 (if (not caption) ""
3538 (format (if (plist-get info :html-table-caption-above)
3539 "<caption class=\"t-above\">%s</caption>"
3540 "<caption class=\"t-bottom\">%s</caption>")
3541 (concat
3542 "<span class=\"table-number\">"
3543 (format (org-html--translate "Table %d:" info) number)
3544 "</span> " (org-export-data caption info))))
3545 (funcall table-column-specs table info)
3546 contents))))
3548 ;;;; Target
3550 (defun org-html-target (target _contents info)
3551 "Transcode a TARGET object from Org to HTML.
3552 CONTENTS is nil. INFO is a plist holding contextual
3553 information."
3554 (let ((ref (org-export-get-reference target info)))
3555 (org-html--anchor ref nil nil info)))
3557 ;;;; Timestamp
3559 (defun org-html-timestamp (timestamp _contents info)
3560 "Transcode a TIMESTAMP object from Org to HTML.
3561 CONTENTS is nil. INFO is a plist holding contextual
3562 information."
3563 (let ((value (org-html-plain-text (org-timestamp-translate timestamp) info)))
3564 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3565 (replace-regexp-in-string "--" "&#x2013;" value))))
3567 ;;;; Underline
3569 (defun org-html-underline (_underline contents info)
3570 "Transcode UNDERLINE from Org to HTML.
3571 CONTENTS is the text with underline markup. INFO is a plist
3572 holding contextual information."
3573 (format (or (cdr (assq 'underline (plist-get info :html-text-markup-alist)))
3574 "%s")
3575 contents))
3577 ;;;; Verbatim
3579 (defun org-html-verbatim (verbatim _contents info)
3580 "Transcode VERBATIM from Org to HTML.
3581 CONTENTS is nil. INFO is a plist holding contextual
3582 information."
3583 (format (or (cdr (assq 'verbatim (plist-get info :html-text-markup-alist))) "%s")
3584 (org-html-encode-plain-text (org-element-property :value verbatim))))
3586 ;;;; Verse Block
3588 (defun org-html-verse-block (_verse-block contents info)
3589 "Transcode a VERSE-BLOCK element from Org to HTML.
3590 CONTENTS is verse block contents. INFO is a plist holding
3591 contextual information."
3592 (format "<p class=\"verse\">\n%s</p>"
3593 ;; Replace leading white spaces with non-breaking spaces.
3594 (replace-regexp-in-string
3595 "^[ \t]+" (lambda (m) (org-html--make-string (length m) "&#xa0;"))
3596 ;; Replace each newline character with line break. Also
3597 ;; remove any trailing "br" close-tag so as to avoid
3598 ;; duplicates.
3599 (let* ((br (org-html-close-tag "br" nil info))
3600 (re (format "\\(?:%s\\)?[ \t]*\n" (regexp-quote br))))
3601 (replace-regexp-in-string re (concat br "\n") contents)))))
3604 ;;; Filter Functions
3606 (defun org-html-final-function (contents _backend info)
3607 "Filter to indent the HTML and convert HTML entities."
3608 (with-temp-buffer
3609 (insert contents)
3610 (set-auto-mode t)
3611 (if (plist-get info :html-indent)
3612 (indent-region (point-min) (point-max)))
3613 (buffer-substring-no-properties (point-min) (point-max))))
3616 ;;; End-user functions
3618 ;;;###autoload
3619 (defun org-html-export-as-html
3620 (&optional async subtreep visible-only body-only ext-plist)
3621 "Export current buffer to an HTML buffer.
3623 If narrowing is active in the current buffer, only export its
3624 narrowed part.
3626 If a region is active, export that region.
3628 A non-nil optional argument ASYNC means the process should happen
3629 asynchronously. The resulting buffer should be accessible
3630 through the `org-export-stack' interface.
3632 When optional argument SUBTREEP is non-nil, export the sub-tree
3633 at point, extracting information from the headline properties
3634 first.
3636 When optional argument VISIBLE-ONLY is non-nil, don't export
3637 contents of hidden elements.
3639 When optional argument BODY-ONLY is non-nil, only write code
3640 between \"<body>\" and \"</body>\" tags.
3642 EXT-PLIST, when provided, is a property list with external
3643 parameters overriding Org default settings, but still inferior to
3644 file-local settings.
3646 Export is done in a buffer named \"*Org HTML Export*\", which
3647 will be displayed when `org-export-show-temporary-export-buffer'
3648 is non-nil."
3649 (interactive)
3650 (org-export-to-buffer 'html "*Org HTML Export*"
3651 async subtreep visible-only body-only ext-plist
3652 (lambda () (set-auto-mode t))))
3654 ;;;###autoload
3655 (defun org-html-convert-region-to-html ()
3656 "Assume the current region has Org syntax, and convert it to HTML.
3657 This can be used in any buffer. For example, you can write an
3658 itemized list in Org syntax in an HTML buffer and use this command
3659 to convert it."
3660 (interactive)
3661 (org-export-replace-region-by 'html))
3663 ;;;###autoload
3664 (defun org-html-export-to-html
3665 (&optional async subtreep visible-only body-only ext-plist)
3666 "Export current buffer to a HTML file.
3668 If narrowing is active in the current buffer, only export its
3669 narrowed part.
3671 If a region is active, export that region.
3673 A non-nil optional argument ASYNC means the process should happen
3674 asynchronously. The resulting file should be accessible through
3675 the `org-export-stack' interface.
3677 When optional argument SUBTREEP is non-nil, export the sub-tree
3678 at point, extracting information from the headline properties
3679 first.
3681 When optional argument VISIBLE-ONLY is non-nil, don't export
3682 contents of hidden elements.
3684 When optional argument BODY-ONLY is non-nil, only write code
3685 between \"<body>\" and \"</body>\" tags.
3687 EXT-PLIST, when provided, is a property list with external
3688 parameters overriding Org default settings, but still inferior to
3689 file-local settings.
3691 Return output file's name."
3692 (interactive)
3693 (let* ((extension (concat "." (or (plist-get ext-plist :html-extension)
3694 org-html-extension
3695 "html")))
3696 (file (org-export-output-file-name extension subtreep))
3697 (org-export-coding-system org-html-coding-system))
3698 (org-export-to-file 'html file
3699 async subtreep visible-only body-only ext-plist)))
3701 ;;;###autoload
3702 (defun org-html-publish-to-html (plist filename pub-dir)
3703 "Publish an org file to HTML.
3705 FILENAME is the filename of the Org file to be published. PLIST
3706 is the property list for the given project. PUB-DIR is the
3707 publishing directory.
3709 Return output file name."
3710 (org-publish-org-to 'html filename
3711 (concat "." (or (plist-get plist :html-extension)
3712 org-html-extension
3713 "html"))
3714 plist pub-dir))
3717 (provide 'ox-html)
3719 ;; Local variables:
3720 ;; generated-autoload-file: "org-loaddefs.el"
3721 ;; End:
3723 ;;; ox-html.el ends here