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 ;; GNU Emacs 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 ;; GNU Emacs 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 GNU Emacs. 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"
262 (defcustom org-html-text-markup-alist
263 '((bold .
"<b>%s</b>")
264 (code .
"<code>%s</code>")
265 (italic .
"<i>%s</i>")
266 (strike-through .
"<del>%s</del>")
267 (underline .
"<span style=\"text-decoration:underline;\">%s</span>")
268 (verbatim .
"<code>%s</code>"))
269 "Alist of HTML expressions to convert text markup
271 The key must be a symbol among `bold', `code', `italic',
272 `strike-through', `underline' and `verbatim'. The value is
273 a formatting string to wrap fontified text with.
275 If no association can be found for a given markup, text will be
277 :group
'org-export-html
278 :type
'(alist :key-type
(symbol :tag
"Markup type")
279 :value-type
(string :tag
"Format string"))
280 :options
'(bold code italic strike-through underline verbatim
))
285 (defcustom org-html-pretty-output nil
286 "Enable this to generate pretty HTML."
287 :group
'org-export-html
293 (defcustom org-html-format-drawer-function nil
294 "Function called to format a drawer in HTML code.
296 The function must accept two parameters:
297 NAME the drawer name, like \"LOGBOOK\"
298 CONTENTS the contents of the drawer.
300 The function should return the string to be exported.
302 For example, the variable could be set to the following function
303 in order to mimic default behaviour:
305 \(defun org-html-format-drawer-default \(name contents\)
306 \"Format a drawer element for HTML export.\"
308 :group
'org-export-html
314 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
315 <h2 class=\"footnotes\">%s: </h2>
316 <div id=\"text-footnotes\">
320 "Format for the footnotes section.
321 Should contain a two instances of %s. The first will be replaced with the
322 language-specific word for \"Footnotes\", the second one will be replaced
323 by the footnotes themselves."
324 :group
'org-export-html
327 (defcustom org-html-footnote-format
"<sup>%s</sup>"
328 "The format for the footnote reference.
329 %s will be replaced by the footnote reference itself."
330 :group
'org-export-html
333 (defcustom org-html-footnote-separator
"<sup>, </sup>"
334 "Text used to separate footnotes."
335 :group
'org-export-html
341 (defcustom org-html-toplevel-hlevel
2
342 "The <H> level for level 1 headings in HTML export.
343 This is also important for the classes that will be wrapped around headlines
344 and outline structure. If this variable is 1, the top-level headlines will
345 be <h1>, and the corresponding classes will be outline-1, section-number-1,
346 and outline-text-1. If this is 2, all of these will get a 2 instead.
347 The default for this variable is 2, because we use <h1> for formatting the
349 :group
'org-export-html
352 (defcustom org-html-format-headline-function nil
353 "Function to format headline text.
355 This function will be called with 5 arguments:
356 TODO the todo keyword (string or nil).
357 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
358 PRIORITY the priority of the headline (integer or nil)
359 TEXT the main headline text (string).
360 TAGS the tags (string or nil).
362 The function result will be used in the section format string.
364 As an example, one could set the variable to the following, in
365 order to reproduce the default set-up:
367 \(defun org-html-format-headline \(todo todo-type priority text tags)
368 \"Default format function for an headline.\"
370 \(format \"\\\\textbf{\\\\textsc{\\\\textsf{%s}}} \" todo))
372 \(format \"\\\\framebox{\\\\#%c} \" priority))
374 \(when tags (format \"\\\\hfill{}\\\\textsc{%s}\" tags))))"
375 :group
'org-export-html
381 (defcustom org-html-allow-name-attribute-in-anchors t
382 "When nil, do not set \"name\" attribute in anchors.
383 By default, anchors are formatted with both \"id\" and \"name\"
384 attributes, when appropriate."
385 :group
'org-export-html
391 (defcustom org-html-format-inlinetask-function nil
392 "Function called to format an inlinetask in HTML code.
394 The function must accept six parameters:
395 TODO the todo keyword, as a string
396 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
397 PRIORITY the inlinetask priority, as a string
398 NAME the inlinetask name, as a string.
399 TAGS the inlinetask tags, as a list of strings.
400 CONTENTS the contents of the inlinetask, as a string.
402 The function should return the string to be exported.
404 For example, the variable could be set to the following function
405 in order to mimic default behaviour:
407 \(defun org-html-format-inlinetask \(todo type priority name tags contents\)
408 \"Format an inline task element for HTML export.\"
412 \(format \"\\\\textbf{\\\\textsf{\\\\textsc{%s}}} \" todo))
413 \(when priority (format \"\\\\framebox{\\\\#%c} \" priority))
415 \(when tags (format \"\\\\hfill{}\\\\textsc{%s}\" tags)))))
416 \(format (concat \"\\\\begin{center}\\n\"
418 \"\\\\begin{minipage}[c]{.6\\\\textwidth}\\n\"
420 \"\\\\rule[.8em]{\\\\textwidth}{2pt}\\n\\n\"
422 \"\\\\end{minipage}}\"
424 full-title contents))"
425 :group
'org-export-html
431 (defcustom org-html-with-latex org-export-with-latex
432 "Non-nil means process LaTeX math snippets.
434 When set, the exporter will process LaTeX environments and
437 This option can also be set with the +OPTIONS line,
438 e.g. \"tex:mathjax\". Allowed values are:
440 nil Ignore math snippets.
441 `verbatim' Keep everything in verbatim
442 `dvipng' Process the LaTeX fragments to images. This will also
443 include processing of non-math environments.
444 `imagemagick' Convert the LaTeX fragments to pdf files and use
445 imagemagick to convert pdf files to png files.
446 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
448 t Synonym for `mathjax'."
449 :group
'org-export-html
451 (const :tag
"Do not process math in any way" nil
)
452 (const :tag
"Use dvipng to make images" dvipng
)
453 (const :tag
"Use imagemagick to make images" imagemagick
)
454 (const :tag
"Use MathJax to display math" mathjax
)
455 (const :tag
"Leave math verbatim" verbatim
)))
458 ;;;; Links :: Generic
460 (defcustom org-html-link-org-files-as-html t
461 "Non-nil means make file links to `file.org' point to `file.html'.
462 When org-mode is exporting an org-mode file to HTML, links to
463 non-html files are directly put into a href tag in HTML.
464 However, links to other Org-mode files (recognized by the
465 extension `.org.) should become links to the corresponding html
466 file, assuming that the linked org-mode file will also be
468 When nil, the links still point to the plain `.org' file."
469 :group
'org-export-html
473 ;;;; Links :: Inline images
475 (defcustom org-html-inline-images
'maybe
476 "Non-nil means inline images into exported HTML pages.
477 This is done using an <img> tag. When nil, an anchor with href is used to
478 link to the image. If this option is `maybe', then images in links with
479 an empty description will be inlined, while images with a description will
481 :group
'org-export-html
482 :type
'(choice (const :tag
"Never" nil
)
483 (const :tag
"Always" t
)
484 (const :tag
"When there is no description" maybe
)))
486 (defcustom org-html-inline-image-rules
487 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
488 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
489 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
490 "Rules characterizing image files that can be inlined into HTML.
492 A rule consists in an association whose key is the type of link
493 to consider, and value is a regexp that will be matched against
496 Note that, by default, the image extension *actually* allowed
497 depend on the way the HTML file is processed. When used with
498 pdflatex, pdf, jpg and png images are OK. When processing
499 through dvi to Postscript, only ps and eps are allowed. The
500 default we use here encompasses both."
501 :group
'org-export-html
502 :type
'(alist :key-type
(string :tag
"Type")
503 :value-type
(regexp :tag
"Path")))
508 (defcustom org-html-protect-char-alist
512 "Alist of characters to be converted by `org-html-protect'."
513 :group
'org-export-html
514 :type
'(repeat (cons (string :tag
"Character")
515 (string :tag
"HTML equivalent"))))
520 (defcustom org-html-htmlize-output-type
'inline-css
521 "Output type to be used by htmlize when formatting code snippets.
522 Choices are `css', to export the CSS selectors only, or `inline-css', to
523 export the CSS attribute values inline in the HTML. We use as default
524 `inline-css', in order to make the resulting HTML self-containing.
526 However, this will fail when using Emacs in batch mode for export, because
527 then no rich font definitions are in place. It will also not be good if
528 people with different Emacs setup contribute HTML files to a website,
529 because the fonts will represent the individual setups. In these cases,
530 it is much better to let Org/Htmlize assign classes only, and to use
531 a style file to define the look of these classes.
532 To get a start for your css file, start Emacs session and make sure that
533 all the faces you are interested in are defined, for example by loading files
534 in all modes you want. Then, use the command
535 \\[org-html-htmlize-generate-css] to extract class definitions."
536 :group
'org-export-html
537 :type
'(choice (const css
) (const inline-css
)))
539 (defcustom org-html-htmlize-font-prefix
"org-"
540 "The prefix for CSS class names for htmlize font specifications."
541 :group
'org-export-html
544 (defcustom org-html-htmlized-org-css-url nil
545 "URL pointing to a CSS file defining text colors for htmlized Emacs buffers.
546 Normally when creating an htmlized version of an Org buffer, htmlize will
547 create CSS to define the font colors. However, this does not work when
548 converting in batch mode, and it also can look bad if different people
549 with different fontification setup work on the same website.
550 When this variable is non-nil, creating an htmlized version of an Org buffer
551 using `org-export-as-org' will remove the internal CSS section and replace it
552 with a link to this URL."
553 :group
'org-export-html
555 (const :tag
"Keep internal css" nil
)
556 (string :tag
"URL or local href")))
561 (defcustom org-html-table-tag
562 "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
563 "The HTML tag that is used to start a table.
564 This must be a <table> tag, but you may change the options like
565 borders and spacing."
566 :group
'org-export-html
569 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
570 "The opening tag for table header fields.
571 This is customizable so that alignment options can be specified.
572 The first %s will be filled with the scope of the field, either row or col.
573 The second %s will be replaced by a style entry to align the field.
574 See also the variable `org-html-table-use-header-tags-for-first-column'.
575 See also the variable `org-html-table-align-individual-fields'."
576 :group
'org-export-html
577 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
579 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
580 "The opening tag for table data fields.
581 This is customizable so that alignment options can be specified.
582 The first %s will be filled with the scope of the field, either row or col.
583 The second %s will be replaced by a style entry to align the field.
584 See also the variable `org-html-table-align-individual-fields'."
585 :group
'org-export-html
586 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
588 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
589 "The opening tag for table data fields.
590 This is customizable so that alignment options can be specified.
591 Instead of strings, these can be Lisp forms that will be evaluated
592 for each row in order to construct the table row tags. During evaluation,
593 the variable `head' will be true when this is a header line, nil when this
594 is a body line. And the variable `nline' will contain the line number,
595 starting from 1 in the first header line. For example
597 (setq org-html-table-row-tags
600 (if (= (mod nline 2) 1)
601 \"<tr class=\\\"tr-odd\\\">\"
602 \"<tr class=\\\"tr-even\\\">\"))
605 will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
606 :group
'org-export-html
608 (choice :tag
"Opening tag"
609 (string :tag
"Specify")
611 (choice :tag
"Closing tag"
612 (string :tag
"Specify")
615 (defcustom org-html-table-align-individual-fields t
616 "Non-nil means attach style attributes for alignment to each table field.
617 When nil, alignment will only be specified in the column tags, but this
618 is ignored by some browsers (like Firefox, Safari). Opera does it right
620 :group
'org-export-html
623 (defcustom org-html-table-use-header-tags-for-first-column nil
624 "Non-nil means format column one in tables with header tags.
625 When nil, also column one will use data tags."
626 :group
'org-export-html
629 (defcustom org-html-table-caption-above t
630 "When non-nil, place caption string at the beginning of the table.
631 Otherwise, place it near the end."
632 :group
'org-export-html
638 (defcustom org-html-tag-class-prefix
""
639 "Prefix to class names for TODO keywords.
640 Each tag gets a class given by the tag itself, with this prefix.
641 The default prefix is empty because it is nice to just use the keyword
642 as a class name. But if you get into conflicts with other, existing
643 CSS classes, then this prefix can be very useful."
644 :group
'org-export-html
648 ;;;; Template :: Generic
650 (defcustom org-html-extension
"html"
651 "The extension for exported HTML files."
652 :group
'org-export-html
655 (defcustom org-html-xml-declaration
656 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
657 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
658 "The extension for exported HTML files.
659 %s will be replaced with the charset of the exported file.
660 This may be a string, or an alist with export extensions
661 and corresponding declarations."
662 :group
'org-export-html
664 (string :tag
"Single declaration")
665 (repeat :tag
"Dependent on extension"
666 (cons (string :tag
"Extension")
667 (string :tag
"Declaration")))))
669 (defcustom org-html-coding-system
'utf-8
670 "Coding system for HTML export.
671 Use utf-8 as the default value."
672 :group
'org-export-html
673 :type
'coding-system
)
675 (defcustom org-html-divs
'("preamble" "content" "postamble")
676 "The name of the main divs for HTML export.
677 This is a list of three strings, the first one for the preamble
678 DIV, the second one for the content DIV and the third one for the
680 :group
'org-export-html
682 (string :tag
" Div for the preamble:")
683 (string :tag
" Div for the content:")
684 (string :tag
"Div for the postamble:")))
687 ;;;; Template :: Mathjax
689 (defcustom org-html-mathjax-options
690 '((path "http://orgmode.org/mathjax/MathJax.js")
695 "Options for MathJax setup.
697 path The path where to find MathJax
698 scale Scaling for the HTML-CSS backend, usually between 100 and 133
699 align How to align display math: left, center, or right
700 indent If align is not center, how far from the left/right side?
701 mathml Should a MathML player be used if available?
702 This is faster and reduces bandwidth use, but currently
703 sometimes has lower spacing quality. Therefore, the default is
704 nil. When browsers get better, this switch can be flipped.
706 You can also customize this for each buffer, using something like
708 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
709 :group
'org-export-html
710 :type
'(list :greedy t
711 (list :tag
"path (the path from where to load MathJax.js)"
712 (const :format
" " path
) (string))
713 (list :tag
"scale (scaling for the displayed math)"
714 (const :format
" " scale
) (string))
715 (list :tag
"align (alignment of displayed equations)"
716 (const :format
" " align
) (string))
717 (list :tag
"indent (indentation with left or right alignment)"
718 (const :format
" " indent
) (string))
719 (list :tag
"mathml (should MathML display be used is possible)"
720 (const :format
" " mathml
) (boolean))))
722 (defcustom org-html-mathjax-template
723 "<script type=\"text/javascript\" src=\"%PATH\">
724 <!--/*--><![CDATA[/*><!--*/
726 // Only one of the two following lines, depending on user settings
727 // First allows browser-native MathML display, second forces HTML/CSS
728 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
729 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
730 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
731 \"TeX/noUndefined.js\"],
733 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
734 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
735 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
736 ignoreClass: \"tex2jax_ignore\",
737 processEscapes: false,
738 processEnvironments: true,
741 showProcessingMessages: true,
742 displayAlign: \"%ALIGN\",
743 displayIndent: \"%INDENT\",
747 availableFonts: [\"STIX\",\"TeX\"],
748 preferredFont: \"TeX\",
764 "The MathJax setup for XHTML files."
765 :group
'org-export-html
769 ;;;; Template :: Postamble
771 (defcustom org-html-postamble
'auto
772 "Non-nil means insert a postamble in HTML export.
774 When `t', insert a string as defined by the formatting string in
775 `org-html-postamble-format'. When set to a string, this
776 string overrides `org-html-postamble-format'. When set to
777 'auto, discard `org-html-postamble-format' and honor
778 `org-export-author/email/creator-info' variables. When set to a
779 function, apply this function and insert the returned string.
780 The function takes the property list of export options as its
783 Setting :html-postamble in publishing projects will take
784 precedence over this variable."
785 :group
'org-export-html
786 :type
'(choice (const :tag
"No postamble" nil
)
787 (const :tag
"Auto preamble" 'auto
)
788 (const :tag
"Default formatting string" t
)
789 (string :tag
"Custom formatting string")
790 (function :tag
"Function (must return a string)")))
792 (defcustom org-html-postamble-format
793 '(("en" "<p class=\"author\">Author: %a (%e)</p>
794 <p class=\"date\">Date: %d</p>
795 <p class=\"creator\">Generated by %c</p>
796 <p class=\"xhtml-validation\">%v</p>"))
797 "Alist of languages and format strings for the HTML postamble.
799 The first element of each list is the language code, as used for
800 the #+LANGUAGE keyword.
802 The second element of each list is a format string to format the
803 postamble itself. This format string can contain these elements:
805 %a stands for the author's name.
806 %e stands for the author's email.
807 %d stands for the date.
808 %c will be replaced by information about Org/Emacs versions.
809 %v will be replaced by `org-html-validation-link'.
811 If you need to use a \"%\" character, you need to escape it
813 :group
'org-export-html
814 :type
'(alist :key-type
(string :tag
"Language")
815 :value-type
(string :tag
"Format string")))
817 (defcustom org-html-validation-link
818 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
819 "Link to HTML validation service."
820 :group
'org-export-html
823 (defcustom org-html-creator-string
824 (format "Generated by <a href=\"http://orgmode.org\">Org</a> mode %s in <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s."
825 (if (fboundp 'org-version
) (org-version) "(Unknown)")
827 "String to insert at the end of the HTML document."
828 :group
'org-export-html
829 :type
'(string :tag
"Creator string"))
832 ;;;; Template :: Preamble
834 (defcustom org-html-preamble t
835 "Non-nil means insert a preamble in HTML export.
837 When `t', insert a string as defined by one of the formatting
838 strings in `org-html-preamble-format'. When set to a
839 string, this string overrides `org-html-preamble-format'.
840 When set to a function, apply this function and insert the
841 returned string. The function takes the property list of export
842 options as its only argument.
844 Setting :html-preamble in publishing projects will take
845 precedence over this variable."
846 :group
'org-export-html
847 :type
'(choice (const :tag
"No preamble" nil
)
848 (const :tag
"Default preamble" t
)
849 (string :tag
"Custom formatting string")
850 (function :tag
"Function (must return a string)")))
852 (defcustom org-html-preamble-format
'(("en" ""))
853 "Alist of languages and format strings for the HTML preamble.
855 The first element of each list is the language code, as used for
856 the #+LANGUAGE keyword.
858 The second element of each list is a format string to format the
859 preamble itself. This format string can contain these elements:
861 %t stands for the title.
862 %a stands for the author's name.
863 %e stands for the author's email.
864 %d stands for the date.
866 If you need to use a \"%\" character, you need to escape it
868 :group
'org-export-html
869 :type
'(alist :key-type
(string :tag
"Language")
870 :value-type
(string :tag
"Format string")))
872 (defcustom org-html-link-up
""
873 "Where should the \"UP\" link of exported HTML pages lead?"
874 :group
'org-export-html
875 :type
'(string :tag
"File or URL"))
877 (defcustom org-html-link-home
""
878 "Where should the \"HOME\" link of exported HTML pages lead?"
879 :group
'org-export-html
880 :type
'(string :tag
"File or URL"))
882 (defcustom org-html-home
/up-format
883 "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
884 <a accesskey=\"h\" href=\"%s\"> UP </a>
886 <a accesskey=\"H\" href=\"%s\"> HOME </a>
888 "Snippet used to insert the HOME and UP links.
889 This is a format string, the first %s will receive the UP link,
890 the second the HOME link. If both `org-html-link-up' and
891 `org-html-link-home' are empty, the entire snippet will be
893 :group
'org-export-html
897 ;;;; Template :: Scripts
899 (defcustom org-html-style-include-scripts t
900 "Non-nil means include the JavaScript snippets in exported HTML files.
901 The actual script is defined in `org-html-scripts' and should
903 :group
'org-export-html
907 ;;;; Template :: Styles
909 (defcustom org-html-style-include-default t
910 "Non-nil means include the default style in exported HTML files.
911 The actual style is defined in `org-html-style-default' and should
912 not be modified. Use the variables `org-html-style' to add
913 your own style information."
914 :group
'org-export-html
917 (put 'org-html-style-include-default
'safe-local-variable
'booleanp
)
919 (defcustom org-html-style
""
920 "Org-wide style definitions for exported HTML files.
922 This variable needs to contain the full HTML structure to provide a style,
923 including the surrounding HTML tags. If you set the value of this variable,
924 you should consider to include definitions for the following classes:
925 title, todo, done, timestamp, timestamp-kwd, tag, target.
927 For example, a valid value would be:
929 <style type=\"text/css\">
931 p { font-weight: normal; color: gray; }
933 .title { text-align: center; }
934 .todo, .timestamp-kwd { color: red; }
935 .done { color: green; }
939 If you'd like to refer to an external style file, use something like
941 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
943 As the value of this option simply gets inserted into the HTML <head> header,
944 you can \"misuse\" it to add arbitrary text to the header.
945 See also the variable `org-html-style-extra'."
946 :group
'org-export-html
949 (put 'org-html-style
'safe-local-variable
'stringp
)
951 (defcustom org-html-style-extra
""
952 "Additional style information for HTML export.
953 The value of this variable is inserted into the HTML buffer right after
954 the value of `org-html-style'. Use this variable for per-file
955 settings of style information, and do not forget to surround the style
956 settings with <style>...</style> tags."
957 :group
'org-export-html
960 (put 'org-html-style-extra
'safe-local-variable
'stringp
)
965 (defcustom org-html-todo-kwd-class-prefix
""
966 "Prefix to class names for TODO keywords.
967 Each TODO keyword gets a class given by the keyword itself, with this prefix.
968 The default prefix is empty because it is nice to just use the keyword
969 as a class name. But if you get into conflicts with other, existing
970 CSS classes, then this prefix can be very useful."
971 :group
'org-export-html
974 (defcustom org-html-display-buffer-mode
'html-mode
975 "Default mode when visiting the HTML output."
976 :group
'org-export-html
978 :type
'(choice (function 'html-mode
)
979 (function 'nxml-mode
)
980 (function :tag
"Other mode")))
984 ;;; Internal Functions
986 (defun org-html-format-inline-image (src &optional
987 caption label attr standalone-p
)
988 (let* ((id (if (not label
) ""
989 (format " id=\"%s\"" (org-export-solidify-link-text label
))))
992 ((string-match "\\<alt=" (or attr
"")) "")
993 ((string-match "^ltxpng/" src
)
994 (format " alt=\"%s\""
995 (org-html-encode-plain-text
996 (org-find-text-property-in-string
997 'org-latex-src src
))))
998 (t (format " alt=\"%s\""
999 (file-name-nondirectory src
)))))))
1002 (let ((img (format "<img src=\"%s\" %s/>" src attr
)))
1003 (format "\n<div%s class=\"figure\">%s%s\n</div>"
1004 id
(format "\n<p>%s</p>" img
)
1005 (when caption
(format "\n<p>%s</p>" caption
)))))
1006 (t (format "<img src=\"%s\" %s/>" src
(concat attr id
))))))
1008 (defun org-html--textarea-block (element)
1009 "Transcode ELEMENT into a textarea block.
1010 ELEMENT is either a src block or an example block."
1011 (let ((code (car (org-export-unravel-code element
)))
1012 (attr (org-export-read-attribute :attr_html element
)))
1013 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>"
1014 (or (plist-get attr
:width
) 80)
1015 (or (plist-get attr
:height
) (org-count-lines code
))
1021 (defun org-html-bibliography ()
1022 "Find bibliography, cut it out and return it."
1024 (let (beg end
(cnt 1) bib
)
1026 (goto-char (point-min))
1027 (when (re-search-forward
1028 "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t
)
1029 (setq beg
(match-beginning 0))
1030 (while (re-search-forward "</?div\\>" nil t
)
1031 (setq cnt
(+ cnt
(if (string= (match-string 0) "<div") +1 -
1)))
1033 (and (looking-at ">") (forward-char 1))
1034 (setq bib
(buffer-substring beg
(point)))
1035 (delete-region beg
(point))
1036 (throw 'exit bib
))))
1041 (defun org-html-splice-attributes (tag attributes
)
1042 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
1043 (if (not attributes
)
1045 (let (oldatt newatt
)
1046 (setq oldatt
(org-extract-attributes-from-string tag
)
1048 newatt
(cdr (org-extract-attributes-from-string attributes
)))
1050 (setq oldatt
(plist-put oldatt
(pop newatt
) (pop newatt
))))
1051 (if (string-match ">" tag
)
1053 (replace-match (concat (org-attributes-to-string oldatt
) ">")
1057 (defun org-export-splice-style (style extra
)
1058 "Splice EXTRA into STYLE, just before \"</style>\"."
1059 (if (and (stringp extra
)
1060 (string-match "\\S-" extra
)
1061 (string-match "</style>" style
))
1062 (concat (substring style
0 (match-beginning 0))
1064 (substring style
(match-beginning 0)))
1067 (defun org-html-htmlize-region-for-paste (beg end
)
1068 "Convert the region to HTML, using htmlize.el.
1069 This is much like `htmlize-region-for-paste', only that it uses
1070 the settings define in the org-... variables."
1071 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1072 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1073 (htmlbuf (htmlize-region beg end
)))
1075 (with-current-buffer htmlbuf
1076 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1077 (plist-get htmlize-buffer-places
'content-end
)))
1078 (kill-buffer htmlbuf
))))
1081 (defun org-html-htmlize-generate-css ()
1082 "Create the CSS for all font definitions in the current Emacs session.
1083 Use this to create face definitions in your CSS style file that can then
1084 be used by code snippets transformed by htmlize.
1085 This command just produces a buffer that contains class definitions for all
1086 faces used in the current Emacs session. You can copy and paste the ones you
1087 need into your CSS file.
1089 If you then set `org-html-htmlize-output-type' to `css', calls
1090 to the function `org-html-htmlize-region-for-paste' will
1091 produce code that uses these same face definitions."
1094 (and (get-buffer "*html*") (kill-buffer "*html*"))
1096 (let ((fl (face-list))
1097 (htmlize-css-name-prefix "org-")
1098 (htmlize-output-type 'css
)
1100 (while (setq f
(pop fl
)
1101 i
(and f
(face-attribute f
:inherit
)))
1102 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1103 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1104 (htmlize-region (point-min) (point-max))))
1105 (org-pop-to-buffer-same-window "*html*")
1106 (goto-char (point-min))
1107 (if (re-search-forward "<style" nil t
)
1108 (delete-region (point-min) (match-beginning 0)))
1109 (if (re-search-forward "</style>" nil t
)
1110 (delete-region (1+ (match-end 0)) (point-max)))
1111 (beginning-of-line 1)
1112 (if (looking-at " +") (replace-match ""))
1113 (goto-char (point-min)))
1115 (defun org-html--make-string (n string
)
1116 "Build a string by concatenating N times STRING."
1117 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1119 (defun org-html-toc-text (toc-entries)
1120 (let* ((prev-level (1- (nth 1 (car toc-entries
))))
1121 (start-level prev-level
))
1125 (let ((headline (nth 0 entry
))
1126 (level (nth 1 entry
)))
1128 (let* ((cnt (- level prev-level
))
1129 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1131 (setq prev-level level
)
1133 (org-html--make-string
1134 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1135 ((< cnt
0) "</li>\n</ul>\n")))
1136 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1139 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
1141 (defun* org-html-format-toc-headline
1142 (todo todo-type priority text tags
1143 &key level section-number headline-label
&allow-other-keys
)
1144 (let ((headline (concat
1145 section-number
(and section-number
". ")
1147 (and tags
" ") (org-html--tags tags
))))
1148 (format "<a href=\"#%s\">%s</a>"
1149 (org-export-solidify-link-text headline-label
)
1150 (if (not nil
) headline
1151 (format "<span class=\"%s\">%s</span>" todo-type headline
)))))
1153 (defun org-html-toc (depth info
)
1154 (let* ((headlines (org-export-collect-headlines info depth
))
1156 (loop for headline in headlines collect
1157 (list (org-html-format-headline--wrap
1158 headline info
'org-html-format-toc-headline
)
1159 (org-export-get-relative-level headline info
)))))
1162 "<div id=\"table-of-contents\">\n"
1163 (format "<h%d>%s</h%d>\n"
1164 org-html-toplevel-hlevel
1165 (org-html--translate "Table of Contents" info
)
1166 org-html-toplevel-hlevel
)
1167 "<div id=\"text-table-of-contents\">"
1168 (org-html-toc-text toc-entries
)
1172 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1173 "Turn todo keyword into a valid class name.
1174 Replaces invalid characters with \"_\"."
1176 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1177 (setq kwd
(replace-match "_" t t kwd
))))
1180 (defun org-html-format-footnote-reference (n def refcnt
)
1181 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1182 (format org-html-footnote-format
1183 (let* ((id (format "fnr.%s%s" n extra
))
1184 (href (format " href=\"#fn.%s\"" n
))
1185 (attributes (concat " class=\"footref\"" href
)))
1186 (org-html--anchor id n attributes
)))))
1188 (defun org-html-format-footnotes-section (section-name definitions
)
1189 (if (not definitions
) ""
1190 (format org-html-footnotes-section section-name definitions
)))
1192 (defun org-html-format-footnote-definition (fn)
1193 (let ((n (car fn
)) (def (cdr fn
)))
1195 "<tr>\n<td>%s</td>\n<td>%s</td>\n</tr>\n"
1196 (format org-html-footnote-format
1197 (let* ((id (format "fn.%s" n
))
1198 (href (format " href=\"#fnr.%s\"" n
))
1199 (attributes (concat " class=\"footnum\"" href
)))
1200 (org-html--anchor id n attributes
)))
1203 (defun org-html-footnote-section (info)
1204 (let* ((fn-alist (org-export-collect-footnote-definitions
1205 (plist-get info
:parse-tree
) info
))
1208 (loop for
(n type raw
) in fn-alist collect
1209 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1210 (org-trim (org-export-data raw info
))
1212 (org-trim (org-export-data raw info
))))))))
1214 (org-html-format-footnotes-section
1215 (org-html--translate "Footnotes" info
)
1217 "<table>\n%s\n</table>\n"
1218 (mapconcat 'org-html-format-footnote-definition fn-alist
"\n"))))))
1224 (defun org-html--build-meta-info (info)
1225 "Return meta tags for exported document.
1226 INFO is a plist used as a communication channel."
1227 (let* ((title (org-export-data (plist-get info
:title
) info
))
1228 (author (and (plist-get info
:with-author
)
1229 (let ((auth (plist-get info
:author
)))
1230 (and auth
(org-export-data auth info
)))))
1231 (date (and (plist-get info
:with-date
)
1232 (let ((date (plist-get info
:date
)))
1233 (and date
(org-export-data date info
)))))
1234 (description (plist-get info
:description
))
1235 (keywords (plist-get info
:keywords
)))
1237 (format "<title>%s</title>\n" title
)
1239 "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>\n"
1240 (or (and org-html-coding-system
1241 (fboundp 'coding-system-get
)
1242 (coding-system-get org-html-coding-system
'mime-charset
))
1244 (format "<meta name=\"title\" content=\"%s\"/>\n" title
)
1245 (format "<meta name=\"generator\" content=\"Org-mode\"/>\n")
1246 (and date
(format "<meta name=\"generated\" content=\"%s\"/>\n" date
))
1247 (and author
(format "<meta name=\"author\" content=\"%s\"/>\n" author
))
1249 (format "<meta name=\"description\" content=\"%s\"/>\n" description
))
1251 (format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords
)))))
1253 (defun org-html--build-style (info)
1254 "Return style information for exported document.
1255 INFO is a plist used as a communication channel."
1256 (org-element-normalize-string
1258 (when (plist-get info
:html-style-include-default
) org-html-style-default
)
1259 (org-element-normalize-string (plist-get info
:html-style
))
1260 (org-element-normalize-string (plist-get info
:html-style-extra
))
1261 (when (plist-get info
:html-style-include-scripts
) org-html-scripts
))))
1263 (defun org-html--build-mathjax-config (info)
1264 "Insert the user setup into the mathjax template.
1265 INFO is a plist used as a communication channel."
1266 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1267 (org-element-map (plist-get info
:parse-tree
)
1268 '(latex-fragment latex-environment
) 'identity info t
))
1269 (let ((template org-html-mathjax-template
)
1270 (options org-html-mathjax-options
)
1271 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1272 name val
(yes " ") (no "// ") x
)
1275 (setq name
(car e
) val
(nth 1 e
))
1276 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1277 (setq val
(car (read-from-string
1278 (substring in-buffer
(match-end 0))))))
1279 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1280 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1281 (setq template
(replace-match val t t template
))))
1283 (setq val
(nth 1 (assq 'mathml options
)))
1284 (if (string-match (concat "\\<mathml:") in-buffer
)
1285 (setq val
(car (read-from-string
1286 (substring in-buffer
(match-end 0))))))
1287 ;; Exchange prefixes depending on mathml setting.
1288 (if (not val
) (setq x yes yes no no x
))
1289 ;; Replace cookies to turn on or off the config/jax lines.
1290 (if (string-match ":MMLYES:" template
)
1291 (setq template
(replace-match yes t t template
)))
1292 (if (string-match ":MMLNO:" template
)
1293 (setq template
(replace-match no t t template
)))
1294 ;; Return the modified template.
1295 (org-element-normalize-string template
))))
1297 (defun org-html--build-preamble (info)
1298 "Return document preamble as a string, or nil.
1299 INFO is a plist used as a communication channel."
1300 (let ((preamble (plist-get info
:html-preamble
)))
1302 (let ((preamble-contents
1303 (if (functionp preamble
) (funcall preamble info
)
1304 (let ((title (org-export-data (plist-get info
:title
) info
))
1305 (date (if (not (plist-get info
:with-date
)) ""
1306 (org-export-data (plist-get info
:date
) info
)))
1307 (author (if (not (plist-get info
:with-author
)) ""
1308 (org-export-data (plist-get info
:author
) info
)))
1309 (email (if (not (plist-get info
:with-email
)) ""
1310 (plist-get info
:email
))))
1311 (if (stringp preamble
)
1312 (format-spec preamble
1313 `((?t .
,title
) (?a .
,author
)
1314 (?d .
,date
) (?e .
,email
)))
1316 (or (cadr (assoc (plist-get info
:language
)
1317 org-html-preamble-format
))
1318 (cadr (assoc "en" org-html-preamble-format
)))
1319 `((?t .
,title
) (?a .
,author
)
1320 (?d .
,date
) (?e .
,email
))))))))
1321 (when (org-string-nw-p preamble-contents
)
1322 (concat (format "<div id=\"%s\">\n" (nth 0 org-html-divs
))
1323 (org-element-normalize-string preamble-contents
)
1326 (defun org-html--build-postamble (info)
1327 "Return document postamble as a string, or nil.
1328 INFO is a plist used as a communication channel."
1329 (let ((postamble (plist-get info
:html-postamble
)))
1331 (let ((postamble-contents
1332 (if (functionp postamble
) (funcall postamble info
)
1333 (let ((date (if (not (plist-get info
:with-date
)) ""
1334 (org-export-data (plist-get info
:date
) info
)))
1335 (author (let ((author (plist-get info
:author
)))
1336 (and author
(org-export-data author info
))))
1339 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1340 (split-string (plist-get info
:email
) ",+ *")
1342 (html-validation-link (or org-html-validation-link
""))
1343 (creator-info (plist-get info
:creator
)))
1344 (cond ((stringp postamble
)
1345 (format-spec postamble
1346 `((?a .
,author
) (?e .
,email
)
1347 (?d .
,date
) (?c .
,creator-info
)
1348 (?v .
,html-validation-link
))))
1349 ((eq postamble
'auto
)
1351 (when (plist-get info
:time-stamp-file
)
1352 (format "<p class=\"date\">%s: %s</p>\n"
1353 (org-html--translate "Date" info
)
1355 (when (and (plist-get info
:with-author
) author
)
1356 (format "<p class=\"author\">%s : %s</p>\n"
1357 (org-html--translate "Author" info
)
1359 (when (and (plist-get info
:with-email
) email
)
1360 (format "<p class=\"email\">%s </p>\n" email
))
1361 (when (plist-get info
:with-creator
)
1362 (format "<p class=\"creator\">%s</p>\n"
1364 html-validation-link
"\n"))
1366 (or (cadr (assoc (plist-get info
:language
)
1367 org-html-postamble-format
))
1368 (cadr (assoc "en" org-html-postamble-format
)))
1369 `((?a .
,author
) (?e .
,email
)
1370 (?d .
,date
) (?c .
,creator-info
)
1371 (?v .
,html-validation-link
)))))))))
1372 (when (org-string-nw-p postamble-contents
)
1374 (format "<div id=\"%s\">\n" (nth 2 org-html-divs
))
1375 (org-element-normalize-string postamble-contents
)
1378 (defun org-html-inner-template (contents info
)
1379 "Return body of document string after HTML conversion.
1380 CONTENTS is the transcoded contents string. INFO is a plist
1381 holding export options."
1383 (format "<div id=\"%s\">\n" (nth 1 org-html-divs
))
1385 (format "<h1 class=\"title\">%s</h1>\n"
1386 (org-export-data (plist-get info
:title
) info
))
1387 ;; Table of contents.
1388 (let ((depth (plist-get info
:with-toc
)))
1389 (when depth
(org-html-toc depth info
)))
1390 ;; Document contents.
1392 ;; Footnotes section.
1393 (org-html-footnote-section info
)
1395 (org-html-bibliography)
1398 (defun org-html-template (contents info
)
1399 "Return complete document string after HTML conversion.
1400 CONTENTS is the transcoded contents string. INFO is a plist
1401 holding export options."
1404 (or (and (stringp org-html-xml-declaration
)
1405 org-html-xml-declaration
)
1406 (cdr (assoc (plist-get info
:html-extension
)
1407 org-html-xml-declaration
))
1408 (cdr (assoc "html" org-html-xml-declaration
))
1411 (or (and org-html-coding-system
1412 (fboundp 'coding-system-get
)
1413 (coding-system-get org-html-coding-system
'mime-charset
))
1416 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
1417 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
1418 (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n"
1419 (plist-get info
:language
) (plist-get info
:language
))
1421 (org-html--build-meta-info info
)
1422 (org-html--build-style info
)
1423 (org-html--build-mathjax-config info
)
1426 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1427 (link-home (org-trim (plist-get info
:html-link-home
))))
1428 (unless (and (string= link-up
"") (string= link-up
""))
1429 (format org-html-home
/up-format
1430 (or link-up link-home
)
1431 (or link-home link-up
))))
1433 (org-html--build-preamble info
)
1434 ;; Document contents.
1437 (org-html--build-postamble info
)
1438 ;; Closing document.
1439 "</body>\n</html>"))
1441 (defun org-html--translate (s info
)
1442 "Translate string S according to specified language.
1443 INFO is a plist used as a communication channel."
1444 (org-export-translate s
:html info
))
1448 (defun org-html--anchor (&optional id desc attributes
)
1449 (let* ((name (and org-html-allow-name-attribute-in-anchors id
))
1450 (attributes (concat (and id
(format " id=\"%s\"" id
))
1451 (and name
(format " name=\"%s\"" name
))
1453 (format "<a%s>%s</a>" attributes
(or desc
""))))
1457 (defun org-html--todo (todo)
1459 (format "<span class=\"%s %s%s\">%s</span>"
1460 (if (member todo org-done-keywords
) "done" "todo")
1461 org-html-todo-kwd-class-prefix
(org-html-fix-class-name todo
)
1466 (defun org-html--tags (tags)
1468 (format "<span class=\"tag\">%s</span>"
1471 (format "<span class=\"%s\">%s</span>"
1472 (concat org-html-tag-class-prefix
1473 (org-html-fix-class-name tag
))
1479 (defun* org-html-format-headline
1480 (todo todo-type priority text tags
1481 &key level section-number headline-label
&allow-other-keys
)
1482 (let ((section-number
1483 (when section-number
1484 (format "<span class=\"section-number-%d\">%s</span> "
1485 level section-number
)))
1486 (todo (org-html--todo todo
))
1487 (tags (org-html--tags tags
)))
1488 (concat section-number todo
(and todo
" ") text
1489 (and tags
" ") tags
)))
1493 (defun org-html-fontify-code (code lang
)
1494 "Color CODE with htmlize library.
1495 CODE is a string representing the source code to colorize. LANG
1496 is the language used for CODE, as a string, or nil."
1499 ;; Case 1: No lang. Possibly an example block.
1501 ;; Simple transcoding.
1502 (org-html-encode-plain-text code
))
1503 ;; Case 2: No htmlize or an inferior version of htmlize
1504 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1506 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1507 ;; Simple transcoding.
1508 (org-html-encode-plain-text code
))
1511 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1512 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1514 ;; Case 1: Language is not associated with any Emacs mode
1515 ((not (functionp lang-mode
))
1516 ;; Simple transcoding.
1517 (org-html-encode-plain-text code
))
1518 ;; Case 2: Default. Fontify code.
1521 (setq code
(with-temp-buffer
1522 ;; Switch to language-specific mode.
1526 (font-lock-fontify-buffer)
1527 ;; Remove formatting on newline characters.
1529 (let ((beg (point-min))
1532 (while (progn (end-of-line) (< (point) end
))
1533 (put-text-property (point) (1+ (point)) 'face nil
)
1536 (set-buffer-modified-p nil
)
1538 (org-html-htmlize-region-for-paste
1539 (point-min) (point-max))))
1540 ;; Strip any encolosing <pre></pre> tags.
1541 (if (string-match "<pre[^>]*>\n*\\([^\000]*\\)</pre>" code
)
1542 (match-string 1 code
)
1545 (defun org-html-do-format-code
1546 (code &optional lang refs retain-labels num-start
)
1547 "Format CODE string as source code.
1548 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1549 respectively, the language of the source code, as a string, an
1550 alist between line numbers and references (as returned by
1551 `org-export-unravel-code'), a boolean specifying if labels should
1552 appear in the source code, and the number associated to the first
1554 (let* ((code-lines (org-split-string code
"\n"))
1555 (code-length (length code-lines
))
1559 (length (number-to-string (+ code-length num-start
))))))
1560 (code (org-html-fontify-code code lang
)))
1561 (org-export-format-code
1563 (lambda (loc line-num ref
)
1566 ;; Add line number, if needed.
1568 (format "<span class=\"linenr\">%s</span>"
1569 (format num-fmt line-num
)))
1570 ;; Transcoded src line.
1572 ;; Add label, if needed.
1573 (when (and ref retain-labels
) (format " (%s)" ref
))))
1574 ;; Mark transcoded line as an anchor, if needed.
1576 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1580 (defun org-html-format-code (element info
)
1581 "Format contents of ELEMENT as source code.
1582 ELEMENT is either an example block or a src block. INFO is
1583 a plist used as a communication channel."
1584 (let* ((lang (org-element-property :language element
))
1585 ;; Extract code and references.
1586 (code-info (org-export-unravel-code element
))
1587 (code (car code-info
))
1588 (refs (cdr code-info
))
1589 ;; Does the src block contain labels?
1590 (retain-labels (org-element-property :retain-labels element
))
1591 ;; Does it have line numbers?
1592 (num-start (case (org-element-property :number-lines element
)
1593 (continued (org-export-get-loc element info
))
1595 (org-html-do-format-code code lang refs retain-labels num-start
)))
1599 ;;; Transcode Functions
1603 (defun org-html-bold (bold contents info
)
1604 "Transcode BOLD from Org to HTML.
1605 CONTENTS is the text with bold markup. INFO is a plist holding
1606 contextual information."
1607 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
1613 (defun org-html-center-block (center-block contents info
)
1614 "Transcode a CENTER-BLOCK element from Org to HTML.
1615 CONTENTS holds the contents of the block. INFO is a plist
1616 holding contextual information."
1617 (format "<div style=\"text-align: center\">\n%s</div>" contents
))
1622 (defun org-html-clock (clock contents info
)
1623 "Transcode a CLOCK element from Org to HTML.
1624 CONTENTS is nil. INFO is a plist used as a communication
1627 <span class=\"timestamp-wrapper\">
1628 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
1633 (org-element-property :raw-value
1634 (org-element-property :value clock
)))
1635 (let ((time (org-element-property :duration clock
)))
1636 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
1641 (defun org-html-code (code contents info
)
1642 "Transcode CODE from Org to HTML.
1643 CONTENTS is nil. INFO is a plist holding contextual
1645 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
1646 (org-element-property :value code
)))
1651 (defun org-html-drawer (drawer contents info
)
1652 "Transcode a DRAWER element from Org to HTML.
1653 CONTENTS holds the contents of the block. INFO is a plist
1654 holding contextual information."
1655 (if (functionp org-html-format-drawer-function
)
1656 (funcall org-html-format-drawer-function
1657 (org-element-property :drawer-name drawer
)
1659 ;; If there's no user defined function: simply
1660 ;; display contents of the drawer.
1666 (defun org-html-dynamic-block (dynamic-block contents info
)
1667 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
1668 CONTENTS holds the contents of the block. INFO is a plist
1669 holding contextual information. See `org-export-data'."
1675 (defun org-html-entity (entity contents info
)
1676 "Transcode an ENTITY object from Org to HTML.
1677 CONTENTS are the definition itself. INFO is a plist holding
1678 contextual information."
1679 (org-element-property :html entity
))
1684 (defun org-html-example-block (example-block contents info
)
1685 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
1686 CONTENTS is nil. INFO is a plist holding contextual
1688 (if (org-export-read-attribute :attr_html example-block
:textarea
)
1689 (org-html--textarea-block example-block
)
1690 (format "<pre class=\"example\">\n%s</pre>"
1691 (org-html-format-code example-block info
))))
1696 (defun org-html-export-snippet (export-snippet contents info
)
1697 "Transcode a EXPORT-SNIPPET object from Org to HTML.
1698 CONTENTS is nil. INFO is a plist holding contextual
1700 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
1701 (org-element-property :value export-snippet
)))
1706 (defun org-html-export-block (export-block contents info
)
1707 "Transcode a EXPORT-BLOCK element from Org to HTML.
1708 CONTENTS is nil. INFO is a plist holding contextual information."
1709 (when (string= (org-element-property :type export-block
) "HTML")
1710 (org-remove-indentation (org-element-property :value export-block
))))
1715 (defun org-html-fixed-width (fixed-width contents info
)
1716 "Transcode a FIXED-WIDTH element from Org to HTML.
1717 CONTENTS is nil. INFO is a plist holding contextual information."
1718 (format "<pre class=\"example\">\n%s</pre>"
1719 (org-html-do-format-code
1720 (org-remove-indentation
1721 (org-element-property :value fixed-width
)))))
1724 ;;;; Footnote Reference
1726 (defun org-html-footnote-reference (footnote-reference contents info
)
1727 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
1728 CONTENTS is nil. INFO is a plist holding contextual information."
1730 ;; Insert separator between two footnotes in a row.
1731 (let ((prev (org-export-get-previous-element footnote-reference info
)))
1732 (when (eq (org-element-type prev
) 'footnote-reference
)
1733 org-html-footnote-separator
))
1735 ((not (org-export-footnote-first-reference-p footnote-reference info
))
1736 (org-html-format-footnote-reference
1737 (org-export-get-footnote-number footnote-reference info
)
1739 ;; Inline definitions are secondary strings.
1740 ((eq (org-element-property :type footnote-reference
) 'inline
)
1741 (org-html-format-footnote-reference
1742 (org-export-get-footnote-number footnote-reference info
)
1744 ;; Non-inline footnotes definitions are full Org data.
1745 (t (org-html-format-footnote-reference
1746 (org-export-get-footnote-number footnote-reference info
)
1752 (defun org-html-format-headline--wrap (headline info
1753 &optional format-function
1755 "Transcode an HEADLINE element from Org to HTML.
1756 CONTENTS holds the contents of the headline. INFO is a plist
1757 holding contextual information."
1758 (let* ((level (+ (org-export-get-relative-level headline info
)
1759 (1- org-html-toplevel-hlevel
)))
1760 (headline-number (org-export-get-headline-number headline info
))
1761 (section-number (and (not (org-export-low-level-p headline info
))
1762 (org-export-numbered-headline-p headline info
)
1763 (mapconcat 'number-to-string
1764 headline-number
".")))
1765 (todo (and (plist-get info
:with-todo-keywords
)
1766 (let ((todo (org-element-property :todo-keyword headline
)))
1767 (and todo
(org-export-data todo info
)))))
1768 (todo-type (and todo
(org-element-property :todo-type headline
)))
1769 (priority (and (plist-get info
:with-priority
)
1770 (org-element-property :priority headline
)))
1771 (text (org-export-data (org-element-property :title headline
) info
))
1772 (tags (and (plist-get info
:with-tags
)
1773 (org-export-get-tags headline info
)))
1774 (headline-label (or (org-element-property :CUSTOM_ID headline
)
1775 (concat "sec-" (mapconcat 'number-to-string
1776 headline-number
"-"))))
1777 (format-function (cond
1778 ((functionp format-function
) format-function
)
1779 ((functionp org-html-format-headline-function
)
1781 (lambda (todo todo-type priority text tags
1783 (funcall org-html-format-headline-function
1784 todo todo-type priority text tags
))))
1785 (t 'org-html-format-headline
))))
1786 (apply format-function
1787 todo todo-type priority text tags
1788 :headline-label headline-label
:level level
1789 :section-number section-number extra-keys
)))
1791 (defun org-html-headline (headline contents info
)
1792 "Transcode an HEADLINE element from Org to HTML.
1793 CONTENTS holds the contents of the headline. INFO is a plist
1794 holding contextual information."
1796 (setq contents
(or contents
""))
1797 (let* ((numberedp (org-export-numbered-headline-p headline info
))
1798 (level (org-export-get-relative-level headline info
))
1799 (text (org-export-data (org-element-property :title headline
) info
))
1800 (todo (and (plist-get info
:with-todo-keywords
)
1801 (let ((todo (org-element-property :todo-keyword headline
)))
1802 (and todo
(org-export-data todo info
)))))
1803 (todo-type (and todo
(org-element-property :todo-type headline
)))
1804 (tags (and (plist-get info
:with-tags
)
1805 (org-export-get-tags headline info
)))
1806 (priority (and (plist-get info
:with-priority
)
1807 (org-element-property :priority headline
)))
1808 (section-number (and (org-export-numbered-headline-p headline info
)
1809 (mapconcat 'number-to-string
1810 (org-export-get-headline-number
1811 headline info
) ".")))
1812 ;; Create the headline text.
1813 (full-text (org-html-format-headline--wrap headline info
)))
1815 ;; Case 1: This is a footnote section: ignore it.
1816 ((org-element-property :footnote-section-p headline
) nil
)
1817 ;; Case 2. This is a deep sub-tree: export it as a list item.
1818 ;; Also export as items headlines for which no section
1819 ;; format has been found.
1820 ((org-export-low-level-p headline info
)
1821 ;; Build the real contents of the sub-tree.
1822 (let* ((type (if numberedp
'ordered
'unordered
))
1823 (itemized-body (org-html-format-list-item
1824 contents type nil nil full-text
)))
1826 (and (org-export-first-sibling-p headline info
)
1827 (org-html-begin-plain-list type
))
1829 (and (org-export-last-sibling-p headline info
)
1830 (org-html-end-plain-list type
)))))
1831 ;; Case 3. Standard headline. Export it as a section.
1833 (let* ((section-number (mapconcat 'number-to-string
1834 (org-export-get-headline-number
1835 headline info
) "-"))
1837 (list (org-element-property :CUSTOM_ID headline
)
1838 (concat "sec-" section-number
)
1839 (org-element-property :ID headline
))))
1840 (preferred-id (car ids
))
1841 (extra-ids (cdr ids
))
1842 (extra-class (org-element-property :html-container-class headline
))
1843 (level1 (+ level
(1- org-html-toplevel-hlevel
))))
1844 (format "<div id=\"%s\" class=\"%s\">%s%s</div>\n"
1845 (format "outline-container-%s"
1846 (or (org-element-property :CUSTOM_ID headline
)
1848 (concat (format "outline-%d" level1
) (and extra-class
" ")
1850 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
1855 (let ((id (org-export-solidify-link-text
1856 (if (org-uuidgen-p x
) (concat "ID-" x
)
1858 (org-html--anchor id
)))
1865 ;;;; Horizontal Rule
1867 (defun org-html-horizontal-rule (horizontal-rule contents info
)
1868 "Transcode an HORIZONTAL-RULE object from Org to HTML.
1869 CONTENTS is nil. INFO is a plist holding contextual information."
1873 ;;;; Inline Src Block
1875 (defun org-html-inline-src-block (inline-src-block contents info
)
1876 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
1877 CONTENTS holds the contents of the item. INFO is a plist holding
1878 contextual information."
1879 (let* ((org-lang (org-element-property :language inline-src-block
))
1880 (code (org-element-property :value inline-src-block
)))
1881 (error "Cannot export inline src block")))
1886 (defun org-html-format-section (text class
&optional id
)
1887 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
1888 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
1890 (defun org-html-inlinetask (inlinetask contents info
)
1891 "Transcode an INLINETASK element from Org to HTML.
1892 CONTENTS holds the contents of the block. INFO is a plist
1893 holding contextual information."
1895 ;; If `org-html-format-inlinetask-function' is provided, call it
1896 ;; with appropriate arguments.
1897 ((functionp org-html-format-inlinetask-function
)
1898 (let ((format-function
1900 (lambda (todo todo-type priority text tags
1901 &key contents
&allow-other-keys
)
1902 (funcall org-html-format-inlinetask-function
1903 todo todo-type priority text tags contents
)))))
1904 (org-html-format-headline--wrap
1905 inlinetask info format-function
:contents contents
)))
1906 ;; Otherwise, use a default template.
1907 (t (format "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>"
1908 (org-html-format-headline--wrap inlinetask info
)
1914 (defun org-html-italic (italic contents info
)
1915 "Transcode ITALIC from Org to HTML.
1916 CONTENTS is the text with italic markup. INFO is a plist holding
1917 contextual information."
1918 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
1923 (defun org-html-checkbox (checkbox)
1924 (case checkbox
(on "<code>[X]</code>")
1925 (off "<code>[ ]</code>")
1926 (trans "<code>[-]</code>")
1929 (defun org-html-format-list-item (contents type checkbox
1930 &optional term-counter-id
1932 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" "))))
1936 (let* ((counter term-counter-id
)
1937 (extra (if counter
(format " value=\"%s\"" counter
) "")))
1939 (format "<li%s>" extra
)
1940 (when headline
(concat headline
"<br/>")))))
1942 (let* ((id term-counter-id
)
1943 (extra (if id
(format " id=\"%s\"" id
) "")))
1945 (format "<li%s>" extra
)
1946 (when headline
(concat headline
"<br/>")))))
1948 (let* ((term term-counter-id
))
1949 (setq term
(or term
"(no term)"))
1950 ;; Check-boxes in descriptive lists are associated to tag.
1951 (concat (format "<dt> %s </dt>"
1952 (concat checkbox term
))
1954 (unless (eq type
'descriptive
) checkbox
)
1959 (descriptive "</dd>")))))
1961 (defun org-html-item (item contents info
)
1962 "Transcode an ITEM element from Org to HTML.
1963 CONTENTS holds the contents of the item. INFO is a plist holding
1964 contextual information."
1965 (let* ((plain-list (org-export-get-parent item
))
1966 (type (org-element-property :type plain-list
))
1967 (counter (org-element-property :counter item
))
1968 (checkbox (org-element-property :checkbox item
))
1969 (tag (let ((tag (org-element-property :tag item
)))
1970 (and tag
(org-export-data tag info
)))))
1971 (org-html-format-list-item
1972 contents type checkbox
(or tag counter
))))
1977 (defun org-html-keyword (keyword contents info
)
1978 "Transcode a KEYWORD element from Org to HTML.
1979 CONTENTS is nil. INFO is a plist holding contextual information."
1980 (let ((key (org-element-property :key keyword
))
1981 (value (org-element-property :value keyword
)))
1983 ((string= key
"HTML") value
)
1984 ;; Invisible targets.
1985 ((string= key
"TARGET") nil
)
1986 ((string= key
"TOC")
1987 (let ((value (downcase value
)))
1989 ((string-match "\\<headlines\\>" value
)
1990 (let ((depth (or (and (string-match "[0-9]+" value
)
1991 (string-to-number (match-string 0 value
)))
1992 (plist-get info
:with-toc
))))
1993 (org-html-toc depth info
)))
1994 ((string= "tables" value
) "\\listoftables")
1995 ((string= "figures" value
) "\\listoffigures")
1996 ((string= "listings" value
)
1998 ;; At the moment, src blocks with a caption are wrapped
1999 ;; into a figure environment.
2000 (t "\\listoffigures")))))))))
2003 ;;;; Latex Environment
2005 (defun org-html-format-latex (latex-frag processing-type
)
2006 "Format LaTeX fragments into HTML."
2007 (let ((cache-relpath "") (cache-dir "") bfn
)
2008 (unless (eq processing-type
'mathjax
)
2009 (setq bfn
(buffer-file-name)
2012 (file-name-sans-extension
2013 (file-name-nondirectory bfn
)))
2014 cache-dir
(file-name-directory bfn
)))
2017 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2018 nil nil processing-type
)
2021 (defun org-html-latex-environment (latex-environment contents info
)
2022 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2023 CONTENTS is nil. INFO is a plist holding contextual information."
2024 (let ((processing-type (plist-get info
:with-latex
))
2025 (latex-frag (org-remove-indentation
2026 (org-element-property :value latex-environment
)))
2027 (caption (org-export-data
2028 (org-export-get-caption latex-environment
) info
))
2030 (label (org-element-property :name latex-environment
)))
2032 ((memq processing-type
'(t mathjax
))
2033 (org-html-format-latex latex-frag
'mathjax
))
2034 ((eq processing-type
'dvipng
)
2035 (let* ((formula-link (org-html-format-latex
2036 latex-frag processing-type
)))
2037 (when (and formula-link
2038 (string-match "file:\\([^]]*\\)" formula-link
))
2039 (org-html-format-inline-image
2040 (match-string 1 formula-link
) caption label attr t
))))
2046 (defun org-html-latex-fragment (latex-fragment contents info
)
2047 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2048 CONTENTS is nil. INFO is a plist holding contextual information."
2049 (let ((latex-frag (org-element-property :value latex-fragment
))
2050 (processing-type (plist-get info
:with-latex
)))
2051 (case processing-type
2053 (org-html-format-latex latex-frag
'mathjax
))
2055 (let* ((formula-link (org-html-format-latex
2056 latex-frag processing-type
)))
2057 (when (and formula-link
2058 (string-match "file:\\([^]]*\\)" formula-link
))
2059 (org-html-format-inline-image
2060 (match-string 1 formula-link
)))))
2066 (defun org-html-line-break (line-break contents info
)
2067 "Transcode a LINE-BREAK object from Org to HTML.
2068 CONTENTS is nil. INFO is a plist holding contextual information."
2074 (defun org-html-link--inline-image (link desc info
)
2075 "Return HTML code for an inline image.
2076 LINK is the link pointing to the inline image. INFO is a plist
2077 used as a communication channel."
2078 (let* ((type (org-element-property :type link
))
2079 (raw-path (org-element-property :path link
))
2080 (path (cond ((member type
'("http" "https"))
2081 (concat type
":" raw-path
))
2082 ((file-name-absolute-p raw-path
)
2083 (expand-file-name raw-path
))
2085 (parent (org-export-get-parent-element link
))
2086 (caption (org-export-data (org-export-get-caption parent
) info
))
2087 (label (org-element-property :name parent
))
2088 ;; Retrieve latex attributes from the element around.
2089 (attr (let ((raw-attr
2090 (mapconcat #'identity
2091 (org-element-property :attr_html parent
)
2093 (unless (string= raw-attr
"") raw-attr
))))
2094 ;; Now clear ATTR from any special keyword and set a default
2095 ;; value if nothing is left.
2096 (setq attr
(if (not attr
) "" (org-trim attr
)))
2097 ;; Return proper string, depending on DISPOSITION.
2098 (org-html-format-inline-image
2099 path caption label attr
(org-html-standalone-image-p link info
))))
2101 (defvar org-html-standalone-image-predicate
)
2102 (defun org-html-standalone-image-p (element info
&optional predicate
)
2103 "Test if ELEMENT is a standalone image for the purpose HTML export.
2104 INFO is a plist holding contextual information.
2106 Return non-nil, if ELEMENT is of type paragraph and it's sole
2107 content, save for whitespaces, is a link that qualifies as an
2110 Return non-nil, if ELEMENT is of type link and it's containing
2111 paragraph has no other content save for leading and trailing
2114 Return nil, otherwise.
2116 Bind `org-html-standalone-image-predicate' to constrain
2117 paragraph further. For example, to check for only captioned
2118 standalone images, do the following.
2120 \(setq org-html-standalone-image-predicate
2121 \(lambda \(paragraph\)
2122 \(org-element-property :caption paragraph\)\)\)"
2123 (let ((paragraph (case (org-element-type element
)
2125 (link (and (org-export-inline-image-p
2126 element org-html-inline-image-rules
)
2127 (org-export-get-parent element
)))
2129 (when (eq (org-element-type paragraph
) 'paragraph
)
2130 (when (or (not (and (boundp 'org-html-standalone-image-predicate
)
2131 (functionp org-html-standalone-image-predicate
)))
2132 (funcall org-html-standalone-image-predicate paragraph
))
2133 (let ((contents (org-element-contents paragraph
)))
2134 (loop for x in contents
2135 with inline-image-count
= 0
2137 ((eq (org-element-type x
) 'plain-text
)
2138 (not (org-string-nw-p x
)))
2139 ((eq (org-element-type x
) 'link
)
2140 (when (org-export-inline-image-p
2141 x org-html-inline-image-rules
)
2142 (= (incf inline-image-count
) 1)))
2145 (defun org-html-link (link desc info
)
2146 "Transcode a LINK object from Org to HTML.
2148 DESC is the description part of the link, or the empty string.
2149 INFO is a plist holding contextual information. See
2151 (let* ((--link-org-files-as-html-maybe
2153 (lambda (raw-path info
)
2154 "Treat links to `file.org' as links to `file.html', if needed.
2155 See `org-html-link-org-files-as-html'."
2157 ((and org-html-link-org-files-as-html
2159 (downcase (file-name-extension raw-path
"."))))
2160 (concat (file-name-sans-extension raw-path
) "."
2161 (plist-get info
:html-extension
)))
2163 (type (org-element-property :type link
))
2164 (raw-path (org-element-property :path link
))
2165 ;; Ensure DESC really exists, or set it to nil.
2166 (desc (and (not (string= desc
"")) desc
))
2169 ((member type
'("http" "https" "ftp" "mailto"))
2170 (concat type
":" raw-path
))
2171 ((string= type
"file")
2172 ;; Treat links to ".org" files as ".html", if needed.
2174 (funcall --link-org-files-as-html-maybe raw-path info
))
2175 ;; If file path is absolute, prepend it with protocol
2176 ;; component - "file://".
2177 (when (file-name-absolute-p raw-path
)
2179 (concat "file://" (expand-file-name raw-path
))))
2180 ;; Add search option, if any. A search option can be
2181 ;; relative to a custom-id or a headline title. Any other
2182 ;; option is ignored.
2183 (let ((option (org-element-property :search-option link
)))
2184 (cond ((not option
) raw-path
)
2185 ((eq (aref option
0) ?
#) (concat raw-path option
))
2186 ;; External fuzzy link: try to resolve it if path
2187 ;; belongs to current project, if any.
2188 ((eq (aref option
0) ?
*)
2192 (org-publish-resolve-external-fuzzy-link
2193 (org-element-property :path link
) option
)))
2194 (and numbers
(concat "#sec-"
2195 (mapconcat 'number-to-string
2196 numbers
"-")))))))))
2198 attributes protocol
)
2199 ;; Extract attributes from parent's paragraph.
2200 (and (setq attributes
2203 (let ((att (org-element-property
2204 :attr_html
(org-export-get-parent-element link
))))
2205 (unless (and desc att
(string-match (regexp-quote (car att
)) desc
)) att
))
2207 (setq attributes
(concat " " attributes
)))
2211 ((and (or (eq t org-html-inline-images
)
2212 (and org-html-inline-images
(not desc
)))
2213 (org-export-inline-image-p link org-html-inline-image-rules
))
2214 (org-html-link--inline-image link desc info
))
2215 ;; Radio target: Transcode target's contents and use them as
2216 ;; link's description.
2217 ((string= type
"radio")
2218 (let ((destination (org-export-resolve-radio-link link info
)))
2220 (format "<a href=\"#%s\"%s>%s</a>"
2221 (org-export-solidify-link-text path
)
2223 (org-export-data (org-element-contents destination
) info
)))))
2224 ;; Links pointing to an headline: Find destination and build
2225 ;; appropriate referencing command.
2226 ((member type
'("custom-id" "fuzzy" "id"))
2227 (let ((destination (if (string= type
"fuzzy")
2228 (org-export-resolve-fuzzy-link link info
)
2229 (org-export-resolve-id-link link info
))))
2230 (case (org-element-type destination
)
2231 ;; ID link points to an external file.
2233 (let ((fragment (concat "ID-" path
))
2234 ;; Treat links to ".org" files as ".html", if needed.
2235 (path (funcall --link-org-files-as-html-maybe
2237 (format "<a href=\"%s#%s\"%s>%s</a>"
2238 path fragment attributes
(or desc destination
))))
2239 ;; Fuzzy link points nowhere.
2244 (org-element-property :raw-link link
) info
))))
2245 ;; Fuzzy link points to an invisible target.
2247 ;; Link points to an headline.
2250 ;; What href to use?
2252 ;; Case 1: Headline is linked via it's CUSTOM_ID
2253 ;; property. Use CUSTOM_ID.
2254 ((string= type
"custom-id")
2255 (org-element-property :CUSTOM_ID destination
))
2256 ;; Case 2: Headline is linked via it's ID property
2257 ;; or through other means. Use the default href.
2258 ((member type
'("id" "fuzzy"))
2260 (mapconcat 'number-to-string
2261 (org-export-get-headline-number
2262 destination info
) "-")))
2263 (t (error "Shouldn't reach here"))))
2264 ;; What description to use?
2266 ;; Case 1: Headline is numbered and LINK has no
2267 ;; description or LINK's description matches
2268 ;; headline's title. Display section number.
2269 (if (and (org-export-numbered-headline-p destination info
)
2271 (string= desc
(org-element-property
2272 :raw-value destination
))))
2273 (mapconcat 'number-to-string
2274 (org-export-get-headline-number
2275 destination info
) ".")
2276 ;; Case 2: Either the headline is un-numbered or
2277 ;; LINK has a custom description. Display LINK's
2278 ;; description or headline's title.
2279 (or desc
(org-export-data (org-element-property
2280 :title destination
) info
)))))
2281 (format "<a href=\"#%s\"%s>%s</a>"
2282 (org-export-solidify-link-text href
) attributes desc
)))
2283 ;; Fuzzy link points to a target. Do as above.
2285 (let ((path (org-export-solidify-link-text path
)) number
)
2288 ((org-html-standalone-image-p destination info
)
2289 (org-export-get-ordinal
2290 (assoc 'link
(org-element-contents destination
))
2291 info
'link
'org-html-standalone-image-p
))
2292 (t (org-export-get-ordinal destination info
))))
2293 (setq desc
(when number
2294 (if (atom number
) (number-to-string number
)
2295 (mapconcat 'number-to-string number
".")))))
2296 (format "<a href=\"#%s\"%s>%s</a>"
2297 path attributes
(or desc
"No description for this link")))))))
2298 ;; Coderef: replace link with the reference name or the
2299 ;; equivalent line number.
2300 ((string= type
"coderef")
2301 (let ((fragment (concat "coderef-" path
)))
2302 (format "<a href=\"#%s\" %s%s>%s</a>"
2304 (format (concat "class=\"coderef\""
2305 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2306 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2309 (format (org-export-get-coderef-format path desc
)
2310 (org-export-resolve-coderef path info
)))))
2311 ;; Link type is handled by a special function.
2312 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2313 (funcall protocol
(org-link-unescape path
) desc
'html
))
2314 ;; External link with a description part.
2315 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2316 ;; External link without a description part.
2317 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2318 ;; No path, only description. Try to do something useful.
2319 (t (format "<i>%s</i>" desc
)))))
2324 (defun org-html-paragraph (paragraph contents info
)
2325 "Transcode a PARAGRAPH element from Org to HTML.
2326 CONTENTS is the contents of the paragraph, as a string. INFO is
2327 the plist used as a communication channel."
2328 (let* ((style nil
) ; FIXME
2329 (class (cdr (assoc style
'((footnote .
"footnote")
2331 (extra (if class
(format " class=\"%s\"" class
) ""))
2332 (parent (org-export-get-parent paragraph
)))
2334 ((and (eq (org-element-type parent
) 'item
)
2335 (= (org-element-property :begin paragraph
)
2336 (org-element-property :contents-begin parent
)))
2337 ;; leading paragraph in a list item have no tags
2339 ((org-html-standalone-image-p paragraph info
)
2342 (t (format "<p%s>\n%s</p>" extra contents
)))))
2347 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2348 ;; the correct value for the item counter
2349 (defun org-html-begin-plain-list (type &optional arg1
)
2350 "Insert the beginning of the HTML list depending on TYPE.
2351 When ARG1 is a string, use it as the start parameter for ordered
2355 (format "<ol class=\"org-ol\"%s>"
2356 (if arg1
(format " start=\"%d\"" arg1
) "")))
2357 (unordered "<ul class=\"org-ul\">")
2358 (descriptive "<dl class=\"org-dl\">")))
2360 (defun org-html-end-plain-list (type)
2361 "Insert the end of the HTML list depending on TYPE."
2365 (descriptive "</dl>")))
2367 (defun org-html-plain-list (plain-list contents info
)
2368 "Transcode a PLAIN-LIST element from Org to HTML.
2369 CONTENTS is the contents of the list. INFO is a plist holding
2370 contextual information."
2371 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2372 (type (org-element-property :type plain-list
)))
2374 (org-html-begin-plain-list type
)
2375 contents
(org-html-end-plain-list type
))))
2379 (defun org-html-convert-special-strings (string)
2380 "Convert special characters in STRING to HTML."
2381 (let ((all org-html-special-string-regexps
)
2383 (while (setq a
(pop all
))
2384 (setq re
(car a
) rpl
(cdr a
) start
0)
2385 (while (string-match re string start
)
2386 (setq string
(replace-match rpl t nil string
))))
2389 (defun org-html-encode-plain-text (text)
2390 "Convert plain text characters to HTML equivalent.
2391 Possible conversions are set in `org-export-html-protect-char-alist'."
2394 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2395 org-html-protect-char-alist
)
2398 (defun org-html-plain-text (text info
)
2399 "Transcode a TEXT string from Org to HTML.
2400 TEXT is the string to transcode. INFO is a plist holding
2401 contextual information."
2402 (let ((output text
))
2403 ;; Protect following characters: <, >, &.
2404 (setq output
(org-html-encode-plain-text output
))
2405 ;; Handle smart quotes. Be sure to provide original string since
2406 ;; OUTPUT may have been modified.
2407 (when (plist-get info
:with-smart-quotes
)
2408 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2409 ;; Handle special strings.
2410 (when (plist-get info
:with-special-strings
)
2411 (setq output
(org-html-convert-special-strings output
)))
2412 ;; Handle break preservation if required.
2413 (when (plist-get info
:preserve-breaks
)
2415 (replace-regexp-in-string
2416 "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output
)))
2423 (defun org-html-planning (planning contents info
)
2424 "Transcode a PLANNING element from Org to HTML.
2425 CONTENTS is nil. INFO is a plist used as a communication
2427 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2429 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2434 (let ((closed (org-element-property :closed planning
)))
2436 (format span-fmt org-closed-string
2438 (org-element-property :raw-value closed
)))))
2439 (let ((deadline (org-element-property :deadline planning
)))
2441 (format span-fmt org-deadline-string
2443 (org-element-property :raw-value deadline
)))))
2444 (let ((scheduled (org-element-property :scheduled planning
)))
2446 (format span-fmt org-scheduled-string
2448 (org-element-property :raw-value scheduled
)))))))
2452 ;;;; Property Drawer
2454 (defun org-html-property-drawer (property-drawer contents info
)
2455 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2456 CONTENTS is nil. INFO is a plist holding contextual
2458 ;; The property drawer isn't exported but we want separating blank
2459 ;; lines nonetheless.
2465 (defun org-html-quote-block (quote-block contents info
)
2466 "Transcode a QUOTE-BLOCK element from Org to HTML.
2467 CONTENTS holds the contents of the block. INFO is a plist
2468 holding contextual information."
2469 (format "<blockquote>\n%s</blockquote>" contents
))
2474 (defun org-html-quote-section (quote-section contents info
)
2475 "Transcode a QUOTE-SECTION element from Org to HTML.
2476 CONTENTS is nil. INFO is a plist holding contextual information."
2477 (let ((value (org-remove-indentation
2478 (org-element-property :value quote-section
))))
2479 (when value
(format "<pre>\n%s</pre>" value
))))
2484 (defun org-html-section (section contents info
)
2485 "Transcode a SECTION element from Org to HTML.
2486 CONTENTS holds the contents of the section. INFO is a plist
2487 holding contextual information."
2488 (let ((parent (org-export-get-parent-headline section
)))
2489 ;; Before first headline: no container, just return CONTENTS.
2490 (if (not parent
) contents
2491 ;; Get div's class and id references.
2492 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2493 (1- org-html-toplevel-hlevel
)))
2497 (org-export-get-headline-number parent info
) "-")))
2498 ;; Build return value.
2499 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2501 (or (org-element-property :CUSTOM_ID parent
) section-number
)
2506 (defun org-html-radio-target (radio-target text info
)
2507 "Transcode a RADIO-TARGET object from Org to HTML.
2508 TEXT is the text of the target. INFO is a plist holding
2509 contextual information."
2510 (let ((id (org-export-solidify-link-text
2511 (org-element-property :value radio-target
))))
2512 (org-html--anchor id text
)))
2517 (defun org-html-special-block (special-block contents info
)
2518 "Transcode a SPECIAL-BLOCK element from Org to HTML.
2519 CONTENTS holds the contents of the block. INFO is a plist
2520 holding contextual information."
2521 (format "<div class=\"%s\">\n%s\n</div>"
2522 (downcase (org-element-property :type special-block
))
2528 (defun org-html-src-block (src-block contents info
)
2529 "Transcode a SRC-BLOCK element from Org to HTML.
2530 CONTENTS holds the contents of the item. INFO is a plist holding
2531 contextual information."
2532 (if (org-export-read-attribute :attr_html src-block
:textarea
)
2533 (org-html--textarea-block src-block
)
2534 (let ((lang (org-element-property :language src-block
))
2535 (caption (org-export-get-caption src-block
))
2536 (code (org-html-format-code src-block info
)))
2537 (if (not lang
) (format "<pre class=\"example\">\n%s</pre>" code
)
2538 (format "<div class=\"org-src-container\">\n%s%s\n</div>"
2539 (if (not caption
) ""
2540 (format "<label class=\"org-src-name\">%s</label>"
2541 (org-export-data caption info
)))
2542 (format "\n<pre class=\"src src-%s\">%s</pre>" lang code
))))))
2545 ;;;; Statistics Cookie
2547 (defun org-html-statistics-cookie (statistics-cookie contents info
)
2548 "Transcode a STATISTICS-COOKIE object from Org to HTML.
2549 CONTENTS is nil. INFO is a plist holding contextual information."
2550 (let ((cookie-value (org-element-property :value statistics-cookie
)))
2551 (format "<code>%s</code>" cookie-value
)))
2556 (defun org-html-strike-through (strike-through contents info
)
2557 "Transcode STRIKE-THROUGH from Org to HTML.
2558 CONTENTS is the text with strike-through markup. INFO is a plist
2559 holding contextual information."
2560 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
2566 (defun org-html-subscript (subscript contents info
)
2567 "Transcode a SUBSCRIPT object from Org to HTML.
2568 CONTENTS is the contents of the object. INFO is a plist holding
2569 contextual information."
2570 (format "<sub>%s</sub>" contents
))
2575 (defun org-html-superscript (superscript contents info
)
2576 "Transcode a SUPERSCRIPT object from Org to HTML.
2577 CONTENTS is the contents of the object. INFO is a plist holding
2578 contextual information."
2579 (format "<sup>%s</sup>" contents
))
2584 (defun org-html-table-cell (table-cell contents info
)
2585 "Transcode a TABLE-CELL element from Org to HTML.
2586 CONTENTS is nil. INFO is a plist used as a communication
2588 (let* ((table-row (org-export-get-parent table-cell
))
2589 (table (org-export-get-parent-table table-cell
))
2591 (if (not org-html-table-align-individual-fields
) ""
2592 (format (if (and (boundp 'org-html-format-table-no-css
)
2593 org-html-format-table-no-css
)
2594 " align=\"%s\"" " class=\"%s\"")
2595 (org-export-table-cell-alignment table-cell info
)))))
2596 (when (or (not contents
) (string= "" (org-trim contents
)))
2597 (setq contents
" "))
2599 ((and (org-export-table-has-header-p table info
)
2600 (= 1 (org-export-table-row-group table-row info
)))
2601 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
2602 contents
(cdr org-html-table-header-tags
)))
2603 ((and org-html-table-use-header-tags-for-first-column
2604 (zerop (cdr (org-export-table-cell-address table-cell info
))))
2605 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
2606 contents
(cdr org-html-table-header-tags
)))
2607 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
2608 contents
(cdr org-html-table-data-tags
))))))
2613 (defun org-html-table-row (table-row contents info
)
2614 "Transcode a TABLE-ROW element from Org to HTML.
2615 CONTENTS is the contents of the row. INFO is a plist used as a
2616 communication channel."
2617 ;; Rules are ignored since table separators are deduced from
2618 ;; borders of the current row.
2619 (when (eq (org-element-property :type table-row
) 'standard
)
2620 (let* ((first-rowgroup-p (= 1 (org-export-table-row-group table-row info
)))
2623 ;; Case 1: Row belongs to second or subsequent rowgroups.
2624 ((not (= 1 (org-export-table-row-group table-row info
)))
2625 '("<tbody>" .
"\n</tbody>"))
2626 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
2627 ((org-export-table-has-header-p
2628 (org-export-get-parent-table table-row
) info
)
2629 '("<thead>" .
"\n</thead>"))
2630 ;; Case 2: Row is from first and only row group.
2631 (t '("<tbody>" .
"\n</tbody>")))))
2633 ;; Begin a rowgroup?
2634 (when (org-export-table-row-starts-rowgroup-p table-row info
)
2635 (car rowgroup-tags
))
2637 (concat "\n" (eval (car org-html-table-row-tags
))
2640 (eval (cdr org-html-table-row-tags
)))
2642 (when (org-export-table-row-ends-rowgroup-p table-row info
)
2643 (cdr rowgroup-tags
))))))
2648 (defun org-html-table-first-row-data-cells (table info
)
2650 (org-element-map table
'table-row
2652 (unless (eq (org-element-property :type row
) 'rule
) row
))
2654 (special-column-p (org-export-table-has-special-column-p table
)))
2655 (if (not special-column-p
) (org-element-contents table-row
)
2656 (cdr (org-element-contents table-row
)))))
2658 (defun org-html-table--table.el-table
(table info
)
2659 (when (eq (org-element-property :type table
) 'table.el
)
2661 (let ((outbuf (with-current-buffer
2662 (get-buffer-create "*org-export-table*")
2663 (erase-buffer) (current-buffer))))
2665 (insert (org-element-property :value table
))
2667 (re-search-forward "^[ \t]*|[^|]" nil t
)
2668 (table-generate-source 'html outbuf
))
2669 (with-current-buffer outbuf
2670 (prog1 (org-trim (buffer-string))
2673 (defun org-html-table (table contents info
)
2674 "Transcode a TABLE element from Org to HTML.
2675 CONTENTS is the contents of the table. INFO is a plist holding
2676 contextual information."
2677 (case (org-element-property :type table
)
2678 ;; Case 1: table.el table. Convert it using appropriate tools.
2679 (table.el
(org-html-table--table.el-table table info
))
2680 ;; Case 2: Standard table.
2682 (let* ((label (org-element-property :name table
))
2683 (caption (org-export-get-caption table
))
2684 (attributes (mapconcat #'identity
2685 (org-element-property :attr_html table
)
2688 (if (and (boundp 'org-html-format-table-no-css
)
2689 org-html-format-table-no-css
)
2690 "align=\"%s\"" "class=\"%s\""))
2693 (lambda (table info
)
2695 (lambda (table-cell)
2696 (let ((alignment (org-export-table-cell-alignment
2699 ;; Begin a colgroup?
2700 (when (org-export-table-cell-starts-colgroup-p
2703 ;; Add a column. Also specify it's alignment.
2704 (format "\n<col %s/>" (format alignspec alignment
))
2706 (when (org-export-table-cell-ends-colgroup-p
2709 (org-html-table-first-row-data-cells table info
) "\n"))))
2711 (let ((table-tag (plist-get info
:html-table-tag
)))
2713 (and (string-match "<table\\(.*\\)>" table-tag
)
2714 (match-string 1 table-tag
))
2715 (and label
(format " id=\"%s\""
2716 (org-export-solidify-link-text label
)))
2717 (unless (string= attributes
"")
2718 (concat " " attributes
))))))
2719 ;; Remove last blank line.
2720 (setq contents
(substring contents
0 -
1))
2721 (format "<table%s>\n%s\n%s\n%s\n</table>"
2723 (if (not caption
) ""
2724 (format "<caption>%s</caption>"
2725 (org-export-data caption info
)))
2726 (funcall table-column-specs table info
)
2732 (defun org-html-target (target contents info
)
2733 "Transcode a TARGET object from Org to HTML.
2734 CONTENTS is nil. INFO is a plist holding contextual
2736 (let ((id (org-export-solidify-link-text
2737 (org-element-property :value target
))))
2738 (org-html--anchor id
)))
2743 (defun org-html-timestamp (timestamp contents info
)
2744 "Transcode a TIMESTAMP object from Org to HTML.
2745 CONTENTS is nil. INFO is a plist holding contextual
2747 (let ((value (org-html-plain-text
2748 (org-timestamp-translate timestamp
) info
)))
2749 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
2750 (replace-regexp-in-string "--" "–" value
))))
2755 (defun org-html-underline (underline contents info
)
2756 "Transcode UNDERLINE from Org to HTML.
2757 CONTENTS is the text with underline markup. INFO is a plist
2758 holding contextual information."
2759 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
2765 (defun org-html-verbatim (verbatim contents info
)
2766 "Transcode VERBATIM from Org to HTML.
2767 CONTENTS is nil. INFO is a plist holding contextual
2769 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
2770 (org-element-property :value verbatim
)))
2775 (defun org-html-verse-block (verse-block contents info
)
2776 "Transcode a VERSE-BLOCK element from Org to HTML.
2777 CONTENTS is verse block contents. INFO is a plist holding
2778 contextual information."
2779 ;; Replace each newline character with line break. Also replace
2780 ;; each blank line with a line break.
2781 (setq contents
(replace-regexp-in-string
2782 "^ *\\\\\\\\$" "<br/>\n"
2783 (replace-regexp-in-string
2784 "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents
)))
2785 ;; Replace each white space at beginning of a line with a
2786 ;; non-breaking space.
2787 (while (string-match "^[ \t]+" contents
)
2788 (let* ((num-ws (length (match-string 0 contents
)))
2789 (ws (let (out) (dotimes (i num-ws out
)
2790 (setq out
(concat out
" "))))))
2791 (setq contents
(replace-match ws nil t contents
))))
2792 (format "<p class=\"verse\">\n%s</p>" contents
))
2796 ;;; Filter Functions
2798 (defun org-html-final-function (contents backend info
)
2799 (if (not org-html-pretty-output
) contents
2803 (indent-region (point-min) (point-max))
2804 (buffer-substring-no-properties (point-min) (point-max)))))
2808 ;;; End-user functions
2811 (defun org-html-export-as-html
2812 (&optional async subtreep visible-only body-only ext-plist
)
2813 "Export current buffer to an HTML buffer.
2815 If narrowing is active in the current buffer, only export its
2818 If a region is active, export that region.
2820 A non-nil optional argument ASYNC means the process should happen
2821 asynchronously. The resulting buffer should be accessible
2822 through the `org-export-stack' interface.
2824 When optional argument SUBTREEP is non-nil, export the sub-tree
2825 at point, extracting information from the headline properties
2828 When optional argument VISIBLE-ONLY is non-nil, don't export
2829 contents of hidden elements.
2831 When optional argument BODY-ONLY is non-nil, only write code
2832 between \"<body>\" and \"</body>\" tags.
2834 EXT-PLIST, when provided, is a property list with external
2835 parameters overriding Org default settings, but still inferior to
2836 file-local settings.
2838 Export is done in a buffer named \"*Org HTML Export*\", which
2839 will be displayed when `org-export-show-temporary-export-buffer'
2843 (org-export-async-start
2845 (with-current-buffer (get-buffer-create "*Org HTML Export*")
2848 (goto-char (point-min))
2849 (funcall org-html-display-buffer-mode
)
2850 (org-export-add-to-stack (current-buffer) 'html
)))
2851 `(org-export-as 'html
,subtreep
,visible-only
,body-only
',ext-plist
))
2852 (let ((outbuf (org-export-to-buffer
2853 'html
"*Org HTML Export*"
2854 subtreep visible-only body-only ext-plist
)))
2856 (with-current-buffer outbuf
(funcall org-html-display-buffer-mode
))
2857 (when org-export-show-temporary-export-buffer
2858 (switch-to-buffer-other-window outbuf
)))))
2861 (defun org-html-export-to-html
2862 (&optional async subtreep visible-only body-only ext-plist
)
2863 "Export current buffer to a HTML file.
2865 If narrowing is active in the current buffer, only export its
2868 If a region is active, export that region.
2870 A non-nil optional argument ASYNC means the process should happen
2871 asynchronously. The resulting file should be accessible through
2872 the `org-export-stack' interface.
2874 When optional argument SUBTREEP is non-nil, export the sub-tree
2875 at point, extracting information from the headline properties
2878 When optional argument VISIBLE-ONLY is non-nil, don't export
2879 contents of hidden elements.
2881 When optional argument BODY-ONLY is non-nil, only write code
2882 between \"<body>\" and \"</body>\" tags.
2884 EXT-PLIST, when provided, is a property list with external
2885 parameters overriding Org default settings, but still inferior to
2886 file-local settings.
2888 Return output file's name."
2890 (let* ((extension (concat "." org-html-extension
))
2891 (file (org-export-output-file-name extension subtreep
))
2892 (org-export-coding-system org-html-coding-system
))
2894 (org-export-async-start
2895 (lambda (f) (org-export-add-to-stack f
'html
))
2896 (let ((org-export-coding-system org-html-coding-system
))
2899 'html
,file
,subtreep
,visible-only
,body-only
',ext-plist
))))
2900 (let ((org-export-coding-system org-html-coding-system
))
2902 'html file subtreep visible-only body-only ext-plist
)))))
2905 (defun org-html-publish-to-html (plist filename pub-dir
)
2906 "Publish an org file to HTML.
2908 FILENAME is the filename of the Org file to be published. PLIST
2909 is the property list for the given project. PUB-DIR is the
2910 publishing directory.
2912 Return output file name."
2913 (org-publish-org-to 'html filename
".html" plist pub-dir
))
2919 ;;;; org-format-table-html
2920 ;;;; org-format-org-table-html
2921 ;;;; org-format-table-table-html
2922 ;;;; org-table-number-fraction
2923 ;;;; org-table-number-regexp
2924 ;;;; org-html-table-caption-above
2925 ;;;; org-html-with-timestamp
2926 ;;;; org-html-html-helper-timestamp
2927 ;;;; org-html-inline-image-extensions
2928 ;;;; org-export-preferred-target-alist
2929 ;;;; class for anchors
2930 ;;;; org-export-with-section-numbers, body-only
2931 ;;;; org-export-mark-todo-in-toc
2932 ;;;; org-html-format-org-link
2933 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
2934 ;;;; alt = (file-name-nondirectory path)
2939 ;; generated-autoload-file: "org-loaddefs.el"
2942 ;;; ox-html.el ends here