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
981 ;;; Internal Functions
983 (defun org-html-format-inline-image (src &optional
984 caption label attr standalone-p
)
985 (let* ((id (if (not label
) ""
986 (format " id=\"%s\"" (org-export-solidify-link-text label
))))
989 ((string-match "\\<alt=" (or attr
"")) "")
990 ((string-match "^ltxpng/" src
)
991 (format " alt=\"%s\""
992 (org-html-encode-plain-text
993 (org-find-text-property-in-string
994 'org-latex-src src
))))
995 (t (format " alt=\"%s\""
996 (file-name-nondirectory src
)))))))
999 (let ((img (format "<img src=\"%s\" %s/>" src attr
)))
1000 (format "\n<div%s class=\"figure\">%s%s\n</div>"
1001 id
(format "\n<p>%s</p>" img
)
1002 (when caption
(format "\n<p>%s</p>" caption
)))))
1003 (t (format "<img src=\"%s\" %s/>" src
(concat attr id
))))))
1005 (defun org-html--textarea-block (element)
1006 "Transcode ELEMENT into a textarea block.
1007 ELEMENT is either a src block or an example block."
1008 (let ((code (car (org-export-unravel-code element
)))
1009 (attr (org-export-read-attribute :attr_html element
)))
1010 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>"
1011 (or (plist-get attr
:width
) 80)
1012 (or (plist-get attr
:height
) (org-count-lines code
))
1018 (defun org-html-bibliography ()
1019 "Find bibliography, cut it out and return it."
1021 (let (beg end
(cnt 1) bib
)
1023 (goto-char (point-min))
1024 (when (re-search-forward
1025 "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t
)
1026 (setq beg
(match-beginning 0))
1027 (while (re-search-forward "</?div\\>" nil t
)
1028 (setq cnt
(+ cnt
(if (string= (match-string 0) "<div") +1 -
1)))
1030 (and (looking-at ">") (forward-char 1))
1031 (setq bib
(buffer-substring beg
(point)))
1032 (delete-region beg
(point))
1033 (throw 'exit bib
))))
1038 (defun org-html-splice-attributes (tag attributes
)
1039 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
1040 (if (not attributes
)
1042 (let (oldatt newatt
)
1043 (setq oldatt
(org-extract-attributes-from-string tag
)
1045 newatt
(cdr (org-extract-attributes-from-string attributes
)))
1047 (setq oldatt
(plist-put oldatt
(pop newatt
) (pop newatt
))))
1048 (if (string-match ">" tag
)
1050 (replace-match (concat (org-attributes-to-string oldatt
) ">")
1054 (defun org-export-splice-style (style extra
)
1055 "Splice EXTRA into STYLE, just before \"</style>\"."
1056 (if (and (stringp extra
)
1057 (string-match "\\S-" extra
)
1058 (string-match "</style>" style
))
1059 (concat (substring style
0 (match-beginning 0))
1061 (substring style
(match-beginning 0)))
1064 (defun org-export-htmlize-region-for-paste (beg end
)
1065 "Convert the region to HTML, using htmlize.el.
1066 This is much like `htmlize-region-for-paste', only that it uses
1067 the settings define in the org-... variables."
1068 (let* ((htmlize-output-type org-export-htmlize-output-type
)
1069 (htmlize-css-name-prefix org-export-htmlize-font-prefix
)
1070 (htmlbuf (htmlize-region beg end
)))
1072 (with-current-buffer htmlbuf
1073 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1074 (plist-get htmlize-buffer-places
'content-end
)))
1075 (kill-buffer htmlbuf
))))
1078 (defun org-export-htmlize-generate-css ()
1079 "Create the CSS for all font definitions in the current Emacs session.
1080 Use this to create face definitions in your CSS style file that can then
1081 be used by code snippets transformed by htmlize.
1082 This command just produces a buffer that contains class definitions for all
1083 faces used in the current Emacs session. You can copy and paste the ones you
1084 need into your CSS file.
1086 If you then set `org-export-htmlize-output-type' to `css', calls
1087 to the function `org-export-htmlize-region-for-paste' will
1088 produce code that uses these same face definitions."
1091 (and (get-buffer "*html*") (kill-buffer "*html*"))
1093 (let ((fl (face-list))
1094 (htmlize-css-name-prefix "org-")
1095 (htmlize-output-type 'css
)
1097 (while (setq f
(pop fl
)
1098 i
(and f
(face-attribute f
:inherit
)))
1099 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1100 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1101 (htmlize-region (point-min) (point-max))))
1102 (org-pop-to-buffer-same-window "*html*")
1103 (goto-char (point-min))
1104 (if (re-search-forward "<style" nil t
)
1105 (delete-region (point-min) (match-beginning 0)))
1106 (if (re-search-forward "</style>" nil t
)
1107 (delete-region (1+ (match-end 0)) (point-max)))
1108 (beginning-of-line 1)
1109 (if (looking-at " +") (replace-match ""))
1110 (goto-char (point-min)))
1112 (defun org-html--make-string (n string
)
1113 "Build a string by concatenating N times STRING."
1114 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1116 (defun org-html-toc-text (toc-entries)
1117 (let* ((prev-level (1- (nth 1 (car toc-entries
))))
1118 (start-level prev-level
))
1122 (let ((headline (nth 0 entry
))
1123 (level (nth 1 entry
)))
1125 (let* ((cnt (- level prev-level
))
1126 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1128 (setq prev-level level
)
1130 (org-html--make-string
1131 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1132 ((< cnt
0) "</li>\n</ul>\n")))
1133 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1136 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
1138 (defun* org-html-format-toc-headline
1139 (todo todo-type priority text tags
1140 &key level section-number headline-label
&allow-other-keys
)
1141 (let ((headline (concat
1142 section-number
(and section-number
". ")
1144 (and tags
" ") (org-html--tags tags
))))
1145 (format "<a href=\"#%s\">%s</a>"
1146 (org-export-solidify-link-text headline-label
)
1147 (if (not nil
) headline
1148 (format "<span class=\"%s\">%s</span>" todo-type headline
)))))
1150 (defun org-html-toc (depth info
)
1151 (let* ((headlines (org-export-collect-headlines info depth
))
1153 (loop for headline in headlines collect
1154 (list (org-html-format-headline--wrap
1155 headline info
'org-html-format-toc-headline
)
1156 (org-export-get-relative-level headline info
)))))
1159 "<div id=\"table-of-contents\">\n"
1160 (format "<h%d>%s</h%d>\n"
1161 org-html-toplevel-hlevel
1162 (org-html--translate "Table of Contents" info
)
1163 org-html-toplevel-hlevel
)
1164 "<div id=\"text-table-of-contents\">"
1165 (org-html-toc-text toc-entries
)
1169 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1170 "Turn todo keyword into a valid class name.
1171 Replaces invalid characters with \"_\"."
1173 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1174 (setq kwd
(replace-match "_" t t kwd
))))
1177 (defun org-html-format-footnote-reference (n def refcnt
)
1178 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1179 (format org-html-footnote-format
1180 (let* ((id (format "fnr.%s%s" n extra
))
1181 (href (format " href=\"#fn.%s\"" n
))
1182 (attributes (concat " class=\"footref\"" href
)))
1183 (org-html--anchor id n attributes
)))))
1185 (defun org-html-format-footnotes-section (section-name definitions
)
1186 (if (not definitions
) ""
1187 (format org-html-footnotes-section section-name definitions
)))
1189 (defun org-html-format-footnote-definition (fn)
1190 (let ((n (car fn
)) (def (cdr fn
)))
1192 "<tr>\n<td>%s</td>\n<td>%s</td>\n</tr>\n"
1193 (format org-html-footnote-format
1194 (let* ((id (format "fn.%s" n
))
1195 (href (format " href=\"#fnr.%s\"" n
))
1196 (attributes (concat " class=\"footnum\"" href
)))
1197 (org-html--anchor id n attributes
)))
1200 (defun org-html-footnote-section (info)
1201 (let* ((fn-alist (org-export-collect-footnote-definitions
1202 (plist-get info
:parse-tree
) info
))
1205 (loop for
(n type raw
) in fn-alist collect
1206 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1207 (org-trim (org-export-data raw info
))
1209 (org-trim (org-export-data raw info
))))))))
1211 (org-html-format-footnotes-section
1212 (org-html--translate "Footnotes" info
)
1214 "<table>\n%s\n</table>\n"
1215 (mapconcat 'org-html-format-footnote-definition fn-alist
"\n"))))))
1221 (defun org-html--build-meta-info (info)
1222 "Return meta tags for exported document.
1223 INFO is a plist used as a communication channel."
1224 (let* ((title (org-export-data (plist-get info
:title
) info
))
1225 (author (and (plist-get info
:with-author
)
1226 (let ((auth (plist-get info
:author
)))
1227 (and auth
(org-export-data auth info
)))))
1228 (date (and (plist-get info
:with-date
)
1229 (let ((date (plist-get info
:date
)))
1230 (and date
(org-export-data date info
)))))
1231 (description (plist-get info
:description
))
1232 (keywords (plist-get info
:keywords
)))
1234 (format "<title>%s</title>\n" title
)
1236 "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>"
1237 (or (and org-html-coding-system
1238 (fboundp 'coding-system-get
)
1239 (coding-system-get org-html-coding-system
'mime-charset
))
1241 (format "<meta name=\"title\" content=\"%s\"/>\n" title
)
1242 (format "<meta name=\"generator\" content=\"Org-mode\"/>\n")
1243 (and date
(format "<meta name=\"generated\" content=\"%s\"/>\n" date
))
1244 (and author
(format "<meta name=\"author\" content=\"%s\"/>\n" author
))
1246 (format "<meta name=\"description\" content=\"%s\"/>\n" description
))
1248 (format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords
)))))
1250 (defun org-html--build-style (info)
1251 "Return style information for exported document.
1252 INFO is a plist used as a communication channel."
1253 (org-element-normalize-string
1255 (when (plist-get info
:html-style-include-default
) org-html-style-default
)
1256 (org-element-normalize-string (plist-get info
:html-style
))
1257 (org-element-normalize-string (plist-get info
:html-style-extra
))
1258 (when (plist-get info
:html-style-include-scripts
) org-html-scripts
))))
1260 (defun org-html--build-mathjax-config (info)
1261 "Insert the user setup into the mathjax template.
1262 INFO is a plist used as a communication channel."
1263 (when (memq (plist-get info
:with-latex
) '(mathjax t
))
1264 (let ((template org-html-mathjax-template
)
1265 (options org-html-mathjax-options
)
1266 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1267 name val
(yes " ") (no "// ") x
)
1270 (setq name
(car e
) val
(nth 1 e
))
1271 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1272 (setq val
(car (read-from-string
1273 (substring in-buffer
(match-end 0))))))
1274 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1275 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1276 (setq template
(replace-match val t t template
))))
1278 (setq val
(nth 1 (assq 'mathml options
)))
1279 (if (string-match (concat "\\<mathml:") in-buffer
)
1280 (setq val
(car (read-from-string
1281 (substring in-buffer
(match-end 0))))))
1282 ;; Exchange prefixes depending on mathml setting.
1283 (if (not val
) (setq x yes yes no no x
))
1284 ;; Replace cookies to turn on or off the config/jax lines.
1285 (if (string-match ":MMLYES:" template
)
1286 (setq template
(replace-match yes t t template
)))
1287 (if (string-match ":MMLNO:" template
)
1288 (setq template
(replace-match no t t template
)))
1289 ;; Return the modified template.
1290 (org-element-normalize-string template
))))
1292 (defun org-html--build-preamble (info)
1293 "Return document preamble as a string, or nil.
1294 INFO is a plist used as a communication channel."
1295 (let ((preamble (plist-get info
:html-preamble
)))
1297 (let ((preamble-contents
1298 (if (functionp preamble
) (funcall preamble info
)
1299 (let ((title (org-export-data (plist-get info
:title
) info
))
1300 (date (if (not (plist-get info
:with-date
)) ""
1301 (org-export-data (plist-get info
:date
) info
)))
1302 (author (if (not (plist-get info
:with-author
)) ""
1303 (org-export-data (plist-get info
:author
) info
)))
1304 (email (if (not (plist-get info
:with-email
)) ""
1305 (plist-get info
:email
))))
1306 (if (stringp preamble
)
1307 (format-spec preamble
1308 `((?t .
,title
) (?a .
,author
)
1309 (?d .
,date
) (?e .
,email
)))
1311 (or (cadr (assoc (plist-get info
:language
)
1312 org-html-preamble-format
))
1313 (cadr (assoc "en" org-html-preamble-format
)))
1314 `((?t .
,title
) (?a .
,author
)
1315 (?d .
,date
) (?e .
,email
))))))))
1316 (when (org-string-nw-p preamble-contents
)
1317 (concat (format "<div id=\"%s\">\n" (nth 0 org-html-divs
))
1318 (org-element-normalize-string preamble-contents
)
1321 (defun org-html--build-postamble (info)
1322 "Return document postamble as a string, or nil.
1323 INFO is a plist used as a communication channel."
1324 (let ((postamble (plist-get info
:html-postamble
)))
1326 (let ((postamble-contents
1327 (if (functionp postamble
) (funcall postamble info
)
1328 (let ((date (if (not (plist-get info
:with-date
)) ""
1329 (org-export-data (plist-get info
:date
) info
)))
1330 (author (let ((author (plist-get info
:author
)))
1331 (and author
(org-export-data author info
))))
1334 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1335 (split-string (plist-get info
:email
) ",+ *")
1337 (html-validation-link (or org-html-validation-link
""))
1338 (creator-info (plist-get info
:creator
)))
1339 (cond ((stringp postamble
)
1340 (format-spec postamble
1341 `((?a .
,author
) (?e .
,email
)
1342 (?d .
,date
) (?c .
,creator-info
)
1343 (?v .
,html-validation-link
))))
1344 ((eq postamble
'auto
)
1346 (when (plist-get info
:time-stamp-file
)
1347 (format "<p class=\"date\">%s: %s</p>\n"
1348 (org-html--translate "Date" info
)
1350 (when (and (plist-get info
:with-author
) author
)
1351 (format "<p class=\"author\">%s : %s</p>\n"
1352 (org-html--translate "Author" info
)
1354 (when (and (plist-get info
:with-email
) email
)
1355 (format "<p class=\"email\">%s </p>\n" email
))
1356 (when (plist-get info
:with-creator
)
1357 (format "<p class=\"creator\">%s</p>\n"
1359 html-validation-link
"\n"))
1361 (or (cadr (assoc (plist-get info
:language
)
1362 org-html-postamble-format
))
1363 (cadr (assoc "en" org-html-postamble-format
)))
1364 `((?a .
,author
) (?e .
,email
)
1365 (?d .
,date
) (?c .
,creator-info
)
1366 (?v .
,html-validation-link
)))))))))
1367 (when (org-string-nw-p postamble-contents
)
1369 (format "<div id=\"%s\">\n" (nth 2 org-html-divs
))
1370 (org-element-normalize-string postamble-contents
)
1373 (defun org-html-inner-template (contents info
)
1374 "Return body of document string after HTML conversion.
1375 CONTENTS is the transcoded contents string. INFO is a plist
1376 holding export options."
1378 (format "<div id=\"%s\">\n" (nth 1 org-html-divs
))
1380 (format "<h1 class=\"title\">%s</h1>\n"
1381 (org-export-data (plist-get info
:title
) info
))
1382 ;; Table of contents.
1383 (let ((depth (plist-get info
:with-toc
)))
1384 (when depth
(org-html-toc depth info
)))
1385 ;; Document contents.
1387 ;; Footnotes section.
1388 (org-html-footnote-section info
)
1390 (org-html-bibliography)
1393 (defun org-html-template (contents info
)
1394 "Return complete document string after HTML conversion.
1395 CONTENTS is the transcoded contents string. INFO is a plist
1396 holding export options."
1399 (or (and (stringp org-html-xml-declaration
)
1400 org-html-xml-declaration
)
1401 (cdr (assoc (plist-get info
:html-extension
)
1402 org-html-xml-declaration
))
1403 (cdr (assoc "html" org-html-xml-declaration
))
1406 (or (and org-html-coding-system
1407 (fboundp 'coding-system-get
)
1408 (coding-system-get org-html-coding-system
'mime-charset
))
1411 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
1412 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
1413 (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n"
1414 (plist-get info
:language
) (plist-get info
:language
))
1416 (org-html--build-meta-info info
)
1417 (org-html--build-style info
)
1418 (org-html--build-mathjax-config info
)
1421 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1422 (link-home (org-trim (plist-get info
:html-link-home
))))
1423 (unless (and (string= link-up
"") (string= link-up
""))
1424 (format org-html-home
/up-format
1425 (or link-up link-home
)
1426 (or link-home link-up
))))
1428 (org-html--build-preamble info
)
1429 ;; Document contents.
1432 (org-html--build-postamble info
)
1433 ;; Closing document.
1434 "</body>\n</html>"))
1436 (defun org-html--translate (s info
)
1437 "Translate string S according to specified language.
1438 INFO is a plist used as a communication channel."
1439 (org-export-translate s
:html info
))
1443 (defun org-html--anchor (&optional id desc attributes
)
1444 (let* ((name (and org-html-allow-name-attribute-in-anchors id
))
1445 (attributes (concat (and id
(format " id=\"%s\"" id
))
1446 (and name
(format " name=\"%s\"" name
))
1448 (format "<a%s>%s</a>" attributes
(or desc
""))))
1452 (defun org-html--todo (todo)
1454 (format "<span class=\"%s %s%s\">%s</span>"
1455 (if (member todo org-done-keywords
) "done" "todo")
1456 org-html-todo-kwd-class-prefix
(org-html-fix-class-name todo
)
1461 (defun org-html--tags (tags)
1463 (format "<span class=\"tag\">%s</span>"
1466 (format "<span class=\"%s\">%s</span>"
1467 (concat org-html-tag-class-prefix
1468 (org-html-fix-class-name tag
))
1474 (defun* org-html-format-headline
1475 (todo todo-type priority text tags
1476 &key level section-number headline-label
&allow-other-keys
)
1477 (let ((section-number
1478 (when section-number
1479 (format "<span class=\"section-number-%d\">%s</span> "
1480 level section-number
)))
1481 (todo (org-html--todo todo
))
1482 (tags (org-html--tags tags
)))
1483 (concat section-number todo
(and todo
" ") text
1484 (and tags
" ") tags
)))
1488 (defun org-html-fontify-code (code lang
)
1489 "Color CODE with htmlize library.
1490 CODE is a string representing the source code to colorize. LANG
1491 is the language used for CODE, as a string, or nil."
1494 ;; Case 1: No lang. Possibly an example block.
1496 ;; Simple transcoding.
1497 (org-html-encode-plain-text code
))
1498 ;; Case 2: No htmlize or an inferior version of htmlize
1499 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1501 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1502 ;; Simple transcoding.
1503 (org-html-encode-plain-text code
))
1506 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1507 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1509 ;; Case 1: Language is not associated with any Emacs mode
1510 ((not (functionp lang-mode
))
1511 ;; Simple transcoding.
1512 (org-html-encode-plain-text code
))
1513 ;; Case 2: Default. Fontify code.
1516 (setq code
(with-temp-buffer
1517 ;; Switch to language-specific mode.
1521 (font-lock-fontify-buffer)
1522 ;; Remove formatting on newline characters.
1524 (let ((beg (point-min))
1527 (while (progn (end-of-line) (< (point) end
))
1528 (put-text-property (point) (1+ (point)) 'face nil
)
1531 (set-buffer-modified-p nil
)
1533 (org-export-htmlize-region-for-paste
1534 (point-min) (point-max))))
1535 ;; Strip any encolosing <pre></pre> tags.
1536 (if (string-match "<pre[^>]*>\n*\\([^\000]*\\)</pre>" code
)
1537 (match-string 1 code
)
1540 (defun org-html-do-format-code
1541 (code &optional lang refs retain-labels num-start
)
1542 "Format CODE string as source code.
1543 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1544 respectively, the language of the source code, as a string, an
1545 alist between line numbers and references (as returned by
1546 `org-export-unravel-code'), a boolean specifying if labels should
1547 appear in the source code, and the number associated to the first
1549 (let* ((code-lines (org-split-string code
"\n"))
1550 (code-length (length code-lines
))
1554 (length (number-to-string (+ code-length num-start
))))))
1555 (code (org-html-fontify-code code lang
)))
1556 (org-export-format-code
1558 (lambda (loc line-num ref
)
1561 ;; Add line number, if needed.
1563 (format "<span class=\"linenr\">%s</span>"
1564 (format num-fmt line-num
)))
1565 ;; Transcoded src line.
1567 ;; Add label, if needed.
1568 (when (and ref retain-labels
) (format " (%s)" ref
))))
1569 ;; Mark transcoded line as an anchor, if needed.
1571 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1575 (defun org-html-format-code (element info
)
1576 "Format contents of ELEMENT as source code.
1577 ELEMENT is either an example block or a src block. INFO is
1578 a plist used as a communication channel."
1579 (let* ((lang (org-element-property :language element
))
1580 ;; Extract code and references.
1581 (code-info (org-export-unravel-code element
))
1582 (code (car code-info
))
1583 (refs (cdr code-info
))
1584 ;; Does the src block contain labels?
1585 (retain-labels (org-element-property :retain-labels element
))
1586 ;; Does it have line numbers?
1587 (num-start (case (org-element-property :number-lines element
)
1588 (continued (org-export-get-loc element info
))
1590 (org-html-do-format-code code lang refs retain-labels num-start
)))
1594 ;;; Transcode Functions
1598 (defun org-html-bold (bold contents info
)
1599 "Transcode BOLD from Org to HTML.
1600 CONTENTS is the text with bold markup. INFO is a plist holding
1601 contextual information."
1602 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
1608 (defun org-html-center-block (center-block contents info
)
1609 "Transcode a CENTER-BLOCK element from Org to HTML.
1610 CONTENTS holds the contents of the block. INFO is a plist
1611 holding contextual information."
1612 (format "<div style=\"text-align: center\">\n%s</div>" contents
))
1617 (defun org-html-clock (clock contents info
)
1618 "Transcode a CLOCK element from Org to HTML.
1619 CONTENTS is nil. INFO is a plist used as a communication
1622 <span class=\"timestamp-wrapper\">
1623 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
1628 (org-element-property :raw-value
1629 (org-element-property :value clock
)))
1630 (let ((time (org-element-property :duration clock
)))
1631 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
1636 (defun org-html-code (code contents info
)
1637 "Transcode CODE from Org to HTML.
1638 CONTENTS is nil. INFO is a plist holding contextual
1640 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
1641 (org-element-property :value code
)))
1646 (defun org-html-drawer (drawer contents info
)
1647 "Transcode a DRAWER element from Org to HTML.
1648 CONTENTS holds the contents of the block. INFO is a plist
1649 holding contextual information."
1650 (if (functionp org-html-format-drawer-function
)
1651 (funcall org-html-format-drawer-function
1652 (org-element-property :drawer-name drawer
)
1654 ;; If there's no user defined function: simply
1655 ;; display contents of the drawer.
1661 (defun org-html-dynamic-block (dynamic-block contents info
)
1662 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
1663 CONTENTS holds the contents of the block. INFO is a plist
1664 holding contextual information. See `org-export-data'."
1670 (defun org-html-entity (entity contents info
)
1671 "Transcode an ENTITY object from Org to HTML.
1672 CONTENTS are the definition itself. INFO is a plist holding
1673 contextual information."
1674 (org-element-property :html entity
))
1679 (defun org-html-example-block (example-block contents info
)
1680 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
1681 CONTENTS is nil. INFO is a plist holding contextual
1683 (if (org-export-read-attribute :attr_html example-block
:textarea
)
1684 (org-html--textarea-block example-block
)
1685 (format "<pre class=\"example\">\n%s</pre>"
1686 (org-html-format-code example-block info
))))
1691 (defun org-html-export-snippet (export-snippet contents info
)
1692 "Transcode a EXPORT-SNIPPET object from Org to HTML.
1693 CONTENTS is nil. INFO is a plist holding contextual
1695 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
1696 (org-element-property :value export-snippet
)))
1701 (defun org-html-export-block (export-block contents info
)
1702 "Transcode a EXPORT-BLOCK element from Org to HTML.
1703 CONTENTS is nil. INFO is a plist holding contextual information."
1704 (when (string= (org-element-property :type export-block
) "HTML")
1705 (org-remove-indentation (org-element-property :value export-block
))))
1710 (defun org-html-fixed-width (fixed-width contents info
)
1711 "Transcode a FIXED-WIDTH element from Org to HTML.
1712 CONTENTS is nil. INFO is a plist holding contextual information."
1713 (format "<pre class=\"example\">\n%s</pre>"
1714 (org-html-do-format-code
1715 (org-remove-indentation
1716 (org-element-property :value fixed-width
)))))
1719 ;;;; Footnote Reference
1721 (defun org-html-footnote-reference (footnote-reference contents info
)
1722 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
1723 CONTENTS is nil. INFO is a plist holding contextual information."
1725 ;; Insert separator between two footnotes in a row.
1726 (let ((prev (org-export-get-previous-element footnote-reference info
)))
1727 (when (eq (org-element-type prev
) 'footnote-reference
)
1728 org-html-footnote-separator
))
1730 ((not (org-export-footnote-first-reference-p footnote-reference info
))
1731 (org-html-format-footnote-reference
1732 (org-export-get-footnote-number footnote-reference info
)
1734 ;; Inline definitions are secondary strings.
1735 ((eq (org-element-property :type footnote-reference
) 'inline
)
1736 (org-html-format-footnote-reference
1737 (org-export-get-footnote-number footnote-reference info
)
1739 ;; Non-inline footnotes definitions are full Org data.
1740 (t (org-html-format-footnote-reference
1741 (org-export-get-footnote-number footnote-reference info
)
1747 (defun org-html-format-headline--wrap (headline info
1748 &optional format-function
1750 "Transcode an HEADLINE element from Org to HTML.
1751 CONTENTS holds the contents of the headline. INFO is a plist
1752 holding contextual information."
1753 (let* ((level (+ (org-export-get-relative-level headline info
)
1754 (1- org-html-toplevel-hlevel
)))
1755 (headline-number (org-export-get-headline-number headline info
))
1756 (section-number (and (not (org-export-low-level-p headline info
))
1757 (org-export-numbered-headline-p headline info
)
1758 (mapconcat 'number-to-string
1759 headline-number
".")))
1760 (todo (and (plist-get info
:with-todo-keywords
)
1761 (let ((todo (org-element-property :todo-keyword headline
)))
1762 (and todo
(org-export-data todo info
)))))
1763 (todo-type (and todo
(org-element-property :todo-type headline
)))
1764 (priority (and (plist-get info
:with-priority
)
1765 (org-element-property :priority headline
)))
1766 (text (org-export-data (org-element-property :title headline
) info
))
1767 (tags (and (plist-get info
:with-tags
)
1768 (org-export-get-tags headline info
)))
1769 (headline-label (or (org-element-property :custom-id headline
)
1770 (concat "sec-" (mapconcat 'number-to-string
1771 headline-number
"-"))))
1772 (format-function (cond
1773 ((functionp format-function
) format-function
)
1774 ((functionp org-html-format-headline-function
)
1776 (lambda (todo todo-type priority text tags
1778 (funcall org-html-format-headline-function
1779 todo todo-type priority text tags
))))
1780 (t 'org-html-format-headline
))))
1781 (apply format-function
1782 todo todo-type priority text tags
1783 :headline-label headline-label
:level level
1784 :section-number section-number extra-keys
)))
1786 (defun org-html-headline (headline contents info
)
1787 "Transcode an HEADLINE element from Org to HTML.
1788 CONTENTS holds the contents of the headline. INFO is a plist
1789 holding contextual information."
1791 (setq contents
(or contents
""))
1792 (let* ((numberedp (org-export-numbered-headline-p headline info
))
1793 (level (org-export-get-relative-level headline info
))
1794 (text (org-export-data (org-element-property :title headline
) info
))
1795 (todo (and (plist-get info
:with-todo-keywords
)
1796 (let ((todo (org-element-property :todo-keyword headline
)))
1797 (and todo
(org-export-data todo info
)))))
1798 (todo-type (and todo
(org-element-property :todo-type headline
)))
1799 (tags (and (plist-get info
:with-tags
)
1800 (org-export-get-tags headline info
)))
1801 (priority (and (plist-get info
:with-priority
)
1802 (org-element-property :priority headline
)))
1803 (section-number (and (org-export-numbered-headline-p headline info
)
1804 (mapconcat 'number-to-string
1805 (org-export-get-headline-number
1806 headline info
) ".")))
1807 ;; Create the headline text.
1808 (full-text (org-html-format-headline--wrap headline info
)))
1810 ;; Case 1: This is a footnote section: ignore it.
1811 ((org-element-property :footnote-section-p headline
) nil
)
1812 ;; Case 2. This is a deep sub-tree: export it as a list item.
1813 ;; Also export as items headlines for which no section
1814 ;; format has been found.
1815 ((org-export-low-level-p headline info
)
1816 ;; Build the real contents of the sub-tree.
1817 (let* ((type (if numberedp
'ordered
'unordered
))
1818 (itemized-body (org-html-format-list-item
1819 contents type nil nil full-text
)))
1821 (and (org-export-first-sibling-p headline info
)
1822 (org-html-begin-plain-list type
))
1824 (and (org-export-last-sibling-p headline info
)
1825 (org-html-end-plain-list type
)))))
1826 ;; Case 3. Standard headline. Export it as a section.
1828 (let* ((section-number (mapconcat 'number-to-string
1829 (org-export-get-headline-number
1830 headline info
) "-"))
1832 (list (org-element-property :custom-id headline
)
1833 (concat "sec-" section-number
)
1834 (org-element-property :id headline
))))
1835 (preferred-id (car ids
))
1836 (extra-ids (cdr ids
))
1837 (extra-class (org-element-property :html-container-class headline
))
1838 (level1 (+ level
(1- org-html-toplevel-hlevel
))))
1839 (format "<div id=\"%s\" class=\"%s\">%s%s</div>\n"
1840 (format "outline-container-%s"
1841 (or (org-element-property :custom-id headline
)
1843 (concat (format "outline-%d" level1
) (and extra-class
" ")
1845 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
1850 (let ((id (org-export-solidify-link-text
1851 (if (org-uuidgen-p x
) (concat "ID-" x
)
1853 (org-html--anchor id
)))
1860 ;;;; Horizontal Rule
1862 (defun org-html-horizontal-rule (horizontal-rule contents info
)
1863 "Transcode an HORIZONTAL-RULE object from Org to HTML.
1864 CONTENTS is nil. INFO is a plist holding contextual information."
1868 ;;;; Inline Src Block
1870 (defun org-html-inline-src-block (inline-src-block contents info
)
1871 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
1872 CONTENTS holds the contents of the item. INFO is a plist holding
1873 contextual information."
1874 (let* ((org-lang (org-element-property :language inline-src-block
))
1875 (code (org-element-property :value inline-src-block
)))
1881 (defun org-html-format-section (text class
&optional id
)
1882 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
1883 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
1885 (defun org-html-inlinetask (inlinetask contents info
)
1886 "Transcode an INLINETASK element from Org to HTML.
1887 CONTENTS holds the contents of the block. INFO is a plist
1888 holding contextual information."
1890 ;; If `org-html-format-inlinetask-function' is provided, call it
1891 ;; with appropriate arguments.
1892 ((functionp org-html-format-inlinetask-function
)
1893 (let ((format-function
1895 (lambda (todo todo-type priority text tags
1896 &key contents
&allow-other-keys
)
1897 (funcall org-html-format-inlinetask-function
1898 todo todo-type priority text tags contents
)))))
1899 (org-html-format-headline--wrap
1900 inlinetask info format-function
:contents contents
)))
1901 ;; Otherwise, use a default template.
1902 (t (format "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>"
1903 (org-html-format-headline--wrap inlinetask info
)
1909 (defun org-html-italic (italic contents info
)
1910 "Transcode ITALIC from Org to HTML.
1911 CONTENTS is the text with italic markup. INFO is a plist holding
1912 contextual information."
1913 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
1918 (defun org-html-checkbox (checkbox)
1919 (case checkbox
(on "<code>[X]</code>")
1920 (off "<code>[ ]</code>")
1921 (trans "<code>[-]</code>")
1924 (defun org-html-format-list-item (contents type checkbox
1925 &optional term-counter-id
1927 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" "))))
1931 (let* ((counter term-counter-id
)
1932 (extra (if counter
(format " value=\"%s\"" counter
) "")))
1934 (format "<li%s>" extra
)
1935 (when headline
(concat headline
"<br/>")))))
1937 (let* ((id term-counter-id
)
1938 (extra (if id
(format " id=\"%s\"" id
) "")))
1940 (format "<li%s>" extra
)
1941 (when headline
(concat headline
"<br/>")))))
1943 (let* ((term term-counter-id
))
1944 (setq term
(or term
"(no term)"))
1945 ;; Check-boxes in descriptive lists are associated to tag.
1946 (concat (format "<dt> %s </dt>"
1947 (concat checkbox term
))
1949 (unless (eq type
'descriptive
) checkbox
)
1954 (descriptive "</dd>")))))
1956 (defun org-html-item (item contents info
)
1957 "Transcode an ITEM element from Org to HTML.
1958 CONTENTS holds the contents of the item. INFO is a plist holding
1959 contextual information."
1960 (let* ((plain-list (org-export-get-parent item
))
1961 (type (org-element-property :type plain-list
))
1962 (counter (org-element-property :counter item
))
1963 (checkbox (org-element-property :checkbox item
))
1964 (tag (let ((tag (org-element-property :tag item
)))
1965 (and tag
(org-export-data tag info
)))))
1966 (org-html-format-list-item
1967 contents type checkbox
(or tag counter
))))
1972 (defun org-html-keyword (keyword contents info
)
1973 "Transcode a KEYWORD element from Org to HTML.
1974 CONTENTS is nil. INFO is a plist holding contextual information."
1975 (let ((key (org-element-property :key keyword
))
1976 (value (org-element-property :value keyword
)))
1978 ((string= key
"HTML") value
)
1979 ((string= key
"INDEX") (format "\\index{%s}" value
))
1980 ;; Invisible targets.
1981 ((string= key
"TARGET") nil
)
1982 ((string= key
"TOC")
1983 (let ((value (downcase value
)))
1985 ((string-match "\\<headlines\\>" value
)
1986 (let ((depth (or (and (string-match "[0-9]+" value
)
1987 (string-to-number (match-string 0 value
)))
1988 (plist-get info
:with-toc
))))
1989 (org-html-toc depth info
)))
1990 ((string= "tables" value
) "\\listoftables")
1991 ((string= "figures" value
) "\\listoffigures")
1992 ((string= "listings" value
)
1994 ;; At the moment, src blocks with a caption are wrapped
1995 ;; into a figure environment.
1996 (t "\\listoffigures")))))))))
1999 ;;;; Latex Environment
2001 (defun org-html-format-latex (latex-frag processing-type
)
2002 "Format LaTeX fragments into HTML."
2003 (let ((cache-relpath "") (cache-dir "") bfn
)
2004 (unless (eq processing-type
'mathjax
)
2005 (setq bfn
(buffer-file-name)
2008 (file-name-sans-extension
2009 (file-name-nondirectory bfn
)))
2010 cache-dir
(file-name-directory bfn
)))
2013 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2014 nil nil processing-type
)
2017 (defun org-html-latex-environment (latex-environment contents info
)
2018 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2019 CONTENTS is nil. INFO is a plist holding contextual information."
2020 (let ((processing-type (plist-get info
:with-latex
))
2021 (latex-frag (org-remove-indentation
2022 (org-element-property :value latex-environment
)))
2023 (caption (org-export-data
2024 (org-export-get-caption latex-environment
) info
))
2026 (label (org-element-property :name latex-environment
)))
2028 ((memq processing-type
'(t mathjax
))
2029 (org-html-format-latex latex-frag
'mathjax
))
2030 ((eq processing-type
'dvipng
)
2031 (let* ((formula-link (org-html-format-latex
2032 latex-frag processing-type
)))
2033 (when (and formula-link
2034 (string-match "file:\\([^]]*\\)" formula-link
))
2035 (org-html-format-inline-image
2036 (match-string 1 formula-link
) caption label attr t
))))
2042 (defun org-html-latex-fragment (latex-fragment contents info
)
2043 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2044 CONTENTS is nil. INFO is a plist holding contextual information."
2045 (let ((latex-frag (org-element-property :value latex-fragment
))
2046 (processing-type (plist-get info
:with-latex
)))
2047 (case processing-type
2049 (org-html-format-latex latex-frag
'mathjax
))
2051 (let* ((formula-link (org-html-format-latex
2052 latex-frag processing-type
)))
2053 (when (and formula-link
2054 (string-match "file:\\([^]]*\\)" formula-link
))
2055 (org-html-format-inline-image
2056 (match-string 1 formula-link
)))))
2062 (defun org-html-line-break (line-break contents info
)
2063 "Transcode a LINE-BREAK object from Org to HTML.
2064 CONTENTS is nil. INFO is a plist holding contextual information."
2070 (defun org-html-link--inline-image (link desc info
)
2071 "Return HTML code for an inline image.
2072 LINK is the link pointing to the inline image. INFO is a plist
2073 used as a communication channel."
2074 (let* ((type (org-element-property :type link
))
2075 (raw-path (org-element-property :path link
))
2076 (path (cond ((member type
'("http" "https"))
2077 (concat type
":" raw-path
))
2078 ((file-name-absolute-p raw-path
)
2079 (expand-file-name raw-path
))
2081 (parent (org-export-get-parent-element link
))
2082 (caption (org-export-data (org-export-get-caption parent
) info
))
2083 (label (org-element-property :name parent
))
2084 ;; Retrieve latex attributes from the element around.
2085 (attr (let ((raw-attr
2086 (mapconcat #'identity
2087 (org-element-property :attr_html parent
)
2089 (unless (string= raw-attr
"") raw-attr
))))
2090 ;; Now clear ATTR from any special keyword and set a default
2091 ;; value if nothing is left.
2092 (setq attr
(if (not attr
) "" (org-trim attr
)))
2093 ;; Return proper string, depending on DISPOSITION.
2094 (org-html-format-inline-image
2095 path caption label attr
(org-html-standalone-image-p link info
))))
2097 (defvar org-html-standalone-image-predicate
)
2098 (defun org-html-standalone-image-p (element info
&optional predicate
)
2099 "Test if ELEMENT is a standalone image for the purpose HTML export.
2100 INFO is a plist holding contextual information.
2102 Return non-nil, if ELEMENT is of type paragraph and it's sole
2103 content, save for whitespaces, is a link that qualifies as an
2106 Return non-nil, if ELEMENT is of type link and it's containing
2107 paragraph has no other content save for leading and trailing
2110 Return nil, otherwise.
2112 Bind `org-html-standalone-image-predicate' to constrain
2113 paragraph further. For example, to check for only captioned
2114 standalone images, do the following.
2116 \(setq org-html-standalone-image-predicate
2117 \(lambda \(paragraph\)
2118 \(org-element-property :caption paragraph\)\)\)"
2119 (let ((paragraph (case (org-element-type element
)
2121 (link (and (org-export-inline-image-p
2122 element org-html-inline-image-rules
)
2123 (org-export-get-parent element
)))
2125 (when (eq (org-element-type paragraph
) 'paragraph
)
2126 (when (or (not (and (boundp 'org-html-standalone-image-predicate
)
2127 (functionp org-html-standalone-image-predicate
)))
2128 (funcall org-html-standalone-image-predicate paragraph
))
2129 (let ((contents (org-element-contents paragraph
)))
2130 (loop for x in contents
2131 with inline-image-count
= 0
2133 ((eq (org-element-type x
) 'plain-text
)
2134 (not (org-string-nw-p x
)))
2135 ((eq (org-element-type x
) 'link
)
2136 (when (org-export-inline-image-p
2137 x org-html-inline-image-rules
)
2138 (= (incf inline-image-count
) 1)))
2141 (defun org-html-link (link desc info
)
2142 "Transcode a LINK object from Org to HTML.
2144 DESC is the description part of the link, or the empty string.
2145 INFO is a plist holding contextual information. See
2147 (let* ((--link-org-files-as-html-maybe
2149 (lambda (raw-path info
)
2150 "Treat links to `file.org' as links to `file.html', if needed.
2151 See `org-html-link-org-files-as-html'."
2153 ((and org-html-link-org-files-as-html
2155 (downcase (file-name-extension raw-path
"."))))
2156 (concat (file-name-sans-extension raw-path
) "."
2157 (plist-get info
:html-extension
)))
2159 (type (org-element-property :type link
))
2160 (raw-path (org-element-property :path link
))
2161 ;; Ensure DESC really exists, or set it to nil.
2162 (desc (and (not (string= desc
"")) desc
))
2164 ((member type
'("http" "https" "ftp" "mailto"))
2165 (concat type
":" raw-path
))
2166 ((string= type
"file")
2167 ;; Treat links to ".org" files as ".html", if needed.
2168 (setq raw-path
(funcall --link-org-files-as-html-maybe
2170 ;; If file path is absolute, prepend it with protocol
2171 ;; component - "file://".
2172 (if (not (file-name-absolute-p raw-path
)) raw-path
2173 (concat "file://" (expand-file-name raw-path
))))
2175 attributes protocol
)
2176 ;; Extract attributes from parent's paragraph.
2177 (and (setq attributes
2180 (let ((att (org-element-property
2181 :attr_html
(org-export-get-parent-element link
))))
2182 (unless (and desc att
(string-match (regexp-quote (car att
)) desc
)) att
))
2184 (setq attributes
(concat " " attributes
)))
2188 ((and (or (eq t org-html-inline-images
)
2189 (and org-html-inline-images
(not desc
)))
2190 (org-export-inline-image-p link org-html-inline-image-rules
))
2191 (org-html-link--inline-image link desc info
))
2192 ;; Radio target: Transcode target's contents and use them as
2193 ;; link's description.
2194 ((string= type
"radio")
2195 (let ((destination (org-export-resolve-radio-link link info
)))
2197 (format "<a href=\"#%s\"%s>%s</a>"
2198 (org-export-solidify-link-text path
)
2200 (org-export-data (org-element-contents destination
) info
)))))
2201 ;; Links pointing to an headline: Find destination and build
2202 ;; appropriate referencing command.
2203 ((member type
'("custom-id" "fuzzy" "id"))
2204 (let ((destination (if (string= type
"fuzzy")
2205 (org-export-resolve-fuzzy-link link info
)
2206 (org-export-resolve-id-link link info
))))
2207 (case (org-element-type destination
)
2208 ;; ID link points to an external file.
2210 (assert (org-uuidgen-p path
))
2211 (let ((fragment (concat "ID-" path
))
2212 ;; Treat links to ".org" files as ".html", if needed.
2213 (path (funcall --link-org-files-as-html-maybe
2215 (format "<a href=\"%s#%s\"%s>%s</a>"
2216 path fragment attributes
(or desc destination
))))
2217 ;; Fuzzy link points nowhere.
2222 (org-element-property :raw-link link
) info
))))
2223 ;; Fuzzy link points to an invisible target.
2225 ;; Link points to an headline.
2228 ;; What href to use?
2230 ;; Case 1: Headline is linked via it's CUSTOM_ID
2231 ;; property. Use CUSTOM_ID.
2232 ((string= type
"custom-id")
2233 (org-element-property :custom-id destination
))
2234 ;; Case 2: Headline is linked via it's ID property
2235 ;; or through other means. Use the default href.
2236 ((member type
'("id" "fuzzy"))
2238 (mapconcat 'number-to-string
2239 (org-export-get-headline-number
2240 destination info
) "-")))
2241 (t (error "Shouldn't reach here"))))
2242 ;; What description to use?
2244 ;; Case 1: Headline is numbered and LINK has no
2245 ;; description or LINK's description matches
2246 ;; headline's title. Display section number.
2247 (if (and (org-export-numbered-headline-p destination info
)
2249 (string= desc
(org-element-property
2250 :raw-value destination
))))
2251 (mapconcat 'number-to-string
2252 (org-export-get-headline-number
2253 destination info
) ".")
2254 ;; Case 2: Either the headline is un-numbered or
2255 ;; LINK has a custom description. Display LINK's
2256 ;; description or headline's title.
2257 (or desc
(org-export-data (org-element-property
2258 :title destination
) info
)))))
2259 (format "<a href=\"#%s\"%s>%s</a>"
2260 (org-export-solidify-link-text href
) attributes desc
)))
2261 ;; Fuzzy link points to a target. Do as above.
2263 (let ((path (org-export-solidify-link-text path
)) number
)
2266 ((org-html-standalone-image-p destination info
)
2267 (org-export-get-ordinal
2268 (assoc 'link
(org-element-contents destination
))
2269 info
'link
'org-html-standalone-image-p
))
2270 (t (org-export-get-ordinal destination info
))))
2271 (setq desc
(when number
2272 (if (atom number
) (number-to-string number
)
2273 (mapconcat 'number-to-string number
".")))))
2274 (format "<a href=\"#%s\"%s>%s</a>"
2275 path attributes
(or desc
"FIXME")))))))
2276 ;; Coderef: replace link with the reference name or the
2277 ;; equivalent line number.
2278 ((string= type
"coderef")
2279 (let ((fragment (concat "coderef-" path
)))
2280 (format "<a href=\"#%s\" %s%s>%s</a>"
2282 (format (concat "class=\"coderef\""
2283 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2284 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2287 (format (org-export-get-coderef-format path desc
)
2288 (org-export-resolve-coderef path info
)))))
2289 ;; Link type is handled by a special function.
2290 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2291 (funcall protocol
(org-link-unescape path
) desc
'html
))
2292 ;; External link with a description part.
2293 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2294 ;; External link without a description part.
2295 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2296 ;; No path, only description. Try to do something useful.
2297 (t (format "<i>%s</i>" desc
)))))
2302 (defun org-html-paragraph (paragraph contents info
)
2303 "Transcode a PARAGRAPH element from Org to HTML.
2304 CONTENTS is the contents of the paragraph, as a string. INFO is
2305 the plist used as a communication channel."
2306 (let* ((style nil
) ; FIXME
2307 (class (cdr (assoc style
'((footnote .
"footnote")
2309 (extra (if class
(format " class=\"%s\"" class
) ""))
2310 (parent (org-export-get-parent paragraph
)))
2312 ((and (eq (org-element-type parent
) 'item
)
2313 (= (org-element-property :begin paragraph
)
2314 (org-element-property :contents-begin parent
)))
2315 ;; leading paragraph in a list item have no tags
2317 ((org-html-standalone-image-p paragraph info
)
2320 (t (format "<p%s>\n%s</p>" extra contents
)))))
2325 (defun org-html-begin-plain-list (type &optional arg1
)
2328 (format "<ol class=\"org-ol\"%s>" (if arg1
; FIXME
2329 (format " start=\"%d\"" arg1
)
2331 (unordered "<ul class=\"org-ul\">")
2332 (descriptive "<dl class=\"org-dl\">")))
2334 (defun org-html-end-plain-list (type)
2338 (descriptive "</dl>")))
2340 (defun org-html-plain-list (plain-list contents info
)
2341 "Transcode a PLAIN-LIST element from Org to HTML.
2342 CONTENTS is the contents of the list. INFO is a plist holding
2343 contextual information."
2344 (let* (arg1 ;; FIXME
2345 (type (org-element-property :type plain-list
)))
2347 (org-html-begin-plain-list type
)
2348 contents
(org-html-end-plain-list type
))))
2352 (defun org-html-convert-special-strings (string)
2353 "Convert special characters in STRING to HTML."
2354 (let ((all org-html-special-string-regexps
)
2356 (while (setq a
(pop all
))
2357 (setq re
(car a
) rpl
(cdr a
) start
0)
2358 (while (string-match re string start
)
2359 (setq string
(replace-match rpl t nil string
))))
2362 (defun org-html-encode-plain-text (text)
2363 "Convert plain text characters to HTML equivalent.
2364 Possible conversions are set in `org-export-html-protect-char-alist'."
2367 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2368 org-html-protect-char-alist
)
2371 (defun org-html-plain-text (text info
)
2372 "Transcode a TEXT string from Org to HTML.
2373 TEXT is the string to transcode. INFO is a plist holding
2374 contextual information."
2375 (let ((output text
))
2376 ;; Protect following characters: <, >, &.
2377 (setq output
(org-html-encode-plain-text output
))
2378 ;; Handle smart quotes. Be sure to provide original string since
2379 ;; OUTPUT may have been modified.
2380 (when (plist-get info
:with-smart-quotes
)
2381 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2382 ;; Handle special strings.
2383 (when (plist-get info
:with-special-strings
)
2384 (setq output
(org-html-convert-special-strings output
)))
2385 ;; Handle break preservation if required.
2386 (when (plist-get info
:preserve-breaks
)
2388 (replace-regexp-in-string
2389 "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output
)))
2396 (defun org-html-planning (planning contents info
)
2397 "Transcode a PLANNING element from Org to HTML.
2398 CONTENTS is nil. INFO is a plist used as a communication
2400 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2402 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2407 (let ((closed (org-element-property :closed planning
)))
2409 (format span-fmt org-closed-string
2411 (org-element-property :raw-value closed
)))))
2412 (let ((deadline (org-element-property :deadline planning
)))
2414 (format span-fmt org-deadline-string
2416 (org-element-property :raw-value deadline
)))))
2417 (let ((scheduled (org-element-property :scheduled planning
)))
2419 (format span-fmt org-scheduled-string
2421 (org-element-property :raw-value scheduled
)))))))
2425 ;;;; Property Drawer
2427 (defun org-html-property-drawer (property-drawer contents info
)
2428 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2429 CONTENTS is nil. INFO is a plist holding contextual
2431 ;; The property drawer isn't exported but we want separating blank
2432 ;; lines nonetheless.
2438 (defun org-html-quote-block (quote-block contents info
)
2439 "Transcode a QUOTE-BLOCK element from Org to HTML.
2440 CONTENTS holds the contents of the block. INFO is a plist
2441 holding contextual information."
2442 (format "<blockquote>\n%s</blockquote>" contents
))
2447 (defun org-html-quote-section (quote-section contents info
)
2448 "Transcode a QUOTE-SECTION element from Org to HTML.
2449 CONTENTS is nil. INFO is a plist holding contextual information."
2450 (let ((value (org-remove-indentation
2451 (org-element-property :value quote-section
))))
2452 (when value
(format "<pre>\n%s</pre>" value
))))
2457 (defun org-html-section (section contents info
)
2458 "Transcode a SECTION element from Org to HTML.
2459 CONTENTS holds the contents of the section. INFO is a plist
2460 holding contextual information."
2461 (let ((parent (org-export-get-parent-headline section
)))
2462 ;; Before first headline: no container, just return CONTENTS.
2463 (if (not parent
) contents
2464 ;; Get div's class and id references.
2465 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2466 (1- org-html-toplevel-hlevel
)))
2470 (org-export-get-headline-number parent info
) "-")))
2471 ;; Build return value.
2472 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2474 (or (org-element-property :custom-id parent
) section-number
)
2479 (defun org-html-radio-target (radio-target text info
)
2480 "Transcode a RADIO-TARGET object from Org to HTML.
2481 TEXT is the text of the target. INFO is a plist holding
2482 contextual information."
2483 (let ((id (org-export-solidify-link-text
2484 (org-element-property :value radio-target
))))
2485 (org-html--anchor id text
)))
2490 (defun org-html-special-block (special-block contents info
)
2491 "Transcode a SPECIAL-BLOCK element from Org to HTML.
2492 CONTENTS holds the contents of the block. INFO is a plist
2493 holding contextual information."
2494 (format "<div class=\"%s\">\n%s\n</div>"
2495 (downcase (org-element-property :type special-block
))
2501 (defun org-html-src-block (src-block contents info
)
2502 "Transcode a SRC-BLOCK element from Org to HTML.
2503 CONTENTS holds the contents of the item. INFO is a plist holding
2504 contextual information."
2505 (if (org-export-read-attribute :attr_html src-block
:textarea
)
2506 (org-html--textarea-block src-block
)
2507 (let ((lang (org-element-property :language src-block
))
2508 (caption (org-export-get-caption src-block
))
2509 (code (org-html-format-code src-block info
)))
2510 (if (not lang
) (format "<pre class=\"example\">\n%s</pre>" code
)
2511 (format "<div class=\"org-src-container\">\n%s%s\n</div>"
2512 (if (not caption
) ""
2513 (format "<label class=\"org-src-name\">%s</label>"
2514 (org-export-data caption info
)))
2515 (format "\n<pre class=\"src src-%s\">%s</pre>" lang code
))))))
2518 ;;;; Statistics Cookie
2520 (defun org-html-statistics-cookie (statistics-cookie contents info
)
2521 "Transcode a STATISTICS-COOKIE object from Org to HTML.
2522 CONTENTS is nil. INFO is a plist holding contextual information."
2523 (let ((cookie-value (org-element-property :value statistics-cookie
)))
2524 (format "<code>%s</code>" cookie-value
)))
2529 (defun org-html-strike-through (strike-through contents info
)
2530 "Transcode STRIKE-THROUGH from Org to HTML.
2531 CONTENTS is the text with strike-through markup. INFO is a plist
2532 holding contextual information."
2533 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
2539 (defun org-html-subscript (subscript contents info
)
2540 "Transcode a SUBSCRIPT object from Org to HTML.
2541 CONTENTS is the contents of the object. INFO is a plist holding
2542 contextual information."
2543 (format "<sub>%s</sub>" contents
))
2548 (defun org-html-superscript (superscript contents info
)
2549 "Transcode a SUPERSCRIPT object from Org to HTML.
2550 CONTENTS is the contents of the object. INFO is a plist holding
2551 contextual information."
2552 (format "<sup>%s</sup>" contents
))
2557 (defun org-html-table-cell (table-cell contents info
)
2558 "Transcode a TABLE-CELL element from Org to HTML.
2559 CONTENTS is nil. INFO is a plist used as a communication
2561 (let* ((table-row (org-export-get-parent table-cell
))
2562 (table (org-export-get-parent-table table-cell
))
2564 (if (not org-html-table-align-individual-fields
) ""
2565 (format (if (and (boundp 'org-html-format-table-no-css
)
2566 org-html-format-table-no-css
)
2567 " align=\"%s\"" " class=\"%s\"")
2568 (org-export-table-cell-alignment table-cell info
)))))
2569 (when (or (not contents
) (string= "" (org-trim contents
)))
2570 (setq contents
" "))
2572 ((and (org-export-table-has-header-p table info
)
2573 (= 1 (org-export-table-row-group table-row info
)))
2574 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
2575 contents
(cdr org-html-table-header-tags
)))
2576 ((and org-html-table-use-header-tags-for-first-column
2577 (zerop (cdr (org-export-table-cell-address table-cell info
))))
2578 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
2579 contents
(cdr org-html-table-header-tags
)))
2580 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
2581 contents
(cdr org-html-table-data-tags
))))))
2586 (defun org-html-table-row (table-row contents info
)
2587 "Transcode a TABLE-ROW element from Org to HTML.
2588 CONTENTS is the contents of the row. INFO is a plist used as a
2589 communication channel."
2590 ;; Rules are ignored since table separators are deduced from
2591 ;; borders of the current row.
2592 (when (eq (org-element-property :type table-row
) 'standard
)
2593 (let* ((first-rowgroup-p (= 1 (org-export-table-row-group table-row info
)))
2596 ;; Case 1: Row belongs to second or subsequent rowgroups.
2597 ((not (= 1 (org-export-table-row-group table-row info
)))
2598 '("<tbody>" .
"\n</tbody>"))
2599 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
2600 ((org-export-table-has-header-p
2601 (org-export-get-parent-table table-row
) info
)
2602 '("<thead>" .
"\n</thead>"))
2603 ;; Case 2: Row is from first and only row group.
2604 (t '("<tbody>" .
"\n</tbody>")))))
2606 ;; Begin a rowgroup?
2607 (when (org-export-table-row-starts-rowgroup-p table-row info
)
2608 (car rowgroup-tags
))
2610 (concat "\n" (eval (car org-html-table-row-tags
))
2613 (eval (cdr org-html-table-row-tags
)))
2615 (when (org-export-table-row-ends-rowgroup-p table-row info
)
2616 (cdr rowgroup-tags
))))))
2621 (defun org-html-table-first-row-data-cells (table info
)
2623 (org-element-map table
'table-row
2625 (unless (eq (org-element-property :type row
) 'rule
) row
))
2627 (special-column-p (org-export-table-has-special-column-p table
)))
2628 (if (not special-column-p
) (org-element-contents table-row
)
2629 (cdr (org-element-contents table-row
)))))
2631 (defun org-html-table--table.el-table
(table info
)
2632 (when (eq (org-element-property :type table
) 'table.el
)
2634 (let ((outbuf (with-current-buffer
2635 (get-buffer-create "*org-export-table*")
2636 (erase-buffer) (current-buffer))))
2638 (insert (org-element-property :value table
))
2640 (re-search-forward "^[ \t]*|[^|]" nil t
)
2641 (table-generate-source 'html outbuf
))
2642 (with-current-buffer outbuf
2643 (prog1 (org-trim (buffer-string))
2646 (defun org-html-table (table contents info
)
2647 "Transcode a TABLE element from Org to HTML.
2648 CONTENTS is the contents of the table. INFO is a plist holding
2649 contextual information."
2650 (case (org-element-property :type table
)
2651 ;; Case 1: table.el table. Convert it using appropriate tools.
2652 (table.el
(org-html-table--table.el-table table info
))
2653 ;; Case 2: Standard table.
2655 (let* ((label (org-element-property :name table
))
2656 (caption (org-export-get-caption table
))
2657 (attributes (mapconcat #'identity
2658 (org-element-property :attr_html table
)
2661 (if (and (boundp 'org-html-format-table-no-css
)
2662 org-html-format-table-no-css
)
2663 "align=\"%s\"" "class=\"%s\""))
2666 (lambda (table info
)
2668 (lambda (table-cell)
2669 (let ((alignment (org-export-table-cell-alignment
2672 ;; Begin a colgroup?
2673 (when (org-export-table-cell-starts-colgroup-p
2676 ;; Add a column. Also specify it's alignment.
2677 (format "\n<col %s/>" (format alignspec alignment
))
2679 (when (org-export-table-cell-ends-colgroup-p
2682 (org-html-table-first-row-data-cells table info
) "\n"))))
2684 (let ((table-tag (plist-get info
:html-table-tag
)))
2686 (and (string-match "<table\\(.*\\)>" table-tag
)
2687 (match-string 1 table-tag
))
2688 (and label
(format " id=\"%s\""
2689 (org-export-solidify-link-text label
)))))))
2690 ;; Remove last blank line.
2691 (setq contents
(substring contents
0 -
1))
2692 (format "<table%s>\n%s\n%s\n%s\n</table>"
2694 (if (not caption
) ""
2695 (format "<caption>%s</caption>"
2696 (org-export-data caption info
)))
2697 (funcall table-column-specs table info
)
2703 (defun org-html-target (target contents info
)
2704 "Transcode a TARGET object from Org to HTML.
2705 CONTENTS is nil. INFO is a plist holding contextual
2707 (let ((id (org-export-solidify-link-text
2708 (org-element-property :value target
))))
2709 (org-html--anchor id
)))
2714 (defun org-html-timestamp (timestamp contents info
)
2715 "Transcode a TIMESTAMP object from Org to HTML.
2716 CONTENTS is nil. INFO is a plist holding contextual
2718 (let ((value (org-html-plain-text
2719 (org-timestamp-translate timestamp
) info
)))
2720 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
2721 (replace-regexp-in-string "--" "–" value
))))
2726 (defun org-html-underline (underline contents info
)
2727 "Transcode UNDERLINE from Org to HTML.
2728 CONTENTS is the text with underline markup. INFO is a plist
2729 holding contextual information."
2730 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
2736 (defun org-html-verbatim (verbatim contents info
)
2737 "Transcode VERBATIM from Org to HTML.
2738 CONTENTS is nil. INFO is a plist holding contextual
2740 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
2741 (org-element-property :value verbatim
)))
2746 (defun org-html-verse-block (verse-block contents info
)
2747 "Transcode a VERSE-BLOCK element from Org to HTML.
2748 CONTENTS is verse block contents. INFO is a plist holding
2749 contextual information."
2750 ;; Replace each newline character with line break. Also replace
2751 ;; each blank line with a line break.
2752 (setq contents
(replace-regexp-in-string
2753 "^ *\\\\\\\\$" "<br/>\n"
2754 (replace-regexp-in-string
2755 "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents
)))
2756 ;; Replace each white space at beginning of a line with a
2757 ;; non-breaking space.
2758 (while (string-match "^[ \t]+" contents
)
2759 (let* ((num-ws (length (match-string 0 contents
)))
2760 (ws (let (out) (dotimes (i num-ws out
)
2761 (setq out
(concat out
" "))))))
2762 (setq contents
(replace-match ws nil t contents
))))
2763 (format "<p class=\"verse\">\n%s</p>" contents
))
2767 ;;; Filter Functions
2769 (defun org-html-final-function (contents backend info
)
2770 (if (not org-html-pretty-output
) contents
2774 (indent-region (point-min) (point-max))
2775 (buffer-substring-no-properties (point-min) (point-max)))))
2779 ;;; End-user functions
2782 (defun org-html-export-as-html
2783 (&optional async subtreep visible-only body-only ext-plist
)
2784 "Export current buffer to an HTML buffer.
2786 If narrowing is active in the current buffer, only export its
2789 If a region is active, export that region.
2791 A non-nil optional argument ASYNC means the process should happen
2792 asynchronously. The resulting buffer should be accessible
2793 through the `org-export-stack' interface.
2795 When optional argument SUBTREEP is non-nil, export the sub-tree
2796 at point, extracting information from the headline properties
2799 When optional argument VISIBLE-ONLY is non-nil, don't export
2800 contents of hidden elements.
2802 When optional argument BODY-ONLY is non-nil, only write code
2803 between \"<body>\" and \"</body>\" tags.
2805 EXT-PLIST, when provided, is a property list with external
2806 parameters overriding Org default settings, but still inferior to
2807 file-local settings.
2809 Export is done in a buffer named \"*Org HTML Export*\", which
2810 will be displayed when `org-export-show-temporary-export-buffer'
2814 (org-export-async-start
2816 (with-current-buffer (get-buffer-create "*Org HTML Export*")
2819 (goto-char (point-min))
2821 (org-export-add-to-stack (current-buffer) 'html
)))
2822 `(org-export-as 'html
,subtreep
,visible-only
,body-only
',ext-plist
))
2823 (let ((outbuf (org-export-to-buffer
2824 'html
"*Org HTML Export*"
2825 subtreep visible-only body-only ext-plist
)))
2827 (with-current-buffer outbuf
(nxml-mode))
2828 (when org-export-show-temporary-export-buffer
2829 (switch-to-buffer-other-window outbuf
)))))
2832 (defun org-html-export-to-html
2833 (&optional async subtreep visible-only body-only ext-plist
)
2834 "Export current buffer to a HTML file.
2836 If narrowing is active in the current buffer, only export its
2839 If a region is active, export that region.
2841 A non-nil optional argument ASYNC means the process should happen
2842 asynchronously. The resulting file should be accessible through
2843 the `org-export-stack' interface.
2845 When optional argument SUBTREEP is non-nil, export the sub-tree
2846 at point, extracting information from the headline properties
2849 When optional argument VISIBLE-ONLY is non-nil, don't export
2850 contents of hidden elements.
2852 When optional argument BODY-ONLY is non-nil, only write code
2853 between \"<body>\" and \"</body>\" tags.
2855 EXT-PLIST, when provided, is a property list with external
2856 parameters overriding Org default settings, but still inferior to
2857 file-local settings.
2859 Return output file's name."
2861 (let* ((extension (concat "." org-html-extension
))
2862 (file (org-export-output-file-name extension subtreep
))
2863 (org-export-coding-system org-html-coding-system
))
2865 (org-export-async-start
2866 (lambda (f) (org-export-add-to-stack f
'html
))
2867 (let ((org-export-coding-system org-html-coding-system
))
2870 'html
,file
,subtreep
,visible-only
,body-only
',ext-plist
))))
2871 (let ((org-export-coding-system org-html-coding-system
))
2873 'html file subtreep visible-only body-only ext-plist
)))))
2876 (defun org-html-publish-to-html (plist filename pub-dir
)
2877 "Publish an org file to HTML.
2879 FILENAME is the filename of the Org file to be published. PLIST
2880 is the property list for the given project. PUB-DIR is the
2881 publishing directory.
2883 Return output file name."
2884 (org-publish-org-to 'html filename
".html" plist pub-dir
))
2890 ;;;; org-format-table-html
2891 ;;;; org-format-org-table-html
2892 ;;;; org-format-table-table-html
2893 ;;;; org-table-number-fraction
2894 ;;;; org-table-number-regexp
2895 ;;;; org-html-table-caption-above
2897 ;;;; org-html-with-timestamp
2898 ;;;; org-html-html-helper-timestamp
2900 ;;;; org-export-as-html-and-open
2901 ;;;; org-export-as-html-batch
2902 ;;;; org-export-as-html-to-buffer
2903 ;;;; org-replace-region-by-html
2904 ;;;; org-export-region-as-html
2905 ;;;; org-export-as-html
2907 ;;;; (org-export-directory :html opt-plist)
2908 ;;;; (plist-get opt-plist :html-extension)
2909 ;;;; org-html-toplevel-hlevel
2910 ;;;; org-html-special-string-regexps
2911 ;;;; org-html-inline-images
2912 ;;;; org-html-inline-image-extensions
2913 ;;;; org-html-protect-char-alist
2914 ;;;; org-html-table-use-header-tags-for-first-column
2915 ;;;; org-html-todo-kwd-class-prefix
2916 ;;;; org-html-tag-class-prefix
2917 ;;;; org-html-footnote-separator
2919 ;;;; org-export-preferred-target-alist
2920 ;;;; org-export-solidify-link-text
2921 ;;;; class for anchors
2922 ;;;; org-export-with-section-numbers, body-only
2923 ;;;; org-export-mark-todo-in-toc
2925 ;;;; org-html-format-org-link
2926 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
2927 ;;;; alt = (file-name-nondirectory path)
2929 ;;;; org-export-time-stamp-file'
2934 ;; generated-autoload-file: "org-loaddefs.el"
2937 ;;; ox-html.el ends here