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 (:html-htmlized-css-url
"HTML_HTMLIZED_CSS_URL" nil org-html-htmlized-org-css-url
)
126 ;; Redefine regular options.
127 (:creator
"CREATOR" nil org-html-creator-string
)
128 (:with-latex nil
"tex" org-html-with-latex
)
129 ;; Leave room for "ox-infojs.el" extension.
130 (:infojs-opt
"INFOJS_OPT" nil nil
)))
134 ;;; Internal Variables
136 (defvar org-html-format-table-no-css
)
137 (defvar htmlize-buffer-places
) ; from htmlize.el
139 (defconst org-html-special-string-regexps
140 '(("\\\\-" .
"­")
141 ("---\\([^-]\\)" .
"—\\1")
142 ("--\\([^-]\\)" .
"–\\1")
143 ("\\.\\.\\." .
"…"))
144 "Regular expressions for special string conversion.")
146 (defconst org-html-scripts
147 "<script type=\"text/javascript\">
149 @licstart The following is the entire license notice for the
150 JavaScript code in this tag.
152 Copyright (C) 2012 Free Software Foundation, Inc.
154 The JavaScript code in this tag is free software: you can
155 redistribute it and/or modify it under the terms of the GNU
156 General Public License (GNU GPL) as published by the Free Software
157 Foundation, either version 3 of the License, or (at your option)
158 any later version. The code is distributed WITHOUT ANY WARRANTY;
159 without even the implied warranty of MERCHANTABILITY or FITNESS
160 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
162 As additional permission under GNU GPL version 3 section 7, you
163 may distribute non-source (e.g., minimized or compacted) forms of
164 that code without the copy of the GNU GPL normally required by
165 section 4, provided you include this license notice and a URL
166 through which recipients can access the Corresponding Source.
169 @licend The above is the entire license notice
170 for the JavaScript code in this tag.
172 <!--/*--><![CDATA[/*><!--*/
173 function CodeHighlightOn(elem, id)
175 var target = document.getElementById(id);
177 elem.cacheClassElem = elem.className;
178 elem.cacheClassTarget = target.className;
179 target.className = \"code-highlighted\";
180 elem.className = \"code-highlighted\";
183 function CodeHighlightOff(elem, id)
185 var target = document.getElementById(id);
186 if(elem.cacheClassElem)
187 elem.className = elem.cacheClassElem;
188 if(elem.cacheClassTarget)
189 target.className = elem.cacheClassTarget;
193 "Basic JavaScript that is needed by HTML files produced by Org mode.")
195 (defconst org-html-style-default
196 "<style type=\"text/css\">
197 <!--/*--><![CDATA[/*><!--*/
198 html { font-family: Times, serif; font-size: 12pt; }
199 .title { text-align: center; }
200 .todo { color: red; }
201 .done { color: green; }
202 .tag { background-color: #add8e6; font-weight:normal }
204 .timestamp { color: #bebebe; }
205 .timestamp-kwd { color: #5f9ea0; }
206 .right {margin-left:auto; margin-right:0px; text-align:right;}
207 .left {margin-left:0px; margin-right:auto; text-align:left;}
208 .center {margin-left:auto; margin-right:auto; text-align:center;}
209 p.verse { margin-left: 3% }
211 border: 1pt solid #AEBDCC;
212 background-color: #F3F5F7;
214 font-family: courier, monospace;
218 table { border-collapse: collapse; }
219 td, th { vertical-align: top; }
220 th.right { text-align:center; }
221 th.left { text-align:center; }
222 th.center { text-align:center; }
223 td.right { text-align:right; }
224 td.left { text-align:left; }
225 td.center { text-align:center; }
226 dt { font-weight: bold; }
227 div.figure { padding: 0.5em; }
228 div.figure p { text-align: center; }
231 border:2px solid gray;
235 textarea { overflow-x: auto; }
236 .linenr { font-size:smaller }
237 .code-highlighted {background-color:#ffff00;}
238 .org-info-js_info-navigation { border-style:none; }
239 #org-info-js_console-label { font-size:10px; font-weight:bold;
240 white-space:nowrap; }
241 .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
245 "The default style specification for exported HTML files.
246 Please use the variables `org-html-style' and
247 `org-html-style-extra' to add to this style. If you wish to not
248 have the default style included, customize the variable
249 `org-html-style-include-default'.")
253 ;;; User Configuration Variables
255 (defgroup org-export-html nil
256 "Options for exporting Org mode files to HTML."
257 :tag
"Org Export HTML"
263 (defcustom org-html-text-markup-alist
264 '((bold .
"<b>%s</b>")
265 (code .
"<code>%s</code>")
266 (italic .
"<i>%s</i>")
267 (strike-through .
"<del>%s</del>")
268 (underline .
"<span style=\"text-decoration:underline;\">%s</span>")
269 (verbatim .
"<code>%s</code>"))
270 "Alist of HTML expressions to convert text markup
272 The key must be a symbol among `bold', `code', `italic',
273 `strike-through', `underline' and `verbatim'. The value is
274 a formatting string to wrap fontified text with.
276 If no association can be found for a given markup, text will be
278 :group
'org-export-html
279 :type
'(alist :key-type
(symbol :tag
"Markup type")
280 :value-type
(string :tag
"Format string"))
281 :options
'(bold code italic strike-through underline verbatim
))
286 (defcustom org-html-pretty-output nil
287 "Enable this to generate pretty HTML."
288 :group
'org-export-html
294 (defcustom org-html-format-drawer-function nil
295 "Function called to format a drawer in HTML code.
297 The function must accept two parameters:
298 NAME the drawer name, like \"LOGBOOK\"
299 CONTENTS the contents of the drawer.
301 The function should return the string to be exported.
303 For example, the variable could be set to the following function
304 in order to mimic default behaviour:
306 \(defun org-html-format-drawer-default \(name contents\)
307 \"Format a drawer element for HTML export.\"
309 :group
'org-export-html
315 (defcustom org-html-footnotes-section
"<div id=\"footnotes\">
316 <h2 class=\"footnotes\">%s: </h2>
317 <div id=\"text-footnotes\">
321 "Format for the footnotes section.
322 Should contain a two instances of %s. The first will be replaced with the
323 language-specific word for \"Footnotes\", the second one will be replaced
324 by the footnotes themselves."
325 :group
'org-export-html
328 (defcustom org-html-footnote-format
"<sup>%s</sup>"
329 "The format for the footnote reference.
330 %s will be replaced by the footnote reference itself."
331 :group
'org-export-html
334 (defcustom org-html-footnote-separator
"<sup>, </sup>"
335 "Text used to separate footnotes."
336 :group
'org-export-html
342 (defcustom org-html-toplevel-hlevel
2
343 "The <H> level for level 1 headings in HTML export.
344 This is also important for the classes that will be wrapped around headlines
345 and outline structure. If this variable is 1, the top-level headlines will
346 be <h1>, and the corresponding classes will be outline-1, section-number-1,
347 and outline-text-1. If this is 2, all of these will get a 2 instead.
348 The default for this variable is 2, because we use <h1> for formatting the
350 :group
'org-export-html
353 (defcustom org-html-format-headline-function nil
354 "Function to format headline text.
356 This function will be called with 5 arguments:
357 TODO the todo keyword (string or nil).
358 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
359 PRIORITY the priority of the headline (integer or nil)
360 TEXT the main headline text (string).
361 TAGS the tags (string or nil).
363 The function result will be used in the section format string."
364 :group
'org-export-html
370 (defcustom org-html-allow-name-attribute-in-anchors t
371 "When nil, do not set \"name\" attribute in anchors.
372 By default, anchors are formatted with both \"id\" and \"name\"
373 attributes, when appropriate."
374 :group
'org-export-html
380 (defcustom org-html-format-inlinetask-function nil
381 "Function called to format an inlinetask in HTML code.
383 The function must accept six parameters:
384 TODO the todo keyword, as a string
385 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
386 PRIORITY the inlinetask priority, as a string
387 NAME the inlinetask name, as a string.
388 TAGS the inlinetask tags, as a list of strings.
389 CONTENTS the contents of the inlinetask, as a string.
391 The function should return the string to be exported.
393 For example, the variable could be set to the following function
394 in order to mimic default behaviour:
396 \(defun org-html-format-inlinetask \(todo type priority name tags contents\)
397 \"Format an inline task element for HTML export.\"
401 \(format \"\\\\textbf{\\\\textsf{\\\\textsc{%s}}} \" todo))
402 \(when priority (format \"\\\\framebox{\\\\#%c} \" priority))
404 \(when tags (format \"\\\\hfill{}\\\\textsc{%s}\" tags)))))
405 \(format (concat \"\\\\begin{center}\\n\"
407 \"\\\\begin{minipage}[c]{.6\\\\textwidth}\\n\"
409 \"\\\\rule[.8em]{\\\\textwidth}{2pt}\\n\\n\"
411 \"\\\\end{minipage}}\"
413 full-title contents))"
414 :group
'org-export-html
420 (defcustom org-html-with-latex org-export-with-latex
421 "Non-nil means process LaTeX math snippets.
423 When set, the exporter will process LaTeX environments and
426 This option can also be set with the +OPTIONS line,
427 e.g. \"tex:mathjax\". Allowed values are:
429 nil Ignore math snippets.
430 `verbatim' Keep everything in verbatim
431 `dvipng' Process the LaTeX fragments to images. This will also
432 include processing of non-math environments.
433 `imagemagick' Convert the LaTeX fragments to pdf files and use
434 imagemagick to convert pdf files to png files.
435 `mathjax' Do MathJax preprocessing and arrange for MathJax.js to
437 t Synonym for `mathjax'."
438 :group
'org-export-html
440 (const :tag
"Do not process math in any way" nil
)
441 (const :tag
"Use dvipng to make images" dvipng
)
442 (const :tag
"Use imagemagick to make images" imagemagick
)
443 (const :tag
"Use MathJax to display math" mathjax
)
444 (const :tag
"Leave math verbatim" verbatim
)))
447 ;;;; Links :: Generic
449 (defcustom org-html-link-org-files-as-html t
450 "Non-nil means make file links to `file.org' point to `file.html'.
451 When org-mode is exporting an org-mode file to HTML, links to
452 non-html files are directly put into a href tag in HTML.
453 However, links to other Org-mode files (recognized by the
454 extension `.org.) should become links to the corresponding html
455 file, assuming that the linked org-mode file will also be
457 When nil, the links still point to the plain `.org' file."
458 :group
'org-export-html
462 ;;;; Links :: Inline images
464 (defcustom org-html-inline-images
'maybe
465 "Non-nil means inline images into exported HTML pages.
466 This is done using an <img> tag. When nil, an anchor with href is used to
467 link to the image. If this option is `maybe', then images in links with
468 an empty description will be inlined, while images with a description will
470 :group
'org-export-html
471 :type
'(choice (const :tag
"Never" nil
)
472 (const :tag
"Always" t
)
473 (const :tag
"When there is no description" maybe
)))
475 (defcustom org-html-inline-image-rules
476 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
477 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
478 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
479 "Rules characterizing image files that can be inlined into HTML.
481 A rule consists in an association whose key is the type of link
482 to consider, and value is a regexp that will be matched against
485 Note that, by default, the image extension *actually* allowed
486 depend on the way the HTML file is processed. When used with
487 pdflatex, pdf, jpg and png images are OK. When processing
488 through dvi to Postscript, only ps and eps are allowed. The
489 default we use here encompasses both."
490 :group
'org-export-html
491 :type
'(alist :key-type
(string :tag
"Type")
492 :value-type
(regexp :tag
"Path")))
497 (defcustom org-html-protect-char-alist
501 "Alist of characters to be converted by `org-html-protect'."
502 :group
'org-export-html
503 :type
'(repeat (cons (string :tag
"Character")
504 (string :tag
"HTML equivalent"))))
509 (defcustom org-html-htmlize-output-type
'inline-css
510 "Output type to be used by htmlize when formatting code snippets.
511 Choices are `css', to export the CSS selectors only, or `inline-css', to
512 export the CSS attribute values inline in the HTML. We use as default
513 `inline-css', in order to make the resulting HTML self-containing.
515 However, this will fail when using Emacs in batch mode for export, because
516 then no rich font definitions are in place. It will also not be good if
517 people with different Emacs setup contribute HTML files to a website,
518 because the fonts will represent the individual setups. In these cases,
519 it is much better to let Org/Htmlize assign classes only, and to use
520 a style file to define the look of these classes.
521 To get a start for your css file, start Emacs session and make sure that
522 all the faces you are interested in are defined, for example by loading files
523 in all modes you want. Then, use the command
524 \\[org-html-htmlize-generate-css] to extract class definitions."
525 :group
'org-export-html
526 :type
'(choice (const css
) (const inline-css
)))
528 (defcustom org-html-htmlize-font-prefix
"org-"
529 "The prefix for CSS class names for htmlize font specifications."
530 :group
'org-export-html
533 (defcustom org-html-htmlized-org-css-url nil
534 "URL pointing to a CSS file defining text colors for htmlized Emacs buffers.
535 Normally when creating an htmlized version of an Org buffer, htmlize will
536 create CSS to define the font colors. However, this does not work when
537 converting in batch mode, and it also can look bad if different people
538 with different fontification setup work on the same website.
539 When this variable is non-nil, creating an htmlized version of an Org buffer
540 using `org-export-as-org' will include a link to this URL if the
541 setting of `org-html-htmlize-output-type' is 'css."
542 :group
'org-export-html
544 (const :tag
"Don't include external stylesheet link" nil
)
545 (string :tag
"URL or local href")))
550 (defcustom org-html-table-tag
551 "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
552 "The HTML tag that is used to start a table.
553 This must be a <table> tag, but you may change the options like
554 borders and spacing."
555 :group
'org-export-html
558 (defcustom org-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
559 "The opening tag for table header fields.
560 This is customizable so that alignment options can be specified.
561 The first %s will be filled with the scope of the field, either row or col.
562 The second %s will be replaced by a style entry to align the field.
563 See also the variable `org-html-table-use-header-tags-for-first-column'.
564 See also the variable `org-html-table-align-individual-fields'."
565 :group
'org-export-html
566 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
568 (defcustom org-html-table-data-tags
'("<td%s>" .
"</td>")
569 "The opening tag for table data fields.
570 This is customizable so that alignment options can be specified.
571 The first %s will be filled with the scope of the field, either row or col.
572 The second %s will be replaced by a style entry to align the field.
573 See also the variable `org-html-table-align-individual-fields'."
574 :group
'org-export-html
575 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
577 (defcustom org-html-table-row-tags
'("<tr>" .
"</tr>")
578 "The opening tag for table data fields.
579 This is customizable so that alignment options can be specified.
580 Instead of strings, these can be Lisp forms that will be evaluated
581 for each row in order to construct the table row tags. During evaluation,
582 the variable `head' will be true when this is a header line, nil when this
583 is a body line. And the variable `nline' will contain the line number,
584 starting from 1 in the first header line. For example
586 (setq org-html-table-row-tags
589 (if (= (mod nline 2) 1)
590 \"<tr class=\\\"tr-odd\\\">\"
591 \"<tr class=\\\"tr-even\\\">\"))
594 will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
595 :group
'org-export-html
597 (choice :tag
"Opening tag"
598 (string :tag
"Specify")
600 (choice :tag
"Closing tag"
601 (string :tag
"Specify")
604 (defcustom org-html-table-align-individual-fields t
605 "Non-nil means attach style attributes for alignment to each table field.
606 When nil, alignment will only be specified in the column tags, but this
607 is ignored by some browsers (like Firefox, Safari). Opera does it right
609 :group
'org-export-html
612 (defcustom org-html-table-use-header-tags-for-first-column nil
613 "Non-nil means format column one in tables with header tags.
614 When nil, also column one will use data tags."
615 :group
'org-export-html
618 (defcustom org-html-table-caption-above t
619 "When non-nil, place caption string at the beginning of the table.
620 Otherwise, place it near the end."
621 :group
'org-export-html
627 (defcustom org-html-tag-class-prefix
""
628 "Prefix to class names for TODO keywords.
629 Each tag gets a class given by the tag itself, with this prefix.
630 The default prefix is empty because it is nice to just use the keyword
631 as a class name. But if you get into conflicts with other, existing
632 CSS classes, then this prefix can be very useful."
633 :group
'org-export-html
637 ;;;; Template :: Generic
639 (defcustom org-html-extension
"html"
640 "The extension for exported HTML files."
641 :group
'org-export-html
644 (defcustom org-html-xml-declaration
645 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
646 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
647 "The extension for exported HTML files.
648 %s will be replaced with the charset of the exported file.
649 This may be a string, or an alist with export extensions
650 and corresponding declarations."
651 :group
'org-export-html
653 (string :tag
"Single declaration")
654 (repeat :tag
"Dependent on extension"
655 (cons (string :tag
"Extension")
656 (string :tag
"Declaration")))))
658 (defcustom org-html-coding-system
'utf-8
659 "Coding system for HTML export.
660 Use utf-8 as the default value."
661 :group
'org-export-html
662 :type
'coding-system
)
664 (defcustom org-html-divs
'("preamble" "content" "postamble")
665 "The name of the main divs for HTML export.
666 This is a list of three strings, the first one for the preamble
667 DIV, the second one for the content DIV and the third one for the
669 :group
'org-export-html
671 (string :tag
" Div for the preamble:")
672 (string :tag
" Div for the content:")
673 (string :tag
"Div for the postamble:")))
676 ;;;; Template :: Mathjax
678 (defcustom org-html-mathjax-options
679 '((path "http://orgmode.org/mathjax/MathJax.js")
684 "Options for MathJax setup.
686 path The path where to find MathJax
687 scale Scaling for the HTML-CSS backend, usually between 100 and 133
688 align How to align display math: left, center, or right
689 indent If align is not center, how far from the left/right side?
690 mathml Should a MathML player be used if available?
691 This is faster and reduces bandwidth use, but currently
692 sometimes has lower spacing quality. Therefore, the default is
693 nil. When browsers get better, this switch can be flipped.
695 You can also customize this for each buffer, using something like
697 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
698 :group
'org-export-html
699 :type
'(list :greedy t
700 (list :tag
"path (the path from where to load MathJax.js)"
701 (const :format
" " path
) (string))
702 (list :tag
"scale (scaling for the displayed math)"
703 (const :format
" " scale
) (string))
704 (list :tag
"align (alignment of displayed equations)"
705 (const :format
" " align
) (string))
706 (list :tag
"indent (indentation with left or right alignment)"
707 (const :format
" " indent
) (string))
708 (list :tag
"mathml (should MathML display be used is possible)"
709 (const :format
" " mathml
) (boolean))))
711 (defcustom org-html-mathjax-template
712 "<script type=\"text/javascript\" src=\"%PATH\">
713 <!--/*--><![CDATA[/*><!--*/
715 // Only one of the two following lines, depending on user settings
716 // First allows browser-native MathML display, second forces HTML/CSS
717 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
718 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
719 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
720 \"TeX/noUndefined.js\"],
722 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
723 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
724 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
725 ignoreClass: \"tex2jax_ignore\",
726 processEscapes: false,
727 processEnvironments: true,
730 showProcessingMessages: true,
731 displayAlign: \"%ALIGN\",
732 displayIndent: \"%INDENT\",
736 availableFonts: [\"STIX\",\"TeX\"],
737 preferredFont: \"TeX\",
753 "The MathJax setup for XHTML files."
754 :group
'org-export-html
758 ;;;; Template :: Postamble
760 (defcustom org-html-postamble
'auto
761 "Non-nil means insert a postamble in HTML export.
763 When `t', insert a string as defined by the formatting string in
764 `org-html-postamble-format'. When set to a string, this
765 string overrides `org-html-postamble-format'. When set to
766 'auto, discard `org-html-postamble-format' and honor
767 `org-export-author/email/creator-info' variables. When set to a
768 function, apply this function and insert the returned string.
769 The function takes the property list of export options as its
772 Setting :html-postamble in publishing projects will take
773 precedence over this variable."
774 :group
'org-export-html
775 :type
'(choice (const :tag
"No postamble" nil
)
776 (const :tag
"Auto preamble" 'auto
)
777 (const :tag
"Default formatting string" t
)
778 (string :tag
"Custom formatting string")
779 (function :tag
"Function (must return a string)")))
781 (defcustom org-html-postamble-format
782 '(("en" "<p class=\"author\">Author: %a (%e)</p>
783 <p class=\"date\">Date: %d</p>
784 <p class=\"creator\">Generated by %c</p>
785 <p class=\"xhtml-validation\">%v</p>"))
786 "Alist of languages and format strings for the HTML postamble.
788 The first element of each list is the language code, as used for
789 the #+LANGUAGE keyword.
791 The second element of each list is a format string to format the
792 postamble itself. This format string can contain these elements:
794 %a stands for the author's name.
795 %e stands for the author's email.
796 %d stands for the date.
797 %c will be replaced by information about Org/Emacs versions.
798 %v will be replaced by `org-html-validation-link'.
800 If you need to use a \"%\" character, you need to escape it
802 :group
'org-export-html
803 :type
'(alist :key-type
(string :tag
"Language")
804 :value-type
(string :tag
"Format string")))
806 (defcustom org-html-validation-link
807 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
808 "Link to HTML validation service."
809 :group
'org-export-html
812 (defcustom org-html-creator-string
813 (format "Generated by <a href=\"http://orgmode.org\">Org</a> mode %s in <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s."
814 (if (fboundp 'org-version
) (org-version) "(Unknown)")
816 "String to insert at the end of the HTML document."
817 :group
'org-export-html
818 :type
'(string :tag
"Creator string"))
821 ;;;; Template :: Preamble
823 (defcustom org-html-preamble t
824 "Non-nil means insert a preamble in HTML export.
826 When `t', insert a string as defined by one of the formatting
827 strings in `org-html-preamble-format'. When set to a
828 string, this string overrides `org-html-preamble-format'.
829 When set to a function, apply this function and insert the
830 returned string. The function takes the property list of export
831 options as its only argument.
833 Setting :html-preamble in publishing projects will take
834 precedence over this variable."
835 :group
'org-export-html
836 :type
'(choice (const :tag
"No preamble" nil
)
837 (const :tag
"Default preamble" t
)
838 (string :tag
"Custom formatting string")
839 (function :tag
"Function (must return a string)")))
841 (defcustom org-html-preamble-format
'(("en" ""))
842 "Alist of languages and format strings for the HTML preamble.
844 The first element of each list is the language code, as used for
845 the #+LANGUAGE keyword.
847 The second element of each list is a format string to format the
848 preamble itself. This format string can contain these elements:
850 %t stands for the title.
851 %a stands for the author's name.
852 %e stands for the author's email.
853 %d stands for the date.
855 If you need to use a \"%\" character, you need to escape it
857 :group
'org-export-html
858 :type
'(alist :key-type
(string :tag
"Language")
859 :value-type
(string :tag
"Format string")))
861 (defcustom org-html-link-up
""
862 "Where should the \"UP\" link of exported HTML pages lead?"
863 :group
'org-export-html
864 :type
'(string :tag
"File or URL"))
866 (defcustom org-html-link-home
""
867 "Where should the \"HOME\" link of exported HTML pages lead?"
868 :group
'org-export-html
869 :type
'(string :tag
"File or URL"))
871 (defcustom org-html-home
/up-format
872 "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
873 <a accesskey=\"h\" href=\"%s\"> UP </a>
875 <a accesskey=\"H\" href=\"%s\"> HOME </a>
877 "Snippet used to insert the HOME and UP links.
878 This is a format string, the first %s will receive the UP link,
879 the second the HOME link. If both `org-html-link-up' and
880 `org-html-link-home' are empty, the entire snippet will be
882 :group
'org-export-html
886 ;;;; Template :: Scripts
888 (defcustom org-html-style-include-scripts t
889 "Non-nil means include the JavaScript snippets in exported HTML files.
890 The actual script is defined in `org-html-scripts' and should
892 :group
'org-export-html
896 ;;;; Template :: Styles
898 (defcustom org-html-style-include-default t
899 "Non-nil means include the default style in exported HTML files.
900 The actual style is defined in `org-html-style-default' and should
901 not be modified. Use the variables `org-html-style' to add
902 your own style information."
903 :group
'org-export-html
906 (put 'org-html-style-include-default
'safe-local-variable
'booleanp
)
908 (defcustom org-html-style
""
909 "Org-wide style definitions for exported HTML files.
911 This variable needs to contain the full HTML structure to provide a style,
912 including the surrounding HTML tags. If you set the value of this variable,
913 you should consider to include definitions for the following classes:
914 title, todo, done, timestamp, timestamp-kwd, tag, target.
916 For example, a valid value would be:
918 <style type=\"text/css\">
920 p { font-weight: normal; color: gray; }
922 .title { text-align: center; }
923 .todo, .timestamp-kwd { color: red; }
924 .done { color: green; }
928 If you'd like to refer to an external style file, use something like
930 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
932 As the value of this option simply gets inserted into the HTML <head> header,
933 you can \"misuse\" it to add arbitrary text to the header.
934 See also the variable `org-html-style-extra'."
935 :group
'org-export-html
938 (put 'org-html-style
'safe-local-variable
'stringp
)
940 (defcustom org-html-style-extra
""
941 "Additional style information for HTML export.
942 The value of this variable is inserted into the HTML buffer right after
943 the value of `org-html-style'. Use this variable for per-file
944 settings of style information, and do not forget to surround the style
945 settings with <style>...</style> tags."
946 :group
'org-export-html
949 (put 'org-html-style-extra
'safe-local-variable
'stringp
)
954 (defcustom org-html-todo-kwd-class-prefix
""
955 "Prefix to class names for TODO keywords.
956 Each TODO keyword gets a class given by the keyword itself, with this prefix.
957 The default prefix is empty because it is nice to just use the keyword
958 as a class name. But if you get into conflicts with other, existing
959 CSS classes, then this prefix can be very useful."
960 :group
'org-export-html
963 (defcustom org-html-display-buffer-mode
'html-mode
964 "Default mode when visiting the HTML output."
965 :group
'org-export-html
967 :package-version
'(Org .
"8.0")
968 :type
'(choice (function 'html-mode
)
969 (function 'nxml-mode
)
970 (function :tag
"Other mode")))
974 ;;; Internal Functions
976 (defun org-html-format-inline-image (src &optional
977 caption label attr standalone-p
)
978 (let* ((id (if (not label
) ""
979 (format " id=\"%s\"" (org-export-solidify-link-text label
))))
982 ((string-match "\\<alt=" (or attr
"")) "")
983 ((string-match "^ltxpng/" src
)
984 (format " alt=\"%s\""
985 (org-html-encode-plain-text
986 (org-find-text-property-in-string
987 'org-latex-src src
))))
988 (t (format " alt=\"%s\""
989 (file-name-nondirectory src
)))))))
992 (let ((img (format "<img src=\"%s\" %s/>" src attr
)))
993 (format "\n<div%s class=\"figure\">%s%s\n</div>"
994 id
(format "\n<p>%s</p>" img
)
995 (when caption
(format "\n<p>%s</p>" caption
)))))
996 (t (format "<img src=\"%s\" %s/>" src
(concat attr id
))))))
998 (defun org-html--textarea-block (element)
999 "Transcode ELEMENT into a textarea block.
1000 ELEMENT is either a src block or an example block."
1001 (let ((code (car (org-export-unravel-code element
)))
1002 (attr (org-export-read-attribute :attr_html element
)))
1003 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>"
1004 (or (plist-get attr
:width
) 80)
1005 (or (plist-get attr
:height
) (org-count-lines code
))
1011 (defun org-html-bibliography ()
1012 "Find bibliography, cut it out and return it."
1014 (let (beg end
(cnt 1) bib
)
1016 (goto-char (point-min))
1017 (when (re-search-forward
1018 "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t
)
1019 (setq beg
(match-beginning 0))
1020 (while (re-search-forward "</?div\\>" nil t
)
1021 (setq cnt
(+ cnt
(if (string= (match-string 0) "<div") +1 -
1)))
1023 (and (looking-at ">") (forward-char 1))
1024 (setq bib
(buffer-substring beg
(point)))
1025 (delete-region beg
(point))
1026 (throw 'exit bib
))))
1031 (defun org-html-splice-attributes (tag attributes
)
1032 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
1033 (if (not attributes
)
1035 (let (oldatt newatt
)
1036 (setq oldatt
(org-extract-attributes-from-string tag
)
1038 newatt
(cdr (org-extract-attributes-from-string attributes
)))
1040 (setq oldatt
(plist-put oldatt
(pop newatt
) (pop newatt
))))
1041 (if (string-match ">" tag
)
1043 (replace-match (concat (org-attributes-to-string oldatt
) ">")
1047 (defun org-export-splice-style (style extra
)
1048 "Splice EXTRA into STYLE, just before \"</style>\"."
1049 (if (and (stringp extra
)
1050 (string-match "\\S-" extra
)
1051 (string-match "</style>" style
))
1052 (concat (substring style
0 (match-beginning 0))
1054 (substring style
(match-beginning 0)))
1057 (defun org-html-htmlize-region-for-paste (beg end
)
1058 "Convert the region to HTML, using htmlize.el.
1059 This is much like `htmlize-region-for-paste', only that it uses
1060 the settings define in the org-... variables."
1061 (let* ((htmlize-output-type org-html-htmlize-output-type
)
1062 (htmlize-css-name-prefix org-html-htmlize-font-prefix
)
1063 (htmlbuf (htmlize-region beg end
)))
1065 (with-current-buffer htmlbuf
1066 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1067 (plist-get htmlize-buffer-places
'content-end
)))
1068 (kill-buffer htmlbuf
))))
1071 (defun org-html-htmlize-generate-css ()
1072 "Create the CSS for all font definitions in the current Emacs session.
1073 Use this to create face definitions in your CSS style file that can then
1074 be used by code snippets transformed by htmlize.
1075 This command just produces a buffer that contains class definitions for all
1076 faces used in the current Emacs session. You can copy and paste the ones you
1077 need into your CSS file.
1079 If you then set `org-html-htmlize-output-type' to `css', calls
1080 to the function `org-html-htmlize-region-for-paste' will
1081 produce code that uses these same face definitions."
1084 (and (get-buffer "*html*") (kill-buffer "*html*"))
1086 (let ((fl (face-list))
1087 (htmlize-css-name-prefix "org-")
1088 (htmlize-output-type 'css
)
1090 (while (setq f
(pop fl
)
1091 i
(and f
(face-attribute f
:inherit
)))
1092 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1093 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1094 (htmlize-region (point-min) (point-max))))
1095 (org-pop-to-buffer-same-window "*html*")
1096 (goto-char (point-min))
1097 (if (re-search-forward "<style" nil t
)
1098 (delete-region (point-min) (match-beginning 0)))
1099 (if (re-search-forward "</style>" nil t
)
1100 (delete-region (1+ (match-end 0)) (point-max)))
1101 (beginning-of-line 1)
1102 (if (looking-at " +") (replace-match ""))
1103 (goto-char (point-min)))
1105 (defun org-html--make-string (n string
)
1106 "Build a string by concatenating N times STRING."
1107 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1109 (defun org-html-fix-class-name (kwd) ; audit callers of this function
1110 "Turn todo keyword into a valid class name.
1111 Replaces invalid characters with \"_\"."
1113 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1114 (setq kwd
(replace-match "_" t t kwd
))))
1117 (defun org-html-format-footnote-reference (n def refcnt
)
1118 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1119 (format org-html-footnote-format
1120 (let* ((id (format "fnr.%s%s" n extra
))
1121 (href (format " href=\"#fn.%s\"" n
))
1122 (attributes (concat " class=\"footref\"" href
)))
1123 (org-html--anchor id n attributes
)))))
1125 (defun org-html-format-footnotes-section (section-name definitions
)
1126 (if (not definitions
) ""
1127 (format org-html-footnotes-section section-name definitions
)))
1129 (defun org-html-format-footnote-definition (fn)
1130 (let ((n (car fn
)) (def (cdr fn
)))
1132 "<tr>\n<td>%s</td>\n<td>%s</td>\n</tr>\n"
1133 (format org-html-footnote-format
1134 (let* ((id (format "fn.%s" n
))
1135 (href (format " href=\"#fnr.%s\"" n
))
1136 (attributes (concat " class=\"footnum\"" href
)))
1137 (org-html--anchor id n attributes
)))
1140 (defun org-html-footnote-section (info)
1141 (let* ((fn-alist (org-export-collect-footnote-definitions
1142 (plist-get info
:parse-tree
) info
))
1145 (loop for
(n type raw
) in fn-alist collect
1146 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1147 (org-trim (org-export-data raw info
))
1149 (org-trim (org-export-data raw info
))))))))
1151 (org-html-format-footnotes-section
1152 (org-html--translate "Footnotes" info
)
1154 "<table>\n%s\n</table>\n"
1155 (mapconcat 'org-html-format-footnote-definition fn-alist
"\n"))))))
1161 (defun org-html--build-meta-info (info)
1162 "Return meta tags for exported document.
1163 INFO is a plist used as a communication channel."
1164 (let* ((title (org-export-data (plist-get info
:title
) info
))
1165 (author (and (plist-get info
:with-author
)
1166 (let ((auth (plist-get info
:author
)))
1167 (and auth
(org-export-data auth info
)))))
1168 (date (and (plist-get info
:with-date
)
1169 (let ((date (plist-get info
:date
)))
1170 (and date
(org-export-data date info
)))))
1171 (description (plist-get info
:description
))
1172 (keywords (plist-get info
:keywords
)))
1174 (format "<title>%s</title>\n" title
)
1176 "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>\n"
1177 (or (and org-html-coding-system
1178 (fboundp 'coding-system-get
)
1179 (coding-system-get org-html-coding-system
'mime-charset
))
1181 (format "<meta name=\"title\" content=\"%s\"/>\n" title
)
1182 (format "<meta name=\"generator\" content=\"Org-mode\"/>\n")
1183 (and date
(format "<meta name=\"generated\" content=\"%s\"/>\n" date
))
1184 (and author
(format "<meta name=\"author\" content=\"%s\"/>\n" author
))
1186 (format "<meta name=\"description\" content=\"%s\"/>\n" description
))
1188 (format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords
)))))
1190 (defun org-html--build-style (info)
1191 "Return style information for exported document.
1192 INFO is a plist used as a communication channel."
1193 (org-element-normalize-string
1195 (when (plist-get info
:html-style-include-default
)
1196 (org-element-normalize-string org-html-style-default
))
1197 (org-element-normalize-string (plist-get info
:html-style
))
1198 (when (and (plist-get info
:html-htmlized-css-url
)
1199 (eq org-html-htmlize-output-type
'css
))
1200 (format "<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\" />\n"
1201 (plist-get info
:html-htmlized-css-url
)))
1202 (org-element-normalize-string (plist-get info
:html-style-extra
))
1203 (when (plist-get info
:html-style-include-scripts
) org-html-scripts
))))
1205 (defun org-html--build-mathjax-config (info)
1206 "Insert the user setup into the mathjax template.
1207 INFO is a plist used as a communication channel."
1208 (when (and (memq (plist-get info
:with-latex
) '(mathjax t
))
1209 (org-element-map (plist-get info
:parse-tree
)
1210 '(latex-fragment latex-environment
) 'identity info t
))
1211 (let ((template org-html-mathjax-template
)
1212 (options org-html-mathjax-options
)
1213 (in-buffer (or (plist-get info
:html-mathjax
) ""))
1214 name val
(yes " ") (no "// ") x
)
1217 (setq name
(car e
) val
(nth 1 e
))
1218 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1219 (setq val
(car (read-from-string
1220 (substring in-buffer
(match-end 0))))))
1221 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1222 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1223 (setq template
(replace-match val t t template
))))
1225 (setq val
(nth 1 (assq 'mathml options
)))
1226 (if (string-match (concat "\\<mathml:") in-buffer
)
1227 (setq val
(car (read-from-string
1228 (substring in-buffer
(match-end 0))))))
1229 ;; Exchange prefixes depending on mathml setting.
1230 (if (not val
) (setq x yes yes no no x
))
1231 ;; Replace cookies to turn on or off the config/jax lines.
1232 (if (string-match ":MMLYES:" template
)
1233 (setq template
(replace-match yes t t template
)))
1234 (if (string-match ":MMLNO:" template
)
1235 (setq template
(replace-match no t t template
)))
1236 ;; Return the modified template.
1237 (org-element-normalize-string template
))))
1239 (defun org-html--build-preamble (info)
1240 "Return document preamble as a string, or nil.
1241 INFO is a plist used as a communication channel."
1242 (let ((preamble (plist-get info
:html-preamble
)))
1244 (let ((preamble-contents
1245 (if (functionp preamble
) (funcall preamble info
)
1246 (let ((title (org-export-data (plist-get info
:title
) info
))
1247 (date (if (not (plist-get info
:with-date
)) ""
1248 (org-export-data (plist-get info
:date
) info
)))
1249 (author (if (not (plist-get info
:with-author
)) ""
1250 (org-export-data (plist-get info
:author
) info
)))
1251 (email (if (not (plist-get info
:with-email
)) ""
1252 (plist-get info
:email
))))
1253 (if (stringp preamble
)
1254 (format-spec preamble
1255 `((?t .
,title
) (?a .
,author
)
1256 (?d .
,date
) (?e .
,email
)))
1258 (or (cadr (assoc (plist-get info
:language
)
1259 org-html-preamble-format
))
1260 (cadr (assoc "en" org-html-preamble-format
)))
1261 `((?t .
,title
) (?a .
,author
)
1262 (?d .
,date
) (?e .
,email
))))))))
1263 (when (org-string-nw-p preamble-contents
)
1264 (concat (format "<div id=\"%s\">\n" (nth 0 org-html-divs
))
1265 (org-element-normalize-string preamble-contents
)
1268 (defun org-html--build-postamble (info)
1269 "Return document postamble as a string, or nil.
1270 INFO is a plist used as a communication channel."
1271 (let ((postamble (plist-get info
:html-postamble
)))
1273 (let ((postamble-contents
1274 (if (functionp postamble
) (funcall postamble info
)
1275 (let ((date (if (not (plist-get info
:with-date
)) ""
1276 (org-export-data (plist-get info
:date
) info
)))
1277 (author (let ((author (plist-get info
:author
)))
1278 (and author
(org-export-data author info
))))
1281 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1282 (split-string (plist-get info
:email
) ",+ *")
1284 (html-validation-link (or org-html-validation-link
""))
1285 (creator-info (plist-get info
:creator
)))
1286 (cond ((stringp postamble
)
1287 (format-spec postamble
1288 `((?a .
,author
) (?e .
,email
)
1289 (?d .
,date
) (?c .
,creator-info
)
1290 (?v .
,html-validation-link
))))
1291 ((eq postamble
'auto
)
1293 (when (plist-get info
:time-stamp-file
)
1294 (format "<p class=\"date\">%s: %s</p>\n"
1295 (org-html--translate "Date" info
)
1297 (when (and (plist-get info
:with-author
) author
)
1298 (format "<p class=\"author\">%s : %s</p>\n"
1299 (org-html--translate "Author" info
)
1301 (when (and (plist-get info
:with-email
) email
)
1302 (format "<p class=\"email\">%s </p>\n" email
))
1303 (when (plist-get info
:with-creator
)
1304 (format "<p class=\"creator\">%s</p>\n"
1306 html-validation-link
"\n"))
1308 (or (cadr (assoc (plist-get info
:language
)
1309 org-html-postamble-format
))
1310 (cadr (assoc "en" org-html-postamble-format
)))
1311 `((?a .
,author
) (?e .
,email
)
1312 (?d .
,date
) (?c .
,creator-info
)
1313 (?v .
,html-validation-link
)))))))))
1314 (when (org-string-nw-p postamble-contents
)
1316 (format "<div id=\"%s\">\n" (nth 2 org-html-divs
))
1317 (org-element-normalize-string postamble-contents
)
1320 (defun org-html-inner-template (contents info
)
1321 "Return body of document string after HTML conversion.
1322 CONTENTS is the transcoded contents string. INFO is a plist
1323 holding export options."
1325 (format "<div id=\"%s\">\n" (nth 1 org-html-divs
))
1327 (format "<h1 class=\"title\">%s</h1>\n"
1328 (org-export-data (plist-get info
:title
) info
))
1329 ;; Table of contents.
1330 (let ((depth (plist-get info
:with-toc
)))
1331 (when depth
(org-html-toc depth info
)))
1332 ;; Document contents.
1334 ;; Footnotes section.
1335 (org-html-footnote-section info
)
1337 (org-html-bibliography)
1340 (defun org-html-template (contents info
)
1341 "Return complete document string after HTML conversion.
1342 CONTENTS is the transcoded contents string. INFO is a plist
1343 holding export options."
1346 (or (and (stringp org-html-xml-declaration
)
1347 org-html-xml-declaration
)
1348 (cdr (assoc (plist-get info
:html-extension
)
1349 org-html-xml-declaration
))
1350 (cdr (assoc "html" org-html-xml-declaration
))
1353 (or (and org-html-coding-system
1354 (fboundp 'coding-system-get
)
1355 (coding-system-get org-html-coding-system
'mime-charset
))
1358 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
1359 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
1360 (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n"
1361 (plist-get info
:language
) (plist-get info
:language
))
1363 (org-html--build-meta-info info
)
1364 (org-html--build-style info
)
1365 (org-html--build-mathjax-config info
)
1368 (let ((link-up (org-trim (plist-get info
:html-link-up
)))
1369 (link-home (org-trim (plist-get info
:html-link-home
))))
1370 (unless (and (string= link-up
"") (string= link-up
""))
1371 (format org-html-home
/up-format
1372 (or link-up link-home
)
1373 (or link-home link-up
))))
1375 (org-html--build-preamble info
)
1376 ;; Document contents.
1379 (org-html--build-postamble info
)
1380 ;; Closing document.
1381 "</body>\n</html>"))
1383 (defun org-html--translate (s info
)
1384 "Translate string S according to specified language.
1385 INFO is a plist used as a communication channel."
1386 (org-export-translate s
:html info
))
1390 (defun org-html--anchor (&optional id desc attributes
)
1391 (let* ((name (and org-html-allow-name-attribute-in-anchors id
))
1392 (attributes (concat (and id
(format " id=\"%s\"" id
))
1393 (and name
(format " name=\"%s\"" name
))
1395 (format "<a%s>%s</a>" attributes
(or desc
""))))
1399 (defun org-html--todo (todo)
1401 (format "<span class=\"%s %s%s\">%s</span>"
1402 (if (member todo org-done-keywords
) "done" "todo")
1403 org-html-todo-kwd-class-prefix
(org-html-fix-class-name todo
)
1408 (defun org-html--tags (tags)
1410 (format "<span class=\"tag\">%s</span>"
1413 (format "<span class=\"%s\">%s</span>"
1414 (concat org-html-tag-class-prefix
1415 (org-html-fix-class-name tag
))
1421 (defun* org-html-format-headline
1422 (todo todo-type priority text tags
1423 &key level section-number headline-label
&allow-other-keys
)
1424 (let ((section-number
1425 (when section-number
1426 (format "<span class=\"section-number-%d\">%s</span> "
1427 level section-number
)))
1428 (todo (org-html--todo todo
))
1429 (tags (org-html--tags tags
)))
1430 (concat section-number todo
(and todo
" ") text
1431 (and tags
" ") tags
)))
1435 (defun org-html-fontify-code (code lang
)
1436 "Color CODE with htmlize library.
1437 CODE is a string representing the source code to colorize. LANG
1438 is the language used for CODE, as a string, or nil."
1441 ;; Case 1: No lang. Possibly an example block.
1443 ;; Simple transcoding.
1444 (org-html-encode-plain-text code
))
1445 ;; Case 2: No htmlize or an inferior version of htmlize
1446 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1448 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1449 ;; Simple transcoding.
1450 (org-html-encode-plain-text code
))
1453 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1454 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1456 ;; Case 1: Language is not associated with any Emacs mode
1457 ((not (functionp lang-mode
))
1458 ;; Simple transcoding.
1459 (org-html-encode-plain-text code
))
1460 ;; Case 2: Default. Fontify code.
1463 (setq code
(with-temp-buffer
1464 ;; Switch to language-specific mode.
1468 (font-lock-fontify-buffer)
1469 ;; Remove formatting on newline characters.
1471 (let ((beg (point-min))
1474 (while (progn (end-of-line) (< (point) end
))
1475 (put-text-property (point) (1+ (point)) 'face nil
)
1478 (set-buffer-modified-p nil
)
1480 (org-html-htmlize-region-for-paste
1481 (point-min) (point-max))))
1482 ;; Strip any enclosing <pre></pre> tags.
1483 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code
) (match-end 0)))
1484 (end (and beg
(string-match "</pre>\\'" code
))))
1485 (if (and beg end
) (substring code beg end
) code
)))))))))
1487 (defun org-html-do-format-code
1488 (code &optional lang refs retain-labels num-start
)
1489 "Format CODE string as source code.
1490 Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
1491 respectively, the language of the source code, as a string, an
1492 alist between line numbers and references (as returned by
1493 `org-export-unravel-code'), a boolean specifying if labels should
1494 appear in the source code, and the number associated to the first
1496 (let* ((code-lines (org-split-string code
"\n"))
1497 (code-length (length code-lines
))
1501 (length (number-to-string (+ code-length num-start
))))))
1502 (code (org-html-fontify-code code lang
)))
1503 (org-export-format-code
1505 (lambda (loc line-num ref
)
1508 ;; Add line number, if needed.
1510 (format "<span class=\"linenr\">%s</span>"
1511 (format num-fmt line-num
)))
1512 ;; Transcoded src line.
1514 ;; Add label, if needed.
1515 (when (and ref retain-labels
) (format " (%s)" ref
))))
1516 ;; Mark transcoded line as an anchor, if needed.
1518 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1522 (defun org-html-format-code (element info
)
1523 "Format contents of ELEMENT as source code.
1524 ELEMENT is either an example block or a src block. INFO is
1525 a plist used as a communication channel."
1526 (let* ((lang (org-element-property :language element
))
1527 ;; Extract code and references.
1528 (code-info (org-export-unravel-code element
))
1529 (code (car code-info
))
1530 (refs (cdr code-info
))
1531 ;; Does the src block contain labels?
1532 (retain-labels (org-element-property :retain-labels element
))
1533 ;; Does it have line numbers?
1534 (num-start (case (org-element-property :number-lines element
)
1535 (continued (org-export-get-loc element info
))
1537 (org-html-do-format-code code lang refs retain-labels num-start
)))
1541 ;;; Tables of Contents
1543 (defun org-html-toc (depth info
)
1544 "Build a table of contents.
1545 DEPTH is an integer specifying the depth of the table. INFO is
1546 a plist used as a communication channel. Return the table of
1547 contents as a string, or nil if it is empty."
1549 (mapcar (lambda (headline)
1550 (cons (org-html--format-toc-headline headline info
)
1551 (org-export-get-relative-level headline info
)))
1552 (org-export-collect-headlines info depth
))))
1554 (concat "<div id=\"table-of-contents\">\n"
1555 (format "<h%d>%s</h%d>\n"
1556 org-html-toplevel-hlevel
1557 (org-html--translate "Table of Contents" info
)
1558 org-html-toplevel-hlevel
)
1559 "<div id=\"text-table-of-contents\">"
1560 (org-html--toc-text toc-entries
)
1564 (defun org-html--toc-text (toc-entries)
1565 "Return innards of a table of contents, as a string.
1566 TOC-ENTRIES is an alist where key is an entry title, as a string,
1567 and value is its relative level, as an integer."
1568 (let* ((prev-level (1- (cdar toc-entries
)))
1569 (start-level prev-level
))
1573 (let ((headline (car entry
))
1574 (level (cdr entry
)))
1576 (let* ((cnt (- level prev-level
))
1577 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1579 (setq prev-level level
)
1581 (org-html--make-string
1582 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1583 ((< cnt
0) "</li>\n</ul>\n")))
1584 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1587 (org-html--make-string (- prev-level start-level
) "</li>\n</ul>\n"))))
1589 (defun org-html--format-toc-headline (headline info
)
1590 "Return an appropriate table of contents entry for HEADLINE.
1591 INFO is a plist used as a communication channel."
1592 (let* ((headline-number (org-export-get-headline-number headline info
))
1594 (and (not (org-export-low-level-p headline info
))
1595 (org-export-numbered-headline-p headline info
)
1596 (concat (mapconcat 'number-to-string headline-number
".") ". ")))
1597 (tags (and (eq (plist-get info
:with-tags
) t
)
1598 (org-export-get-tags headline info
))))
1599 (format "<a href=\"#%s\">%s</a>"
1601 (org-export-solidify-link-text
1602 (or (org-element-property :CUSTOM_ID headline
)
1603 (concat "sec-" (mapconcat 'number-to-string
1604 headline-number
"-"))))
1606 (concat section-number
1608 (org-export-get-alt-title headline info
) info
)
1609 (and tags
" ") (org-html--tags tags
)))))
1611 (defun org-html-list-of-listings (info)
1612 "Build a list of listings.
1613 INFO is a plist used as a communication channel. Return the list
1614 of listings as a string, or nil if it is empty."
1615 (let ((lol-entries (org-export-collect-listings info
)))
1617 (concat "<div id=\"list-of-listings\">\n"
1618 (format "<h%d>%s</h%d>\n"
1619 org-html-toplevel-hlevel
1620 (org-html--translate "List of Listings" info
)
1621 org-html-toplevel-hlevel
)
1622 "<div id=\"text-list-of-listings\">\n<ul>\n"
1624 (initial-fmt (org-html--translate "Listing %d:" info
)))
1627 (let ((label (org-element-property :name entry
))
1630 (or (org-export-get-caption entry t
)
1631 (org-export-get-caption entry
))
1636 (concat (format initial-fmt
(incf count
)) " " title
)
1637 (format "<a href=\"#%s\">%s %s</a>"
1638 (org-export-solidify-link-text label
)
1639 (format initial-fmt
(incf count
))
1643 "\n</ul>\n</div>\n</div>"))))
1645 (defun org-html-list-of-tables (info)
1646 "Build a list of tables.
1647 INFO is a plist used as a communication channel. Return the list
1648 of tables as a string, or nil if it is empty."
1649 (let ((lol-entries (org-export-collect-tables info
)))
1651 (concat "<div id=\"list-of-tables\">\n"
1652 (format "<h%d>%s</h%d>\n"
1653 org-html-toplevel-hlevel
1654 (org-html--translate "List of Tables" info
)
1655 org-html-toplevel-hlevel
)
1656 "<div id=\"text-list-of-tables\">\n<ul>\n"
1658 (initial-fmt (org-html--translate "Table %d:" info
)))
1661 (let ((label (org-element-property :name entry
))
1664 (or (org-export-get-caption entry t
)
1665 (org-export-get-caption entry
))
1670 (concat (format initial-fmt
(incf count
)) " " title
)
1671 (format "<a href=\"#%s\">%s %s</a>"
1672 (org-export-solidify-link-text label
)
1673 (format initial-fmt
(incf count
))
1677 "\n</ul>\n</div>\n</div>"))))
1681 ;;; Transcode Functions
1685 (defun org-html-bold (bold contents info
)
1686 "Transcode BOLD from Org to HTML.
1687 CONTENTS is the text with bold markup. INFO is a plist holding
1688 contextual information."
1689 (format (or (cdr (assq 'bold org-html-text-markup-alist
)) "%s")
1695 (defun org-html-center-block (center-block contents info
)
1696 "Transcode a CENTER-BLOCK element from Org to HTML.
1697 CONTENTS holds the contents of the block. INFO is a plist
1698 holding contextual information."
1699 (format "<div style=\"text-align: center\">\n%s</div>" contents
))
1704 (defun org-html-clock (clock contents info
)
1705 "Transcode a CLOCK element from Org to HTML.
1706 CONTENTS is nil. INFO is a plist used as a communication
1709 <span class=\"timestamp-wrapper\">
1710 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
1715 (org-element-property :raw-value
1716 (org-element-property :value clock
)))
1717 (let ((time (org-element-property :duration clock
)))
1718 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
1723 (defun org-html-code (code contents info
)
1724 "Transcode CODE from Org to HTML.
1725 CONTENTS is nil. INFO is a plist holding contextual
1727 (format (or (cdr (assq 'code org-html-text-markup-alist
)) "%s")
1728 (org-element-property :value code
)))
1733 (defun org-html-drawer (drawer contents info
)
1734 "Transcode a DRAWER element from Org to HTML.
1735 CONTENTS holds the contents of the block. INFO is a plist
1736 holding contextual information."
1737 (if (functionp org-html-format-drawer-function
)
1738 (funcall org-html-format-drawer-function
1739 (org-element-property :drawer-name drawer
)
1741 ;; If there's no user defined function: simply
1742 ;; display contents of the drawer.
1748 (defun org-html-dynamic-block (dynamic-block contents info
)
1749 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
1750 CONTENTS holds the contents of the block. INFO is a plist
1751 holding contextual information. See `org-export-data'."
1757 (defun org-html-entity (entity contents info
)
1758 "Transcode an ENTITY object from Org to HTML.
1759 CONTENTS are the definition itself. INFO is a plist holding
1760 contextual information."
1761 (org-element-property :html entity
))
1766 (defun org-html-example-block (example-block contents info
)
1767 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
1768 CONTENTS is nil. INFO is a plist holding contextual
1770 (if (org-export-read-attribute :attr_html example-block
:textarea
)
1771 (org-html--textarea-block example-block
)
1772 (format "<pre class=\"example\">\n%s</pre>"
1773 (org-html-format-code example-block info
))))
1778 (defun org-html-export-snippet (export-snippet contents info
)
1779 "Transcode a EXPORT-SNIPPET object from Org to HTML.
1780 CONTENTS is nil. INFO is a plist holding contextual
1782 (when (eq (org-export-snippet-backend export-snippet
) 'html
)
1783 (org-element-property :value export-snippet
)))
1788 (defun org-html-export-block (export-block contents info
)
1789 "Transcode a EXPORT-BLOCK element from Org to HTML.
1790 CONTENTS is nil. INFO is a plist holding contextual information."
1791 (when (string= (org-element-property :type export-block
) "HTML")
1792 (org-remove-indentation (org-element-property :value export-block
))))
1797 (defun org-html-fixed-width (fixed-width contents info
)
1798 "Transcode a FIXED-WIDTH element from Org to HTML.
1799 CONTENTS is nil. INFO is a plist holding contextual information."
1800 (format "<pre class=\"example\">\n%s</pre>"
1801 (org-html-do-format-code
1802 (org-remove-indentation
1803 (org-element-property :value fixed-width
)))))
1806 ;;;; Footnote Reference
1808 (defun org-html-footnote-reference (footnote-reference contents info
)
1809 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
1810 CONTENTS is nil. INFO is a plist holding contextual information."
1812 ;; Insert separator between two footnotes in a row.
1813 (let ((prev (org-export-get-previous-element footnote-reference info
)))
1814 (when (eq (org-element-type prev
) 'footnote-reference
)
1815 org-html-footnote-separator
))
1817 ((not (org-export-footnote-first-reference-p footnote-reference info
))
1818 (org-html-format-footnote-reference
1819 (org-export-get-footnote-number footnote-reference info
)
1821 ;; Inline definitions are secondary strings.
1822 ((eq (org-element-property :type footnote-reference
) 'inline
)
1823 (org-html-format-footnote-reference
1824 (org-export-get-footnote-number footnote-reference info
)
1826 ;; Non-inline footnotes definitions are full Org data.
1827 (t (org-html-format-footnote-reference
1828 (org-export-get-footnote-number footnote-reference info
)
1834 (defun org-html-format-headline--wrap
1835 (headline info
&optional format-function
&rest extra-keys
)
1836 "Transcode a HEADLINE element from Org to HTML.
1837 CONTENTS holds the contents of the headline. INFO is a plist
1838 holding contextual information."
1839 (let* ((level (+ (org-export-get-relative-level headline info
)
1840 (1- org-html-toplevel-hlevel
)))
1841 (headline-number (org-export-get-headline-number headline info
))
1842 (section-number (and (not (org-export-low-level-p headline info
))
1843 (org-export-numbered-headline-p headline info
)
1844 (mapconcat 'number-to-string
1845 headline-number
".")))
1846 (todo (and (plist-get info
:with-todo-keywords
)
1847 (let ((todo (org-element-property :todo-keyword headline
)))
1848 (and todo
(org-export-data todo info
)))))
1849 (todo-type (and todo
(org-element-property :todo-type headline
)))
1850 (priority (and (plist-get info
:with-priority
)
1851 (org-element-property :priority headline
)))
1852 (text (org-export-data (org-element-property :title headline
) info
))
1853 (tags (and (plist-get info
:with-tags
)
1854 (org-export-get-tags headline info
)))
1855 (headline-label (or (org-element-property :CUSTOM_ID headline
)
1856 (concat "sec-" (mapconcat 'number-to-string
1857 headline-number
"-"))))
1858 (format-function (cond
1859 ((functionp format-function
) format-function
)
1860 ((functionp org-html-format-headline-function
)
1862 (lambda (todo todo-type priority text tags
1864 (funcall org-html-format-headline-function
1865 todo todo-type priority text tags
))))
1866 (t 'org-html-format-headline
))))
1867 (apply format-function
1868 todo todo-type priority text tags
1869 :headline-label headline-label
:level level
1870 :section-number section-number extra-keys
)))
1872 (defun org-html-headline (headline contents info
)
1873 "Transcode a HEADLINE element from Org to HTML.
1874 CONTENTS holds the contents of the headline. INFO is a plist
1875 holding contextual information."
1877 (setq contents
(or contents
""))
1878 (let* ((numberedp (org-export-numbered-headline-p headline info
))
1879 (level (org-export-get-relative-level headline info
))
1880 (text (org-export-data (org-element-property :title headline
) info
))
1881 (todo (and (plist-get info
:with-todo-keywords
)
1882 (let ((todo (org-element-property :todo-keyword headline
)))
1883 (and todo
(org-export-data todo info
)))))
1884 (todo-type (and todo
(org-element-property :todo-type headline
)))
1885 (tags (and (plist-get info
:with-tags
)
1886 (org-export-get-tags headline info
)))
1887 (priority (and (plist-get info
:with-priority
)
1888 (org-element-property :priority headline
)))
1889 (section-number (and (org-export-numbered-headline-p headline info
)
1890 (mapconcat 'number-to-string
1891 (org-export-get-headline-number
1892 headline info
) ".")))
1893 ;; Create the headline text.
1894 (full-text (org-html-format-headline--wrap headline info
)))
1896 ;; Case 1: This is a footnote section: ignore it.
1897 ((org-element-property :footnote-section-p headline
) nil
)
1898 ;; Case 2. This is a deep sub-tree: export it as a list item.
1899 ;; Also export as items headlines for which no section
1900 ;; format has been found.
1901 ((org-export-low-level-p headline info
)
1902 ;; Build the real contents of the sub-tree.
1903 (let* ((type (if numberedp
'ordered
'unordered
))
1904 (itemized-body (org-html-format-list-item
1905 contents type nil nil full-text
)))
1907 (and (org-export-first-sibling-p headline info
)
1908 (org-html-begin-plain-list type
))
1910 (and (org-export-last-sibling-p headline info
)
1911 (org-html-end-plain-list type
)))))
1912 ;; Case 3. Standard headline. Export it as a section.
1914 (let* ((section-number (mapconcat 'number-to-string
1915 (org-export-get-headline-number
1916 headline info
) "-"))
1918 (list (org-element-property :CUSTOM_ID headline
)
1919 (concat "sec-" section-number
)
1920 (org-element-property :ID headline
))))
1921 (preferred-id (car ids
))
1922 (extra-ids (cdr ids
))
1923 (extra-class (org-element-property :HTML_CONTAINER_CLASS headline
))
1924 (level1 (+ level
(1- org-html-toplevel-hlevel
))))
1925 (format "<div id=\"%s\" class=\"%s\">%s%s</div>\n"
1926 (format "outline-container-%s"
1927 (or (org-element-property :CUSTOM_ID headline
)
1929 (concat (format "outline-%d" level1
) (and extra-class
" ")
1931 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
1936 (let ((id (org-export-solidify-link-text
1937 (if (org-uuidgen-p x
) (concat "ID-" x
)
1939 (org-html--anchor id
)))
1946 ;;;; Horizontal Rule
1948 (defun org-html-horizontal-rule (horizontal-rule contents info
)
1949 "Transcode an HORIZONTAL-RULE object from Org to HTML.
1950 CONTENTS is nil. INFO is a plist holding contextual information."
1954 ;;;; Inline Src Block
1956 (defun org-html-inline-src-block (inline-src-block contents info
)
1957 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
1958 CONTENTS holds the contents of the item. INFO is a plist holding
1959 contextual information."
1960 (let* ((org-lang (org-element-property :language inline-src-block
))
1961 (code (org-element-property :value inline-src-block
)))
1962 (error "Cannot export inline src block")))
1967 (defun org-html-format-section (text class
&optional id
)
1968 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
1969 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
1971 (defun org-html-inlinetask (inlinetask contents info
)
1972 "Transcode an INLINETASK element from Org to HTML.
1973 CONTENTS holds the contents of the block. INFO is a plist
1974 holding contextual information."
1976 ;; If `org-html-format-inlinetask-function' is provided, call it
1977 ;; with appropriate arguments.
1978 ((functionp org-html-format-inlinetask-function
)
1979 (let ((format-function
1981 (lambda (todo todo-type priority text tags
1982 &key contents
&allow-other-keys
)
1983 (funcall org-html-format-inlinetask-function
1984 todo todo-type priority text tags contents
)))))
1985 (org-html-format-headline--wrap
1986 inlinetask info format-function
:contents contents
)))
1987 ;; Otherwise, use a default template.
1988 (t (format "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>"
1989 (org-html-format-headline--wrap inlinetask info
)
1995 (defun org-html-italic (italic contents info
)
1996 "Transcode ITALIC from Org to HTML.
1997 CONTENTS is the text with italic markup. INFO is a plist holding
1998 contextual information."
1999 (format (or (cdr (assq 'italic org-html-text-markup-alist
)) "%s") contents
))
2004 (defun org-html-checkbox (checkbox)
2005 (case checkbox
(on "<code>[X]</code>")
2006 (off "<code>[ ]</code>")
2007 (trans "<code>[-]</code>")
2010 (defun org-html-format-list-item (contents type checkbox
2011 &optional term-counter-id
2013 (let ((checkbox (concat (org-html-checkbox checkbox
) (and checkbox
" "))))
2017 (let* ((counter term-counter-id
)
2018 (extra (if counter
(format " value=\"%s\"" counter
) "")))
2020 (format "<li%s>" extra
)
2021 (when headline
(concat headline
"<br/>")))))
2023 (let* ((id term-counter-id
)
2024 (extra (if id
(format " id=\"%s\"" id
) "")))
2026 (format "<li%s>" extra
)
2027 (when headline
(concat headline
"<br/>")))))
2029 (let* ((term term-counter-id
))
2030 (setq term
(or term
"(no term)"))
2031 ;; Check-boxes in descriptive lists are associated to tag.
2032 (concat (format "<dt> %s </dt>"
2033 (concat checkbox term
))
2035 (unless (eq type
'descriptive
) checkbox
)
2040 (descriptive "</dd>")))))
2042 (defun org-html-item (item contents info
)
2043 "Transcode an ITEM element from Org to HTML.
2044 CONTENTS holds the contents of the item. INFO is a plist holding
2045 contextual information."
2046 (let* ((plain-list (org-export-get-parent item
))
2047 (type (org-element-property :type plain-list
))
2048 (counter (org-element-property :counter item
))
2049 (checkbox (org-element-property :checkbox item
))
2050 (tag (let ((tag (org-element-property :tag item
)))
2051 (and tag
(org-export-data tag info
)))))
2052 (org-html-format-list-item
2053 contents type checkbox
(or tag counter
))))
2058 (defun org-html-keyword (keyword contents info
)
2059 "Transcode a KEYWORD element from Org to HTML.
2060 CONTENTS is nil. INFO is a plist holding contextual information."
2061 (let ((key (org-element-property :key keyword
))
2062 (value (org-element-property :value keyword
)))
2064 ((string= key
"HTML") value
)
2065 ;; Invisible targets.
2066 ((string= key
"TARGET") nil
)
2067 ((string= key
"TOC")
2068 (let ((value (downcase value
)))
2070 ((string-match "\\<headlines\\>" value
)
2071 (let ((depth (or (and (string-match "[0-9]+" value
)
2072 (string-to-number (match-string 0 value
)))
2073 (plist-get info
:with-toc
))))
2074 (org-html-toc depth info
)))
2075 ((string= "listings" value
) (org-html-list-of-listings info
))
2076 ((string= "tables" value
) (org-html-list-of-tables info
))))))))
2079 ;;;; Latex Environment
2081 (defun org-html-format-latex (latex-frag processing-type
)
2082 "Format LaTeX fragments into HTML."
2083 (let ((cache-relpath "") (cache-dir "") bfn
)
2084 (unless (eq processing-type
'mathjax
)
2085 (setq bfn
(buffer-file-name)
2088 (file-name-sans-extension
2089 (file-name-nondirectory bfn
)))
2090 cache-dir
(file-name-directory bfn
)))
2093 (org-format-latex cache-relpath cache-dir nil
"Creating LaTeX Image..."
2094 nil nil processing-type
)
2097 (defun org-html-latex-environment (latex-environment contents info
)
2098 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2099 CONTENTS is nil. INFO is a plist holding contextual information."
2100 (let ((processing-type (plist-get info
:with-latex
))
2101 (latex-frag (org-remove-indentation
2102 (org-element-property :value latex-environment
)))
2103 (caption (org-export-data
2104 (org-export-get-caption latex-environment
) info
))
2106 (label (org-element-property :name latex-environment
)))
2108 ((memq processing-type
'(t mathjax
))
2109 (org-html-format-latex latex-frag
'mathjax
))
2110 ((eq processing-type
'dvipng
)
2111 (let* ((formula-link (org-html-format-latex
2112 latex-frag processing-type
)))
2113 (when (and formula-link
2114 (string-match "file:\\([^]]*\\)" formula-link
))
2115 (org-html-format-inline-image
2116 (match-string 1 formula-link
) caption label attr t
))))
2122 (defun org-html-latex-fragment (latex-fragment contents info
)
2123 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2124 CONTENTS is nil. INFO is a plist holding contextual information."
2125 (let ((latex-frag (org-element-property :value latex-fragment
))
2126 (processing-type (plist-get info
:with-latex
)))
2127 (case processing-type
2129 (org-html-format-latex latex-frag
'mathjax
))
2131 (let* ((formula-link (org-html-format-latex
2132 latex-frag processing-type
)))
2133 (when (and formula-link
2134 (string-match "file:\\([^]]*\\)" formula-link
))
2135 (org-html-format-inline-image
2136 (match-string 1 formula-link
)))))
2142 (defun org-html-line-break (line-break contents info
)
2143 "Transcode a LINE-BREAK object from Org to HTML.
2144 CONTENTS is nil. INFO is a plist holding contextual information."
2150 (defun org-html-link--inline-image (link desc info
)
2151 "Return HTML code for an inline image.
2152 LINK is the link pointing to the inline image. INFO is a plist
2153 used as a communication channel."
2154 (let* ((type (org-element-property :type link
))
2155 (raw-path (org-element-property :path link
))
2156 (path (cond ((member type
'("http" "https"))
2157 (concat type
":" raw-path
))
2158 ((file-name-absolute-p raw-path
)
2159 (expand-file-name raw-path
))
2161 (parent (org-export-get-parent-element link
))
2162 (caption (org-export-data (org-export-get-caption parent
) info
))
2163 (label (org-element-property :name parent
))
2164 ;; Retrieve latex attributes from the PARENT element. HACK:
2165 ;; Only do this for the first link in PARENT. This is needed
2166 ;; as long as attributes cannot be set on a per link basis.
2167 (attr (when (eq link
(org-element-map parent
'link
'identity info t
))
2169 (mapconcat #'identity
2170 (org-element-property :attr_html parent
)
2172 (unless (string= raw-attr
"") raw-attr
)))))
2173 ;; Now clear ATTR from any special keyword and set a default
2174 ;; value if nothing is left.
2175 (setq attr
(if (not attr
) "" (org-trim attr
)))
2176 ;; Return proper string, depending on DISPOSITION.
2177 (org-html-format-inline-image
2178 path caption label attr
(org-html-standalone-image-p link info
))))
2180 (defvar org-html-standalone-image-predicate
)
2181 (defun org-html-standalone-image-p (element info
&optional predicate
)
2182 "Test if ELEMENT is a standalone image for the purpose HTML export.
2183 INFO is a plist holding contextual information.
2185 Return non-nil, if ELEMENT is of type paragraph and it's sole
2186 content, save for whitespaces, is a link that qualifies as an
2189 Return non-nil, if ELEMENT is of type link and it's containing
2190 paragraph has no other content save for leading and trailing
2193 Return nil, otherwise.
2195 Bind `org-html-standalone-image-predicate' to constrain
2196 paragraph further. For example, to check for only captioned
2197 standalone images, do the following.
2199 \(setq org-html-standalone-image-predicate
2200 \(lambda \(paragraph\)
2201 \(org-element-property :caption paragraph\)\)\)"
2202 (let ((paragraph (case (org-element-type element
)
2204 (link (and (org-export-inline-image-p
2205 element org-html-inline-image-rules
)
2206 (org-export-get-parent element
)))
2208 (when (eq (org-element-type paragraph
) 'paragraph
)
2209 (when (or (not (and (boundp 'org-html-standalone-image-predicate
)
2210 (functionp org-html-standalone-image-predicate
)))
2211 (funcall org-html-standalone-image-predicate paragraph
))
2212 (let ((contents (org-element-contents paragraph
)))
2213 (loop for x in contents
2214 with inline-image-count
= 0
2216 ((eq (org-element-type x
) 'plain-text
)
2217 (not (org-string-nw-p x
)))
2218 ((eq (org-element-type x
) 'link
)
2219 (when (org-export-inline-image-p
2220 x org-html-inline-image-rules
)
2221 (= (incf inline-image-count
) 1)))
2224 (defun org-html-link (link desc info
)
2225 "Transcode a LINK object from Org to HTML.
2227 DESC is the description part of the link, or the empty string.
2228 INFO is a plist holding contextual information. See
2230 (let* ((--link-org-files-as-html-maybe
2232 (lambda (raw-path info
)
2233 "Treat links to `file.org' as links to `file.html', if needed.
2234 See `org-html-link-org-files-as-html'."
2236 ((and org-html-link-org-files-as-html
2238 (downcase (file-name-extension raw-path
"."))))
2239 (concat (file-name-sans-extension raw-path
) "."
2240 (plist-get info
:html-extension
)))
2242 (type (org-element-property :type link
))
2243 (raw-path (org-element-property :path link
))
2244 ;; Ensure DESC really exists, or set it to nil.
2245 (desc (and (not (string= desc
"")) desc
))
2248 ((member type
'("http" "https" "ftp" "mailto"))
2249 (concat type
":" raw-path
))
2250 ((string= type
"file")
2251 ;; Treat links to ".org" files as ".html", if needed.
2253 (funcall --link-org-files-as-html-maybe raw-path info
))
2254 ;; If file path is absolute, prepend it with protocol
2255 ;; component - "file://".
2256 (when (file-name-absolute-p raw-path
)
2258 (concat "file://" (expand-file-name raw-path
))))
2259 ;; Add search option, if any. A search option can be
2260 ;; relative to a custom-id or a headline title. Any other
2261 ;; option is ignored.
2262 (let ((option (org-element-property :search-option link
)))
2263 (cond ((not option
) raw-path
)
2264 ((eq (aref option
0) ?
#) (concat raw-path option
))
2265 ;; External fuzzy link: try to resolve it if path
2266 ;; belongs to current project, if any.
2267 ((eq (aref option
0) ?
*)
2271 (org-publish-resolve-external-fuzzy-link
2272 (org-element-property :path link
) option
)))
2273 (and numbers
(concat "#sec-"
2274 (mapconcat 'number-to-string
2275 numbers
"-")))))))))
2277 attributes protocol
)
2278 ;; Extract attributes from parent's paragraph. HACK: Only do this
2279 ;; for the first link in parent. This is needed as long as
2280 ;; attributes cannot be set on a per link basis.
2281 (and (setq attributes
2282 (let ((parent (org-export-get-parent-element link
)))
2283 (if (not (eq (org-element-map parent
'link
'identity info t
)
2288 (let ((att (org-element-property :attr_html parent
)))
2289 (unless (and desc att
2290 (string-match (regexp-quote (car att
)) desc
))
2293 (setq attributes
(concat " " attributes
)))
2296 ((and (or (eq t org-html-inline-images
)
2297 (and org-html-inline-images
(not desc
)))
2298 (org-export-inline-image-p link org-html-inline-image-rules
))
2299 (org-html-link--inline-image link desc info
))
2300 ;; Radio target: Transcode target's contents and use them as
2301 ;; link's description.
2302 ((string= type
"radio")
2303 (let ((destination (org-export-resolve-radio-link link info
)))
2305 (format "<a href=\"#%s\"%s>%s</a>"
2306 (org-export-solidify-link-text path
)
2308 (org-export-data (org-element-contents destination
) info
)))))
2309 ;; Links pointing to a headline: Find destination and build
2310 ;; appropriate referencing command.
2311 ((member type
'("custom-id" "fuzzy" "id"))
2312 (let ((destination (if (string= type
"fuzzy")
2313 (org-export-resolve-fuzzy-link link info
)
2314 (org-export-resolve-id-link link info
))))
2315 (case (org-element-type destination
)
2316 ;; ID link points to an external file.
2318 (let ((fragment (concat "ID-" path
))
2319 ;; Treat links to ".org" files as ".html", if needed.
2320 (path (funcall --link-org-files-as-html-maybe
2322 (format "<a href=\"%s#%s\"%s>%s</a>"
2323 path fragment attributes
(or desc destination
))))
2324 ;; Fuzzy link points nowhere.
2329 (org-element-property :raw-link link
) info
))))
2330 ;; Fuzzy link points to an invisible target.
2332 ;; Link points to a headline.
2335 ;; What href to use?
2337 ;; Case 1: Headline is linked via it's CUSTOM_ID
2338 ;; property. Use CUSTOM_ID.
2339 ((string= type
"custom-id")
2340 (org-element-property :CUSTOM_ID destination
))
2341 ;; Case 2: Headline is linked via it's ID property
2342 ;; or through other means. Use the default href.
2343 ((member type
'("id" "fuzzy"))
2345 (mapconcat 'number-to-string
2346 (org-export-get-headline-number
2347 destination info
) "-")))
2348 (t (error "Shouldn't reach here"))))
2349 ;; What description to use?
2351 ;; Case 1: Headline is numbered and LINK has no
2352 ;; description or LINK's description matches
2353 ;; headline's title. Display section number.
2354 (if (and (org-export-numbered-headline-p destination info
)
2356 (string= desc
(org-element-property
2357 :raw-value destination
))))
2358 (mapconcat 'number-to-string
2359 (org-export-get-headline-number
2360 destination info
) ".")
2361 ;; Case 2: Either the headline is un-numbered or
2362 ;; LINK has a custom description. Display LINK's
2363 ;; description or headline's title.
2364 (or desc
(org-export-data (org-element-property
2365 :title destination
) info
)))))
2366 (format "<a href=\"#%s\"%s>%s</a>"
2367 (org-export-solidify-link-text href
) attributes desc
)))
2368 ;; Fuzzy link points to a target. Do as above.
2370 (let ((path (org-export-solidify-link-text path
)) number
)
2373 ((org-html-standalone-image-p destination info
)
2374 (org-export-get-ordinal
2375 (assoc 'link
(org-element-contents destination
))
2376 info
'link
'org-html-standalone-image-p
))
2377 (t (org-export-get-ordinal destination info
))))
2378 (setq desc
(when number
2379 (if (atom number
) (number-to-string number
)
2380 (mapconcat 'number-to-string number
".")))))
2381 (format "<a href=\"#%s\"%s>%s</a>"
2382 path attributes
(or desc
"No description for this link")))))))
2383 ;; Coderef: replace link with the reference name or the
2384 ;; equivalent line number.
2385 ((string= type
"coderef")
2386 (let ((fragment (concat "coderef-" path
)))
2387 (format "<a href=\"#%s\" %s%s>%s</a>"
2389 (format (concat "class=\"coderef\""
2390 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2391 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2394 (format (org-export-get-coderef-format path desc
)
2395 (org-export-resolve-coderef path info
)))))
2396 ;; Link type is handled by a special function.
2397 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2398 (funcall protocol
(org-link-unescape path
) desc
'html
))
2399 ;; External link with a description part.
2400 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2401 ;; External link without a description part.
2402 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2403 ;; No path, only description. Try to do something useful.
2404 (t (format "<i>%s</i>" desc
)))))
2409 (defun org-html-paragraph (paragraph contents info
)
2410 "Transcode a PARAGRAPH element from Org to HTML.
2411 CONTENTS is the contents of the paragraph, as a string. INFO is
2412 the plist used as a communication channel."
2413 (let* ((style nil
) ; FIXME
2414 (class (cdr (assoc style
'((footnote .
"footnote")
2416 (extra (if class
(format " class=\"%s\"" class
) ""))
2417 (parent (org-export-get-parent paragraph
)))
2419 ((and (eq (org-element-type parent
) 'item
)
2420 (= (org-element-property :begin paragraph
)
2421 (org-element-property :contents-begin parent
)))
2422 ;; leading paragraph in a list item have no tags
2424 ((org-html-standalone-image-p paragraph info
)
2427 (t (format "<p%s>\n%s</p>" extra contents
)))))
2432 ;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
2433 ;; the correct value for the item counter
2434 (defun org-html-begin-plain-list (type &optional arg1
)
2435 "Insert the beginning of the HTML list depending on TYPE.
2436 When ARG1 is a string, use it as the start parameter for ordered
2440 (format "<ol class=\"org-ol\"%s>"
2441 (if arg1
(format " start=\"%d\"" arg1
) "")))
2442 (unordered "<ul class=\"org-ul\">")
2443 (descriptive "<dl class=\"org-dl\">")))
2445 (defun org-html-end-plain-list (type)
2446 "Insert the end of the HTML list depending on TYPE."
2450 (descriptive "</dl>")))
2452 (defun org-html-plain-list (plain-list contents info
)
2453 "Transcode a PLAIN-LIST element from Org to HTML.
2454 CONTENTS is the contents of the list. INFO is a plist holding
2455 contextual information."
2456 (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
2457 (type (org-element-property :type plain-list
)))
2459 (org-html-begin-plain-list type
)
2460 contents
(org-html-end-plain-list type
))))
2464 (defun org-html-convert-special-strings (string)
2465 "Convert special characters in STRING to HTML."
2466 (let ((all org-html-special-string-regexps
)
2468 (while (setq a
(pop all
))
2469 (setq re
(car a
) rpl
(cdr a
) start
0)
2470 (while (string-match re string start
)
2471 (setq string
(replace-match rpl t nil string
))))
2474 (defun org-html-encode-plain-text (text)
2475 "Convert plain text characters to HTML equivalent.
2476 Possible conversions are set in `org-export-html-protect-char-alist'."
2479 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2480 org-html-protect-char-alist
)
2483 (defun org-html-plain-text (text info
)
2484 "Transcode a TEXT string from Org to HTML.
2485 TEXT is the string to transcode. INFO is a plist holding
2486 contextual information."
2487 (let ((output text
))
2488 ;; Protect following characters: <, >, &.
2489 (setq output
(org-html-encode-plain-text output
))
2490 ;; Handle smart quotes. Be sure to provide original string since
2491 ;; OUTPUT may have been modified.
2492 (when (plist-get info
:with-smart-quotes
)
2493 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2494 ;; Handle special strings.
2495 (when (plist-get info
:with-special-strings
)
2496 (setq output
(org-html-convert-special-strings output
)))
2497 ;; Handle break preservation if required.
2498 (when (plist-get info
:preserve-breaks
)
2500 (replace-regexp-in-string
2501 "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output
)))
2508 (defun org-html-planning (planning contents info
)
2509 "Transcode a PLANNING element from Org to HTML.
2510 CONTENTS is nil. INFO is a plist used as a communication
2512 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2514 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2519 (let ((closed (org-element-property :closed planning
)))
2521 (format span-fmt org-closed-string
2523 (org-element-property :raw-value closed
)))))
2524 (let ((deadline (org-element-property :deadline planning
)))
2526 (format span-fmt org-deadline-string
2528 (org-element-property :raw-value deadline
)))))
2529 (let ((scheduled (org-element-property :scheduled planning
)))
2531 (format span-fmt org-scheduled-string
2533 (org-element-property :raw-value scheduled
)))))))
2537 ;;;; Property Drawer
2539 (defun org-html-property-drawer (property-drawer contents info
)
2540 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2541 CONTENTS is nil. INFO is a plist holding contextual
2543 ;; The property drawer isn't exported but we want separating blank
2544 ;; lines nonetheless.
2550 (defun org-html-quote-block (quote-block contents info
)
2551 "Transcode a QUOTE-BLOCK element from Org to HTML.
2552 CONTENTS holds the contents of the block. INFO is a plist
2553 holding contextual information."
2554 (format "<blockquote>\n%s</blockquote>" contents
))
2559 (defun org-html-quote-section (quote-section contents info
)
2560 "Transcode a QUOTE-SECTION element from Org to HTML.
2561 CONTENTS is nil. INFO is a plist holding contextual information."
2562 (let ((value (org-remove-indentation
2563 (org-element-property :value quote-section
))))
2564 (when value
(format "<pre>\n%s</pre>" value
))))
2569 (defun org-html-section (section contents info
)
2570 "Transcode a SECTION element from Org to HTML.
2571 CONTENTS holds the contents of the section. INFO is a plist
2572 holding contextual information."
2573 (let ((parent (org-export-get-parent-headline section
)))
2574 ;; Before first headline: no container, just return CONTENTS.
2575 (if (not parent
) contents
2576 ;; Get div's class and id references.
2577 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2578 (1- org-html-toplevel-hlevel
)))
2582 (org-export-get-headline-number parent info
) "-")))
2583 ;; Build return value.
2584 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2586 (or (org-element-property :CUSTOM_ID parent
) section-number
)
2591 (defun org-html-radio-target (radio-target text info
)
2592 "Transcode a RADIO-TARGET object from Org to HTML.
2593 TEXT is the text of the target. INFO is a plist holding
2594 contextual information."
2595 (let ((id (org-export-solidify-link-text
2596 (org-element-property :value radio-target
))))
2597 (org-html--anchor id text
)))
2602 (defun org-html-special-block (special-block contents info
)
2603 "Transcode a SPECIAL-BLOCK element from Org to HTML.
2604 CONTENTS holds the contents of the block. INFO is a plist
2605 holding contextual information."
2606 (format "<div class=\"%s\">\n%s\n</div>"
2607 (downcase (org-element-property :type special-block
))
2613 (defun org-html-src-block (src-block contents info
)
2614 "Transcode a SRC-BLOCK element from Org to HTML.
2615 CONTENTS holds the contents of the item. INFO is a plist holding
2616 contextual information."
2617 (if (org-export-read-attribute :attr_html src-block
:textarea
)
2618 (org-html--textarea-block src-block
)
2619 (let ((lang (org-element-property :language src-block
))
2620 (caption (org-export-get-caption src-block
))
2621 (code (org-html-format-code src-block info
))
2622 (label (let ((lbl (org-element-property :name src-block
)))
2624 (format " id=\"%s\""
2625 (org-export-solidify-link-text lbl
))))))
2626 (if (not lang
) (format "<pre class=\"example\"%s>\n%s</pre>" label code
)
2628 "<div class=\"org-src-container\">\n%s%s\n</div>"
2629 (if (not caption
) ""
2630 (format "<label class=\"org-src-name\">%s</label>"
2631 (org-export-data caption info
)))
2632 (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code
))))))
2635 ;;;; Statistics Cookie
2637 (defun org-html-statistics-cookie (statistics-cookie contents info
)
2638 "Transcode a STATISTICS-COOKIE object from Org to HTML.
2639 CONTENTS is nil. INFO is a plist holding contextual information."
2640 (let ((cookie-value (org-element-property :value statistics-cookie
)))
2641 (format "<code>%s</code>" cookie-value
)))
2646 (defun org-html-strike-through (strike-through contents info
)
2647 "Transcode STRIKE-THROUGH from Org to HTML.
2648 CONTENTS is the text with strike-through markup. INFO is a plist
2649 holding contextual information."
2650 (format (or (cdr (assq 'strike-through org-html-text-markup-alist
)) "%s")
2656 (defun org-html-subscript (subscript contents info
)
2657 "Transcode a SUBSCRIPT object from Org to HTML.
2658 CONTENTS is the contents of the object. INFO is a plist holding
2659 contextual information."
2660 (format "<sub>%s</sub>" contents
))
2665 (defun org-html-superscript (superscript contents info
)
2666 "Transcode a SUPERSCRIPT object from Org to HTML.
2667 CONTENTS is the contents of the object. INFO is a plist holding
2668 contextual information."
2669 (format "<sup>%s</sup>" contents
))
2674 (defun org-html-table-cell (table-cell contents info
)
2675 "Transcode a TABLE-CELL element from Org to HTML.
2676 CONTENTS is nil. INFO is a plist used as a communication
2678 (let* ((table-row (org-export-get-parent table-cell
))
2679 (table (org-export-get-parent-table table-cell
))
2681 (if (not org-html-table-align-individual-fields
) ""
2682 (format (if (and (boundp 'org-html-format-table-no-css
)
2683 org-html-format-table-no-css
)
2684 " align=\"%s\"" " class=\"%s\"")
2685 (org-export-table-cell-alignment table-cell info
)))))
2686 (when (or (not contents
) (string= "" (org-trim contents
)))
2687 (setq contents
" "))
2689 ((and (org-export-table-has-header-p table info
)
2690 (= 1 (org-export-table-row-group table-row info
)))
2691 (concat "\n" (format (car org-html-table-header-tags
) "col" cell-attrs
)
2692 contents
(cdr org-html-table-header-tags
)))
2693 ((and org-html-table-use-header-tags-for-first-column
2694 (zerop (cdr (org-export-table-cell-address table-cell info
))))
2695 (concat "\n" (format (car org-html-table-header-tags
) "row" cell-attrs
)
2696 contents
(cdr org-html-table-header-tags
)))
2697 (t (concat "\n" (format (car org-html-table-data-tags
) cell-attrs
)
2698 contents
(cdr org-html-table-data-tags
))))))
2703 (defun org-html-table-row (table-row contents info
)
2704 "Transcode a TABLE-ROW element from Org to HTML.
2705 CONTENTS is the contents of the row. INFO is a plist used as a
2706 communication channel."
2707 ;; Rules are ignored since table separators are deduced from
2708 ;; borders of the current row.
2709 (when (eq (org-element-property :type table-row
) 'standard
)
2710 (let* ((first-rowgroup-p (= 1 (org-export-table-row-group table-row info
)))
2713 ;; Case 1: Row belongs to second or subsequent rowgroups.
2714 ((not (= 1 (org-export-table-row-group table-row info
)))
2715 '("<tbody>" .
"\n</tbody>"))
2716 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
2717 ((org-export-table-has-header-p
2718 (org-export-get-parent-table table-row
) info
)
2719 '("<thead>" .
"\n</thead>"))
2720 ;; Case 2: Row is from first and only row group.
2721 (t '("<tbody>" .
"\n</tbody>")))))
2723 ;; Begin a rowgroup?
2724 (when (org-export-table-row-starts-rowgroup-p table-row info
)
2725 (car rowgroup-tags
))
2727 (concat "\n" (eval (car org-html-table-row-tags
))
2730 (eval (cdr org-html-table-row-tags
)))
2732 (when (org-export-table-row-ends-rowgroup-p table-row info
)
2733 (cdr rowgroup-tags
))))))
2738 (defun org-html-table-first-row-data-cells (table info
)
2740 (org-element-map table
'table-row
2742 (unless (eq (org-element-property :type row
) 'rule
) row
))
2744 (special-column-p (org-export-table-has-special-column-p table
)))
2745 (if (not special-column-p
) (org-element-contents table-row
)
2746 (cdr (org-element-contents table-row
)))))
2748 (defun org-html-table--table.el-table
(table info
)
2749 (when (eq (org-element-property :type table
) 'table.el
)
2751 (let ((outbuf (with-current-buffer
2752 (get-buffer-create "*org-export-table*")
2753 (erase-buffer) (current-buffer))))
2755 (insert (org-element-property :value table
))
2757 (re-search-forward "^[ \t]*|[^|]" nil t
)
2758 (table-generate-source 'html outbuf
))
2759 (with-current-buffer outbuf
2760 (prog1 (org-trim (buffer-string))
2763 (defun org-html-table (table contents info
)
2764 "Transcode a TABLE element from Org to HTML.
2765 CONTENTS is the contents of the table. INFO is a plist holding
2766 contextual information."
2767 (case (org-element-property :type table
)
2768 ;; Case 1: table.el table. Convert it using appropriate tools.
2769 (table.el
(org-html-table--table.el-table table info
))
2770 ;; Case 2: Standard table.
2772 (let* ((label (org-element-property :name table
))
2773 (caption (org-export-get-caption table
))
2774 (attributes (mapconcat #'identity
2775 (org-element-property :attr_html table
)
2778 (if (and (boundp 'org-html-format-table-no-css
)
2779 org-html-format-table-no-css
)
2780 "align=\"%s\"" "class=\"%s\""))
2783 (lambda (table info
)
2785 (lambda (table-cell)
2786 (let ((alignment (org-export-table-cell-alignment
2789 ;; Begin a colgroup?
2790 (when (org-export-table-cell-starts-colgroup-p
2793 ;; Add a column. Also specify it's alignment.
2794 (format "\n<col %s/>" (format alignspec alignment
))
2796 (when (org-export-table-cell-ends-colgroup-p
2799 (org-html-table-first-row-data-cells table info
) "\n"))))
2801 (let ((table-tag (plist-get info
:html-table-tag
)))
2803 (and (string-match "<table\\(.*\\)>" table-tag
)
2804 (match-string 1 table-tag
))
2805 (and label
(format " id=\"%s\""
2806 (org-export-solidify-link-text label
)))
2807 (unless (string= attributes
"")
2808 (concat " " attributes
))))))
2809 ;; Remove last blank line.
2810 (setq contents
(substring contents
0 -
1))
2811 (format "<table%s>\n%s\n%s\n%s\n</table>"
2813 (if (not caption
) ""
2814 (format "<caption>%s</caption>"
2815 (org-export-data caption info
)))
2816 (funcall table-column-specs table info
)
2822 (defun org-html-target (target contents info
)
2823 "Transcode a TARGET object from Org to HTML.
2824 CONTENTS is nil. INFO is a plist holding contextual
2826 (let ((id (org-export-solidify-link-text
2827 (org-element-property :value target
))))
2828 (org-html--anchor id
)))
2833 (defun org-html-timestamp (timestamp contents info
)
2834 "Transcode a TIMESTAMP object from Org to HTML.
2835 CONTENTS is nil. INFO is a plist holding contextual
2837 (let ((value (org-html-plain-text
2838 (org-timestamp-translate timestamp
) info
)))
2839 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
2840 (replace-regexp-in-string "--" "–" value
))))
2845 (defun org-html-underline (underline contents info
)
2846 "Transcode UNDERLINE from Org to HTML.
2847 CONTENTS is the text with underline markup. INFO is a plist
2848 holding contextual information."
2849 (format (or (cdr (assq 'underline org-html-text-markup-alist
)) "%s")
2855 (defun org-html-verbatim (verbatim contents info
)
2856 "Transcode VERBATIM from Org to HTML.
2857 CONTENTS is nil. INFO is a plist holding contextual
2859 (format (or (cdr (assq 'verbatim org-html-text-markup-alist
)) "%s")
2860 (org-element-property :value verbatim
)))
2865 (defun org-html-verse-block (verse-block contents info
)
2866 "Transcode a VERSE-BLOCK element from Org to HTML.
2867 CONTENTS is verse block contents. INFO is a plist holding
2868 contextual information."
2869 ;; Replace each newline character with line break. Also replace
2870 ;; each blank line with a line break.
2871 (setq contents
(replace-regexp-in-string
2872 "^ *\\\\\\\\$" "<br/>\n"
2873 (replace-regexp-in-string
2874 "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents
)))
2875 ;; Replace each white space at beginning of a line with a
2876 ;; non-breaking space.
2877 (while (string-match "^[ \t]+" contents
)
2878 (let* ((num-ws (length (match-string 0 contents
)))
2879 (ws (let (out) (dotimes (i num-ws out
)
2880 (setq out
(concat out
" "))))))
2881 (setq contents
(replace-match ws nil t contents
))))
2882 (format "<p class=\"verse\">\n%s</p>" contents
))
2886 ;;; Filter Functions
2888 (defun org-html-final-function (contents backend info
)
2889 (if (not org-html-pretty-output
) contents
2893 (indent-region (point-min) (point-max))
2894 (buffer-substring-no-properties (point-min) (point-max)))))
2898 ;;; End-user functions
2901 (defun org-html-export-as-html
2902 (&optional async subtreep visible-only body-only ext-plist
)
2903 "Export current buffer to an HTML buffer.
2905 If narrowing is active in the current buffer, only export its
2908 If a region is active, export that region.
2910 A non-nil optional argument ASYNC means the process should happen
2911 asynchronously. The resulting buffer should be accessible
2912 through the `org-export-stack' interface.
2914 When optional argument SUBTREEP is non-nil, export the sub-tree
2915 at point, extracting information from the headline properties
2918 When optional argument VISIBLE-ONLY is non-nil, don't export
2919 contents of hidden elements.
2921 When optional argument BODY-ONLY is non-nil, only write code
2922 between \"<body>\" and \"</body>\" tags.
2924 EXT-PLIST, when provided, is a property list with external
2925 parameters overriding Org default settings, but still inferior to
2926 file-local settings.
2928 Export is done in a buffer named \"*Org HTML Export*\", which
2929 will be displayed when `org-export-show-temporary-export-buffer'
2933 (org-export-async-start
2935 (with-current-buffer (get-buffer-create "*Org HTML Export*")
2938 (goto-char (point-min))
2939 (funcall org-html-display-buffer-mode
)
2940 (org-export-add-to-stack (current-buffer) 'html
)))
2941 `(org-export-as 'html
,subtreep
,visible-only
,body-only
',ext-plist
))
2942 (let ((outbuf (org-export-to-buffer
2943 'html
"*Org HTML Export*"
2944 subtreep visible-only body-only ext-plist
)))
2946 (with-current-buffer outbuf
(funcall org-html-display-buffer-mode
))
2947 (when org-export-show-temporary-export-buffer
2948 (switch-to-buffer-other-window outbuf
)))))
2951 (defun org-html-export-to-html
2952 (&optional async subtreep visible-only body-only ext-plist
)
2953 "Export current buffer to a HTML file.
2955 If narrowing is active in the current buffer, only export its
2958 If a region is active, export that region.
2960 A non-nil optional argument ASYNC means the process should happen
2961 asynchronously. The resulting file should be accessible through
2962 the `org-export-stack' interface.
2964 When optional argument SUBTREEP is non-nil, export the sub-tree
2965 at point, extracting information from the headline properties
2968 When optional argument VISIBLE-ONLY is non-nil, don't export
2969 contents of hidden elements.
2971 When optional argument BODY-ONLY is non-nil, only write code
2972 between \"<body>\" and \"</body>\" tags.
2974 EXT-PLIST, when provided, is a property list with external
2975 parameters overriding Org default settings, but still inferior to
2976 file-local settings.
2978 Return output file's name."
2980 (let* ((extension (concat "." org-html-extension
))
2981 (file (org-export-output-file-name extension subtreep
))
2982 (org-export-coding-system org-html-coding-system
))
2984 (org-export-async-start
2985 (lambda (f) (org-export-add-to-stack f
'html
))
2986 (let ((org-export-coding-system org-html-coding-system
))
2989 'html
,file
,subtreep
,visible-only
,body-only
',ext-plist
))))
2990 (let ((org-export-coding-system org-html-coding-system
))
2992 'html file subtreep visible-only body-only ext-plist
)))))
2995 (defun org-html-publish-to-html (plist filename pub-dir
)
2996 "Publish an org file to HTML.
2998 FILENAME is the filename of the Org file to be published. PLIST
2999 is the property list for the given project. PUB-DIR is the
3000 publishing directory.
3002 Return output file name."
3003 (org-publish-org-to 'html filename
".html" plist pub-dir
))
3009 ;;;; org-format-table-html
3010 ;;;; org-format-org-table-html
3011 ;;;; org-format-table-table-html
3012 ;;;; org-table-number-fraction
3013 ;;;; org-table-number-regexp
3014 ;;;; org-html-table-caption-above
3015 ;;;; org-html-with-timestamp
3016 ;;;; org-html-html-helper-timestamp
3017 ;;;; org-html-inline-image-extensions
3018 ;;;; org-export-preferred-target-alist
3019 ;;;; class for anchors
3020 ;;;; org-export-with-section-numbers, body-only
3021 ;;;; org-export-mark-todo-in-toc
3022 ;;;; org-html-format-org-link
3023 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
3024 ;;;; alt = (file-name-nondirectory path)
3029 ;; generated-autoload-file: "org-loaddefs.el"
3032 ;;; ox-html.el ends here