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 (node-property . org-html-node-property
)
76 (paragraph . org-html-paragraph
)
77 (plain-list . org-html-plain-list
)
78 (plain-text . org-html-plain-text
)
79 (planning . org-html-planning
)
80 (property-drawer . org-html-property-drawer
)
81 (quote-block . org-html-quote-block
)
82 (quote-section . org-html-quote-section
)
83 (radio-target . org-html-radio-target
)
84 (section . org-html-section
)
85 (special-block . org-html-special-block
)
86 (src-block . org-html-src-block
)
87 (statistics-cookie . org-html-statistics-cookie
)
88 (strike-through . org-html-strike-through
)
89 (subscript . org-html-subscript
)
90 (superscript . org-html-superscript
)
91 (table . org-html-table
)
92 (table-cell . org-html-table-cell
)
93 (table-row . org-html-table-row
)
94 (target . org-html-target
)
95 (template . org-html-template
)
96 (timestamp . org-html-timestamp
)
97 (underline . org-html-underline
)
98 (verbatim . org-html-verbatim
)
99 (verse-block . org-html-verse-block
))
101 :filters-alist
'((:filter-options . org-html-infojs-install-script
)
102 (:filter-final-output . org-html-final-function
))
104 '(?h
"Export to HTML"
105 ((?H
"As HTML buffer" org-html-export-as-html
)
106 (?h
"As HTML file" org-html-export-to-html
)
107 (?o
"As HTML file and open"
109 (if a
(org-html-export-to-html t s v b
)
110 (org-open-file (org-html-export-to-html nil s v b
)))))))
112 '((:html-extension nil nil org-html-extension
)
113 (:html-link-org-as-html nil nil org-html-link-org-files-as-html
)
114 (:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
115 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
116 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
117 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
118 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
119 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
120 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
121 (:html-postamble nil
"html-postamble" org-html-postamble
)
122 (:html-preamble nil
"html-preamble" org-html-preamble
)
123 (:html-head
"HTML_HEAD" nil org-html-head newline
)
124 (:html-head-extra
"HTML_HEAD_EXTRA" nil org-html-head-extra newline
)
125 (:html-head-include-default-style nil
"html-style" org-html-head-include-default-style
)
126 (:html-head-include-scripts nil
"html-scripts" org-html-head-include-scripts
)
127 (:html-table-attributes nil nil org-html-table-default-attributes
)
128 (:html-table-row-tags nil nil org-html-table-row-tags
)
129 (:html-xml-declaration nil nil org-html-xml-declaration
)
130 (:html-inline-images nil nil org-html-inline-images
)
131 (:infojs-opt
"INFOJS_OPT" nil nil
)
132 ;; Redefine regular options.
133 (:creator
"CREATOR" nil org-html-creator-string
)
134 (:with-latex nil
"tex" org-html-with-latex
)))
137 ;;; Internal Variables
139 (defvar org-html-format-table-no-css
)
140 (defvar htmlize-buffer-places
) ; from htmlize.el
142 (defvar org-html--pre
/postamble-class
"status"
143 "CSS class used for pre/postamble")
145 (defconst org-html-doctype-alist
146 '(("html4-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
147 \"http://www.w3.org/TR/html4/strict.dtd\">")
148 ("html4-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
149 \"http://www.w3.org/TR/html4/loose.dtd\">")
150 ("html4-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
151 \"http://www.w3.org/TR/html4/frameset.dtd\">")
153 ("xhtml-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
154 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
155 ("xhtml-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
156 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
157 ("xhtml-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
158 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
159 ("xhtml-11" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
160 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
162 ("html5" .
"<!DOCTYPE html>")
163 ("xhtml5" .
"<!DOCTYPE html>"))
164 "An alist mapping (x)html flavors to specific doctypes.")
166 (defconst org-html-html5-elements
167 '("article" "aside" "audio" "canvas" "details" "figcaption"
168 "figure" "footer" "header" "menu" "meter" "nav" "output"
169 "progress" "section" "video")
170 "New elements in html5.
172 <hgroup> is not included because it's currently impossible to
173 wrap special blocks around multiple headlines. For other blocks
174 that should contain headlines, use the HTML_CONTAINER property on
175 the headline itself.")
177 (defconst org-html-special-string-regexps
178 '(("\\\\-" .
"­") ; shy
179 ("---\\([^-]\\)" .
"—\\1") ; mdash
180 ("--\\([^-]\\)" .
"–\\1") ; ndash
181 ("\\.\\.\\." .
"…")) ; hellip
182 "Regular expressions for special string conversion.")
184 (defconst org-html-scripts
185 "<script type=\"text/javascript\">
187 @licstart The following is the entire license notice for the
188 JavaScript code in this tag.
190 Copyright (C) 2012-2013 Free Software Foundation, Inc.
192 The JavaScript code in this tag is free software: you can
193 redistribute it and/or modify it under the terms of the GNU
194 General Public License (GNU GPL) as published by the Free Software
195 Foundation, either version 3 of the License, or (at your option)
196 any later version. The code is distributed WITHOUT ANY WARRANTY;
197 without even the implied warranty of MERCHANTABILITY or FITNESS
198 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
200 As additional permission under GNU GPL version 3 section 7, you
201 may distribute non-source (e.g., minimized or compacted) forms of
202 that code without the copy of the GNU GPL normally required by
203 section 4, provided you include this license notice and a URL
204 through which recipients can access the Corresponding Source.
207 @licend The above is the entire license notice
208 for the JavaScript code in this tag.
210 <!--/*--><![CDATA[/*><!--*/
211 function CodeHighlightOn(elem, id)
213 var target = document.getElementById(id);
215 elem.cacheClassElem = elem.className;
216 elem.cacheClassTarget = target.className;
217 target.className = \"code-highlighted\";
218 elem.className = \"code-highlighted\";
221 function CodeHighlightOff(elem, id)
223 var target = document.getElementById(id);
224 if(elem.cacheClassElem)
225 elem.className = elem.cacheClassElem;
226 if(elem.cacheClassTarget)
227 target.className = elem.cacheClassTarget;
231 "Basic JavaScript that is needed by HTML files produced by Org mode.")
233 (defconst org-html-style-default
234 "<style type=\"text/css\">
235 <!--/*--><![CDATA[/*><!--*/
236 .title { text-align: center; }
237 .todo { font-family: monospace; color: red; }
238 .done { color: green; }
239 .tag { background-color: #eee; font-family: monospace;
240 padding: 2px; font-size: 80%; font-weight: normal; }
241 .timestamp { color: #bebebe; }
242 .timestamp-kwd { color: #5f9ea0; }
243 .right { margin-left: auto; margin-right: 0px; text-align: right; }
244 .left { margin-left: 0px; margin-right: auto; text-align: left; }
245 .center { margin-left: auto; margin-right: auto; text-align: center; }
246 .underline { text-decoration: underline; }
247 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
248 p.verse { margin-left: 3%; }
250 border: 1px solid #ccc;
251 box-shadow: 3px 3px 3px #eee;
253 font-family: monospace;
265 background-color: white;
269 border: 1px solid black;
271 pre.src:hover:before { display: inline;}
272 pre.src-sh:before { content: 'sh'; }
273 pre.src-bash:before { content: 'sh'; }
274 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
275 pre.src-R:before { content: 'R'; }
276 pre.src-perl:before { content: 'Perl'; }
277 pre.src-java:before { content: 'Java'; }
278 pre.src-sql:before { content: 'SQL'; }
280 table { border-collapse:collapse; }
281 td, th { vertical-align:top; }
282 th.right { text-align: center; }
283 th.left { text-align: center; }
284 th.center { text-align: center; }
285 td.right { text-align: right; }
286 td.left { text-align: left; }
287 td.center { text-align: center; }
288 dt { font-weight: bold; }
289 .footpara:nth-child(2) { display: inline; }
290 .footpara { display: block; }
291 .footdef { margin-bottom: 1em; }
292 .figure { padding: 1em; }
293 .figure p { text-align: center; }
296 border: 2px solid gray;
301 { text-align: right; font-size: 70%; white-space: nowrap; }
302 textarea { overflow-x: auto; }
303 .linenr { font-size: smaller }
304 .code-highlighted { background-color: #ffff00; }
305 .org-info-js_info-navigation { border-style: none; }
306 #org-info-js_console-label
307 { font-size: 10px; font-weight: bold; white-space: nowrap; }
308 .org-info-js_search-highlight
309 { background-color: #ffff00; color: #000000; font-weight: bold; }
312 "The default style specification for exported HTML files.
313 You can use `org-html-head' and `org-html-head-extra' to add to
314 this style. If you don't want to include this default style,
315 customize `org-html-head-include-default-style'.")
318 ;;; User Configuration Variables
320 (defgroup org-export-html nil
321 "Options for exporting Org mode files to HTML."
322 :tag
"Org Export HTML"
327 (defvar org-html-infojs-opts-table
328 '((path PATH
"http://orgmode.org/org-info.js")
332 (tdepth TOC_DEPTH
"max")
333 (sdepth SECTION_DEPTH
"max")
334 (mouse MOUSE_HINT
"underline")
335 (buttons VIEW_BUTTONS
"0")
337 (up LINK_UP
:html-link-up
)
338 (home LINK_HOME
:html-link-home
))
339 "JavaScript options, long form for script, default values.")
341 (defcustom org-html-use-infojs
'when-configured
342 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
343 This option can be nil or t to never or always use the script.
344 It can also be the symbol `when-configured', meaning that the
345 script will be linked into the export file if and only if there
346 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
347 `org-html-infojs-options'."
348 :group
'org-export-html
350 :package-version
'(Org .
"8.0")
352 (const :tag
"Never" nil
)
353 (const :tag
"When configured in buffer" when-configured
)
354 (const :tag
"Always" t
)))
356 (defcustom org-html-infojs-options
357 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
358 "Options settings for the INFOJS JavaScript.
359 Each of the options must have an entry in `org-html-infojs-opts-table'.
360 The value can either be a string that will be passed to the script, or
361 a property. This property is then assumed to be a property that is defined
362 by the Export/Publishing setup of Org.
363 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
364 means to use the maximum value consistent with other options."
365 :group
'org-export-html
367 :package-version
'(Org .
"8.0")
369 `(set :greedy t
:inline t
372 (list 'cons
(list 'const
(car x
))
374 (symbol :tag
"Publishing/Export property")
375 (string :tag
"Value"))))
376 org-html-infojs-opts-table
)))
378 (defcustom org-html-infojs-template
379 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
382 * @source: %SCRIPT_PATH
384 * @licstart The following is the entire license notice for the
385 * JavaScript code in %SCRIPT_PATH.
387 * Copyright (C) 2012-2013 Free Software Foundation, Inc.
390 * The JavaScript code in this tag is free software: you can
391 * redistribute it and/or modify it under the terms of the GNU
392 * General Public License (GNU GPL) as published by the Free Software
393 * Foundation, either version 3 of the License, or (at your option)
394 * any later version. The code is distributed WITHOUT ANY WARRANTY;
395 * without even the implied warranty of MERCHANTABILITY or FITNESS
396 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
398 * As additional permission under GNU GPL version 3 section 7, you
399 * may distribute non-source (e.g., minimized or compacted) forms of
400 * that code without the copy of the GNU GPL normally required by
401 * section 4, provided you include this license notice and a URL
402 * through which recipients can access the Corresponding Source.
404 * @licend The above is the entire license notice
405 * for the JavaScript code in %SCRIPT_PATH.
410 <script type=\"text/javascript\">
413 @licstart The following is the entire license notice for the
414 JavaScript code in this tag.
416 Copyright (C) 2012-2013 Free Software Foundation, Inc.
418 The JavaScript code in this tag is free software: you can
419 redistribute it and/or modify it under the terms of the GNU
420 General Public License (GNU GPL) as published by the Free Software
421 Foundation, either version 3 of the License, or (at your option)
422 any later version. The code is distributed WITHOUT ANY WARRANTY;
423 without even the implied warranty of MERCHANTABILITY or FITNESS
424 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
426 As additional permission under GNU GPL version 3 section 7, you
427 may distribute non-source (e.g., minimized or compacted) forms of
428 that code without the copy of the GNU GPL normally required by
429 section 4, provided you include this license notice and a URL
430 through which recipients can access the Corresponding Source.
433 @licend The above is the entire license notice
434 for the JavaScript code in this tag.
437 <!--/*--><![CDATA[/*><!--*/
439 org_html_manager.setup(); // activate after the parameters are set
442 "The template for the export style additions when org-info.js is used.
443 Option settings will replace the %MANAGER-OPTIONS cookie."
444 :group
'org-export-html
446 :package-version
'(Org .
"8.0")
449 (defun org-html-infojs-install-script (exp-plist backend
)
450 "Install script in export options when appropriate.
451 EXP-PLIST is a plist containing export options. BACKEND is the
452 export back-end currently used."
453 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
454 (not org-html-use-infojs
)
455 (and (eq org-html-use-infojs
'when-configured
)
456 (or (not (plist-get exp-plist
:infojs-opt
))
457 (string-match "\\<view:nil\\>"
458 (plist-get exp-plist
:infojs-opt
)))))
459 (let* ((template org-html-infojs-template
)
460 (ptoc (plist-get exp-plist
:with-toc
))
461 (hlevels (plist-get exp-plist
:headline-levels
))
463 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
464 (options (plist-get exp-plist
:infojs-opt
))
465 (table org-html-infojs-opts-table
)
467 (dolist (entry table
)
468 (let* ((opt (car entry
))
470 ;; Compute default values for script option OPT from
471 ;; `org-html-infojs-options' variable.
473 (let ((default (cdr (assq opt org-html-infojs-options
))))
474 (if (and (symbolp default
) (not (memq default
'(t nil
))))
475 (plist-get exp-plist default
)
477 ;; Value set through INFOJS_OPT keyword has precedence
478 ;; over the default one.
479 (val (if (and options
480 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
482 (match-string 1 options
)
486 (replace-regexp-in-string
487 "%SCRIPT_PATH" val template t t
)))
488 (sdepth (when (integerp (read val
))
489 (setq sdepth
(min (read val
) sdepth
))))
490 (tdepth (when (integerp (read val
))
491 (setq tdepth
(min (read val
) tdepth
))))
494 ((or (eq val t
) (equal val
"t")) "1")
495 ((or (eq val nil
) (equal val
"nil")) "0")
497 (t (format "%s" val
))))
498 (push (cons var val
) style
)))))
499 ;; Now we set the depth of the *generated* TOC to SDEPTH,
500 ;; because the toc will actually determine the splitting. How
501 ;; much of the toc will actually be displayed is governed by the
503 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
504 ;; The table of contents should not show more sections than we
506 (setq tdepth
(min tdepth sdepth
))
507 (push (cons "TOC_DEPTH" tdepth
) style
)
508 ;; Build style string.
509 (setq style
(mapconcat
510 (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
514 (when (and style
(> (length style
) 0))
515 (and (string-match "%MANAGER_OPTIONS" template
)
516 (setq style
(replace-match style t t template
))
519 exp-plist
:html-head-extra
520 (concat (or (plist-get exp-plist
:html-head-extra
) "")
523 ;; This script absolutely needs the table of contents, so we
524 ;; change that setting.
525 (unless (plist-get exp-plist
:with-toc
)
526 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
527 ;; Return the modified property list.
532 (defcustom org-html-text-markup-alist
533 '((bold .
"<b>%s</b>")
534 (code .
"<code>%s</code>")
535 (italic .
"<i>%s</i>")
536 (strike-through .
"<del>%s</del>")
537 (underline .
"<span class=\"underline\">%s</span>")
538 (verbatim .
"<code>%s</code>"))
539 "Alist of HTML expressions to convert text markup.
541 The key must be a symbol among `bold', `code', `italic',
542 `strike-through', `underline' and `verbatim'. The value is
543 a formatting string to wrap fontified text with.
545 If no association can be found for a given markup, text will be
547 :group
'org-export-html
549 :package-version
'(Org .
"8.0")
550 :type
'(alist :key-type
(symbol :tag
"Markup type")
551 :value-type
(string :tag
"Format string"))
552 :options
'(bold code italic strike-through underline verbatim
))
554 (defcustom org-html-indent nil
555 "Non-nil means to indent the generated HTML.
556 Warning: non-nil may break indentation of source code blocks."
557 :group
'org-export-html
559 :package-version
'(Org .
"8.0")
562 (defcustom org-html-use-unicode-chars nil
563 "Non-nil means to use unicode characters instead of HTML entities."
564 :group
'org-export-html
566 :package-version
'(Org .
"8.0")
571 (defcustom org-html-format-drawer-function
572 (lambda (name contents
) contents
)
573 "Function called to format a drawer in HTML code.
575 The function must accept two parameters:
576 NAME the drawer name, like \"LOGBOOK\"
577 CONTENTS the contents of the drawer.
579 The function should return the string to be exported.
581 For example, the variable could be set to the following function
582 in order to mimic default behaviour:
584 The default value simply returns the value of CONTENTS."
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
'ignore
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
'ignore
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* ((headline-number (org-export-get-headline-number headline info
))
1985 (todo (and (plist-get info
:with-todo-keywords
)
1986 (let ((todo (org-element-property :todo-keyword headline
)))
1987 (and todo
(org-export-data todo info
)))))
1988 (todo-type (and todo
(org-element-property :todo-type headline
)))
1989 (priority (and (plist-get info
:with-priority
)
1990 (org-element-property :priority headline
)))
1991 (text (org-export-data-with-backend
1992 (org-export-get-alt-title headline info
)
1993 ;; Create an anonymous back-end that will ignore any
1994 ;; footnote-reference, link, radio-target and target
1995 ;; in table of contents.
1996 (org-export-create-backend
1998 :transcoders
'((footnote-reference . ignore
)
1999 (link .
(lambda (object c i
) c
))
2000 (radio-target .
(lambda (object c i
) c
))
2003 (tags (and (eq (plist-get info
:with-tags
) t
)
2004 (org-export-get-tags headline info
))))
2005 (format "<a href=\"#%s\">%s</a>"
2007 (org-export-solidify-link-text
2008 (or (org-element-property :CUSTOM_ID headline
)
2010 (mapconcat #'number-to-string headline-number
"-"))))
2013 (and (not (org-export-low-level-p headline info
))
2014 (org-export-numbered-headline-p headline info
)
2015 (concat (mapconcat #'number-to-string headline-number
".")
2017 (apply (if (not (eq org-html-format-headline-function
'ignore
))
2018 (lambda (todo todo-type priority text tags
&rest ignore
)
2019 (funcall org-html-format-headline-function
2020 todo todo-type priority text tags
))
2021 #'org-html-format-headline
)
2022 todo todo-type priority text tags
:section-number nil
)))))
2024 (defun org-html-list-of-listings (info)
2025 "Build a list of listings.
2026 INFO is a plist used as a communication channel. Return the list
2027 of listings as a string, or nil if it is empty."
2028 (let ((lol-entries (org-export-collect-listings info
)))
2030 (concat "<div id=\"list-of-listings\">\n"
2031 (format "<h%d>%s</h%d>\n"
2032 org-html-toplevel-hlevel
2033 (org-html--translate "List of Listings" info
)
2034 org-html-toplevel-hlevel
)
2035 "<div id=\"text-list-of-listings\">\n<ul>\n"
2037 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2038 (org-html--translate "Listing %d:" info
))))
2041 (let ((label (org-element-property :name entry
))
2044 (or (org-export-get-caption entry t
)
2045 (org-export-get-caption entry
))
2050 (concat (format initial-fmt
(incf count
)) " " title
)
2051 (format "<a href=\"#%s\">%s %s</a>"
2052 (org-export-solidify-link-text label
)
2053 (format initial-fmt
(incf count
))
2057 "\n</ul>\n</div>\n</div>"))))
2059 (defun org-html-list-of-tables (info)
2060 "Build a list of tables.
2061 INFO is a plist used as a communication channel. Return the list
2062 of tables as a string, or nil if it is empty."
2063 (let ((lol-entries (org-export-collect-tables info
)))
2065 (concat "<div id=\"list-of-tables\">\n"
2066 (format "<h%d>%s</h%d>\n"
2067 org-html-toplevel-hlevel
2068 (org-html--translate "List of Tables" info
)
2069 org-html-toplevel-hlevel
)
2070 "<div id=\"text-list-of-tables\">\n<ul>\n"
2072 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2073 (org-html--translate "Table %d:" info
))))
2076 (let ((label (org-element-property :name entry
))
2079 (or (org-export-get-caption entry t
)
2080 (org-export-get-caption entry
))
2085 (concat (format initial-fmt
(incf count
)) " " title
)
2086 (format "<a href=\"#%s\">%s %s</a>"
2087 (org-export-solidify-link-text label
)
2088 (format initial-fmt
(incf count
))
2092 "\n</ul>\n</div>\n</div>"))))
2095 ;;; Transcode Functions
2099 (defun org-html-bold (bold contents info
)
2100 "Transcode BOLD from Org to HTML.
2101 CONTENTS is the text with bold markup. INFO is a plist holding
2102 contextual information."
2103 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
2108 (defun org-html-center-block (center-block contents info
)
2109 "Transcode a CENTER-BLOCK element from Org to HTML.
2110 CONTENTS holds the contents of the block. INFO is a plist
2111 holding contextual information."
2112 (format "<div class=\"center\">\n%s</div>" contents
))
2116 (defun org-html-clock (clock contents info
)
2117 "Transcode a CLOCK element from Org to HTML.
2118 CONTENTS is nil. INFO is a plist used as a communication
2121 <span class=\"timestamp-wrapper\">
2122 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2127 (org-element-property :raw-value
2128 (org-element-property :value clock
)))
2129 (let ((time (org-element-property :duration clock
)))
2130 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2134 (defun org-html-code (code contents info
)
2135 "Transcode CODE from Org to HTML.
2136 CONTENTS is nil. INFO is a plist holding contextual
2138 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
2139 (org-html-encode-plain-text (org-element-property :value code
))))
2143 (defun org-html-drawer (drawer contents info
)
2144 "Transcode a DRAWER element from Org to HTML.
2145 CONTENTS holds the contents of the block. INFO is a plist
2146 holding contextual information."
2147 (if (functionp org-html-format-drawer-function
)
2148 (funcall org-html-format-drawer-function
2149 (org-element-property :drawer-name drawer
)
2151 ;; If there's no user defined function: simply
2152 ;; display contents of the drawer.
2157 (defun org-html-dynamic-block (dynamic-block contents info
)
2158 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2159 CONTENTS holds the contents of the block. INFO is a plist
2160 holding contextual information. See `org-export-data'."
2165 (defun org-html-entity (entity contents info
)
2166 "Transcode an ENTITY object from Org to HTML.
2167 CONTENTS are the definition itself. INFO is a plist holding
2168 contextual information."
2169 (org-element-property :html entity
))
2173 (defun org-html-example-block (example-block contents info
)
2174 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2175 CONTENTS is nil. INFO is a plist holding contextual
2177 (if (org-export-read-attribute :attr_html example-block
:textarea
)
2178 (org-html--textarea-block example-block
)
2179 (format "<pre class=\"example\">\n%s</pre>"
2180 (org-html-format-code example-block info
))))
2184 (defun org-html-export-snippet (export-snippet contents info
)
2185 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2186 CONTENTS is nil. INFO is a plist holding contextual
2188 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2189 (org-element-property :value export-snippet
)))
2193 (defun org-html-export-block (export-block contents info
)
2194 "Transcode a EXPORT-BLOCK element from Org to HTML.
2195 CONTENTS is nil. INFO is a plist holding contextual information."
2196 (when (string= (org-element-property :type export-block
) "HTML")
2197 (org-remove-indentation (org-element-property :value export-block
))))
2201 (defun org-html-fixed-width (fixed-width contents info
)
2202 "Transcode a FIXED-WIDTH element from Org to HTML.
2203 CONTENTS is nil. INFO is a plist holding contextual information."
2204 (format "<pre class=\"example\">\n%s</pre>"
2205 (org-html-do-format-code
2206 (org-remove-indentation
2207 (org-element-property :value fixed-width
)))))
2209 ;;;; Footnote Reference
2211 (defun org-html-footnote-reference (footnote-reference contents info
)
2212 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2213 CONTENTS is nil. INFO is a plist holding contextual information."
2215 ;; Insert separator between two footnotes in a row.
2216 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2217 (when (eq (org-element-type prev
) 'footnote-reference
)
2218 org-html-footnote-separator
))
2220 ((not (org-export-footnote-first-reference-p footnote-reference info
))
2221 (org-html-format-footnote-reference
2222 (org-export-get-footnote-number footnote-reference info
)
2224 ;; Inline definitions are secondary strings.
2225 ((eq (org-element-property :type footnote-reference
) 'inline
)
2226 (org-html-format-footnote-reference
2227 (org-export-get-footnote-number footnote-reference info
)
2229 ;; Non-inline footnotes definitions are full Org data.
2230 (t (org-html-format-footnote-reference
2231 (org-export-get-footnote-number footnote-reference info
)
2236 (defun org-html-format-headline--wrap
2237 (headline info
&optional format-function
&rest extra-keys
)
2238 "Transcode a HEADLINE element from Org to HTML.
2239 CONTENTS holds the contents of the headline. INFO is a plist
2240 holding contextual information."
2241 (let* ((level (+ (org-export-get-relative-level headline info
)
2242 (1- org-html-toplevel-hlevel
)))
2243 (headline-number (org-export-get-headline-number headline info
))
2244 (section-number (and (not (org-export-low-level-p headline info
))
2245 (org-export-numbered-headline-p headline info
)
2246 (mapconcat 'number-to-string
2247 headline-number
".")))
2248 (todo (and (plist-get info
:with-todo-keywords
)
2249 (let ((todo (org-element-property :todo-keyword headline
)))
2250 (and todo
(org-export-data todo info
)))))
2251 (todo-type (and todo
(org-element-property :todo-type headline
)))
2252 (priority (and (plist-get info
:with-priority
)
2253 (org-element-property :priority headline
)))
2254 (text (org-export-data (org-element-property :title headline
) info
))
2255 (tags (and (plist-get info
:with-tags
)
2256 (org-export-get-tags headline info
)))
2257 (headline-label (or (org-element-property :CUSTOM_ID headline
)
2258 (concat "sec-" (mapconcat 'number-to-string
2259 headline-number
"-"))))
2261 (cond ((functionp format-function
) format-function
)
2262 ((not (eq org-html-format-headline-function
'ignore
))
2263 (lambda (todo todo-type priority text tags
&rest ignore
)
2264 (funcall org-html-format-headline-function
2265 todo todo-type priority text tags
)))
2266 (t 'org-html-format-headline
))))
2267 (apply format-function
2268 todo todo-type priority text tags
2269 :headline-label headline-label
:level level
2270 :section-number section-number extra-keys
)))
2272 (defun org-html-headline (headline contents info
)
2273 "Transcode a HEADLINE element from Org to HTML.
2274 CONTENTS holds the contents of the headline. INFO is a plist
2275 holding contextual information."
2277 (setq contents
(or contents
""))
2278 (let* ((numberedp (org-export-numbered-headline-p headline info
))
2279 (level (org-export-get-relative-level headline info
))
2280 (text (org-export-data (org-element-property :title headline
) info
))
2281 (todo (and (plist-get info
:with-todo-keywords
)
2282 (let ((todo (org-element-property :todo-keyword headline
)))
2283 (and todo
(org-export-data todo info
)))))
2284 (todo-type (and todo
(org-element-property :todo-type headline
)))
2285 (tags (and (plist-get info
:with-tags
)
2286 (org-export-get-tags headline info
)))
2287 (priority (and (plist-get info
:with-priority
)
2288 (org-element-property :priority headline
)))
2289 (section-number (and (org-export-numbered-headline-p headline info
)
2290 (mapconcat 'number-to-string
2291 (org-export-get-headline-number
2292 headline info
) ".")))
2293 ;; Create the headline text.
2294 (full-text (org-html-format-headline--wrap headline info
)))
2296 ;; Case 1: This is a footnote section: ignore it.
2297 ((org-element-property :footnote-section-p headline
) nil
)
2298 ;; Case 2. This is a deep sub-tree: export it as a list item.
2299 ;; Also export as items headlines for which no section
2300 ;; format has been found.
2301 ((org-export-low-level-p headline info
)
2302 ;; Build the real contents of the sub-tree.
2303 (let* ((type (if numberedp
'ordered
'unordered
))
2304 (itemized-body (org-html-format-list-item
2305 contents type nil info nil full-text
)))
2307 (and (org-export-first-sibling-p headline info
)
2308 (org-html-begin-plain-list type
))
2310 (and (org-export-last-sibling-p headline info
)
2311 (org-html-end-plain-list type
)))))
2312 ;; Case 3. Standard headline. Export it as a section.
2314 (let* ((section-number (mapconcat 'number-to-string
2315 (org-export-get-headline-number
2316 headline info
) "-"))
2318 (list (org-element-property :CUSTOM_ID headline
)
2319 (concat "sec-" section-number
)
2320 (org-element-property :ID headline
))))
2321 (preferred-id (car ids
))
2322 (extra-ids (cdr ids
))
2323 (extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2324 (level1 (+ level
(1- org-html-toplevel-hlevel
)))
2325 (first-content (car (org-element-contents headline
))))
2326 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2327 (org-html--container headline info
)
2328 (format "outline-container-%s"
2329 (or (org-element-property :CUSTOM_ID headline
)
2330 (concat "sec-" section-number
)))
2331 (concat (format "outline-%d" level1
) (and extra-class
" ")
2333 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2338 (let ((id (org-export-solidify-link-text
2339 (if (org-uuidgen-p x
) (concat "ID-" x
)
2341 (org-html--anchor id
)))
2345 ;; When there is no section, pretend there is an empty
2346 ;; one to get the correct <div class="outline- ...>
2347 ;; which is needed by `org-info.js'.
2348 (if (not (eq (org-element-type first-content
) 'section
))
2349 (concat (org-html-section first-content
"" info
)
2352 (org-html--container headline info
)))))))
2354 (defun org-html--container (headline info
)
2355 (or (org-element-property :HTML_CONTAINER headline
)
2356 (if (= 1 (org-export-get-relative-level headline info
))
2357 (plist-get info
:html-container
)
2360 ;;;; Horizontal Rule
2362 (defun org-html-horizontal-rule (horizontal-rule contents info
)
2363 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2364 CONTENTS is nil. INFO is a plist holding contextual information."
2365 (org-html-close-tag "hr" nil info
))
2367 ;;;; Inline Src Block
2369 (defun org-html-inline-src-block (inline-src-block contents info
)
2370 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2371 CONTENTS holds the contents of the item. INFO is a plist holding
2372 contextual information."
2373 (let* ((org-lang (org-element-property :language inline-src-block
))
2374 (code (org-element-property :value inline-src-block
)))
2375 (error "Cannot export inline src block")))
2379 (defun org-html-format-section (text class
&optional id
)
2380 "Format a section with TEXT into a HTML div with CLASS and ID."
2381 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
2382 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
2384 (defun org-html-inlinetask (inlinetask contents info
)
2385 "Transcode an INLINETASK element from Org to HTML.
2386 CONTENTS holds the contents of the block. INFO is a plist
2387 holding contextual information."
2389 ;; If `org-html-format-inlinetask-function' is not 'ignore, call it
2390 ;; with appropriate arguments.
2391 ((not (eq org-html-format-inlinetask-function
'ignore
))
2392 (let ((format-function
2394 (lambda (todo todo-type priority text tags
2395 &key contents
&allow-other-keys
)
2396 (funcall org-html-format-inlinetask-function
2397 todo todo-type priority text tags contents
)))))
2398 (org-html-format-headline--wrap
2399 inlinetask info format-function
:contents contents
)))
2400 ;; Otherwise, use a default template.
2401 (t (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2402 (org-html-format-headline--wrap inlinetask info
)
2403 (org-html-close-tag "br" nil info
)
2408 (defun org-html-italic (italic contents info
)
2409 "Transcode ITALIC from Org to HTML.
2410 CONTENTS is the text with italic markup. INFO is a plist holding
2411 contextual information."
2412 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
2416 (defun org-html-checkbox (checkbox)
2417 "Format CHECKBOX into HTML."
2418 (case checkbox
(on "<code>[X]</code>")
2419 (off "<code>[ ]</code>")
2420 (trans "<code>[-]</code>")
2423 (defun org-html-format-list-item (contents type checkbox info
2424 &optional term-counter-id
2426 "Format a list item into HTML."
2427 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" ")))
2428 (br (org-html-close-tag "br" nil info
)))
2432 (let* ((counter term-counter-id
)
2433 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2435 (format "<li%s>" extra
)
2436 (when headline
(concat headline br
)))))
2438 (let* ((id term-counter-id
)
2439 (extra (if id
(format " id=\"%s\"" id
) "")))
2441 (format "<li%s>" extra
)
2442 (when headline
(concat headline br
)))))
2444 (let* ((term term-counter-id
))
2445 (setq term
(or term
"(no term)"))
2446 ;; Check-boxes in descriptive lists are associated to tag.
2447 (concat (format "<dt> %s </dt>"
2448 (concat checkbox term
))
2450 (unless (eq type
'descriptive
) checkbox
)
2455 (descriptive "</dd>")))))
2457 (defun org-html-item (item contents info
)
2458 "Transcode an ITEM element from Org to HTML.
2459 CONTENTS holds the contents of the item. INFO is a plist holding
2460 contextual information."
2461 (let* ((plain-list (org-export-get-parent item
))
2462 (type (org-element-property :type plain-list
))
2463 (counter (org-element-property :counter item
))
2464 (checkbox (org-element-property :checkbox item
))
2465 (tag (let ((tag (org-element-property :tag item
)))
2466 (and tag
(org-export-data tag info
)))))
2467 (org-html-format-list-item
2468 contents type checkbox info
(or tag counter
))))
2472 (defun org-html-keyword (keyword contents info
)
2473 "Transcode a KEYWORD element from Org to HTML.
2474 CONTENTS is nil. INFO is a plist holding contextual information."
2475 (let ((key (org-element-property :key keyword
))
2476 (value (org-element-property :value keyword
)))
2478 ((string= key
"HTML") value
)
2479 ((string= key
"TOC")
2480 (let ((value (downcase value
)))
2482 ((string-match "\\<headlines\\>" value
)
2483 (let ((depth (or (and (string-match "[0-9]+" value
)
2484 (string-to-number (match-string 0 value
)))
2485 (plist-get info
:with-toc
))))
2486 (org-html-toc depth info
)))
2487 ((string= "listings" value
) (org-html-list-of-listings info
))
2488 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2490 ;;;; Latex Environment
2492 (defun org-html-format-latex (latex-frag processing-type
)
2493 "Format a LaTeX fragment LATEX-FRAG into HTML."
2494 (let ((cache-relpath "") (cache-dir ""))
2495 (unless (eq processing-type
'mathjax
)
2496 (let ((bfn (or (buffer-file-name)
2498 (expand-file-name "latex" temporary-file-directory
)))))
2501 (file-name-sans-extension
2502 (file-name-nondirectory bfn
)))
2503 cache-dir
(file-name-directory bfn
))))
2506 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2507 nil nil processing-type
)
2510 (defun org-html-latex-environment (latex-environment contents info
)
2511 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2512 CONTENTS is nil. INFO is a plist holding contextual information."
2513 (let ((processing-type (plist-get info
:with-latex
))
2514 (latex-frag (org-remove-indentation
2515 (org-element-property :value latex-environment
)))
2516 (attributes (org-export-read-attribute :attr_html latex-environment
)))
2517 (case processing-type
2519 (org-html-format-latex latex-frag
'mathjax
))
2520 ((dvipng imagemagick
)
2521 (let ((formula-link (org-html-format-latex latex-frag processing-type
)))
2522 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2523 ;; Do not provide a caption or a name to be consistent with
2524 ;; `mathjax' handling.
2525 (org-html--wrap-image
2526 (org-html--format-image
2527 (match-string 1 formula-link
) attributes info
) info
))))
2532 (defun org-html-latex-fragment (latex-fragment contents info
)
2533 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2534 CONTENTS is nil. INFO is a plist holding contextual information."
2535 (let ((latex-frag (org-element-property :value latex-fragment
))
2536 (processing-type (plist-get info
:with-latex
)))
2537 (case processing-type
2539 (org-html-format-latex latex-frag
'mathjax
))
2540 ((dvipng imagemagick
)
2541 (let ((formula-link (org-html-format-latex latex-frag processing-type
)))
2542 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2543 (org-html--format-image (match-string 1 formula-link
) nil info
))))
2548 (defun org-html-line-break (line-break contents info
)
2549 "Transcode a LINE-BREAK object from Org to HTML.
2550 CONTENTS is nil. INFO is a plist holding contextual information."
2551 (concat (org-html-close-tag "br" nil info
) "\n"))
2555 (defun org-html-inline-image-p (link info
)
2556 "Non-nil when LINK is meant to appear as an image.
2557 INFO is a plist used as a communication channel. LINK is an
2558 inline image when it has no description and targets an image
2559 file (see `org-html-inline-image-rules' for more information), or
2560 if its description is a single link targeting an image file."
2561 (if (not (org-element-contents link
))
2562 (org-export-inline-image-p link org-html-inline-image-rules
)
2564 (let ((link-count 0))
2565 (org-element-map (org-element-contents link
)
2566 (cons 'plain-text org-element-all-objects
)
2568 (case (org-element-type obj
)
2569 (plain-text (org-string-nw-p obj
))
2570 (link (if (= link-count
1) t
2572 (not (org-export-inline-image-p
2573 obj org-html-inline-image-rules
))))
2577 (defvar org-html-standalone-image-predicate
)
2578 (defun org-html-standalone-image-p (element info
)
2579 "Test if ELEMENT is a standalone image.
2581 INFO is a plist holding contextual information.
2583 Return non-nil, if ELEMENT is of type paragraph and its sole
2584 content, save for white spaces, is a link that qualifies as an
2587 Return non-nil, if ELEMENT is of type link and its containing
2588 paragraph has no other content save white spaces.
2590 Return nil, otherwise.
2592 Bind `org-html-standalone-image-predicate' to constrain paragraph
2593 further. For example, to check for only captioned standalone
2596 \(lambda (paragraph) (org-element-property :caption paragraph))"
2597 (let ((paragraph (case (org-element-type element
)
2599 (link (org-export-get-parent element
)))))
2600 (and (eq (org-element-type paragraph
) 'paragraph
)
2601 (or (not (and (boundp 'org-html-standalone-image-predicate
)
2602 (functionp org-html-standalone-image-predicate
)))
2603 (funcall org-html-standalone-image-predicate paragraph
))
2604 (not (let ((link-count 0))
2605 (org-element-map (org-element-contents paragraph
)
2606 (cons 'plain-text org-element-all-objects
)
2607 (lambda (obj) (case (org-element-type obj
)
2608 (plain-text (org-string-nw-p obj
))
2610 (or (> (incf link-count
) 1)
2611 (not (org-html-inline-image-p obj info
))))
2613 info
'first-match
'link
))))))
2615 (defun org-html-link (link desc info
)
2616 "Transcode a LINK object from Org to HTML.
2618 DESC is the description part of the link, or the empty string.
2619 INFO is a plist holding contextual information. See
2621 (let* ((home (when (plist-get info
:html-link-home
)
2622 (org-trim (plist-get info
:html-link-home
))))
2623 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2624 (link-org-files-as-html-maybe
2626 (lambda (raw-path info
)
2627 "Treat links to `file.org' as links to `file.html', if needed.
2628 See `org-html-link-org-files-as-html'."
2630 ((and org-html-link-org-files-as-html
2632 (downcase (file-name-extension raw-path
"."))))
2633 (concat (file-name-sans-extension raw-path
) "."
2634 (plist-get info
:html-extension
)))
2636 (type (org-element-property :type link
))
2637 (raw-path (org-element-property :path link
))
2638 ;; Ensure DESC really exists, or set it to nil.
2639 (desc (org-string-nw-p desc
))
2642 ((member type
'("http" "https" "ftp" "mailto"))
2645 (concat type
":" raw-path
)) org-link-escape-chars-browser
))
2646 ((string= type
"file")
2647 ;; Treat links to ".org" files as ".html", if needed.
2649 (funcall link-org-files-as-html-maybe raw-path info
))
2650 ;; If file path is absolute, prepend it with protocol
2651 ;; component - "file://".
2652 (cond ((file-name-absolute-p raw-path
)
2654 (concat "file://" (expand-file-name
2656 ((and home use-abs-url
)
2657 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2658 ;; Add search option, if any. A search option can be
2659 ;; relative to a custom-id or a headline title. Any other
2660 ;; option is ignored.
2661 (let ((option (org-element-property :search-option link
)))
2662 (cond ((not option
) raw-path
)
2663 ((eq (aref option
0) ?
#) (concat raw-path option
))
2664 ;; External fuzzy link: try to resolve it if path
2665 ;; belongs to current project, if any.
2666 ((eq (aref option
0) ?
*)
2670 (org-publish-resolve-external-fuzzy-link
2671 (org-element-property :path link
) option
)))
2672 (and numbers
(concat "#sec-"
2673 (mapconcat 'number-to-string
2677 ;; Extract attributes from parent's paragraph. HACK: Only do
2678 ;; this for the first link in parent (inner image link for
2679 ;; inline images). This is needed as long as attributes
2680 ;; cannot be set on a per link basis.
2682 (let* ((parent (org-export-get-parent-element link
))
2683 (link (let ((container (org-export-get-parent link
)))
2684 (if (and (eq (org-element-type container
) 'link
)
2685 (org-html-inline-image-p link info
))
2688 (and (eq (org-element-map parent
'link
'identity info t
) link
)
2689 (org-export-read-attribute :attr_html parent
))))
2691 (let ((attr (org-html--make-attribute-string attributes-plist
)))
2692 (if (org-string-nw-p attr
) (concat " " attr
) "")))
2696 ((and org-html-inline-images
2697 (org-export-inline-image-p link org-html-inline-image-rules
))
2698 (org-html--format-image path attributes-plist info
))
2699 ;; Radio target: Transcode target's contents and use them as
2700 ;; link's description.
2701 ((string= type
"radio")
2702 (let ((destination (org-export-resolve-radio-link link info
)))
2704 (format "<a href=\"#%s\"%s>%s</a>"
2705 (org-export-solidify-link-text path
)
2707 (org-export-data (org-element-contents destination
) info
)))))
2708 ;; Links pointing to a headline: Find destination and build
2709 ;; appropriate referencing command.
2710 ((member type
'("custom-id" "fuzzy" "id"))
2711 (let ((destination (if (string= type
"fuzzy")
2712 (org-export-resolve-fuzzy-link link info
)
2713 (org-export-resolve-id-link link info
))))
2714 (case (org-element-type destination
)
2715 ;; ID link points to an external file.
2717 (let ((fragment (concat "ID-" path
))
2718 ;; Treat links to ".org" files as ".html", if needed.
2719 (path (funcall link-org-files-as-html-maybe
2721 (format "<a href=\"%s#%s\"%s>%s</a>"
2722 path fragment attributes
(or desc destination
))))
2723 ;; Fuzzy link points nowhere.
2728 (org-element-property :raw-link link
) info
))))
2729 ;; Link points to a headline.
2732 ;; What href to use?
2734 ;; Case 1: Headline is linked via it's CUSTOM_ID
2735 ;; property. Use CUSTOM_ID.
2736 ((string= type
"custom-id")
2737 (org-element-property :CUSTOM_ID destination
))
2738 ;; Case 2: Headline is linked via it's ID property
2739 ;; or through other means. Use the default href.
2740 ((member type
'("id" "fuzzy"))
2742 (mapconcat 'number-to-string
2743 (org-export-get-headline-number
2744 destination info
) "-")))
2745 (t (error "Shouldn't reach here"))))
2746 ;; What description to use?
2748 ;; Case 1: Headline is numbered and LINK has no
2749 ;; description. Display section number.
2750 (if (and (org-export-numbered-headline-p destination info
)
2752 (mapconcat 'number-to-string
2753 (org-export-get-headline-number
2754 destination info
) ".")
2755 ;; Case 2: Either the headline is un-numbered or
2756 ;; LINK has a custom description. Display LINK's
2757 ;; description or headline's title.
2758 (or desc
(org-export-data (org-element-property
2759 :title destination
) info
)))))
2760 (format "<a href=\"#%s\"%s>%s</a>"
2761 (org-export-solidify-link-text href
) attributes desc
)))
2762 ;; Fuzzy link points to a target or an element.
2764 (let* ((path (org-export-solidify-link-text path
))
2765 (org-html-standalone-image-predicate 'org-html--has-caption-p
)
2768 ((org-html-standalone-image-p destination info
)
2769 (org-export-get-ordinal
2770 (org-element-map destination
'link
2772 info
'link
'org-html-standalone-image-p
))
2773 (t (org-export-get-ordinal
2774 destination info nil
'org-html--has-caption-p
))))
2776 ((not number
) "No description for this link")
2777 ((numberp number
) (number-to-string number
))
2778 (t (mapconcat 'number-to-string number
".")))))
2779 (format "<a href=\"#%s\"%s>%s</a>" path attributes desc
))))))
2780 ;; Coderef: replace link with the reference name or the
2781 ;; equivalent line number.
2782 ((string= type
"coderef")
2783 (let ((fragment (concat "coderef-" path
)))
2784 (format "<a href=\"#%s\"%s%s>%s</a>"
2787 (format (concat "class=\"coderef\""
2788 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2789 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2792 (format (org-export-get-coderef-format path desc
)
2793 (org-export-resolve-coderef path info
)))))
2794 ;; Link type is handled by a special function.
2795 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2796 (funcall protocol
(org-link-unescape path
) desc
'html
))
2797 ;; External link with a description part.
2798 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2799 ;; External link without a description part.
2800 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2801 ;; No path, only description. Try to do something useful.
2802 (t (format "<i>%s</i>" desc
)))))
2806 (defun org-html-node-property (node-property contents info
)
2807 "Transcode a NODE-PROPERTY element from Org to HTML.
2808 CONTENTS is nil. INFO is a plist holding contextual
2811 (org-element-property :key node-property
)
2812 (let ((value (org-element-property :value node-property
)))
2813 (if value
(concat " " value
) ""))))
2817 (defun org-html-paragraph (paragraph contents info
)
2818 "Transcode a PARAGRAPH element from Org to HTML.
2819 CONTENTS is the contents of the paragraph, as a string. INFO is
2820 the plist used as a communication channel."
2821 (let* ((parent (org-export-get-parent paragraph
))
2822 (parent-type (org-element-type parent
))
2823 (style '((footnote-definition " class=\"footpara\"")))
2824 (extra (or (cadr (assoc parent-type style
)) "")))
2826 ((and (eq (org-element-type parent
) 'item
)
2827 (= (org-element-property :begin paragraph
)
2828 (org-element-property :contents-begin parent
)))
2829 ;; Leading paragraph in a list item have no tags.
2831 ((org-html-standalone-image-p paragraph info
)
2832 ;; Standalone image.
2834 (let ((raw (org-export-data
2835 (org-export-get-caption paragraph
) info
))
2836 (org-html-standalone-image-predicate
2837 'org-html--has-caption-p
))
2838 (if (not (org-string-nw-p raw
)) raw
2840 "<span class=\"figure-number\">"
2841 (format (org-html--translate "Figure %d:" info
)
2842 (org-export-get-ordinal
2843 (org-element-map paragraph
'link
2845 info nil
'org-html-standalone-image-p
))
2847 (label (org-element-property :name paragraph
)))
2848 (org-html--wrap-image contents info caption label
)))
2849 ;; Regular paragraph.
2850 (t (format "<p%s>\n%s</p>" extra contents
)))))
2854 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2855 ;; the correct value for the item counter
2856 (defun org-html-begin-plain-list (type &optional arg1
)
2857 "Insert the beginning of the HTML list depending on TYPE.
2858 When ARG1 is a string, use it as the start parameter for ordered
2862 (format "<ol class=\"org-ol\"%s>"
2863 (if arg1
(format " start=\"%d\"" arg1
) "")))
2864 (unordered "<ul class=\"org-ul\">")
2865 (descriptive "<dl class=\"org-dl\">")))
2867 (defun org-html-end-plain-list (type)
2868 "Insert the end of the HTML list depending on TYPE."
2872 (descriptive "</dl>")))
2874 (defun org-html-plain-list (plain-list contents info
)
2875 "Transcode a PLAIN-LIST element from Org to HTML.
2876 CONTENTS is the contents of the list. INFO is a plist holding
2877 contextual information."
2878 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2879 (type (org-element-property :type plain-list
)))
2881 (org-html-begin-plain-list type
)
2882 contents
(org-html-end-plain-list type
))))
2886 (defun org-html-convert-special-strings (string)
2887 "Convert special characters in STRING to HTML."
2888 (let ((all org-html-special-string-regexps
)
2890 (while (setq a
(pop all
))
2891 (setq re
(car a
) rpl
(cdr a
) start
0)
2892 (while (string-match re string start
)
2893 (setq string
(replace-match rpl t nil string
))))
2896 (defun org-html-encode-plain-text (text)
2897 "Convert plain text characters from TEXT to HTML equivalent.
2898 Possible conversions are set in `org-html-protect-char-alist'."
2901 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2902 org-html-protect-char-alist
)
2905 (defun org-html-plain-text (text info
)
2906 "Transcode a TEXT string from Org to HTML.
2907 TEXT is the string to transcode. INFO is a plist holding
2908 contextual information."
2909 (let ((output text
))
2910 ;; Protect following characters: <, >, &.
2911 (setq output
(org-html-encode-plain-text output
))
2912 ;; Handle smart quotes. Be sure to provide original string since
2913 ;; OUTPUT may have been modified.
2914 (when (plist-get info
:with-smart-quotes
)
2915 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2916 ;; Handle special strings.
2917 (when (plist-get info
:with-special-strings
)
2918 (setq output
(org-html-convert-special-strings output
)))
2919 ;; Handle break preservation if required.
2920 (when (plist-get info
:preserve-breaks
)
2922 (replace-regexp-in-string
2923 "\\(\\\\\\\\\\)?[ \t]*\n"
2924 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
2931 (defun org-html-planning (planning contents info
)
2932 "Transcode a PLANNING element from Org to HTML.
2933 CONTENTS is nil. INFO is a plist used as a communication
2935 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2937 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2942 (let ((closed (org-element-property :closed planning
)))
2944 (format span-fmt org-closed-string
2946 (org-element-property :raw-value closed
)))))
2947 (let ((deadline (org-element-property :deadline planning
)))
2949 (format span-fmt org-deadline-string
2951 (org-element-property :raw-value deadline
)))))
2952 (let ((scheduled (org-element-property :scheduled planning
)))
2954 (format span-fmt org-scheduled-string
2956 (org-element-property :raw-value scheduled
)))))))
2959 ;;;; Property Drawer
2961 (defun org-html-property-drawer (property-drawer contents info
)
2962 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2963 CONTENTS holds the contents of the drawer. INFO is a plist
2964 holding contextual information."
2965 (and (org-string-nw-p contents
)
2966 (format "<pre class=\"example\">\n%s</pre>" contents
)))
2970 (defun org-html-quote-block (quote-block contents info
)
2971 "Transcode a QUOTE-BLOCK element from Org to HTML.
2972 CONTENTS holds the contents of the block. INFO is a plist
2973 holding contextual information."
2974 (format "<blockquote>\n%s</blockquote>" contents
))
2978 (defun org-html-quote-section (quote-section contents info
)
2979 "Transcode a QUOTE-SECTION element from Org to HTML.
2980 CONTENTS is nil. INFO is a plist holding contextual information."
2981 (let ((value (org-remove-indentation
2982 (org-element-property :value quote-section
))))
2983 (when value
(format "<pre>\n%s</pre>" value
))))
2987 (defun org-html-section (section contents info
)
2988 "Transcode a SECTION element from Org to HTML.
2989 CONTENTS holds the contents of the section. INFO is a plist
2990 holding contextual information."
2991 (let ((parent (org-export-get-parent-headline section
)))
2992 ;; Before first headline: no container, just return CONTENTS.
2993 (if (not parent
) contents
2994 ;; Get div's class and id references.
2995 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2996 (1- org-html-toplevel-hlevel
)))
3000 (org-export-get-headline-number parent info
) "-")))
3001 ;; Build return value.
3002 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
3004 (or (org-element-property :CUSTOM_ID parent
) section-number
)
3009 (defun org-html-radio-target (radio-target text info
)
3010 "Transcode a RADIO-TARGET object from Org to HTML.
3011 TEXT is the text of the target. INFO is a plist holding
3012 contextual information."
3013 (let ((id (org-export-solidify-link-text
3014 (org-element-property :value radio-target
))))
3015 (org-html--anchor id text
)))
3019 (defun org-html-special-block (special-block contents info
)
3020 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3021 CONTENTS holds the contents of the block. INFO is a plist
3022 holding contextual information."
3023 (let* ((block-type (downcase
3024 (org-element-property :type special-block
)))
3025 (contents (or contents
""))
3026 (html5-fancy (and (org-html-html5-p info
)
3027 (plist-get info
:html-html5-fancy
)
3028 (member block-type org-html-html5-elements
)))
3029 (attributes (org-export-read-attribute :attr_html special-block
)))
3031 (let ((class (plist-get attributes
:class
)))
3032 (setq attributes
(plist-put attributes
:class
3033 (if class
(concat class
" " block-type
)
3035 (setq attributes
(org-html--make-attribute-string attributes
))
3036 (when (not (equal attributes
""))
3037 (setq attributes
(concat " " attributes
)))
3039 (format "<%s%s>\n%s</%s>" block-type attributes
3040 contents block-type
)
3041 (format "<div%s>\n%s\n</div>" attributes contents
))))
3045 (defun org-html-src-block (src-block contents info
)
3046 "Transcode a SRC-BLOCK element from Org to HTML.
3047 CONTENTS holds the contents of the item. INFO is a plist holding
3048 contextual information."
3049 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3050 (org-html--textarea-block src-block
)
3051 (let ((lang (org-element-property :language src-block
))
3052 (caption (org-export-get-caption src-block
))
3053 (code (org-html-format-code src-block info
))
3054 (label (let ((lbl (org-element-property :name src-block
)))
3056 (format " id=\"%s\""
3057 (org-export-solidify-link-text lbl
))))))
3058 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3060 "<div class=\"org-src-container\">\n%s%s\n</div>"
3061 (if (not caption
) ""
3062 (format "<label class=\"org-src-name\">%s</label>"
3063 (org-export-data caption info
)))
3064 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3066 ;;;; Statistics Cookie
3068 (defun org-html-statistics-cookie (statistics-cookie contents info
)
3069 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3070 CONTENTS is nil. INFO is a plist holding contextual information."
3071 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3072 (format "<code>%s</code>" cookie-value
)))
3076 (defun org-html-strike-through (strike-through contents info
)
3077 "Transcode STRIKE-THROUGH from Org to HTML.
3078 CONTENTS is the text with strike-through markup. INFO is a plist
3079 holding contextual information."
3080 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
3085 (defun org-html-subscript (subscript contents info
)
3086 "Transcode a SUBSCRIPT object from Org to HTML.
3087 CONTENTS is the contents of the object. INFO is a plist holding
3088 contextual information."
3089 (format "<sub>%s</sub>" contents
))
3093 (defun org-html-superscript (superscript contents info
)
3094 "Transcode a SUPERSCRIPT object from Org to HTML.
3095 CONTENTS is the contents of the object. INFO is a plist holding
3096 contextual information."
3097 (format "<sup>%s</sup>" contents
))
3101 (defun org-html-table-cell (table-cell contents info
)
3102 "Transcode a TABLE-CELL element from Org to HTML.
3103 CONTENTS is nil. INFO is a plist used as a communication
3105 (let* ((table-row (org-export-get-parent table-cell
))
3106 (table (org-export-get-parent-table table-cell
))
3108 (if (not org-html-table-align-individual-fields
) ""
3109 (format (if (and (boundp 'org-html-format-table-no-css
)
3110 org-html-format-table-no-css
)
3111 " align=\"%s\"" " class=\"%s\"")
3112 (org-export-table-cell-alignment table-cell info
)))))
3113 (when (or (not contents
) (string= "" (org-trim contents
)))
3114 (setq contents
" "))
3116 ((and (org-export-table-has-header-p table info
)
3117 (= 1 (org-export-table-row-group table-row info
)))
3118 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
3119 contents
(cdr org-html-table-header-tags
)))
3120 ((and org-html-table-use-header-tags-for-first-column
3121 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3122 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
3123 contents
(cdr org-html-table-header-tags
)))
3124 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
3125 contents
(cdr org-html-table-data-tags
))))))
3129 (defun org-html-table-row (table-row contents info
)
3130 "Transcode a TABLE-ROW element from Org to HTML.
3131 CONTENTS is the contents of the row. INFO is a plist used as a
3132 communication channel."
3133 ;; Rules are ignored since table separators are deduced from
3134 ;; borders of the current row.
3135 (when (eq (org-element-property :type table-row
) 'standard
)
3136 (let* ((rowgroup-number (org-export-table-row-group table-row info
))
3137 (row-number (org-export-table-row-number table-row info
))
3139 (org-export-table-row-starts-rowgroup-p table-row info
))
3141 (org-export-table-row-ends-rowgroup-p table-row info
))
3142 ;; `top-row-p' and `end-rowgroup-p' are not used directly
3143 ;; but should be set so that `org-html-table-row-tags' can
3144 ;; use them (see the docstring of this variable.)
3145 (top-row-p (and (equal start-rowgroup-p
'(top))
3146 (equal end-rowgroup-p
'(below top
))))
3147 (bottom-row-p (and (equal start-rowgroup-p
'(above))
3148 (equal end-rowgroup-p
'(bottom above
))))
3151 ;; Case 1: Row belongs to second or subsequent rowgroups.
3152 ((not (= 1 rowgroup-number
))
3153 '("<tbody>" .
"\n</tbody>"))
3154 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
3155 ((org-export-table-has-header-p
3156 (org-export-get-parent-table table-row
) info
)
3157 '("<thead>" .
"\n</thead>"))
3158 ;; Case 2: Row is from first and only row group.
3159 (t '("<tbody>" .
"\n</tbody>")))))
3161 ;; Begin a rowgroup?
3162 (when start-rowgroup-p
(car rowgroup-tags
))
3164 (concat "\n" (eval (car org-html-table-row-tags
))
3167 (eval (cdr org-html-table-row-tags
)))
3169 (when end-rowgroup-p
(cdr rowgroup-tags
))))))
3173 (defun org-html-table-first-row-data-cells (table info
)
3174 "Transcode the first row of TABLE.
3175 INFO is a plist used as a communication channel."
3177 (org-element-map table
'table-row
3179 (unless (eq (org-element-property :type row
) 'rule
) row
))
3181 (special-column-p (org-export-table-has-special-column-p table
)))
3182 (if (not special-column-p
) (org-element-contents table-row
)
3183 (cdr (org-element-contents table-row
)))))
3185 (defun org-html-table--table.el-table
(table info
)
3186 "Format table.el tables into HTML.
3187 INFO is a plist used as a communication channel."
3188 (when (eq (org-element-property :type table
) 'table.el
)
3190 (let ((outbuf (with-current-buffer
3191 (get-buffer-create "*org-export-table*")
3192 (erase-buffer) (current-buffer))))
3194 (insert (org-element-property :value table
))
3196 (re-search-forward "^[ \t]*|[^|]" nil t
)
3197 (table-generate-source 'html outbuf
))
3198 (with-current-buffer outbuf
3199 (prog1 (org-trim (buffer-string))
3202 (defun org-html-table (table contents info
)
3203 "Transcode a TABLE element from Org to HTML.
3204 CONTENTS is the contents of the table. INFO is a plist holding
3205 contextual information."
3206 (case (org-element-property :type table
)
3207 ;; Case 1: table.el table. Convert it using appropriate tools.
3208 (table.el
(org-html-table--table.el-table table info
))
3209 ;; Case 2: Standard table.
3211 (let* ((label (org-element-property :name table
))
3212 (caption (org-export-get-caption table
))
3213 (number (org-export-get-ordinal
3214 table info nil
'org-html--has-caption-p
))
3216 (org-html--make-attribute-string
3218 (and label
(list :id
(org-export-solidify-link-text label
)))
3219 (and (not (org-html-html5-p info
))
3220 (plist-get info
:html-table-attributes
))
3221 (org-export-read-attribute :attr_html table
))))
3223 (if (and (boundp 'org-html-format-table-no-css
)
3224 org-html-format-table-no-css
)
3225 "align=\"%s\"" "class=\"%s\""))
3228 (lambda (table info
)
3230 (lambda (table-cell)
3231 (let ((alignment (org-export-table-cell-alignment
3234 ;; Begin a colgroup?
3235 (when (org-export-table-cell-starts-colgroup-p
3238 ;; Add a column. Also specify it's alignment.
3241 "col" (concat " " (format alignspec alignment
)) info
))
3243 (when (org-export-table-cell-ends-colgroup-p
3246 (org-html-table-first-row-data-cells table info
) "\n")))))
3247 (format "<table%s>\n%s\n%s\n%s</table>"
3248 (if (equal attributes
"") "" (concat " " attributes
))
3249 (if (not caption
) ""
3250 (format (if org-html-table-caption-above
3251 "<caption align=\"above\">%s</caption>"
3252 "<caption align=\"bottom\">%s</caption>")
3254 "<span class=\"table-number\">"
3255 (format (org-html--translate "Table %d:" info
) number
)
3256 "</span> " (org-export-data caption info
))))
3257 (funcall table-column-specs table info
)
3262 (defun org-html-target (target contents info
)
3263 "Transcode a TARGET object from Org to HTML.
3264 CONTENTS is nil. INFO is a plist holding contextual
3266 (let ((id (org-export-solidify-link-text
3267 (org-element-property :value target
))))
3268 (org-html--anchor id
)))
3272 (defun org-html-timestamp (timestamp contents info
)
3273 "Transcode a TIMESTAMP object from Org to HTML.
3274 CONTENTS is nil. INFO is a plist holding contextual
3276 (let ((value (org-html-plain-text
3277 (org-timestamp-translate timestamp
) info
)))
3278 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3279 (replace-regexp-in-string "--" "–" value
))))
3283 (defun org-html-underline (underline contents info
)
3284 "Transcode UNDERLINE from Org to HTML.
3285 CONTENTS is the text with underline markup. INFO is a plist
3286 holding contextual information."
3287 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
3292 (defun org-html-verbatim (verbatim contents info
)
3293 "Transcode VERBATIM from Org to HTML.
3294 CONTENTS is nil. INFO is a plist holding contextual
3296 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
3297 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3301 (defun org-html-verse-block (verse-block contents info
)
3302 "Transcode a VERSE-BLOCK element from Org to HTML.
3303 CONTENTS is verse block contents. INFO is a plist holding
3304 contextual information."
3305 ;; Replace each newline character with line break. Also replace
3306 ;; each blank line with a line break.
3307 (setq contents
(replace-regexp-in-string
3308 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3309 (replace-regexp-in-string
3310 "\\(\\\\\\\\\\)?[ \t]*\n"
3311 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3312 ;; Replace each white space at beginning of a line with a
3313 ;; non-breaking space.
3314 (while (string-match "^[ \t]+" contents
)
3315 (let* ((num-ws (length (match-string 0 contents
)))
3316 (ws (let (out) (dotimes (i num-ws out
)
3317 (setq out
(concat out
" "))))))
3318 (setq contents
(replace-match ws nil t contents
))))
3319 (format "<p class=\"verse\">\n%s</p>" contents
))
3322 ;;; Filter Functions
3324 (defun org-html-final-function (contents backend info
)
3325 "Filter to indent the HTML and convert HTML entities."
3330 (indent-region (point-min) (point-max)))
3331 (when org-html-use-unicode-chars
3333 (mm-url-decode-entities))
3334 (buffer-substring-no-properties (point-min) (point-max))))
3337 ;;; End-user functions
3340 (defun org-html-export-as-html
3341 (&optional async subtreep visible-only body-only ext-plist
)
3342 "Export current buffer to an HTML buffer.
3344 If narrowing is active in the current buffer, only export its
3347 If a region is active, export that region.
3349 A non-nil optional argument ASYNC means the process should happen
3350 asynchronously. The resulting buffer should be accessible
3351 through the `org-export-stack' interface.
3353 When optional argument SUBTREEP is non-nil, export the sub-tree
3354 at point, extracting information from the headline properties
3357 When optional argument VISIBLE-ONLY is non-nil, don't export
3358 contents of hidden elements.
3360 When optional argument BODY-ONLY is non-nil, only write code
3361 between \"<body>\" and \"</body>\" tags.
3363 EXT-PLIST, when provided, is a property list with external
3364 parameters overriding Org default settings, but still inferior to
3365 file-local settings.
3367 Export is done in a buffer named \"*Org HTML Export*\", which
3368 will be displayed when `org-export-show-temporary-export-buffer'
3371 (org-export-to-buffer 'html
"*Org HTML Export*"
3372 async subtreep visible-only body-only ext-plist
3373 (lambda () (set-auto-mode t
))))
3376 (defun org-html-convert-region-to-html ()
3377 "Assume the current region has org-mode syntax, and convert it to HTML.
3378 This can be used in any buffer. For example, you can write an
3379 itemized list in org-mode syntax in an HTML buffer and use this
3380 command to convert it."
3382 (org-export-replace-region-by 'html
))
3385 (defun org-html-export-to-html
3386 (&optional async subtreep visible-only body-only ext-plist
)
3387 "Export current buffer to a HTML file.
3389 If narrowing is active in the current buffer, only export its
3392 If a region is active, export that region.
3394 A non-nil optional argument ASYNC means the process should happen
3395 asynchronously. The resulting file should be accessible through
3396 the `org-export-stack' interface.
3398 When optional argument SUBTREEP is non-nil, export the sub-tree
3399 at point, extracting information from the headline properties
3402 When optional argument VISIBLE-ONLY is non-nil, don't export
3403 contents of hidden elements.
3405 When optional argument BODY-ONLY is non-nil, only write code
3406 between \"<body>\" and \"</body>\" tags.
3408 EXT-PLIST, when provided, is a property list with external
3409 parameters overriding Org default settings, but still inferior to
3410 file-local settings.
3412 Return output file's name."
3414 (let* ((extension (concat "." org-html-extension
))
3415 (file (org-export-output-file-name extension subtreep
))
3416 (org-export-coding-system org-html-coding-system
))
3417 (org-export-to-file 'html file
3418 async subtreep visible-only body-only ext-plist
)))
3421 (defun org-html-publish-to-html (plist filename pub-dir
)
3422 "Publish an org file to HTML.
3424 FILENAME is the filename of the Org file to be published. PLIST
3425 is the property list for the given project. PUB-DIR is the
3426 publishing directory.
3428 Return output file name."
3429 (org-publish-org-to 'html filename
3430 (concat "." (or (plist-get plist
:html-extension
)
3431 org-html-extension
"html"))
3437 ;;;; org-format-table-html
3438 ;;;; org-format-org-table-html
3439 ;;;; org-format-table-table-html
3440 ;;;; org-table-number-fraction
3441 ;;;; org-table-number-regexp
3442 ;;;; org-html-inline-image-extensions
3443 ;;;; org-export-preferred-target-alist
3444 ;;;; class for anchors
3445 ;;;; org-export-mark-todo-in-toc
3446 ;;;; org-html-format-org-link
3447 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
3448 ;;;; alt = (file-name-nondirectory path)
3453 ;; generated-autoload-file: "org-loaddefs.el"
3456 ;;; ox-html.el ends here