1 ;;; ox-html.el --- HTML Back-End for Org Export Engine
3 ;; Copyright (C) 2011-2014 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Jambunathan K <kjambunathan at gmail dot com>
7 ;; Keywords: outlines, hypermedia, calendar, wp
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This library implements a HTML back-end for Org generic exporter.
27 ;; See Org manual for more information.
35 (require 'format-spec
)
36 (eval-when-compile (require 'cl
) (require 'table nil
'noerror
))
39 ;;; Function Declarations
41 (declare-function org-id-find-id-file
"org-id" (id))
42 (declare-function htmlize-region
"ext:htmlize" (beg end
))
43 (declare-function org-pop-to-buffer-same-window
44 "org-compat" (&optional buffer-or-name norecord label
))
45 (declare-function mm-url-decode-entities
"mm-url" ())
49 (org-export-define-backend 'html
50 '((bold . org-html-bold
)
51 (center-block . org-html-center-block
)
52 (clock . org-html-clock
)
53 (code . org-html-code
)
54 (drawer . org-html-drawer
)
55 (dynamic-block . org-html-dynamic-block
)
56 (entity . org-html-entity
)
57 (example-block . org-html-example-block
)
58 (export-block . org-html-export-block
)
59 (export-snippet . org-html-export-snippet
)
60 (fixed-width . org-html-fixed-width
)
61 (footnote-definition . org-html-footnote-definition
)
62 (footnote-reference . org-html-footnote-reference
)
63 (headline . org-html-headline
)
64 (horizontal-rule . org-html-horizontal-rule
)
65 (inline-src-block . org-html-inline-src-block
)
66 (inlinetask . org-html-inlinetask
)
67 (inner-template . org-html-inner-template
)
68 (italic . org-html-italic
)
69 (item . org-html-item
)
70 (keyword . org-html-keyword
)
71 (latex-environment . org-html-latex-environment
)
72 (latex-fragment . org-html-latex-fragment
)
73 (line-break . org-html-line-break
)
74 (link . org-html-link
)
75 (paragraph . org-html-paragraph
)
76 (plain-list . org-html-plain-list
)
77 (plain-text . org-html-plain-text
)
78 (planning . org-html-planning
)
79 (property-drawer . org-html-property-drawer
)
80 (quote-block . org-html-quote-block
)
81 (quote-section . org-html-quote-section
)
82 (radio-target . org-html-radio-target
)
83 (section . org-html-section
)
84 (special-block . org-html-special-block
)
85 (src-block . org-html-src-block
)
86 (statistics-cookie . org-html-statistics-cookie
)
87 (strike-through . org-html-strike-through
)
88 (subscript . org-html-subscript
)
89 (superscript . org-html-superscript
)
90 (table . org-html-table
)
91 (table-cell . org-html-table-cell
)
92 (table-row . org-html-table-row
)
93 (target . org-html-target
)
94 (template . org-html-template
)
95 (timestamp . org-html-timestamp
)
96 (underline . org-html-underline
)
97 (verbatim . org-html-verbatim
)
98 (verse-block . org-html-verse-block
))
100 :filters-alist
'((:filter-options . org-html-infojs-install-script
)
101 (:filter-final-output . org-html-final-function
))
103 '(?h
"Export to HTML"
104 ((?H
"As HTML buffer" org-html-export-as-html
)
105 (?h
"As HTML file" org-html-export-to-html
)
106 (?o
"As HTML file and open"
108 (if a
(org-html-export-to-html t s v b
)
109 (org-open-file (org-html-export-to-html nil s v b
)))))))
111 '((:html-extension nil nil org-html-extension
)
112 (:html-link-org-as-html nil nil org-html-link-org-files-as-html
)
113 (:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
114 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
115 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
116 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
117 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
118 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
119 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
120 (:html-postamble nil
"html-postamble" org-html-postamble
)
121 (:html-preamble nil
"html-preamble" org-html-preamble
)
122 (:html-head
"HTML_HEAD" nil org-html-head newline
)
123 (:html-head-extra
"HTML_HEAD_EXTRA" nil org-html-head-extra newline
)
124 (:html-head-include-default-style nil
"html-style" org-html-head-include-default-style
)
125 (:html-head-include-scripts nil
"html-scripts" org-html-head-include-scripts
)
126 (:html-table-attributes nil nil org-html-table-default-attributes
)
127 (:html-table-row-tags nil nil org-html-table-row-tags
)
128 (:html-xml-declaration nil nil org-html-xml-declaration
)
129 (:html-inline-images nil nil org-html-inline-images
)
130 (:infojs-opt
"INFOJS_OPT" nil nil
)
131 ;; Redefine regular options.
132 (:creator
"CREATOR" nil org-html-creator-string
)
133 (:with-latex nil
"tex" org-html-with-latex
)
134 ;; Retrieve LaTeX header for fragments.
135 (:latex-header
"LATEX_HEADER" nil nil newline
)))
138 ;;; Internal Variables
140 (defvar org-html-format-table-no-css
)
141 (defvar htmlize-buffer-places
) ; from htmlize.el
143 (defvar org-html--pre
/postamble-class
"status"
144 "CSS class used for pre/postamble")
146 (defconst org-html-doctype-alist
147 '(("html4-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
148 \"http://www.w3.org/TR/html4/strict.dtd\">")
149 ("html4-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
150 \"http://www.w3.org/TR/html4/loose.dtd\">")
151 ("html4-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
152 \"http://www.w3.org/TR/html4/frameset.dtd\">")
154 ("xhtml-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
155 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
156 ("xhtml-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
157 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
158 ("xhtml-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
159 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
160 ("xhtml-11" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
161 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
163 ("html5" .
"<!DOCTYPE html>")
164 ("xhtml5" .
"<!DOCTYPE html>"))
165 "An alist mapping (x)html flavors to specific doctypes.")
167 (defconst org-html-html5-elements
168 '("article" "aside" "audio" "canvas" "details" "figcaption"
169 "figure" "footer" "header" "menu" "meter" "nav" "output"
170 "progress" "section" "video")
171 "New elements in html5.
173 <hgroup> is not included because it's currently impossible to
174 wrap special blocks around multiple headlines. For other blocks
175 that should contain headlines, use the HTML_CONTAINER property on
176 the headline itself.")
178 (defconst org-html-special-string-regexps
179 '(("\\\\-" .
"­") ; shy
180 ("---\\([^-]\\)" .
"—\\1") ; mdash
181 ("--\\([^-]\\)" .
"–\\1") ; ndash
182 ("\\.\\.\\." .
"…")) ; hellip
183 "Regular expressions for special string conversion.")
185 (defconst org-html-scripts
186 "<script type=\"text/javascript\">
188 @licstart The following is the entire license notice for the
189 JavaScript code in this tag.
191 Copyright (C) 2012-2013 Free Software Foundation, Inc.
193 The JavaScript code in this tag is free software: you can
194 redistribute it and/or modify it under the terms of the GNU
195 General Public License (GNU GPL) as published by the Free Software
196 Foundation, either version 3 of the License, or (at your option)
197 any later version. The code is distributed WITHOUT ANY WARRANTY;
198 without even the implied warranty of MERCHANTABILITY or FITNESS
199 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
201 As additional permission under GNU GPL version 3 section 7, you
202 may distribute non-source (e.g., minimized or compacted) forms of
203 that code without the copy of the GNU GPL normally required by
204 section 4, provided you include this license notice and a URL
205 through which recipients can access the Corresponding Source.
208 @licend The above is the entire license notice
209 for the JavaScript code in this tag.
211 <!--/*--><![CDATA[/*><!--*/
212 function CodeHighlightOn(elem, id)
214 var target = document.getElementById(id);
216 elem.cacheClassElem = elem.className;
217 elem.cacheClassTarget = target.className;
218 target.className = \"code-highlighted\";
219 elem.className = \"code-highlighted\";
222 function CodeHighlightOff(elem, id)
224 var target = document.getElementById(id);
225 if(elem.cacheClassElem)
226 elem.className = elem.cacheClassElem;
227 if(elem.cacheClassTarget)
228 target.className = elem.cacheClassTarget;
232 "Basic JavaScript that is needed by HTML files produced by Org mode.")
234 (defconst org-html-style-default
235 "<style type=\"text/css\">
236 <!--/*--><![CDATA[/*><!--*/
237 .title { text-align: center; }
238 .todo { font-family: monospace; color: red; }
239 .done { color: green; }
240 .tag { background-color: #eee; font-family: monospace;
241 padding: 2px; font-size: 80%; font-weight: normal; }
242 .timestamp { color: #bebebe; }
243 .timestamp-kwd { color: #5f9ea0; }
244 .right { margin-left: auto; margin-right: 0px; text-align: right; }
245 .left { margin-left: 0px; margin-right: auto; text-align: left; }
246 .center { margin-left: auto; margin-right: auto; text-align: center; }
247 .underline { text-decoration: underline; }
248 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
249 p.verse { margin-left: 3%; }
251 border: 1px solid #ccc;
252 box-shadow: 3px 3px 3px #eee;
254 font-family: monospace;
266 background-color: white;
270 border: 1px solid black;
272 pre.src:hover:before { display: inline;}
273 pre.src-sh:before { content: 'sh'; }
274 pre.src-bash:before { content: 'sh'; }
275 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
276 pre.src-R:before { content: 'R'; }
277 pre.src-perl:before { content: 'Perl'; }
278 pre.src-java:before { content: 'Java'; }
279 pre.src-sql:before { content: 'SQL'; }
281 table { border-collapse:collapse; }
282 caption.t-above { caption-side: top; }
283 caption.t-bottom { caption-side: bottom; }
284 td, th { vertical-align:top; }
285 th.right { text-align: center; }
286 th.left { text-align: center; }
287 th.center { text-align: center; }
288 td.right { text-align: right; }
289 td.left { text-align: left; }
290 td.center { text-align: center; }
291 dt { font-weight: bold; }
292 .footpara:nth-child(2) { display: inline; }
293 .footpara { display: block; }
294 .footdef { margin-bottom: 1em; }
295 .figure { padding: 1em; }
296 .figure p { text-align: center; }
299 border: 2px solid gray;
304 { text-align: right; font-size: 70%; white-space: nowrap; }
305 textarea { overflow-x: auto; }
306 .linenr { font-size: smaller }
307 .code-highlighted { background-color: #ffff00; }
308 .org-info-js_info-navigation { border-style: none; }
309 #org-info-js_console-label
310 { font-size: 10px; font-weight: bold; white-space: nowrap; }
311 .org-info-js_search-highlight
312 { background-color: #ffff00; color: #000000; font-weight: bold; }
315 "The default style specification for exported HTML files.
316 You can use `org-html-head' and `org-html-head-extra' to add to
317 this style. If you don't want to include this default style,
318 customize `org-html-head-include-default-style'.")
321 ;;; User Configuration Variables
323 (defgroup org-export-html nil
324 "Options for exporting Org mode files to HTML."
325 :tag
"Org Export HTML"
330 (defvar org-html-infojs-opts-table
331 '((path PATH
"http://orgmode.org/org-info.js")
335 (tdepth TOC_DEPTH
"max")
336 (sdepth SECTION_DEPTH
"max")
337 (mouse MOUSE_HINT
"underline")
338 (buttons VIEW_BUTTONS
"0")
340 (up LINK_UP
:html-link-up
)
341 (home LINK_HOME
:html-link-home
))
342 "JavaScript options, long form for script, default values.")
344 (defcustom org-html-use-infojs
'when-configured
345 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
346 This option can be nil or t to never or always use the script.
347 It can also be the symbol `when-configured', meaning that the
348 script will be linked into the export file if and only if there
349 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
350 `org-html-infojs-options'."
351 :group
'org-export-html
353 :package-version
'(Org .
"8.0")
355 (const :tag
"Never" nil
)
356 (const :tag
"When configured in buffer" when-configured
)
357 (const :tag
"Always" t
)))
359 (defcustom org-html-infojs-options
360 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
361 "Options settings for the INFOJS JavaScript.
362 Each of the options must have an entry in `org-html-infojs-opts-table'.
363 The value can either be a string that will be passed to the script, or
364 a property. This property is then assumed to be a property that is defined
365 by the Export/Publishing setup of Org.
366 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
367 means to use the maximum value consistent with other options."
368 :group
'org-export-html
370 :package-version
'(Org .
"8.0")
372 `(set :greedy t
:inline t
375 (list 'cons
(list 'const
(car x
))
377 (symbol :tag
"Publishing/Export property")
378 (string :tag
"Value"))))
379 org-html-infojs-opts-table
)))
381 (defcustom org-html-infojs-template
382 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
385 * @source: %SCRIPT_PATH
387 * @licstart The following is the entire license notice for the
388 * JavaScript code in %SCRIPT_PATH.
390 * Copyright (C) 2012-2013 Free Software Foundation, Inc.
393 * The JavaScript code in this tag is free software: you can
394 * redistribute it and/or modify it under the terms of the GNU
395 * General Public License (GNU GPL) as published by the Free Software
396 * Foundation, either version 3 of the License, or (at your option)
397 * any later version. The code is distributed WITHOUT ANY WARRANTY;
398 * without even the implied warranty of MERCHANTABILITY or FITNESS
399 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
401 * As additional permission under GNU GPL version 3 section 7, you
402 * may distribute non-source (e.g., minimized or compacted) forms of
403 * that code without the copy of the GNU GPL normally required by
404 * section 4, provided you include this license notice and a URL
405 * through which recipients can access the Corresponding Source.
407 * @licend The above is the entire license notice
408 * for the JavaScript code in %SCRIPT_PATH.
413 <script type=\"text/javascript\">
416 @licstart The following is the entire license notice for the
417 JavaScript code in this tag.
419 Copyright (C) 2012-2013 Free Software Foundation, Inc.
421 The JavaScript code in this tag is free software: you can
422 redistribute it and/or modify it under the terms of the GNU
423 General Public License (GNU GPL) as published by the Free Software
424 Foundation, either version 3 of the License, or (at your option)
425 any later version. The code is distributed WITHOUT ANY WARRANTY;
426 without even the implied warranty of MERCHANTABILITY or FITNESS
427 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
429 As additional permission under GNU GPL version 3 section 7, you
430 may distribute non-source (e.g., minimized or compacted) forms of
431 that code without the copy of the GNU GPL normally required by
432 section 4, provided you include this license notice and a URL
433 through which recipients can access the Corresponding Source.
436 @licend The above is the entire license notice
437 for the JavaScript code in this tag.
440 <!--/*--><![CDATA[/*><!--*/
442 org_html_manager.setup(); // activate after the parameters are set
445 "The template for the export style additions when org-info.js is used.
446 Option settings will replace the %MANAGER-OPTIONS cookie."
447 :group
'org-export-html
449 :package-version
'(Org .
"8.0")
452 (defun org-html-infojs-install-script (exp-plist backend
)
453 "Install script in export options when appropriate.
454 EXP-PLIST is a plist containing export options. BACKEND is the
455 export back-end currently used."
456 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
457 (not org-html-use-infojs
)
458 (and (eq org-html-use-infojs
'when-configured
)
459 (or (not (plist-get exp-plist
:infojs-opt
))
460 (string-match "\\<view:nil\\>"
461 (plist-get exp-plist
:infojs-opt
)))))
462 (let* ((template org-html-infojs-template
)
463 (ptoc (plist-get exp-plist
:with-toc
))
464 (hlevels (plist-get exp-plist
:headline-levels
))
466 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
467 (options (plist-get exp-plist
:infojs-opt
))
468 (table org-html-infojs-opts-table
)
470 (dolist (entry table
)
471 (let* ((opt (car entry
))
473 ;; Compute default values for script option OPT from
474 ;; `org-html-infojs-options' variable.
476 (let ((default (cdr (assq opt org-html-infojs-options
))))
477 (if (and (symbolp default
) (not (memq default
'(t nil
))))
478 (plist-get exp-plist default
)
480 ;; Value set through INFOJS_OPT keyword has precedence
481 ;; over the default one.
482 (val (if (and options
483 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
485 (match-string 1 options
)
489 (replace-regexp-in-string
490 "%SCRIPT_PATH" val template t t
)))
491 (sdepth (when (integerp (read val
))
492 (setq sdepth
(min (read val
) sdepth
))))
493 (tdepth (when (integerp (read val
))
494 (setq tdepth
(min (read val
) tdepth
))))
497 ((or (eq val t
) (equal val
"t")) "1")
498 ((or (eq val nil
) (equal val
"nil")) "0")
500 (t (format "%s" val
))))
501 (push (cons var val
) style
)))))
502 ;; Now we set the depth of the *generated* TOC to SDEPTH,
503 ;; because the toc will actually determine the splitting. How
504 ;; much of the toc will actually be displayed is governed by the
506 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
507 ;; The table of contents should not show more sections than we
509 (setq tdepth
(min tdepth sdepth
))
510 (push (cons "TOC_DEPTH" tdepth
) style
)
511 ;; Build style string.
512 (setq style
(mapconcat
513 (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
517 (when (and style
(> (length style
) 0))
518 (and (string-match "%MANAGER_OPTIONS" template
)
519 (setq style
(replace-match style t t template
))
522 exp-plist
:html-head-extra
523 (concat (or (plist-get exp-plist
:html-head-extra
) "")
526 ;; This script absolutely needs the table of contents, so we
527 ;; change that setting.
528 (unless (plist-get exp-plist
:with-toc
)
529 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
530 ;; Return the modified property list.
535 (defcustom org-html-text-markup-alist
536 '((bold .
"<b>%s</b>")
537 (code .
"<code>%s</code>")
538 (italic .
"<i>%s</i>")
539 (strike-through .
"<del>%s</del>")
540 (underline .
"<span class=\"underline\">%s</span>")
541 (verbatim .
"<code>%s</code>"))
542 "Alist of HTML expressions to convert text markup.
544 The key must be a symbol among `bold', `code', `italic',
545 `strike-through', `underline' and `verbatim'. The value is
546 a formatting string to wrap fontified text with.
548 If no association can be found for a given markup, text will be
550 :group
'org-export-html
552 :package-version
'(Org .
"8.0")
553 :type
'(alist :key-type
(symbol :tag
"Markup type")
554 :value-type
(string :tag
"Format string"))
555 :options
'(bold code italic strike-through underline verbatim
))
557 (defcustom org-html-indent nil
558 "Non-nil means to indent the generated HTML.
559 Warning: non-nil may break indentation of source code blocks."
560 :group
'org-export-html
562 :package-version
'(Org .
"8.0")
565 (defcustom org-html-use-unicode-chars nil
566 "Non-nil means to use unicode characters instead of HTML entities."
567 :group
'org-export-html
569 :package-version
'(Org .
"8.0")
574 (defcustom org-html-format-drawer-function
575 (lambda (name contents
) contents
)
576 "Function called to format a drawer in HTML code.
578 The function must accept two parameters:
579 NAME the drawer name, like \"LOGBOOK\"
580 CONTENTS the contents of the drawer.
582 The function should return the string to be exported.
584 For example, the variable could be set to the following function
585 in order to mimic default behaviour:
587 The default value simply returns the value of CONTENTS."
588 :group
'org-export-html
590 :package-version
'(Org .
"8.0")
595 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
596 <h2 class=\"footnotes\">%s: </h2>
597 <div id=\"text-footnotes\">
601 "Format for the footnotes section.
602 Should contain a two instances of %s. The first will be replaced with the
603 language-specific word for \"Footnotes\", the second one will be replaced
604 by the footnotes themselves."
605 :group
'org-export-html
608 (defcustom org-html-footnote-format
"<sup>%s</sup>"
609 "The format for the footnote reference.
610 %s will be replaced by the footnote reference itself."
611 :group
'org-export-html
614 (defcustom org-html-footnote-separator
"<sup>, </sup>"
615 "Text used to separate footnotes."
616 :group
'org-export-html
621 (defcustom org-html-toplevel-hlevel
2
622 "The <H> level for level 1 headings in HTML export.
623 This is also important for the classes that will be wrapped around headlines
624 and outline structure. If this variable is 1, the top-level headlines will
625 be <h1>, and the corresponding classes will be outline-1, section-number-1,
626 and outline-text-1. If this is 2, all of these will get a 2 instead.
627 The default for this variable is 2, because we use <h1> for formatting the
629 :group
'org-export-html
632 (defcustom org-html-format-headline-function
'ignore
633 "Function to format headline text.
635 This function will be called with 5 arguments:
636 TODO the todo keyword (string or nil).
637 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
638 PRIORITY the priority of the headline (integer or nil)
639 TEXT the main headline text (string).
640 TAGS the tags (string or nil).
642 The function result will be used in the section format string."
643 :group
'org-export-html
645 :package-version
'(Org .
"8.0")
650 (defcustom org-html-allow-name-attribute-in-anchors t
651 "When nil, do not set \"name\" attribute in anchors.
652 By default, anchors are formatted with both \"id\" and \"name\"
653 attributes, when appropriate."
654 :group
'org-export-html
656 :package-version
'(Org .
"8.0")
661 (defcustom org-html-format-inlinetask-function
'ignore
662 "Function called to format an inlinetask in HTML code.
664 The function must accept six parameters:
665 TODO the todo keyword, as a string
666 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
667 PRIORITY the inlinetask priority, as a string
668 NAME the inlinetask name, as a string.
669 TAGS the inlinetask tags, as a list of strings.
670 CONTENTS the contents of the inlinetask, as a string.
672 The function should return the string to be exported."
673 :group
'org-export-html
675 :package-version
'(Org .
"8.0")
680 (defcustom org-html-with-latex org-export-with-latex
681 "Non-nil means process LaTeX math snippets.
683 When set, the exporter will process LaTeX environments and
686 This option can also be set with the +OPTIONS line,
687 e.g. \"tex:mathjax\". Allowed values are:
689 nil Ignore math snippets.
690 `verbatim' Keep everything in verbatim
691 `dvipng' Process the LaTeX fragments to images. This will also
692 include processing of non-math environments.
693 `imagemagick' Convert the LaTeX fragments to pdf files and use
694 imagemagick to convert pdf files to png files.
695 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
697 t Synonym for `mathjax'."
698 :group
'org-export-html
700 :package-version
'(Org .
"8.0")
702 (const :tag
"Do not process math in any way" nil
)
703 (const :tag
"Use dvipng to make images" dvipng
)
704 (const :tag
"Use imagemagick to make images" imagemagick
)
705 (const :tag
"Use MathJax to display math" mathjax
)
706 (const :tag
"Leave math verbatim" verbatim
)))
708 ;;;; Links :: Generic
710 (defcustom org-html-link-org-files-as-html t
711 "Non-nil means make file links to `file.org' point to `file.html'.
712 When `org-mode' is exporting an `org-mode' file to HTML, links to
713 non-html files are directly put into a href tag in HTML.
714 However, links to other Org-mode files (recognized by the
715 extension `.org.) should become links to the corresponding html
716 file, assuming that the linked `org-mode' file will also be
718 When nil, the links still point to the plain `.org' file."
719 :group
'org-export-html
722 ;;;; Links :: Inline images
724 (defcustom org-html-inline-images t
725 "Non-nil means inline images into exported HTML pages.
726 This is done using an <img> tag. When nil, an anchor with href is used to
728 :group
'org-export-html
730 :package-version
'(Org .
"8.1")
733 (defcustom org-html-inline-image-rules
734 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
735 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
736 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
737 "Rules characterizing image files that can be inlined into HTML.
738 A rule consists in an association whose key is the type of link
739 to consider, and value is a regexp that will be matched against
741 :group
'org-export-html
743 :package-version
'(Org .
"8.0")
744 :type
'(alist :key-type
(string :tag
"Type")
745 :value-type
(regexp :tag
"Path")))
749 (defcustom org-html-protect-char-alist
753 "Alist of characters to be converted by `org-html-protect'."
754 :group
'org-export-html
755 :type
'(repeat (cons (string :tag
"Character")
756 (string :tag
"HTML equivalent"))))
760 (defcustom org-html-htmlize-output-type
'inline-css
761 "Output type to be used by htmlize when formatting code snippets.
762 Choices are `css', to export the CSS selectors only, or `inline-css', to
763 export the CSS attribute values inline in the HTML. We use as default
764 `inline-css', in order to make the resulting HTML self-containing.
766 However, this will fail when using Emacs in batch mode for export, because
767 then no rich font definitions are in place. It will also not be good if
768 people with different Emacs setup contribute HTML files to a website,
769 because the fonts will represent the individual setups. In these cases,
770 it is much better to let Org/Htmlize assign classes only, and to use
771 a style file to define the look of these classes.
772 To get a start for your css file, start Emacs session and make sure that
773 all the faces you are interested in are defined, for example by loading files
774 in all modes you want. Then, use the command
775 \\[org-html-htmlize-generate-css] to extract class definitions."
776 :group
'org-export-html
777 :type
'(choice (const css
) (const inline-css
)))
779 (defcustom org-html-htmlize-font-prefix
"org-"
780 "The prefix for CSS class names for htmlize font specifications."
781 :group
'org-export-html
786 (defcustom org-html-table-default-attributes
787 '(:border
"2" :cellspacing
"0" :cellpadding
"6" :rules
"groups" :frame
"hsides")
788 "Default attributes and values which will be used in table tags.
789 This is a plist where attributes are symbols, starting with
790 colons, and values are strings.
792 When exporting to HTML5, these values will be disregarded."
793 :group
'org-export-html
795 :package-version
'(Org .
"8.0")
796 :type
'(plist :key-type
(symbol :tag
"Property")
797 :value-type
(string :tag
"Value")))
799 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
800 "The opening tag for table header fields.
801 This is customizable so that alignment options can be specified.
802 The first %s will be filled with the scope of the field, either row or col.
803 The second %s will be replaced by a style entry to align the field.
804 See also the variable `org-html-table-use-header-tags-for-first-column'.
805 See also the variable `org-html-table-align-individual-fields'."
806 :group
'org-export-html
807 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
809 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
810 "The opening tag for table data fields.
811 This is customizable so that alignment options can be specified.
812 The first %s will be filled with the scope of the field, either row or col.
813 The second %s will be replaced by a style entry to align the field.
814 See also the variable `org-html-table-align-individual-fields'."
815 :group
'org-export-html
816 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
818 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
819 "The opening and ending tags for table rows.
820 This is customizable so that alignment options can be specified.
821 Instead of strings, these can be Lisp forms that will be
822 evaluated for each row in order to construct the table row tags.
824 During evaluation, these variables will be dynamically bound so that
827 `row-number': row number (0 is the first row)
828 `rowgroup-number': group number of current row
829 `start-rowgroup-p': non-nil means the row starts a group
830 `end-rowgroup-p': non-nil means the row ends a group
831 `top-row-p': non-nil means this is the top row
832 `bottom-row-p': non-nil means this is the bottom row
836 \(setq org-html-table-row-tags
837 (cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
838 (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
839 (t (if (= (mod row-number 2) 1)
840 \"<tr class=\\\"tr-odd\\\">\"
841 \"<tr class=\\\"tr-even\\\">\")))
844 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
845 and the bottom row, and otherwise alternate between \"tr-odd\" and
846 \"tr-even\" for odd and even rows."
847 :group
'org-export-html
849 (choice :tag
"Opening tag"
850 (string :tag
"Specify")
852 (choice :tag
"Closing tag"
853 (string :tag
"Specify")
856 (defcustom org-html-table-align-individual-fields t
857 "Non-nil means attach style attributes for alignment to each table field.
858 When nil, alignment will only be specified in the column tags, but this
859 is ignored by some browsers (like Firefox, Safari). Opera does it right
861 :group
'org-export-html
864 (defcustom org-html-table-use-header-tags-for-first-column nil
865 "Non-nil means format column one in tables with header tags.
866 When nil, also column one will use data tags."
867 :group
'org-export-html
870 (defcustom org-html-table-caption-above t
871 "When non-nil, place caption string at the beginning of the table.
872 Otherwise, place it near the end."
873 :group
'org-export-html
878 (defcustom org-html-tag-class-prefix
""
879 "Prefix to class names for TODO keywords.
880 Each tag gets a class given by the tag itself, with this prefix.
881 The default prefix is empty because it is nice to just use the keyword
882 as a class name. But if you get into conflicts with other, existing
883 CSS classes, then this prefix can be very useful."
884 :group
'org-export-html
887 ;;;; Template :: Generic
889 (defcustom org-html-extension
"html"
890 "The extension for exported HTML files."
891 :group
'org-export-html
894 (defcustom org-html-xml-declaration
895 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
896 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
897 "The extension for exported HTML files.
898 %s will be replaced with the charset of the exported file.
899 This may be a string, or an alist with export extensions
900 and corresponding declarations.
902 This declaration only applies when exporting to XHTML."
903 :group
'org-export-html
905 (string :tag
"Single declaration")
906 (repeat :tag
"Dependent on extension"
907 (cons (string :tag
"Extension")
908 (string :tag
"Declaration")))))
910 (defcustom org-html-coding-system
'utf-8
911 "Coding system for HTML export.
912 Use utf-8 as the default value."
913 :group
'org-export-html
915 :package-version
'(Org .
"8.0")
916 :type
'coding-system
)
918 (defcustom org-html-doctype
"xhtml-strict"
919 "Document type definition to use for exported HTML files.
920 Can be set with the in-buffer HTML_DOCTYPE property or for
921 publishing, with :html-doctype."
922 :group
'org-export-html
924 :package-version
'(Org .
"8.0")
927 (defcustom org-html-html5-fancy nil
928 "Non-nil means using new HTML5 elements.
929 This variable is ignored for anything other than HTML5 export.
931 For compatibility with Internet Explorer, it's probably a good
932 idea to download some form of the html5shiv (for instance
933 https://code.google.com/p/html5shiv/) and add it to your
934 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
935 versions 8 and below."
936 :group
'org-export-html
938 :package-version
'(Org .
"8.0")
941 (defcustom org-html-container-element
"div"
942 "HTML element to use for wrapping top level sections.
943 Can be set with the in-buffer HTML_CONTAINER property or for
944 publishing, with :html-container.
946 Note that changing the default will prevent you from using
947 org-info.js for your website."
948 :group
'org-export-html
950 :package-version
'(Org .
"8.0")
953 (defcustom org-html-divs
954 '((preamble "div" "preamble")
955 (content "div" "content")
956 (postamble "div" "postamble"))
957 "Alist of the three section elements for HTML export.
958 The car of each entry is one of 'preamble, 'content or 'postamble.
959 The cdrs of each entry are the ELEMENT_TYPE and ID for each
960 section of the exported document.
962 Note that changing the default will prevent you from using
963 org-info.js for your website."
964 :group
'org-export-html
966 :package-version
'(Org .
"8.0")
967 :type
'(list :greedy t
968 (list :tag
"Preamble"
969 (const :format
"" preamble
)
970 (string :tag
"element") (string :tag
" id"))
972 (const :format
"" content
)
973 (string :tag
"element") (string :tag
" id"))
974 (list :tag
"Postamble" (const :format
"" postamble
)
975 (string :tag
" id") (string :tag
"element"))))
977 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
978 "Format used for timestamps in preamble, postamble and metadata.
979 See `format-time-string' for more information on its components."
980 :group
'org-export-html
982 :package-version
'(Org .
"8.0")
985 ;;;; Template :: Mathjax
987 (defcustom org-html-mathjax-options
988 '((path "http://orgmode.org/mathjax/MathJax.js")
993 "Options for MathJax setup.
995 path The path where to find MathJax
996 scale Scaling for the HTML-CSS backend, usually between 100 and 133
997 align How to align display math: left, center, or right
998 indent If align is not center, how far from the left/right side?
999 mathml Should a MathML player be used if available?
1000 This is faster and reduces bandwidth use, but currently
1001 sometimes has lower spacing quality. Therefore, the default is
1002 nil. When browsers get better, this switch can be flipped.
1004 You can also customize this for each buffer, using something like
1006 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
1007 :group
'org-export-html
1008 :type
'(list :greedy t
1009 (list :tag
"path (the path from where to load MathJax.js)"
1010 (const :format
" " path
) (string))
1011 (list :tag
"scale (scaling for the displayed math)"
1012 (const :format
" " scale
) (string))
1013 (list :tag
"align (alignment of displayed equations)"
1014 (const :format
" " align
) (string))
1015 (list :tag
"indent (indentation with left or right alignment)"
1016 (const :format
" " indent
) (string))
1017 (list :tag
"mathml (should MathML display be used is possible)"
1018 (const :format
" " mathml
) (boolean))))
1020 (defcustom org-html-mathjax-template
1021 "<script type=\"text/javascript\" src=\"%PATH\"></script>
1022 <script type=\"text/javascript\">
1023 <!--/*--><![CDATA[/*><!--*/
1024 MathJax.Hub.Config({
1025 // Only one of the two following lines, depending on user settings
1026 // First allows browser-native MathML display, second forces HTML/CSS
1027 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
1028 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
1029 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
1030 \"TeX/noUndefined.js\"],
1032 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
1033 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
1034 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
1035 ignoreClass: \"tex2jax_ignore\",
1036 processEscapes: false,
1037 processEnvironments: true,
1040 showProcessingMessages: true,
1041 displayAlign: \"%ALIGN\",
1042 displayIndent: \"%INDENT\",
1046 availableFonts: [\"STIX\",\"TeX\"],
1047 preferredFont: \"TeX\",
1063 "The MathJax setup for XHTML files."
1064 :group
'org-export-html
1067 ;;;; Template :: Postamble
1069 (defcustom org-html-postamble
'auto
1070 "Non-nil means insert a postamble in HTML export.
1072 When set to 'auto, check against the
1073 `org-export-with-author/email/creator/date' variables to set the
1074 content of the postamble. When set to a string, use this string
1075 as the postamble. When t, insert a string as defined by the
1076 formatting string in `org-html-postamble-format'.
1078 When set to a function, apply this function and insert the
1079 returned string. The function takes the property list of export
1080 options as its only argument.
1082 Setting :html-postamble in publishing projects will take
1083 precedence over this variable."
1084 :group
'org-export-html
1085 :type
'(choice (const :tag
"No postamble" nil
)
1086 (const :tag
"Auto postamble" auto
)
1087 (const :tag
"Default formatting string" t
)
1088 (string :tag
"Custom formatting string")
1089 (function :tag
"Function (must return a string)")))
1091 (defcustom org-html-postamble-format
1092 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1093 <p class=\"date\">Date: %d</p>
1094 <p class=\"creator\">%c</p>
1095 <p class=\"validation\">%v</p>"))
1096 "Alist of languages and format strings for the HTML postamble.
1098 The first element of each list is the language code, as used for
1099 the LANGUAGE keyword. See `org-export-default-language'.
1101 The second element of each list is a format string to format the
1102 postamble itself. This format string can contain these elements:
1104 %t stands for the title.
1105 %a stands for the author's name.
1106 %e stands for the author's email.
1107 %d stands for the date.
1108 %c will be replaced by `org-html-creator-string'.
1109 %v will be replaced by `org-html-validation-link'.
1110 %T will be replaced by the export time.
1111 %C will be replaced by the last modification time.
1113 If you need to use a \"%\" character, you need to escape it
1115 :group
'org-export-html
1117 (list (string :tag
"Language")
1118 (string :tag
"Format string"))))
1120 (defcustom org-html-validation-link
1121 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1122 "Link to HTML validation service."
1123 :group
'org-export-html
1126 (defcustom org-html-creator-string
1127 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1129 (if (fboundp 'org-version
) (org-version) "unknown version"))
1130 "Information about the creator of the HTML document.
1131 This option can also be set on with the CREATOR keyword."
1132 :group
'org-export-html
1134 :package-version
'(Org .
"8.0")
1135 :type
'(string :tag
"Creator string"))
1137 ;;;; Template :: Preamble
1139 (defcustom org-html-preamble t
1140 "Non-nil means insert a preamble in HTML export.
1142 When t, insert a string as defined by the formatting string in
1143 `org-html-preamble-format'. When set to a string, use this
1144 formatting string instead (see `org-html-postamble-format' for an
1145 example of such a formatting string).
1147 When set to a function, apply this function and insert the
1148 returned string. The function takes the property list of export
1149 options as its only argument.
1151 Setting :html-preamble in publishing projects will take
1152 precedence over this variable."
1153 :group
'org-export-html
1154 :type
'(choice (const :tag
"No preamble" nil
)
1155 (const :tag
"Default preamble" t
)
1156 (string :tag
"Custom formatting string")
1157 (function :tag
"Function (must return a string)")))
1159 (defcustom org-html-preamble-format
'(("en" ""))
1160 "Alist of languages and format strings for the HTML preamble.
1162 The first element of each list is the language code, as used for
1163 the LANGUAGE keyword. See `org-export-default-language'.
1165 The second element of each list is a format string to format the
1166 preamble itself. This format string can contain these elements:
1168 %t stands for the title.
1169 %a stands for the author's name.
1170 %e stands for the author's email.
1171 %d stands for the date.
1172 %c will be replaced by `org-html-creator-string'.
1173 %v will be replaced by `org-html-validation-link'.
1174 %T will be replaced by the export time.
1175 %C will be replaced by the last modification time.
1177 If you need to use a \"%\" character, you need to escape it
1180 See the default value of `org-html-postamble-format' for an
1182 :group
'org-export-html
1184 (list (string :tag
"Language")
1185 (string :tag
"Format string"))))
1187 (defcustom org-html-link-up
""
1188 "Where should the \"UP\" link of exported HTML pages lead?"
1189 :group
'org-export-html
1190 :type
'(string :tag
"File or URL"))
1192 (defcustom org-html-link-home
""
1193 "Where should the \"HOME\" link of exported HTML pages lead?"
1194 :group
'org-export-html
1195 :type
'(string :tag
"File or URL"))
1197 (defcustom org-html-link-use-abs-url nil
1198 "Should we prepend relative links with HTML_LINK_HOME?"
1199 :group
'org-export-html
1201 :package-version
'(Org .
"8.1")
1204 (defcustom org-html-home
/up-format
1205 "<div id=\"org-div-home-and-up\">
1206 <a accesskey=\"h\" href=\"%s\"> UP </a>
1208 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1210 "Snippet used to insert the HOME and UP links.
1211 This is a format string, the first %s will receive the UP link,
1212 the second the HOME link. If both `org-html-link-up' and
1213 `org-html-link-home' are empty, the entire snippet will be
1215 :group
'org-export-html
1218 ;;;; Template :: Scripts
1220 (define-obsolete-variable-alias
1221 'org-html-style-include-scripts
'org-html-head-include-scripts
"24.4")
1222 (defcustom org-html-head-include-scripts t
1223 "Non-nil means include the JavaScript snippets in exported HTML files.
1224 The actual script is defined in `org-html-scripts' and should
1226 :group
'org-export-html
1228 :package-version
'(Org .
"8.0")
1231 ;;;; Template :: Styles
1233 (define-obsolete-variable-alias
1234 'org-html-style-include-default
'org-html-head-include-default-style
"24.4")
1235 (defcustom org-html-head-include-default-style t
1236 "Non-nil means include the default style in exported HTML files.
1237 The actual style is defined in `org-html-style-default' and
1238 should not be modified. Use `org-html-head' to use your own
1240 :group
'org-export-html
1242 :package-version
'(Org .
"8.0")
1245 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1247 (define-obsolete-variable-alias 'org-html-style
'org-html-head
"24.4")
1248 (defcustom org-html-head
""
1249 "Org-wide head definitions for exported HTML files.
1251 This variable can contain the full HTML structure to provide a
1252 style, including the surrounding HTML tags. You can consider
1253 including definitions for the following classes: title, todo,
1254 done, timestamp, timestamp-kwd, tag, target.
1256 For example, a valid value would be:
1258 <style type=\"text/css\">
1260 p { font-weight: normal; color: gray; }
1261 h1 { color: black; }
1262 .title { text-align: center; }
1263 .todo, .timestamp-kwd { color: red; }
1264 .done { color: green; }
1268 If you want to refer to an external style, use something like
1270 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1272 As the value of this option simply gets inserted into the HTML
1273 <head> header, you can use it to add any arbitrary text to the
1276 You can set this on a per-file basis using #+HTML_HEAD:,
1277 or for publication projects using the :html-head property."
1278 :group
'org-export-html
1280 :package-version
'(Org .
"8.0")
1283 (put 'org-html-head
'safe-local-variable
'stringp
)
1285 (defcustom org-html-head-extra
""
1286 "More head information to add in the HTML output.
1288 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1289 or for publication projects using the :html-head-extra property."
1290 :group
'org-export-html
1292 :package-version
'(Org .
"8.0")
1295 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1299 (defcustom org-html-todo-kwd-class-prefix
""
1300 "Prefix to class names for TODO keywords.
1301 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1302 The default prefix is empty because it is nice to just use the keyword
1303 as a class name. But if you get into conflicts with other, existing
1304 CSS classes, then this prefix can be very useful."
1305 :group
'org-export-html
1309 ;;; Internal Functions
1311 (defun org-html-xhtml-p (info)
1312 (let ((dt (downcase (plist-get info
:html-doctype
))))
1313 (string-match-p "xhtml" dt
)))
1315 (defun org-html-html5-p (info)
1316 (let ((dt (downcase (plist-get info
:html-doctype
))))
1317 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1319 (defun org-html-close-tag (tag attr info
)
1320 (concat "<" tag
" " attr
1321 (if (org-html-xhtml-p info
) " />" ">")))
1323 (defun org-html-doctype (info)
1324 "Return correct html doctype tag from `org-html-doctype-alist',
1325 or the literal value of :html-doctype from INFO if :html-doctype
1326 is not found in the alist.
1327 INFO is a plist used as a communication channel."
1328 (let ((dt (plist-get info
:html-doctype
)))
1329 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1331 (defun org-html--make-attribute-string (attributes)
1332 "Return a list of attributes, as a string.
1333 ATTRIBUTES is a plist where values are either strings or nil. An
1334 attributes with a nil value will be omitted from the result."
1336 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1337 (cond ((null item
) (pop output
))
1338 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1339 (t (let ((key (car output
))
1340 (value (replace-regexp-in-string
1341 "\"" """ (org-html-encode-plain-text item
))))
1342 (setcar output
(format "%s=\"%s\"" key value
))))))))
1344 (defun org-html--wrap-image (contents info
&optional caption label
)
1345 "Wrap CONTENTS string within an appropriate environment for images.
1346 INFO is a plist used as a communication channel. When optional
1347 arguments CAPTION and LABEL are given, use them for caption and
1349 (let ((html5-fancy (and (org-html-html5-p info
)
1350 (plist-get info
:html-html5-fancy
))))
1351 (format (if html5-fancy
"\n<figure%s>%s%s\n</figure>"
1352 "\n<div%s class=\"figure\">%s%s\n</div>")
1354 (if (not (org-string-nw-p label
)) ""
1355 (format " id=\"%s\"" (org-export-solidify-link-text label
)))
1357 (format "\n<p>%s</p>" contents
)
1359 (if (not (org-string-nw-p caption
)) ""
1360 (format (if html5-fancy
"\n<figcaption>%s</figcaption>"
1364 (defun org-html--format-image (source attributes info
)
1365 "Return \"img\" tag with given SOURCE and ATTRIBUTES.
1366 SOURCE is a string specifying the location of the image.
1367 ATTRIBUTES is a plist, as returned by
1368 `org-export-read-attribute'. INFO is a plist used as
1369 a communication channel."
1372 (org-html--make-attribute-string
1375 :alt
(if (string-match-p "^ltxpng/" source
)
1376 (org-html-encode-plain-text
1377 (org-find-text-property-in-string 'org-latex-src source
))
1378 (file-name-nondirectory source
)))
1382 (defun org-html--textarea-block (element)
1383 "Transcode ELEMENT into a textarea block.
1384 ELEMENT is either a src block or an example block."
1385 (let* ((code (car (org-export-unravel-code element
)))
1386 (attr (org-export-read-attribute :attr_html element
)))
1387 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1388 (or (plist-get attr
:width
) 80)
1389 (or (plist-get attr
:height
) (org-count-lines code
))
1392 (defun org-html--has-caption-p (element &optional info
)
1393 "Non-nil when ELEMENT has a caption affiliated keyword.
1394 INFO is a plist used as a communication channel. This function
1395 is meant to be used as a predicate for `org-export-get-ordinal' or
1396 a value to `org-html-standalone-image-predicate'."
1397 (org-element-property :caption element
))
1401 (defun org-html-htmlize-region-for-paste (beg end
)
1402 "Convert the region between BEG and END to HTML, using htmlize.el.
1403 This is much like `htmlize-region-for-paste', only that it uses
1404 the settings define in the org-... variables."
1405 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1406 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1407 (htmlbuf (htmlize-region beg end
)))
1409 (with-current-buffer htmlbuf
1410 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1411 (plist-get htmlize-buffer-places
'content-end
)))
1412 (kill-buffer htmlbuf
))))
1415 (defun org-html-htmlize-generate-css ()
1416 "Create the CSS for all font definitions in the current Emacs session.
1417 Use this to create face definitions in your CSS style file that can then
1418 be used by code snippets transformed by htmlize.
1419 This command just produces a buffer that contains class definitions for all
1420 faces used in the current Emacs session. You can copy and paste the ones you
1421 need into your CSS file.
1423 If you then set `org-html-htmlize-output-type' to `css', calls
1424 to the function `org-html-htmlize-region-for-paste' will
1425 produce code that uses these same face definitions."
1428 (and (get-buffer "*html*") (kill-buffer "*html*"))
1430 (let ((fl (face-list))
1431 (htmlize-css-name-prefix "org-")
1432 (htmlize-output-type 'css
)
1434 (while (setq f
(pop fl
)
1435 i
(and f
(face-attribute f
:inherit
)))
1436 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1437 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1438 (htmlize-region (point-min) (point-max))))
1439 (org-pop-to-buffer-same-window "*html*")
1440 (goto-char (point-min))
1441 (if (re-search-forward "<style" nil t
)
1442 (delete-region (point-min) (match-beginning 0)))
1443 (if (re-search-forward "</style>" nil t
)
1444 (delete-region (1+ (match-end 0)) (point-max)))
1445 (beginning-of-line 1)
1446 (if (looking-at " +") (replace-match ""))
1447 (goto-char (point-min)))
1449 (defun org-html--make-string (n string
)
1450 "Build a string by concatenating N times STRING."
1451 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1453 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1454 "Turn todo keyword KWD into a valid class name.
1455 Replaces invalid characters with \"_\"."
1457 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1458 (setq kwd
(replace-match "_" t t kwd
))))
1461 (defun org-html-format-footnote-reference (n def refcnt
)
1462 "Format footnote reference N with definition DEF into HTML."
1463 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1464 (format org-html-footnote-format
1465 (let* ((id (format "fnr.%s%s" n extra
))
1466 (href (format " href=\"#fn.%s\"" n
))
1467 (attributes (concat " class=\"footref\"" href
)))
1468 (org-html--anchor id n attributes
)))))
1470 (defun org-html-format-footnotes-section (section-name definitions
)
1471 "Format footnotes section SECTION-NAME."
1472 (if (not definitions
) ""
1473 (format org-html-footnotes-section section-name definitions
)))
1475 (defun org-html-format-footnote-definition (fn)
1476 "Format the footnote definition FN."
1477 (let ((n (car fn
)) (def (cdr fn
)))
1479 "<div class=\"footdef\">%s %s</div>\n"
1480 (format org-html-footnote-format
1481 (let* ((id (format "fn.%s" n
))
1482 (href (format " href=\"#fnr.%s\"" n
))
1483 (attributes (concat " class=\"footnum\"" href
)))
1484 (org-html--anchor id n attributes
)))
1487 (defun org-html-footnote-section (info)
1488 "Format the footnote section.
1489 INFO is a plist used as a communication channel."
1490 (let* ((fn-alist (org-export-collect-footnote-definitions
1491 (plist-get info
:parse-tree
) info
))
1493 (loop for
(n type raw
) in fn-alist collect
1494 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1495 (org-trim (org-export-data raw info
))
1497 (org-trim (org-export-data raw info
))))))))
1499 (org-html-format-footnotes-section
1500 (org-html--translate "Footnotes" info
)
1503 (mapconcat 'org-html-format-footnote-definition fn-alist
"\n"))))))
1508 (defun org-html--build-meta-info (info)
1509 "Return meta tags for exported document.
1510 INFO is a plist used as a communication channel."
1511 (let ((protect-string
1513 (replace-regexp-in-string
1514 "\"" """ (org-html-encode-plain-text str
))))
1515 (title (org-export-data (plist-get info
:title
) info
))
1516 (author (and (plist-get info
:with-author
)
1517 (let ((auth (plist-get info
:author
)))
1519 ;; Return raw Org syntax, skipping non
1520 ;; exportable objects.
1521 (org-element-interpret-data
1522 (org-element-map auth
1523 (cons 'plain-text org-element-all-objects
)
1524 'identity info
))))))
1525 (description (plist-get info
:description
))
1526 (keywords (plist-get info
:keywords
))
1527 (charset (or (and org-html-coding-system
1528 (fboundp 'coding-system-get
)
1529 (coding-system-get org-html-coding-system
1533 (format "<title>%s</title>\n" title
)
1534 (when (plist-get info
:time-stamp-file
)
1536 (concat "<!-- " org-html-metadata-timestamp-format
" -->\n")))
1538 (if (org-html-html5-p info
)
1539 (org-html-close-tag "meta" " charset=\"%s\"" info
)
1541 "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1544 (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info
)
1546 (and (org-string-nw-p author
)
1548 (org-html-close-tag "meta"
1549 (format " name=\"author\" content=\"%s\""
1550 (funcall protect-string author
))
1553 (and (org-string-nw-p description
)
1555 (org-html-close-tag "meta"
1556 (format " name=\"description\" content=\"%s\"\n"
1557 (funcall protect-string description
))
1560 (and (org-string-nw-p keywords
)
1562 (org-html-close-tag "meta"
1563 (format " name=\"keywords\" content=\"%s\""
1564 (funcall protect-string keywords
))
1568 (defun org-html--build-head (info)
1569 "Return information for the <head>..</head> of the HTML output.
1570 INFO is a plist used as a communication channel."
1571 (org-element-normalize-string
1573 (when (plist-get info
:html-head-include-default-style
)
1574 (org-element-normalize-string org-html-style-default
))
1575 (org-element-normalize-string (plist-get info
:html-head
))
1576 (org-element-normalize-string (plist-get info
:html-head-extra
))
1577 (when (and (plist-get info
:html-htmlized-css-url
)
1578 (eq org-html-htmlize-output-type
'css
))
1579 (org-html-close-tag "link"
1580 (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1581 (plist-get info
:html-htmlized-css-url
))
1583 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1585 (defun org-html--build-mathjax-config (info)
1586 "Insert the user setup into the mathjax template.
1587 INFO is a plist used as a communication channel."
1588 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1589 (org-element-map (plist-get info
:parse-tree
)
1590 '(latex-fragment latex-environment
) 'identity info t
))
1591 (let ((template org-html-mathjax-template
)
1592 (options org-html-mathjax-options
)
1593 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1594 name val
(yes " ") (no "// ") x
)
1597 (setq name
(car e
) val
(nth 1 e
))
1598 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1599 (setq val
(car (read-from-string
1600 (substring in-buffer
(match-end 0))))))
1601 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1602 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1603 (setq template
(replace-match val t t template
))))
1605 (setq val
(nth 1 (assq 'mathml options
)))
1606 (if (string-match (concat "\\<mathml:") in-buffer
)
1607 (setq val
(car (read-from-string
1608 (substring in-buffer
(match-end 0))))))
1609 ;; Exchange prefixes depending on mathml setting.
1610 (if (not val
) (setq x yes yes no no x
))
1611 ;; Replace cookies to turn on or off the config/jax lines.
1612 (if (string-match ":MMLYES:" template
)
1613 (setq template
(replace-match yes t t template
)))
1614 (if (string-match ":MMLNO:" template
)
1615 (setq template
(replace-match no t t template
)))
1616 ;; Return the modified template.
1617 (org-element-normalize-string template
))))
1619 (defun org-html-format-spec (info)
1620 "Return format specification for elements that can be
1621 used in the preamble or postamble."
1622 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1623 (?d .
,(org-export-data (org-export-get-date info
) info
))
1624 (?T .
,(format-time-string org-html-metadata-timestamp-format
))
1625 (?a .
,(org-export-data (plist-get info
:author
) info
))
1628 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1629 (split-string (plist-get info
:email
) ",+ *")
1631 (?c .
,(plist-get info
:creator
))
1632 (?C .
,(let ((file (plist-get info
:input-file
)))
1633 (format-time-string org-html-metadata-timestamp-format
1634 (if file
(nth 5 (file-attributes file
))
1636 (?v .
,(or org-html-validation-link
""))))
1638 (defun org-html--build-pre/postamble
(type info
)
1639 "Return document preamble or postamble as a string, or nil.
1640 TYPE is either 'preamble or 'postamble, INFO is a plist used as a
1641 communication channel."
1642 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1643 (spec (org-html-format-spec info
)))
1645 (let ((section-contents
1646 (if (functionp section
) (funcall section info
)
1648 ((stringp section
) (format-spec section spec
))
1650 (let ((date (cdr (assq ?d spec
)))
1651 (author (cdr (assq ?a spec
)))
1652 (email (cdr (assq ?e spec
)))
1653 (creator (cdr (assq ?c spec
)))
1654 (timestamp (cdr (assq ?T spec
)))
1655 (validation-link (cdr (assq ?v spec
))))
1657 (when (and (plist-get info
:with-date
)
1658 (org-string-nw-p date
))
1659 (format "<p class=\"date\">%s: %s</p>\n"
1660 (org-html--translate "Date" info
)
1662 (when (and (plist-get info
:with-author
)
1663 (org-string-nw-p author
))
1664 (format "<p class=\"author\">%s: %s</p>\n"
1665 (org-html--translate "Author" info
)
1667 (when (and (plist-get info
:with-email
)
1668 (org-string-nw-p email
))
1669 (format "<p class=\"email\">%s: %s</p>\n"
1670 (org-html--translate "Email" info
)
1672 (when (plist-get info
:time-stamp-file
)
1674 "<p class=\"date\">%s: %s</p>\n"
1675 (org-html--translate "Created" info
)
1676 (format-time-string org-html-metadata-timestamp-format
)))
1677 (when (plist-get info
:with-creator
)
1678 (format "<p class=\"creator\">%s</p>\n" creator
))
1679 (format "<p class=\"validation\">%s</p>\n"
1683 (plist-get info
:language
)
1685 (format "org-html-%s-format" type
)))))
1690 (intern (format "org-html-%s-format" type
))))))
1692 (when (org-string-nw-p section-contents
)
1694 (format "<%s id=\"%s\" class=\"%s\">\n"
1695 (nth 1 (assq type org-html-divs
))
1696 (nth 2 (assq type org-html-divs
))
1697 org-html--pre
/postamble-class
)
1698 (org-element-normalize-string section-contents
)
1699 (format "</%s>\n" (nth 1 (assq type org-html-divs
)))))))))
1701 (defun org-html-inner-template (contents info
)
1702 "Return body of document string after HTML conversion.
1703 CONTENTS is the transcoded contents string. INFO is a plist
1704 holding export options."
1706 ;; Table of contents.
1707 (let ((depth (plist-get info
:with-toc
)))
1708 (when depth
(org-html-toc depth info
)))
1709 ;; Document contents.
1711 ;; Footnotes section.
1712 (org-html-footnote-section info
)))
1714 (defun org-html-template (contents info
)
1715 "Return complete document string after HTML conversion.
1716 CONTENTS is the transcoded contents string. INFO is a plist
1717 holding export options."
1719 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1720 (let ((decl (or (and (stringp org-html-xml-declaration
)
1721 org-html-xml-declaration
)
1722 (cdr (assoc (plist-get info
:html-extension
)
1723 org-html-xml-declaration
))
1724 (cdr (assoc "html" org-html-xml-declaration
))
1727 (when (not (or (eq nil decl
) (string= "" decl
)))
1730 (or (and org-html-coding-system
1731 (fboundp 'coding-system-get
)
1732 (coding-system-get org-html-coding-system
'mime-charset
))
1734 (org-html-doctype info
)
1737 (when (org-html-xhtml-p info
)
1739 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1740 (plist-get info
:language
) (plist-get info
:language
)))
1743 (org-html--build-meta-info info
)
1744 (org-html--build-head info
)
1745 (org-html--build-mathjax-config info
)
1748 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1749 (link-home (org-trim (plist-get info
:html-link-home
))))
1750 (unless (and (string= link-up
"") (string= link-home
""))
1751 (format org-html-home
/up-format
1752 (or link-up link-home
)
1753 (or link-home link-up
))))
1755 (org-html--build-pre/postamble
'preamble info
)
1756 ;; Document contents.
1757 (format "<%s id=\"%s\">\n"
1758 (nth 1 (assq 'content org-html-divs
))
1759 (nth 2 (assq 'content org-html-divs
)))
1761 (let ((title (plist-get info
:title
)))
1762 (format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title
"") info
)))
1765 (nth 1 (assq 'content org-html-divs
)))
1767 (org-html--build-pre/postamble
'postamble info
)
1768 ;; Closing document.
1769 "</body>\n</html>"))
1771 (defun org-html--translate (s info
)
1772 "Translate string S according to specified language.
1773 INFO is a plist used as a communication channel."
1774 (org-export-translate s
:html info
))
1778 (defun org-html--anchor (&optional id desc attributes
)
1779 "Format a HTML anchor."
1780 (let* ((name (and org-html-allow-name-attribute-in-anchors id
))
1781 (attributes (concat (and id
(format " id=\"%s\"" id
))
1782 (and name
(format " name=\"%s\"" name
))
1784 (format "<a%s>%s</a>" attributes
(or desc
""))))
1788 (defun org-html--todo (todo)
1789 "Format TODO keywords into HTML."
1791 (format "<span class=\"%s %s%s\">%s</span>"
1792 (if (member todo org-done-keywords
) "done" "todo")
1793 org-html-todo-kwd-class-prefix
(org-html-fix-class-name todo
)
1798 (defun org-html--tags (tags)
1799 "Format TAGS into HTML."
1801 (format "<span class=\"tag\">%s</span>"
1804 (format "<span class=\"%s\">%s</span>"
1805 (concat org-html-tag-class-prefix
1806 (org-html-fix-class-name tag
))
1812 (defun* org-html-format-headline
1813 (todo todo-type priority text tags
1814 &key level section-number headline-label
&allow-other-keys
)
1815 "Format a headline in HTML."
1816 (let ((section-number
1817 (when section-number
1818 (format "<span class=\"section-number-%d\">%s</span> "
1819 level section-number
)))
1820 (todo (org-html--todo todo
))
1821 (tags (org-html--tags tags
)))
1822 (concat section-number todo
(and todo
" ") text
1823 (and tags
"   ") tags
)))
1827 (defun org-html-fontify-code (code lang
)
1828 "Color CODE with htmlize library.
1829 CODE is a string representing the source code to colorize. LANG
1830 is the language used for CODE, as a string, or nil."
1833 ;; Case 1: No lang. Possibly an example block.
1835 ;; Simple transcoding.
1836 (org-html-encode-plain-text code
))
1837 ;; Case 2: No htmlize or an inferior version of htmlize
1838 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1840 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1841 ;; Simple transcoding.
1842 (org-html-encode-plain-text code
))
1845 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1846 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1848 ;; Case 1: Language is not associated with any Emacs mode
1849 ((not (functionp lang-mode
))
1850 ;; Simple transcoding.
1851 (org-html-encode-plain-text code
))
1852 ;; Case 2: Default. Fontify code.
1855 (setq code
(with-temp-buffer
1856 ;; Switch to language-specific mode.
1860 (font-lock-fontify-buffer)
1861 ;; Remove formatting on newline characters.
1863 (let ((beg (point-min))
1866 (while (progn (end-of-line) (< (point) end
))
1867 (put-text-property (point) (1+ (point)) 'face nil
)
1870 (set-buffer-modified-p nil
)
1872 (org-html-htmlize-region-for-paste
1873 (point-min) (point-max))))
1874 ;; Strip any enclosing <pre></pre> tags.
1875 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
1876 (end (and beg
(string-match "</pre>\\'" code
))))
1877 (if (and beg end
) (substring code beg end
) code
)))))))))
1879 (defun org-html-do-format-code
1880 (code &optional lang refs retain-labels num-start
)
1881 "Format CODE string as source code.
1882 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1883 respectively, the language of the source code, as a string, an
1884 alist between line numbers and references (as returned by
1885 `org-export-unravel-code'), a boolean specifying if labels should
1886 appear in the source code, and the number associated to the first
1888 (let* ((code-lines (org-split-string code
"\n"))
1889 (code-length (length code-lines
))
1893 (length (number-to-string (+ code-length num-start
))))))
1894 (code (org-html-fontify-code code lang
)))
1895 (org-export-format-code
1897 (lambda (loc line-num ref
)
1900 ;; Add line number, if needed.
1902 (format "<span class=\"linenr\">%s</span>"
1903 (format num-fmt line-num
)))
1904 ;; Transcoded src line.
1906 ;; Add label, if needed.
1907 (when (and ref retain-labels
) (format " (%s)" ref
))))
1908 ;; Mark transcoded line as an anchor, if needed.
1910 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1914 (defun org-html-format-code (element info
)
1915 "Format contents of ELEMENT as source code.
1916 ELEMENT is either an example block or a src block. INFO is
1917 a plist used as a communication channel."
1918 (let* ((lang (org-element-property :language element
))
1919 ;; Extract code and references.
1920 (code-info (org-export-unravel-code element
))
1921 (code (car code-info
))
1922 (refs (cdr code-info
))
1923 ;; Does the src block contain labels?
1924 (retain-labels (org-element-property :retain-labels element
))
1925 ;; Does it have line numbers?
1926 (num-start (case (org-element-property :number-lines element
)
1927 (continued (org-export-get-loc element info
))
1929 (org-html-do-format-code code lang refs retain-labels num-start
)))
1932 ;;; Tables of Contents
1934 (defun org-html-toc (depth info
)
1935 "Build a table of contents.
1936 DEPTH is an integer specifying the depth of the table. INFO is a
1937 plist used as a communication channel. Return the table of
1938 contents as a string, or nil if it is empty."
1940 (mapcar (lambda (headline)
1941 (cons (org-html--format-toc-headline headline info
)
1942 (org-export-get-relative-level headline info
)))
1943 (org-export-collect-headlines info depth
)))
1944 (outer-tag (if (and (org-html-html5-p info
)
1945 (plist-get info
:html-html5-fancy
))
1949 (concat (format "<%s id=\"table-of-contents\">\n" outer-tag
)
1950 (format "<h%d>%s</h%d>\n"
1951 org-html-toplevel-hlevel
1952 (org-html--translate "Table of Contents" info
)
1953 org-html-toplevel-hlevel
)
1954 "<div id=\"text-table-of-contents\">"
1955 (org-html--toc-text toc-entries
)
1957 (format "</%s>\n" outer-tag
)))))
1959 (defun org-html--toc-text (toc-entries)
1960 "Return innards of a table of contents, as a string.
1961 TOC-ENTRIES is an alist where key is an entry title, as a string,
1962 and value is its relative level, as an integer."
1963 (let* ((prev-level (1- (cdar toc-entries
)))
1964 (start-level prev-level
))
1968 (let ((headline (car entry
))
1969 (level (cdr entry
)))
1971 (let* ((cnt (- level prev-level
))
1972 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1974 (setq prev-level level
)
1976 (org-html--make-string
1977 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1978 ((< cnt
0) "</li>\n</ul>\n")))
1979 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1982 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
1984 (defun org-html--format-toc-headline (headline info
)
1985 "Return an appropriate table of contents entry for HEADLINE.
1986 INFO is a plist used as a communication channel."
1987 (let* ((headline-number (org-export-get-headline-number headline info
))
1988 (todo (and (plist-get info
:with-todo-keywords
)
1989 (let ((todo (org-element-property :todo-keyword headline
)))
1990 (and todo
(org-export-data todo info
)))))
1991 (todo-type (and todo
(org-element-property :todo-type headline
)))
1992 (priority (and (plist-get info
:with-priority
)
1993 (org-element-property :priority headline
)))
1994 (text (org-export-data-with-backend
1995 (org-export-get-alt-title headline info
)
1996 ;; Create an anonymous back-end that will ignore any
1997 ;; footnote-reference, link, radio-target and target
1998 ;; in table of contents.
1999 (org-export-create-backend
2001 :transcoders
'((footnote-reference . ignore
)
2002 (link .
(lambda (object c i
) c
))
2003 (radio-target .
(lambda (object c i
) c
))
2006 (tags (and (eq (plist-get info
:with-tags
) t
)
2007 (org-export-get-tags headline info
))))
2008 (format "<a href=\"#%s\">%s</a>"
2010 (org-export-solidify-link-text
2011 (or (org-element-property :CUSTOM_ID headline
)
2013 (mapconcat #'number-to-string headline-number
"-"))))
2016 (and (not (org-export-low-level-p headline info
))
2017 (org-export-numbered-headline-p headline info
)
2018 (concat (mapconcat #'number-to-string headline-number
".")
2020 (apply (if (not (eq org-html-format-headline-function
'ignore
))
2021 (lambda (todo todo-type priority text tags
&rest ignore
)
2022 (funcall org-html-format-headline-function
2023 todo todo-type priority text tags
))
2024 #'org-html-format-headline
)
2025 todo todo-type priority text tags
:section-number nil
)))))
2027 (defun org-html-list-of-listings (info)
2028 "Build a list of listings.
2029 INFO is a plist used as a communication channel. Return the list
2030 of listings as a string, or nil if it is empty."
2031 (let ((lol-entries (org-export-collect-listings info
)))
2033 (concat "<div id=\"list-of-listings\">\n"
2034 (format "<h%d>%s</h%d>\n"
2035 org-html-toplevel-hlevel
2036 (org-html--translate "List of Listings" info
)
2037 org-html-toplevel-hlevel
)
2038 "<div id=\"text-list-of-listings\">\n<ul>\n"
2040 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2041 (org-html--translate "Listing %d:" info
))))
2044 (let ((label (org-element-property :name entry
))
2047 (or (org-export-get-caption entry t
)
2048 (org-export-get-caption entry
))
2053 (concat (format initial-fmt
(incf count
)) " " title
)
2054 (format "<a href=\"#%s\">%s %s</a>"
2055 (org-export-solidify-link-text label
)
2056 (format initial-fmt
(incf count
))
2060 "\n</ul>\n</div>\n</div>"))))
2062 (defun org-html-list-of-tables (info)
2063 "Build a list of tables.
2064 INFO is a plist used as a communication channel. Return the list
2065 of tables as a string, or nil if it is empty."
2066 (let ((lol-entries (org-export-collect-tables info
)))
2068 (concat "<div id=\"list-of-tables\">\n"
2069 (format "<h%d>%s</h%d>\n"
2070 org-html-toplevel-hlevel
2071 (org-html--translate "List of Tables" info
)
2072 org-html-toplevel-hlevel
)
2073 "<div id=\"text-list-of-tables\">\n<ul>\n"
2075 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2076 (org-html--translate "Table %d:" info
))))
2079 (let ((label (org-element-property :name entry
))
2082 (or (org-export-get-caption entry t
)
2083 (org-export-get-caption entry
))
2088 (concat (format initial-fmt
(incf count
)) " " title
)
2089 (format "<a href=\"#%s\">%s %s</a>"
2090 (org-export-solidify-link-text label
)
2091 (format initial-fmt
(incf count
))
2095 "\n</ul>\n</div>\n</div>"))))
2098 ;;; Transcode Functions
2102 (defun org-html-bold (bold contents info
)
2103 "Transcode BOLD from Org to HTML.
2104 CONTENTS is the text with bold markup. INFO is a plist holding
2105 contextual information."
2106 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
2111 (defun org-html-center-block (center-block contents info
)
2112 "Transcode a CENTER-BLOCK element from Org to HTML.
2113 CONTENTS holds the contents of the block. INFO is a plist
2114 holding contextual information."
2115 (format "<div class=\"center\">\n%s</div>" contents
))
2119 (defun org-html-clock (clock contents info
)
2120 "Transcode a CLOCK element from Org to HTML.
2121 CONTENTS is nil. INFO is a plist used as a communication
2124 <span class=\"timestamp-wrapper\">
2125 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2130 (org-element-property :raw-value
2131 (org-element-property :value clock
)))
2132 (let ((time (org-element-property :duration clock
)))
2133 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2137 (defun org-html-code (code contents info
)
2138 "Transcode CODE from Org to HTML.
2139 CONTENTS is nil. INFO is a plist holding contextual
2141 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
2142 (org-html-encode-plain-text (org-element-property :value code
))))
2146 (defun org-html-drawer (drawer contents info
)
2147 "Transcode a DRAWER element from Org to HTML.
2148 CONTENTS holds the contents of the block. INFO is a plist
2149 holding contextual information."
2150 (if (functionp org-html-format-drawer-function
)
2151 (funcall org-html-format-drawer-function
2152 (org-element-property :drawer-name drawer
)
2154 ;; If there's no user defined function: simply
2155 ;; display contents of the drawer.
2160 (defun org-html-dynamic-block (dynamic-block contents info
)
2161 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2162 CONTENTS holds the contents of the block. INFO is a plist
2163 holding contextual information. See `org-export-data'."
2168 (defun org-html-entity (entity contents info
)
2169 "Transcode an ENTITY object from Org to HTML.
2170 CONTENTS are the definition itself. INFO is a plist holding
2171 contextual information."
2172 (org-element-property :html entity
))
2176 (defun org-html-example-block (example-block contents info
)
2177 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2178 CONTENTS is nil. INFO is a plist holding contextual
2180 (if (org-export-read-attribute :attr_html example-block
:textarea
)
2181 (org-html--textarea-block example-block
)
2182 (format "<pre class=\"example\">\n%s</pre>"
2183 (org-html-format-code example-block info
))))
2187 (defun org-html-export-snippet (export-snippet contents info
)
2188 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2189 CONTENTS is nil. INFO is a plist holding contextual
2191 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2192 (org-element-property :value export-snippet
)))
2196 (defun org-html-export-block (export-block contents info
)
2197 "Transcode a EXPORT-BLOCK element from Org to HTML.
2198 CONTENTS is nil. INFO is a plist holding contextual information."
2199 (when (string= (org-element-property :type export-block
) "HTML")
2200 (org-remove-indentation (org-element-property :value export-block
))))
2204 (defun org-html-fixed-width (fixed-width contents info
)
2205 "Transcode a FIXED-WIDTH element from Org to HTML.
2206 CONTENTS is nil. INFO is a plist holding contextual information."
2207 (format "<pre class=\"example\">\n%s</pre>"
2208 (org-html-do-format-code
2209 (org-remove-indentation
2210 (org-element-property :value fixed-width
)))))
2212 ;;;; Footnote Reference
2214 (defun org-html-footnote-reference (footnote-reference contents info
)
2215 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2216 CONTENTS is nil. INFO is a plist holding contextual information."
2218 ;; Insert separator between two footnotes in a row.
2219 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2220 (when (eq (org-element-type prev
) 'footnote-reference
)
2221 org-html-footnote-separator
))
2223 ((not (org-export-footnote-first-reference-p footnote-reference info
))
2224 (org-html-format-footnote-reference
2225 (org-export-get-footnote-number footnote-reference info
)
2227 ;; Inline definitions are secondary strings.
2228 ((eq (org-element-property :type footnote-reference
) 'inline
)
2229 (org-html-format-footnote-reference
2230 (org-export-get-footnote-number footnote-reference info
)
2232 ;; Non-inline footnotes definitions are full Org data.
2233 (t (org-html-format-footnote-reference
2234 (org-export-get-footnote-number footnote-reference info
)
2239 (defun org-html-format-headline--wrap
2240 (headline info
&optional format-function
&rest extra-keys
)
2241 "Transcode a HEADLINE element from Org to HTML.
2242 CONTENTS holds the contents of the headline. INFO is a plist
2243 holding contextual information."
2244 (let* ((level (+ (org-export-get-relative-level headline info
)
2245 (1- org-html-toplevel-hlevel
)))
2246 (headline-number (org-export-get-headline-number headline info
))
2247 (section-number (and (not (org-export-low-level-p headline info
))
2248 (org-export-numbered-headline-p headline info
)
2249 (mapconcat 'number-to-string
2250 headline-number
".")))
2251 (todo (and (plist-get info
:with-todo-keywords
)
2252 (let ((todo (org-element-property :todo-keyword headline
)))
2253 (and todo
(org-export-data todo info
)))))
2254 (todo-type (and todo
(org-element-property :todo-type headline
)))
2255 (priority (and (plist-get info
:with-priority
)
2256 (org-element-property :priority headline
)))
2257 (text (org-export-data (org-element-property :title headline
) info
))
2258 (tags (and (plist-get info
:with-tags
)
2259 (org-export-get-tags headline info
)))
2260 (headline-label (or (org-element-property :CUSTOM_ID headline
)
2261 (concat "sec-" (mapconcat 'number-to-string
2262 headline-number
"-"))))
2264 (cond ((functionp format-function
) format-function
)
2265 ((not (eq org-html-format-headline-function
'ignore
))
2266 (lambda (todo todo-type priority text tags
&rest ignore
)
2267 (funcall org-html-format-headline-function
2268 todo todo-type priority text tags
)))
2269 (t 'org-html-format-headline
))))
2270 (apply format-function
2271 todo todo-type priority text tags
2272 :headline-label headline-label
:level level
2273 :section-number section-number extra-keys
)))
2275 (defun org-html-headline (headline contents info
)
2276 "Transcode a HEADLINE element from Org to HTML.
2277 CONTENTS holds the contents of the headline. INFO is a plist
2278 holding contextual information."
2280 (setq contents
(or contents
""))
2281 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2282 (level (org-export-get-relative-level headline info
))
2283 (text (org-export-data (org-element-property :title headline
) info
))
2284 (todo (and (plist-get info
:with-todo-keywords
)
2285 (let ((todo (org-element-property :todo-keyword headline
)))
2286 (and todo
(org-export-data todo info
)))))
2287 (todo-type (and todo
(org-element-property :todo-type headline
)))
2288 (tags (and (plist-get info
:with-tags
)
2289 (org-export-get-tags headline info
)))
2290 (priority (and (plist-get info
:with-priority
)
2291 (org-element-property :priority headline
)))
2292 (section-number (and (org-export-numbered-headline-p headline info
)
2293 (mapconcat 'number-to-string
2294 (org-export-get-headline-number
2295 headline info
) ".")))
2296 ;; Create the headline text.
2297 (full-text (org-html-format-headline--wrap headline info
)))
2299 ;; Case 1: This is a footnote section: ignore it.
2300 ((org-element-property :footnote-section-p headline
) nil
)
2301 ;; Case 2. This is a deep sub-tree: export it as a list item.
2302 ;; Also export as items headlines for which no section
2303 ;; format has been found.
2304 ((org-export-low-level-p headline info
)
2305 ;; Build the real contents of the sub-tree.
2306 (let* ((type (if numberedp
'ordered
'unordered
))
2307 (itemized-body (org-html-format-list-item
2308 contents type nil info nil full-text
)))
2310 (and (org-export-first-sibling-p headline info
)
2311 (org-html-begin-plain-list type
))
2313 (and (org-export-last-sibling-p headline info
)
2314 (org-html-end-plain-list type
)))))
2315 ;; Case 3. Standard headline. Export it as a section.
2317 (let* ((section-number (mapconcat 'number-to-string
2318 (org-export-get-headline-number
2319 headline info
) "-"))
2321 (list (org-element-property :CUSTOM_ID headline
)
2322 (concat "sec-" section-number
)
2323 (org-element-property :ID headline
))))
2324 (preferred-id (car ids
))
2325 (extra-ids (cdr ids
))
2326 (extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2327 (level1 (+ level
(1- org-html-toplevel-hlevel
)))
2328 (first-content (car (org-element-contents headline
))))
2329 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2330 (org-html--container headline info
)
2331 (format "outline-container-%s"
2332 (or (org-element-property :CUSTOM_ID headline
)
2333 (concat "sec-" section-number
)))
2334 (concat (format "outline-%d" level1
) (and extra-class
" ")
2336 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2341 (let ((id (org-export-solidify-link-text
2342 (if (org-uuidgen-p x
) (concat "ID-" x
)
2344 (org-html--anchor id
)))
2348 ;; When there is no section, pretend there is an empty
2349 ;; one to get the correct <div class="outline- ...>
2350 ;; which is needed by `org-info.js'.
2351 (if (not (eq (org-element-type first-content
) 'section
))
2352 (concat (org-html-section first-content
"" info
)
2355 (org-html--container headline info
)))))))
2357 (defun org-html--container (headline info
)
2358 (or (org-element-property :HTML_CONTAINER headline
)
2359 (if (= 1 (org-export-get-relative-level headline info
))
2360 (plist-get info
:html-container
)
2363 ;;;; Horizontal Rule
2365 (defun org-html-horizontal-rule (horizontal-rule contents info
)
2366 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2367 CONTENTS is nil. INFO is a plist holding contextual information."
2368 (org-html-close-tag "hr" nil info
))
2370 ;;;; Inline Src Block
2372 (defun org-html-inline-src-block (inline-src-block contents info
)
2373 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2374 CONTENTS holds the contents of the item. INFO is a plist holding
2375 contextual information."
2376 (let* ((org-lang (org-element-property :language inline-src-block
))
2377 (code (org-element-property :value inline-src-block
)))
2378 (error "Cannot export inline src block")))
2382 (defun org-html-format-section (text class
&optional id
)
2383 "Format a section with TEXT into a HTML div with CLASS and ID."
2384 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
2385 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
2387 (defun org-html-inlinetask (inlinetask contents info
)
2388 "Transcode an INLINETASK element from Org to HTML.
2389 CONTENTS holds the contents of the block. INFO is a plist
2390 holding contextual information."
2392 ;; If `org-html-format-inlinetask-function' is not 'ignore, call it
2393 ;; with appropriate arguments.
2394 ((not (eq org-html-format-inlinetask-function
'ignore
))
2395 (let ((format-function
2397 (lambda (todo todo-type priority text tags
2398 &key contents
&allow-other-keys
)
2399 (funcall org-html-format-inlinetask-function
2400 todo todo-type priority text tags contents
)))))
2401 (org-html-format-headline--wrap
2402 inlinetask info format-function
:contents contents
)))
2403 ;; Otherwise, use a default template.
2404 (t (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2405 (org-html-format-headline--wrap inlinetask info
)
2406 (org-html-close-tag "br" nil info
)
2411 (defun org-html-italic (italic contents info
)
2412 "Transcode ITALIC from Org to HTML.
2413 CONTENTS is the text with italic markup. INFO is a plist holding
2414 contextual information."
2415 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
2419 (defun org-html-checkbox (checkbox)
2420 "Format CHECKBOX into HTML."
2421 (case checkbox
(on "<code>[X]</code>")
2422 (off "<code>[ ]</code>")
2423 (trans "<code>[-]</code>")
2426 (defun org-html-format-list-item (contents type checkbox info
2427 &optional term-counter-id
2429 "Format a list item into HTML."
2430 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" ")))
2431 (br (org-html-close-tag "br" nil info
)))
2435 (let* ((counter term-counter-id
)
2436 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2438 (format "<li%s>" extra
)
2439 (when headline
(concat headline br
)))))
2441 (let* ((id term-counter-id
)
2442 (extra (if id
(format " id=\"%s\"" id
) "")))
2444 (format "<li%s>" extra
)
2445 (when headline
(concat headline br
)))))
2447 (let* ((term term-counter-id
))
2448 (setq term
(or term
"(no term)"))
2449 ;; Check-boxes in descriptive lists are associated to tag.
2450 (concat (format "<dt> %s </dt>"
2451 (concat checkbox term
))
2453 (unless (eq type
'descriptive
) checkbox
)
2458 (descriptive "</dd>")))))
2460 (defun org-html-item (item contents info
)
2461 "Transcode an ITEM element from Org to HTML.
2462 CONTENTS holds the contents of the item. INFO is a plist holding
2463 contextual information."
2464 (let* ((plain-list (org-export-get-parent item
))
2465 (type (org-element-property :type plain-list
))
2466 (counter (org-element-property :counter item
))
2467 (checkbox (org-element-property :checkbox item
))
2468 (tag (let ((tag (org-element-property :tag item
)))
2469 (and tag
(org-export-data tag info
)))))
2470 (org-html-format-list-item
2471 contents type checkbox info
(or tag counter
))))
2475 (defun org-html-keyword (keyword contents info
)
2476 "Transcode a KEYWORD element from Org to HTML.
2477 CONTENTS is nil. INFO is a plist holding contextual information."
2478 (let ((key (org-element-property :key keyword
))
2479 (value (org-element-property :value keyword
)))
2481 ((string= key
"HTML") value
)
2482 ((string= key
"TOC")
2483 (let ((value (downcase value
)))
2485 ((string-match "\\<headlines\\>" value
)
2486 (let ((depth (or (and (string-match "[0-9]+" value
)
2487 (string-to-number (match-string 0 value
)))
2488 (plist-get info
:with-toc
))))
2489 (org-html-toc depth info
)))
2490 ((string= "listings" value
) (org-html-list-of-listings info
))
2491 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2493 ;;;; Latex Environment
2495 (defun org-html-format-latex (latex-frag processing-type info
)
2496 "Format a LaTeX fragment LATEX-FRAG into HTML.
2497 PROCESSING-TYPE designates the tool used for conversion. It is
2498 a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil
2499 and t. See `org-html-with-latex' for more information. INFO is
2500 a plist containing export properties."
2501 (let ((cache-relpath "") (cache-dir ""))
2502 (unless (eq processing-type
'mathjax
)
2503 (let ((bfn (or (buffer-file-name)
2505 (expand-file-name "latex" temporary-file-directory
))))
2507 (let ((header (plist-get info
:latex-header
)))
2510 (lambda (line) (concat "#+LATEX_HEADER: " line
))
2511 (org-split-string header
"\n")
2516 (file-name-sans-extension
2517 (file-name-nondirectory bfn
)))
2518 cache-dir
(file-name-directory bfn
))
2519 ;; Re-create LaTeX environment from original buffer in
2520 ;; temporary buffer so that dvipng/imagemagick can properly
2521 ;; turn the fragment into an image.
2522 (setq latex-frag
(concat latex-header latex-frag
))))
2525 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2526 nil nil processing-type
)
2529 (defun org-html-latex-environment (latex-environment contents info
)
2530 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2531 CONTENTS is nil. INFO is a plist holding contextual information."
2532 (let ((processing-type (plist-get info
:with-latex
))
2533 (latex-frag (org-remove-indentation
2534 (org-element-property :value latex-environment
)))
2535 (attributes (org-export-read-attribute :attr_html latex-environment
)))
2536 (case processing-type
2538 (org-html-format-latex latex-frag
'mathjax info
))
2539 ((dvipng imagemagick
)
2541 (org-html-format-latex latex-frag processing-type info
)))
2542 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2543 ;; Do not provide a caption or a name to be consistent with
2544 ;; `mathjax' handling.
2545 (org-html--wrap-image
2546 (org-html--format-image
2547 (match-string 1 formula-link
) attributes info
) info
))))
2552 (defun org-html-latex-fragment (latex-fragment contents info
)
2553 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2554 CONTENTS is nil. INFO is a plist holding contextual information."
2555 (let ((latex-frag (org-element-property :value latex-fragment
))
2556 (processing-type (plist-get info
:with-latex
)))
2557 (case processing-type
2559 (org-html-format-latex latex-frag
'mathjax info
))
2560 ((dvipng imagemagick
)
2562 (org-html-format-latex latex-frag processing-type info
)))
2563 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2564 (org-html--format-image (match-string 1 formula-link
) nil info
))))
2569 (defun org-html-line-break (line-break contents info
)
2570 "Transcode a LINE-BREAK object from Org to HTML.
2571 CONTENTS is nil. INFO is a plist holding contextual information."
2572 (concat (org-html-close-tag "br" nil info
) "\n"))
2576 (defun org-html-inline-image-p (link info
)
2577 "Non-nil when LINK is meant to appear as an image.
2578 INFO is a plist used as a communication channel. LINK is an
2579 inline image when it has no description and targets an image
2580 file (see `org-html-inline-image-rules' for more information), or
2581 if its description is a single link targeting an image file."
2582 (if (not (org-element-contents link
))
2583 (org-export-inline-image-p link org-html-inline-image-rules
)
2585 (let ((link-count 0))
2586 (org-element-map (org-element-contents link
)
2587 (cons 'plain-text org-element-all-objects
)
2589 (case (org-element-type obj
)
2590 (plain-text (org-string-nw-p obj
))
2591 (link (if (= link-count
1) t
2593 (not (org-export-inline-image-p
2594 obj org-html-inline-image-rules
))))
2598 (defvar org-html-standalone-image-predicate
)
2599 (defun org-html-standalone-image-p (element info
)
2600 "Test if ELEMENT is a standalone image.
2602 INFO is a plist holding contextual information.
2604 Return non-nil, if ELEMENT is of type paragraph and its sole
2605 content, save for white spaces, is a link that qualifies as an
2608 Return non-nil, if ELEMENT is of type link and its containing
2609 paragraph has no other content save white spaces.
2611 Return nil, otherwise.
2613 Bind `org-html-standalone-image-predicate' to constrain paragraph
2614 further. For example, to check for only captioned standalone
2617 \(lambda (paragraph) (org-element-property :caption paragraph))"
2618 (let ((paragraph (case (org-element-type element
)
2620 (link (org-export-get-parent element
)))))
2621 (and (eq (org-element-type paragraph
) 'paragraph
)
2622 (or (not (and (boundp 'org-html-standalone-image-predicate
)
2623 (functionp org-html-standalone-image-predicate
)))
2624 (funcall org-html-standalone-image-predicate paragraph
))
2625 (not (let ((link-count 0))
2626 (org-element-map (org-element-contents paragraph
)
2627 (cons 'plain-text org-element-all-objects
)
2628 (lambda (obj) (case (org-element-type obj
)
2629 (plain-text (org-string-nw-p obj
))
2631 (or (> (incf link-count
) 1)
2632 (not (org-html-inline-image-p obj info
))))
2634 info
'first-match
'link
))))))
2636 (defun org-html-link (link desc info
)
2637 "Transcode a LINK object from Org to HTML.
2639 DESC is the description part of the link, or the empty string.
2640 INFO is a plist holding contextual information. See
2642 (let* ((home (when (plist-get info
:html-link-home
)
2643 (org-trim (plist-get info
:html-link-home
))))
2644 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2645 (link-org-files-as-html-maybe
2647 (lambda (raw-path info
)
2648 "Treat links to `file.org' as links to `file.html', if needed.
2649 See `org-html-link-org-files-as-html'."
2651 ((and org-html-link-org-files-as-html
2653 (downcase (file-name-extension raw-path
"."))))
2654 (concat (file-name-sans-extension raw-path
) "."
2655 (plist-get info
:html-extension
)))
2657 (type (org-element-property :type link
))
2658 (raw-path (org-element-property :path link
))
2659 ;; Ensure DESC really exists, or set it to nil.
2660 (desc (org-string-nw-p desc
))
2663 ((member type
'("http" "https" "ftp" "mailto"))
2664 (concat type
":" raw-path
))
2665 ((string= type
"file")
2666 ;; Treat links to ".org" files as ".html", if needed.
2668 (funcall link-org-files-as-html-maybe raw-path info
))
2669 ;; If file path is absolute, prepend it with protocol
2670 ;; component - "file://".
2671 (cond ((file-name-absolute-p raw-path
)
2673 (concat "file://" (expand-file-name
2675 ((and home use-abs-url
)
2676 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2677 ;; Add search option, if any. A search option can be
2678 ;; relative to a custom-id or a headline title. Any other
2679 ;; option is ignored.
2680 (let ((option (org-element-property :search-option link
)))
2681 (cond ((not option
) raw-path
)
2682 ((eq (aref option
0) ?
#) (concat raw-path option
))
2683 ;; External fuzzy link: try to resolve it if path
2684 ;; belongs to current project, if any.
2685 ((eq (aref option
0) ?
*)
2689 (org-publish-resolve-external-fuzzy-link
2690 (org-element-property :path link
) option
)))
2691 (and numbers
(concat "#sec-"
2692 (mapconcat 'number-to-string
2696 ;; Extract attributes from parent's paragraph. HACK: Only do
2697 ;; this for the first link in parent (inner image link for
2698 ;; inline images). This is needed as long as attributes
2699 ;; cannot be set on a per link basis.
2701 (let* ((parent (org-export-get-parent-element link
))
2702 (link (let ((container (org-export-get-parent link
)))
2703 (if (and (eq (org-element-type container
) 'link
)
2704 (org-html-inline-image-p link info
))
2707 (and (eq (org-element-map parent
'link
'identity info t
) link
)
2708 (org-export-read-attribute :attr_html parent
))))
2710 (let ((attr (org-html--make-attribute-string attributes-plist
)))
2711 (if (org-string-nw-p attr
) (concat " " attr
) "")))
2715 ((and org-html-inline-images
2716 (org-export-inline-image-p link org-html-inline-image-rules
))
2717 (org-html--format-image path attributes-plist info
))
2718 ;; Radio target: Transcode target's contents and use them as
2719 ;; link's description.
2720 ((string= type
"radio")
2721 (let ((destination (org-export-resolve-radio-link link info
)))
2723 (format "<a href=\"#%s\"%s>%s</a>"
2724 (org-export-solidify-link-text path
)
2726 (org-export-data (org-element-contents destination
) info
)))))
2727 ;; Links pointing to a headline: Find destination and build
2728 ;; appropriate referencing command.
2729 ((member type
'("custom-id" "fuzzy" "id"))
2730 (let ((destination (if (string= type
"fuzzy")
2731 (org-export-resolve-fuzzy-link link info
)
2732 (org-export-resolve-id-link link info
))))
2733 (case (org-element-type destination
)
2734 ;; ID link points to an external file.
2736 (let ((fragment (concat "ID-" path
))
2737 ;; Treat links to ".org" files as ".html", if needed.
2738 (path (funcall link-org-files-as-html-maybe
2740 (format "<a href=\"%s#%s\"%s>%s</a>"
2741 path fragment attributes
(or desc destination
))))
2742 ;; Fuzzy link points nowhere.
2747 (org-element-property :raw-link link
) info
))))
2748 ;; Link points to a headline.
2751 ;; What href to use?
2753 ;; Case 1: Headline is linked via it's CUSTOM_ID
2754 ;; property. Use CUSTOM_ID.
2755 ((string= type
"custom-id")
2756 (org-element-property :CUSTOM_ID destination
))
2757 ;; Case 2: Headline is linked via it's ID property
2758 ;; or through other means. Use the default href.
2759 ((member type
'("id" "fuzzy"))
2761 (mapconcat 'number-to-string
2762 (org-export-get-headline-number
2763 destination info
) "-")))
2764 (t (error "Shouldn't reach here"))))
2765 ;; What description to use?
2767 ;; Case 1: Headline is numbered and LINK has no
2768 ;; description. Display section number.
2769 (if (and (org-export-numbered-headline-p destination info
)
2771 (mapconcat 'number-to-string
2772 (org-export-get-headline-number
2773 destination info
) ".")
2774 ;; Case 2: Either the headline is un-numbered or
2775 ;; LINK has a custom description. Display LINK's
2776 ;; description or headline's title.
2777 (or desc
(org-export-data (org-element-property
2778 :title destination
) info
)))))
2779 (format "<a href=\"#%s\"%s>%s</a>"
2780 (org-export-solidify-link-text href
) attributes desc
)))
2781 ;; Fuzzy link points to a target or an element.
2783 (let* ((path (org-export-solidify-link-text path
))
2784 (org-html-standalone-image-predicate 'org-html--has-caption-p
)
2787 ((org-html-standalone-image-p destination info
)
2788 (org-export-get-ordinal
2789 (org-element-map destination
'link
2791 info
'link
'org-html-standalone-image-p
))
2792 (t (org-export-get-ordinal
2793 destination info nil
'org-html--has-caption-p
))))
2795 ((not number
) "No description for this link")
2796 ((numberp number
) (number-to-string number
))
2797 (t (mapconcat 'number-to-string number
".")))))
2798 (format "<a href=\"#%s\"%s>%s</a>" path attributes desc
))))))
2799 ;; Coderef: replace link with the reference name or the
2800 ;; equivalent line number.
2801 ((string= type
"coderef")
2802 (let ((fragment (concat "coderef-" path
)))
2803 (format "<a href=\"#%s\"%s%s>%s</a>"
2806 (format (concat "class=\"coderef\""
2807 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2808 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2811 (format (org-export-get-coderef-format path desc
)
2812 (org-export-resolve-coderef path info
)))))
2813 ;; Link type is handled by a special function.
2814 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2815 (funcall protocol
(org-link-unescape path
) desc
'html
))
2816 ;; External link with a description part.
2817 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2818 ;; External link without a description part.
2819 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2820 ;; No path, only description. Try to do something useful.
2821 (t (format "<i>%s</i>" desc
)))))
2825 (defun org-html-paragraph (paragraph contents info
)
2826 "Transcode a PARAGRAPH element from Org to HTML.
2827 CONTENTS is the contents of the paragraph, as a string. INFO is
2828 the plist used as a communication channel."
2829 (let* ((parent (org-export-get-parent paragraph
))
2830 (parent-type (org-element-type parent
))
2831 (style '((footnote-definition " class=\"footpara\"")))
2832 (extra (or (cadr (assoc parent-type style
)) "")))
2834 ((and (eq (org-element-type parent
) 'item
)
2835 (= (org-element-property :begin paragraph
)
2836 (org-element-property :contents-begin parent
)))
2837 ;; Leading paragraph in a list item have no tags.
2839 ((org-html-standalone-image-p paragraph info
)
2840 ;; Standalone image.
2842 (let ((raw (org-export-data
2843 (org-export-get-caption paragraph
) info
))
2844 (org-html-standalone-image-predicate
2845 'org-html--has-caption-p
))
2846 (if (not (org-string-nw-p raw
)) raw
2848 "<span class=\"figure-number\">"
2849 (format (org-html--translate "Figure %d:" info
)
2850 (org-export-get-ordinal
2851 (org-element-map paragraph
'link
2853 info nil
'org-html-standalone-image-p
))
2855 (label (org-element-property :name paragraph
)))
2856 (org-html--wrap-image contents info caption label
)))
2857 ;; Regular paragraph.
2858 (t (format "<p%s>\n%s</p>" extra contents
)))))
2862 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2863 ;; the correct value for the item counter
2864 (defun org-html-begin-plain-list (type &optional arg1
)
2865 "Insert the beginning of the HTML list depending on TYPE.
2866 When ARG1 is a string, use it as the start parameter for ordered
2870 (format "<ol class=\"org-ol\"%s>"
2871 (if arg1
(format " start=\"%d\"" arg1
) "")))
2872 (unordered "<ul class=\"org-ul\">")
2873 (descriptive "<dl class=\"org-dl\">")))
2875 (defun org-html-end-plain-list (type)
2876 "Insert the end of the HTML list depending on TYPE."
2880 (descriptive "</dl>")))
2882 (defun org-html-plain-list (plain-list contents info
)
2883 "Transcode a PLAIN-LIST element from Org to HTML.
2884 CONTENTS is the contents of the list. INFO is a plist holding
2885 contextual information."
2886 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2887 (type (org-element-property :type plain-list
)))
2889 (org-html-begin-plain-list type
)
2890 contents
(org-html-end-plain-list type
))))
2894 (defun org-html-convert-special-strings (string)
2895 "Convert special characters in STRING to HTML."
2896 (let ((all org-html-special-string-regexps
)
2898 (while (setq a
(pop all
))
2899 (setq re
(car a
) rpl
(cdr a
) start
0)
2900 (while (string-match re string start
)
2901 (setq string
(replace-match rpl t nil string
))))
2904 (defun org-html-encode-plain-text (text)
2905 "Convert plain text characters from TEXT to HTML equivalent.
2906 Possible conversions are set in `org-html-protect-char-alist'."
2909 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2910 org-html-protect-char-alist
)
2913 (defun org-html-plain-text (text info
)
2914 "Transcode a TEXT string from Org to HTML.
2915 TEXT is the string to transcode. INFO is a plist holding
2916 contextual information."
2917 (let ((output text
))
2918 ;; Protect following characters: <, >, &.
2919 (setq output
(org-html-encode-plain-text output
))
2920 ;; Handle smart quotes. Be sure to provide original string since
2921 ;; OUTPUT may have been modified.
2922 (when (plist-get info
:with-smart-quotes
)
2923 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2924 ;; Handle special strings.
2925 (when (plist-get info
:with-special-strings
)
2926 (setq output
(org-html-convert-special-strings output
)))
2927 ;; Handle break preservation if required.
2928 (when (plist-get info
:preserve-breaks
)
2930 (replace-regexp-in-string
2931 "\\(\\\\\\\\\\)?[ \t]*\n"
2932 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
2939 (defun org-html-planning (planning contents info
)
2940 "Transcode a PLANNING element from Org to HTML.
2941 CONTENTS is nil. INFO is a plist used as a communication
2943 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2945 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2950 (let ((closed (org-element-property :closed planning
)))
2952 (format span-fmt org-closed-string
2954 (org-element-property :raw-value closed
)))))
2955 (let ((deadline (org-element-property :deadline planning
)))
2957 (format span-fmt org-deadline-string
2959 (org-element-property :raw-value deadline
)))))
2960 (let ((scheduled (org-element-property :scheduled planning
)))
2962 (format span-fmt org-scheduled-string
2964 (org-element-property :raw-value scheduled
)))))))
2967 ;;;; Property Drawer
2969 (defun org-html-property-drawer (property-drawer contents info
)
2970 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2971 CONTENTS is nil. INFO is a plist holding contextual
2973 ;; The property drawer isn't exported but we want separating blank
2974 ;; lines nonetheless.
2979 (defun org-html-quote-block (quote-block contents info
)
2980 "Transcode a QUOTE-BLOCK element from Org to HTML.
2981 CONTENTS holds the contents of the block. INFO is a plist
2982 holding contextual information."
2983 (format "<blockquote>\n%s</blockquote>" contents
))
2987 (defun org-html-quote-section (quote-section contents info
)
2988 "Transcode a QUOTE-SECTION element from Org to HTML.
2989 CONTENTS is nil. INFO is a plist holding contextual information."
2990 (let ((value (org-remove-indentation
2991 (org-element-property :value quote-section
))))
2992 (when value
(format "<pre>\n%s</pre>" value
))))
2996 (defun org-html-section (section contents info
)
2997 "Transcode a SECTION element from Org to HTML.
2998 CONTENTS holds the contents of the section. INFO is a plist
2999 holding contextual information."
3000 (let ((parent (org-export-get-parent-headline section
)))
3001 ;; Before first headline: no container, just return CONTENTS.
3002 (if (not parent
) contents
3003 ;; Get div's class and id references.
3004 (let* ((class-num (+ (org-export-get-relative-level parent info
)
3005 (1- org-html-toplevel-hlevel
)))
3009 (org-export-get-headline-number parent info
) "-")))
3010 ;; Build return value.
3011 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
3013 (or (org-element-property :CUSTOM_ID parent
) section-number
)
3018 (defun org-html-radio-target (radio-target text info
)
3019 "Transcode a RADIO-TARGET object from Org to HTML.
3020 TEXT is the text of the target. INFO is a plist holding
3021 contextual information."
3022 (let ((id (org-export-solidify-link-text
3023 (org-element-property :value radio-target
))))
3024 (org-html--anchor id text
)))
3028 (defun org-html-special-block (special-block contents info
)
3029 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3030 CONTENTS holds the contents of the block. INFO is a plist
3031 holding contextual information."
3032 (let* ((block-type (downcase
3033 (org-element-property :type special-block
)))
3034 (contents (or contents
""))
3035 (html5-fancy (and (org-html-html5-p info
)
3036 (plist-get info
:html-html5-fancy
)
3037 (member block-type org-html-html5-elements
)))
3038 (attributes (org-export-read-attribute :attr_html special-block
)))
3040 (let ((class (plist-get attributes
:class
)))
3041 (setq attributes
(plist-put attributes
:class
3042 (if class
(concat class
" " block-type
)
3044 (setq attributes
(org-html--make-attribute-string attributes
))
3045 (when (not (equal attributes
""))
3046 (setq attributes
(concat " " attributes
)))
3048 (format "<%s%s>\n%s</%s>" block-type attributes
3049 contents block-type
)
3050 (format "<div%s>\n%s\n</div>" attributes contents
))))
3054 (defun org-html-src-block (src-block contents info
)
3055 "Transcode a SRC-BLOCK element from Org to HTML.
3056 CONTENTS holds the contents of the item. INFO is a plist holding
3057 contextual information."
3058 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3059 (org-html--textarea-block src-block
)
3060 (let ((lang (org-element-property :language src-block
))
3061 (caption (org-export-get-caption src-block
))
3062 (code (org-html-format-code src-block info
))
3063 (label (let ((lbl (org-element-property :name src-block
)))
3065 (format " id=\"%s\""
3066 (org-export-solidify-link-text lbl
))))))
3067 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3069 "<div class=\"org-src-container\">\n%s%s\n</div>"
3070 (if (not caption
) ""
3071 (format "<label class=\"org-src-name\">%s</label>"
3072 (org-export-data caption info
)))
3073 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3075 ;;;; Statistics Cookie
3077 (defun org-html-statistics-cookie (statistics-cookie contents info
)
3078 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3079 CONTENTS is nil. INFO is a plist holding contextual information."
3080 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3081 (format "<code>%s</code>" cookie-value
)))
3085 (defun org-html-strike-through (strike-through contents info
)
3086 "Transcode STRIKE-THROUGH from Org to HTML.
3087 CONTENTS is the text with strike-through markup. INFO is a plist
3088 holding contextual information."
3089 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
3094 (defun org-html-subscript (subscript contents info
)
3095 "Transcode a SUBSCRIPT object from Org to HTML.
3096 CONTENTS is the contents of the object. INFO is a plist holding
3097 contextual information."
3098 (format "<sub>%s</sub>" contents
))
3102 (defun org-html-superscript (superscript contents info
)
3103 "Transcode a SUPERSCRIPT object from Org to HTML.
3104 CONTENTS is the contents of the object. INFO is a plist holding
3105 contextual information."
3106 (format "<sup>%s</sup>" contents
))
3110 (defun org-html-table-cell (table-cell contents info
)
3111 "Transcode a TABLE-CELL element from Org to HTML.
3112 CONTENTS is nil. INFO is a plist used as a communication
3114 (let* ((table-row (org-export-get-parent table-cell
))
3115 (table (org-export-get-parent-table table-cell
))
3117 (if (not org-html-table-align-individual-fields
) ""
3118 (format (if (and (boundp 'org-html-format-table-no-css
)
3119 org-html-format-table-no-css
)
3120 " align=\"%s\"" " class=\"%s\"")
3121 (org-export-table-cell-alignment table-cell info
)))))
3122 (when (or (not contents
) (string= "" (org-trim contents
)))
3123 (setq contents
" "))
3125 ((and (org-export-table-has-header-p table info
)
3126 (= 1 (org-export-table-row-group table-row info
)))
3127 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
3128 contents
(cdr org-html-table-header-tags
)))
3129 ((and org-html-table-use-header-tags-for-first-column
3130 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3131 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
3132 contents
(cdr org-html-table-header-tags
)))
3133 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
3134 contents
(cdr org-html-table-data-tags
))))))
3138 (defun org-html-table-row (table-row contents info
)
3139 "Transcode a TABLE-ROW element from Org to HTML.
3140 CONTENTS is the contents of the row. INFO is a plist used as a
3141 communication channel."
3142 ;; Rules are ignored since table separators are deduced from
3143 ;; borders of the current row.
3144 (when (eq (org-element-property :type table-row
) 'standard
)
3145 (let* ((rowgroup-number (org-export-table-row-group table-row info
))
3146 (row-number (org-export-table-row-number table-row info
))
3148 (org-export-table-row-starts-rowgroup-p table-row info
))
3150 (org-export-table-row-ends-rowgroup-p table-row info
))
3151 ;; `top-row-p' and `end-rowgroup-p' are not used directly
3152 ;; but should be set so that `org-html-table-row-tags' can
3153 ;; use them (see the docstring of this variable.)
3154 (top-row-p (and (equal start-rowgroup-p
'(top))
3155 (equal end-rowgroup-p
'(below top
))))
3156 (bottom-row-p (and (equal start-rowgroup-p
'(above))
3157 (equal end-rowgroup-p
'(bottom above
))))
3160 ;; Case 1: Row belongs to second or subsequent rowgroups.
3161 ((not (= 1 rowgroup-number
))
3162 '("<tbody>" .
"\n</tbody>"))
3163 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
3164 ((org-export-table-has-header-p
3165 (org-export-get-parent-table table-row
) info
)
3166 '("<thead>" .
"\n</thead>"))
3167 ;; Case 2: Row is from first and only row group.
3168 (t '("<tbody>" .
"\n</tbody>")))))
3170 ;; Begin a rowgroup?
3171 (when start-rowgroup-p
(car rowgroup-tags
))
3173 (concat "\n" (eval (car org-html-table-row-tags
))
3176 (eval (cdr org-html-table-row-tags
)))
3178 (when end-rowgroup-p
(cdr rowgroup-tags
))))))
3182 (defun org-html-table-first-row-data-cells (table info
)
3183 "Transcode the first row of TABLE.
3184 INFO is a plist used as a communication channel."
3186 (org-element-map table
'table-row
3188 (unless (eq (org-element-property :type row
) 'rule
) row
))
3190 (special-column-p (org-export-table-has-special-column-p table
)))
3191 (if (not special-column-p
) (org-element-contents table-row
)
3192 (cdr (org-element-contents table-row
)))))
3194 (defun org-html-table--table.el-table
(table info
)
3195 "Format table.el tables into HTML.
3196 INFO is a plist used as a communication channel."
3197 (when (eq (org-element-property :type table
) 'table.el
)
3199 (let ((outbuf (with-current-buffer
3200 (get-buffer-create "*org-export-table*")
3201 (erase-buffer) (current-buffer))))
3203 (insert (org-element-property :value table
))
3205 (re-search-forward "^[ \t]*|[^|]" nil t
)
3206 (table-generate-source 'html outbuf
))
3207 (with-current-buffer outbuf
3208 (prog1 (org-trim (buffer-string))
3211 (defun org-html-table (table contents info
)
3212 "Transcode a TABLE element from Org to HTML.
3213 CONTENTS is the contents of the table. INFO is a plist holding
3214 contextual information."
3215 (case (org-element-property :type table
)
3216 ;; Case 1: table.el table. Convert it using appropriate tools.
3217 (table.el
(org-html-table--table.el-table table info
))
3218 ;; Case 2: Standard table.
3220 (let* ((label (org-element-property :name table
))
3221 (caption (org-export-get-caption table
))
3222 (number (org-export-get-ordinal
3223 table info nil
'org-html--has-caption-p
))
3225 (org-html--make-attribute-string
3227 (and label
(list :id
(org-export-solidify-link-text label
)))
3228 (and (not (org-html-html5-p info
))
3229 (plist-get info
:html-table-attributes
))
3230 (org-export-read-attribute :attr_html table
))))
3232 (if (and (boundp 'org-html-format-table-no-css
)
3233 org-html-format-table-no-css
)
3234 "align=\"%s\"" "class=\"%s\""))
3237 (lambda (table info
)
3239 (lambda (table-cell)
3240 (let ((alignment (org-export-table-cell-alignment
3243 ;; Begin a colgroup?
3244 (when (org-export-table-cell-starts-colgroup-p
3247 ;; Add a column. Also specify it's alignment.
3250 "col" (concat " " (format alignspec alignment
)) info
))
3252 (when (org-export-table-cell-ends-colgroup-p
3255 (org-html-table-first-row-data-cells table info
) "\n")))))
3256 (format "<table%s>\n%s\n%s\n%s</table>"
3257 (if (equal attributes
"") "" (concat " " attributes
))
3258 (if (not caption
) ""
3259 (format (if org-html-table-caption-above
3260 "<caption class=\"t-above\">%s</caption>"
3261 "<caption class=\"t-bottom\">%s</caption>")
3263 "<span class=\"table-number\">"
3264 (format (org-html--translate "Table %d:" info
) number
)
3265 "</span> " (org-export-data caption info
))))
3266 (funcall table-column-specs table info
)
3271 (defun org-html-target (target contents info
)
3272 "Transcode a TARGET object from Org to HTML.
3273 CONTENTS is nil. INFO is a plist holding contextual
3275 (let ((id (org-export-solidify-link-text
3276 (org-element-property :value target
))))
3277 (org-html--anchor id
)))
3281 (defun org-html-timestamp (timestamp contents info
)
3282 "Transcode a TIMESTAMP object from Org to HTML.
3283 CONTENTS is nil. INFO is a plist holding contextual
3285 (let ((value (org-html-plain-text
3286 (org-timestamp-translate timestamp
) info
)))
3287 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3288 (replace-regexp-in-string "--" "–" value
))))
3292 (defun org-html-underline (underline contents info
)
3293 "Transcode UNDERLINE from Org to HTML.
3294 CONTENTS is the text with underline markup. INFO is a plist
3295 holding contextual information."
3296 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
3301 (defun org-html-verbatim (verbatim contents info
)
3302 "Transcode VERBATIM from Org to HTML.
3303 CONTENTS is nil. INFO is a plist holding contextual
3305 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
3306 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3310 (defun org-html-verse-block (verse-block contents info
)
3311 "Transcode a VERSE-BLOCK element from Org to HTML.
3312 CONTENTS is verse block contents. INFO is a plist holding
3313 contextual information."
3314 ;; Replace each newline character with line break. Also replace
3315 ;; each blank line with a line break.
3316 (setq contents
(replace-regexp-in-string
3317 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3318 (replace-regexp-in-string
3319 "\\(\\\\\\\\\\)?[ \t]*\n"
3320 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3321 ;; Replace each white space at beginning of a line with a
3322 ;; non-breaking space.
3323 (while (string-match "^[ \t]+" contents
)
3324 (let* ((num-ws (length (match-string 0 contents
)))
3325 (ws (let (out) (dotimes (i num-ws out
)
3326 (setq out
(concat out
" "))))))
3327 (setq contents
(replace-match ws nil t contents
))))
3328 (format "<p class=\"verse\">\n%s</p>" contents
))
3331 ;;; Filter Functions
3333 (defun org-html-final-function (contents backend info
)
3334 "Filter to indent the HTML and convert HTML entities."
3339 (indent-region (point-min) (point-max)))
3340 (when org-html-use-unicode-chars
3342 (mm-url-decode-entities))
3343 (buffer-substring-no-properties (point-min) (point-max))))
3346 ;;; End-user functions
3349 (defun org-html-export-as-html
3350 (&optional async subtreep visible-only body-only ext-plist
)
3351 "Export current buffer to an HTML buffer.
3353 If narrowing is active in the current buffer, only export its
3356 If a region is active, export that region.
3358 A non-nil optional argument ASYNC means the process should happen
3359 asynchronously. The resulting buffer should be accessible
3360 through the `org-export-stack' interface.
3362 When optional argument SUBTREEP is non-nil, export the sub-tree
3363 at point, extracting information from the headline properties
3366 When optional argument VISIBLE-ONLY is non-nil, don't export
3367 contents of hidden elements.
3369 When optional argument BODY-ONLY is non-nil, only write code
3370 between \"<body>\" and \"</body>\" tags.
3372 EXT-PLIST, when provided, is a property list with external
3373 parameters overriding Org default settings, but still inferior to
3374 file-local settings.
3376 Export is done in a buffer named \"*Org HTML Export*\", which
3377 will be displayed when `org-export-show-temporary-export-buffer'
3380 (org-export-to-buffer 'html
"*Org HTML Export*"
3381 async subtreep visible-only body-only ext-plist
3382 (lambda () (set-auto-mode t
))))
3385 (defun org-html-convert-region-to-html ()
3386 "Assume the current region has org-mode syntax, and convert it to HTML.
3387 This can be used in any buffer. For example, you can write an
3388 itemized list in org-mode syntax in an HTML buffer and use this
3389 command to convert it."
3391 (org-export-replace-region-by 'html
))
3394 (defun org-html-export-to-html
3395 (&optional async subtreep visible-only body-only ext-plist
)
3396 "Export current buffer to a HTML file.
3398 If narrowing is active in the current buffer, only export its
3401 If a region is active, export that region.
3403 A non-nil optional argument ASYNC means the process should happen
3404 asynchronously. The resulting file should be accessible through
3405 the `org-export-stack' interface.
3407 When optional argument SUBTREEP is non-nil, export the sub-tree
3408 at point, extracting information from the headline properties
3411 When optional argument VISIBLE-ONLY is non-nil, don't export
3412 contents of hidden elements.
3414 When optional argument BODY-ONLY is non-nil, only write code
3415 between \"<body>\" and \"</body>\" tags.
3417 EXT-PLIST, when provided, is a property list with external
3418 parameters overriding Org default settings, but still inferior to
3419 file-local settings.
3421 Return output file's name."
3423 (let* ((extension (concat "." org-html-extension
))
3424 (file (org-export-output-file-name extension subtreep
))
3425 (org-export-coding-system org-html-coding-system
))
3426 (org-export-to-file 'html file
3427 async subtreep visible-only body-only ext-plist
)))
3430 (defun org-html-publish-to-html (plist filename pub-dir
)
3431 "Publish an org file to HTML.
3433 FILENAME is the filename of the Org file to be published. PLIST
3434 is the property list for the given project. PUB-DIR is the
3435 publishing directory.
3437 Return output file name."
3438 (org-publish-org-to 'html filename
3439 (concat "." (or (plist-get plist
:html-extension
)
3440 org-html-extension
"html"))
3447 ;; generated-autoload-file: "org-loaddefs.el"
3450 ;;; ox-html.el ends here