1 ;;; ox-html.el --- HTML Back-End for Org Export Engine
3 ;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
5 ;; Author: Jambunathan K <kjambunathan at gmail dot com>
6 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ;; This library implements a HTML back-end for Org generic exporter.
27 ;; M-x org-export-as-html
29 ;; in an Org mode buffer. See ox.el for more details on how this
38 (require 'format-spec
)
39 (eval-when-compile (require 'cl
) (require 'table
))
43 ;;; Function Declarations
45 (declare-function org-id-find-id-file
"org-id" (id))
46 (declare-function htmlize-region
"ext:htmlize" (beg end
))
47 (declare-function org-pop-to-buffer-same-window
48 "org-compat" (&optional buffer-or-name norecord label
))
53 (org-export-define-backend html
54 ((bold . org-html-bold
)
55 (center-block . org-html-center-block
)
56 (clock . org-html-clock
)
57 (code . org-html-code
)
58 (drawer . org-html-drawer
)
59 (dynamic-block . org-html-dynamic-block
)
60 (entity . org-html-entity
)
61 (example-block . org-html-example-block
)
62 (export-block . org-html-export-block
)
63 (export-snippet . org-html-export-snippet
)
64 (fixed-width . org-html-fixed-width
)
65 (footnote-definition . org-html-footnote-definition
)
66 (footnote-reference . org-html-footnote-reference
)
67 (headline . org-html-headline
)
68 (horizontal-rule . org-html-horizontal-rule
)
69 (inline-src-block . org-html-inline-src-block
)
70 (inlinetask . org-html-inlinetask
)
71 (inner-template . org-html-inner-template
)
72 (italic . org-html-italic
)
73 (item . org-html-item
)
74 (keyword . org-html-keyword
)
75 (latex-environment . org-html-latex-environment
)
76 (latex-fragment . org-html-latex-fragment
)
77 (line-break . org-html-line-break
)
78 (link . org-html-link
)
79 (paragraph . org-html-paragraph
)
80 (plain-list . org-html-plain-list
)
81 (plain-text . org-html-plain-text
)
82 (planning . org-html-planning
)
83 (property-drawer . org-html-property-drawer
)
84 (quote-block . org-html-quote-block
)
85 (quote-section . org-html-quote-section
)
86 (radio-target . org-html-radio-target
)
87 (section . org-html-section
)
88 (special-block . org-html-special-block
)
89 (src-block . org-html-src-block
)
90 (statistics-cookie . org-html-statistics-cookie
)
91 (strike-through . org-html-strike-through
)
92 (subscript . org-html-subscript
)
93 (superscript . org-html-superscript
)
94 (table . org-html-table
)
95 (table-cell . org-html-table-cell
)
96 (table-row . org-html-table-row
)
97 (target . org-html-target
)
98 (template . org-html-template
)
99 (timestamp . org-html-timestamp
)
100 (underline . org-html-underline
)
101 (verbatim . org-html-verbatim
)
102 (verse-block . org-html-verse-block
))
104 :filters-alist
((:filter-final-output . org-html-final-function
))
107 ((?H
"As HTML buffer" org-html-export-as-html
)
108 (?h
"As HTML file" org-html-export-to-html
)
109 (?o
"As HTML file and open"
111 (if a
(org-html-export-to-html t s v b
)
112 (org-open-file (org-html-export-to-html nil s v b
)))))))
114 ((:html-extension nil nil org-html-extension
)
115 (:html-link-home
"HTML_LINK_HOME" nil org-html-link-home
)
116 (:html-link-up
"HTML_LINK_UP" nil org-html-link-up
)
117 (:html-mathjax
"HTML_MATHJAX" nil
"" space
)
118 (:html-postamble nil
"html-postamble" org-html-postamble
)
119 (:html-preamble nil
"html-preamble" org-html-preamble
)
120 (:html-style nil nil org-html-style
)
121 (:html-style-extra
"HTML_STYLE" nil org-html-style-extra newline
)
122 (:html-style-include-default nil nil org-html-style-include-default
)
123 (:html-style-include-scripts nil nil org-html-style-include-scripts
)
124 (:html-table-tag nil nil org-html-table-tag
)
125 ;; Redefine regular options.
126 (:creator
"CREATOR" nil org-html-creator-string
)
127 (:with-latex nil
"tex" org-html-with-latex
)
128 ;; Leave room for "ox-infojs.el" extension.
129 (:infojs-opt
"INFOJS_OPT" nil nil
)))
133 ;;; Internal Variables
135 (defvar org-html-format-table-no-css
)
136 (defvar htmlize-buffer-places
) ; from htmlize.el
138 (defconst org-html-special-string-regexps
139 '(("\\\\-" .
"­")
140 ("---\\([^-]\\)" .
"—\\1")
141 ("--\\([^-]\\)" .
"–\\1")
142 ("\\.\\.\\." .
"…"))
143 "Regular expressions for special string conversion.")
145 (defconst org-html-scripts
146 "<script type=\"text/javascript\">
148 @licstart The following is the entire license notice for the
149 JavaScript code in this tag.
151 Copyright (C) 2012 Free Software Foundation, Inc.
153 The JavaScript code in this tag is free software: you can
154 redistribute it and/or modify it under the terms of the GNU
155 General Public License (GNU GPL) as published by the Free Software
156 Foundation, either version 3 of the License, or (at your option)
157 any later version. The code is distributed WITHOUT ANY WARRANTY;
158 without even the implied warranty of MERCHANTABILITY or FITNESS
159 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
161 As additional permission under GNU GPL version 3 section 7, you
162 may distribute non-source (e.g., minimized or compacted) forms of
163 that code without the copy of the GNU GPL normally required by
164 section 4, provided you include this license notice and a URL
165 through which recipients can access the Corresponding Source.
168 @licend The above is the entire license notice
169 for the JavaScript code in this tag.
171 <!--/*--><![CDATA[/*><!--*/
172 function CodeHighlightOn(elem, id)
174 var target = document.getElementById(id);
176 elem.cacheClassElem = elem.className;
177 elem.cacheClassTarget = target.className;
178 target.className = \"code-highlighted\";
179 elem.className = \"code-highlighted\";
182 function CodeHighlightOff(elem, id)
184 var target = document.getElementById(id);
185 if(elem.cacheClassElem)
186 elem.className = elem.cacheClassElem;
187 if(elem.cacheClassTarget)
188 target.className = elem.cacheClassTarget;
192 "Basic JavaScript that is needed by HTML files produced by Org mode.")
194 (defconst org-html-style-default
195 "<style type=\"text/css\">
196 <!--/*--><![CDATA[/*><!--*/
197 html { font-family: Times, serif; font-size: 12pt; }
198 .title { text-align: center; }
199 .todo { color: red; }
200 .done { color: green; }
201 .tag { background-color: #add8e6; font-weight:normal }
203 .timestamp { color: #bebebe; }
204 .timestamp-kwd { color: #5f9ea0; }
205 .right {margin-left:auto; margin-right:0px; text-align:right;}
206 .left {margin-left:0px; margin-right:auto; text-align:left;}
207 .center {margin-left:auto; margin-right:auto; text-align:center;}
208 p.verse { margin-left: 3% }
210 border: 1pt solid #AEBDCC;
211 background-color: #F3F5F7;
213 font-family: courier, monospace;
217 table { border-collapse: collapse; }
218 td, th { vertical-align: top; }
219 th.right { text-align:center; }
220 th.left { text-align:center; }
221 th.center { text-align:center; }
222 td.right { text-align:right; }
223 td.left { text-align:left; }
224 td.center { text-align:center; }
225 dt { font-weight: bold; }
226 div.figure { padding: 0.5em; }
227 div.figure p { text-align: center; }
230 border:2px solid gray;
234 textarea { overflow-x: auto; }
235 .linenr { font-size:smaller }
236 .code-highlighted {background-color:#ffff00;}
237 .org-info-js_info-navigation { border-style:none; }
238 #org-info-js_console-label { font-size:10px; font-weight:bold;
239 white-space:nowrap; }
240 .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
244 "The default style specification for exported HTML files.
245 Please use the variables `org-html-style' and
246 `org-html-style-extra' to add to this style. If you wish to not
247 have the default style included, customize the variable
248 `org-html-style-include-default'.")
252 ;;; User Configuration Variables
254 (defgroup org-export-html nil
255 "Options for exporting Org mode files to HTML."
256 :tag
"Org Export HTML"
259 (defgroup org-export-htmlize nil
260 "Options for processing examples with htmlize.el."
261 :tag
"Org Export Htmlize"
262 :group
'org-export-html
)
267 (defcustom org-html-text-markup-alist
268 '((bold .
"<b>%s</b>")
269 (code .
"<code>%s</code>")
270 (italic .
"<i>%s</i>")
271 (strike-through .
"<del>%s</del>")
272 (underline .
"<span style=\"text-decoration:underline;\">%s</span>")
273 (verbatim .
"<code>%s</code>"))
274 "Alist of HTML expressions to convert text markup
276 The key must be a symbol among `bold', `code', `italic',
277 `strike-through', `underline' and `verbatim'. The value is
278 a formatting string to wrap fontified text with.
280 If no association can be found for a given markup, text will be
282 :group
'org-export-html
283 :type
'(alist :key-type
(symbol :tag
"Markup type")
284 :value-type
(string :tag
"Format string"))
285 :options
'(bold code italic strike-through underline verbatim
))
290 (defcustom org-html-pretty-output nil
291 "Enable this to generate pretty HTML."
292 :group
'org-export-html
298 (defcustom org-html-format-drawer-function nil
299 "Function called to format a drawer in HTML code.
301 The function must accept two parameters:
302 NAME the drawer name, like \"LOGBOOK\"
303 CONTENTS the contents of the drawer.
305 The function should return the string to be exported.
307 For example, the variable could be set to the following function
308 in order to mimic default behaviour:
310 \(defun org-html-format-drawer-default \(name contents\)
311 \"Format a drawer element for HTML export.\"
313 :group
'org-export-html
319 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
320 <h2 class=\"footnotes\">%s: </h2>
321 <div id=\"text-footnotes\">
325 "Format for the footnotes section.
326 Should contain a two instances of %s. The first will be replaced with the
327 language-specific word for \"Footnotes\", the second one will be replaced
328 by the footnotes themselves."
329 :group
'org-export-html
332 (defcustom org-html-footnote-format
"<sup>%s</sup>"
333 "The format for the footnote reference.
334 %s will be replaced by the footnote reference itself."
335 :group
'org-export-html
338 (defcustom org-html-footnote-separator
"<sup>, </sup>"
339 "Text used to separate footnotes."
340 :group
'org-export-html
346 (defcustom org-html-toplevel-hlevel
2
347 "The <H> level for level 1 headings in HTML export.
348 This is also important for the classes that will be wrapped around headlines
349 and outline structure. If this variable is 1, the top-level headlines will
350 be <h1>, and the corresponding classes will be outline-1, section-number-1,
351 and outline-text-1. If this is 2, all of these will get a 2 instead.
352 The default for this variable is 2, because we use <h1> for formatting the
354 :group
'org-export-html
357 (defcustom org-html-format-headline-function nil
358 "Function to format headline text.
360 This function will be called with 5 arguments:
361 TODO the todo keyword (string or nil).
362 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
363 PRIORITY the priority of the headline (integer or nil)
364 TEXT the main headline text (string).
365 TAGS the tags (string or nil).
367 The function result will be used in the section format string.
369 As an example, one could set the variable to the following, in
370 order to reproduce the default set-up:
372 \(defun org-html-format-headline \(todo todo-type priority text tags)
373 \"Default format function for an headline.\"
375 \(format \"\\\\textbf{\\\\textsc{\\\\textsf{%s}}} \" todo))
377 \(format \"\\\\framebox{\\\\#%c} \" priority))
379 \(when tags (format \"\\\\hfill{}\\\\textsc{%s}\" tags))))"
380 :group
'org-export-html
386 (defcustom org-html-allow-name-attribute-in-anchors t
387 "When nil, do not set \"name\" attribute in anchors.
388 By default, anchors are formatted with both \"id\" and \"name\"
389 attributes, when appropriate."
390 :group
'org-export-html
396 (defcustom org-html-format-inlinetask-function nil
397 "Function called to format an inlinetask in HTML code.
399 The function must accept six parameters:
400 TODO the todo keyword, as a string
401 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
402 PRIORITY the inlinetask priority, as a string
403 NAME the inlinetask name, as a string.
404 TAGS the inlinetask tags, as a list of strings.
405 CONTENTS the contents of the inlinetask, as a string.
407 The function should return the string to be exported.
409 For example, the variable could be set to the following function
410 in order to mimic default behaviour:
412 \(defun org-html-format-inlinetask \(todo type priority name tags contents\)
413 \"Format an inline task element for HTML export.\"
417 \(format \"\\\\textbf{\\\\textsf{\\\\textsc{%s}}} \" todo))
418 \(when priority (format \"\\\\framebox{\\\\#%c} \" priority))
420 \(when tags (format \"\\\\hfill{}\\\\textsc{%s}\" tags)))))
421 \(format (concat \"\\\\begin{center}\\n\"
423 \"\\\\begin{minipage}[c]{.6\\\\textwidth}\\n\"
425 \"\\\\rule[.8em]{\\\\textwidth}{2pt}\\n\\n\"
427 \"\\\\end{minipage}}\"
429 full-title contents))"
430 :group
'org-export-html
436 (defcustom org-html-with-latex org-export-with-latex
437 "Non-nil means process LaTeX math snippets.
439 When set, the exporter will process LaTeX environments and
442 This option can also be set with the +OPTIONS line,
443 e.g. \"tex:mathjax\". Allowed values are:
445 nil Ignore math snippets.
446 `verbatim' Keep everything in verbatim
447 `dvipng' Process the LaTeX fragments to images. This will also
448 include processing of non-math environments.
449 `imagemagick' Convert the LaTeX fragments to pdf files and use
450 imagemagick to convert pdf files to png files.
451 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
453 t Synonym for `mathjax'."
454 :group
'org-export-html
456 (const :tag
"Do not process math in any way" nil
)
457 (const :tag
"Use dvipng to make images" dvipng
)
458 (const :tag
"Use imagemagick to make images" imagemagick
)
459 (const :tag
"Use MathJax to display math" mathjax
)
460 (const :tag
"Leave math verbatim" verbatim
)))
463 ;;;; Links :: Generic
465 (defcustom org-html-link-org-files-as-html t
466 "Non-nil means make file links to `file.org' point to `file.html'.
467 When org-mode is exporting an org-mode file to HTML, links to
468 non-html files are directly put into a href tag in HTML.
469 However, links to other Org-mode files (recognized by the
470 extension `.org.) should become links to the corresponding html
471 file, assuming that the linked org-mode file will also be
473 When nil, the links still point to the plain `.org' file."
474 :group
'org-export-html
478 ;;;; Links :: Inline images
480 (defcustom org-html-inline-images
'maybe
481 "Non-nil means inline images into exported HTML pages.
482 This is done using an <img> tag. When nil, an anchor with href is used to
483 link to the image. If this option is `maybe', then images in links with
484 an empty description will be inlined, while images with a description will
486 :group
'org-export-html
487 :type
'(choice (const :tag
"Never" nil
)
488 (const :tag
"Always" t
)
489 (const :tag
"When there is no description" maybe
)))
491 (defcustom org-html-inline-image-rules
492 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
493 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
494 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
495 "Rules characterizing image files that can be inlined into HTML.
497 A rule consists in an association whose key is the type of link
498 to consider, and value is a regexp that will be matched against
501 Note that, by default, the image extension *actually* allowed
502 depend on the way the HTML file is processed. When used with
503 pdflatex, pdf, jpg and png images are OK. When processing
504 through dvi to Postscript, only ps and eps are allowed. The
505 default we use here encompasses both."
506 :group
'org-export-html
507 :type
'(alist :key-type
(string :tag
"Type")
508 :value-type
(regexp :tag
"Path")))
513 (defcustom org-html-protect-char-alist
517 "Alist of characters to be converted by `org-html-protect'."
518 :group
'org-export-html
519 :type
'(repeat (cons (string :tag
"Character")
520 (string :tag
"HTML equivalent"))))
525 (defcustom org-export-htmlize-output-type
'inline-css
526 "Output type to be used by htmlize when formatting code snippets.
527 Choices are `css', to export the CSS selectors only, or `inline-css', to
528 export the CSS attribute values inline in the HTML. We use as default
529 `inline-css', in order to make the resulting HTML self-containing.
531 However, this will fail when using Emacs in batch mode for export, because
532 then no rich font definitions are in place. It will also not be good if
533 people with different Emacs setup contribute HTML files to a website,
534 because the fonts will represent the individual setups. In these cases,
535 it is much better to let Org/Htmlize assign classes only, and to use
536 a style file to define the look of these classes.
537 To get a start for your css file, start Emacs session and make sure that
538 all the faces you are interested in are defined, for example by loading files
539 in all modes you want. Then, use the command
540 \\[org-export-htmlize-generate-css] to extract class definitions."
541 :group
'org-export-htmlize
542 :type
'(choice (const css
) (const inline-css
)))
544 (defcustom org-export-htmlize-font-prefix
"org-"
545 "The prefix for CSS class names for htmlize font specifications."
546 :group
'org-export-htmlize
549 (defcustom org-export-htmlized-org-css-url nil
550 "URL pointing to a CSS file defining text colors for htmlized Emacs buffers.
551 Normally when creating an htmlized version of an Org buffer, htmlize will
552 create CSS to define the font colors. However, this does not work when
553 converting in batch mode, and it also can look bad if different people
554 with different fontification setup work on the same website.
555 When this variable is non-nil, creating an htmlized version of an Org buffer
556 using `org-export-as-org' will remove the internal CSS section and replace it
557 with a link to this URL."
558 :group
'org-export-htmlize
560 (const :tag
"Keep internal css" nil
)
561 (string :tag
"URL or local href")))
566 (defcustom org-html-table-tag
567 "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
568 "The HTML tag that is used to start a table.
569 This must be a <table> tag, but you may change the options like
570 borders and spacing."
571 :group
'org-export-html
574 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
575 "The opening tag for table header fields.
576 This is customizable so that alignment options can be specified.
577 The first %s will be filled with the scope of the field, either row or col.
578 The second %s will be replaced by a style entry to align the field.
579 See also the variable `org-html-table-use-header-tags-for-first-column'.
580 See also the variable `org-html-table-align-individual-fields'."
581 :group
'org-export-tables
; FIXME: change group?
582 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
584 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
585 "The opening tag for table data fields.
586 This is customizable so that alignment options can be specified.
587 The first %s will be filled with the scope of the field, either row or col.
588 The second %s will be replaced by a style entry to align the field.
589 See also the variable `org-html-table-align-individual-fields'."
590 :group
'org-export-tables
591 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
593 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
594 "The opening tag for table data fields.
595 This is customizable so that alignment options can be specified.
596 Instead of strings, these can be Lisp forms that will be evaluated
597 for each row in order to construct the table row tags. During evaluation,
598 the variable `head' will be true when this is a header line, nil when this
599 is a body line. And the variable `nline' will contain the line number,
600 starting from 1 in the first header line. For example
602 (setq org-html-table-row-tags
605 (if (= (mod nline 2) 1)
606 \"<tr class=\\\"tr-odd\\\">\"
607 \"<tr class=\\\"tr-even\\\">\"))
610 will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
611 :group
'org-export-tables
613 (choice :tag
"Opening tag"
614 (string :tag
"Specify")
616 (choice :tag
"Closing tag"
617 (string :tag
"Specify")
620 (defcustom org-html-table-align-individual-fields t
621 "Non-nil means attach style attributes for alignment to each table field.
622 When nil, alignment will only be specified in the column tags, but this
623 is ignored by some browsers (like Firefox, Safari). Opera does it right
625 :group
'org-export-tables
628 (defcustom org-html-table-use-header-tags-for-first-column nil
629 "Non-nil means format column one in tables with header tags.
630 When nil, also column one will use data tags."
631 :group
'org-export-tables
634 (defcustom org-html-table-caption-above t
635 "When non-nil, place caption string at the beginning of the table.
636 Otherwise, place it near the end."
637 :group
'org-export-html
643 (defcustom org-html-tag-class-prefix
""
644 "Prefix to class names for TODO keywords.
645 Each tag gets a class given by the tag itself, with this prefix.
646 The default prefix is empty because it is nice to just use the keyword
647 as a class name. But if you get into conflicts with other, existing
648 CSS classes, then this prefix can be very useful."
649 :group
'org-export-html
653 ;;;; Template :: Generic
655 (defcustom org-html-extension
"html"
656 "The extension for exported HTML files."
657 :group
'org-export-html
660 (defcustom org-html-xml-declaration
661 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
662 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
663 "The extension for exported HTML files.
664 %s will be replaced with the charset of the exported file.
665 This may be a string, or an alist with export extensions
666 and corresponding declarations."
667 :group
'org-export-html
669 (string :tag
"Single declaration")
670 (repeat :tag
"Dependent on extension"
671 (cons (string :tag
"Extension")
672 (string :tag
"Declaration")))))
674 (defcustom org-html-coding-system
'utf-8
675 "Coding system for HTML export.
676 Use utf-8 as the default value."
677 :group
'org-export-html
678 :type
'coding-system
)
680 (defcustom org-html-divs
'("preamble" "content" "postamble")
681 "The name of the main divs for HTML export.
682 This is a list of three strings, the first one for the preamble
683 DIV, the second one for the content DIV and the third one for the
685 :group
'org-export-html
687 (string :tag
" Div for the preamble:")
688 (string :tag
" Div for the content:")
689 (string :tag
"Div for the postamble:")))
692 ;;;; Template :: Mathjax
694 (defcustom org-html-mathjax-options
695 '((path "http://orgmode.org/mathjax/MathJax.js")
700 "Options for MathJax setup.
702 path The path where to find MathJax
703 scale Scaling for the HTML-CSS backend, usually between 100 and 133
704 align How to align display math: left, center, or right
705 indent If align is not center, how far from the left/right side?
706 mathml Should a MathML player be used if available?
707 This is faster and reduces bandwidth use, but currently
708 sometimes has lower spacing quality. Therefore, the default is
709 nil. When browsers get better, this switch can be flipped.
711 You can also customize this for each buffer, using something like
713 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
714 :group
'org-export-html
715 :type
'(list :greedy t
716 (list :tag
"path (the path from where to load MathJax.js)"
717 (const :format
" " path
) (string))
718 (list :tag
"scale (scaling for the displayed math)"
719 (const :format
" " scale
) (string))
720 (list :tag
"align (alignment of displayed equations)"
721 (const :format
" " align
) (string))
722 (list :tag
"indent (indentation with left or right alignment)"
723 (const :format
" " indent
) (string))
724 (list :tag
"mathml (should MathML display be used is possible)"
725 (const :format
" " mathml
) (boolean))))
727 (defcustom org-html-mathjax-template
728 "<script type=\"text/javascript\" src=\"%PATH\">
729 <!--/*--><![CDATA[/*><!--*/
731 // Only one of the two following lines, depending on user settings
732 // First allows browser-native MathML display, second forces HTML/CSS
733 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
734 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
735 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
736 \"TeX/noUndefined.js\"],
738 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
739 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
740 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
741 ignoreClass: \"tex2jax_ignore\",
742 processEscapes: false,
743 processEnvironments: true,
746 showProcessingMessages: true,
747 displayAlign: \"%ALIGN\",
748 displayIndent: \"%INDENT\",
752 availableFonts: [\"STIX\",\"TeX\"],
753 preferredFont: \"TeX\",
769 "The MathJax setup for XHTML files."
770 :group
'org-export-html
774 ;;;; Template :: Postamble
776 (defcustom org-html-postamble
'auto
777 "Non-nil means insert a postamble in HTML export.
779 When `t', insert a string as defined by the formatting string in
780 `org-html-postamble-format'. When set to a string, this
781 string overrides `org-html-postamble-format'. When set to
782 'auto, discard `org-html-postamble-format' and honor
783 `org-export-author/email/creator-info' variables. When set to a
784 function, apply this function and insert the returned string.
785 The function takes the property list of export options as its
788 Setting :html-postamble in publishing projects will take
789 precedence over this variable."
790 :group
'org-export-html
791 :type
'(choice (const :tag
"No postamble" nil
)
792 (const :tag
"Auto preamble" 'auto
)
793 (const :tag
"Default formatting string" t
)
794 (string :tag
"Custom formatting string")
795 (function :tag
"Function (must return a string)")))
797 (defcustom org-html-postamble-format
798 '(("en" "<p class=\"author\">Author: %a (%e)</p>
799 <p class=\"date\">Date: %d</p>
800 <p class=\"creator\">Generated by %c</p>
801 <p class=\"xhtml-validation\">%v</p>"))
802 "Alist of languages and format strings for the HTML postamble.
804 The first element of each list is the language code, as used for
805 the #+LANGUAGE keyword.
807 The second element of each list is a format string to format the
808 postamble itself. This format string can contain these elements:
810 %a stands for the author's name.
811 %e stands for the author's email.
812 %d stands for the date.
813 %c will be replaced by information about Org/Emacs versions.
814 %v will be replaced by `org-html-validation-link'.
816 If you need to use a \"%\" character, you need to escape it
818 :group
'org-export-html
819 :type
'(alist :key-type
(string :tag
"Language")
820 :value-type
(string :tag
"Format string")))
822 (defcustom org-html-validation-link
823 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
824 "Link to HTML validation service."
825 :group
'org-export-html
828 (defcustom org-html-creator-string
829 (format "Generated by <a href=\"http://orgmode.org\">Org</a> mode %s in <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s."
830 (if (fboundp 'org-version
) (org-version) "(Unknown)")
832 "String to insert at the end of the HTML document."
833 :group
'org-export-html
834 :type
'(string :tag
"Creator string"))
837 ;;;; Template :: Preamble
839 (defcustom org-html-preamble t
840 "Non-nil means insert a preamble in HTML export.
842 When `t', insert a string as defined by one of the formatting
843 strings in `org-html-preamble-format'. When set to a
844 string, this string overrides `org-html-preamble-format'.
845 When set to a function, apply this function and insert the
846 returned string. The function takes the property list of export
847 options as its only argument.
849 Setting :html-preamble in publishing projects will take
850 precedence over this variable."
851 :group
'org-export-html
852 :type
'(choice (const :tag
"No preamble" nil
)
853 (const :tag
"Default preamble" t
)
854 (string :tag
"Custom formatting string")
855 (function :tag
"Function (must return a string)")))
857 (defcustom org-html-preamble-format
'(("en" ""))
858 "Alist of languages and format strings for the HTML preamble.
860 The first element of each list is the language code, as used for
861 the #+LANGUAGE keyword.
863 The second element of each list is a format string to format the
864 preamble itself. This format string can contain these elements:
866 %t stands for the title.
867 %a stands for the author's name.
868 %e stands for the author's email.
869 %d stands for the date.
871 If you need to use a \"%\" character, you need to escape it
873 :group
'org-export-html
874 :type
'(alist :key-type
(string :tag
"Language")
875 :value-type
(string :tag
"Format string")))
877 (defcustom org-html-link-up
""
878 "Where should the \"UP\" link of exported HTML pages lead?"
879 :group
'org-export-html
880 :type
'(string :tag
"File or URL"))
882 (defcustom org-html-link-home
""
883 "Where should the \"HOME\" link of exported HTML pages lead?"
884 :group
'org-export-html
885 :type
'(string :tag
"File or URL"))
887 (defcustom org-html-home
/up-format
888 "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
889 <a accesskey=\"h\" href=\"%s\"> UP </a>
891 <a accesskey=\"H\" href=\"%s\"> HOME </a>
893 "Snippet used to insert the HOME and UP links.
894 This is a format string, the first %s will receive the UP link,
895 the second the HOME link. If both `org-html-link-up' and
896 `org-html-link-home' are empty, the entire snippet will be
898 :group
'org-export-html
902 ;;;; Template :: Scripts
904 (defcustom org-html-style-include-scripts t
905 "Non-nil means include the JavaScript snippets in exported HTML files.
906 The actual script is defined in `org-html-scripts' and should
908 :group
'org-export-html
912 ;;;; Template :: Styles
914 (defcustom org-html-style-include-default t
915 "Non-nil means include the default style in exported HTML files.
916 The actual style is defined in `org-html-style-default' and should
917 not be modified. Use the variables `org-html-style' to add
918 your own style information."
919 :group
'org-export-html
922 (put 'org-html-style-include-default
'safe-local-variable
'booleanp
)
924 (defcustom org-html-style
""
925 "Org-wide style definitions for exported HTML files.
927 This variable needs to contain the full HTML structure to provide a style,
928 including the surrounding HTML tags. If you set the value of this variable,
929 you should consider to include definitions for the following classes:
930 title, todo, done, timestamp, timestamp-kwd, tag, target.
932 For example, a valid value would be:
934 <style type=\"text/css\">
936 p { font-weight: normal; color: gray; }
938 .title { text-align: center; }
939 .todo, .timestamp-kwd { color: red; }
940 .done { color: green; }
944 If you'd like to refer to an external style file, use something like
946 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
948 As the value of this option simply gets inserted into the HTML <head> header,
949 you can \"misuse\" it to add arbitrary text to the header.
950 See also the variable `org-html-style-extra'."
951 :group
'org-export-html
954 (put 'org-html-style
'safe-local-variable
'stringp
)
956 (defcustom org-html-style-extra
""
957 "Additional style information for HTML export.
958 The value of this variable is inserted into the HTML buffer right after
959 the value of `org-html-style'. Use this variable for per-file
960 settings of style information, and do not forget to surround the style
961 settings with <style>...</style> tags."
962 :group
'org-export-html
965 (put 'org-html-style-extra
'safe-local-variable
'stringp
)
970 (defcustom org-html-todo-kwd-class-prefix
""
971 "Prefix to class names for TODO keywords.
972 Each TODO keyword gets a class given by the keyword itself, with this prefix.
973 The default prefix is empty because it is nice to just use the keyword
974 as a class name. But if you get into conflicts with other, existing
975 CSS classes, then this prefix can be very useful."
976 :group
'org-export-html
979 (defcustom org-html-display-buffer-mode
'html-mode
980 "Default mode when visiting the HTML output."
981 :group
'org-export-html
983 :type
'(choice (function 'html-mode
)
984 (function 'nxml-mode
)
985 (function :tag
"Other mode")))
989 ;;; Internal Functions
991 (defun org-html-format-inline-image (src &optional
992 caption label attr standalone-p
)
993 (let* ((id (if (not label
) ""
994 (format " id=\"%s\"" (org-export-solidify-link-text label
))))
997 ((string-match "\\<alt=" (or attr
"")) "")
998 ((string-match "^ltxpng/" src
)
999 (format " alt=\"%s\""
1000 (org-html-encode-plain-text
1001 (org-find-text-property-in-string
1002 'org-latex-src src
))))
1003 (t (format " alt=\"%s\""
1004 (file-name-nondirectory src
)))))))
1007 (let ((img (format "<img src=\"%s\" %s/>" src attr
)))
1008 (format "\n<div%s class=\"figure\">%s%s\n</div>"
1009 id
(format "\n<p>%s</p>" img
)
1010 (when caption
(format "\n<p>%s</p>" caption
)))))
1011 (t (format "<img src=\"%s\" %s/>" src
(concat attr id
))))))
1013 (defun org-html--textarea-block (element)
1014 "Transcode ELEMENT into a textarea block.
1015 ELEMENT is either a src block or an example block."
1016 (let ((code (car (org-export-unravel-code element
)))
1017 (attr (org-export-read-attribute :attr_html element
)))
1018 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>"
1019 (or (plist-get attr
:width
) 80)
1020 (or (plist-get attr
:height
) (org-count-lines code
))
1026 (defun org-html-bibliography ()
1027 "Find bibliography, cut it out and return it."
1029 (let (beg end
(cnt 1) bib
)
1031 (goto-char (point-min))
1032 (when (re-search-forward
1033 "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t
)
1034 (setq beg
(match-beginning 0))
1035 (while (re-search-forward "</?div\\>" nil t
)
1036 (setq cnt
(+ cnt
(if (string= (match-string 0) "<div") +1 -
1)))
1038 (and (looking-at ">") (forward-char 1))
1039 (setq bib
(buffer-substring beg
(point)))
1040 (delete-region beg
(point))
1041 (throw 'exit bib
))))
1046 (defun org-html-splice-attributes (tag attributes
)
1047 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
1048 (if (not attributes
)
1050 (let (oldatt newatt
)
1051 (setq oldatt
(org-extract-attributes-from-string tag
)
1053 newatt
(cdr (org-extract-attributes-from-string attributes
)))
1055 (setq oldatt
(plist-put oldatt
(pop newatt
) (pop newatt
))))
1056 (if (string-match ">" tag
)
1058 (replace-match (concat (org-attributes-to-string oldatt
) ">")
1062 (defun org-export-splice-style (style extra
)
1063 "Splice EXTRA into STYLE, just before \"</style>\"."
1064 (if (and (stringp extra
)
1065 (string-match "\\S-" extra
)
1066 (string-match "</style>" style
))
1067 (concat (substring style
0 (match-beginning 0))
1069 (substring style
(match-beginning 0)))
1072 (defun org-export-htmlize-region-for-paste (beg end
)
1073 "Convert the region to HTML, using htmlize.el.
1074 This is much like `htmlize-region-for-paste', only that it uses
1075 the settings define in the org-... variables."
1076 (let* ((htmlize-output-type org-export-htmlize-output-type
)
1077 (htmlize-css-name-prefix org-export-htmlize-font-prefix
)
1078 (htmlbuf (htmlize-region beg end
)))
1080 (with-current-buffer htmlbuf
1081 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1082 (plist-get htmlize-buffer-places
'content-end
)))
1083 (kill-buffer htmlbuf
))))
1086 (defun org-export-htmlize-generate-css ()
1087 "Create the CSS for all font definitions in the current Emacs session.
1088 Use this to create face definitions in your CSS style file that can then
1089 be used by code snippets transformed by htmlize.
1090 This command just produces a buffer that contains class definitions for all
1091 faces used in the current Emacs session. You can copy and paste the ones you
1092 need into your CSS file.
1094 If you then set `org-export-htmlize-output-type' to `css', calls
1095 to the function `org-export-htmlize-region-for-paste' will
1096 produce code that uses these same face definitions."
1099 (and (get-buffer "*html*") (kill-buffer "*html*"))
1101 (let ((fl (face-list))
1102 (htmlize-css-name-prefix "org-")
1103 (htmlize-output-type 'css
)
1105 (while (setq f
(pop fl
)
1106 i
(and f
(face-attribute f
:inherit
)))
1107 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1108 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1109 (htmlize-region (point-min) (point-max))))
1110 (org-pop-to-buffer-same-window "*html*")
1111 (goto-char (point-min))
1112 (if (re-search-forward "<style" nil t
)
1113 (delete-region (point-min) (match-beginning 0)))
1114 (if (re-search-forward "</style>" nil t
)
1115 (delete-region (1+ (match-end 0)) (point-max)))
1116 (beginning-of-line 1)
1117 (if (looking-at " +") (replace-match ""))
1118 (goto-char (point-min)))
1120 (defun org-html--make-string (n string
)
1121 "Build a string by concatenating N times STRING."
1122 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1124 (defun org-html-toc-text (toc-entries)
1125 (let* ((prev-level (1- (nth 1 (car toc-entries
))))
1126 (start-level prev-level
))
1130 (let ((headline (nth 0 entry
))
1131 (level (nth 1 entry
)))
1133 (let* ((cnt (- level prev-level
))
1134 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1136 (setq prev-level level
)
1138 (org-html--make-string
1139 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1140 ((< cnt
0) "</li>\n</ul>\n")))
1141 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1144 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
1146 (defun* org-html-format-toc-headline
1147 (todo todo-type priority text tags
1148 &key level section-number headline-label
&allow-other-keys
)
1149 (let ((headline (concat
1150 section-number
(and section-number
". ")
1152 (and tags
" ") (org-html--tags tags
))))
1153 (format "<a href=\"#%s\">%s</a>"
1154 (org-export-solidify-link-text headline-label
)
1155 (if (not nil
) headline
1156 (format "<span class=\"%s\">%s</span>" todo-type headline
)))))
1158 (defun org-html-toc (depth info
)
1159 (let* ((headlines (org-export-collect-headlines info depth
))
1161 (loop for headline in headlines collect
1162 (list (org-html-format-headline--wrap
1163 headline info
'org-html-format-toc-headline
)
1164 (org-export-get-relative-level headline info
)))))
1167 "<div id=\"table-of-contents\">\n"
1168 (format "<h%d>%s</h%d>\n"
1169 org-html-toplevel-hlevel
1170 (org-html--translate "Table of Contents" info
)
1171 org-html-toplevel-hlevel
)
1172 "<div id=\"text-table-of-contents\">"
1173 (org-html-toc-text toc-entries
)
1177 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1178 "Turn todo keyword into a valid class name.
1179 Replaces invalid characters with \"_\"."
1181 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1182 (setq kwd
(replace-match "_" t t kwd
))))
1185 (defun org-html-format-footnote-reference (n def refcnt
)
1186 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1187 (format org-html-footnote-format
1188 (let* ((id (format "fnr.%s%s" n extra
))
1189 (href (format " href=\"#fn.%s\"" n
))
1190 (attributes (concat " class=\"footref\"" href
)))
1191 (org-html--anchor id n attributes
)))))
1193 (defun org-html-format-footnotes-section (section-name definitions
)
1194 (if (not definitions
) ""
1195 (format org-html-footnotes-section section-name definitions
)))
1197 (defun org-html-format-footnote-definition (fn)
1198 (let ((n (car fn
)) (def (cdr fn
)))
1200 "<tr>\n<td>%s</td>\n<td>%s</td>\n</tr>\n"
1201 (format org-html-footnote-format
1202 (let* ((id (format "fn.%s" n
))
1203 (href (format " href=\"#fnr.%s\"" n
))
1204 (attributes (concat " class=\"footnum\"" href
)))
1205 (org-html--anchor id n attributes
)))
1208 (defun org-html-footnote-section (info)
1209 (let* ((fn-alist (org-export-collect-footnote-definitions
1210 (plist-get info
:parse-tree
) info
))
1213 (loop for
(n type raw
) in fn-alist collect
1214 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1215 (org-trim (org-export-data raw info
))
1217 (org-trim (org-export-data raw info
))))))))
1219 (org-html-format-footnotes-section
1220 (org-html--translate "Footnotes" info
)
1222 "<table>\n%s\n</table>\n"
1223 (mapconcat 'org-html-format-footnote-definition fn-alist
"\n"))))))
1229 (defun org-html--build-meta-info (info)
1230 "Return meta tags for exported document.
1231 INFO is a plist used as a communication channel."
1232 (let* ((title (org-export-data (plist-get info
:title
) info
))
1233 (author (and (plist-get info
:with-author
)
1234 (let ((auth (plist-get info
:author
)))
1235 (and auth
(org-export-data auth info
)))))
1236 (date (and (plist-get info
:with-date
)
1237 (let ((date (plist-get info
:date
)))
1238 (and date
(org-export-data date info
)))))
1239 (description (plist-get info
:description
))
1240 (keywords (plist-get info
:keywords
)))
1242 (format "<title>%s</title>\n" title
)
1244 "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>"
1245 (or (and org-html-coding-system
1246 (fboundp 'coding-system-get
)
1247 (coding-system-get org-html-coding-system
'mime-charset
))
1249 (format "<meta name=\"title\" content=\"%s\"/>\n" title
)
1250 (format "<meta name=\"generator\" content=\"Org-mode\"/>\n")
1251 (and date
(format "<meta name=\"generated\" content=\"%s\"/>\n" date
))
1252 (and author
(format "<meta name=\"author\" content=\"%s\"/>\n" author
))
1254 (format "<meta name=\"description\" content=\"%s\"/>\n" description
))
1256 (format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords
)))))
1258 (defun org-html--build-style (info)
1259 "Return style information for exported document.
1260 INFO is a plist used as a communication channel."
1261 (org-element-normalize-string
1263 (when (plist-get info
:html-style-include-default
) org-html-style-default
)
1264 (org-element-normalize-string (plist-get info
:html-style
))
1265 (org-element-normalize-string (plist-get info
:html-style-extra
))
1266 (when (plist-get info
:html-style-include-scripts
) org-html-scripts
))))
1268 (defun org-html--build-mathjax-config (info)
1269 "Insert the user setup into the mathjax template.
1270 INFO is a plist used as a communication channel."
1271 (when (memq (plist-get info
:with-latex
) '(mathjax t
))
1272 (let ((template org-html-mathjax-template
)
1273 (options org-html-mathjax-options
)
1274 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1275 name val
(yes " ") (no "// ") x
)
1278 (setq name
(car e
) val
(nth 1 e
))
1279 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1280 (setq val
(car (read-from-string
1281 (substring in-buffer
(match-end 0))))))
1282 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1283 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1284 (setq template
(replace-match val t t template
))))
1286 (setq val
(nth 1 (assq 'mathml options
)))
1287 (if (string-match (concat "\\<mathml:") in-buffer
)
1288 (setq val
(car (read-from-string
1289 (substring in-buffer
(match-end 0))))))
1290 ;; Exchange prefixes depending on mathml setting.
1291 (if (not val
) (setq x yes yes no no x
))
1292 ;; Replace cookies to turn on or off the config/jax lines.
1293 (if (string-match ":MMLYES:" template
)
1294 (setq template
(replace-match yes t t template
)))
1295 (if (string-match ":MMLNO:" template
)
1296 (setq template
(replace-match no t t template
)))
1297 ;; Return the modified template.
1298 (org-element-normalize-string template
))))
1300 (defun org-html--build-preamble (info)
1301 "Return document preamble as a string, or nil.
1302 INFO is a plist used as a communication channel."
1303 (let ((preamble (plist-get info
:html-preamble
)))
1305 (let ((preamble-contents
1306 (if (functionp preamble
) (funcall preamble info
)
1307 (let ((title (org-export-data (plist-get info
:title
) info
))
1308 (date (if (not (plist-get info
:with-date
)) ""
1309 (org-export-data (plist-get info
:date
) info
)))
1310 (author (if (not (plist-get info
:with-author
)) ""
1311 (org-export-data (plist-get info
:author
) info
)))
1312 (email (if (not (plist-get info
:with-email
)) ""
1313 (plist-get info
:email
))))
1314 (if (stringp preamble
)
1315 (format-spec preamble
1316 `((?t .
,title
) (?a .
,author
)
1317 (?d .
,date
) (?e .
,email
)))
1319 (or (cadr (assoc (plist-get info
:language
)
1320 org-html-preamble-format
))
1321 (cadr (assoc "en" org-html-preamble-format
)))
1322 `((?t .
,title
) (?a .
,author
)
1323 (?d .
,date
) (?e .
,email
))))))))
1324 (when (org-string-nw-p preamble-contents
)
1325 (concat (format "<div id=\"%s\">\n" (nth 0 org-html-divs
))
1326 (org-element-normalize-string preamble-contents
)
1329 (defun org-html--build-postamble (info)
1330 "Return document postamble as a string, or nil.
1331 INFO is a plist used as a communication channel."
1332 (let ((postamble (plist-get info
:html-postamble
)))
1334 (let ((postamble-contents
1335 (if (functionp postamble
) (funcall postamble info
)
1336 (let ((date (if (not (plist-get info
:with-date
)) ""
1337 (org-export-data (plist-get info
:date
) info
)))
1338 (author (let ((author (plist-get info
:author
)))
1339 (and author
(org-export-data author info
))))
1342 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1343 (split-string (plist-get info
:email
) ",+ *")
1345 (html-validation-link (or org-html-validation-link
""))
1346 (creator-info (plist-get info
:creator
)))
1347 (cond ((stringp postamble
)
1348 (format-spec postamble
1349 `((?a .
,author
) (?e .
,email
)
1350 (?d .
,date
) (?c .
,creator-info
)
1351 (?v .
,html-validation-link
))))
1352 ((eq postamble
'auto
)
1354 (when (plist-get info
:time-stamp-file
)
1355 (format "<p class=\"date\">%s: %s</p>\n"
1356 (org-html--translate "Date" info
)
1358 (when (and (plist-get info
:with-author
) author
)
1359 (format "<p class=\"author\">%s : %s</p>\n"
1360 (org-html--translate "Author" info
)
1362 (when (and (plist-get info
:with-email
) email
)
1363 (format "<p class=\"email\">%s </p>\n" email
))
1364 (when (plist-get info
:with-creator
)
1365 (format "<p class=\"creator\">%s</p>\n"
1367 html-validation-link
"\n"))
1369 (or (cadr (assoc (plist-get info
:language
)
1370 org-html-postamble-format
))
1371 (cadr (assoc "en" org-html-postamble-format
)))
1372 `((?a .
,author
) (?e .
,email
)
1373 (?d .
,date
) (?c .
,creator-info
)
1374 (?v .
,html-validation-link
)))))))))
1375 (when (org-string-nw-p postamble-contents
)
1377 (format "<div id=\"%s\">\n" (nth 2 org-html-divs
))
1378 (org-element-normalize-string postamble-contents
)
1381 (defun org-html-inner-template (contents info
)
1382 "Return body of document string after HTML conversion.
1383 CONTENTS is the transcoded contents string. INFO is a plist
1384 holding export options."
1386 (format "<div id=\"%s\">\n" (nth 1 org-html-divs
))
1388 (format "<h1 class=\"title\">%s</h1>\n"
1389 (org-export-data (plist-get info
:title
) info
))
1390 ;; Table of contents.
1391 (let ((depth (plist-get info
:with-toc
)))
1392 (when depth
(org-html-toc depth info
)))
1393 ;; Document contents.
1395 ;; Footnotes section.
1396 (org-html-footnote-section info
)
1398 (org-html-bibliography)
1401 (defun org-html-template (contents info
)
1402 "Return complete document string after HTML conversion.
1403 CONTENTS is the transcoded contents string. INFO is a plist
1404 holding export options."
1407 (or (and (stringp org-html-xml-declaration
)
1408 org-html-xml-declaration
)
1409 (cdr (assoc (plist-get info
:html-extension
)
1410 org-html-xml-declaration
))
1411 (cdr (assoc "html" org-html-xml-declaration
))
1414 (or (and org-html-coding-system
1415 (fboundp 'coding-system-get
)
1416 (coding-system-get org-html-coding-system
'mime-charset
))
1419 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
1420 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
1421 (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n"
1422 (plist-get info
:language
) (plist-get info
:language
))
1424 (org-html--build-meta-info info
)
1425 (org-html--build-style info
)
1426 (org-html--build-mathjax-config info
)
1429 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1430 (link-home (org-trim (plist-get info
:html-link-home
))))
1431 (unless (and (string= link-up
"") (string= link-up
""))
1432 (format org-html-home
/up-format
1433 (or link-up link-home
)
1434 (or link-home link-up
))))
1436 (org-html--build-preamble info
)
1437 ;; Document contents.
1440 (org-html--build-postamble info
)
1441 ;; Closing document.
1442 "</body>\n</html>"))
1444 (defun org-html--translate (s info
)
1445 "Translate string S according to specified language.
1446 INFO is a plist used as a communication channel."
1447 (org-export-translate s
:html info
))
1451 (defun org-html--anchor (&optional id desc attributes
)
1452 (let* ((name (and org-html-allow-name-attribute-in-anchors id
))
1453 (attributes (concat (and id
(format " id=\"%s\"" id
))
1454 (and name
(format " name=\"%s\"" name
))
1456 (format "<a%s>%s</a>" attributes
(or desc
""))))
1460 (defun org-html--todo (todo)
1462 (format "<span class=\"%s %s%s\">%s</span>"
1463 (if (member todo org-done-keywords
) "done" "todo")
1464 org-html-todo-kwd-class-prefix
(org-html-fix-class-name todo
)
1469 (defun org-html--tags (tags)
1471 (format "<span class=\"tag\">%s</span>"
1474 (format "<span class=\"%s\">%s</span>"
1475 (concat org-html-tag-class-prefix
1476 (org-html-fix-class-name tag
))
1482 (defun* org-html-format-headline
1483 (todo todo-type priority text tags
1484 &key level section-number headline-label
&allow-other-keys
)
1485 (let ((section-number
1486 (when section-number
1487 (format "<span class=\"section-number-%d\">%s</span> "
1488 level section-number
)))
1489 (todo (org-html--todo todo
))
1490 (tags (org-html--tags tags
)))
1491 (concat section-number todo
(and todo
" ") text
1492 (and tags
" ") tags
)))
1496 (defun org-html-fontify-code (code lang
)
1497 "Color CODE with htmlize library.
1498 CODE is a string representing the source code to colorize. LANG
1499 is the language used for CODE, as a string, or nil."
1502 ;; Case 1: No lang. Possibly an example block.
1504 ;; Simple transcoding.
1505 (org-html-encode-plain-text code
))
1506 ;; Case 2: No htmlize or an inferior version of htmlize
1507 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1509 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1510 ;; Simple transcoding.
1511 (org-html-encode-plain-text code
))
1514 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1515 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1517 ;; Case 1: Language is not associated with any Emacs mode
1518 ((not (functionp lang-mode
))
1519 ;; Simple transcoding.
1520 (org-html-encode-plain-text code
))
1521 ;; Case 2: Default. Fontify code.
1524 (setq code
(with-temp-buffer
1525 ;; Switch to language-specific mode.
1529 (font-lock-fontify-buffer)
1530 ;; Remove formatting on newline characters.
1532 (let ((beg (point-min))
1535 (while (progn (end-of-line) (< (point) end
))
1536 (put-text-property (point) (1+ (point)) 'face nil
)
1539 (set-buffer-modified-p nil
)
1541 (org-export-htmlize-region-for-paste
1542 (point-min) (point-max))))
1543 ;; Strip any encolosing <pre></pre> tags.
1544 (if (string-match "<pre[^>]*>\n*\\([^\000]*\\)</pre>" code
)
1545 (match-string 1 code
)
1548 (defun org-html-do-format-code
1549 (code &optional lang refs retain-labels num-start
)
1550 "Format CODE string as source code.
1551 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1552 respectively, the language of the source code, as a string, an
1553 alist between line numbers and references (as returned by
1554 `org-export-unravel-code'), a boolean specifying if labels should
1555 appear in the source code, and the number associated to the first
1557 (let* ((code-lines (org-split-string code
"\n"))
1558 (code-length (length code-lines
))
1562 (length (number-to-string (+ code-length num-start
))))))
1563 (code (org-html-fontify-code code lang
)))
1564 (org-export-format-code
1566 (lambda (loc line-num ref
)
1569 ;; Add line number, if needed.
1571 (format "<span class=\"linenr\">%s</span>"
1572 (format num-fmt line-num
)))
1573 ;; Transcoded src line.
1575 ;; Add label, if needed.
1576 (when (and ref retain-labels
) (format " (%s)" ref
))))
1577 ;; Mark transcoded line as an anchor, if needed.
1579 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1583 (defun org-html-format-code (element info
)
1584 "Format contents of ELEMENT as source code.
1585 ELEMENT is either an example block or a src block. INFO is
1586 a plist used as a communication channel."
1587 (let* ((lang (org-element-property :language element
))
1588 ;; Extract code and references.
1589 (code-info (org-export-unravel-code element
))
1590 (code (car code-info
))
1591 (refs (cdr code-info
))
1592 ;; Does the src block contain labels?
1593 (retain-labels (org-element-property :retain-labels element
))
1594 ;; Does it have line numbers?
1595 (num-start (case (org-element-property :number-lines element
)
1596 (continued (org-export-get-loc element info
))
1598 (org-html-do-format-code code lang refs retain-labels num-start
)))
1602 ;;; Transcode Functions
1606 (defun org-html-bold (bold contents info
)
1607 "Transcode BOLD from Org to HTML.
1608 CONTENTS is the text with bold markup. INFO is a plist holding
1609 contextual information."
1610 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
1616 (defun org-html-center-block (center-block contents info
)
1617 "Transcode a CENTER-BLOCK element from Org to HTML.
1618 CONTENTS holds the contents of the block. INFO is a plist
1619 holding contextual information."
1620 (format "<div style=\"text-align: center\">\n%s</div>" contents
))
1625 (defun org-html-clock (clock contents info
)
1626 "Transcode a CLOCK element from Org to HTML.
1627 CONTENTS is nil. INFO is a plist used as a communication
1630 <span class=\"timestamp-wrapper\">
1631 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
1636 (org-element-property :raw-value
1637 (org-element-property :value clock
)))
1638 (let ((time (org-element-property :duration clock
)))
1639 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
1644 (defun org-html-code (code contents info
)
1645 "Transcode CODE from Org to HTML.
1646 CONTENTS is nil. INFO is a plist holding contextual
1648 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
1649 (org-element-property :value code
)))
1654 (defun org-html-drawer (drawer contents info
)
1655 "Transcode a DRAWER element from Org to HTML.
1656 CONTENTS holds the contents of the block. INFO is a plist
1657 holding contextual information."
1658 (if (functionp org-html-format-drawer-function
)
1659 (funcall org-html-format-drawer-function
1660 (org-element-property :drawer-name drawer
)
1662 ;; If there's no user defined function: simply
1663 ;; display contents of the drawer.
1669 (defun org-html-dynamic-block (dynamic-block contents info
)
1670 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
1671 CONTENTS holds the contents of the block. INFO is a plist
1672 holding contextual information. See `org-export-data'."
1678 (defun org-html-entity (entity contents info
)
1679 "Transcode an ENTITY object from Org to HTML.
1680 CONTENTS are the definition itself. INFO is a plist holding
1681 contextual information."
1682 (org-element-property :html entity
))
1687 (defun org-html-example-block (example-block contents info
)
1688 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
1689 CONTENTS is nil. INFO is a plist holding contextual
1691 (if (org-export-read-attribute :attr_html example-block
:textarea
)
1692 (org-html--textarea-block example-block
)
1693 (format "<pre class=\"example\">\n%s</pre>"
1694 (org-html-format-code example-block info
))))
1699 (defun org-html-export-snippet (export-snippet contents info
)
1700 "Transcode a EXPORT-SNIPPET object from Org to HTML.
1701 CONTENTS is nil. INFO is a plist holding contextual
1703 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
1704 (org-element-property :value export-snippet
)))
1709 (defun org-html-export-block (export-block contents info
)
1710 "Transcode a EXPORT-BLOCK element from Org to HTML.
1711 CONTENTS is nil. INFO is a plist holding contextual information."
1712 (when (string= (org-element-property :type export-block
) "HTML")
1713 (org-remove-indentation (org-element-property :value export-block
))))
1718 (defun org-html-fixed-width (fixed-width contents info
)
1719 "Transcode a FIXED-WIDTH element from Org to HTML.
1720 CONTENTS is nil. INFO is a plist holding contextual information."
1721 (format "<pre class=\"example\">\n%s</pre>"
1722 (org-html-do-format-code
1723 (org-remove-indentation
1724 (org-element-property :value fixed-width
)))))
1727 ;;;; Footnote Reference
1729 (defun org-html-footnote-reference (footnote-reference contents info
)
1730 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
1731 CONTENTS is nil. INFO is a plist holding contextual information."
1733 ;; Insert separator between two footnotes in a row.
1734 (let ((prev (org-export-get-previous-element footnote-reference info
)))
1735 (when (eq (org-element-type prev
) 'footnote-reference
)
1736 org-html-footnote-separator
))
1738 ((not (org-export-footnote-first-reference-p footnote-reference info
))
1739 (org-html-format-footnote-reference
1740 (org-export-get-footnote-number footnote-reference info
)
1742 ;; Inline definitions are secondary strings.
1743 ((eq (org-element-property :type footnote-reference
) 'inline
)
1744 (org-html-format-footnote-reference
1745 (org-export-get-footnote-number footnote-reference info
)
1747 ;; Non-inline footnotes definitions are full Org data.
1748 (t (org-html-format-footnote-reference
1749 (org-export-get-footnote-number footnote-reference info
)
1755 (defun org-html-format-headline--wrap (headline info
1756 &optional format-function
1758 "Transcode an HEADLINE element from Org to HTML.
1759 CONTENTS holds the contents of the headline. INFO is a plist
1760 holding contextual information."
1761 (let* ((level (+ (org-export-get-relative-level headline info
)
1762 (1- org-html-toplevel-hlevel
)))
1763 (headline-number (org-export-get-headline-number headline info
))
1764 (section-number (and (not (org-export-low-level-p headline info
))
1765 (org-export-numbered-headline-p headline info
)
1766 (mapconcat 'number-to-string
1767 headline-number
".")))
1768 (todo (and (plist-get info
:with-todo-keywords
)
1769 (let ((todo (org-element-property :todo-keyword headline
)))
1770 (and todo
(org-export-data todo info
)))))
1771 (todo-type (and todo
(org-element-property :todo-type headline
)))
1772 (priority (and (plist-get info
:with-priority
)
1773 (org-element-property :priority headline
)))
1774 (text (org-export-data (org-element-property :title headline
) info
))
1775 (tags (and (plist-get info
:with-tags
)
1776 (org-export-get-tags headline info
)))
1777 (headline-label (or (org-element-property :custom-id headline
)
1778 (concat "sec-" (mapconcat 'number-to-string
1779 headline-number
"-"))))
1780 (format-function (cond
1781 ((functionp format-function
) format-function
)
1782 ((functionp org-html-format-headline-function
)
1784 (lambda (todo todo-type priority text tags
1786 (funcall org-html-format-headline-function
1787 todo todo-type priority text tags
))))
1788 (t 'org-html-format-headline
))))
1789 (apply format-function
1790 todo todo-type priority text tags
1791 :headline-label headline-label
:level level
1792 :section-number section-number extra-keys
)))
1794 (defun org-html-headline (headline contents info
)
1795 "Transcode an HEADLINE element from Org to HTML.
1796 CONTENTS holds the contents of the headline. INFO is a plist
1797 holding contextual information."
1799 (setq contents
(or contents
""))
1800 (let* ((numberedp (org-export-numbered-headline-p headline info
))
1801 (level (org-export-get-relative-level headline info
))
1802 (text (org-export-data (org-element-property :title headline
) info
))
1803 (todo (and (plist-get info
:with-todo-keywords
)
1804 (let ((todo (org-element-property :todo-keyword headline
)))
1805 (and todo
(org-export-data todo info
)))))
1806 (todo-type (and todo
(org-element-property :todo-type headline
)))
1807 (tags (and (plist-get info
:with-tags
)
1808 (org-export-get-tags headline info
)))
1809 (priority (and (plist-get info
:with-priority
)
1810 (org-element-property :priority headline
)))
1811 (section-number (and (org-export-numbered-headline-p headline info
)
1812 (mapconcat 'number-to-string
1813 (org-export-get-headline-number
1814 headline info
) ".")))
1815 ;; Create the headline text.
1816 (full-text (org-html-format-headline--wrap headline info
)))
1818 ;; Case 1: This is a footnote section: ignore it.
1819 ((org-element-property :footnote-section-p headline
) nil
)
1820 ;; Case 2. This is a deep sub-tree: export it as a list item.
1821 ;; Also export as items headlines for which no section
1822 ;; format has been found.
1823 ((org-export-low-level-p headline info
)
1824 ;; Build the real contents of the sub-tree.
1825 (let* ((type (if numberedp
'ordered
'unordered
))
1826 (itemized-body (org-html-format-list-item
1827 contents type nil nil full-text
)))
1829 (and (org-export-first-sibling-p headline info
)
1830 (org-html-begin-plain-list type
))
1832 (and (org-export-last-sibling-p headline info
)
1833 (org-html-end-plain-list type
)))))
1834 ;; Case 3. Standard headline. Export it as a section.
1836 (let* ((section-number (mapconcat 'number-to-string
1837 (org-export-get-headline-number
1838 headline info
) "-"))
1840 (list (org-element-property :custom-id headline
)
1841 (concat "sec-" section-number
)
1842 (org-element-property :id headline
))))
1843 (preferred-id (car ids
))
1844 (extra-ids (cdr ids
))
1845 (extra-class (org-element-property :html-container-class headline
))
1846 (level1 (+ level
(1- org-html-toplevel-hlevel
))))
1847 (format "<div id=\"%s\" class=\"%s\">%s%s</div>\n"
1848 (format "outline-container-%s"
1849 (or (org-element-property :custom-id headline
)
1851 (concat (format "outline-%d" level1
) (and extra-class
" ")
1853 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
1858 (let ((id (org-export-solidify-link-text
1859 (if (org-uuidgen-p x
) (concat "ID-" x
)
1861 (org-html--anchor id
)))
1868 ;;;; Horizontal Rule
1870 (defun org-html-horizontal-rule (horizontal-rule contents info
)
1871 "Transcode an HORIZONTAL-RULE object from Org to HTML.
1872 CONTENTS is nil. INFO is a plist holding contextual information."
1876 ;;;; Inline Src Block
1878 (defun org-html-inline-src-block (inline-src-block contents info
)
1879 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
1880 CONTENTS holds the contents of the item. INFO is a plist holding
1881 contextual information."
1882 (let* ((org-lang (org-element-property :language inline-src-block
))
1883 (code (org-element-property :value inline-src-block
)))
1889 (defun org-html-format-section (text class
&optional id
)
1890 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
1891 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
1893 (defun org-html-inlinetask (inlinetask contents info
)
1894 "Transcode an INLINETASK element from Org to HTML.
1895 CONTENTS holds the contents of the block. INFO is a plist
1896 holding contextual information."
1898 ;; If `org-html-format-inlinetask-function' is provided, call it
1899 ;; with appropriate arguments.
1900 ((functionp org-html-format-inlinetask-function
)
1901 (let ((format-function
1903 (lambda (todo todo-type priority text tags
1904 &key contents
&allow-other-keys
)
1905 (funcall org-html-format-inlinetask-function
1906 todo todo-type priority text tags contents
)))))
1907 (org-html-format-headline--wrap
1908 inlinetask info format-function
:contents contents
)))
1909 ;; Otherwise, use a default template.
1910 (t (format "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>"
1911 (org-html-format-headline--wrap inlinetask info
)
1917 (defun org-html-italic (italic contents info
)
1918 "Transcode ITALIC from Org to HTML.
1919 CONTENTS is the text with italic markup. INFO is a plist holding
1920 contextual information."
1921 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
1926 (defun org-html-checkbox (checkbox)
1927 (case checkbox
(on "<code>[X]</code>")
1928 (off "<code>[ ]</code>")
1929 (trans "<code>[-]</code>")
1932 (defun org-html-format-list-item (contents type checkbox
1933 &optional term-counter-id
1935 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" "))))
1939 (let* ((counter term-counter-id
)
1940 (extra (if counter
(format " value=\"%s\"" counter
) "")))
1942 (format "<li%s>" extra
)
1943 (when headline
(concat headline
"<br/>")))))
1945 (let* ((id term-counter-id
)
1946 (extra (if id
(format " id=\"%s\"" id
) "")))
1948 (format "<li%s>" extra
)
1949 (when headline
(concat headline
"<br/>")))))
1951 (let* ((term term-counter-id
))
1952 (setq term
(or term
"(no term)"))
1953 ;; Check-boxes in descriptive lists are associated to tag.
1954 (concat (format "<dt> %s </dt>"
1955 (concat checkbox term
))
1957 (unless (eq type
'descriptive
) checkbox
)
1962 (descriptive "</dd>")))))
1964 (defun org-html-item (item contents info
)
1965 "Transcode an ITEM element from Org to HTML.
1966 CONTENTS holds the contents of the item. INFO is a plist holding
1967 contextual information."
1968 (let* ((plain-list (org-export-get-parent item
))
1969 (type (org-element-property :type plain-list
))
1970 (counter (org-element-property :counter item
))
1971 (checkbox (org-element-property :checkbox item
))
1972 (tag (let ((tag (org-element-property :tag item
)))
1973 (and tag
(org-export-data tag info
)))))
1974 (org-html-format-list-item
1975 contents type checkbox
(or tag counter
))))
1980 (defun org-html-keyword (keyword contents info
)
1981 "Transcode a KEYWORD element from Org to HTML.
1982 CONTENTS is nil. INFO is a plist holding contextual information."
1983 (let ((key (org-element-property :key keyword
))
1984 (value (org-element-property :value keyword
)))
1986 ((string= key
"HTML") value
)
1987 ((string= key
"INDEX") (format "\\index{%s}" value
))
1988 ;; Invisible targets.
1989 ((string= key
"TARGET") nil
)
1990 ((string= key
"TOC")
1991 (let ((value (downcase value
)))
1993 ((string-match "\\<headlines\\>" value
)
1994 (let ((depth (or (and (string-match "[0-9]+" value
)
1995 (string-to-number (match-string 0 value
)))
1996 (plist-get info
:with-toc
))))
1997 (org-html-toc depth info
)))
1998 ((string= "tables" value
) "\\listoftables")
1999 ((string= "figures" value
) "\\listoffigures")
2000 ((string= "listings" value
)
2002 ;; At the moment, src blocks with a caption are wrapped
2003 ;; into a figure environment.
2004 (t "\\listoffigures")))))))))
2007 ;;;; Latex Environment
2009 (defun org-html-format-latex (latex-frag processing-type
)
2010 "Format LaTeX fragments into HTML."
2011 (let ((cache-relpath "") (cache-dir "") bfn
)
2012 (unless (eq processing-type
'mathjax
)
2013 (setq bfn
(buffer-file-name)
2016 (file-name-sans-extension
2017 (file-name-nondirectory bfn
)))
2018 cache-dir
(file-name-directory bfn
)))
2021 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2022 nil nil processing-type
)
2025 (defun org-html-latex-environment (latex-environment contents info
)
2026 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2027 CONTENTS is nil. INFO is a plist holding contextual information."
2028 (let ((processing-type (plist-get info
:with-latex
))
2029 (latex-frag (org-remove-indentation
2030 (org-element-property :value latex-environment
)))
2031 (caption (org-export-data
2032 (org-export-get-caption latex-environment
) info
))
2034 (label (org-element-property :name latex-environment
)))
2036 ((memq processing-type
'(t mathjax
))
2037 (org-html-format-latex latex-frag
'mathjax
))
2038 ((eq processing-type
'dvipng
)
2039 (let* ((formula-link (org-html-format-latex
2040 latex-frag processing-type
)))
2041 (when (and formula-link
2042 (string-match "file:\\([^]]*\\)" formula-link
))
2043 (org-html-format-inline-image
2044 (match-string 1 formula-link
) caption label attr t
))))
2050 (defun org-html-latex-fragment (latex-fragment contents info
)
2051 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2052 CONTENTS is nil. INFO is a plist holding contextual information."
2053 (let ((latex-frag (org-element-property :value latex-fragment
))
2054 (processing-type (plist-get info
:with-latex
)))
2055 (case processing-type
2057 (org-html-format-latex latex-frag
'mathjax
))
2059 (let* ((formula-link (org-html-format-latex
2060 latex-frag processing-type
)))
2061 (when (and formula-link
2062 (string-match "file:\\([^]]*\\)" formula-link
))
2063 (org-html-format-inline-image
2064 (match-string 1 formula-link
)))))
2070 (defun org-html-line-break (line-break contents info
)
2071 "Transcode a LINE-BREAK object from Org to HTML.
2072 CONTENTS is nil. INFO is a plist holding contextual information."
2078 (defun org-html-link--inline-image (link desc info
)
2079 "Return HTML code for an inline image.
2080 LINK is the link pointing to the inline image. INFO is a plist
2081 used as a communication channel."
2082 (let* ((type (org-element-property :type link
))
2083 (raw-path (org-element-property :path link
))
2084 (path (cond ((member type
'("http" "https"))
2085 (concat type
":" raw-path
))
2086 ((file-name-absolute-p raw-path
)
2087 (expand-file-name raw-path
))
2089 (parent (org-export-get-parent-element link
))
2090 (caption (org-export-data (org-export-get-caption parent
) info
))
2091 (label (org-element-property :name parent
))
2092 ;; Retrieve latex attributes from the element around.
2093 (attr (let ((raw-attr
2094 (mapconcat #'identity
2095 (org-element-property :attr_html parent
)
2097 (unless (string= raw-attr
"") raw-attr
))))
2098 ;; Now clear ATTR from any special keyword and set a default
2099 ;; value if nothing is left.
2100 (setq attr
(if (not attr
) "" (org-trim attr
)))
2101 ;; Return proper string, depending on DISPOSITION.
2102 (org-html-format-inline-image
2103 path caption label attr
(org-html-standalone-image-p link info
))))
2105 (defvar org-html-standalone-image-predicate
)
2106 (defun org-html-standalone-image-p (element info
&optional predicate
)
2107 "Test if ELEMENT is a standalone image for the purpose HTML export.
2108 INFO is a plist holding contextual information.
2110 Return non-nil, if ELEMENT is of type paragraph and it's sole
2111 content, save for whitespaces, is a link that qualifies as an
2114 Return non-nil, if ELEMENT is of type link and it's containing
2115 paragraph has no other content save for leading and trailing
2118 Return nil, otherwise.
2120 Bind `org-html-standalone-image-predicate' to constrain
2121 paragraph further. For example, to check for only captioned
2122 standalone images, do the following.
2124 \(setq org-html-standalone-image-predicate
2125 \(lambda \(paragraph\)
2126 \(org-element-property :caption paragraph\)\)\)"
2127 (let ((paragraph (case (org-element-type element
)
2129 (link (and (org-export-inline-image-p
2130 element org-html-inline-image-rules
)
2131 (org-export-get-parent element
)))
2133 (when (eq (org-element-type paragraph
) 'paragraph
)
2134 (when (or (not (and (boundp 'org-html-standalone-image-predicate
)
2135 (functionp org-html-standalone-image-predicate
)))
2136 (funcall org-html-standalone-image-predicate paragraph
))
2137 (let ((contents (org-element-contents paragraph
)))
2138 (loop for x in contents
2139 with inline-image-count
= 0
2141 ((eq (org-element-type x
) 'plain-text
)
2142 (not (org-string-nw-p x
)))
2143 ((eq (org-element-type x
) 'link
)
2144 (when (org-export-inline-image-p
2145 x org-html-inline-image-rules
)
2146 (= (incf inline-image-count
) 1)))
2149 (defun org-html-link (link desc info
)
2150 "Transcode a LINK object from Org to HTML.
2152 DESC is the description part of the link, or the empty string.
2153 INFO is a plist holding contextual information. See
2155 (let* ((--link-org-files-as-html-maybe
2157 (lambda (raw-path info
)
2158 "Treat links to `file.org' as links to `file.html', if needed.
2159 See `org-html-link-org-files-as-html'."
2161 ((and org-html-link-org-files-as-html
2163 (downcase (file-name-extension raw-path
"."))))
2164 (concat (file-name-sans-extension raw-path
) "."
2165 (plist-get info
:html-extension
)))
2167 (type (org-element-property :type link
))
2168 (raw-path (org-element-property :path link
))
2169 ;; Ensure DESC really exists, or set it to nil.
2170 (desc (and (not (string= desc
"")) desc
))
2172 ((member type
'("http" "https" "ftp" "mailto"))
2173 (concat type
":" raw-path
))
2174 ((string= type
"file")
2175 ;; Treat links to ".org" files as ".html", if needed.
2176 (setq raw-path
(funcall --link-org-files-as-html-maybe
2178 ;; If file path is absolute, prepend it with protocol
2179 ;; component - "file://".
2180 (if (not (file-name-absolute-p raw-path
)) raw-path
2181 (concat "file://" (expand-file-name raw-path
))))
2183 attributes protocol
)
2184 ;; Extract attributes from parent's paragraph.
2185 (and (setq attributes
2188 (let ((att (org-element-property
2189 :attr_html
(org-export-get-parent-element link
))))
2190 (unless (and desc att
(string-match (regexp-quote (car att
)) desc
)) att
))
2192 (setq attributes
(concat " " attributes
)))
2196 ((and (or (eq t org-html-inline-images
)
2197 (and org-html-inline-images
(not desc
)))
2198 (org-export-inline-image-p link org-html-inline-image-rules
))
2199 (org-html-link--inline-image link desc info
))
2200 ;; Radio target: Transcode target's contents and use them as
2201 ;; link's description.
2202 ((string= type
"radio")
2203 (let ((destination (org-export-resolve-radio-link link info
)))
2205 (format "<a href=\"#%s\"%s>%s</a>"
2206 (org-export-solidify-link-text path
)
2208 (org-export-data (org-element-contents destination
) info
)))))
2209 ;; Links pointing to an headline: Find destination and build
2210 ;; appropriate referencing command.
2211 ((member type
'("custom-id" "fuzzy" "id"))
2212 (let ((destination (if (string= type
"fuzzy")
2213 (org-export-resolve-fuzzy-link link info
)
2214 (org-export-resolve-id-link link info
))))
2215 (case (org-element-type destination
)
2216 ;; ID link points to an external file.
2218 (let ((fragment (concat "ID-" path
))
2219 ;; Treat links to ".org" files as ".html", if needed.
2220 (path (funcall --link-org-files-as-html-maybe
2222 (format "<a href=\"%s#%s\"%s>%s</a>"
2223 path fragment attributes
(or desc destination
))))
2224 ;; Fuzzy link points nowhere.
2229 (org-element-property :raw-link link
) info
))))
2230 ;; Fuzzy link points to an invisible target.
2232 ;; Link points to an headline.
2235 ;; What href to use?
2237 ;; Case 1: Headline is linked via it's CUSTOM_ID
2238 ;; property. Use CUSTOM_ID.
2239 ((string= type
"custom-id")
2240 (org-element-property :custom-id destination
))
2241 ;; Case 2: Headline is linked via it's ID property
2242 ;; or through other means. Use the default href.
2243 ((member type
'("id" "fuzzy"))
2245 (mapconcat 'number-to-string
2246 (org-export-get-headline-number
2247 destination info
) "-")))
2248 (t (error "Shouldn't reach here"))))
2249 ;; What description to use?
2251 ;; Case 1: Headline is numbered and LINK has no
2252 ;; description or LINK's description matches
2253 ;; headline's title. Display section number.
2254 (if (and (org-export-numbered-headline-p destination info
)
2256 (string= desc
(org-element-property
2257 :raw-value destination
))))
2258 (mapconcat 'number-to-string
2259 (org-export-get-headline-number
2260 destination info
) ".")
2261 ;; Case 2: Either the headline is un-numbered or
2262 ;; LINK has a custom description. Display LINK's
2263 ;; description or headline's title.
2264 (or desc
(org-export-data (org-element-property
2265 :title destination
) info
)))))
2266 (format "<a href=\"#%s\"%s>%s</a>"
2267 (org-export-solidify-link-text href
) attributes desc
)))
2268 ;; Fuzzy link points to a target. Do as above.
2270 (let ((path (org-export-solidify-link-text path
)) number
)
2273 ((org-html-standalone-image-p destination info
)
2274 (org-export-get-ordinal
2275 (assoc 'link
(org-element-contents destination
))
2276 info
'link
'org-html-standalone-image-p
))
2277 (t (org-export-get-ordinal destination info
))))
2278 (setq desc
(when number
2279 (if (atom number
) (number-to-string number
)
2280 (mapconcat 'number-to-string number
".")))))
2281 (format "<a href=\"#%s\"%s>%s</a>"
2282 path attributes
(or desc
"FIXME")))))))
2283 ;; Coderef: replace link with the reference name or the
2284 ;; equivalent line number.
2285 ((string= type
"coderef")
2286 (let ((fragment (concat "coderef-" path
)))
2287 (format "<a href=\"#%s\" %s%s>%s</a>"
2289 (format (concat "class=\"coderef\""
2290 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2291 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2294 (format (org-export-get-coderef-format path desc
)
2295 (org-export-resolve-coderef path info
)))))
2296 ;; Link type is handled by a special function.
2297 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2298 (funcall protocol
(org-link-unescape path
) desc
'html
))
2299 ;; External link with a description part.
2300 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2301 ;; External link without a description part.
2302 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2303 ;; No path, only description. Try to do something useful.
2304 (t (format "<i>%s</i>" desc
)))))
2309 (defun org-html-paragraph (paragraph contents info
)
2310 "Transcode a PARAGRAPH element from Org to HTML.
2311 CONTENTS is the contents of the paragraph, as a string. INFO is
2312 the plist used as a communication channel."
2313 (let* ((style nil
) ; FIXME
2314 (class (cdr (assoc style
'((footnote .
"footnote")
2316 (extra (if class
(format " class=\"%s\"" class
) ""))
2317 (parent (org-export-get-parent paragraph
)))
2319 ((and (eq (org-element-type parent
) 'item
)
2320 (= (org-element-property :begin paragraph
)
2321 (org-element-property :contents-begin parent
)))
2322 ;; leading paragraph in a list item have no tags
2324 ((org-html-standalone-image-p paragraph info
)
2327 (t (format "<p%s>\n%s</p>" extra contents
)))))
2332 (defun org-html-begin-plain-list (type &optional arg1
)
2335 (format "<ol class=\"org-ol\"%s>" (if arg1
; FIXME
2336 (format " start=\"%d\"" arg1
)
2338 (unordered "<ul class=\"org-ul\">")
2339 (descriptive "<dl class=\"org-dl\">")))
2341 (defun org-html-end-plain-list (type)
2345 (descriptive "</dl>")))
2347 (defun org-html-plain-list (plain-list contents info
)
2348 "Transcode a PLAIN-LIST element from Org to HTML.
2349 CONTENTS is the contents of the list. INFO is a plist holding
2350 contextual information."
2351 (let* (arg1 ;; FIXME
2352 (type (org-element-property :type plain-list
)))
2354 (org-html-begin-plain-list type
)
2355 contents
(org-html-end-plain-list type
))))
2359 (defun org-html-convert-special-strings (string)
2360 "Convert special characters in STRING to HTML."
2361 (let ((all org-html-special-string-regexps
)
2363 (while (setq a
(pop all
))
2364 (setq re
(car a
) rpl
(cdr a
) start
0)
2365 (while (string-match re string start
)
2366 (setq string
(replace-match rpl t nil string
))))
2369 (defun org-html-encode-plain-text (text)
2370 "Convert plain text characters to HTML equivalent.
2371 Possible conversions are set in `org-export-html-protect-char-alist'."
2374 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2375 org-html-protect-char-alist
)
2378 (defun org-html-plain-text (text info
)
2379 "Transcode a TEXT string from Org to HTML.
2380 TEXT is the string to transcode. INFO is a plist holding
2381 contextual information."
2382 (let ((output text
))
2383 ;; Protect following characters: <, >, &.
2384 (setq output
(org-html-encode-plain-text output
))
2385 ;; Handle smart quotes. Be sure to provide original string since
2386 ;; OUTPUT may have been modified.
2387 (when (plist-get info
:with-smart-quotes
)
2388 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2389 ;; Handle special strings.
2390 (when (plist-get info
:with-special-strings
)
2391 (setq output
(org-html-convert-special-strings output
)))
2392 ;; Handle break preservation if required.
2393 (when (plist-get info
:preserve-breaks
)
2395 (replace-regexp-in-string
2396 "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output
)))
2403 (defun org-html-planning (planning contents info
)
2404 "Transcode a PLANNING element from Org to HTML.
2405 CONTENTS is nil. INFO is a plist used as a communication
2407 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2409 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2414 (let ((closed (org-element-property :closed planning
)))
2416 (format span-fmt org-closed-string
2418 (org-element-property :raw-value closed
)))))
2419 (let ((deadline (org-element-property :deadline planning
)))
2421 (format span-fmt org-deadline-string
2423 (org-element-property :raw-value deadline
)))))
2424 (let ((scheduled (org-element-property :scheduled planning
)))
2426 (format span-fmt org-scheduled-string
2428 (org-element-property :raw-value scheduled
)))))))
2432 ;;;; Property Drawer
2434 (defun org-html-property-drawer (property-drawer contents info
)
2435 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2436 CONTENTS is nil. INFO is a plist holding contextual
2438 ;; The property drawer isn't exported but we want separating blank
2439 ;; lines nonetheless.
2445 (defun org-html-quote-block (quote-block contents info
)
2446 "Transcode a QUOTE-BLOCK element from Org to HTML.
2447 CONTENTS holds the contents of the block. INFO is a plist
2448 holding contextual information."
2449 (format "<blockquote>\n%s</blockquote>" contents
))
2454 (defun org-html-quote-section (quote-section contents info
)
2455 "Transcode a QUOTE-SECTION element from Org to HTML.
2456 CONTENTS is nil. INFO is a plist holding contextual information."
2457 (let ((value (org-remove-indentation
2458 (org-element-property :value quote-section
))))
2459 (when value
(format "<pre>\n%s</pre>" value
))))
2464 (defun org-html-section (section contents info
)
2465 "Transcode a SECTION element from Org to HTML.
2466 CONTENTS holds the contents of the section. INFO is a plist
2467 holding contextual information."
2468 (let ((parent (org-export-get-parent-headline section
)))
2469 ;; Before first headline: no container, just return CONTENTS.
2470 (if (not parent
) contents
2471 ;; Get div's class and id references.
2472 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2473 (1- org-html-toplevel-hlevel
)))
2477 (org-export-get-headline-number parent info
) "-")))
2478 ;; Build return value.
2479 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2481 (or (org-element-property :custom-id parent
) section-number
)
2486 (defun org-html-radio-target (radio-target text info
)
2487 "Transcode a RADIO-TARGET object from Org to HTML.
2488 TEXT is the text of the target. INFO is a plist holding
2489 contextual information."
2490 (let ((id (org-export-solidify-link-text
2491 (org-element-property :value radio-target
))))
2492 (org-html--anchor id text
)))
2497 (defun org-html-special-block (special-block contents info
)
2498 "Transcode a SPECIAL-BLOCK element from Org to HTML.
2499 CONTENTS holds the contents of the block. INFO is a plist
2500 holding contextual information."
2501 (format "<div class=\"%s\">\n%s\n</div>"
2502 (downcase (org-element-property :type special-block
))
2508 (defun org-html-src-block (src-block contents info
)
2509 "Transcode a SRC-BLOCK element from Org to HTML.
2510 CONTENTS holds the contents of the item. INFO is a plist holding
2511 contextual information."
2512 (if (org-export-read-attribute :attr_html src-block
:textarea
)
2513 (org-html--textarea-block src-block
)
2514 (let ((lang (org-element-property :language src-block
))
2515 (caption (org-export-get-caption src-block
))
2516 (code (org-html-format-code src-block info
)))
2517 (if (not lang
) (format "<pre class=\"example\">\n%s</pre>" code
)
2518 (format "<div class=\"org-src-container\">\n%s%s\n</div>"
2519 (if (not caption
) ""
2520 (format "<label class=\"org-src-name\">%s</label>"
2521 (org-export-data caption info
)))
2522 (format "\n<pre class=\"src src-%s\">%s</pre>" lang code
))))))
2525 ;;;; Statistics Cookie
2527 (defun org-html-statistics-cookie (statistics-cookie contents info
)
2528 "Transcode a STATISTICS-COOKIE object from Org to HTML.
2529 CONTENTS is nil. INFO is a plist holding contextual information."
2530 (let ((cookie-value (org-element-property :value statistics-cookie
)))
2531 (format "<code>%s</code>" cookie-value
)))
2536 (defun org-html-strike-through (strike-through contents info
)
2537 "Transcode STRIKE-THROUGH from Org to HTML.
2538 CONTENTS is the text with strike-through markup. INFO is a plist
2539 holding contextual information."
2540 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
2546 (defun org-html-subscript (subscript contents info
)
2547 "Transcode a SUBSCRIPT object from Org to HTML.
2548 CONTENTS is the contents of the object. INFO is a plist holding
2549 contextual information."
2550 (format "<sub>%s</sub>" contents
))
2555 (defun org-html-superscript (superscript contents info
)
2556 "Transcode a SUPERSCRIPT object from Org to HTML.
2557 CONTENTS is the contents of the object. INFO is a plist holding
2558 contextual information."
2559 (format "<sup>%s</sup>" contents
))
2564 (defun org-html-table-cell (table-cell contents info
)
2565 "Transcode a TABLE-CELL element from Org to HTML.
2566 CONTENTS is nil. INFO is a plist used as a communication
2568 (let* ((table-row (org-export-get-parent table-cell
))
2569 (table (org-export-get-parent-table table-cell
))
2571 (if (not org-html-table-align-individual-fields
) ""
2572 (format (if (and (boundp 'org-html-format-table-no-css
)
2573 org-html-format-table-no-css
)
2574 " align=\"%s\"" " class=\"%s\"")
2575 (org-export-table-cell-alignment table-cell info
)))))
2576 (when (or (not contents
) (string= "" (org-trim contents
)))
2577 (setq contents
" "))
2579 ((and (org-export-table-has-header-p table info
)
2580 (= 1 (org-export-table-row-group table-row info
)))
2581 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
2582 contents
(cdr org-html-table-header-tags
)))
2583 ((and org-html-table-use-header-tags-for-first-column
2584 (zerop (cdr (org-export-table-cell-address table-cell info
))))
2585 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
2586 contents
(cdr org-html-table-header-tags
)))
2587 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
2588 contents
(cdr org-html-table-data-tags
))))))
2593 (defun org-html-table-row (table-row contents info
)
2594 "Transcode a TABLE-ROW element from Org to HTML.
2595 CONTENTS is the contents of the row. INFO is a plist used as a
2596 communication channel."
2597 ;; Rules are ignored since table separators are deduced from
2598 ;; borders of the current row.
2599 (when (eq (org-element-property :type table-row
) 'standard
)
2600 (let* ((first-rowgroup-p (= 1 (org-export-table-row-group table-row info
)))
2603 ;; Case 1: Row belongs to second or subsequent rowgroups.
2604 ((not (= 1 (org-export-table-row-group table-row info
)))
2605 '("<tbody>" .
"\n</tbody>"))
2606 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
2607 ((org-export-table-has-header-p
2608 (org-export-get-parent-table table-row
) info
)
2609 '("<thead>" .
"\n</thead>"))
2610 ;; Case 2: Row is from first and only row group.
2611 (t '("<tbody>" .
"\n</tbody>")))))
2613 ;; Begin a rowgroup?
2614 (when (org-export-table-row-starts-rowgroup-p table-row info
)
2615 (car rowgroup-tags
))
2617 (concat "\n" (eval (car org-html-table-row-tags
))
2620 (eval (cdr org-html-table-row-tags
)))
2622 (when (org-export-table-row-ends-rowgroup-p table-row info
)
2623 (cdr rowgroup-tags
))))))
2628 (defun org-html-table-first-row-data-cells (table info
)
2630 (org-element-map table
'table-row
2632 (unless (eq (org-element-property :type row
) 'rule
) row
))
2634 (special-column-p (org-export-table-has-special-column-p table
)))
2635 (if (not special-column-p
) (org-element-contents table-row
)
2636 (cdr (org-element-contents table-row
)))))
2638 (defun org-html-table--table.el-table
(table info
)
2639 (when (eq (org-element-property :type table
) 'table.el
)
2641 (let ((outbuf (with-current-buffer
2642 (get-buffer-create "*org-export-table*")
2643 (erase-buffer) (current-buffer))))
2645 (insert (org-element-property :value table
))
2647 (re-search-forward "^[ \t]*|[^|]" nil t
)
2648 (table-generate-source 'html outbuf
))
2649 (with-current-buffer outbuf
2650 (prog1 (org-trim (buffer-string))
2653 (defun org-html-table (table contents info
)
2654 "Transcode a TABLE element from Org to HTML.
2655 CONTENTS is the contents of the table. INFO is a plist holding
2656 contextual information."
2657 (case (org-element-property :type table
)
2658 ;; Case 1: table.el table. Convert it using appropriate tools.
2659 (table.el
(org-html-table--table.el-table table info
))
2660 ;; Case 2: Standard table.
2662 (let* ((label (org-element-property :name table
))
2663 (caption (org-export-get-caption table
))
2664 (attributes (mapconcat #'identity
2665 (org-element-property :attr_html table
)
2668 (if (and (boundp 'org-html-format-table-no-css
)
2669 org-html-format-table-no-css
)
2670 "align=\"%s\"" "class=\"%s\""))
2673 (lambda (table info
)
2675 (lambda (table-cell)
2676 (let ((alignment (org-export-table-cell-alignment
2679 ;; Begin a colgroup?
2680 (when (org-export-table-cell-starts-colgroup-p
2683 ;; Add a column. Also specify it's alignment.
2684 (format "\n<col %s/>" (format alignspec alignment
))
2686 (when (org-export-table-cell-ends-colgroup-p
2689 (org-html-table-first-row-data-cells table info
) "\n"))))
2691 (let ((table-tag (plist-get info
:html-table-tag
)))
2693 (and (string-match "<table\\(.*\\)>" table-tag
)
2694 (match-string 1 table-tag
))
2695 (and label
(format " id=\"%s\""
2696 (org-export-solidify-link-text label
)))))))
2697 ;; Remove last blank line.
2698 (setq contents
(substring contents
0 -
1))
2699 (format "<table%s>\n%s\n%s\n%s\n</table>"
2701 (if (not caption
) ""
2702 (format "<caption>%s</caption>"
2703 (org-export-data caption info
)))
2704 (funcall table-column-specs table info
)
2710 (defun org-html-target (target contents info
)
2711 "Transcode a TARGET object from Org to HTML.
2712 CONTENTS is nil. INFO is a plist holding contextual
2714 (let ((id (org-export-solidify-link-text
2715 (org-element-property :value target
))))
2716 (org-html--anchor id
)))
2721 (defun org-html-timestamp (timestamp contents info
)
2722 "Transcode a TIMESTAMP object from Org to HTML.
2723 CONTENTS is nil. INFO is a plist holding contextual
2725 (let ((value (org-html-plain-text
2726 (org-timestamp-translate timestamp
) info
)))
2727 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
2728 (replace-regexp-in-string "--" "–" value
))))
2733 (defun org-html-underline (underline contents info
)
2734 "Transcode UNDERLINE from Org to HTML.
2735 CONTENTS is the text with underline markup. INFO is a plist
2736 holding contextual information."
2737 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
2743 (defun org-html-verbatim (verbatim contents info
)
2744 "Transcode VERBATIM from Org to HTML.
2745 CONTENTS is nil. INFO is a plist holding contextual
2747 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
2748 (org-element-property :value verbatim
)))
2753 (defun org-html-verse-block (verse-block contents info
)
2754 "Transcode a VERSE-BLOCK element from Org to HTML.
2755 CONTENTS is verse block contents. INFO is a plist holding
2756 contextual information."
2757 ;; Replace each newline character with line break. Also replace
2758 ;; each blank line with a line break.
2759 (setq contents
(replace-regexp-in-string
2760 "^ *\\\\\\\\$" "<br/>\n"
2761 (replace-regexp-in-string
2762 "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents
)))
2763 ;; Replace each white space at beginning of a line with a
2764 ;; non-breaking space.
2765 (while (string-match "^[ \t]+" contents
)
2766 (let* ((num-ws (length (match-string 0 contents
)))
2767 (ws (let (out) (dotimes (i num-ws out
)
2768 (setq out
(concat out
" "))))))
2769 (setq contents
(replace-match ws nil t contents
))))
2770 (format "<p class=\"verse\">\n%s</p>" contents
))
2774 ;;; Filter Functions
2776 (defun org-html-final-function (contents backend info
)
2777 (if (not org-html-pretty-output
) contents
2781 (indent-region (point-min) (point-max))
2782 (buffer-substring-no-properties (point-min) (point-max)))))
2786 ;;; End-user functions
2789 (defun org-html-export-as-html
2790 (&optional async subtreep visible-only body-only ext-plist
)
2791 "Export current buffer to an HTML buffer.
2793 If narrowing is active in the current buffer, only export its
2796 If a region is active, export that region.
2798 A non-nil optional argument ASYNC means the process should happen
2799 asynchronously. The resulting buffer should be accessible
2800 through the `org-export-stack' interface.
2802 When optional argument SUBTREEP is non-nil, export the sub-tree
2803 at point, extracting information from the headline properties
2806 When optional argument VISIBLE-ONLY is non-nil, don't export
2807 contents of hidden elements.
2809 When optional argument BODY-ONLY is non-nil, only write code
2810 between \"<body>\" and \"</body>\" tags.
2812 EXT-PLIST, when provided, is a property list with external
2813 parameters overriding Org default settings, but still inferior to
2814 file-local settings.
2816 Export is done in a buffer named \"*Org HTML Export*\", which
2817 will be displayed when `org-export-show-temporary-export-buffer'
2821 (org-export-async-start
2823 (with-current-buffer (get-buffer-create "*Org HTML Export*")
2826 (goto-char (point-min))
2827 (funcall org-html-display-buffer-mode
)
2828 (org-export-add-to-stack (current-buffer) 'html
)))
2829 `(org-export-as 'html
,subtreep
,visible-only
,body-only
',ext-plist
))
2830 (let ((outbuf (org-export-to-buffer
2831 'html
"*Org HTML Export*"
2832 subtreep visible-only body-only ext-plist
)))
2834 (with-current-buffer outbuf
(funcall org-html-display-buffer-mode
))
2835 (when org-export-show-temporary-export-buffer
2836 (switch-to-buffer-other-window outbuf
)))))
2839 (defun org-html-export-to-html
2840 (&optional async subtreep visible-only body-only ext-plist
)
2841 "Export current buffer to a HTML file.
2843 If narrowing is active in the current buffer, only export its
2846 If a region is active, export that region.
2848 A non-nil optional argument ASYNC means the process should happen
2849 asynchronously. The resulting file should be accessible through
2850 the `org-export-stack' interface.
2852 When optional argument SUBTREEP is non-nil, export the sub-tree
2853 at point, extracting information from the headline properties
2856 When optional argument VISIBLE-ONLY is non-nil, don't export
2857 contents of hidden elements.
2859 When optional argument BODY-ONLY is non-nil, only write code
2860 between \"<body>\" and \"</body>\" tags.
2862 EXT-PLIST, when provided, is a property list with external
2863 parameters overriding Org default settings, but still inferior to
2864 file-local settings.
2866 Return output file's name."
2868 (let* ((extension (concat "." org-html-extension
))
2869 (file (org-export-output-file-name extension subtreep
))
2870 (org-export-coding-system org-html-coding-system
))
2872 (org-export-async-start
2873 (lambda (f) (org-export-add-to-stack f
'html
))
2874 (let ((org-export-coding-system org-html-coding-system
))
2877 'html
,file
,subtreep
,visible-only
,body-only
',ext-plist
))))
2878 (let ((org-export-coding-system org-html-coding-system
))
2880 'html file subtreep visible-only body-only ext-plist
)))))
2883 (defun org-html-publish-to-html (plist filename pub-dir
)
2884 "Publish an org file to HTML.
2886 FILENAME is the filename of the Org file to be published. PLIST
2887 is the property list for the given project. PUB-DIR is the
2888 publishing directory.
2890 Return output file name."
2891 (org-publish-org-to 'html filename
".html" plist pub-dir
))
2897 ;;;; org-format-table-html
2898 ;;;; org-format-org-table-html
2899 ;;;; org-format-table-table-html
2900 ;;;; org-table-number-fraction
2901 ;;;; org-table-number-regexp
2902 ;;;; org-html-table-caption-above
2904 ;;;; org-html-with-timestamp
2905 ;;;; org-html-html-helper-timestamp
2907 ;;;; org-export-as-html-and-open
2908 ;;;; org-export-as-html-batch
2909 ;;;; org-export-as-html-to-buffer
2910 ;;;; org-replace-region-by-html
2911 ;;;; org-export-region-as-html
2912 ;;;; org-export-as-html
2914 ;;;; (org-export-directory :html opt-plist)
2915 ;;;; (plist-get opt-plist :html-extension)
2916 ;;;; org-html-toplevel-hlevel
2917 ;;;; org-html-special-string-regexps
2918 ;;;; org-html-inline-images
2919 ;;;; org-html-inline-image-extensions
2920 ;;;; org-html-protect-char-alist
2921 ;;;; org-html-table-use-header-tags-for-first-column
2922 ;;;; org-html-todo-kwd-class-prefix
2923 ;;;; org-html-tag-class-prefix
2924 ;;;; org-html-footnote-separator
2926 ;;;; org-export-preferred-target-alist
2927 ;;;; org-export-solidify-link-text
2928 ;;;; class for anchors
2929 ;;;; org-export-with-section-numbers, body-only
2930 ;;;; org-export-mark-todo-in-toc
2932 ;;;; org-html-format-org-link
2933 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
2934 ;;;; alt = (file-name-nondirectory path)
2936 ;;;; org-export-time-stamp-file'
2941 ;; generated-autoload-file: "org-loaddefs.el"
2944 ;;; ox-html.el ends here