1 ;;; ox-html.el --- HTML Back-End for Org Export Engine
3 ;; Copyright (C) 2011-2013 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
)))
136 ;;; Internal Variables
138 (defvar org-html-format-table-no-css
)
139 (defvar htmlize-buffer-places
) ; from htmlize.el
141 (defvar org-html--pre
/postamble-class
"status"
142 "CSS class used for pre/postamble")
144 (defconst org-html-doctype-alist
145 '(("html4-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
146 \"http://www.w3.org/TR/html4/strict.dtd\">")
147 ("html4-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
148 \"http://www.w3.org/TR/html4/loose.dtd\">")
149 ("html4-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
150 \"http://www.w3.org/TR/html4/frameset.dtd\">")
152 ("xhtml-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
153 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
154 ("xhtml-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
155 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
156 ("xhtml-framset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
157 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
158 ("xhtml-11" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
159 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
161 ("html5" .
"<!DOCTYPE html>")
162 ("xhtml5" .
"<!DOCTYPE html>"))
163 "An alist mapping (x)html flavors to specific doctypes.")
165 (defconst org-html-html5-elements
166 '("article" "aside" "audio" "canvas" "details" "figcaption"
167 "figure" "footer" "header" "menu" "meter" "nav" "output"
168 "progress" "section" "video")
169 "New elements in html5.
171 <hgroup> is not included because it's currently impossible to
172 wrap special blocks around multiple headlines. For other blocks
173 that should contain headlines, use the HTML_CONTAINER property on
174 the headline itself.")
176 (defconst org-html-special-string-regexps
177 '(("\\\\-" .
"­") ; shy
178 ("---\\([^-]\\)" .
"—\\1") ; mdash
179 ("--\\([^-]\\)" .
"–\\1") ; ndash
180 ("\\.\\.\\." .
"…")) ; hellip
181 "Regular expressions for special string conversion.")
183 (defconst org-html-scripts
184 "<script type=\"text/javascript\">
186 @licstart The following is the entire license notice for the
187 JavaScript code in this tag.
189 Copyright (C) 2012-2013 Free Software Foundation, Inc.
191 The JavaScript code in this tag is free software: you can
192 redistribute it and/or modify it under the terms of the GNU
193 General Public License (GNU GPL) as published by the Free Software
194 Foundation, either version 3 of the License, or (at your option)
195 any later version. The code is distributed WITHOUT ANY WARRANTY;
196 without even the implied warranty of MERCHANTABILITY or FITNESS
197 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
199 As additional permission under GNU GPL version 3 section 7, you
200 may distribute non-source (e.g., minimized or compacted) forms of
201 that code without the copy of the GNU GPL normally required by
202 section 4, provided you include this license notice and a URL
203 through which recipients can access the Corresponding Source.
206 @licend The above is the entire license notice
207 for the JavaScript code in this tag.
209 <!--/*--><![CDATA[/*><!--*/
210 function CodeHighlightOn(elem, id)
212 var target = document.getElementById(id);
214 elem.cacheClassElem = elem.className;
215 elem.cacheClassTarget = target.className;
216 target.className = \"code-highlighted\";
217 elem.className = \"code-highlighted\";
220 function CodeHighlightOff(elem, id)
222 var target = document.getElementById(id);
223 if(elem.cacheClassElem)
224 elem.className = elem.cacheClassElem;
225 if(elem.cacheClassTarget)
226 target.className = elem.cacheClassTarget;
230 "Basic JavaScript that is needed by HTML files produced by Org mode.")
232 (defconst org-html-style-default
233 "<style type=\"text/css\">
234 <!--/*--><![CDATA[/*><!--*/
235 .title { text-align: center; }
236 .todo { font-family: monospace; color: red; }
237 .done { color: green; }
238 .tag { background-color: #eee; font-family: monospace;
239 padding: 2px; font-size: 80%; font-weight: normal; }
240 .timestamp { color: #bebebe; }
241 .timestamp-kwd { color: #5f9ea0; }
242 .right { margin-left: auto; margin-right: 0px; text-align: right; }
243 .left { margin-left: 0px; margin-right: auto; text-align: left; }
244 .center { margin-left: auto; margin-right: auto; text-align: center; }
245 .underline { text-decoration: underline; }
246 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
247 p.verse { margin-left: 3%; }
249 border: 1px solid #ccc;
250 box-shadow: 3px 3px 3px #eee;
252 font-family: monospace;
264 background-color: white;
268 border: 1px solid black;
270 pre.src:hover:before { display: inline;}
271 pre.src-sh:before { content: 'sh'; }
272 pre.src-bash:before { content: 'sh'; }
273 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
274 pre.src-R:before { content: 'R'; }
275 pre.src-perl:before { content: 'Perl'; }
276 pre.src-java:before { content: 'Java'; }
277 pre.src-sql:before { content: 'SQL'; }
279 table { border-collapse:collapse; }
280 td, th { vertical-align:top; }
281 th.right { text-align: center; }
282 th.left { text-align: center; }
283 th.center { text-align: center; }
284 td.right { text-align: right; }
285 td.left { text-align: left; }
286 td.center { text-align: center; }
287 dt { font-weight: bold; }
288 .footpara:nth-child(2) { display: inline; }
289 .footpara { display: block; }
290 .footdef { margin-bottom: 1em; }
291 .figure { padding: 1em; }
292 .figure p { text-align: center; }
295 border: 2px solid gray;
300 { text-align: right; font-size: 70%; white-space: nowrap; }
301 textarea { overflow-x: auto; }
302 .linenr { font-size: smaller }
303 .code-highlighted { background-color: #ffff00; }
304 .org-info-js_info-navigation { border-style: none; }
305 #org-info-js_console-label
306 { font-size: 10px; font-weight: bold; white-space: nowrap; }
307 .org-info-js_search-highlight
308 { background-color: #ffff00; color: #000000; font-weight: bold; }
311 "The default style specification for exported HTML files.
312 You can use `org-html-head' and `org-html-head-extra' to add to
313 this style. If you don't want to include this default style,
314 customize `org-html-head-include-default-style'.")
317 ;;; User Configuration Variables
319 (defgroup org-export-html nil
320 "Options for exporting Org mode files to HTML."
321 :tag
"Org Export HTML"
326 (defvar org-html-infojs-opts-table
327 '((path PATH
"http://orgmode.org/org-info.js")
331 (tdepth TOC_DEPTH
"max")
332 (sdepth SECTION_DEPTH
"max")
333 (mouse MOUSE_HINT
"underline")
334 (buttons VIEW_BUTTONS
"0")
336 (up LINK_UP
:html-link-up
)
337 (home LINK_HOME
:html-link-home
))
338 "JavaScript options, long form for script, default values.")
340 (defcustom org-html-use-infojs
'when-configured
341 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
342 This option can be nil or t to never or always use the script.
343 It can also be the symbol `when-configured', meaning that the
344 script will be linked into the export file if and only if there
345 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
346 `org-html-infojs-options'."
347 :group
'org-export-html
349 :package-version
'(Org .
"8.0")
351 (const :tag
"Never" nil
)
352 (const :tag
"When configured in buffer" when-configured
)
353 (const :tag
"Always" t
)))
355 (defcustom org-html-infojs-options
356 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
357 "Options settings for the INFOJS JavaScript.
358 Each of the options must have an entry in `org-html-infojs-opts-table'.
359 The value can either be a string that will be passed to the script, or
360 a property. This property is then assumed to be a property that is defined
361 by the Export/Publishing setup of Org.
362 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
363 means to use the maximum value consistent with other options."
364 :group
'org-export-html
366 :package-version
'(Org .
"8.0")
368 `(set :greedy t
:inline t
371 (list 'cons
(list 'const
(car x
))
373 (symbol :tag
"Publishing/Export property")
374 (string :tag
"Value"))))
375 org-html-infojs-opts-table
)))
377 (defcustom org-html-infojs-template
378 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
381 * @source: %SCRIPT_PATH
383 * @licstart The following is the entire license notice for the
384 * JavaScript code in %SCRIPT_PATH.
386 * Copyright (C) 2012-2013 Free Software Foundation, Inc.
389 * The JavaScript code in this tag is free software: you can
390 * redistribute it and/or modify it under the terms of the GNU
391 * General Public License (GNU GPL) as published by the Free Software
392 * Foundation, either version 3 of the License, or (at your option)
393 * any later version. The code is distributed WITHOUT ANY WARRANTY;
394 * without even the implied warranty of MERCHANTABILITY or FITNESS
395 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
397 * As additional permission under GNU GPL version 3 section 7, you
398 * may distribute non-source (e.g., minimized or compacted) forms of
399 * that code without the copy of the GNU GPL normally required by
400 * section 4, provided you include this license notice and a URL
401 * through which recipients can access the Corresponding Source.
403 * @licend The above is the entire license notice
404 * for the JavaScript code in %SCRIPT_PATH.
409 <script type=\"text/javascript\">
412 @licstart The following is the entire license notice for the
413 JavaScript code in this tag.
415 Copyright (C) 2012-2013 Free Software Foundation, Inc.
417 The JavaScript code in this tag is free software: you can
418 redistribute it and/or modify it under the terms of the GNU
419 General Public License (GNU GPL) as published by the Free Software
420 Foundation, either version 3 of the License, or (at your option)
421 any later version. The code is distributed WITHOUT ANY WARRANTY;
422 without even the implied warranty of MERCHANTABILITY or FITNESS
423 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
425 As additional permission under GNU GPL version 3 section 7, you
426 may distribute non-source (e.g., minimized or compacted) forms of
427 that code without the copy of the GNU GPL normally required by
428 section 4, provided you include this license notice and a URL
429 through which recipients can access the Corresponding Source.
432 @licend The above is the entire license notice
433 for the JavaScript code in this tag.
436 <!--/*--><![CDATA[/*><!--*/
438 org_html_manager.setup(); // activate after the parameters are set
441 "The template for the export style additions when org-info.js is used.
442 Option settings will replace the %MANAGER-OPTIONS cookie."
443 :group
'org-export-html
445 :package-version
'(Org .
"8.0")
448 (defun org-html-infojs-install-script (exp-plist backend
)
449 "Install script in export options when appropriate.
450 EXP-PLIST is a plist containing export options. BACKEND is the
451 export back-end currently used."
452 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
453 (not org-html-use-infojs
)
454 (and (eq org-html-use-infojs
'when-configured
)
455 (or (not (plist-get exp-plist
:infojs-opt
))
456 (string-match "\\<view:nil\\>"
457 (plist-get exp-plist
:infojs-opt
)))))
458 (let* ((template org-html-infojs-template
)
459 (ptoc (plist-get exp-plist
:with-toc
))
460 (hlevels (plist-get exp-plist
:headline-levels
))
462 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
463 (options (plist-get exp-plist
:infojs-opt
))
464 (table org-html-infojs-opts-table
)
466 (dolist (entry table
)
467 (let* ((opt (car entry
))
469 ;; Compute default values for script option OPT from
470 ;; `org-html-infojs-options' variable.
472 (let ((default (cdr (assq opt org-html-infojs-options
))))
473 (if (and (symbolp default
) (not (memq default
'(t nil
))))
474 (plist-get exp-plist default
)
476 ;; Value set through INFOJS_OPT keyword has precedence
477 ;; over the default one.
478 (val (if (and options
479 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
481 (match-string 1 options
)
485 (replace-regexp-in-string
486 "%SCRIPT_PATH" val template t t
)))
487 (sdepth (when (integerp (read val
))
488 (setq sdepth
(min (read val
) sdepth
))))
489 (tdepth (when (integerp (read val
))
490 (setq tdepth
(min (read val
) tdepth
))))
493 ((or (eq val t
) (equal val
"t")) "1")
494 ((or (eq val nil
) (equal val
"nil")) "0")
496 (t (format "%s" val
))))
497 (push (cons var val
) style
)))))
498 ;; Now we set the depth of the *generated* TOC to SDEPTH,
499 ;; because the toc will actually determine the splitting. How
500 ;; much of the toc will actually be displayed is governed by the
502 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
503 ;; The table of contents should not show more sections than we
505 (setq tdepth
(min tdepth sdepth
))
506 (push (cons "TOC_DEPTH" tdepth
) style
)
507 ;; Build style string.
508 (setq style
(mapconcat
509 (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
513 (when (and style
(> (length style
) 0))
514 (and (string-match "%MANAGER_OPTIONS" template
)
515 (setq style
(replace-match style t t template
))
518 exp-plist
:html-head-extra
519 (concat (or (plist-get exp-plist
:html-head-extra
) "")
522 ;; This script absolutely needs the table of contents, so we
523 ;; change that setting.
524 (unless (plist-get exp-plist
:with-toc
)
525 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
526 ;; Return the modified property list.
531 (defcustom org-html-text-markup-alist
532 '((bold .
"<b>%s</b>")
533 (code .
"<code>%s</code>")
534 (italic .
"<i>%s</i>")
535 (strike-through .
"<del>%s</del>")
536 (underline .
"<span class=\"underline\">%s</span>")
537 (verbatim .
"<code>%s</code>"))
538 "Alist of HTML expressions to convert text markup.
540 The key must be a symbol among `bold', `code', `italic',
541 `strike-through', `underline' and `verbatim'. The value is
542 a formatting string to wrap fontified text with.
544 If no association can be found for a given markup, text will be
546 :group
'org-export-html
548 :package-version
'(Org .
"8.0")
549 :type
'(alist :key-type
(symbol :tag
"Markup type")
550 :value-type
(string :tag
"Format string"))
551 :options
'(bold code italic strike-through underline verbatim
))
553 (defcustom org-html-indent nil
554 "Non-nil means to indent the generated HTML.
555 Warning: non-nil may break indentation of source code blocks."
556 :group
'org-export-html
558 :package-version
'(Org .
"8.0")
561 (defcustom org-html-use-unicode-chars nil
562 "Non-nil means to use unicode characters instead of HTML entities."
563 :group
'org-export-html
565 :package-version
'(Org .
"8.0")
570 (defcustom org-html-format-drawer-function nil
571 "Function called to format a drawer in HTML code.
573 The function must accept two parameters:
574 NAME the drawer name, like \"LOGBOOK\"
575 CONTENTS the contents of the drawer.
577 The function should return the string to be exported.
579 For example, the variable could be set to the following function
580 in order to mimic default behaviour:
582 \(defun org-html-format-drawer-default \(name contents\)
583 \"Format a drawer element for HTML export.\"
585 :group
'org-export-html
587 :package-version
'(Org .
"8.0")
592 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
593 <h2 class=\"footnotes\">%s: </h2>
594 <div id=\"text-footnotes\">
598 "Format for the footnotes section.
599 Should contain a two instances of %s. The first will be replaced with the
600 language-specific word for \"Footnotes\", the second one will be replaced
601 by the footnotes themselves."
602 :group
'org-export-html
605 (defcustom org-html-footnote-format
"<sup>%s</sup>"
606 "The format for the footnote reference.
607 %s will be replaced by the footnote reference itself."
608 :group
'org-export-html
611 (defcustom org-html-footnote-separator
"<sup>, </sup>"
612 "Text used to separate footnotes."
613 :group
'org-export-html
618 (defcustom org-html-toplevel-hlevel
2
619 "The <H> level for level 1 headings in HTML export.
620 This is also important for the classes that will be wrapped around headlines
621 and outline structure. If this variable is 1, the top-level headlines will
622 be <h1>, and the corresponding classes will be outline-1, section-number-1,
623 and outline-text-1. If this is 2, all of these will get a 2 instead.
624 The default for this variable is 2, because we use <h1> for formatting the
626 :group
'org-export-html
629 (defcustom org-html-format-headline-function nil
630 "Function to format headline text.
632 This function will be called with 5 arguments:
633 TODO the todo keyword (string or nil).
634 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
635 PRIORITY the priority of the headline (integer or nil)
636 TEXT the main headline text (string).
637 TAGS the tags (string or nil).
639 The function result will be used in the section format string."
640 :group
'org-export-html
642 :package-version
'(Org .
"8.0")
647 (defcustom org-html-allow-name-attribute-in-anchors t
648 "When nil, do not set \"name\" attribute in anchors.
649 By default, anchors are formatted with both \"id\" and \"name\"
650 attributes, when appropriate."
651 :group
'org-export-html
653 :package-version
'(Org .
"8.0")
658 (defcustom org-html-format-inlinetask-function nil
659 "Function called to format an inlinetask in HTML code.
661 The function must accept six parameters:
662 TODO the todo keyword, as a string
663 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
664 PRIORITY the inlinetask priority, as a string
665 NAME the inlinetask name, as a string.
666 TAGS the inlinetask tags, as a list of strings.
667 CONTENTS the contents of the inlinetask, as a string.
669 The function should return the string to be exported."
670 :group
'org-export-html
672 :package-version
'(Org .
"8.0")
677 (defcustom org-html-with-latex org-export-with-latex
678 "Non-nil means process LaTeX math snippets.
680 When set, the exporter will process LaTeX environments and
683 This option can also be set with the +OPTIONS line,
684 e.g. \"tex:mathjax\". Allowed values are:
686 nil Ignore math snippets.
687 `verbatim' Keep everything in verbatim
688 `dvipng' Process the LaTeX fragments to images. This will also
689 include processing of non-math environments.
690 `imagemagick' Convert the LaTeX fragments to pdf files and use
691 imagemagick to convert pdf files to png files.
692 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
694 t Synonym for `mathjax'."
695 :group
'org-export-html
697 :package-version
'(Org .
"8.0")
699 (const :tag
"Do not process math in any way" nil
)
700 (const :tag
"Use dvipng to make images" dvipng
)
701 (const :tag
"Use imagemagick to make images" imagemagick
)
702 (const :tag
"Use MathJax to display math" mathjax
)
703 (const :tag
"Leave math verbatim" verbatim
)))
705 ;;;; Links :: Generic
707 (defcustom org-html-link-org-files-as-html t
708 "Non-nil means make file links to `file.org' point to `file.html'.
709 When `org-mode' is exporting an `org-mode' file to HTML, links to
710 non-html files are directly put into a href tag in HTML.
711 However, links to other Org-mode files (recognized by the
712 extension `.org.) should become links to the corresponding html
713 file, assuming that the linked `org-mode' file will also be
715 When nil, the links still point to the plain `.org' file."
716 :group
'org-export-html
719 ;;;; Links :: Inline images
721 (defcustom org-html-inline-images t
722 "Non-nil means inline images into exported HTML pages.
723 This is done using an <img> tag. When nil, an anchor with href is used to
725 :group
'org-export-html
727 :package-version
'(Org .
"8.1")
730 (defcustom org-html-inline-image-rules
731 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
732 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
733 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
734 "Rules characterizing image files that can be inlined into HTML.
735 A rule consists in an association whose key is the type of link
736 to consider, and value is a regexp that will be matched against
738 :group
'org-export-html
740 :package-version
'(Org .
"8.0")
741 :type
'(alist :key-type
(string :tag
"Type")
742 :value-type
(regexp :tag
"Path")))
746 (defcustom org-html-protect-char-alist
750 "Alist of characters to be converted by `org-html-protect'."
751 :group
'org-export-html
752 :type
'(repeat (cons (string :tag
"Character")
753 (string :tag
"HTML equivalent"))))
757 (defcustom org-html-htmlize-output-type
'inline-css
758 "Output type to be used by htmlize when formatting code snippets.
759 Choices are `css', to export the CSS selectors only, or `inline-css', to
760 export the CSS attribute values inline in the HTML. We use as default
761 `inline-css', in order to make the resulting HTML self-containing.
763 However, this will fail when using Emacs in batch mode for export, because
764 then no rich font definitions are in place. It will also not be good if
765 people with different Emacs setup contribute HTML files to a website,
766 because the fonts will represent the individual setups. In these cases,
767 it is much better to let Org/Htmlize assign classes only, and to use
768 a style file to define the look of these classes.
769 To get a start for your css file, start Emacs session and make sure that
770 all the faces you are interested in are defined, for example by loading files
771 in all modes you want. Then, use the command
772 \\[org-html-htmlize-generate-css] to extract class definitions."
773 :group
'org-export-html
774 :type
'(choice (const css
) (const inline-css
)))
776 (defcustom org-html-htmlize-font-prefix
"org-"
777 "The prefix for CSS class names for htmlize font specifications."
778 :group
'org-export-html
783 (defcustom org-html-table-default-attributes
784 '(:border
"2" :cellspacing
"0" :cellpadding
"6" :rules
"groups" :frame
"hsides")
785 "Default attributes and values which will be used in table tags.
786 This is a plist where attributes are symbols, starting with
787 colons, and values are strings.
789 When exporting to HTML5, these values will be disregarded."
790 :group
'org-export-html
792 :package-version
'(Org .
"8.0")
793 :type
'(plist :key-type
(symbol :tag
"Property")
794 :value-type
(string :tag
"Value")))
796 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
797 "The opening tag for table header fields.
798 This is customizable so that alignment options can be specified.
799 The first %s will be filled with the scope of the field, either row or col.
800 The second %s will be replaced by a style entry to align the field.
801 See also the variable `org-html-table-use-header-tags-for-first-column'.
802 See also the variable `org-html-table-align-individual-fields'."
803 :group
'org-export-html
804 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
806 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
807 "The opening tag for table data fields.
808 This is customizable so that alignment options can be specified.
809 The first %s will be filled with the scope of the field, either row or col.
810 The second %s will be replaced by a style entry to align the field.
811 See also the variable `org-html-table-align-individual-fields'."
812 :group
'org-export-html
813 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
815 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
816 "The opening and ending tags for table rows.
817 This is customizable so that alignment options can be specified.
818 Instead of strings, these can be Lisp forms that will be
819 evaluated for each row in order to construct the table row tags.
821 During evaluation, these variables will be dynamically bound so that
824 `row-number': row number (0 is the first row)
825 `rowgroup-number': group number of current row
826 `start-rowgroup-p': non-nil means the row starts a group
827 `end-rowgroup-p': non-nil means the row ends a group
828 `top-row-p': non-nil means this is the top row
829 `bottom-row-p': non-nil means this is the bottom row
833 \(setq org-html-table-row-tags
834 (cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
835 (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
836 (t (if (= (mod row-number 2) 1)
837 \"<tr class=\\\"tr-odd\\\">\"
838 \"<tr class=\\\"tr-even\\\">\")))
841 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
842 and the bottom row, and otherwise alternate between \"tr-odd\" and
843 \"tr-even\" for odd and even rows."
844 :group
'org-export-html
846 (choice :tag
"Opening tag"
847 (string :tag
"Specify")
849 (choice :tag
"Closing tag"
850 (string :tag
"Specify")
853 (defcustom org-html-table-align-individual-fields t
854 "Non-nil means attach style attributes for alignment to each table field.
855 When nil, alignment will only be specified in the column tags, but this
856 is ignored by some browsers (like Firefox, Safari). Opera does it right
858 :group
'org-export-html
861 (defcustom org-html-table-use-header-tags-for-first-column nil
862 "Non-nil means format column one in tables with header tags.
863 When nil, also column one will use data tags."
864 :group
'org-export-html
867 (defcustom org-html-table-caption-above t
868 "When non-nil, place caption string at the beginning of the table.
869 Otherwise, place it near the end."
870 :group
'org-export-html
875 (defcustom org-html-tag-class-prefix
""
876 "Prefix to class names for TODO keywords.
877 Each tag gets a class given by the tag itself, with this prefix.
878 The default prefix is empty because it is nice to just use the keyword
879 as a class name. But if you get into conflicts with other, existing
880 CSS classes, then this prefix can be very useful."
881 :group
'org-export-html
884 ;;;; Template :: Generic
886 (defcustom org-html-extension
"html"
887 "The extension for exported HTML files."
888 :group
'org-export-html
891 (defcustom org-html-xml-declaration
892 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
893 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
894 "The extension for exported HTML files.
895 %s will be replaced with the charset of the exported file.
896 This may be a string, or an alist with export extensions
897 and corresponding declarations.
899 This declaration only applies when exporting to XHTML."
900 :group
'org-export-html
902 (string :tag
"Single declaration")
903 (repeat :tag
"Dependent on extension"
904 (cons (string :tag
"Extension")
905 (string :tag
"Declaration")))))
907 (defcustom org-html-coding-system
'utf-8
908 "Coding system for HTML export.
909 Use utf-8 as the default value."
910 :group
'org-export-html
912 :package-version
'(Org .
"8.0")
913 :type
'coding-system
)
915 (defcustom org-html-doctype
"xhtml-strict"
916 "Document type definition to use for exported HTML files.
917 Can be set with the in-buffer HTML_DOCTYPE property or for
918 publishing, with :html-doctype."
919 :group
'org-export-html
921 :package-version
'(Org .
"8.0")
924 (defcustom org-html-html5-fancy nil
925 "Non-nil means using new HTML5 elements.
926 This variable is ignored for anything other than HTML5 export.
928 For compatibility with Internet Explorer, it's probably a good
929 idea to download some form of the html5shiv (for instance
930 https://code.google.com/p/html5shiv/) and add it to your
931 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
932 versions 8 and below."
933 :group
'org-export-html
935 :package-version
'(Org .
"8.0")
938 (defcustom org-html-container-element
"div"
939 "HTML element to use for wrapping top level sections.
940 Can be set with the in-buffer HTML_CONTAINER property or for
941 publishing, with :html-container.
943 Note that changing the default will prevent you from using
944 org-info.js for your website."
945 :group
'org-export-html
947 :package-version
'(Org .
"8.0")
950 (defcustom org-html-divs
951 '((preamble "div" "preamble")
952 (content "div" "content")
953 (postamble "div" "postamble"))
954 "Alist of the three section elements for HTML export.
955 The car of each entry is one of 'preamble, 'content or 'postamble.
956 The cdrs of each entry are the ELEMENT_TYPE and ID for each
957 section of the exported document.
959 Note that changing the default will prevent you from using
960 org-info.js for your website."
961 :group
'org-export-html
963 :package-version
'(Org .
"8.0")
964 :type
'(list :greedy t
965 (list :tag
"Preamble"
966 (const :format
"" preamble
)
967 (string :tag
"element") (string :tag
" id"))
969 (const :format
"" content
)
970 (string :tag
"element") (string :tag
" id"))
971 (list :tag
"Postamble" (const :format
"" postamble
)
972 (string :tag
" id") (string :tag
"element"))))
974 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
975 "Format used for timestamps in preamble, postamble and metadata.
976 See `format-time-string' for more information on its components."
977 :group
'org-export-html
979 :package-version
'(Org .
"8.0")
982 ;;;; Template :: Mathjax
984 (defcustom org-html-mathjax-options
985 '((path "http://orgmode.org/mathjax/MathJax.js")
990 "Options for MathJax setup.
992 path The path where to find MathJax
993 scale Scaling for the HTML-CSS backend, usually between 100 and 133
994 align How to align display math: left, center, or right
995 indent If align is not center, how far from the left/right side?
996 mathml Should a MathML player be used if available?
997 This is faster and reduces bandwidth use, but currently
998 sometimes has lower spacing quality. Therefore, the default is
999 nil. When browsers get better, this switch can be flipped.
1001 You can also customize this for each buffer, using something like
1003 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
1004 :group
'org-export-html
1005 :type
'(list :greedy t
1006 (list :tag
"path (the path from where to load MathJax.js)"
1007 (const :format
" " path
) (string))
1008 (list :tag
"scale (scaling for the displayed math)"
1009 (const :format
" " scale
) (string))
1010 (list :tag
"align (alignment of displayed equations)"
1011 (const :format
" " align
) (string))
1012 (list :tag
"indent (indentation with left or right alignment)"
1013 (const :format
" " indent
) (string))
1014 (list :tag
"mathml (should MathML display be used is possible)"
1015 (const :format
" " mathml
) (boolean))))
1017 (defcustom org-html-mathjax-template
1018 "<script type=\"text/javascript\" src=\"%PATH\"></script>
1019 <script type=\"text/javascript\">
1020 <!--/*--><![CDATA[/*><!--*/
1021 MathJax.Hub.Config({
1022 // Only one of the two following lines, depending on user settings
1023 // First allows browser-native MathML display, second forces HTML/CSS
1024 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
1025 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
1026 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
1027 \"TeX/noUndefined.js\"],
1029 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
1030 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
1031 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
1032 ignoreClass: \"tex2jax_ignore\",
1033 processEscapes: false,
1034 processEnvironments: true,
1037 showProcessingMessages: true,
1038 displayAlign: \"%ALIGN\",
1039 displayIndent: \"%INDENT\",
1043 availableFonts: [\"STIX\",\"TeX\"],
1044 preferredFont: \"TeX\",
1060 "The MathJax setup for XHTML files."
1061 :group
'org-export-html
1064 ;;;; Template :: Postamble
1066 (defcustom org-html-postamble
'auto
1067 "Non-nil means insert a postamble in HTML export.
1069 When set to 'auto, check against the
1070 `org-export-with-author/email/creator/date' variables to set the
1071 content of the postamble. When set to a string, use this string
1072 as the postamble. When t, insert a string as defined by the
1073 formatting string in `org-html-postamble-format'.
1075 When set to a function, apply this function and insert the
1076 returned string. The function takes the property list of export
1077 options as its only argument.
1079 Setting :html-postamble in publishing projects will take
1080 precedence over this variable."
1081 :group
'org-export-html
1082 :type
'(choice (const :tag
"No postamble" nil
)
1083 (const :tag
"Auto postamble" auto
)
1084 (const :tag
"Default formatting string" t
)
1085 (string :tag
"Custom formatting string")
1086 (function :tag
"Function (must return a string)")))
1088 (defcustom org-html-postamble-format
1089 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1090 <p class=\"date\">Date: %d</p>
1091 <p class=\"creator\">%c</p>
1092 <p class=\"validation\">%v</p>"))
1093 "Alist of languages and format strings for the HTML postamble.
1095 The first element of each list is the language code, as used for
1096 the LANGUAGE keyword. See `org-export-default-language'.
1098 The second element of each list is a format string to format the
1099 postamble itself. This format string can contain these elements:
1101 %t stands for the title.
1102 %a stands for the author's name.
1103 %e stands for the author's email.
1104 %d stands for the date.
1105 %c will be replaced by `org-html-creator-string'.
1106 %v will be replaced by `org-html-validation-link'.
1107 %T will be replaced by the export time.
1108 %C will be replaced by the last modification time.
1110 If you need to use a \"%\" character, you need to escape it
1112 :group
'org-export-html
1114 (list (string :tag
"Language")
1115 (string :tag
"Format string"))))
1117 (defcustom org-html-validation-link
1118 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1119 "Link to HTML validation service."
1120 :group
'org-export-html
1123 (defcustom org-html-creator-string
1124 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1126 (if (fboundp 'org-version
) (org-version) "unknown version"))
1127 "Information about the creator of the HTML document.
1128 This option can also be set on with the CREATOR keyword."
1129 :group
'org-export-html
1131 :package-version
'(Org .
"8.0")
1132 :type
'(string :tag
"Creator string"))
1134 ;;;; Template :: Preamble
1136 (defcustom org-html-preamble t
1137 "Non-nil means insert a preamble in HTML export.
1139 When t, insert a string as defined by the formatting string in
1140 `org-html-preamble-format'. When set to a string, use this
1141 formatting string instead (see `org-html-postamble-format' for an
1142 example of such a formatting string).
1144 When set to a function, apply this function and insert the
1145 returned string. The function takes the property list of export
1146 options as its only argument.
1148 Setting :html-preamble in publishing projects will take
1149 precedence over this variable."
1150 :group
'org-export-html
1151 :type
'(choice (const :tag
"No preamble" nil
)
1152 (const :tag
"Default preamble" t
)
1153 (string :tag
"Custom formatting string")
1154 (function :tag
"Function (must return a string)")))
1156 (defcustom org-html-preamble-format
'(("en" ""))
1157 "Alist of languages and format strings for the HTML preamble.
1159 The first element of each list is the language code, as used for
1160 the LANGUAGE keyword. See `org-export-default-language'.
1162 The second element of each list is a format string to format the
1163 preamble itself. This format string can contain these elements:
1165 %t stands for the title.
1166 %a stands for the author's name.
1167 %e stands for the author's email.
1168 %d stands for the date.
1169 %c will be replaced by `org-html-creator-string'.
1170 %v will be replaced by `org-html-validation-link'.
1171 %T will be replaced by the export time.
1172 %C will be replaced by the last modification time.
1174 If you need to use a \"%\" character, you need to escape it
1177 See the default value of `org-html-postamble-format' for an
1179 :group
'org-export-html
1181 (list (string :tag
"Language")
1182 (string :tag
"Format string"))))
1184 (defcustom org-html-link-up
""
1185 "Where should the \"UP\" link of exported HTML pages lead?"
1186 :group
'org-export-html
1187 :type
'(string :tag
"File or URL"))
1189 (defcustom org-html-link-home
""
1190 "Where should the \"HOME\" link of exported HTML pages lead?"
1191 :group
'org-export-html
1192 :type
'(string :tag
"File or URL"))
1194 (defcustom org-html-link-use-abs-url nil
1195 "Should we prepend relative links with HTML_LINK_HOME?"
1196 :group
'org-export-html
1198 :package-version
'(Org .
"8.1")
1201 (defcustom org-html-home
/up-format
1202 "<div id=\"org-div-home-and-up\">
1203 <a accesskey=\"h\" href=\"%s\"> UP </a>
1205 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1207 "Snippet used to insert the HOME and UP links.
1208 This is a format string, the first %s will receive the UP link,
1209 the second the HOME link. If both `org-html-link-up' and
1210 `org-html-link-home' are empty, the entire snippet will be
1212 :group
'org-export-html
1215 ;;;; Template :: Scripts
1217 (define-obsolete-variable-alias
1218 'org-html-style-include-scripts
'org-html-head-include-scripts
"24.4")
1219 (defcustom org-html-head-include-scripts t
1220 "Non-nil means include the JavaScript snippets in exported HTML files.
1221 The actual script is defined in `org-html-scripts' and should
1223 :group
'org-export-html
1225 :package-version
'(Org .
"8.0")
1228 ;;;; Template :: Styles
1230 (define-obsolete-variable-alias
1231 'org-html-style-include-default
'org-html-head-include-default-style
"24.4")
1232 (defcustom org-html-head-include-default-style t
1233 "Non-nil means include the default style in exported HTML files.
1234 The actual style is defined in `org-html-style-default' and
1235 should not be modified. Use `org-html-head' to use your own
1237 :group
'org-export-html
1239 :package-version
'(Org .
"8.0")
1242 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1244 (define-obsolete-variable-alias 'org-html-style
'org-html-head
"24.4")
1245 (defcustom org-html-head
""
1246 "Org-wide head definitions for exported HTML files.
1248 This variable can contain the full HTML structure to provide a
1249 style, including the surrounding HTML tags. You can consider
1250 including definitions for the following classes: title, todo,
1251 done, timestamp, timestamp-kwd, tag, target.
1253 For example, a valid value would be:
1255 <style type=\"text/css\">
1257 p { font-weight: normal; color: gray; }
1258 h1 { color: black; }
1259 .title { text-align: center; }
1260 .todo, .timestamp-kwd { color: red; }
1261 .done { color: green; }
1265 If you want to refer to an external style, use something like
1267 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1269 As the value of this option simply gets inserted into the HTML
1270 <head> header, you can use it to add any arbitrary text to the
1273 You can set this on a per-file basis using #+HTML_HEAD:,
1274 or for publication projects using the :html-head property."
1275 :group
'org-export-html
1277 :package-version
'(Org .
"8.0")
1280 (put 'org-html-head
'safe-local-variable
'stringp
)
1282 (defcustom org-html-head-extra
""
1283 "More head information to add in the HTML output.
1285 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1286 or for publication projects using the :html-head-extra property."
1287 :group
'org-export-html
1289 :package-version
'(Org .
"8.0")
1292 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1296 (defcustom org-html-todo-kwd-class-prefix
""
1297 "Prefix to class names for TODO keywords.
1298 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1299 The default prefix is empty because it is nice to just use the keyword
1300 as a class name. But if you get into conflicts with other, existing
1301 CSS classes, then this prefix can be very useful."
1302 :group
'org-export-html
1306 ;;; Internal Functions
1308 (defun org-html-xhtml-p (info)
1309 (let ((dt (downcase (plist-get info
:html-doctype
))))
1310 (string-match-p "xhtml" dt
)))
1312 (defun org-html-html5-p (info)
1313 (let ((dt (downcase (plist-get info
:html-doctype
))))
1314 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1316 (defun org-html-close-tag (tag attr info
)
1317 (concat "<" tag
" " attr
1318 (if (org-html-xhtml-p info
) " />" ">")))
1320 (defun org-html-doctype (info)
1321 "Return correct html doctype tag from `org-html-doctype-alist',
1322 or the literal value of :html-doctype from INFO if :html-doctype
1323 is not found in the alist.
1324 INFO is a plist used as a communication channel."
1325 (let ((dt (plist-get info
:html-doctype
)))
1326 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1328 (defun org-html--make-attribute-string (attributes)
1329 "Return a list of attributes, as a string.
1330 ATTRIBUTES is a plist where values are either strings or nil. An
1331 attributes with a nil value will be omitted from the result."
1333 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1334 (cond ((null item
) (pop output
))
1335 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1336 (t (let ((key (car output
))
1337 (value (replace-regexp-in-string
1338 "\"" """ (org-html-encode-plain-text item
))))
1339 (setcar output
(format "%s=\"%s\"" key value
))))))))
1341 (defun org-html--wrap-image (contents info
&optional caption label
)
1342 "Wrap CONTENTS string within an appropriate environment for images.
1343 INFO is a plist used as a communication channel. When optional
1344 arguments CAPTION and LABEL are given, use them for caption and
1346 (let ((html5-fancy (and (org-html-html5-p info
)
1347 (plist-get info
:html-html5-fancy
))))
1348 (format (if html5-fancy
"\n<figure%s>%s%s\n</figure>"
1349 "\n<div%s class=\"figure\">%s%s\n</div>")
1351 (if (not (org-string-nw-p label
)) ""
1352 (format " id=\"%s\"" (org-export-solidify-link-text label
)))
1354 (format "\n<p>%s</p>" contents
)
1356 (if (not (org-string-nw-p caption
)) ""
1357 (format (if html5-fancy
"\n<figcaption>%s</figcaption>"
1361 (defun org-html--format-image (source attributes info
)
1362 "Return \"img\" tag with given SOURCE and ATTRIBUTES.
1363 SOURCE is a string specifying the location of the image.
1364 ATTRIBUTES is a plist, as returned by
1365 `org-export-read-attribute'. INFO is a plist used as
1366 a communication channel."
1369 (org-html--make-attribute-string
1372 :alt
(if (string-match-p "^ltxpng/" source
)
1373 (org-html-encode-plain-text
1374 (org-find-text-property-in-string 'org-latex-src source
))
1375 (file-name-nondirectory source
)))
1379 (defun org-html--textarea-block (element)
1380 "Transcode ELEMENT into a textarea block.
1381 ELEMENT is either a src block or an example block."
1382 (let* ((code (car (org-export-unravel-code element
)))
1383 (attr (org-export-read-attribute :attr_html element
)))
1384 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1385 (or (plist-get attr
:width
) 80)
1386 (or (plist-get attr
:height
) (org-count-lines code
))
1389 (defun org-html--has-caption-p (element &optional info
)
1390 "Non-nil when ELEMENT has a caption affiliated keyword.
1391 INFO is a plist used as a communication channel. This function
1392 is meant to be used as a predicate for `org-export-get-ordinal' or
1393 a value to `org-html-standalone-image-predicate'."
1394 (org-element-property :caption element
))
1398 (defun org-html-htmlize-region-for-paste (beg end
)
1399 "Convert the region between BEG and END to HTML, using htmlize.el.
1400 This is much like `htmlize-region-for-paste', only that it uses
1401 the settings define in the org-... variables."
1402 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1403 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1404 (htmlbuf (htmlize-region beg end
)))
1406 (with-current-buffer htmlbuf
1407 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1408 (plist-get htmlize-buffer-places
'content-end
)))
1409 (kill-buffer htmlbuf
))))
1412 (defun org-html-htmlize-generate-css ()
1413 "Create the CSS for all font definitions in the current Emacs session.
1414 Use this to create face definitions in your CSS style file that can then
1415 be used by code snippets transformed by htmlize.
1416 This command just produces a buffer that contains class definitions for all
1417 faces used in the current Emacs session. You can copy and paste the ones you
1418 need into your CSS file.
1420 If you then set `org-html-htmlize-output-type' to `css', calls
1421 to the function `org-html-htmlize-region-for-paste' will
1422 produce code that uses these same face definitions."
1425 (and (get-buffer "*html*") (kill-buffer "*html*"))
1427 (let ((fl (face-list))
1428 (htmlize-css-name-prefix "org-")
1429 (htmlize-output-type 'css
)
1431 (while (setq f
(pop fl
)
1432 i
(and f
(face-attribute f
:inherit
)))
1433 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1434 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1435 (htmlize-region (point-min) (point-max))))
1436 (org-pop-to-buffer-same-window "*html*")
1437 (goto-char (point-min))
1438 (if (re-search-forward "<style" nil t
)
1439 (delete-region (point-min) (match-beginning 0)))
1440 (if (re-search-forward "</style>" nil t
)
1441 (delete-region (1+ (match-end 0)) (point-max)))
1442 (beginning-of-line 1)
1443 (if (looking-at " +") (replace-match ""))
1444 (goto-char (point-min)))
1446 (defun org-html--make-string (n string
)
1447 "Build a string by concatenating N times STRING."
1448 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1450 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1451 "Turn todo keyword KWD into a valid class name.
1452 Replaces invalid characters with \"_\"."
1454 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1455 (setq kwd
(replace-match "_" t t kwd
))))
1458 (defun org-html-format-footnote-reference (n def refcnt
)
1459 "Format footnote reference N with definition DEF into HTML."
1460 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1461 (format org-html-footnote-format
1462 (let* ((id (format "fnr.%s%s" n extra
))
1463 (href (format " href=\"#fn.%s\"" n
))
1464 (attributes (concat " class=\"footref\"" href
)))
1465 (org-html--anchor id n attributes
)))))
1467 (defun org-html-format-footnotes-section (section-name definitions
)
1468 "Format footnotes section SECTION-NAME."
1469 (if (not definitions
) ""
1470 (format org-html-footnotes-section section-name definitions
)))
1472 (defun org-html-format-footnote-definition (fn)
1473 "Format the footnote definition FN."
1474 (let ((n (car fn
)) (def (cdr fn
)))
1476 "<div class=\"footdef\">%s %s</div>\n"
1477 (format org-html-footnote-format
1478 (let* ((id (format "fn.%s" n
))
1479 (href (format " href=\"#fnr.%s\"" n
))
1480 (attributes (concat " class=\"footnum\"" href
)))
1481 (org-html--anchor id n attributes
)))
1484 (defun org-html-footnote-section (info)
1485 "Format the footnote section.
1486 INFO is a plist used as a communication channel."
1487 (let* ((fn-alist (org-export-collect-footnote-definitions
1488 (plist-get info
:parse-tree
) info
))
1490 (loop for
(n type raw
) in fn-alist collect
1491 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1492 (org-trim (org-export-data raw info
))
1494 (org-trim (org-export-data raw info
))))))))
1496 (org-html-format-footnotes-section
1497 (org-html--translate "Footnotes" info
)
1500 (mapconcat 'org-html-format-footnote-definition fn-alist
"\n"))))))
1505 (defun org-html--build-meta-info (info)
1506 "Return meta tags for exported document.
1507 INFO is a plist used as a communication channel."
1508 (let ((protect-string
1510 (replace-regexp-in-string
1511 "\"" """ (org-html-encode-plain-text str
))))
1512 (title (org-export-data (plist-get info
:title
) info
))
1513 (author (and (plist-get info
:with-author
)
1514 (let ((auth (plist-get info
:author
)))
1516 ;; Return raw Org syntax, skipping non
1517 ;; exportable objects.
1518 (org-element-interpret-data
1519 (org-element-map auth
1520 (cons 'plain-text org-element-all-objects
)
1521 'identity info
))))))
1522 (description (plist-get info
:description
))
1523 (keywords (plist-get info
:keywords
))
1524 (charset (or (and org-html-coding-system
1525 (fboundp 'coding-system-get
)
1526 (coding-system-get org-html-coding-system
1530 (format "<title>%s</title>\n" title
)
1531 (when (plist-get info
:time-stamp-file
)
1533 (concat "<!-- " org-html-metadata-timestamp-format
" -->\n")))
1535 (if (org-html-html5-p info
)
1536 (org-html-close-tag "meta" " charset=\"%s\"" info
)
1538 "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1541 (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info
)
1543 (and (org-string-nw-p author
)
1545 (org-html-close-tag "meta"
1546 (format " name=\"author\" content=\"%s\""
1547 (funcall protect-string author
))
1550 (and (org-string-nw-p description
)
1552 (org-html-close-tag "meta"
1553 (format " name=\"description\" content=\"%s\"\n"
1554 (funcall protect-string description
))
1557 (and (org-string-nw-p keywords
)
1559 (org-html-close-tag "meta"
1560 (format " name=\"keywords\" content=\"%s\""
1561 (funcall protect-string keywords
))
1565 (defun org-html--build-head (info)
1566 "Return information for the <head>..</head> of the HTML output.
1567 INFO is a plist used as a communication channel."
1568 (org-element-normalize-string
1570 (when (plist-get info
:html-head-include-default-style
)
1571 (org-element-normalize-string org-html-style-default
))
1572 (org-element-normalize-string (plist-get info
:html-head
))
1573 (org-element-normalize-string (plist-get info
:html-head-extra
))
1574 (when (and (plist-get info
:html-htmlized-css-url
)
1575 (eq org-html-htmlize-output-type
'css
))
1576 (org-html-close-tag "link"
1577 (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1578 (plist-get info
:html-htmlized-css-url
))
1580 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1582 (defun org-html--build-mathjax-config (info)
1583 "Insert the user setup into the mathjax template.
1584 INFO is a plist used as a communication channel."
1585 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1586 (org-element-map (plist-get info
:parse-tree
)
1587 '(latex-fragment latex-environment
) 'identity info t
))
1588 (let ((template org-html-mathjax-template
)
1589 (options org-html-mathjax-options
)
1590 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1591 name val
(yes " ") (no "// ") x
)
1594 (setq name
(car e
) val
(nth 1 e
))
1595 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1596 (setq val
(car (read-from-string
1597 (substring in-buffer
(match-end 0))))))
1598 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1599 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1600 (setq template
(replace-match val t t template
))))
1602 (setq val
(nth 1 (assq 'mathml options
)))
1603 (if (string-match (concat "\\<mathml:") in-buffer
)
1604 (setq val
(car (read-from-string
1605 (substring in-buffer
(match-end 0))))))
1606 ;; Exchange prefixes depending on mathml setting.
1607 (if (not val
) (setq x yes yes no no x
))
1608 ;; Replace cookies to turn on or off the config/jax lines.
1609 (if (string-match ":MMLYES:" template
)
1610 (setq template
(replace-match yes t t template
)))
1611 (if (string-match ":MMLNO:" template
)
1612 (setq template
(replace-match no t t template
)))
1613 ;; Return the modified template.
1614 (org-element-normalize-string template
))))
1616 (defun org-html-format-spec (info)
1617 "Return format specification for elements that can be
1618 used in the preamble or postamble."
1619 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1620 (?d .
,(org-export-data (org-export-get-date info
) info
))
1621 (?T .
,(format-time-string org-html-metadata-timestamp-format
))
1622 (?a .
,(org-export-data (plist-get info
:author
) info
))
1625 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1626 (split-string (plist-get info
:email
) ",+ *")
1628 (?c .
,(plist-get info
:creator
))
1629 (?C .
,(let ((file (plist-get info
:input-file
)))
1630 (format-time-string org-html-metadata-timestamp-format
1631 (if file
(nth 5 (file-attributes file
))
1633 (?v .
,(or org-html-validation-link
""))))
1635 (defun org-html--build-pre/postamble
(type info
)
1636 "Return document preamble or postamble as a string, or nil.
1637 TYPE is either 'preamble or 'postamble, INFO is a plist used as a
1638 communication channel."
1639 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1640 (spec (org-html-format-spec info
)))
1642 (let ((section-contents
1643 (if (functionp section
) (funcall section info
)
1645 ((stringp section
) (format-spec section spec
))
1647 (let ((date (cdr (assq ?d spec
)))
1648 (author (cdr (assq ?a spec
)))
1649 (email (cdr (assq ?e spec
)))
1650 (creator (cdr (assq ?c spec
)))
1651 (timestamp (cdr (assq ?T spec
)))
1652 (validation-link (cdr (assq ?v spec
))))
1654 (when (and (plist-get info
:with-date
)
1655 (org-string-nw-p date
))
1656 (format "<p class=\"date\">%s: %s</p>\n"
1657 (org-html--translate "Date" info
)
1659 (when (and (plist-get info
:with-author
)
1660 (org-string-nw-p author
))
1661 (format "<p class=\"author\">%s: %s</p>\n"
1662 (org-html--translate "Author" info
)
1664 (when (and (plist-get info
:with-email
)
1665 (org-string-nw-p email
))
1666 (format "<p class=\"email\">%s: %s</p>\n"
1667 (org-html--translate "Email" info
)
1669 (when (plist-get info
:time-stamp-file
)
1671 "<p class=\"date\">%s: %s</p>\n"
1672 (org-html--translate "Created" info
)
1673 (format-time-string org-html-metadata-timestamp-format
)))
1674 (when (plist-get info
:with-creator
)
1675 (format "<p class=\"creator\">%s</p>\n" creator
))
1676 (format "<p class=\"validation\">%s</p>\n"
1680 (plist-get info
:language
)
1682 (format "org-html-%s-format" type
)))))
1687 (intern (format "org-html-%s-format" type
))))))
1689 (when (org-string-nw-p section-contents
)
1691 (format "<%s id=\"%s\" class=\"%s\">\n"
1692 (nth 1 (assq type org-html-divs
))
1693 (nth 2 (assq type org-html-divs
))
1694 org-html--pre
/postamble-class
)
1695 (org-element-normalize-string section-contents
)
1696 (format "</%s>\n" (nth 1 (assq type org-html-divs
)))))))))
1698 (defun org-html-inner-template (contents info
)
1699 "Return body of document string after HTML conversion.
1700 CONTENTS is the transcoded contents string. INFO is a plist
1701 holding export options."
1703 ;; Table of contents.
1704 (let ((depth (plist-get info
:with-toc
)))
1705 (when depth
(org-html-toc depth info
)))
1706 ;; Document contents.
1708 ;; Footnotes section.
1709 (org-html-footnote-section info
)))
1711 (defun org-html-template (contents info
)
1712 "Return complete document string after HTML conversion.
1713 CONTENTS is the transcoded contents string. INFO is a plist
1714 holding export options."
1716 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1717 (let ((decl (or (and (stringp org-html-xml-declaration
)
1718 org-html-xml-declaration
)
1719 (cdr (assoc (plist-get info
:html-extension
)
1720 org-html-xml-declaration
))
1721 (cdr (assoc "html" org-html-xml-declaration
))
1724 (when (not (or (eq nil decl
) (string= "" decl
)))
1727 (or (and org-html-coding-system
1728 (fboundp 'coding-system-get
)
1729 (coding-system-get org-html-coding-system
'mime-charset
))
1731 (org-html-doctype info
)
1734 (when (org-html-xhtml-p info
)
1736 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1737 (plist-get info
:language
) (plist-get info
:language
)))
1740 (org-html--build-meta-info info
)
1741 (org-html--build-head info
)
1742 (org-html--build-mathjax-config info
)
1745 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1746 (link-home (org-trim (plist-get info
:html-link-home
))))
1747 (unless (and (string= link-up
"") (string= link-home
""))
1748 (format org-html-home
/up-format
1749 (or link-up link-home
)
1750 (or link-home link-up
))))
1752 (org-html--build-pre/postamble
'preamble info
)
1753 ;; Document contents.
1754 (format "<%s id=\"%s\">\n"
1755 (nth 1 (assq 'content org-html-divs
))
1756 (nth 2 (assq 'content org-html-divs
)))
1758 (let ((title (plist-get info
:title
)))
1759 (format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title
"") info
)))
1762 (nth 1 (assq 'content org-html-divs
)))
1764 (org-html--build-pre/postamble
'postamble info
)
1765 ;; Closing document.
1766 "</body>\n</html>"))
1768 (defun org-html--translate (s info
)
1769 "Translate string S according to specified language.
1770 INFO is a plist used as a communication channel."
1771 (org-export-translate s
:html info
))
1775 (defun org-html--anchor (&optional id desc attributes
)
1776 "Format a HTML anchor."
1777 (let* ((name (and org-html-allow-name-attribute-in-anchors id
))
1778 (attributes (concat (and id
(format " id=\"%s\"" id
))
1779 (and name
(format " name=\"%s\"" name
))
1781 (format "<a%s>%s</a>" attributes
(or desc
""))))
1785 (defun org-html--todo (todo)
1786 "Format TODO keywords into HTML."
1788 (format "<span class=\"%s %s%s\">%s</span>"
1789 (if (member todo org-done-keywords
) "done" "todo")
1790 org-html-todo-kwd-class-prefix
(org-html-fix-class-name todo
)
1795 (defun org-html--tags (tags)
1796 "Format TAGS into HTML."
1798 (format "<span class=\"tag\">%s</span>"
1801 (format "<span class=\"%s\">%s</span>"
1802 (concat org-html-tag-class-prefix
1803 (org-html-fix-class-name tag
))
1809 (defun* org-html-format-headline
1810 (todo todo-type priority text tags
1811 &key level section-number headline-label
&allow-other-keys
)
1812 "Format a headline in HTML."
1813 (let ((section-number
1814 (when section-number
1815 (format "<span class=\"section-number-%d\">%s</span> "
1816 level section-number
)))
1817 (todo (org-html--todo todo
))
1818 (tags (org-html--tags tags
)))
1819 (concat section-number todo
(and todo
" ") text
1820 (and tags
"   ") tags
)))
1824 (defun org-html-fontify-code (code lang
)
1825 "Color CODE with htmlize library.
1826 CODE is a string representing the source code to colorize. LANG
1827 is the language used for CODE, as a string, or nil."
1830 ;; Case 1: No lang. Possibly an example block.
1832 ;; Simple transcoding.
1833 (org-html-encode-plain-text code
))
1834 ;; Case 2: No htmlize or an inferior version of htmlize
1835 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1837 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1838 ;; Simple transcoding.
1839 (org-html-encode-plain-text code
))
1842 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1843 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1845 ;; Case 1: Language is not associated with any Emacs mode
1846 ((not (functionp lang-mode
))
1847 ;; Simple transcoding.
1848 (org-html-encode-plain-text code
))
1849 ;; Case 2: Default. Fontify code.
1852 (setq code
(with-temp-buffer
1853 ;; Switch to language-specific mode.
1857 (font-lock-fontify-buffer)
1858 ;; Remove formatting on newline characters.
1860 (let ((beg (point-min))
1863 (while (progn (end-of-line) (< (point) end
))
1864 (put-text-property (point) (1+ (point)) 'face nil
)
1867 (set-buffer-modified-p nil
)
1869 (org-html-htmlize-region-for-paste
1870 (point-min) (point-max))))
1871 ;; Strip any enclosing <pre></pre> tags.
1872 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
1873 (end (and beg
(string-match "</pre>\\'" code
))))
1874 (if (and beg end
) (substring code beg end
) code
)))))))))
1876 (defun org-html-do-format-code
1877 (code &optional lang refs retain-labels num-start
)
1878 "Format CODE string as source code.
1879 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1880 respectively, the language of the source code, as a string, an
1881 alist between line numbers and references (as returned by
1882 `org-export-unravel-code'), a boolean specifying if labels should
1883 appear in the source code, and the number associated to the first
1885 (let* ((code-lines (org-split-string code
"\n"))
1886 (code-length (length code-lines
))
1890 (length (number-to-string (+ code-length num-start
))))))
1891 (code (org-html-fontify-code code lang
)))
1892 (org-export-format-code
1894 (lambda (loc line-num ref
)
1897 ;; Add line number, if needed.
1899 (format "<span class=\"linenr\">%s</span>"
1900 (format num-fmt line-num
)))
1901 ;; Transcoded src line.
1903 ;; Add label, if needed.
1904 (when (and ref retain-labels
) (format " (%s)" ref
))))
1905 ;; Mark transcoded line as an anchor, if needed.
1907 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1911 (defun org-html-format-code (element info
)
1912 "Format contents of ELEMENT as source code.
1913 ELEMENT is either an example block or a src block. INFO is
1914 a plist used as a communication channel."
1915 (let* ((lang (org-element-property :language element
))
1916 ;; Extract code and references.
1917 (code-info (org-export-unravel-code element
))
1918 (code (car code-info
))
1919 (refs (cdr code-info
))
1920 ;; Does the src block contain labels?
1921 (retain-labels (org-element-property :retain-labels element
))
1922 ;; Does it have line numbers?
1923 (num-start (case (org-element-property :number-lines element
)
1924 (continued (org-export-get-loc element info
))
1926 (org-html-do-format-code code lang refs retain-labels num-start
)))
1929 ;;; Tables of Contents
1931 (defun org-html-toc (depth info
)
1932 "Build a table of contents.
1933 DEPTH is an integer specifying the depth of the table. INFO is a
1934 plist used as a communication channel. Return the table of
1935 contents as a string, or nil if it is empty."
1937 (mapcar (lambda (headline)
1938 (cons (org-html--format-toc-headline headline info
)
1939 (org-export-get-relative-level headline info
)))
1940 (org-export-collect-headlines info depth
)))
1941 (outer-tag (if (and (org-html-html5-p info
)
1942 (plist-get info
:html-html5-fancy
))
1946 (concat (format "<%s id=\"table-of-contents\">\n" outer-tag
)
1947 (format "<h%d>%s</h%d>\n"
1948 org-html-toplevel-hlevel
1949 (org-html--translate "Table of Contents" info
)
1950 org-html-toplevel-hlevel
)
1951 "<div id=\"text-table-of-contents\">"
1952 (org-html--toc-text toc-entries
)
1954 (format "</%s>\n" outer-tag
)))))
1956 (defun org-html--toc-text (toc-entries)
1957 "Return innards of a table of contents, as a string.
1958 TOC-ENTRIES is an alist where key is an entry title, as a string,
1959 and value is its relative level, as an integer."
1960 (let* ((prev-level (1- (cdar toc-entries
)))
1961 (start-level prev-level
))
1965 (let ((headline (car entry
))
1966 (level (cdr entry
)))
1968 (let* ((cnt (- level prev-level
))
1969 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1971 (setq prev-level level
)
1973 (org-html--make-string
1974 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1975 ((< cnt
0) "</li>\n</ul>\n")))
1976 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1979 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
1981 (defun org-html--format-toc-headline (headline info
)
1982 "Return an appropriate table of contents entry for HEADLINE.
1983 INFO is a plist used as a communication channel."
1984 (let* ((todo (and (plist-get info
:with-todo-keywords
)
1985 (let ((todo (org-element-property :todo-keyword headline
)))
1986 (and todo
(org-export-data todo info
)))))
1987 (todo-type (and todo
(org-element-property :todo-type headline
)))
1988 (priority (and (plist-get info
:with-priority
)
1989 (org-element-property :priority headline
)))
1990 (text (org-export-data-with-backend
1991 (org-export-get-alt-title headline info
)
1992 ;; Create an anonymous back-end that will ignore any
1993 ;; footnote-reference, link, radio-target and target
1994 ;; in table of contents.
1995 (org-export-create-backend
1997 :transcoders
'((footnote-reference . ignore
)
1998 (link .
(lambda (object c i
) c
))
1999 (radio-target .
(lambda (object c i
) c
))
2002 (tags (and (eq (plist-get info
:with-tags
) t
)
2003 (org-export-get-tags headline info
))))
2004 (format "<a href=\"#%s\">%s</a>"
2005 (org-export-solidify-link-text
2006 (or (org-element-property :CUSTOM_ID headline
)
2010 (org-export-get-headline-number headline info
)
2012 (apply (if (functionp org-html-format-headline-function
)
2013 (lambda (todo todo-type priority text tags
&rest ignore
)
2014 (funcall org-html-format-headline-function
2015 todo todo-type priority text tags
))
2016 #'org-html-format-headline
)
2017 todo todo-type priority text tags
:section-number nil
))))
2019 (defun org-html-list-of-listings (info)
2020 "Build a list of listings.
2021 INFO is a plist used as a communication channel. Return the list
2022 of listings as a string, or nil if it is empty."
2023 (let ((lol-entries (org-export-collect-listings info
)))
2025 (concat "<div id=\"list-of-listings\">\n"
2026 (format "<h%d>%s</h%d>\n"
2027 org-html-toplevel-hlevel
2028 (org-html--translate "List of Listings" info
)
2029 org-html-toplevel-hlevel
)
2030 "<div id=\"text-list-of-listings\">\n<ul>\n"
2032 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2033 (org-html--translate "Listing %d:" info
))))
2036 (let ((label (org-element-property :name entry
))
2039 (or (org-export-get-caption entry t
)
2040 (org-export-get-caption entry
))
2045 (concat (format initial-fmt
(incf count
)) " " title
)
2046 (format "<a href=\"#%s\">%s %s</a>"
2047 (org-export-solidify-link-text label
)
2048 (format initial-fmt
(incf count
))
2052 "\n</ul>\n</div>\n</div>"))))
2054 (defun org-html-list-of-tables (info)
2055 "Build a list of tables.
2056 INFO is a plist used as a communication channel. Return the list
2057 of tables as a string, or nil if it is empty."
2058 (let ((lol-entries (org-export-collect-tables info
)))
2060 (concat "<div id=\"list-of-tables\">\n"
2061 (format "<h%d>%s</h%d>\n"
2062 org-html-toplevel-hlevel
2063 (org-html--translate "List of Tables" info
)
2064 org-html-toplevel-hlevel
)
2065 "<div id=\"text-list-of-tables\">\n<ul>\n"
2067 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2068 (org-html--translate "Table %d:" info
))))
2071 (let ((label (org-element-property :name entry
))
2074 (or (org-export-get-caption entry t
)
2075 (org-export-get-caption entry
))
2080 (concat (format initial-fmt
(incf count
)) " " title
)
2081 (format "<a href=\"#%s\">%s %s</a>"
2082 (org-export-solidify-link-text label
)
2083 (format initial-fmt
(incf count
))
2087 "\n</ul>\n</div>\n</div>"))))
2090 ;;; Transcode Functions
2094 (defun org-html-bold (bold contents info
)
2095 "Transcode BOLD from Org to HTML.
2096 CONTENTS is the text with bold markup. INFO is a plist holding
2097 contextual information."
2098 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
2103 (defun org-html-center-block (center-block contents info
)
2104 "Transcode a CENTER-BLOCK element from Org to HTML.
2105 CONTENTS holds the contents of the block. INFO is a plist
2106 holding contextual information."
2107 (format "<div class=\"center\">\n%s</div>" contents
))
2111 (defun org-html-clock (clock contents info
)
2112 "Transcode a CLOCK element from Org to HTML.
2113 CONTENTS is nil. INFO is a plist used as a communication
2116 <span class=\"timestamp-wrapper\">
2117 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2122 (org-element-property :raw-value
2123 (org-element-property :value clock
)))
2124 (let ((time (org-element-property :duration clock
)))
2125 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2129 (defun org-html-code (code contents info
)
2130 "Transcode CODE from Org to HTML.
2131 CONTENTS is nil. INFO is a plist holding contextual
2133 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
2134 (org-html-encode-plain-text (org-element-property :value code
))))
2138 (defun org-html-drawer (drawer contents info
)
2139 "Transcode a DRAWER element from Org to HTML.
2140 CONTENTS holds the contents of the block. INFO is a plist
2141 holding contextual information."
2142 (if (functionp org-html-format-drawer-function
)
2143 (funcall org-html-format-drawer-function
2144 (org-element-property :drawer-name drawer
)
2146 ;; If there's no user defined function: simply
2147 ;; display contents of the drawer.
2152 (defun org-html-dynamic-block (dynamic-block contents info
)
2153 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2154 CONTENTS holds the contents of the block. INFO is a plist
2155 holding contextual information. See `org-export-data'."
2160 (defun org-html-entity (entity contents info
)
2161 "Transcode an ENTITY object from Org to HTML.
2162 CONTENTS are the definition itself. INFO is a plist holding
2163 contextual information."
2164 (org-element-property :html entity
))
2168 (defun org-html-example-block (example-block contents info
)
2169 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2170 CONTENTS is nil. INFO is a plist holding contextual
2172 (if (org-export-read-attribute :attr_html example-block
:textarea
)
2173 (org-html--textarea-block example-block
)
2174 (format "<pre class=\"example\">\n%s</pre>"
2175 (org-html-format-code example-block info
))))
2179 (defun org-html-export-snippet (export-snippet contents info
)
2180 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2181 CONTENTS is nil. INFO is a plist holding contextual
2183 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2184 (org-element-property :value export-snippet
)))
2188 (defun org-html-export-block (export-block contents info
)
2189 "Transcode a EXPORT-BLOCK element from Org to HTML.
2190 CONTENTS is nil. INFO is a plist holding contextual information."
2191 (when (string= (org-element-property :type export-block
) "HTML")
2192 (org-remove-indentation (org-element-property :value export-block
))))
2196 (defun org-html-fixed-width (fixed-width contents info
)
2197 "Transcode a FIXED-WIDTH element from Org to HTML.
2198 CONTENTS is nil. INFO is a plist holding contextual information."
2199 (format "<pre class=\"example\">\n%s</pre>"
2200 (org-html-do-format-code
2201 (org-remove-indentation
2202 (org-element-property :value fixed-width
)))))
2204 ;;;; Footnote Reference
2206 (defun org-html-footnote-reference (footnote-reference contents info
)
2207 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2208 CONTENTS is nil. INFO is a plist holding contextual information."
2210 ;; Insert separator between two footnotes in a row.
2211 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2212 (when (eq (org-element-type prev
) 'footnote-reference
)
2213 org-html-footnote-separator
))
2215 ((not (org-export-footnote-first-reference-p footnote-reference info
))
2216 (org-html-format-footnote-reference
2217 (org-export-get-footnote-number footnote-reference info
)
2219 ;; Inline definitions are secondary strings.
2220 ((eq (org-element-property :type footnote-reference
) 'inline
)
2221 (org-html-format-footnote-reference
2222 (org-export-get-footnote-number footnote-reference info
)
2224 ;; Non-inline footnotes definitions are full Org data.
2225 (t (org-html-format-footnote-reference
2226 (org-export-get-footnote-number footnote-reference info
)
2231 (defun org-html-format-headline--wrap
2232 (headline info
&optional format-function
&rest extra-keys
)
2233 "Transcode a HEADLINE element from Org to HTML.
2234 CONTENTS holds the contents of the headline. INFO is a plist
2235 holding contextual information."
2236 (let* ((level (+ (org-export-get-relative-level headline info
)
2237 (1- org-html-toplevel-hlevel
)))
2238 (headline-number (org-export-get-headline-number headline info
))
2239 (section-number (and (not (org-export-low-level-p headline info
))
2240 (org-export-numbered-headline-p headline info
)
2241 (mapconcat 'number-to-string
2242 headline-number
".")))
2243 (todo (and (plist-get info
:with-todo-keywords
)
2244 (let ((todo (org-element-property :todo-keyword headline
)))
2245 (and todo
(org-export-data todo info
)))))
2246 (todo-type (and todo
(org-element-property :todo-type headline
)))
2247 (priority (and (plist-get info
:with-priority
)
2248 (org-element-property :priority headline
)))
2249 (text (org-export-data (org-element-property :title headline
) info
))
2250 (tags (and (plist-get info
:with-tags
)
2251 (org-export-get-tags headline info
)))
2252 (headline-label (or (org-element-property :CUSTOM_ID headline
)
2253 (concat "sec-" (mapconcat 'number-to-string
2254 headline-number
"-"))))
2256 (cond ((functionp format-function
) format-function
)
2257 ((functionp org-html-format-headline-function
)
2258 (lambda (todo todo-type priority text tags
&rest ignore
)
2259 (funcall org-html-format-headline-function
2260 todo todo-type priority text tags
)))
2261 (t 'org-html-format-headline
))))
2262 (apply format-function
2263 todo todo-type priority text tags
2264 :headline-label headline-label
:level level
2265 :section-number section-number extra-keys
)))
2267 (defun org-html-headline (headline contents info
)
2268 "Transcode a HEADLINE element from Org to HTML.
2269 CONTENTS holds the contents of the headline. INFO is a plist
2270 holding contextual information."
2272 (setq contents
(or contents
""))
2273 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2274 (level (org-export-get-relative-level headline info
))
2275 (text (org-export-data (org-element-property :title headline
) info
))
2276 (todo (and (plist-get info
:with-todo-keywords
)
2277 (let ((todo (org-element-property :todo-keyword headline
)))
2278 (and todo
(org-export-data todo info
)))))
2279 (todo-type (and todo
(org-element-property :todo-type headline
)))
2280 (tags (and (plist-get info
:with-tags
)
2281 (org-export-get-tags headline info
)))
2282 (priority (and (plist-get info
:with-priority
)
2283 (org-element-property :priority headline
)))
2284 (section-number (and (org-export-numbered-headline-p headline info
)
2285 (mapconcat 'number-to-string
2286 (org-export-get-headline-number
2287 headline info
) ".")))
2288 ;; Create the headline text.
2289 (full-text (org-html-format-headline--wrap headline info
)))
2291 ;; Case 1: This is a footnote section: ignore it.
2292 ((org-element-property :footnote-section-p headline
) nil
)
2293 ;; Case 2. This is a deep sub-tree: export it as a list item.
2294 ;; Also export as items headlines for which no section
2295 ;; format has been found.
2296 ((org-export-low-level-p headline info
)
2297 ;; Build the real contents of the sub-tree.
2298 (let* ((type (if numberedp
'ordered
'unordered
))
2299 (itemized-body (org-html-format-list-item
2300 contents type nil info nil full-text
)))
2302 (and (org-export-first-sibling-p headline info
)
2303 (org-html-begin-plain-list type
))
2305 (and (org-export-last-sibling-p headline info
)
2306 (org-html-end-plain-list type
)))))
2307 ;; Case 3. Standard headline. Export it as a section.
2309 (let* ((section-number (mapconcat 'number-to-string
2310 (org-export-get-headline-number
2311 headline info
) "-"))
2313 (list (org-element-property :CUSTOM_ID headline
)
2314 (concat "sec-" section-number
)
2315 (org-element-property :ID headline
))))
2316 (preferred-id (car ids
))
2317 (extra-ids (cdr ids
))
2318 (extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2319 (level1 (+ level
(1- org-html-toplevel-hlevel
)))
2320 (first-content (car (org-element-contents headline
))))
2321 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2322 (org-html--container headline info
)
2323 (format "outline-container-%s"
2324 (or (org-element-property :CUSTOM_ID headline
)
2325 (concat "sec-" section-number
)))
2326 (concat (format "outline-%d" level1
) (and extra-class
" ")
2328 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2333 (let ((id (org-export-solidify-link-text
2334 (if (org-uuidgen-p x
) (concat "ID-" x
)
2336 (org-html--anchor id
)))
2340 ;; When there is no section, pretend there is an empty
2341 ;; one to get the correct <div class="outline- ...>
2342 ;; which is needed by `org-info.js'.
2343 (if (not (eq (org-element-type first-content
) 'section
))
2344 (concat (org-html-section first-content
"" info
)
2347 (org-html--container headline info
)))))))
2349 (defun org-html--container (headline info
)
2350 (or (org-element-property :HTML_CONTAINER headline
)
2351 (if (= 1 (org-export-get-relative-level headline info
))
2352 (plist-get info
:html-container
)
2355 ;;;; Horizontal Rule
2357 (defun org-html-horizontal-rule (horizontal-rule contents info
)
2358 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2359 CONTENTS is nil. INFO is a plist holding contextual information."
2360 (org-html-close-tag "hr" nil info
))
2362 ;;;; Inline Src Block
2364 (defun org-html-inline-src-block (inline-src-block contents info
)
2365 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2366 CONTENTS holds the contents of the item. INFO is a plist holding
2367 contextual information."
2368 (let* ((org-lang (org-element-property :language inline-src-block
))
2369 (code (org-element-property :value inline-src-block
)))
2370 (error "Cannot export inline src block")))
2374 (defun org-html-format-section (text class
&optional id
)
2375 "Format a section with TEXT into a HTML div with CLASS and ID."
2376 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
2377 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
2379 (defun org-html-inlinetask (inlinetask contents info
)
2380 "Transcode an INLINETASK element from Org to HTML.
2381 CONTENTS holds the contents of the block. INFO is a plist
2382 holding contextual information."
2384 ;; If `org-html-format-inlinetask-function' is provided, call it
2385 ;; with appropriate arguments.
2386 ((functionp org-html-format-inlinetask-function
)
2387 (let ((format-function
2389 (lambda (todo todo-type priority text tags
2390 &key contents
&allow-other-keys
)
2391 (funcall org-html-format-inlinetask-function
2392 todo todo-type priority text tags contents
)))))
2393 (org-html-format-headline--wrap
2394 inlinetask info format-function
:contents contents
)))
2395 ;; Otherwise, use a default template.
2396 (t (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2397 (org-html-format-headline--wrap inlinetask info
)
2398 (org-html-close-tag "br" nil info
)
2403 (defun org-html-italic (italic contents info
)
2404 "Transcode ITALIC from Org to HTML.
2405 CONTENTS is the text with italic markup. INFO is a plist holding
2406 contextual information."
2407 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
2411 (defun org-html-checkbox (checkbox)
2412 "Format CHECKBOX into HTML."
2413 (case checkbox
(on "<code>[X]</code>")
2414 (off "<code>[ ]</code>")
2415 (trans "<code>[-]</code>")
2418 (defun org-html-format-list-item (contents type checkbox info
2419 &optional term-counter-id
2421 "Format a list item into HTML."
2422 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" ")))
2423 (br (org-html-close-tag "br" nil info
)))
2427 (let* ((counter term-counter-id
)
2428 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2430 (format "<li%s>" extra
)
2431 (when headline
(concat headline br
)))))
2433 (let* ((id term-counter-id
)
2434 (extra (if id
(format " id=\"%s\"" id
) "")))
2436 (format "<li%s>" extra
)
2437 (when headline
(concat headline br
)))))
2439 (let* ((term term-counter-id
))
2440 (setq term
(or term
"(no term)"))
2441 ;; Check-boxes in descriptive lists are associated to tag.
2442 (concat (format "<dt> %s </dt>"
2443 (concat checkbox term
))
2445 (unless (eq type
'descriptive
) checkbox
)
2450 (descriptive "</dd>")))))
2452 (defun org-html-item (item contents info
)
2453 "Transcode an ITEM element from Org to HTML.
2454 CONTENTS holds the contents of the item. INFO is a plist holding
2455 contextual information."
2456 (let* ((plain-list (org-export-get-parent item
))
2457 (type (org-element-property :type plain-list
))
2458 (counter (org-element-property :counter item
))
2459 (checkbox (org-element-property :checkbox item
))
2460 (tag (let ((tag (org-element-property :tag item
)))
2461 (and tag
(org-export-data tag info
)))))
2462 (org-html-format-list-item
2463 contents type checkbox info
(or tag counter
))))
2467 (defun org-html-keyword (keyword contents info
)
2468 "Transcode a KEYWORD element from Org to HTML.
2469 CONTENTS is nil. INFO is a plist holding contextual information."
2470 (let ((key (org-element-property :key keyword
))
2471 (value (org-element-property :value keyword
)))
2473 ((string= key
"HTML") value
)
2474 ((string= key
"TOC")
2475 (let ((value (downcase value
)))
2477 ((string-match "\\<headlines\\>" value
)
2478 (let ((depth (or (and (string-match "[0-9]+" value
)
2479 (string-to-number (match-string 0 value
)))
2480 (plist-get info
:with-toc
))))
2481 (org-html-toc depth info
)))
2482 ((string= "listings" value
) (org-html-list-of-listings info
))
2483 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2485 ;;;; Latex Environment
2487 (defun org-html-format-latex (latex-frag processing-type
)
2488 "Format a LaTeX fragment LATEX-FRAG into HTML."
2489 (let ((cache-relpath "") (cache-dir ""))
2490 (unless (eq processing-type
'mathjax
)
2491 (let ((bfn (or (buffer-file-name)
2493 (expand-file-name "latex" temporary-file-directory
)))))
2496 (file-name-sans-extension
2497 (file-name-nondirectory bfn
)))
2498 cache-dir
(file-name-directory bfn
))))
2501 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2502 nil nil processing-type
)
2505 (defun org-html-latex-environment (latex-environment contents info
)
2506 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2507 CONTENTS is nil. INFO is a plist holding contextual information."
2508 (let ((processing-type (plist-get info
:with-latex
))
2509 (latex-frag (org-remove-indentation
2510 (org-element-property :value latex-environment
)))
2511 (attributes (org-export-read-attribute :attr_html latex-environment
)))
2512 (case processing-type
2514 (org-html-format-latex latex-frag
'mathjax
))
2515 ((dvipng imagemagick
)
2516 (let ((formula-link (org-html-format-latex latex-frag processing-type
)))
2517 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2518 ;; Do not provide a caption or a name to be consistent with
2519 ;; `mathjax' handling.
2520 (org-html--wrap-image
2521 (org-html--format-image
2522 (match-string 1 formula-link
) attributes info
) info
))))
2527 (defun org-html-latex-fragment (latex-fragment contents info
)
2528 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2529 CONTENTS is nil. INFO is a plist holding contextual information."
2530 (let ((latex-frag (org-element-property :value latex-fragment
))
2531 (processing-type (plist-get info
:with-latex
)))
2532 (case processing-type
2534 (org-html-format-latex latex-frag
'mathjax
))
2535 ((dvipng imagemagick
)
2536 (let ((formula-link (org-html-format-latex latex-frag processing-type
)))
2537 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2538 (org-html--format-image (match-string 1 formula-link
) nil info
))))
2543 (defun org-html-line-break (line-break contents info
)
2544 "Transcode a LINE-BREAK object from Org to HTML.
2545 CONTENTS is nil. INFO is a plist holding contextual information."
2546 (concat (org-html-close-tag "br" nil info
) "\n"))
2550 (defun org-html-inline-image-p (link info
)
2551 "Non-nil when LINK is meant to appear as an image.
2552 INFO is a plist used as a communication channel. LINK is an
2553 inline image when it has no description and targets an image
2554 file (see `org-html-inline-image-rules' for more information), or
2555 if its description is a single link targeting an image file."
2556 (if (not (org-element-contents link
))
2557 (org-export-inline-image-p link org-html-inline-image-rules
)
2559 (let ((link-count 0))
2560 (org-element-map (org-element-contents link
)
2561 (cons 'plain-text org-element-all-objects
)
2563 (case (org-element-type obj
)
2564 (plain-text (org-string-nw-p obj
))
2565 (link (if (= link-count
1) t
2567 (not (org-export-inline-image-p
2568 obj org-html-inline-image-rules
))))
2572 (defvar org-html-standalone-image-predicate
)
2573 (defun org-html-standalone-image-p (element info
)
2574 "Test if ELEMENT is a standalone image.
2576 INFO is a plist holding contextual information.
2578 Return non-nil, if ELEMENT is of type paragraph and its sole
2579 content, save for white spaces, is a link that qualifies as an
2582 Return non-nil, if ELEMENT is of type link and its containing
2583 paragraph has no other content save white spaces.
2585 Return nil, otherwise.
2587 Bind `org-html-standalone-image-predicate' to constrain paragraph
2588 further. For example, to check for only captioned standalone
2591 \(lambda (paragraph) (org-element-property :caption paragraph))"
2592 (let ((paragraph (case (org-element-type element
)
2594 (link (org-export-get-parent element
)))))
2595 (and (eq (org-element-type paragraph
) 'paragraph
)
2596 (or (not (and (boundp 'org-html-standalone-image-predicate
)
2597 (functionp org-html-standalone-image-predicate
)))
2598 (funcall org-html-standalone-image-predicate paragraph
))
2599 (not (let ((link-count 0))
2600 (org-element-map (org-element-contents paragraph
)
2601 (cons 'plain-text org-element-all-objects
)
2602 (lambda (obj) (case (org-element-type obj
)
2603 (plain-text (org-string-nw-p obj
))
2605 (or (> (incf link-count
) 1)
2606 (not (org-html-inline-image-p obj info
))))
2608 info
'first-match
'link
))))))
2610 (defun org-html-link (link desc info
)
2611 "Transcode a LINK object from Org to HTML.
2613 DESC is the description part of the link, or the empty string.
2614 INFO is a plist holding contextual information. See
2616 (let* ((home (when (plist-get info
:html-link-home
)
2617 (org-trim (plist-get info
:html-link-home
))))
2618 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2619 (link-org-files-as-html-maybe
2621 (lambda (raw-path info
)
2622 "Treat links to `file.org' as links to `file.html', if needed.
2623 See `org-html-link-org-files-as-html'."
2625 ((and org-html-link-org-files-as-html
2627 (downcase (file-name-extension raw-path
"."))))
2628 (concat (file-name-sans-extension raw-path
) "."
2629 (plist-get info
:html-extension
)))
2631 (type (org-element-property :type link
))
2632 (raw-path (org-element-property :path link
))
2633 ;; Ensure DESC really exists, or set it to nil.
2634 (desc (org-string-nw-p desc
))
2637 ((member type
'("http" "https" "ftp" "mailto"))
2638 (concat type
":" raw-path
))
2639 ((string= type
"file")
2640 ;; Treat links to ".org" files as ".html", if needed.
2642 (funcall link-org-files-as-html-maybe raw-path info
))
2643 ;; If file path is absolute, prepend it with protocol
2644 ;; component - "file://".
2645 (cond ((file-name-absolute-p raw-path
)
2647 (concat "file://" (expand-file-name
2649 ((and home use-abs-url
)
2650 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2651 ;; Add search option, if any. A search option can be
2652 ;; relative to a custom-id or a headline title. Any other
2653 ;; option is ignored.
2654 (let ((option (org-element-property :search-option link
)))
2655 (cond ((not option
) raw-path
)
2656 ((eq (aref option
0) ?
#) (concat raw-path option
))
2657 ;; External fuzzy link: try to resolve it if path
2658 ;; belongs to current project, if any.
2659 ((eq (aref option
0) ?
*)
2663 (org-publish-resolve-external-fuzzy-link
2664 (org-element-property :path link
) option
)))
2665 (and numbers
(concat "#sec-"
2666 (mapconcat 'number-to-string
2670 ;; Extract attributes from parent's paragraph. HACK: Only do
2671 ;; this for the first link in parent (inner image link for
2672 ;; inline images). This is needed as long as attributes
2673 ;; cannot be set on a per link basis.
2675 (let* ((parent (org-export-get-parent-element link
))
2676 (link (let ((container (org-export-get-parent link
)))
2677 (if (and (eq (org-element-type container
) 'link
)
2678 (org-html-inline-image-p link info
))
2681 (and (eq (org-element-map parent
'link
'identity info t
) link
)
2682 (org-export-read-attribute :attr_html parent
))))
2684 (let ((attr (org-html--make-attribute-string attributes-plist
)))
2685 (if (org-string-nw-p attr
) (concat " " attr
) "")))
2689 ((and org-html-inline-images
2690 (org-export-inline-image-p link org-html-inline-image-rules
))
2691 (org-html--format-image path attributes-plist info
))
2692 ;; Radio target: Transcode target's contents and use them as
2693 ;; link's description.
2694 ((string= type
"radio")
2695 (let ((destination (org-export-resolve-radio-link link info
)))
2697 (format "<a href=\"#%s\"%s>%s</a>"
2698 (org-export-solidify-link-text path
)
2700 (org-export-data (org-element-contents destination
) info
)))))
2701 ;; Links pointing to a headline: Find destination and build
2702 ;; appropriate referencing command.
2703 ((member type
'("custom-id" "fuzzy" "id"))
2704 (let ((destination (if (string= type
"fuzzy")
2705 (org-export-resolve-fuzzy-link link info
)
2706 (org-export-resolve-id-link link info
))))
2707 (case (org-element-type destination
)
2708 ;; ID link points to an external file.
2710 (let ((fragment (concat "ID-" path
))
2711 ;; Treat links to ".org" files as ".html", if needed.
2712 (path (funcall link-org-files-as-html-maybe
2714 (format "<a href=\"%s#%s\"%s>%s</a>"
2715 path fragment attributes
(or desc destination
))))
2716 ;; Fuzzy link points nowhere.
2721 (org-element-property :raw-link link
) info
))))
2722 ;; Link points to a headline.
2725 ;; What href to use?
2727 ;; Case 1: Headline is linked via it's CUSTOM_ID
2728 ;; property. Use CUSTOM_ID.
2729 ((string= type
"custom-id")
2730 (org-element-property :CUSTOM_ID destination
))
2731 ;; Case 2: Headline is linked via it's ID property
2732 ;; or through other means. Use the default href.
2733 ((member type
'("id" "fuzzy"))
2735 (mapconcat 'number-to-string
2736 (org-export-get-headline-number
2737 destination info
) "-")))
2738 (t (error "Shouldn't reach here"))))
2739 ;; What description to use?
2741 ;; Case 1: Headline is numbered and LINK has no
2742 ;; description. Display section number.
2743 (if (and (org-export-numbered-headline-p destination info
)
2745 (mapconcat 'number-to-string
2746 (org-export-get-headline-number
2747 destination info
) ".")
2748 ;; Case 2: Either the headline is un-numbered or
2749 ;; LINK has a custom description. Display LINK's
2750 ;; description or headline's title.
2751 (or desc
(org-export-data (org-element-property
2752 :title destination
) info
)))))
2753 (format "<a href=\"#%s\"%s>%s</a>"
2754 (org-export-solidify-link-text href
) attributes desc
)))
2755 ;; Fuzzy link points to a target or an element.
2757 (let* ((path (org-export-solidify-link-text path
))
2758 (org-html-standalone-image-predicate 'org-html--has-caption-p
)
2761 ((org-html-standalone-image-p destination info
)
2762 (org-export-get-ordinal
2763 (org-element-map destination
'link
2765 info
'link
'org-html-standalone-image-p
))
2766 (t (org-export-get-ordinal
2767 destination info nil
'org-html--has-caption-p
))))
2769 ((not number
) "No description for this link")
2770 ((numberp number
) (number-to-string number
))
2771 (t (mapconcat 'number-to-string number
".")))))
2772 (format "<a href=\"#%s\"%s>%s</a>" path attributes desc
))))))
2773 ;; Coderef: replace link with the reference name or the
2774 ;; equivalent line number.
2775 ((string= type
"coderef")
2776 (let ((fragment (concat "coderef-" path
)))
2777 (format "<a href=\"#%s\"%s%s>%s</a>"
2780 (format (concat "class=\"coderef\""
2781 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2782 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2785 (format (org-export-get-coderef-format path desc
)
2786 (org-export-resolve-coderef path info
)))))
2787 ;; Link type is handled by a special function.
2788 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2789 (funcall protocol
(org-link-unescape path
) desc
'html
))
2790 ;; External link with a description part.
2791 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2792 ;; External link without a description part.
2793 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2794 ;; No path, only description. Try to do something useful.
2795 (t (format "<i>%s</i>" desc
)))))
2799 (defun org-html-paragraph (paragraph contents info
)
2800 "Transcode a PARAGRAPH element from Org to HTML.
2801 CONTENTS is the contents of the paragraph, as a string. INFO is
2802 the plist used as a communication channel."
2803 (let* ((parent (org-export-get-parent paragraph
))
2804 (parent-type (org-element-type parent
))
2805 (style '((footnote-definition " class=\"footpara\"")))
2806 (extra (or (cadr (assoc parent-type style
)) "")))
2808 ((and (eq (org-element-type parent
) 'item
)
2809 (= (org-element-property :begin paragraph
)
2810 (org-element-property :contents-begin parent
)))
2811 ;; Leading paragraph in a list item have no tags.
2813 ((org-html-standalone-image-p paragraph info
)
2814 ;; Standalone image.
2816 (let ((raw (org-export-data
2817 (org-export-get-caption paragraph
) info
))
2818 (org-html-standalone-image-predicate
2819 'org-html--has-caption-p
))
2820 (if (not (org-string-nw-p raw
)) raw
2822 "<span class=\"figure-number\">"
2823 (format (org-html--translate "Figure %d:" info
)
2824 (org-export-get-ordinal
2825 (org-element-map paragraph
'link
2827 info nil
'org-html-standalone-image-p
))
2829 (label (org-element-property :name paragraph
)))
2830 (org-html--wrap-image contents info caption label
)))
2831 ;; Regular paragraph.
2832 (t (format "<p%s>\n%s</p>" extra contents
)))))
2836 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2837 ;; the correct value for the item counter
2838 (defun org-html-begin-plain-list (type &optional arg1
)
2839 "Insert the beginning of the HTML list depending on TYPE.
2840 When ARG1 is a string, use it as the start parameter for ordered
2844 (format "<ol class=\"org-ol\"%s>"
2845 (if arg1
(format " start=\"%d\"" arg1
) "")))
2846 (unordered "<ul class=\"org-ul\">")
2847 (descriptive "<dl class=\"org-dl\">")))
2849 (defun org-html-end-plain-list (type)
2850 "Insert the end of the HTML list depending on TYPE."
2854 (descriptive "</dl>")))
2856 (defun org-html-plain-list (plain-list contents info
)
2857 "Transcode a PLAIN-LIST element from Org to HTML.
2858 CONTENTS is the contents of the list. INFO is a plist holding
2859 contextual information."
2860 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2861 (type (org-element-property :type plain-list
)))
2863 (org-html-begin-plain-list type
)
2864 contents
(org-html-end-plain-list type
))))
2868 (defun org-html-convert-special-strings (string)
2869 "Convert special characters in STRING to HTML."
2870 (let ((all org-html-special-string-regexps
)
2872 (while (setq a
(pop all
))
2873 (setq re
(car a
) rpl
(cdr a
) start
0)
2874 (while (string-match re string start
)
2875 (setq string
(replace-match rpl t nil string
))))
2878 (defun org-html-encode-plain-text (text)
2879 "Convert plain text characters from TEXT to HTML equivalent.
2880 Possible conversions are set in `org-html-protect-char-alist'."
2883 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2884 org-html-protect-char-alist
)
2887 (defun org-html-plain-text (text info
)
2888 "Transcode a TEXT string from Org to HTML.
2889 TEXT is the string to transcode. INFO is a plist holding
2890 contextual information."
2891 (let ((output text
))
2892 ;; Protect following characters: <, >, &.
2893 (setq output
(org-html-encode-plain-text output
))
2894 ;; Handle smart quotes. Be sure to provide original string since
2895 ;; OUTPUT may have been modified.
2896 (when (plist-get info
:with-smart-quotes
)
2897 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2898 ;; Handle special strings.
2899 (when (plist-get info
:with-special-strings
)
2900 (setq output
(org-html-convert-special-strings output
)))
2901 ;; Handle break preservation if required.
2902 (when (plist-get info
:preserve-breaks
)
2904 (replace-regexp-in-string
2905 "\\(\\\\\\\\\\)?[ \t]*\n"
2906 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
2913 (defun org-html-planning (planning contents info
)
2914 "Transcode a PLANNING element from Org to HTML.
2915 CONTENTS is nil. INFO is a plist used as a communication
2917 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2919 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2924 (let ((closed (org-element-property :closed planning
)))
2926 (format span-fmt org-closed-string
2928 (org-element-property :raw-value closed
)))))
2929 (let ((deadline (org-element-property :deadline planning
)))
2931 (format span-fmt org-deadline-string
2933 (org-element-property :raw-value deadline
)))))
2934 (let ((scheduled (org-element-property :scheduled planning
)))
2936 (format span-fmt org-scheduled-string
2938 (org-element-property :raw-value scheduled
)))))))
2941 ;;;; Property Drawer
2943 (defun org-html-property-drawer (property-drawer contents info
)
2944 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2945 CONTENTS is nil. INFO is a plist holding contextual
2947 ;; The property drawer isn't exported but we want separating blank
2948 ;; lines nonetheless.
2953 (defun org-html-quote-block (quote-block contents info
)
2954 "Transcode a QUOTE-BLOCK element from Org to HTML.
2955 CONTENTS holds the contents of the block. INFO is a plist
2956 holding contextual information."
2957 (format "<blockquote>\n%s</blockquote>" contents
))
2961 (defun org-html-quote-section (quote-section contents info
)
2962 "Transcode a QUOTE-SECTION element from Org to HTML.
2963 CONTENTS is nil. INFO is a plist holding contextual information."
2964 (let ((value (org-remove-indentation
2965 (org-element-property :value quote-section
))))
2966 (when value
(format "<pre>\n%s</pre>" value
))))
2970 (defun org-html-section (section contents info
)
2971 "Transcode a SECTION element from Org to HTML.
2972 CONTENTS holds the contents of the section. INFO is a plist
2973 holding contextual information."
2974 (let ((parent (org-export-get-parent-headline section
)))
2975 ;; Before first headline: no container, just return CONTENTS.
2976 (if (not parent
) contents
2977 ;; Get div's class and id references.
2978 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2979 (1- org-html-toplevel-hlevel
)))
2983 (org-export-get-headline-number parent info
) "-")))
2984 ;; Build return value.
2985 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2987 (or (org-element-property :CUSTOM_ID parent
) section-number
)
2992 (defun org-html-radio-target (radio-target text info
)
2993 "Transcode a RADIO-TARGET object from Org to HTML.
2994 TEXT is the text of the target. INFO is a plist holding
2995 contextual information."
2996 (let ((id (org-export-solidify-link-text
2997 (org-element-property :value radio-target
))))
2998 (org-html--anchor id text
)))
3002 (defun org-html-special-block (special-block contents info
)
3003 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3004 CONTENTS holds the contents of the block. INFO is a plist
3005 holding contextual information."
3006 (let* ((block-type (downcase
3007 (org-element-property :type special-block
)))
3008 (contents (or contents
""))
3009 (html5-fancy (and (org-html-html5-p info
)
3010 (plist-get info
:html-html5-fancy
)
3011 (member block-type org-html-html5-elements
)))
3012 (attributes (org-export-read-attribute :attr_html special-block
)))
3014 (let ((class (plist-get attributes
:class
)))
3015 (setq attributes
(plist-put attributes
:class
3016 (if class
(concat class
" " block-type
)
3018 (setq attributes
(org-html--make-attribute-string attributes
))
3019 (when (not (equal attributes
""))
3020 (setq attributes
(concat " " attributes
)))
3022 (format "<%s%s>\n%s</%s>" block-type attributes
3023 contents block-type
)
3024 (format "<div%s>\n%s\n</div>" attributes contents
))))
3028 (defun org-html-src-block (src-block contents info
)
3029 "Transcode a SRC-BLOCK element from Org to HTML.
3030 CONTENTS holds the contents of the item. INFO is a plist holding
3031 contextual information."
3032 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3033 (org-html--textarea-block src-block
)
3034 (let ((lang (org-element-property :language src-block
))
3035 (caption (org-export-get-caption src-block
))
3036 (code (org-html-format-code src-block info
))
3037 (label (let ((lbl (org-element-property :name src-block
)))
3039 (format " id=\"%s\""
3040 (org-export-solidify-link-text lbl
))))))
3041 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3043 "<div class=\"org-src-container\">\n%s%s\n</div>"
3044 (if (not caption
) ""
3045 (format "<label class=\"org-src-name\">%s</label>"
3046 (org-export-data caption info
)))
3047 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3049 ;;;; Statistics Cookie
3051 (defun org-html-statistics-cookie (statistics-cookie contents info
)
3052 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3053 CONTENTS is nil. INFO is a plist holding contextual information."
3054 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3055 (format "<code>%s</code>" cookie-value
)))
3059 (defun org-html-strike-through (strike-through contents info
)
3060 "Transcode STRIKE-THROUGH from Org to HTML.
3061 CONTENTS is the text with strike-through markup. INFO is a plist
3062 holding contextual information."
3063 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
3068 (defun org-html-subscript (subscript contents info
)
3069 "Transcode a SUBSCRIPT object from Org to HTML.
3070 CONTENTS is the contents of the object. INFO is a plist holding
3071 contextual information."
3072 (format "<sub>%s</sub>" contents
))
3076 (defun org-html-superscript (superscript contents info
)
3077 "Transcode a SUPERSCRIPT object from Org to HTML.
3078 CONTENTS is the contents of the object. INFO is a plist holding
3079 contextual information."
3080 (format "<sup>%s</sup>" contents
))
3084 (defun org-html-table-cell (table-cell contents info
)
3085 "Transcode a TABLE-CELL element from Org to HTML.
3086 CONTENTS is nil. INFO is a plist used as a communication
3088 (let* ((table-row (org-export-get-parent table-cell
))
3089 (table (org-export-get-parent-table table-cell
))
3091 (if (not org-html-table-align-individual-fields
) ""
3092 (format (if (and (boundp 'org-html-format-table-no-css
)
3093 org-html-format-table-no-css
)
3094 " align=\"%s\"" " class=\"%s\"")
3095 (org-export-table-cell-alignment table-cell info
)))))
3096 (when (or (not contents
) (string= "" (org-trim contents
)))
3097 (setq contents
" "))
3099 ((and (org-export-table-has-header-p table info
)
3100 (= 1 (org-export-table-row-group table-row info
)))
3101 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
3102 contents
(cdr org-html-table-header-tags
)))
3103 ((and org-html-table-use-header-tags-for-first-column
3104 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3105 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
3106 contents
(cdr org-html-table-header-tags
)))
3107 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
3108 contents
(cdr org-html-table-data-tags
))))))
3112 (defun org-html-table-row (table-row contents info
)
3113 "Transcode a TABLE-ROW element from Org to HTML.
3114 CONTENTS is the contents of the row. INFO is a plist used as a
3115 communication channel."
3116 ;; Rules are ignored since table separators are deduced from
3117 ;; borders of the current row.
3118 (when (eq (org-element-property :type table-row
) 'standard
)
3119 (let* ((rowgroup-number (org-export-table-row-group table-row info
))
3120 (row-number (org-export-table-row-number table-row info
))
3122 (org-export-table-row-starts-rowgroup-p table-row info
))
3124 (org-export-table-row-ends-rowgroup-p table-row info
))
3125 ;; `top-row-p' and `end-rowgroup-p' are not used directly
3126 ;; but should be set so that `org-html-table-row-tags' can
3127 ;; use them (see the docstring of this variable.)
3128 (top-row-p (and (equal start-rowgroup-p
'(top))
3129 (equal end-rowgroup-p
'(below top
))))
3130 (bottom-row-p (and (equal start-rowgroup-p
'(above))
3131 (equal end-rowgroup-p
'(bottom above
))))
3134 ;; Case 1: Row belongs to second or subsequent rowgroups.
3135 ((not (= 1 rowgroup-number
))
3136 '("<tbody>" .
"\n</tbody>"))
3137 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
3138 ((org-export-table-has-header-p
3139 (org-export-get-parent-table table-row
) info
)
3140 '("<thead>" .
"\n</thead>"))
3141 ;; Case 2: Row is from first and only row group.
3142 (t '("<tbody>" .
"\n</tbody>")))))
3144 ;; Begin a rowgroup?
3145 (when start-rowgroup-p
(car rowgroup-tags
))
3147 (concat "\n" (eval (car org-html-table-row-tags
))
3150 (eval (cdr org-html-table-row-tags
)))
3152 (when end-rowgroup-p
(cdr rowgroup-tags
))))))
3156 (defun org-html-table-first-row-data-cells (table info
)
3157 "Transcode the first row of TABLE.
3158 INFO is a plist used as a communication channel."
3160 (org-element-map table
'table-row
3162 (unless (eq (org-element-property :type row
) 'rule
) row
))
3164 (special-column-p (org-export-table-has-special-column-p table
)))
3165 (if (not special-column-p
) (org-element-contents table-row
)
3166 (cdr (org-element-contents table-row
)))))
3168 (defun org-html-table--table.el-table
(table info
)
3169 "Format table.el tables into HTML.
3170 INFO is a plist used as a communication channel."
3171 (when (eq (org-element-property :type table
) 'table.el
)
3173 (let ((outbuf (with-current-buffer
3174 (get-buffer-create "*org-export-table*")
3175 (erase-buffer) (current-buffer))))
3177 (insert (org-element-property :value table
))
3179 (re-search-forward "^[ \t]*|[^|]" nil t
)
3180 (table-generate-source 'html outbuf
))
3181 (with-current-buffer outbuf
3182 (prog1 (org-trim (buffer-string))
3185 (defun org-html-table (table contents info
)
3186 "Transcode a TABLE element from Org to HTML.
3187 CONTENTS is the contents of the table. INFO is a plist holding
3188 contextual information."
3189 (case (org-element-property :type table
)
3190 ;; Case 1: table.el table. Convert it using appropriate tools.
3191 (table.el
(org-html-table--table.el-table table info
))
3192 ;; Case 2: Standard table.
3194 (let* ((label (org-element-property :name table
))
3195 (caption (org-export-get-caption table
))
3196 (number (org-export-get-ordinal
3197 table info nil
'org-html--has-caption-p
))
3199 (org-html--make-attribute-string
3201 (and label
(list :id
(org-export-solidify-link-text label
)))
3202 (and (not (org-html-html5-p info
))
3203 (plist-get info
:html-table-attributes
))
3204 (org-export-read-attribute :attr_html table
))))
3206 (if (and (boundp 'org-html-format-table-no-css
)
3207 org-html-format-table-no-css
)
3208 "align=\"%s\"" "class=\"%s\""))
3211 (lambda (table info
)
3213 (lambda (table-cell)
3214 (let ((alignment (org-export-table-cell-alignment
3217 ;; Begin a colgroup?
3218 (when (org-export-table-cell-starts-colgroup-p
3221 ;; Add a column. Also specify it's alignment.
3224 "col" (concat " " (format alignspec alignment
)) info
))
3226 (when (org-export-table-cell-ends-colgroup-p
3229 (org-html-table-first-row-data-cells table info
) "\n")))))
3230 (format "<table%s>\n%s\n%s\n%s</table>"
3231 (if (equal attributes
"") "" (concat " " attributes
))
3232 (if (not caption
) ""
3233 (format (if org-html-table-caption-above
3234 "<caption align=\"above\">%s</caption>"
3235 "<caption align=\"bottom\">%s</caption>")
3237 "<span class=\"table-number\">"
3238 (format (org-html--translate "Table %d:" info
) number
)
3239 "</span> " (org-export-data caption info
))))
3240 (funcall table-column-specs table info
)
3245 (defun org-html-target (target contents info
)
3246 "Transcode a TARGET object from Org to HTML.
3247 CONTENTS is nil. INFO is a plist holding contextual
3249 (let ((id (org-export-solidify-link-text
3250 (org-element-property :value target
))))
3251 (org-html--anchor id
)))
3255 (defun org-html-timestamp (timestamp contents info
)
3256 "Transcode a TIMESTAMP object from Org to HTML.
3257 CONTENTS is nil. INFO is a plist holding contextual
3259 (let ((value (org-html-plain-text
3260 (org-timestamp-translate timestamp
) info
)))
3261 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3262 (replace-regexp-in-string "--" "–" value
))))
3266 (defun org-html-underline (underline contents info
)
3267 "Transcode UNDERLINE from Org to HTML.
3268 CONTENTS is the text with underline markup. INFO is a plist
3269 holding contextual information."
3270 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
3275 (defun org-html-verbatim (verbatim contents info
)
3276 "Transcode VERBATIM from Org to HTML.
3277 CONTENTS is nil. INFO is a plist holding contextual
3279 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
3280 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3284 (defun org-html-verse-block (verse-block contents info
)
3285 "Transcode a VERSE-BLOCK element from Org to HTML.
3286 CONTENTS is verse block contents. INFO is a plist holding
3287 contextual information."
3288 ;; Replace each newline character with line break. Also replace
3289 ;; each blank line with a line break.
3290 (setq contents
(replace-regexp-in-string
3291 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3292 (replace-regexp-in-string
3293 "\\(\\\\\\\\\\)?[ \t]*\n"
3294 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3295 ;; Replace each white space at beginning of a line with a
3296 ;; non-breaking space.
3297 (while (string-match "^[ \t]+" contents
)
3298 (let* ((num-ws (length (match-string 0 contents
)))
3299 (ws (let (out) (dotimes (i num-ws out
)
3300 (setq out
(concat out
" "))))))
3301 (setq contents
(replace-match ws nil t contents
))))
3302 (format "<p class=\"verse\">\n%s</p>" contents
))
3305 ;;; Filter Functions
3307 (defun org-html-final-function (contents backend info
)
3308 "Filter to indent the HTML and convert HTML entities."
3313 (indent-region (point-min) (point-max)))
3314 (when org-html-use-unicode-chars
3316 (mm-url-decode-entities))
3317 (buffer-substring-no-properties (point-min) (point-max))))
3320 ;;; End-user functions
3323 (defun org-html-export-as-html
3324 (&optional async subtreep visible-only body-only ext-plist
)
3325 "Export current buffer to an HTML buffer.
3327 If narrowing is active in the current buffer, only export its
3330 If a region is active, export that region.
3332 A non-nil optional argument ASYNC means the process should happen
3333 asynchronously. The resulting buffer should be accessible
3334 through the `org-export-stack' interface.
3336 When optional argument SUBTREEP is non-nil, export the sub-tree
3337 at point, extracting information from the headline properties
3340 When optional argument VISIBLE-ONLY is non-nil, don't export
3341 contents of hidden elements.
3343 When optional argument BODY-ONLY is non-nil, only write code
3344 between \"<body>\" and \"</body>\" tags.
3346 EXT-PLIST, when provided, is a property list with external
3347 parameters overriding Org default settings, but still inferior to
3348 file-local settings.
3350 Export is done in a buffer named \"*Org HTML Export*\", which
3351 will be displayed when `org-export-show-temporary-export-buffer'
3354 (org-export-to-buffer 'html
"*Org HTML Export*"
3355 async subtreep visible-only body-only ext-plist
3356 (lambda () (set-auto-mode t
))))
3359 (defun org-html-convert-region-to-html ()
3360 "Assume the current region has org-mode syntax, and convert it to HTML.
3361 This can be used in any buffer. For example, you can write an
3362 itemized list in org-mode syntax in an HTML buffer and use this
3363 command to convert it."
3365 (org-export-replace-region-by 'html
))
3368 (defun org-html-export-to-html
3369 (&optional async subtreep visible-only body-only ext-plist
)
3370 "Export current buffer to a HTML file.
3372 If narrowing is active in the current buffer, only export its
3375 If a region is active, export that region.
3377 A non-nil optional argument ASYNC means the process should happen
3378 asynchronously. The resulting file should be accessible through
3379 the `org-export-stack' interface.
3381 When optional argument SUBTREEP is non-nil, export the sub-tree
3382 at point, extracting information from the headline properties
3385 When optional argument VISIBLE-ONLY is non-nil, don't export
3386 contents of hidden elements.
3388 When optional argument BODY-ONLY is non-nil, only write code
3389 between \"<body>\" and \"</body>\" tags.
3391 EXT-PLIST, when provided, is a property list with external
3392 parameters overriding Org default settings, but still inferior to
3393 file-local settings.
3395 Return output file's name."
3397 (let* ((extension (concat "." org-html-extension
))
3398 (file (org-export-output-file-name extension subtreep
))
3399 (org-export-coding-system org-html-coding-system
))
3400 (org-export-to-file 'html file
3401 async subtreep visible-only body-only ext-plist
)))
3404 (defun org-html-publish-to-html (plist filename pub-dir
)
3405 "Publish an org file to HTML.
3407 FILENAME is the filename of the Org file to be published. PLIST
3408 is the property list for the given project. PUB-DIR is the
3409 publishing directory.
3411 Return output file name."
3412 (org-publish-org-to 'html filename
3413 (concat "." (or (plist-get plist
:html-extension
)
3414 org-html-extension
"html"))
3420 ;;;; org-format-table-html
3421 ;;;; org-format-org-table-html
3422 ;;;; org-format-table-table-html
3423 ;;;; org-table-number-fraction
3424 ;;;; org-table-number-regexp
3425 ;;;; org-html-inline-image-extensions
3426 ;;;; org-export-preferred-target-alist
3427 ;;;; class for anchors
3428 ;;;; org-export-mark-todo-in-toc
3429 ;;;; org-html-format-org-link
3430 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
3431 ;;;; alt = (file-name-nondirectory path)
3436 ;; generated-autoload-file: "org-loaddefs.el"
3439 ;;; ox-html.el ends here