1 ;;; ox-html.el --- HTML Back-End for Org Export Engine
3 ;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Jambunathan K <kjambunathan at gmail dot com>
7 ;; Keywords: outlines, hypermedia, calendar, wp
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This library implements a HTML back-end for Org generic exporter.
27 ;; See Org manual for more information.
35 (require 'format-spec
)
36 (eval-when-compile (require 'cl
) (require 'table nil
'noerror
))
39 ;;; Function Declarations
41 (declare-function org-id-find-id-file
"org-id" (id))
42 (declare-function htmlize-region
"ext:htmlize" (beg end
))
43 (declare-function org-pop-to-buffer-same-window
44 "org-compat" (&optional buffer-or-name norecord label
))
45 (declare-function mm-url-decode-entities
"mm-url" ())
49 (org-export-define-backend 'html
50 '((bold . org-html-bold
)
51 (center-block . org-html-center-block
)
52 (clock . org-html-clock
)
53 (code . org-html-code
)
54 (drawer . org-html-drawer
)
55 (dynamic-block . org-html-dynamic-block
)
56 (entity . org-html-entity
)
57 (example-block . org-html-example-block
)
58 (export-block . org-html-export-block
)
59 (export-snippet . org-html-export-snippet
)
60 (fixed-width . org-html-fixed-width
)
61 (footnote-definition . org-html-footnote-definition
)
62 (footnote-reference . org-html-footnote-reference
)
63 (headline . org-html-headline
)
64 (horizontal-rule . org-html-horizontal-rule
)
65 (inline-src-block . org-html-inline-src-block
)
66 (inlinetask . org-html-inlinetask
)
67 (inner-template . org-html-inner-template
)
68 (italic . org-html-italic
)
69 (item . org-html-item
)
70 (keyword . org-html-keyword
)
71 (latex-environment . org-html-latex-environment
)
72 (latex-fragment . org-html-latex-fragment
)
73 (line-break . org-html-line-break
)
74 (link . org-html-link
)
75 (paragraph . org-html-paragraph
)
76 (plain-list . org-html-plain-list
)
77 (plain-text . org-html-plain-text
)
78 (planning . org-html-planning
)
79 (property-drawer . org-html-property-drawer
)
80 (quote-block . org-html-quote-block
)
81 (quote-section . org-html-quote-section
)
82 (radio-target . org-html-radio-target
)
83 (section . org-html-section
)
84 (special-block . org-html-special-block
)
85 (src-block . org-html-src-block
)
86 (statistics-cookie . org-html-statistics-cookie
)
87 (strike-through . org-html-strike-through
)
88 (subscript . org-html-subscript
)
89 (superscript . org-html-superscript
)
90 (table . org-html-table
)
91 (table-cell . org-html-table-cell
)
92 (table-row . org-html-table-row
)
93 (target . org-html-target
)
94 (template . org-html-template
)
95 (timestamp . org-html-timestamp
)
96 (underline . org-html-underline
)
97 (verbatim . org-html-verbatim
)
98 (verse-block . org-html-verse-block
))
100 :filters-alist
'((:filter-options . org-html-infojs-install-script
)
101 (:filter-final-output . org-html-final-function
))
103 '(?h
"Export to HTML"
104 ((?H
"As HTML buffer" org-html-export-as-html
)
105 (?h
"As HTML file" org-html-export-to-html
)
106 (?o
"As HTML file and open"
108 (if a
(org-html-export-to-html t s v b
)
109 (org-open-file (org-html-export-to-html nil s v b
)))))))
111 '((:html-extension nil nil org-html-extension
)
112 (:html-link-org-as-html nil nil org-html-link-org-files-as-html
)
113 (:html-doctype
"HTML_DOCTYPE" nil org-html-doctype
)
114 (:html-container
"HTML_CONTAINER" nil org-html-container-element
)
115 (:html-html5-fancy nil
"html5-fancy" org-html-html5-fancy
)
116 (:html-link-use-abs-url nil
"html-link-use-abs-url" org-html-link-use-abs-url
)
117 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
118 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
119 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
120 (:html-postamble nil
"html-postamble" org-html-postamble
)
121 (:html-preamble nil
"html-preamble" org-html-preamble
)
122 (:html-head
"HTML_HEAD" nil org-html-head newline
)
123 (:html-head-extra
"HTML_HEAD_EXTRA" nil org-html-head-extra newline
)
124 (:html-head-include-default-style nil
"html-style" org-html-head-include-default-style
)
125 (:html-head-include-scripts nil
"html-scripts" org-html-head-include-scripts
)
126 (:html-table-attributes nil nil org-html-table-default-attributes
)
127 (:html-table-row-tags nil nil org-html-table-row-tags
)
128 (:html-xml-declaration nil nil org-html-xml-declaration
)
129 (:html-inline-images nil nil org-html-inline-images
)
130 (:infojs-opt
"INFOJS_OPT" nil nil
)
131 ;; Redefine regular options.
132 (:creator
"CREATOR" nil org-html-creator-string
)
133 (:with-latex nil
"tex" org-html-with-latex
)
134 ;; Retrieve LaTeX header for fragments.
135 (:latex-header
"LATEX_HEADER" nil nil newline
)))
138 ;;; Internal Variables
140 (defvar org-html-format-table-no-css
)
141 (defvar htmlize-buffer-places
) ; from htmlize.el
143 (defvar org-html--pre
/postamble-class
"status"
144 "CSS class used for pre/postamble")
146 (defconst org-html-doctype-alist
147 '(("html4-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
148 \"http://www.w3.org/TR/html4/strict.dtd\">")
149 ("html4-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
150 \"http://www.w3.org/TR/html4/loose.dtd\">")
151 ("html4-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
152 \"http://www.w3.org/TR/html4/frameset.dtd\">")
154 ("xhtml-strict" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
155 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
156 ("xhtml-transitional" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
157 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
158 ("xhtml-frameset" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
159 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
160 ("xhtml-11" .
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
161 \"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
163 ("html5" .
"<!DOCTYPE html>")
164 ("xhtml5" .
"<!DOCTYPE html>"))
165 "An alist mapping (x)html flavors to specific doctypes.")
167 (defconst org-html-html5-elements
168 '("article" "aside" "audio" "canvas" "details" "figcaption"
169 "figure" "footer" "header" "menu" "meter" "nav" "output"
170 "progress" "section" "video")
171 "New elements in html5.
173 For blocks that should contain headlines, use the HTML_CONTAINER
174 property on the headline itself.")
176 (defconst org-html-special-string-regexps
177 '(("\\\\-" .
"­") ; shy
178 ("---\\([^-]\\)" .
"—\\1") ; mdash
179 ("--\\([^-]\\)" .
"–\\1") ; ndash
180 ("\\.\\.\\." .
"…")) ; hellip
181 "Regular expressions for special string conversion.")
183 (defconst org-html-scripts
184 "<script type=\"text/javascript\">
186 @licstart The following is the entire license notice for the
187 JavaScript code in this tag.
189 Copyright (C) 2012-2013 Free Software Foundation, Inc.
191 The JavaScript code in this tag is free software: you can
192 redistribute it and/or modify it under the terms of the GNU
193 General Public License (GNU GPL) as published by the Free Software
194 Foundation, either version 3 of the License, or (at your option)
195 any later version. The code is distributed WITHOUT ANY WARRANTY;
196 without even the implied warranty of MERCHANTABILITY or FITNESS
197 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
199 As additional permission under GNU GPL version 3 section 7, you
200 may distribute non-source (e.g., minimized or compacted) forms of
201 that code without the copy of the GNU GPL normally required by
202 section 4, provided you include this license notice and a URL
203 through which recipients can access the Corresponding Source.
206 @licend The above is the entire license notice
207 for the JavaScript code in this tag.
209 <!--/*--><![CDATA[/*><!--*/
210 function CodeHighlightOn(elem, id)
212 var target = document.getElementById(id);
214 elem.cacheClassElem = elem.className;
215 elem.cacheClassTarget = target.className;
216 target.className = \"code-highlighted\";
217 elem.className = \"code-highlighted\";
220 function CodeHighlightOff(elem, id)
222 var target = document.getElementById(id);
223 if(elem.cacheClassElem)
224 elem.className = elem.cacheClassElem;
225 if(elem.cacheClassTarget)
226 target.className = elem.cacheClassTarget;
230 "Basic JavaScript that is needed by HTML files produced by Org mode.")
232 (defconst org-html-style-default
233 "<style type=\"text/css\">
234 <!--/*--><![CDATA[/*><!--*/
235 .title { text-align: center; }
236 .todo { font-family: monospace; color: red; }
237 .done { color: green; }
238 .tag { background-color: #eee; font-family: monospace;
239 padding: 2px; font-size: 80%; font-weight: normal; }
240 .timestamp { color: #bebebe; }
241 .timestamp-kwd { color: #5f9ea0; }
242 .right { margin-left: auto; margin-right: 0px; text-align: right; }
243 .left { margin-left: 0px; margin-right: auto; text-align: left; }
244 .center { margin-left: auto; margin-right: auto; text-align: center; }
245 .underline { text-decoration: underline; }
246 #postamble p, #preamble p { font-size: 90%; margin: .2em; }
247 p.verse { margin-left: 3%; }
249 border: 1px solid #ccc;
250 box-shadow: 3px 3px 3px #eee;
252 font-family: monospace;
264 background-color: white;
268 border: 1px solid black;
270 pre.src:hover:before { display: inline;}
271 pre.src-sh:before { content: 'sh'; }
272 pre.src-bash:before { content: 'sh'; }
273 pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
274 pre.src-R:before { content: 'R'; }
275 pre.src-perl:before { content: 'Perl'; }
276 pre.src-java:before { content: 'Java'; }
277 pre.src-sql:before { content: 'SQL'; }
279 table { border-collapse:collapse; }
280 caption.t-above { caption-side: top; }
281 caption.t-bottom { caption-side: bottom; }
282 td, th { vertical-align:top; }
283 th.right { text-align: center; }
284 th.left { text-align: center; }
285 th.center { text-align: center; }
286 td.right { text-align: right; }
287 td.left { text-align: left; }
288 td.center { text-align: center; }
289 dt { font-weight: bold; }
290 .footpara:nth-child(2) { display: inline; }
291 .footpara { display: block; }
292 .footdef { margin-bottom: 1em; }
293 .figure { padding: 1em; }
294 .figure p { text-align: center; }
297 border: 2px solid gray;
302 { text-align: right; font-size: 70%; white-space: nowrap; }
303 textarea { overflow-x: auto; }
304 .linenr { font-size: smaller }
305 .code-highlighted { background-color: #ffff00; }
306 .org-info-js_info-navigation { border-style: none; }
307 #org-info-js_console-label
308 { font-size: 10px; font-weight: bold; white-space: nowrap; }
309 .org-info-js_search-highlight
310 { background-color: #ffff00; color: #000000; font-weight: bold; }
313 "The default style specification for exported HTML files.
314 You can use `org-html-head' and `org-html-head-extra' to add to
315 this style. If you don't want to include this default style,
316 customize `org-html-head-include-default-style'.")
319 ;;; User Configuration Variables
321 (defgroup org-export-html nil
322 "Options for exporting Org mode files to HTML."
323 :tag
"Org Export HTML"
328 (defvar org-html-infojs-opts-table
329 '((path PATH
"http://orgmode.org/org-info.js")
333 (tdepth TOC_DEPTH
"max")
334 (sdepth SECTION_DEPTH
"max")
335 (mouse MOUSE_HINT
"underline")
336 (buttons VIEW_BUTTONS
"0")
338 (up LINK_UP
:html-link-up
)
339 (home LINK_HOME
:html-link-home
))
340 "JavaScript options, long form for script, default values.")
342 (defcustom org-html-use-infojs
'when-configured
343 "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
344 This option can be nil or t to never or always use the script.
345 It can also be the symbol `when-configured', meaning that the
346 script will be linked into the export file if and only if there
347 is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
348 `org-html-infojs-options'."
349 :group
'org-export-html
351 :package-version
'(Org .
"8.0")
353 (const :tag
"Never" nil
)
354 (const :tag
"When configured in buffer" when-configured
)
355 (const :tag
"Always" t
)))
357 (defcustom org-html-infojs-options
358 (mapcar (lambda (x) (cons (car x
) (nth 2 x
))) org-html-infojs-opts-table
)
359 "Options settings for the INFOJS JavaScript.
360 Each of the options must have an entry in `org-html-infojs-opts-table'.
361 The value can either be a string that will be passed to the script, or
362 a property. This property is then assumed to be a property that is defined
363 by the Export/Publishing setup of Org.
364 The `sdepth' and `tdepth' parameters can also be set to \"max\", which
365 means to use the maximum value consistent with other options."
366 :group
'org-export-html
368 :package-version
'(Org .
"8.0")
370 `(set :greedy t
:inline t
373 (list 'cons
(list 'const
(car x
))
375 (symbol :tag
"Publishing/Export property")
376 (string :tag
"Value"))))
377 org-html-infojs-opts-table
)))
379 (defcustom org-html-infojs-template
380 "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
383 * @source: %SCRIPT_PATH
385 * @licstart The following is the entire license notice for the
386 * JavaScript code in %SCRIPT_PATH.
388 * Copyright (C) 2012-2013 Free Software Foundation, Inc.
391 * The JavaScript code in this tag is free software: you can
392 * redistribute it and/or modify it under the terms of the GNU
393 * General Public License (GNU GPL) as published by the Free Software
394 * Foundation, either version 3 of the License, or (at your option)
395 * any later version. The code is distributed WITHOUT ANY WARRANTY;
396 * without even the implied warranty of MERCHANTABILITY or FITNESS
397 * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
399 * As additional permission under GNU GPL version 3 section 7, you
400 * may distribute non-source (e.g., minimized or compacted) forms of
401 * that code without the copy of the GNU GPL normally required by
402 * section 4, provided you include this license notice and a URL
403 * through which recipients can access the Corresponding Source.
405 * @licend The above is the entire license notice
406 * for the JavaScript code in %SCRIPT_PATH.
411 <script type=\"text/javascript\">
414 @licstart The following is the entire license notice for the
415 JavaScript code in this tag.
417 Copyright (C) 2012-2013 Free Software Foundation, Inc.
419 The JavaScript code in this tag is free software: you can
420 redistribute it and/or modify it under the terms of the GNU
421 General Public License (GNU GPL) as published by the Free Software
422 Foundation, either version 3 of the License, or (at your option)
423 any later version. The code is distributed WITHOUT ANY WARRANTY;
424 without even the implied warranty of MERCHANTABILITY or FITNESS
425 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
427 As additional permission under GNU GPL version 3 section 7, you
428 may distribute non-source (e.g., minimized or compacted) forms of
429 that code without the copy of the GNU GPL normally required by
430 section 4, provided you include this license notice and a URL
431 through which recipients can access the Corresponding Source.
434 @licend The above is the entire license notice
435 for the JavaScript code in this tag.
438 <!--/*--><![CDATA[/*><!--*/
440 org_html_manager.setup(); // activate after the parameters are set
443 "The template for the export style additions when org-info.js is used.
444 Option settings will replace the %MANAGER-OPTIONS cookie."
445 :group
'org-export-html
447 :package-version
'(Org .
"8.0")
450 (defun org-html-infojs-install-script (exp-plist backend
)
451 "Install script in export options when appropriate.
452 EXP-PLIST is a plist containing export options. BACKEND is the
453 export back-end currently used."
454 (unless (or (memq 'body-only
(plist-get exp-plist
:export-options
))
455 (not org-html-use-infojs
)
456 (and (eq org-html-use-infojs
'when-configured
)
457 (or (not (plist-get exp-plist
:infojs-opt
))
458 (string= "" (plist-get exp-plist
:infojs-opt
))
459 (string-match "\\<view:nil\\>"
460 (plist-get exp-plist
:infojs-opt
)))))
461 (let* ((template org-html-infojs-template
)
462 (ptoc (plist-get exp-plist
:with-toc
))
463 (hlevels (plist-get exp-plist
:headline-levels
))
465 (tdepth (if (integerp ptoc
) (min ptoc hlevels
) hlevels
))
466 (options (plist-get exp-plist
:infojs-opt
))
467 (table org-html-infojs-opts-table
)
469 (dolist (entry table
)
470 (let* ((opt (car entry
))
472 ;; Compute default values for script option OPT from
473 ;; `org-html-infojs-options' variable.
475 (let ((default (cdr (assq opt org-html-infojs-options
))))
476 (if (and (symbolp default
) (not (memq default
'(t nil
))))
477 (plist-get exp-plist default
)
479 ;; Value set through INFOJS_OPT keyword has precedence
480 ;; over the default one.
481 (val (if (and options
482 (string-match (format "\\<%s:\\(\\S-+\\)" opt
)
484 (match-string 1 options
)
488 (replace-regexp-in-string
489 "%SCRIPT_PATH" val template t t
)))
490 (sdepth (when (integerp (read val
))
491 (setq sdepth
(min (read val
) sdepth
))))
492 (tdepth (when (integerp (read val
))
493 (setq tdepth
(min (read val
) tdepth
))))
496 ((or (eq val t
) (equal val
"t")) "1")
497 ((or (eq val nil
) (equal val
"nil")) "0")
499 (t (format "%s" val
))))
500 (push (cons var val
) style
)))))
501 ;; Now we set the depth of the *generated* TOC to SDEPTH,
502 ;; because the toc will actually determine the splitting. How
503 ;; much of the toc will actually be displayed is governed by the
505 (setq exp-plist
(plist-put exp-plist
:with-toc sdepth
))
506 ;; The table of contents should not show more sections than we
508 (setq tdepth
(min tdepth sdepth
))
509 (push (cons "TOC_DEPTH" tdepth
) style
)
510 ;; Build style string.
511 (setq style
(mapconcat
512 (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
516 (when (and style
(> (length style
) 0))
517 (and (string-match "%MANAGER_OPTIONS" template
)
518 (setq style
(replace-match style t t template
))
521 exp-plist
:html-head-extra
522 (concat (or (plist-get exp-plist
:html-head-extra
) "")
525 ;; This script absolutely needs the table of contents, so we
526 ;; change that setting.
527 (unless (plist-get exp-plist
:with-toc
)
528 (setq exp-plist
(plist-put exp-plist
:with-toc t
)))
529 ;; Return the modified property list.
534 (defcustom org-html-text-markup-alist
535 '((bold .
"<b>%s</b>")
536 (code .
"<code>%s</code>")
537 (italic .
"<i>%s</i>")
538 (strike-through .
"<del>%s</del>")
539 (underline .
"<span class=\"underline\">%s</span>")
540 (verbatim .
"<code>%s</code>"))
541 "Alist of HTML expressions to convert text markup.
543 The key must be a symbol among `bold', `code', `italic',
544 `strike-through', `underline' and `verbatim'. The value is
545 a formatting string to wrap fontified text with.
547 If no association can be found for a given markup, text will be
549 :group
'org-export-html
551 :package-version
'(Org .
"8.0")
552 :type
'(alist :key-type
(symbol :tag
"Markup type")
553 :value-type
(string :tag
"Format string"))
554 :options
'(bold code italic strike-through underline verbatim
))
556 (defcustom org-html-indent nil
557 "Non-nil means to indent the generated HTML.
558 Warning: non-nil may break indentation of source code blocks."
559 :group
'org-export-html
561 :package-version
'(Org .
"8.0")
564 (defcustom org-html-use-unicode-chars nil
565 "Non-nil means to use unicode characters instead of HTML entities."
566 :group
'org-export-html
568 :package-version
'(Org .
"8.0")
573 (defcustom org-html-format-drawer-function
574 (lambda (name contents
) contents
)
575 "Function called to format a drawer in HTML code.
577 The function must accept two parameters:
578 NAME the drawer name, like \"LOGBOOK\"
579 CONTENTS the contents of the drawer.
581 The function should return the string to be exported.
583 For example, the variable could be set to the following function
584 in order to mimic default behavior:
586 The default value simply returns the value of CONTENTS."
587 :group
'org-export-html
589 :package-version
'(Org .
"8.0")
594 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
595 <h2 class=\"footnotes\">%s: </h2>
596 <div id=\"text-footnotes\">
600 "Format for the footnotes section.
601 Should contain a two instances of %s. The first will be replaced with the
602 language-specific word for \"Footnotes\", the second one will be replaced
603 by the footnotes themselves."
604 :group
'org-export-html
607 (defcustom org-html-footnote-format
"<sup>%s</sup>"
608 "The format for the footnote reference.
609 %s will be replaced by the footnote reference itself."
610 :group
'org-export-html
613 (defcustom org-html-footnote-separator
"<sup>, </sup>"
614 "Text used to separate footnotes."
615 :group
'org-export-html
620 (defcustom org-html-toplevel-hlevel
2
621 "The <H> level for level 1 headings in HTML export.
622 This is also important for the classes that will be wrapped around headlines
623 and outline structure. If this variable is 1, the top-level headlines will
624 be <h1>, and the corresponding classes will be outline-1, section-number-1,
625 and outline-text-1. If this is 2, all of these will get a 2 instead.
626 The default for this variable is 2, because we use <h1> for formatting the
628 :group
'org-export-html
631 (defcustom org-html-format-headline-function
'ignore
632 "Function to format headline text.
634 This function will be called with 5 arguments:
635 TODO the todo keyword (string or nil).
636 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
637 PRIORITY the priority of the headline (integer or nil)
638 TEXT the main headline text (string).
639 TAGS the tags (string or nil).
641 The function result will be used in the section format string."
642 :group
'org-export-html
644 :package-version
'(Org .
"8.0")
649 (defcustom org-html-allow-name-attribute-in-anchors t
650 "When nil, do not set \"name\" attribute in anchors.
651 By default, anchors are formatted with both \"id\" and \"name\"
652 attributes, when appropriate."
653 :group
'org-export-html
655 :package-version
'(Org .
"8.0")
660 (defcustom org-html-format-inlinetask-function
'ignore
661 "Function called to format an inlinetask in HTML code.
663 The function must accept six parameters:
664 TODO the todo keyword, as a string
665 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
666 PRIORITY the inlinetask priority, as a string
667 NAME the inlinetask name, as a string.
668 TAGS the inlinetask tags, as a list of strings.
669 CONTENTS the contents of the inlinetask, as a string.
671 The function should return the string to be exported."
672 :group
'org-export-html
674 :package-version
'(Org .
"8.0")
679 (defcustom org-html-with-latex org-export-with-latex
680 "Non-nil means process LaTeX math snippets.
682 When set, the exporter will process LaTeX environments and
685 This option can also be set with the +OPTIONS line,
686 e.g. \"tex:mathjax\". Allowed values are:
688 nil Ignore math snippets.
689 `verbatim' Keep everything in verbatim
690 `dvipng' Process the LaTeX fragments to images. This will also
691 include processing of non-math environments.
692 `imagemagick' Convert the LaTeX fragments to pdf files and use
693 imagemagick to convert pdf files to png files.
694 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
696 t Synonym for `mathjax'."
697 :group
'org-export-html
699 :package-version
'(Org .
"8.0")
701 (const :tag
"Do not process math in any way" nil
)
702 (const :tag
"Use dvipng to make images" dvipng
)
703 (const :tag
"Use imagemagick to make images" imagemagick
)
704 (const :tag
"Use MathJax to display math" mathjax
)
705 (const :tag
"Leave math verbatim" verbatim
)))
707 ;;;; Links :: Generic
709 (defcustom org-html-link-org-files-as-html t
710 "Non-nil means make file links to `file.org' point to `file.html'.
711 When `org-mode' is exporting an `org-mode' file to HTML, links to
712 non-html files are directly put into a href tag in HTML.
713 However, links to other Org-mode files (recognized by the
714 extension `.org') should become links to the corresponding html
715 file, assuming that the linked `org-mode' file will also be
717 When nil, the links still point to the plain `.org' file."
718 :group
'org-export-html
721 ;;;; Links :: Inline images
723 (defcustom org-html-inline-images t
724 "Non-nil means inline images into exported HTML pages.
725 This is done using an <img> tag. When nil, an anchor with href is used to
727 :group
'org-export-html
729 :package-version
'(Org .
"8.1")
732 (defcustom org-html-inline-image-rules
733 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
734 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
735 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
736 "Rules characterizing image files that can be inlined into HTML.
737 A rule consists in an association whose key is the type of link
738 to consider, and value is a regexp that will be matched against
740 :group
'org-export-html
742 :package-version
'(Org .
"8.0")
743 :type
'(alist :key-type
(string :tag
"Type")
744 :value-type
(regexp :tag
"Path")))
748 (defcustom org-html-protect-char-alist
752 "Alist of characters to be converted by `org-html-protect'."
753 :group
'org-export-html
754 :type
'(repeat (cons (string :tag
"Character")
755 (string :tag
"HTML equivalent"))))
759 (defcustom org-html-htmlize-output-type
'inline-css
760 "Output type to be used by htmlize when formatting code snippets.
761 Choices are `css', to export the CSS selectors only, or `inline-css', to
762 export the CSS attribute values inline in the HTML. We use as default
763 `inline-css', in order to make the resulting HTML self-containing.
765 However, this will fail when using Emacs in batch mode for export, because
766 then no rich font definitions are in place. It will also not be good if
767 people with different Emacs setup contribute HTML files to a website,
768 because the fonts will represent the individual setups. In these cases,
769 it is much better to let Org/Htmlize assign classes only, and to use
770 a style file to define the look of these classes.
771 To get a start for your css file, start Emacs session and make sure that
772 all the faces you are interested in are defined, for example by loading files
773 in all modes you want. Then, use the command
774 \\[org-html-htmlize-generate-css] to extract class definitions."
775 :group
'org-export-html
776 :type
'(choice (const css
) (const inline-css
)))
778 (defcustom org-html-htmlize-font-prefix
"org-"
779 "The prefix for CSS class names for htmlize font specifications."
780 :group
'org-export-html
785 (defcustom org-html-table-default-attributes
786 '(:border
"2" :cellspacing
"0" :cellpadding
"6" :rules
"groups" :frame
"hsides")
787 "Default attributes and values which will be used in table tags.
788 This is a plist where attributes are symbols, starting with
789 colons, and values are strings.
791 When exporting to HTML5, these values will be disregarded."
792 :group
'org-export-html
794 :package-version
'(Org .
"8.0")
795 :type
'(plist :key-type
(symbol :tag
"Property")
796 :value-type
(string :tag
"Value")))
798 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
799 "The opening tag for table header fields.
800 This is customizable so that alignment options can be specified.
801 The first %s will be filled with the scope of the field, either row or col.
802 The second %s will be replaced by a style entry to align the field.
803 See also the variable `org-html-table-use-header-tags-for-first-column'.
804 See also the variable `org-html-table-align-individual-fields'."
805 :group
'org-export-html
806 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
808 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
809 "The opening tag for table data fields.
810 This is customizable so that alignment options can be specified.
811 The first %s will be filled with the scope of the field, either row or col.
812 The second %s will be replaced by a style entry to align the field.
813 See also the variable `org-html-table-align-individual-fields'."
814 :group
'org-export-html
815 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
817 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
818 "The opening and ending tags for table rows.
819 This is customizable so that alignment options can be specified.
820 Instead of strings, these can be Lisp forms that will be
821 evaluated for each row in order to construct the table row tags.
823 During evaluation, these variables will be dynamically bound so that
826 `row-number': row number (0 is the first row)
827 `rowgroup-number': group number of current row
828 `start-rowgroup-p': non-nil means the row starts a group
829 `end-rowgroup-p': non-nil means the row ends a group
830 `top-row-p': non-nil means this is the top row
831 `bottom-row-p': non-nil means this is the bottom row
835 \(setq org-html-table-row-tags
836 (cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
837 (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
838 (t (if (= (mod row-number 2) 1)
839 \"<tr class=\\\"tr-odd\\\">\"
840 \"<tr class=\\\"tr-even\\\">\")))
843 will use the \"tr-top\" and \"tr-bottom\" classes for the top row
844 and the bottom row, and otherwise alternate between \"tr-odd\" and
845 \"tr-even\" for odd and even rows."
846 :group
'org-export-html
848 (choice :tag
"Opening tag"
849 (string :tag
"Specify")
851 (choice :tag
"Closing tag"
852 (string :tag
"Specify")
855 (defcustom org-html-table-align-individual-fields t
856 "Non-nil means attach style attributes for alignment to each table field.
857 When nil, alignment will only be specified in the column tags, but this
858 is ignored by some browsers (like Firefox, Safari). Opera does it right
860 :group
'org-export-html
863 (defcustom org-html-table-use-header-tags-for-first-column nil
864 "Non-nil means format column one in tables with header tags.
865 When nil, also column one will use data tags."
866 :group
'org-export-html
869 (defcustom org-html-table-caption-above t
870 "When non-nil, place caption string at the beginning of the table.
871 Otherwise, place it near the end."
872 :group
'org-export-html
877 (defcustom org-html-tag-class-prefix
""
878 "Prefix to class names for TODO keywords.
879 Each tag gets a class given by the tag itself, with this prefix.
880 The default prefix is empty because it is nice to just use the keyword
881 as a class name. But if you get into conflicts with other, existing
882 CSS classes, then this prefix can be very useful."
883 :group
'org-export-html
886 ;;;; Template :: Generic
888 (defcustom org-html-extension
"html"
889 "The extension for exported HTML files."
890 :group
'org-export-html
893 (defcustom org-html-xml-declaration
894 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
895 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
896 "The extension for exported HTML files.
897 %s will be replaced with the charset of the exported file.
898 This may be a string, or an alist with export extensions
899 and corresponding declarations.
901 This declaration only applies when exporting to XHTML."
902 :group
'org-export-html
904 (string :tag
"Single declaration")
905 (repeat :tag
"Dependent on extension"
906 (cons (string :tag
"Extension")
907 (string :tag
"Declaration")))))
909 (defcustom org-html-coding-system
'utf-8
910 "Coding system for HTML export.
911 Use utf-8 as the default value."
912 :group
'org-export-html
914 :package-version
'(Org .
"8.0")
915 :type
'coding-system
)
917 (defcustom org-html-doctype
"xhtml-strict"
918 "Document type definition to use for exported HTML files.
919 Can be set with the in-buffer HTML_DOCTYPE property or for
920 publishing, with :html-doctype."
921 :group
'org-export-html
923 :package-version
'(Org .
"8.0")
926 (defcustom org-html-html5-fancy nil
927 "Non-nil means using new HTML5 elements.
928 This variable is ignored for anything other than HTML5 export.
930 For compatibility with Internet Explorer, it's probably a good
931 idea to download some form of the html5shiv (for instance
932 https://code.google.com/p/html5shiv/) and add it to your
933 HTML_HEAD_EXTRA, so that your pages don't break for users of IE
934 versions 8 and below."
935 :group
'org-export-html
937 :package-version
'(Org .
"8.0")
940 (defcustom org-html-container-element
"div"
941 "HTML element to use for wrapping top level sections.
942 Can be set with the in-buffer HTML_CONTAINER property or for
943 publishing, with :html-container.
945 Note that changing the default will prevent you from using
946 org-info.js for your website."
947 :group
'org-export-html
949 :package-version
'(Org .
"8.0")
952 (defcustom org-html-divs
953 '((preamble "div" "preamble")
954 (content "div" "content")
955 (postamble "div" "postamble"))
956 "Alist of the three section elements for HTML export.
957 The car of each entry is one of 'preamble, 'content or 'postamble.
958 The cdrs of each entry are the ELEMENT_TYPE and ID for each
959 section of the exported document.
961 Note that changing the default will prevent you from using
962 org-info.js for your website."
963 :group
'org-export-html
965 :package-version
'(Org .
"8.0")
966 :type
'(list :greedy t
967 (list :tag
"Preamble"
968 (const :format
"" preamble
)
969 (string :tag
"element") (string :tag
" id"))
971 (const :format
"" content
)
972 (string :tag
"element") (string :tag
" id"))
973 (list :tag
"Postamble" (const :format
"" postamble
)
974 (string :tag
" id") (string :tag
"element"))))
976 (defcustom org-html-metadata-timestamp-format
"%Y-%m-%d %a %H:%M"
977 "Format used for timestamps in preamble, postamble and metadata.
978 See `format-time-string' for more information on its components."
979 :group
'org-export-html
981 :package-version
'(Org .
"8.0")
984 ;;;; Template :: Mathjax
986 (defcustom org-html-mathjax-options
987 '((path "http://orgmode.org/mathjax/MathJax.js")
992 "Options for MathJax setup.
994 path The path where to find MathJax
995 scale Scaling for the HTML-CSS backend, usually between 100 and 133
996 align How to align display math: left, center, or right
997 indent If align is not center, how far from the left/right side?
998 mathml Should a MathML player be used if available?
999 This is faster and reduces bandwidth use, but currently
1000 sometimes has lower spacing quality. Therefore, the default is
1001 nil. When browsers get better, this switch can be flipped.
1003 You can also customize this for each buffer, using something like
1005 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
1006 :group
'org-export-html
1007 :type
'(list :greedy t
1008 (list :tag
"path (the path from where to load MathJax.js)"
1009 (const :format
" " path
) (string))
1010 (list :tag
"scale (scaling for the displayed math)"
1011 (const :format
" " scale
) (string))
1012 (list :tag
"align (alignment of displayed equations)"
1013 (const :format
" " align
) (string))
1014 (list :tag
"indent (indentation with left or right alignment)"
1015 (const :format
" " indent
) (string))
1016 (list :tag
"mathml (should MathML display be used is possible)"
1017 (const :format
" " mathml
) (boolean))))
1019 (defcustom org-html-mathjax-template
1020 "<script type=\"text/javascript\" src=\"%PATH\"></script>
1021 <script type=\"text/javascript\">
1022 <!--/*--><![CDATA[/*><!--*/
1023 MathJax.Hub.Config({
1024 // Only one of the two following lines, depending on user settings
1025 // First allows browser-native MathML display, second forces HTML/CSS
1026 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
1027 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
1028 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
1029 \"TeX/noUndefined.js\"],
1031 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
1032 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
1033 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
1034 ignoreClass: \"tex2jax_ignore\",
1035 processEscapes: false,
1036 processEnvironments: true,
1039 showProcessingMessages: true,
1040 displayAlign: \"%ALIGN\",
1041 displayIndent: \"%INDENT\",
1045 availableFonts: [\"STIX\",\"TeX\"],
1046 preferredFont: \"TeX\",
1062 "The MathJax setup for XHTML files."
1063 :group
'org-export-html
1066 ;;;; Template :: Postamble
1068 (defcustom org-html-postamble
'auto
1069 "Non-nil means insert a postamble in HTML export.
1071 When set to 'auto, check against the
1072 `org-export-with-author/email/creator/date' variables to set the
1073 content of the postamble. When set to a string, use this string
1074 as the postamble. When t, insert a string as defined by the
1075 formatting string in `org-html-postamble-format'.
1077 When set to a function, apply this function and insert the
1078 returned string. The function takes the property list of export
1079 options as its only argument.
1081 Setting :html-postamble in publishing projects will take
1082 precedence over this variable."
1083 :group
'org-export-html
1084 :type
'(choice (const :tag
"No postamble" nil
)
1085 (const :tag
"Auto postamble" auto
)
1086 (const :tag
"Default formatting string" t
)
1087 (string :tag
"Custom formatting string")
1088 (function :tag
"Function (must return a string)")))
1090 (defcustom org-html-postamble-format
1091 '(("en" "<p class=\"author\">Author: %a (%e)</p>
1092 <p class=\"date\">Date: %d</p>
1093 <p class=\"creator\">%c</p>
1094 <p class=\"validation\">%v</p>"))
1095 "Alist of languages and format strings for the HTML postamble.
1097 The first element of each list is the language code, as used for
1098 the LANGUAGE keyword. See `org-export-default-language'.
1100 The second element of each list is a format string to format the
1101 postamble itself. This format string can contain these elements:
1103 %t stands for the title.
1104 %a stands for the author's name.
1105 %e stands for the author's email.
1106 %d stands for the date.
1107 %c will be replaced by `org-html-creator-string'.
1108 %v will be replaced by `org-html-validation-link'.
1109 %T will be replaced by the export time.
1110 %C will be replaced by the last modification time.
1112 If you need to use a \"%\" character, you need to escape it
1114 :group
'org-export-html
1116 (list (string :tag
"Language")
1117 (string :tag
"Format string"))))
1119 (defcustom org-html-validation-link
1120 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
1121 "Link to HTML validation service."
1122 :group
'org-export-html
1125 (defcustom org-html-creator-string
1126 (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
1128 (if (fboundp 'org-version
) (org-version) "unknown version"))
1129 "Information about the creator of the HTML document.
1130 This option can also be set on with the CREATOR keyword."
1131 :group
'org-export-html
1133 :package-version
'(Org .
"8.0")
1134 :type
'(string :tag
"Creator string"))
1136 ;;;; Template :: Preamble
1138 (defcustom org-html-preamble t
1139 "Non-nil means insert a preamble in HTML export.
1141 When t, insert a string as defined by the formatting string in
1142 `org-html-preamble-format'. When set to a string, use this
1143 formatting string instead (see `org-html-postamble-format' for an
1144 example of such a formatting string).
1146 When set to a function, apply this function and insert the
1147 returned string. The function takes the property list of export
1148 options as its only argument.
1150 Setting :html-preamble in publishing projects will take
1151 precedence over this variable."
1152 :group
'org-export-html
1153 :type
'(choice (const :tag
"No preamble" nil
)
1154 (const :tag
"Default preamble" t
)
1155 (string :tag
"Custom formatting string")
1156 (function :tag
"Function (must return a string)")))
1158 (defcustom org-html-preamble-format
'(("en" ""))
1159 "Alist of languages and format strings for the HTML preamble.
1161 The first element of each list is the language code, as used for
1162 the LANGUAGE keyword. See `org-export-default-language'.
1164 The second element of each list is a format string to format the
1165 preamble itself. This format string can contain these elements:
1167 %t stands for the title.
1168 %a stands for the author's name.
1169 %e stands for the author's email.
1170 %d stands for the date.
1171 %c will be replaced by `org-html-creator-string'.
1172 %v will be replaced by `org-html-validation-link'.
1173 %T will be replaced by the export time.
1174 %C will be replaced by the last modification time.
1176 If you need to use a \"%\" character, you need to escape it
1179 See the default value of `org-html-postamble-format' for an
1181 :group
'org-export-html
1183 (list (string :tag
"Language")
1184 (string :tag
"Format string"))))
1186 (defcustom org-html-link-up
""
1187 "Where should the \"UP\" link of exported HTML pages lead?"
1188 :group
'org-export-html
1189 :type
'(string :tag
"File or URL"))
1191 (defcustom org-html-link-home
""
1192 "Where should the \"HOME\" link of exported HTML pages lead?"
1193 :group
'org-export-html
1194 :type
'(string :tag
"File or URL"))
1196 (defcustom org-html-link-use-abs-url nil
1197 "Should we prepend relative links with HTML_LINK_HOME?"
1198 :group
'org-export-html
1200 :package-version
'(Org .
"8.1")
1203 (defcustom org-html-home
/up-format
1204 "<div id=\"org-div-home-and-up\">
1205 <a accesskey=\"h\" href=\"%s\"> UP </a>
1207 <a accesskey=\"H\" href=\"%s\"> HOME </a>
1209 "Snippet used to insert the HOME and UP links.
1210 This is a format string, the first %s will receive the UP link,
1211 the second the HOME link. If both `org-html-link-up' and
1212 `org-html-link-home' are empty, the entire snippet will be
1214 :group
'org-export-html
1217 ;;;; Template :: Scripts
1219 (define-obsolete-variable-alias
1220 'org-html-style-include-scripts
'org-html-head-include-scripts
"24.4")
1221 (defcustom org-html-head-include-scripts t
1222 "Non-nil means include the JavaScript snippets in exported HTML files.
1223 The actual script is defined in `org-html-scripts' and should
1225 :group
'org-export-html
1227 :package-version
'(Org .
"8.0")
1230 ;;;; Template :: Styles
1232 (define-obsolete-variable-alias
1233 'org-html-style-include-default
'org-html-head-include-default-style
"24.4")
1234 (defcustom org-html-head-include-default-style t
1235 "Non-nil means include the default style in exported HTML files.
1236 The actual style is defined in `org-html-style-default' and
1237 should not be modified. Use `org-html-head' to use your own
1239 :group
'org-export-html
1241 :package-version
'(Org .
"8.0")
1244 (put 'org-html-head-include-default-style
'safe-local-variable
'booleanp
)
1246 (define-obsolete-variable-alias 'org-html-style
'org-html-head
"24.4")
1247 (defcustom org-html-head
""
1248 "Org-wide head definitions for exported HTML files.
1250 This variable can contain the full HTML structure to provide a
1251 style, including the surrounding HTML tags. You can consider
1252 including definitions for the following classes: title, todo,
1253 done, timestamp, timestamp-kwd, tag, target.
1255 For example, a valid value would be:
1257 <style type=\"text/css\">
1259 p { font-weight: normal; color: gray; }
1260 h1 { color: black; }
1261 .title { text-align: center; }
1262 .todo, .timestamp-kwd { color: red; }
1263 .done { color: green; }
1267 If you want to refer to an external style, use something like
1269 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
1271 As the value of this option simply gets inserted into the HTML
1272 <head> header, you can use it to add any arbitrary text to the
1275 You can set this on a per-file basis using #+HTML_HEAD:,
1276 or for publication projects using the :html-head property."
1277 :group
'org-export-html
1279 :package-version
'(Org .
"8.0")
1282 (put 'org-html-head
'safe-local-variable
'stringp
)
1284 (defcustom org-html-head-extra
""
1285 "More head information to add in the HTML output.
1287 You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
1288 or for publication projects using the :html-head-extra property."
1289 :group
'org-export-html
1291 :package-version
'(Org .
"8.0")
1294 (put 'org-html-head-extra
'safe-local-variable
'stringp
)
1298 (defcustom org-html-todo-kwd-class-prefix
""
1299 "Prefix to class names for TODO keywords.
1300 Each TODO keyword gets a class given by the keyword itself, with this prefix.
1301 The default prefix is empty because it is nice to just use the keyword
1302 as a class name. But if you get into conflicts with other, existing
1303 CSS classes, then this prefix can be very useful."
1304 :group
'org-export-html
1308 ;;; Internal Functions
1310 (defun org-html-xhtml-p (info)
1311 (let ((dt (downcase (plist-get info
:html-doctype
))))
1312 (string-match-p "xhtml" dt
)))
1314 (defun org-html-html5-p (info)
1315 (let ((dt (downcase (plist-get info
:html-doctype
))))
1316 (member dt
'("html5" "xhtml5" "<!doctype html>"))))
1318 (defun org-html-close-tag (tag attr info
)
1319 (concat "<" tag
" " attr
1320 (if (org-html-xhtml-p info
) " />" ">")))
1322 (defun org-html-doctype (info)
1323 "Return correct html doctype tag from `org-html-doctype-alist',
1324 or the literal value of :html-doctype from INFO if :html-doctype
1325 is not found in the alist.
1326 INFO is a plist used as a communication channel."
1327 (let ((dt (plist-get info
:html-doctype
)))
1328 (or (cdr (assoc dt org-html-doctype-alist
)) dt
)))
1330 (defun org-html--make-attribute-string (attributes)
1331 "Return a list of attributes, as a string.
1332 ATTRIBUTES is a plist where values are either strings or nil. An
1333 attributes with a nil value will be omitted from the result."
1335 (dolist (item attributes
(mapconcat 'identity
(nreverse output
) " "))
1336 (cond ((null item
) (pop output
))
1337 ((symbolp item
) (push (substring (symbol-name item
) 1) output
))
1338 (t (let ((key (car output
))
1339 (value (replace-regexp-in-string
1340 "\"" """ (org-html-encode-plain-text item
))))
1341 (setcar output
(format "%s=\"%s\"" key value
))))))))
1343 (defun org-html--wrap-image (contents info
&optional caption label
)
1344 "Wrap CONTENTS string within an appropriate environment for images.
1345 INFO is a plist used as a communication channel. When optional
1346 arguments CAPTION and LABEL are given, use them for caption and
1348 (let ((html5-fancy (and (org-html-html5-p info
)
1349 (plist-get info
:html-html5-fancy
))))
1350 (format (if html5-fancy
"\n<figure%s>%s%s\n</figure>"
1351 "\n<div%s class=\"figure\">%s%s\n</div>")
1353 (if (not (org-string-nw-p label
)) ""
1354 (format " id=\"%s\"" (org-export-solidify-link-text label
)))
1356 (format "\n<p>%s</p>" contents
)
1358 (if (not (org-string-nw-p caption
)) ""
1359 (format (if html5-fancy
"\n<figcaption>%s</figcaption>"
1363 (defun org-html--format-image (source attributes info
)
1364 "Return \"img\" tag with given SOURCE and ATTRIBUTES.
1365 SOURCE is a string specifying the location of the image.
1366 ATTRIBUTES is a plist, as returned by
1367 `org-export-read-attribute'. INFO is a plist used as
1368 a communication channel."
1371 (org-html--make-attribute-string
1374 :alt
(if (string-match-p "^ltxpng/" source
)
1375 (org-html-encode-plain-text
1376 (org-find-text-property-in-string 'org-latex-src source
))
1377 (file-name-nondirectory source
)))
1381 (defun org-html--textarea-block (element)
1382 "Transcode ELEMENT into a textarea block.
1383 ELEMENT is either a src block or an example block."
1384 (let* ((code (car (org-export-unravel-code element
)))
1385 (attr (org-export-read-attribute :attr_html element
)))
1386 (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
1387 (or (plist-get attr
:width
) 80)
1388 (or (plist-get attr
:height
) (org-count-lines code
))
1391 (defun org-html--has-caption-p (element &optional info
)
1392 "Non-nil when ELEMENT has a caption affiliated keyword.
1393 INFO is a plist used as a communication channel. This function
1394 is meant to be used as a predicate for `org-export-get-ordinal' or
1395 a value to `org-html-standalone-image-predicate'."
1396 (org-element-property :caption element
))
1400 (defun org-html-htmlize-region-for-paste (beg end
)
1401 "Convert the region between BEG and END to HTML, using htmlize.el.
1402 This is much like `htmlize-region-for-paste', only that it uses
1403 the settings define in the org-... variables."
1404 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1405 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1406 (htmlbuf (htmlize-region beg end
)))
1408 (with-current-buffer htmlbuf
1409 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1410 (plist-get htmlize-buffer-places
'content-end
)))
1411 (kill-buffer htmlbuf
))))
1414 (defun org-html-htmlize-generate-css ()
1415 "Create the CSS for all font definitions in the current Emacs session.
1416 Use this to create face definitions in your CSS style file that can then
1417 be used by code snippets transformed by htmlize.
1418 This command just produces a buffer that contains class definitions for all
1419 faces used in the current Emacs session. You can copy and paste the ones you
1420 need into your CSS file.
1422 If you then set `org-html-htmlize-output-type' to `css', calls
1423 to the function `org-html-htmlize-region-for-paste' will
1424 produce code that uses these same face definitions."
1427 (and (get-buffer "*html*") (kill-buffer "*html*"))
1429 (let ((fl (face-list))
1430 (htmlize-css-name-prefix "org-")
1431 (htmlize-output-type 'css
)
1433 (while (setq f
(pop fl
)
1434 i
(and f
(face-attribute f
:inherit
)))
1435 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1436 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1437 (htmlize-region (point-min) (point-max))))
1438 (org-pop-to-buffer-same-window "*html*")
1439 (goto-char (point-min))
1440 (if (re-search-forward "<style" nil t
)
1441 (delete-region (point-min) (match-beginning 0)))
1442 (if (re-search-forward "</style>" nil t
)
1443 (delete-region (1+ (match-end 0)) (point-max)))
1444 (beginning-of-line 1)
1445 (if (looking-at " +") (replace-match ""))
1446 (goto-char (point-min)))
1448 (defun org-html--make-string (n string
)
1449 "Build a string by concatenating N times STRING."
1450 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1452 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1453 "Turn todo keyword KWD into a valid class name.
1454 Replaces invalid characters with \"_\"."
1456 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1457 (setq kwd
(replace-match "_" t t kwd
))))
1460 (defun org-html-format-footnote-reference (n def refcnt
)
1461 "Format footnote reference N with definition DEF into HTML."
1462 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1463 (format org-html-footnote-format
1464 (let* ((id (format "fnr.%s%s" n extra
))
1465 (href (format " href=\"#fn.%s\"" n
))
1466 (attributes (concat " class=\"footref\"" href
)))
1467 (org-html--anchor id n attributes
)))))
1469 (defun org-html-format-footnotes-section (section-name definitions
)
1470 "Format footnotes section SECTION-NAME."
1471 (if (not definitions
) ""
1472 (format org-html-footnotes-section section-name definitions
)))
1474 (defun org-html-format-footnote-definition (fn)
1475 "Format the footnote definition FN."
1476 (let ((n (car fn
)) (def (cdr fn
)))
1478 "<div class=\"footdef\">%s %s</div>\n"
1479 (format org-html-footnote-format
1480 (let* ((id (format "fn.%s" n
))
1481 (href (format " href=\"#fnr.%s\"" n
))
1482 (attributes (concat " class=\"footnum\"" href
)))
1483 (org-html--anchor id n attributes
)))
1486 (defun org-html-footnote-section (info)
1487 "Format the footnote section.
1488 INFO is a plist used as a communication channel."
1489 (let* ((fn-alist (org-export-collect-footnote-definitions
1490 (plist-get info
:parse-tree
) info
))
1492 (loop for
(n type raw
) in fn-alist collect
1493 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1494 (org-trim (org-export-data raw info
))
1496 (org-trim (org-export-data raw info
))))))))
1498 (org-html-format-footnotes-section
1499 (org-html--translate "Footnotes" info
)
1502 (mapconcat 'org-html-format-footnote-definition fn-alist
"\n"))))))
1507 (defun org-html--build-meta-info (info)
1508 "Return meta tags for exported document.
1509 INFO is a plist used as a communication channel."
1510 (let ((protect-string
1512 (replace-regexp-in-string
1513 "\"" """ (org-html-encode-plain-text str
))))
1514 (title (org-export-data (plist-get info
:title
) info
))
1515 (author (and (plist-get info
:with-author
)
1516 (let ((auth (plist-get info
:author
)))
1518 ;; Return raw Org syntax, skipping non
1519 ;; exportable objects.
1520 (org-element-interpret-data
1521 (org-element-map auth
1522 (cons 'plain-text org-element-all-objects
)
1523 'identity info
))))))
1524 (description (plist-get info
:description
))
1525 (keywords (plist-get info
:keywords
))
1526 (charset (or (and org-html-coding-system
1527 (fboundp 'coding-system-get
)
1528 (coding-system-get org-html-coding-system
1532 (format "<title>%s</title>\n" title
)
1533 (when (plist-get info
:time-stamp-file
)
1535 (concat "<!-- " org-html-metadata-timestamp-format
" -->\n")))
1537 (if (org-html-html5-p info
)
1538 (org-html-close-tag "meta" " charset=\"%s\"" info
)
1540 "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
1543 (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info
)
1545 (and (org-string-nw-p author
)
1547 (org-html-close-tag "meta"
1548 (format " name=\"author\" content=\"%s\""
1549 (funcall protect-string author
))
1552 (and (org-string-nw-p description
)
1554 (org-html-close-tag "meta"
1555 (format " name=\"description\" content=\"%s\"\n"
1556 (funcall protect-string description
))
1559 (and (org-string-nw-p keywords
)
1561 (org-html-close-tag "meta"
1562 (format " name=\"keywords\" content=\"%s\""
1563 (funcall protect-string keywords
))
1567 (defun org-html--build-head (info)
1568 "Return information for the <head>..</head> of the HTML output.
1569 INFO is a plist used as a communication channel."
1570 (org-element-normalize-string
1572 (when (plist-get info
:html-head-include-default-style
)
1573 (org-element-normalize-string org-html-style-default
))
1574 (org-element-normalize-string (plist-get info
:html-head
))
1575 (org-element-normalize-string (plist-get info
:html-head-extra
))
1576 (when (and (plist-get info
:html-htmlized-css-url
)
1577 (eq org-html-htmlize-output-type
'css
))
1578 (org-html-close-tag "link"
1579 (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
1580 (plist-get info
:html-htmlized-css-url
))
1582 (when (plist-get info
:html-head-include-scripts
) org-html-scripts
))))
1584 (defun org-html--build-mathjax-config (info)
1585 "Insert the user setup into the mathjax template.
1586 INFO is a plist used as a communication channel."
1587 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1588 (org-element-map (plist-get info
:parse-tree
)
1589 '(latex-fragment latex-environment
) 'identity info t
))
1590 (let ((template org-html-mathjax-template
)
1591 (options org-html-mathjax-options
)
1592 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1593 name val
(yes " ") (no "// ") x
)
1596 (setq name
(car e
) val
(nth 1 e
))
1597 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1598 (setq val
(car (read-from-string
1599 (substring in-buffer
(match-end 0))))))
1600 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1601 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1602 (setq template
(replace-match val t t template
))))
1604 (setq val
(nth 1 (assq 'mathml options
)))
1605 (if (string-match (concat "\\<mathml:") in-buffer
)
1606 (setq val
(car (read-from-string
1607 (substring in-buffer
(match-end 0))))))
1608 ;; Exchange prefixes depending on mathml setting.
1609 (if (not val
) (setq x yes yes no no x
))
1610 ;; Replace cookies to turn on or off the config/jax lines.
1611 (if (string-match ":MMLYES:" template
)
1612 (setq template
(replace-match yes t t template
)))
1613 (if (string-match ":MMLNO:" template
)
1614 (setq template
(replace-match no t t template
)))
1615 ;; Return the modified template.
1616 (org-element-normalize-string template
))))
1618 (defun org-html-format-spec (info)
1619 "Return format specification for elements that can be
1620 used in the preamble or postamble."
1621 `((?t .
,(org-export-data (plist-get info
:title
) info
))
1622 (?d .
,(org-export-data (org-export-get-date info
) info
))
1623 (?T .
,(format-time-string org-html-metadata-timestamp-format
))
1624 (?a .
,(org-export-data (plist-get info
:author
) info
))
1627 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1628 (split-string (plist-get info
:email
) ",+ *")
1630 (?c .
,(plist-get info
:creator
))
1631 (?C .
,(let ((file (plist-get info
:input-file
)))
1632 (format-time-string org-html-metadata-timestamp-format
1633 (if file
(nth 5 (file-attributes file
))))))
1634 (?v .
,(or org-html-validation-link
""))))
1636 (defun org-html--build-pre/postamble
(type info
)
1637 "Return document preamble or postamble as a string, or nil.
1638 TYPE is either 'preamble or 'postamble, INFO is a plist used as a
1639 communication channel."
1640 (let ((section (plist-get info
(intern (format ":html-%s" type
))))
1641 (spec (org-html-format-spec info
)))
1643 (let ((section-contents
1644 (if (functionp section
) (funcall section info
)
1646 ((stringp section
) (format-spec section spec
))
1648 (let ((date (cdr (assq ?d spec
)))
1649 (author (cdr (assq ?a spec
)))
1650 (email (cdr (assq ?e spec
)))
1651 (creator (cdr (assq ?c spec
)))
1652 (timestamp (cdr (assq ?T spec
)))
1653 (validation-link (cdr (assq ?v spec
))))
1655 (when (and (plist-get info
:with-date
)
1656 (org-string-nw-p date
))
1657 (format "<p class=\"date\">%s: %s</p>\n"
1658 (org-html--translate "Date" info
)
1660 (when (and (plist-get info
:with-author
)
1661 (org-string-nw-p author
))
1662 (format "<p class=\"author\">%s: %s</p>\n"
1663 (org-html--translate "Author" info
)
1665 (when (and (plist-get info
:with-email
)
1666 (org-string-nw-p email
))
1667 (format "<p class=\"email\">%s: %s</p>\n"
1668 (org-html--translate "Email" info
)
1670 (when (plist-get info
:time-stamp-file
)
1672 "<p class=\"date\">%s: %s</p>\n"
1673 (org-html--translate "Created" info
)
1674 (format-time-string org-html-metadata-timestamp-format
)))
1675 (when (plist-get info
:with-creator
)
1676 (format "<p class=\"creator\">%s</p>\n" creator
))
1677 (format "<p class=\"validation\">%s</p>\n"
1681 (plist-get info
:language
)
1683 (format "org-html-%s-format" type
)))))
1688 (intern (format "org-html-%s-format" type
))))))
1690 (when (org-string-nw-p section-contents
)
1692 (format "<%s id=\"%s\" class=\"%s\">\n"
1693 (nth 1 (assq type org-html-divs
))
1694 (nth 2 (assq type org-html-divs
))
1695 org-html--pre
/postamble-class
)
1696 (org-element-normalize-string section-contents
)
1697 (format "</%s>\n" (nth 1 (assq type org-html-divs
)))))))))
1699 (defun org-html-inner-template (contents info
)
1700 "Return body of document string after HTML conversion.
1701 CONTENTS is the transcoded contents string. INFO is a plist
1702 holding export options."
1704 ;; Table of contents.
1705 (let ((depth (plist-get info
:with-toc
)))
1706 (when depth
(org-html-toc depth info
)))
1707 ;; Document contents.
1709 ;; Footnotes section.
1710 (org-html-footnote-section info
)))
1712 (defun org-html-template (contents info
)
1713 "Return complete document string after HTML conversion.
1714 CONTENTS is the transcoded contents string. INFO is a plist
1715 holding export options."
1717 (when (and (not (org-html-html5-p info
)) (org-html-xhtml-p info
))
1718 (let ((decl (or (and (stringp org-html-xml-declaration
)
1719 org-html-xml-declaration
)
1720 (cdr (assoc (plist-get info
:html-extension
)
1721 org-html-xml-declaration
))
1722 (cdr (assoc "html" org-html-xml-declaration
))
1725 (when (not (or (eq nil decl
) (string= "" decl
)))
1728 (or (and org-html-coding-system
1729 (fboundp 'coding-system-get
)
1730 (coding-system-get org-html-coding-system
'mime-charset
))
1732 (org-html-doctype info
)
1735 (when (org-html-xhtml-p info
)
1737 " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
1738 (plist-get info
:language
) (plist-get info
:language
)))
1741 (org-html--build-meta-info info
)
1742 (org-html--build-head info
)
1743 (org-html--build-mathjax-config info
)
1746 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1747 (link-home (org-trim (plist-get info
:html-link-home
))))
1748 (unless (and (string= link-up
"") (string= link-home
""))
1749 (format org-html-home
/up-format
1750 (or link-up link-home
)
1751 (or link-home link-up
))))
1753 (org-html--build-pre/postamble
'preamble info
)
1754 ;; Document contents.
1755 (format "<%s id=\"%s\">\n"
1756 (nth 1 (assq 'content org-html-divs
))
1757 (nth 2 (assq 'content org-html-divs
)))
1759 (let ((title (plist-get info
:title
)))
1760 (format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title
"") info
)))
1763 (nth 1 (assq 'content org-html-divs
)))
1765 (org-html--build-pre/postamble
'postamble info
)
1766 ;; Closing document.
1767 "</body>\n</html>"))
1769 (defun org-html--translate (s info
)
1770 "Translate string S according to specified language.
1771 INFO is a plist used as a communication channel."
1772 (org-export-translate s
:html info
))
1776 (defun org-html--anchor (&optional id desc attributes
)
1777 "Format a HTML anchor."
1778 (let* ((name (and org-html-allow-name-attribute-in-anchors id
))
1779 (attributes (concat (and id
(format " id=\"%s\"" id
))
1780 (and name
(format " name=\"%s\"" name
))
1782 (format "<a%s>%s</a>" attributes
(or desc
""))))
1786 (defun org-html--todo (todo)
1787 "Format TODO keywords into HTML."
1789 (format "<span class=\"%s %s%s\">%s</span>"
1790 (if (member todo org-done-keywords
) "done" "todo")
1791 org-html-todo-kwd-class-prefix
(org-html-fix-class-name todo
)
1796 (defun org-html--tags (tags)
1797 "Format TAGS into HTML."
1799 (format "<span class=\"tag\">%s</span>"
1802 (format "<span class=\"%s\">%s</span>"
1803 (concat org-html-tag-class-prefix
1804 (org-html-fix-class-name tag
))
1810 (defun* org-html-format-headline
1811 (todo todo-type priority text tags
1812 &key level section-number headline-label
&allow-other-keys
)
1813 "Format a headline in HTML."
1814 (let ((section-number
1815 (when section-number
1816 (format "<span class=\"section-number-%d\">%s</span> "
1817 level section-number
)))
1818 (todo (org-html--todo todo
))
1819 (tags (org-html--tags tags
)))
1820 (concat section-number todo
(and todo
" ") text
1821 (and tags
"   ") tags
)))
1825 (defun org-html-fontify-code (code lang
)
1826 "Color CODE with htmlize library.
1827 CODE is a string representing the source code to colorize. LANG
1828 is the language used for CODE, as a string, or nil."
1831 ;; Case 1: No lang. Possibly an example block.
1833 ;; Simple transcoding.
1834 (org-html-encode-plain-text code
))
1835 ;; Case 2: No htmlize or an inferior version of htmlize
1836 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1838 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1839 ;; Simple transcoding.
1840 (org-html-encode-plain-text code
))
1843 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1844 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1846 ;; Case 1: Language is not associated with any Emacs mode
1847 ((not (functionp lang-mode
))
1848 ;; Simple transcoding.
1849 (org-html-encode-plain-text code
))
1850 ;; Case 2: Default. Fontify code.
1853 (setq code
(with-temp-buffer
1854 ;; Switch to language-specific mode.
1858 (org-font-lock-ensure)
1859 ;; Remove formatting on newline characters.
1861 (let ((beg (point-min))
1864 (while (progn (end-of-line) (< (point) end
))
1865 (put-text-property (point) (1+ (point)) 'face nil
)
1868 (set-buffer-modified-p nil
)
1870 (org-html-htmlize-region-for-paste
1871 (point-min) (point-max))))
1872 ;; Strip any enclosing <pre></pre> tags.
1873 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
1874 (end (and beg
(string-match "</pre>\\'" code
))))
1875 (if (and beg end
) (substring code beg end
) code
)))))))))
1877 (defun org-html-do-format-code
1878 (code &optional lang refs retain-labels num-start
)
1879 "Format CODE string as source code.
1880 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1881 respectively, the language of the source code, as a string, an
1882 alist between line numbers and references (as returned by
1883 `org-export-unravel-code'), a boolean specifying if labels should
1884 appear in the source code, and the number associated to the first
1886 (let* ((code-lines (org-split-string code
"\n"))
1887 (code-length (length code-lines
))
1891 (length (number-to-string (+ code-length num-start
))))))
1892 (code (org-html-fontify-code code lang
)))
1893 (org-export-format-code
1895 (lambda (loc line-num ref
)
1898 ;; Add line number, if needed.
1900 (format "<span class=\"linenr\">%s</span>"
1901 (format num-fmt line-num
)))
1902 ;; Transcoded src line.
1904 ;; Add label, if needed.
1905 (when (and ref retain-labels
) (format " (%s)" ref
))))
1906 ;; Mark transcoded line as an anchor, if needed.
1908 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1912 (defun org-html-format-code (element info
)
1913 "Format contents of ELEMENT as source code.
1914 ELEMENT is either an example block or a src block. INFO is
1915 a plist used as a communication channel."
1916 (let* ((lang (org-element-property :language element
))
1917 ;; Extract code and references.
1918 (code-info (org-export-unravel-code element
))
1919 (code (car code-info
))
1920 (refs (cdr code-info
))
1921 ;; Does the src block contain labels?
1922 (retain-labels (org-element-property :retain-labels element
))
1923 ;; Does it have line numbers?
1924 (num-start (case (org-element-property :number-lines element
)
1925 (continued (org-export-get-loc element info
))
1927 (org-html-do-format-code code lang refs retain-labels num-start
)))
1930 ;;; Tables of Contents
1932 (defun org-html-toc (depth info
)
1933 "Build a table of contents.
1934 DEPTH is an integer specifying the depth of the table. INFO is a
1935 plist used as a communication channel. Return the table of
1936 contents as a string, or nil if it is empty."
1938 (mapcar (lambda (headline)
1939 (cons (org-html--format-toc-headline headline info
)
1940 (org-export-get-relative-level headline info
)))
1941 (org-export-collect-headlines info depth
)))
1942 (outer-tag (if (and (org-html-html5-p info
)
1943 (plist-get info
:html-html5-fancy
))
1947 (concat (format "<%s id=\"table-of-contents\">\n" outer-tag
)
1948 (format "<h%d>%s</h%d>\n"
1949 org-html-toplevel-hlevel
1950 (org-html--translate "Table of Contents" info
)
1951 org-html-toplevel-hlevel
)
1952 "<div id=\"text-table-of-contents\">"
1953 (org-html--toc-text toc-entries
)
1955 (format "</%s>\n" outer-tag
)))))
1957 (defun org-html--toc-text (toc-entries)
1958 "Return innards of a table of contents, as a string.
1959 TOC-ENTRIES is an alist where key is an entry title, as a string,
1960 and value is its relative level, as an integer."
1961 (let* ((prev-level (1- (cdar toc-entries
)))
1962 (start-level prev-level
))
1966 (let ((headline (car entry
))
1967 (level (cdr entry
)))
1969 (let* ((cnt (- level prev-level
))
1970 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1972 (setq prev-level level
)
1974 (org-html--make-string
1975 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1976 ((< cnt
0) "</li>\n</ul>\n")))
1977 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1980 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
1982 (defun org-html--format-toc-headline (headline info
)
1983 "Return an appropriate table of contents entry for HEADLINE.
1984 INFO is a plist used as a communication channel."
1985 (let* ((headline-number (org-export-get-headline-number headline info
))
1986 (todo (and (plist-get info
:with-todo-keywords
)
1987 (let ((todo (org-element-property :todo-keyword headline
)))
1988 (and todo
(org-export-data todo info
)))))
1989 (todo-type (and todo
(org-element-property :todo-type headline
)))
1990 (priority (and (plist-get info
:with-priority
)
1991 (org-element-property :priority headline
)))
1992 (text (org-export-data-with-backend
1993 (org-export-get-alt-title headline info
)
1994 ;; Create an anonymous back-end that will ignore any
1995 ;; footnote-reference, link, radio-target and target
1996 ;; in table of contents.
1997 (org-export-create-backend
1999 :transcoders
'((footnote-reference . ignore
)
2000 (link .
(lambda (object c i
) c
))
2001 (radio-target .
(lambda (object c i
) c
))
2004 (tags (and (eq (plist-get info
:with-tags
) t
)
2005 (org-export-get-tags headline info
))))
2006 (format "<a href=\"#%s\">%s</a>"
2008 (org-export-solidify-link-text
2009 (or (org-element-property :CUSTOM_ID headline
)
2011 (mapconcat #'number-to-string headline-number
"-"))))
2014 (and (not (org-export-low-level-p headline info
))
2015 (org-export-numbered-headline-p headline info
)
2016 (concat (mapconcat #'number-to-string headline-number
".")
2018 (apply (if (not (eq org-html-format-headline-function
'ignore
))
2019 (lambda (todo todo-type priority text tags
&rest ignore
)
2020 (funcall org-html-format-headline-function
2021 todo todo-type priority text tags
))
2022 #'org-html-format-headline
)
2023 todo todo-type priority text tags
:section-number nil
)))))
2025 (defun org-html-list-of-listings (info)
2026 "Build a list of listings.
2027 INFO is a plist used as a communication channel. Return the list
2028 of listings as a string, or nil if it is empty."
2029 (let ((lol-entries (org-export-collect-listings info
)))
2031 (concat "<div id=\"list-of-listings\">\n"
2032 (format "<h%d>%s</h%d>\n"
2033 org-html-toplevel-hlevel
2034 (org-html--translate "List of Listings" info
)
2035 org-html-toplevel-hlevel
)
2036 "<div id=\"text-list-of-listings\">\n<ul>\n"
2038 (initial-fmt (format "<span class=\"listing-number\">%s</span>"
2039 (org-html--translate "Listing %d:" info
))))
2042 (let ((label (org-element-property :name entry
))
2045 (or (org-export-get-caption entry t
)
2046 (org-export-get-caption entry
))
2051 (concat (format initial-fmt
(incf count
)) " " title
)
2052 (format "<a href=\"#%s\">%s %s</a>"
2053 (org-export-solidify-link-text label
)
2054 (format initial-fmt
(incf count
))
2058 "\n</ul>\n</div>\n</div>"))))
2060 (defun org-html-list-of-tables (info)
2061 "Build a list of tables.
2062 INFO is a plist used as a communication channel. Return the list
2063 of tables as a string, or nil if it is empty."
2064 (let ((lol-entries (org-export-collect-tables info
)))
2066 (concat "<div id=\"list-of-tables\">\n"
2067 (format "<h%d>%s</h%d>\n"
2068 org-html-toplevel-hlevel
2069 (org-html--translate "List of Tables" info
)
2070 org-html-toplevel-hlevel
)
2071 "<div id=\"text-list-of-tables\">\n<ul>\n"
2073 (initial-fmt (format "<span class=\"table-number\">%s</span>"
2074 (org-html--translate "Table %d:" info
))))
2077 (let ((label (org-element-property :name entry
))
2080 (or (org-export-get-caption entry t
)
2081 (org-export-get-caption entry
))
2086 (concat (format initial-fmt
(incf count
)) " " title
)
2087 (format "<a href=\"#%s\">%s %s</a>"
2088 (org-export-solidify-link-text label
)
2089 (format initial-fmt
(incf count
))
2093 "\n</ul>\n</div>\n</div>"))))
2096 ;;; Transcode Functions
2100 (defun org-html-bold (bold contents info
)
2101 "Transcode BOLD from Org to HTML.
2102 CONTENTS is the text with bold markup. INFO is a plist holding
2103 contextual information."
2104 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
2109 (defun org-html-center-block (center-block contents info
)
2110 "Transcode a CENTER-BLOCK element from Org to HTML.
2111 CONTENTS holds the contents of the block. INFO is a plist
2112 holding contextual information."
2113 (format "<div class=\"center\">\n%s</div>" contents
))
2117 (defun org-html-clock (clock contents info
)
2118 "Transcode a CLOCK element from Org to HTML.
2119 CONTENTS is nil. INFO is a plist used as a communication
2122 <span class=\"timestamp-wrapper\">
2123 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
2128 (org-element-property :raw-value
2129 (org-element-property :value clock
)))
2130 (let ((time (org-element-property :duration clock
)))
2131 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
2135 (defun org-html-code (code contents info
)
2136 "Transcode CODE from Org to HTML.
2137 CONTENTS is nil. INFO is a plist holding contextual
2139 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
2140 (org-html-encode-plain-text (org-element-property :value code
))))
2144 (defun org-html-drawer (drawer contents info
)
2145 "Transcode a DRAWER element from Org to HTML.
2146 CONTENTS holds the contents of the block. INFO is a plist
2147 holding contextual information."
2148 (if (functionp org-html-format-drawer-function
)
2149 (funcall org-html-format-drawer-function
2150 (org-element-property :drawer-name drawer
)
2152 ;; If there's no user defined function: simply
2153 ;; display contents of the drawer.
2158 (defun org-html-dynamic-block (dynamic-block contents info
)
2159 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
2160 CONTENTS holds the contents of the block. INFO is a plist
2161 holding contextual information. See `org-export-data'."
2166 (defun org-html-entity (entity contents info
)
2167 "Transcode an ENTITY object from Org to HTML.
2168 CONTENTS are the definition itself. INFO is a plist holding
2169 contextual information."
2170 (org-element-property :html entity
))
2174 (defun org-html-example-block (example-block contents info
)
2175 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
2176 CONTENTS is nil. INFO is a plist holding contextual
2178 (if (org-export-read-attribute :attr_html example-block
:textarea
)
2179 (org-html--textarea-block example-block
)
2180 (format "<pre class=\"example\">\n%s</pre>"
2181 (org-html-format-code example-block info
))))
2185 (defun org-html-export-snippet (export-snippet contents info
)
2186 "Transcode a EXPORT-SNIPPET object from Org to HTML.
2187 CONTENTS is nil. INFO is a plist holding contextual
2189 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
2190 (org-element-property :value export-snippet
)))
2194 (defun org-html-export-block (export-block contents info
)
2195 "Transcode a EXPORT-BLOCK element from Org to HTML.
2196 CONTENTS is nil. INFO is a plist holding contextual information."
2197 (when (string= (org-element-property :type export-block
) "HTML")
2198 (org-remove-indentation (org-element-property :value export-block
))))
2202 (defun org-html-fixed-width (fixed-width contents info
)
2203 "Transcode a FIXED-WIDTH element from Org to HTML.
2204 CONTENTS is nil. INFO is a plist holding contextual information."
2205 (format "<pre class=\"example\">\n%s</pre>"
2206 (org-html-do-format-code
2207 (org-remove-indentation
2208 (org-element-property :value fixed-width
)))))
2210 ;;;; Footnote Reference
2212 (defun org-html-footnote-reference (footnote-reference contents info
)
2213 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
2214 CONTENTS is nil. INFO is a plist holding contextual information."
2216 ;; Insert separator between two footnotes in a row.
2217 (let ((prev (org-export-get-previous-element footnote-reference info
)))
2218 (when (eq (org-element-type prev
) 'footnote-reference
)
2219 org-html-footnote-separator
))
2221 ((not (org-export-footnote-first-reference-p footnote-reference info
))
2222 (org-html-format-footnote-reference
2223 (org-export-get-footnote-number footnote-reference info
)
2225 ;; Inline definitions are secondary strings.
2226 ((eq (org-element-property :type footnote-reference
) 'inline
)
2227 (org-html-format-footnote-reference
2228 (org-export-get-footnote-number footnote-reference info
)
2230 ;; Non-inline footnotes definitions are full Org data.
2231 (t (org-html-format-footnote-reference
2232 (org-export-get-footnote-number footnote-reference info
)
2237 (defun org-html-format-headline--wrap
2238 (headline info
&optional format-function
&rest extra-keys
)
2239 "Transcode a HEADLINE element from Org to HTML.
2240 CONTENTS holds the contents of the headline. INFO is a plist
2241 holding contextual information."
2242 (let* ((level (+ (org-export-get-relative-level headline info
)
2243 (1- org-html-toplevel-hlevel
)))
2244 (headline-number (org-export-get-headline-number headline info
))
2245 (section-number (and (not (org-export-low-level-p headline info
))
2246 (org-export-numbered-headline-p headline info
)
2247 (mapconcat 'number-to-string
2248 headline-number
".")))
2249 (todo (and (plist-get info
:with-todo-keywords
)
2250 (let ((todo (org-element-property :todo-keyword headline
)))
2251 (and todo
(org-export-data todo info
)))))
2252 (todo-type (and todo
(org-element-property :todo-type headline
)))
2253 (priority (and (plist-get info
:with-priority
)
2254 (org-element-property :priority headline
)))
2255 (text (org-export-data (org-element-property :title headline
) info
))
2256 (tags (and (plist-get info
:with-tags
)
2257 (org-export-get-tags headline info
)))
2258 (headline-label (or (org-element-property :CUSTOM_ID headline
)
2259 (concat "sec-" (mapconcat 'number-to-string
2260 headline-number
"-"))))
2262 (cond ((functionp format-function
) format-function
)
2263 ((not (eq org-html-format-headline-function
'ignore
))
2264 (lambda (todo todo-type priority text tags
&rest ignore
)
2265 (funcall org-html-format-headline-function
2266 todo todo-type priority text tags
)))
2267 (t 'org-html-format-headline
))))
2268 (apply format-function
2269 todo todo-type priority text tags
2270 :headline-label headline-label
:level level
2271 :section-number section-number extra-keys
)))
2273 (defun org-html-headline (headline contents info
)
2274 "Transcode a HEADLINE element from Org to HTML.
2275 CONTENTS holds the contents of the headline. INFO is a plist
2276 holding contextual information."
2277 (unless (org-element-property :footnote-section-p headline
)
2278 (let* ((contents (or contents
""))
2279 (numberedp (org-export-numbered-headline-p headline info
))
2280 (level (org-export-get-relative-level headline info
))
2281 (text (org-export-data (org-element-property :title headline
) info
))
2282 (todo (and (plist-get info
:with-todo-keywords
)
2283 (let ((todo (org-element-property :todo-keyword headline
)))
2284 (and todo
(org-export-data todo info
)))))
2285 (todo-type (and todo
(org-element-property :todo-type headline
)))
2286 (tags (and (plist-get info
:with-tags
)
2287 (org-export-get-tags headline info
)))
2288 (priority (and (plist-get info
:with-priority
)
2289 (org-element-property :priority headline
)))
2290 (section-number (mapconcat #'number-to-string
2291 (org-export-get-headline-number
2292 headline info
) "-"))
2294 (list (org-element-property :CUSTOM_ID headline
)
2295 (concat "sec-" section-number
)
2296 (org-element-property :ID headline
))))
2297 (preferred-id (car ids
))
2298 (extra-ids (mapconcat
2301 (org-export-solidify-link-text
2302 (if (org-uuidgen-p id
) (concat "ID-" id
) id
))))
2304 ;; Create the headline text.
2305 (full-text (org-html-format-headline--wrap headline info
)))
2306 (if (org-export-low-level-p headline info
)
2307 ;; This is a deep sub-tree: export it as a list item.
2308 (let* ((type (if numberedp
'ordered
'unordered
))
2310 (org-html-format-list-item
2311 contents type nil info nil
2312 (concat (org-html--anchor preferred-id
) extra-ids
2315 (and (org-export-first-sibling-p headline info
)
2316 (org-html-begin-plain-list type
))
2318 (and (org-export-last-sibling-p headline info
)
2319 (org-html-end-plain-list type
))))
2320 ;; Standard headline. Export it as a section.
2321 (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
2322 (level1 (+ level
(1- org-html-toplevel-hlevel
)))
2323 (first-content (car (org-element-contents headline
))))
2324 (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
2325 (org-html--container headline info
)
2326 (format "outline-container-%s"
2327 (or (org-element-property :CUSTOM_ID headline
)
2328 (concat "sec-" section-number
)))
2329 (concat (format "outline-%d" level1
) (and extra-class
" ")
2331 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
2332 level1 preferred-id extra-ids full-text level1
)
2333 ;; When there is no section, pretend there is an
2334 ;; empty one to get the correct <div class="outline-
2335 ;; ...> which is needed by `org-info.js'.
2336 (if (not (eq (org-element-type first-content
) 'section
))
2337 (concat (org-html-section first-content
"" info
)
2340 (org-html--container headline info
)))))))
2342 (defun org-html--container (headline info
)
2343 (or (org-element-property :HTML_CONTAINER headline
)
2344 (if (= 1 (org-export-get-relative-level headline info
))
2345 (plist-get info
:html-container
)
2348 ;;;; Horizontal Rule
2350 (defun org-html-horizontal-rule (horizontal-rule contents info
)
2351 "Transcode an HORIZONTAL-RULE object from Org to HTML.
2352 CONTENTS is nil. INFO is a plist holding contextual information."
2353 (org-html-close-tag "hr" nil info
))
2355 ;;;; Inline Src Block
2357 (defun org-html-inline-src-block (inline-src-block contents info
)
2358 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
2359 CONTENTS holds the contents of the item. INFO is a plist holding
2360 contextual information."
2361 (let* ((org-lang (org-element-property :language inline-src-block
))
2362 (code (org-element-property :value inline-src-block
)))
2363 (error "Cannot export inline src block")))
2367 (defun org-html-format-section (text class
&optional id
)
2368 "Format a section with TEXT into a HTML div with CLASS and ID."
2369 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
2370 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
2372 (defun org-html-inlinetask (inlinetask contents info
)
2373 "Transcode an INLINETASK element from Org to HTML.
2374 CONTENTS holds the contents of the block. INFO is a plist
2375 holding contextual information."
2377 ;; If `org-html-format-inlinetask-function' is not 'ignore, call it
2378 ;; with appropriate arguments.
2379 ((not (eq org-html-format-inlinetask-function
'ignore
))
2380 (let ((format-function
2382 (lambda (todo todo-type priority text tags
2383 &key contents
&allow-other-keys
)
2384 (funcall org-html-format-inlinetask-function
2385 todo todo-type priority text tags contents
)))))
2386 (org-html-format-headline--wrap
2387 inlinetask info format-function
:contents contents
)))
2388 ;; Otherwise, use a default template.
2389 (t (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
2390 (org-html-format-headline--wrap inlinetask info
)
2391 (org-html-close-tag "br" nil info
)
2396 (defun org-html-italic (italic contents info
)
2397 "Transcode ITALIC from Org to HTML.
2398 CONTENTS is the text with italic markup. INFO is a plist holding
2399 contextual information."
2400 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
2404 (defun org-html-checkbox (checkbox)
2405 "Format CHECKBOX into HTML."
2406 (case checkbox
(on "<code>[X]</code>")
2407 (off "<code>[ ]</code>")
2408 (trans "<code>[-]</code>")
2411 (defun org-html-format-list-item (contents type checkbox info
2412 &optional term-counter-id
2414 "Format a list item into HTML."
2415 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" ")))
2416 (br (org-html-close-tag "br" nil info
)))
2420 (let* ((counter term-counter-id
)
2421 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2423 (format "<li%s>" extra
)
2424 (when headline
(concat headline br
)))))
2426 (let* ((id term-counter-id
)
2427 (extra (if id
(format " id=\"%s\"" id
) "")))
2429 (format "<li%s>" extra
)
2430 (when headline
(concat headline br
)))))
2432 (let* ((term term-counter-id
))
2433 (setq term
(or term
"(no term)"))
2434 ;; Check-boxes in descriptive lists are associated to tag.
2435 (concat (format "<dt> %s </dt>"
2436 (concat checkbox term
))
2438 (unless (eq type
'descriptive
) checkbox
)
2443 (descriptive "</dd>")))))
2445 (defun org-html-item (item contents info
)
2446 "Transcode an ITEM element from Org to HTML.
2447 CONTENTS holds the contents of the item. INFO is a plist holding
2448 contextual information."
2449 (let* ((plain-list (org-export-get-parent item
))
2450 (type (org-element-property :type plain-list
))
2451 (counter (org-element-property :counter item
))
2452 (checkbox (org-element-property :checkbox item
))
2453 (tag (let ((tag (org-element-property :tag item
)))
2454 (and tag
(org-export-data tag info
)))))
2455 (org-html-format-list-item
2456 contents type checkbox info
(or tag counter
))))
2460 (defun org-html-keyword (keyword contents info
)
2461 "Transcode a KEYWORD element from Org to HTML.
2462 CONTENTS is nil. INFO is a plist holding contextual information."
2463 (let ((key (org-element-property :key keyword
))
2464 (value (org-element-property :value keyword
)))
2466 ((string= key
"HTML") value
)
2467 ((string= key
"TOC")
2468 (let ((value (downcase value
)))
2470 ((string-match "\\<headlines\\>" value
)
2471 (let ((depth (or (and (string-match "[0-9]+" value
)
2472 (string-to-number (match-string 0 value
)))
2473 (plist-get info
:with-toc
))))
2474 (org-html-toc depth info
)))
2475 ((string= "listings" value
) (org-html-list-of-listings info
))
2476 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2478 ;;;; Latex Environment
2480 (defun org-html-format-latex (latex-frag processing-type info
)
2481 "Format a LaTeX fragment LATEX-FRAG into HTML.
2482 PROCESSING-TYPE designates the tool used for conversion. It is
2483 a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil
2484 and t. See `org-html-with-latex' for more information. INFO is
2485 a plist containing export properties."
2486 (let ((cache-relpath "") (cache-dir ""))
2487 (unless (eq processing-type
'mathjax
)
2488 (let ((bfn (or (buffer-file-name)
2490 (expand-file-name "latex" temporary-file-directory
))))
2492 (let ((header (plist-get info
:latex-header
)))
2495 (lambda (line) (concat "#+LATEX_HEADER: " line
))
2496 (org-split-string header
"\n")
2501 (file-name-sans-extension
2502 (file-name-nondirectory bfn
)))
2503 cache-dir
(file-name-directory bfn
))
2504 ;; Re-create LaTeX environment from original buffer in
2505 ;; temporary buffer so that dvipng/imagemagick can properly
2506 ;; turn the fragment into an image.
2507 (setq latex-frag
(concat latex-header latex-frag
))))
2510 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2511 nil nil processing-type
)
2514 (defun org-html-latex-environment (latex-environment contents info
)
2515 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2516 CONTENTS is nil. INFO is a plist holding contextual information."
2517 (let ((processing-type (plist-get info
:with-latex
))
2518 (latex-frag (org-remove-indentation
2519 (org-element-property :value latex-environment
)))
2520 (attributes (org-export-read-attribute :attr_html latex-environment
)))
2521 (case processing-type
2523 (org-html-format-latex latex-frag
'mathjax info
))
2524 ((dvipng imagemagick
)
2526 (org-html-format-latex latex-frag processing-type info
)))
2527 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2528 ;; Do not provide a caption or a name to be consistent with
2529 ;; `mathjax' handling.
2530 (org-html--wrap-image
2531 (org-html--format-image
2532 (match-string 1 formula-link
) attributes info
) info
))))
2537 (defun org-html-latex-fragment (latex-fragment contents info
)
2538 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2539 CONTENTS is nil. INFO is a plist holding contextual information."
2540 (let ((latex-frag (org-element-property :value latex-fragment
))
2541 (processing-type (plist-get info
:with-latex
)))
2542 (case processing-type
2544 (org-html-format-latex latex-frag
'mathjax info
))
2545 ((dvipng imagemagick
)
2547 (org-html-format-latex latex-frag processing-type info
)))
2548 (when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link
))
2549 (org-html--format-image (match-string 1 formula-link
) nil info
))))
2554 (defun org-html-line-break (line-break contents info
)
2555 "Transcode a LINE-BREAK object from Org to HTML.
2556 CONTENTS is nil. INFO is a plist holding contextual information."
2557 (concat (org-html-close-tag "br" nil info
) "\n"))
2561 (defun org-html-inline-image-p (link info
)
2562 "Non-nil when LINK is meant to appear as an image.
2563 INFO is a plist used as a communication channel. LINK is an
2564 inline image when it has no description and targets an image
2565 file (see `org-html-inline-image-rules' for more information), or
2566 if its description is a single link targeting an image file."
2567 (if (not (org-element-contents link
))
2568 (org-export-inline-image-p link org-html-inline-image-rules
)
2570 (let ((link-count 0))
2571 (org-element-map (org-element-contents link
)
2572 (cons 'plain-text org-element-all-objects
)
2574 (case (org-element-type obj
)
2575 (plain-text (org-string-nw-p obj
))
2576 (link (if (= link-count
1) t
2578 (not (org-export-inline-image-p
2579 obj org-html-inline-image-rules
))))
2583 (defvar org-html-standalone-image-predicate
)
2584 (defun org-html-standalone-image-p (element info
)
2585 "Non-nil if ELEMENT is a standalone image.
2587 INFO is a plist holding contextual information.
2589 An element or object is a standalone image when
2591 - its type is `paragraph' and its sole content, save for white
2592 spaces, is a link that qualifies as an inline image;
2594 - its type is `link' and its containing paragraph has no other
2595 content save white spaces.
2597 Bind `org-html-standalone-image-predicate' to constrain paragraph
2598 further. For example, to check for only captioned standalone
2601 \(lambda (paragraph) (org-element-property :caption paragraph))"
2602 (let ((paragraph (case (org-element-type element
)
2604 (link (org-export-get-parent element
)))))
2605 (and (eq (org-element-type paragraph
) 'paragraph
)
2606 (or (not (fboundp 'org-html-standalone-image-predicate
))
2607 (funcall org-html-standalone-image-predicate paragraph
))
2609 (let ((link-count 0))
2610 (org-element-map (org-element-contents paragraph
)
2611 (cons 'plain-text org-element-all-objects
)
2613 (when (case (org-element-type obj
)
2614 (plain-text (org-string-nw-p obj
))
2615 (link (or (> (incf link-count
) 1)
2616 (not (org-html-inline-image-p obj info
))))
2620 (= link-count
1))))))
2622 (defun org-html-link (link desc info
)
2623 "Transcode a LINK object from Org to HTML.
2625 DESC is the description part of the link, or the empty string.
2626 INFO is a plist holding contextual information. See
2628 (let* ((home (when (plist-get info
:html-link-home
)
2629 (org-trim (plist-get info
:html-link-home
))))
2630 (use-abs-url (plist-get info
:html-link-use-abs-url
))
2631 (link-org-files-as-html-maybe
2633 (lambda (raw-path info
)
2634 "Treat links to `file.org' as links to `file.html', if needed.
2635 See `org-html-link-org-files-as-html'."
2637 ((and org-html-link-org-files-as-html
2639 (downcase (file-name-extension raw-path
"."))))
2640 (concat (file-name-sans-extension raw-path
) "."
2641 (plist-get info
:html-extension
)))
2643 (type (org-element-property :type link
))
2644 (raw-path (org-element-property :path link
))
2645 ;; Ensure DESC really exists, or set it to nil.
2646 (desc (org-string-nw-p desc
))
2649 ((member type
'("http" "https" "ftp" "mailto"))
2652 (concat type
":" raw-path
)) org-link-escape-chars-browser
))
2653 ((string= type
"file")
2654 ;; Treat links to ".org" files as ".html", if needed.
2656 (funcall link-org-files-as-html-maybe raw-path info
))
2657 ;; If file path is absolute, prepend it with protocol
2658 ;; component - "file:".
2660 ((file-name-absolute-p raw-path
)
2661 (setq raw-path
(concat "file:" raw-path
)))
2662 ((and home use-abs-url
)
2663 (setq raw-path
(concat (file-name-as-directory home
) raw-path
))))
2664 ;; Add search option, if any. A search option can be
2665 ;; relative to a custom-id or a headline title. Any other
2666 ;; option is ignored.
2667 (let ((option (org-element-property :search-option link
)))
2668 (cond ((not option
) raw-path
)
2669 ((eq (aref option
0) ?
#) (concat raw-path option
))
2670 ;; External fuzzy link: try to resolve it if path
2671 ;; belongs to current project, if any.
2672 ((eq (aref option
0) ?
*)
2676 (org-publish-resolve-external-fuzzy-link
2677 (org-element-property :path link
) option
)))
2678 (and numbers
(concat "#sec-"
2679 (mapconcat 'number-to-string
2683 ;; Extract attributes from parent's paragraph. HACK: Only do
2684 ;; this for the first link in parent (inner image link for
2685 ;; inline images). This is needed as long as attributes
2686 ;; cannot be set on a per link basis.
2688 (let* ((parent (org-export-get-parent-element link
))
2689 (link (let ((container (org-export-get-parent link
)))
2690 (if (and (eq (org-element-type container
) 'link
)
2691 (org-html-inline-image-p link info
))
2694 (and (eq (org-element-map parent
'link
'identity info t
) link
)
2695 (org-export-read-attribute :attr_html parent
))))
2697 (let ((attr (org-html--make-attribute-string attributes-plist
)))
2698 (if (org-string-nw-p attr
) (concat " " attr
) "")))
2702 ((and org-html-inline-images
2703 (org-export-inline-image-p link org-html-inline-image-rules
))
2704 (org-html--format-image path attributes-plist info
))
2705 ;; Radio target: Transcode target's contents and use them as
2706 ;; link's description.
2707 ((string= type
"radio")
2708 (let ((destination (org-export-resolve-radio-link link info
)))
2709 (if (not destination
) desc
2710 (format "<a href=\"#%s\"%s>%s</a>"
2711 (org-export-solidify-link-text
2712 (org-element-property :value destination
))
2714 ;; Links pointing to a headline: Find destination and build
2715 ;; appropriate referencing command.
2716 ((member type
'("custom-id" "fuzzy" "id"))
2717 (let ((destination (if (string= type
"fuzzy")
2718 (org-export-resolve-fuzzy-link link info
)
2719 (org-export-resolve-id-link link info
))))
2720 (case (org-element-type destination
)
2721 ;; ID link points to an external file.
2723 (let ((fragment (concat "ID-" path
))
2724 ;; Treat links to ".org" files as ".html", if needed.
2725 (path (funcall link-org-files-as-html-maybe
2727 (format "<a href=\"%s#%s\"%s>%s</a>"
2728 path fragment attributes
(or desc destination
))))
2729 ;; Fuzzy link points nowhere.
2734 (org-element-property :raw-link link
) info
))))
2735 ;; Link points to a headline.
2738 ;; What href to use?
2740 ;; Case 1: Headline is linked via it's CUSTOM_ID
2741 ;; property. Use CUSTOM_ID.
2742 ((string= type
"custom-id")
2743 (org-element-property :CUSTOM_ID destination
))
2744 ;; Case 2: Headline is linked via it's ID property
2745 ;; or through other means. Use the default href.
2746 ((member type
'("id" "fuzzy"))
2748 (mapconcat 'number-to-string
2749 (org-export-get-headline-number
2750 destination info
) "-")))
2751 (t (error "Shouldn't reach here"))))
2752 ;; What description to use?
2754 ;; Case 1: Headline is numbered and LINK has no
2755 ;; description. Display section number.
2756 (if (and (org-export-numbered-headline-p destination info
)
2758 (mapconcat 'number-to-string
2759 (org-export-get-headline-number
2760 destination info
) ".")
2761 ;; Case 2: Either the headline is un-numbered or
2762 ;; LINK has a custom description. Display LINK's
2763 ;; description or headline's title.
2764 (or desc
(org-export-data (org-element-property
2765 :title destination
) info
)))))
2766 (format "<a href=\"#%s\"%s>%s</a>"
2767 (org-export-solidify-link-text href
) attributes desc
)))
2768 ;; Fuzzy link points to a target or an element.
2770 (let* ((path (org-export-solidify-link-text path
))
2771 (org-html-standalone-image-predicate 'org-html--has-caption-p
)
2774 ((org-html-standalone-image-p destination info
)
2775 (org-export-get-ordinal
2776 (org-element-map destination
'link
2778 info
'link
'org-html-standalone-image-p
))
2779 (t (org-export-get-ordinal
2780 destination info nil
'org-html--has-caption-p
))))
2782 ((not number
) "No description for this link")
2783 ((numberp number
) (number-to-string number
))
2784 (t (mapconcat 'number-to-string number
".")))))
2785 (format "<a href=\"#%s\"%s>%s</a>" path attributes desc
))))))
2786 ;; Coderef: replace link with the reference name or the
2787 ;; equivalent line number.
2788 ((string= type
"coderef")
2789 (let ((fragment (concat "coderef-" path
)))
2790 (format "<a href=\"#%s\"%s%s>%s</a>"
2793 (format (concat "class=\"coderef\""
2794 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2795 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2798 (format (org-export-get-coderef-format path desc
)
2799 (org-export-resolve-coderef path info
)))))
2800 ;; Link type is handled by a special function.
2801 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2802 (funcall protocol
(org-link-unescape path
) desc
'html
))
2803 ;; External link with a description part.
2804 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2805 ;; External link without a description part.
2806 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2807 ;; No path, only description. Try to do something useful.
2808 (t (format "<i>%s</i>" desc
)))))
2812 (defun org-html-paragraph (paragraph contents info
)
2813 "Transcode a PARAGRAPH element from Org to HTML.
2814 CONTENTS is the contents of the paragraph, as a string. INFO is
2815 the plist used as a communication channel."
2816 (let* ((parent (org-export-get-parent paragraph
))
2817 (parent-type (org-element-type parent
))
2818 (style '((footnote-definition " class=\"footpara\"")))
2819 (extra (or (cadr (assoc parent-type style
)) "")))
2821 ((and (eq (org-element-type parent
) 'item
)
2822 (= (org-element-property :begin paragraph
)
2823 (org-element-property :contents-begin parent
)))
2824 ;; Leading paragraph in a list item have no tags.
2826 ((org-html-standalone-image-p paragraph info
)
2827 ;; Standalone image.
2829 (let ((raw (org-export-data
2830 (org-export-get-caption paragraph
) info
))
2831 (org-html-standalone-image-predicate
2832 'org-html--has-caption-p
))
2833 (if (not (org-string-nw-p raw
)) raw
2835 "<span class=\"figure-number\">"
2836 (format (org-html--translate "Figure %d:" info
)
2837 (org-export-get-ordinal
2838 (org-element-map paragraph
'link
2840 info nil
'org-html-standalone-image-p
))
2842 (label (org-element-property :name paragraph
)))
2843 (org-html--wrap-image contents info caption label
)))
2844 ;; Regular paragraph.
2845 (t (format "<p%s>\n%s</p>" extra contents
)))))
2849 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2850 ;; the correct value for the item counter
2851 (defun org-html-begin-plain-list (type &optional arg1
)
2852 "Insert the beginning of the HTML list depending on TYPE.
2853 When ARG1 is a string, use it as the start parameter for ordered
2857 (format "<ol class=\"org-ol\"%s>"
2858 (if arg1
(format " start=\"%d\"" arg1
) "")))
2859 (unordered "<ul class=\"org-ul\">")
2860 (descriptive "<dl class=\"org-dl\">")))
2862 (defun org-html-end-plain-list (type)
2863 "Insert the end of the HTML list depending on TYPE."
2867 (descriptive "</dl>")))
2869 (defun org-html-plain-list (plain-list contents info
)
2870 "Transcode a PLAIN-LIST element from Org to HTML.
2871 CONTENTS is the contents of the list. INFO is a plist holding
2872 contextual information."
2873 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2874 (type (org-element-property :type plain-list
)))
2876 (org-html-begin-plain-list type
)
2877 contents
(org-html-end-plain-list type
))))
2881 (defun org-html-convert-special-strings (string)
2882 "Convert special characters in STRING to HTML."
2883 (let ((all org-html-special-string-regexps
)
2885 (while (setq a
(pop all
))
2886 (setq re
(car a
) rpl
(cdr a
) start
0)
2887 (while (string-match re string start
)
2888 (setq string
(replace-match rpl t nil string
))))
2891 (defun org-html-encode-plain-text (text)
2892 "Convert plain text characters from TEXT to HTML equivalent.
2893 Possible conversions are set in `org-html-protect-char-alist'."
2896 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2897 org-html-protect-char-alist
)
2900 (defun org-html-plain-text (text info
)
2901 "Transcode a TEXT string from Org to HTML.
2902 TEXT is the string to transcode. INFO is a plist holding
2903 contextual information."
2904 (let ((output text
))
2905 ;; Protect following characters: <, >, &.
2906 (setq output
(org-html-encode-plain-text output
))
2907 ;; Handle smart quotes. Be sure to provide original string since
2908 ;; OUTPUT may have been modified.
2909 (when (plist-get info
:with-smart-quotes
)
2910 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2911 ;; Handle special strings.
2912 (when (plist-get info
:with-special-strings
)
2913 (setq output
(org-html-convert-special-strings output
)))
2914 ;; Handle break preservation if required.
2915 (when (plist-get info
:preserve-breaks
)
2917 (replace-regexp-in-string
2918 "\\(\\\\\\\\\\)?[ \t]*\n"
2919 (concat (org-html-close-tag "br" nil info
) "\n") output
)))
2926 (defun org-html-planning (planning contents info
)
2927 "Transcode a PLANNING element from Org to HTML.
2928 CONTENTS is nil. INFO is a plist used as a communication
2930 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2932 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2937 (let ((closed (org-element-property :closed planning
)))
2939 (format span-fmt org-closed-string
2941 (org-element-property :raw-value closed
)))))
2942 (let ((deadline (org-element-property :deadline planning
)))
2944 (format span-fmt org-deadline-string
2946 (org-element-property :raw-value deadline
)))))
2947 (let ((scheduled (org-element-property :scheduled planning
)))
2949 (format span-fmt org-scheduled-string
2951 (org-element-property :raw-value scheduled
)))))))
2954 ;;;; Property Drawer
2956 (defun org-html-property-drawer (property-drawer contents info
)
2957 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2958 CONTENTS is nil. INFO is a plist holding contextual
2960 ;; The property drawer isn't exported but we want separating blank
2961 ;; lines nonetheless.
2966 (defun org-html-quote-block (quote-block contents info
)
2967 "Transcode a QUOTE-BLOCK element from Org to HTML.
2968 CONTENTS holds the contents of the block. INFO is a plist
2969 holding contextual information."
2970 (format "<blockquote>\n%s</blockquote>" contents
))
2974 (defun org-html-quote-section (quote-section contents info
)
2975 "Transcode a QUOTE-SECTION element from Org to HTML.
2976 CONTENTS is nil. INFO is a plist holding contextual information."
2977 (let ((value (org-remove-indentation
2978 (org-element-property :value quote-section
))))
2979 (when value
(format "<pre>\n%s</pre>" value
))))
2983 (defun org-html-section (section contents info
)
2984 "Transcode a SECTION element from Org to HTML.
2985 CONTENTS holds the contents of the section. INFO is a plist
2986 holding contextual information."
2987 (let ((parent (org-export-get-parent-headline section
)))
2988 ;; Before first headline: no container, just return CONTENTS.
2989 (if (not parent
) contents
2990 ;; Get div's class and id references.
2991 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2992 (1- org-html-toplevel-hlevel
)))
2996 (org-export-get-headline-number parent info
) "-")))
2997 ;; Build return value.
2998 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
3000 (or (org-element-property :CUSTOM_ID parent
) section-number
)
3005 (defun org-html-radio-target (radio-target text info
)
3006 "Transcode a RADIO-TARGET object from Org to HTML.
3007 TEXT is the text of the target. INFO is a plist holding
3008 contextual information."
3009 (let ((id (org-export-solidify-link-text
3010 (org-element-property :value radio-target
))))
3011 (org-html--anchor id text
)))
3015 (defun org-html-special-block (special-block contents info
)
3016 "Transcode a SPECIAL-BLOCK element from Org to HTML.
3017 CONTENTS holds the contents of the block. INFO is a plist
3018 holding contextual information."
3019 (let* ((block-type (downcase
3020 (org-element-property :type special-block
)))
3021 (contents (or contents
""))
3022 (html5-fancy (and (org-html-html5-p info
)
3023 (plist-get info
:html-html5-fancy
)
3024 (member block-type org-html-html5-elements
)))
3025 (attributes (org-export-read-attribute :attr_html special-block
)))
3027 (let ((class (plist-get attributes
:class
)))
3028 (setq attributes
(plist-put attributes
:class
3029 (if class
(concat class
" " block-type
)
3031 (setq attributes
(org-html--make-attribute-string attributes
))
3032 (when (not (equal attributes
""))
3033 (setq attributes
(concat " " attributes
)))
3035 (format "<%s%s>\n%s</%s>" block-type attributes
3036 contents block-type
)
3037 (format "<div%s>\n%s\n</div>" attributes contents
))))
3041 (defun org-html-src-block (src-block contents info
)
3042 "Transcode a SRC-BLOCK element from Org to HTML.
3043 CONTENTS holds the contents of the item. INFO is a plist holding
3044 contextual information."
3045 (if (org-export-read-attribute :attr_html src-block
:textarea
)
3046 (org-html--textarea-block src-block
)
3047 (let ((lang (org-element-property :language src-block
))
3048 (caption (org-export-get-caption src-block
))
3049 (code (org-html-format-code src-block info
))
3050 (label (let ((lbl (org-element-property :name src-block
)))
3052 (format " id=\"%s\""
3053 (org-export-solidify-link-text lbl
))))))
3054 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
3056 "<div class=\"org-src-container\">\n%s%s\n</div>"
3057 (if (not caption
) ""
3058 (format "<label class=\"org-src-name\">%s</label>"
3059 (org-export-data caption info
)))
3060 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
3062 ;;;; Statistics Cookie
3064 (defun org-html-statistics-cookie (statistics-cookie contents info
)
3065 "Transcode a STATISTICS-COOKIE object from Org to HTML.
3066 CONTENTS is nil. INFO is a plist holding contextual information."
3067 (let ((cookie-value (org-element-property :value statistics-cookie
)))
3068 (format "<code>%s</code>" cookie-value
)))
3072 (defun org-html-strike-through (strike-through contents info
)
3073 "Transcode STRIKE-THROUGH from Org to HTML.
3074 CONTENTS is the text with strike-through markup. INFO is a plist
3075 holding contextual information."
3076 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
3081 (defun org-html-subscript (subscript contents info
)
3082 "Transcode a SUBSCRIPT object from Org to HTML.
3083 CONTENTS is the contents of the object. INFO is a plist holding
3084 contextual information."
3085 (format "<sub>%s</sub>" contents
))
3089 (defun org-html-superscript (superscript contents info
)
3090 "Transcode a SUPERSCRIPT object from Org to HTML.
3091 CONTENTS is the contents of the object. INFO is a plist holding
3092 contextual information."
3093 (format "<sup>%s</sup>" contents
))
3097 (defun org-html-table-cell (table-cell contents info
)
3098 "Transcode a TABLE-CELL element from Org to HTML.
3099 CONTENTS is nil. INFO is a plist used as a communication
3101 (let* ((table-row (org-export-get-parent table-cell
))
3102 (table (org-export-get-parent-table table-cell
))
3104 (if (not org-html-table-align-individual-fields
) ""
3105 (format (if (and (boundp 'org-html-format-table-no-css
)
3106 org-html-format-table-no-css
)
3107 " align=\"%s\"" " class=\"%s\"")
3108 (org-export-table-cell-alignment table-cell info
)))))
3109 (when (or (not contents
) (string= "" (org-trim contents
)))
3110 (setq contents
" "))
3112 ((and (org-export-table-has-header-p table info
)
3113 (= 1 (org-export-table-row-group table-row info
)))
3114 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
3115 contents
(cdr org-html-table-header-tags
)))
3116 ((and org-html-table-use-header-tags-for-first-column
3117 (zerop (cdr (org-export-table-cell-address table-cell info
))))
3118 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
3119 contents
(cdr org-html-table-header-tags
)))
3120 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
3121 contents
(cdr org-html-table-data-tags
))))))
3125 (defun org-html-table-row (table-row contents info
)
3126 "Transcode a TABLE-ROW element from Org to HTML.
3127 CONTENTS is the contents of the row. INFO is a plist used as a
3128 communication channel."
3129 ;; Rules are ignored since table separators are deduced from
3130 ;; borders of the current row.
3131 (when (eq (org-element-property :type table-row
) 'standard
)
3132 (let* ((rowgroup-number (org-export-table-row-group table-row info
))
3133 (row-number (org-export-table-row-number table-row info
))
3135 (org-export-table-row-starts-rowgroup-p table-row info
))
3137 (org-export-table-row-ends-rowgroup-p table-row info
))
3138 ;; `top-row-p' and `end-rowgroup-p' are not used directly
3139 ;; but should be set so that `org-html-table-row-tags' can
3140 ;; use them (see the docstring of this variable.)
3141 (top-row-p (and (equal start-rowgroup-p
'(top))
3142 (equal end-rowgroup-p
'(below top
))))
3143 (bottom-row-p (and (equal start-rowgroup-p
'(above))
3144 (equal end-rowgroup-p
'(bottom above
))))
3147 ;; Case 1: Row belongs to second or subsequent rowgroups.
3148 ((not (= 1 rowgroup-number
))
3149 '("<tbody>" .
"\n</tbody>"))
3150 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
3151 ((org-export-table-has-header-p
3152 (org-export-get-parent-table table-row
) info
)
3153 '("<thead>" .
"\n</thead>"))
3154 ;; Case 2: Row is from first and only row group.
3155 (t '("<tbody>" .
"\n</tbody>")))))
3157 ;; Begin a rowgroup?
3158 (when start-rowgroup-p
(car rowgroup-tags
))
3160 (concat "\n" (eval (car org-html-table-row-tags
))
3163 (eval (cdr org-html-table-row-tags
)))
3165 (when end-rowgroup-p
(cdr rowgroup-tags
))))))
3169 (defun org-html-table-first-row-data-cells (table info
)
3170 "Transcode the first row of TABLE.
3171 INFO is a plist used as a communication channel."
3173 (org-element-map table
'table-row
3175 (unless (eq (org-element-property :type row
) 'rule
) row
))
3177 (special-column-p (org-export-table-has-special-column-p table
)))
3178 (if (not special-column-p
) (org-element-contents table-row
)
3179 (cdr (org-element-contents table-row
)))))
3181 (defun org-html-table--table.el-table
(table info
)
3182 "Format table.el tables into HTML.
3183 INFO is a plist used as a communication channel."
3184 (when (eq (org-element-property :type table
) 'table.el
)
3186 (let ((outbuf (with-current-buffer
3187 (get-buffer-create "*org-export-table*")
3188 (erase-buffer) (current-buffer))))
3190 (insert (org-element-property :value table
))
3192 (re-search-forward "^[ \t]*|[^|]" nil t
)
3193 (table-generate-source 'html outbuf
))
3194 (with-current-buffer outbuf
3195 (prog1 (org-trim (buffer-string))
3198 (defun org-html-table (table contents info
)
3199 "Transcode a TABLE element from Org to HTML.
3200 CONTENTS is the contents of the table. INFO is a plist holding
3201 contextual information."
3202 (case (org-element-property :type table
)
3203 ;; Case 1: table.el table. Convert it using appropriate tools.
3204 (table.el
(org-html-table--table.el-table table info
))
3205 ;; Case 2: Standard table.
3207 (let* ((label (org-element-property :name table
))
3208 (caption (org-export-get-caption table
))
3209 (number (org-export-get-ordinal
3210 table info nil
'org-html--has-caption-p
))
3212 (org-html--make-attribute-string
3214 (and label
(list :id
(org-export-solidify-link-text label
)))
3215 (and (not (org-html-html5-p info
))
3216 (plist-get info
:html-table-attributes
))
3217 (org-export-read-attribute :attr_html table
))))
3219 (if (and (boundp 'org-html-format-table-no-css
)
3220 org-html-format-table-no-css
)
3221 "align=\"%s\"" "class=\"%s\""))
3224 (lambda (table info
)
3226 (lambda (table-cell)
3227 (let ((alignment (org-export-table-cell-alignment
3230 ;; Begin a colgroup?
3231 (when (org-export-table-cell-starts-colgroup-p
3234 ;; Add a column. Also specify it's alignment.
3237 "col" (concat " " (format alignspec alignment
)) info
))
3239 (when (org-export-table-cell-ends-colgroup-p
3242 (org-html-table-first-row-data-cells table info
) "\n")))))
3243 (format "<table%s>\n%s\n%s\n%s</table>"
3244 (if (equal attributes
"") "" (concat " " attributes
))
3245 (if (not caption
) ""
3246 (format (if org-html-table-caption-above
3247 "<caption class=\"t-above\">%s</caption>"
3248 "<caption class=\"t-bottom\">%s</caption>")
3250 "<span class=\"table-number\">"
3251 (format (org-html--translate "Table %d:" info
) number
)
3252 "</span> " (org-export-data caption info
))))
3253 (funcall table-column-specs table info
)
3258 (defun org-html-target (target contents info
)
3259 "Transcode a TARGET object from Org to HTML.
3260 CONTENTS is nil. INFO is a plist holding contextual
3262 (let ((id (org-export-solidify-link-text
3263 (org-element-property :value target
))))
3264 (org-html--anchor id
)))
3268 (defun org-html-timestamp (timestamp contents info
)
3269 "Transcode a TIMESTAMP object from Org to HTML.
3270 CONTENTS is nil. INFO is a plist holding contextual
3272 (let ((value (org-html-plain-text
3273 (org-timestamp-translate timestamp
) info
)))
3274 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
3275 (replace-regexp-in-string "--" "–" value
))))
3279 (defun org-html-underline (underline contents info
)
3280 "Transcode UNDERLINE from Org to HTML.
3281 CONTENTS is the text with underline markup. INFO is a plist
3282 holding contextual information."
3283 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
3288 (defun org-html-verbatim (verbatim contents info
)
3289 "Transcode VERBATIM from Org to HTML.
3290 CONTENTS is nil. INFO is a plist holding contextual
3292 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
3293 (org-html-encode-plain-text (org-element-property :value verbatim
))))
3297 (defun org-html-verse-block (verse-block contents info
)
3298 "Transcode a VERSE-BLOCK element from Org to HTML.
3299 CONTENTS is verse block contents. INFO is a plist holding
3300 contextual information."
3301 ;; Replace each newline character with line break. Also replace
3302 ;; each blank line with a line break.
3303 (setq contents
(replace-regexp-in-string
3304 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info
))
3305 (replace-regexp-in-string
3306 "\\(\\\\\\\\\\)?[ \t]*\n"
3307 (format "%s\n" (org-html-close-tag "br" nil info
)) contents
)))
3308 ;; Replace each white space at beginning of a line with a
3309 ;; non-breaking space.
3310 (while (string-match "^[ \t]+" contents
)
3311 (let* ((num-ws (length (match-string 0 contents
)))
3312 (ws (let (out) (dotimes (i num-ws out
)
3313 (setq out
(concat out
" "))))))
3314 (setq contents
(replace-match ws nil t contents
))))
3315 (format "<p class=\"verse\">\n%s</p>" contents
))
3318 ;;; Filter Functions
3320 (defun org-html-final-function (contents backend info
)
3321 "Filter to indent the HTML and convert HTML entities."
3326 (indent-region (point-min) (point-max)))
3327 (when org-html-use-unicode-chars
3329 (mm-url-decode-entities))
3330 (buffer-substring-no-properties (point-min) (point-max))))
3333 ;;; End-user functions
3336 (defun org-html-export-as-html
3337 (&optional async subtreep visible-only body-only ext-plist
)
3338 "Export current buffer to an HTML buffer.
3340 If narrowing is active in the current buffer, only export its
3343 If a region is active, export that region.
3345 A non-nil optional argument ASYNC means the process should happen
3346 asynchronously. The resulting buffer should be accessible
3347 through the `org-export-stack' interface.
3349 When optional argument SUBTREEP is non-nil, export the sub-tree
3350 at point, extracting information from the headline properties
3353 When optional argument VISIBLE-ONLY is non-nil, don't export
3354 contents of hidden elements.
3356 When optional argument BODY-ONLY is non-nil, only write code
3357 between \"<body>\" and \"</body>\" tags.
3359 EXT-PLIST, when provided, is a property list with external
3360 parameters overriding Org default settings, but still inferior to
3361 file-local settings.
3363 Export is done in a buffer named \"*Org HTML Export*\", which
3364 will be displayed when `org-export-show-temporary-export-buffer'
3367 (org-export-to-buffer 'html
"*Org HTML Export*"
3368 async subtreep visible-only body-only ext-plist
3369 (lambda () (set-auto-mode t
))))
3372 (defun org-html-convert-region-to-html ()
3373 "Assume the current region has org-mode syntax, and convert it to HTML.
3374 This can be used in any buffer. For example, you can write an
3375 itemized list in org-mode syntax in an HTML buffer and use this
3376 command to convert it."
3378 (org-export-replace-region-by 'html
))
3381 (defun org-html-export-to-html
3382 (&optional async subtreep visible-only body-only ext-plist
)
3383 "Export current buffer to a HTML file.
3385 If narrowing is active in the current buffer, only export its
3388 If a region is active, export that region.
3390 A non-nil optional argument ASYNC means the process should happen
3391 asynchronously. The resulting file should be accessible through
3392 the `org-export-stack' interface.
3394 When optional argument SUBTREEP is non-nil, export the sub-tree
3395 at point, extracting information from the headline properties
3398 When optional argument VISIBLE-ONLY is non-nil, don't export
3399 contents of hidden elements.
3401 When optional argument BODY-ONLY is non-nil, only write code
3402 between \"<body>\" and \"</body>\" tags.
3404 EXT-PLIST, when provided, is a property list with external
3405 parameters overriding Org default settings, but still inferior to
3406 file-local settings.
3408 Return output file's name."
3410 (let* ((extension (concat "." org-html-extension
))
3411 (file (org-export-output-file-name extension subtreep
))
3412 (org-export-coding-system org-html-coding-system
))
3413 (org-export-to-file 'html file
3414 async subtreep visible-only body-only ext-plist
)))
3417 (defun org-html-publish-to-html (plist filename pub-dir
)
3418 "Publish an org file to HTML.
3420 FILENAME is the filename of the Org file to be published. PLIST
3421 is the property list for the given project. PUB-DIR is the
3422 publishing directory.
3424 Return output file name."
3425 (org-publish-org-to 'html filename
3426 (concat "." (or (plist-get plist
:html-extension
)
3427 org-html-extension
"html"))
3434 ;; generated-autoload-file: "org-loaddefs.el"
3437 ;;; ox-html.el ends here