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