1 ;;; org-e-html.el --- HTML Back-End For Org Export Engine
3 ;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
5 ;; Author: Jambunathan K <kjambunathan at gmail dot com>
6 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ;; This library implements a HTML back-end for Org generic exporter.
27 ;; M-: (org-export-to-buffer 'e-html "*Test e-HTML*") RET
29 ;; in an org-mode buffer then switch to the buffer to see the HTML
30 ;; export. See contrib/lisp/org-export.el for more details on how
31 ;; this exporter works.
39 (require 'org-e-publish
)
40 (require 'format-spec
)
41 (eval-when-compile (require 'cl
) (require 'table
))
45 ;;; Function Declarations
47 (declare-function org-id-find-id-file
"org-id" (id))
48 (declare-function htmlize-region
"ext:htmlize" (beg end
))
49 (declare-function org-pop-to-buffer-same-window
50 "org-compat" (&optional buffer-or-name norecord label
))
55 (org-export-define-backend e-html
56 ((bold . org-e-html-bold
)
57 (center-block . org-e-html-center-block
)
58 (clock . org-e-html-clock
)
59 (code . org-e-html-code
)
60 (drawer . org-e-html-drawer
)
61 (dynamic-block . org-e-html-dynamic-block
)
62 (entity . org-e-html-entity
)
63 (example-block . org-e-html-example-block
)
64 (export-block . org-e-html-export-block
)
65 (export-snippet . org-e-html-export-snippet
)
66 (fixed-width . org-e-html-fixed-width
)
67 (footnote-definition . org-e-html-footnote-definition
)
68 (footnote-reference . org-e-html-footnote-reference
)
69 (headline . org-e-html-headline
)
70 (horizontal-rule . org-e-html-horizontal-rule
)
71 (inline-src-block . org-e-html-inline-src-block
)
72 (inlinetask . org-e-html-inlinetask
)
73 (italic . org-e-html-italic
)
74 (item . org-e-html-item
)
75 (keyword . org-e-html-keyword
)
76 (latex-environment . org-e-html-latex-environment
)
77 (latex-fragment . org-e-html-latex-fragment
)
78 (line-break . org-e-html-line-break
)
79 (link . org-e-html-link
)
80 (paragraph . org-e-html-paragraph
)
81 (plain-list . org-e-html-plain-list
)
82 (plain-text . org-e-html-plain-text
)
83 (planning . org-e-html-planning
)
84 (property-drawer . org-e-html-property-drawer
)
85 (quote-block . org-e-html-quote-block
)
86 (quote-section . org-e-html-quote-section
)
87 (radio-target . org-e-html-radio-target
)
88 (section . org-e-html-section
)
89 (special-block . org-e-html-special-block
)
90 (src-block . org-e-html-src-block
)
91 (statistics-cookie . org-e-html-statistics-cookie
)
92 (strike-through . org-e-html-strike-through
)
93 (subscript . org-e-html-subscript
)
94 (superscript . org-e-html-superscript
)
95 (table . org-e-html-table
)
96 (table-cell . org-e-html-table-cell
)
97 (table-row . org-e-html-table-row
)
98 (target . org-e-html-target
)
99 (template . org-e-html-template
)
100 (timestamp . org-e-html-timestamp
)
101 (underline . org-e-html-underline
)
102 (verbatim . org-e-html-verbatim
)
103 (verse-block . org-e-html-verse-block
))
105 :filters-alist
((:filter-final-output . org-e-html-final-function
))
108 ((?H
"To temporary buffer" org-e-html-export-as-html
)
109 (?h
"To file" org-e-html-export-to-html
)
110 (?o
"To file and open"
111 (lambda (s v b
) (org-open-file (org-e-html-export-to-html s v b
))))))
113 ;; FIXME: Prefix KEYWORD and OPTION with "HTML_". Prefix
114 ;; corresponding properties with `:html-". If such a renaming is
115 ;; taken up, some changes will be required in `org-jsinfo.el',
116 ;; I think. So defer renaming for now.
117 ((:agenda-style nil nil org-agenda-export-html-style
)
118 (:creator
"CREATOR" nil org-e-html-creator-string
)
119 (:convert-org-links nil nil org-e-html-link-org-files-as-html
)
120 ;; (:expand-quoted-html nil "@" org-e-html-expand)
121 (:inline-images nil nil org-e-html-inline-images
)
122 (:link-home
"LINK_HOME" nil org-e-html-link-home
)
123 (:link-up
"LINK_UP" nil org-e-html-link-up
)
124 (:style nil nil org-e-html-style
)
125 (:style-extra
"STYLE" nil org-e-html-style-extra newline
)
126 (:style-include-default nil nil org-e-html-style-include-default
)
127 (:style-include-scripts nil nil org-e-html-style-include-scripts
)
128 ;; (:timestamp nil nil org-e-html-with-timestamp)
129 (:html-extension nil nil org-e-html-extension
)
130 (:html-postamble nil nil org-e-html-postamble
)
131 (:html-preamble nil nil org-e-html-preamble
)
132 (:html-table-tag nil nil org-e-html-table-tag
)
133 (:xml-declaration nil nil org-e-html-xml-declaration
)
134 (:LaTeX-fragments nil
"LaTeX" org-export-with-LaTeX-fragments
)
135 (:mathjax
"MATHJAX" nil
"" space
)))
139 ;;; Internal Variables
141 ;; FIXME: it already exists in org-e-html.el
142 (defconst org-e-html-cvt-link-fn
144 "Function to convert link URLs to exportable URLs.
145 Takes two arguments, TYPE and PATH.
146 Returns exportable url as (TYPE PATH), or nil to signal that it
147 didn't handle this case.
148 Intended to be locally bound around a call to `org-export-as-html'." )
150 (defvar org-e-html-format-table-no-css
)
151 (defvar htmlize-buffer-places
) ; from htmlize.el
152 (defvar body-only
) ; dynamically scoped into this.
154 (defconst org-e-html-special-string-regexps
155 '(("\\\\-" .
"­")
156 ("---\\([^-]\\)" .
"—\\1")
157 ("--\\([^-]\\)" .
"–\\1")
158 ("\\.\\.\\." .
"…"))
159 "Regular expressions for special string conversion.")
161 (defconst org-e-html-scripts
162 "<script type=\"text/javascript\">
164 @licstart The following is the entire license notice for the
165 JavaScript code in this tag.
167 Copyright (C) 2012 Free Software Foundation, Inc.
169 The JavaScript code in this tag is free software: you can
170 redistribute it and/or modify it under the terms of the GNU
171 General Public License (GNU GPL) as published by the Free Software
172 Foundation, either version 3 of the License, or (at your option)
173 any later version. The code is distributed WITHOUT ANY WARRANTY;
174 without even the implied warranty of MERCHANTABILITY or FITNESS
175 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
177 As additional permission under GNU GPL version 3 section 7, you
178 may distribute non-source (e.g., minimized or compacted) forms of
179 that code without the copy of the GNU GPL normally required by
180 section 4, provided you include this license notice and a URL
181 through which recipients can access the Corresponding Source.
184 @licend The above is the entire license notice
185 for the JavaScript code in this tag.
187 <!--/*--><![CDATA[/*><!--*/
188 function CodeHighlightOn(elem, id)
190 var target = document.getElementById(id);
192 elem.cacheClassElem = elem.className;
193 elem.cacheClassTarget = target.className;
194 target.className = \"code-highlighted\";
195 elem.className = \"code-highlighted\";
198 function CodeHighlightOff(elem, id)
200 var target = document.getElementById(id);
201 if(elem.cacheClassElem)
202 elem.className = elem.cacheClassElem;
203 if(elem.cacheClassTarget)
204 target.className = elem.cacheClassTarget;
208 "Basic JavaScript that is needed by HTML files produced by Org mode.")
210 (defconst org-e-html-style-default
211 "<style type=\"text/css\">
212 <!--/*--><![CDATA[/*><!--*/
213 html { font-family: Times, serif; font-size: 12pt; }
214 .title { text-align: center; }
215 .todo { color: red; }
216 .done { color: green; }
217 .tag { background-color: #add8e6; font-weight:normal }
219 .timestamp { color: #bebebe; }
220 .timestamp-kwd { color: #5f9ea0; }
221 .right {margin-left:auto; margin-right:0px; text-align:right;}
222 .left {margin-left:0px; margin-right:auto; text-align:left;}
223 .center {margin-left:auto; margin-right:auto; text-align:center;}
224 p.verse { margin-left: 3% }
226 border: 1pt solid #AEBDCC;
227 background-color: #F3F5F7;
229 font-family: courier, monospace;
233 table { border-collapse: collapse; }
234 td, th { vertical-align: top; }
235 th.right { text-align:center; }
236 th.left { text-align:center; }
237 th.center { text-align:center; }
238 td.right { text-align:right; }
239 td.left { text-align:left; }
240 td.center { text-align:center; }
241 dt { font-weight: bold; }
242 div.figure { padding: 0.5em; }
243 div.figure p { text-align: center; }
246 border:2px solid gray;
250 textarea { overflow-x: auto; }
251 .linenr { font-size:smaller }
252 .code-highlighted {background-color:#ffff00;}
253 .org-info-js_info-navigation { border-style:none; }
254 #org-info-js_console-label { font-size:10px; font-weight:bold;
255 white-space:nowrap; }
256 .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
260 "The default style specification for exported HTML files.
261 Please use the variables `org-e-html-style' and
262 `org-e-html-style-extra' to add to this style. If you wish to not
263 have the default style included, customize the variable
264 `org-e-html-style-include-default'.")
268 ;;; User Configuration Variables
270 (defgroup org-export-e-html nil
271 "Options for exporting Org mode files to HTML."
272 :tag
"Org Export HTML"
275 (defgroup org-export-e-htmlize nil
276 "Options for processing examples with htmlize.el."
277 :tag
"Org Export Htmlize"
278 :group
'org-export-e-html
)
283 (defcustom org-e-html-text-markup-alist
284 '((bold .
"<b>%s</b>")
285 (code .
"<code>%s</code>")
286 (italic .
"<i>%s</i>")
287 (strike-through .
"<del>%s</del>")
288 (underline .
"<span style=\"text-decoration:underline;\">%s</span>")
289 (verbatim .
"<code>%s</code>"))
290 "Alist of HTML expressions to convert text markup
292 The key must be a symbol among `bold', `code', `italic',
293 `strike-through', `underline' and `verbatim'. The value is
294 a formatting string to wrap fontified text with.
296 If no association can be found for a given markup, text will be
298 :group
'org-export-e-html
299 :type
'(alist :key-type
(symbol :tag
"Markup type")
300 :value-type
(string :tag
"Format string"))
301 :options
'(bold code italic strike-through underline verbatim
))
306 (defcustom org-e-html-pretty-output nil
307 "Enable this to generate pretty HTML."
308 :group
'org-export-e-html
314 (defcustom org-e-html-format-drawer-function nil
315 "Function called to format a drawer in HTML code.
317 The function must accept two parameters:
318 NAME the drawer name, like \"LOGBOOK\"
319 CONTENTS the contents of the drawer.
321 The function should return the string to be exported.
323 For example, the variable could be set to the following function
324 in order to mimic default behaviour:
326 \(defun org-e-html-format-drawer-default \(name contents\)
327 \"Format a drawer element for HTML export.\"
329 :group
'org-export-e-html
335 (defcustom org-e-html-footnotes-section
"<div id=\"footnotes\">
336 <h2 class=\"footnotes\">%s: </h2>
337 <div id=\"text-footnotes\">
341 "Format for the footnotes section.
342 Should contain a two instances of %s. The first will be replaced with the
343 language-specific word for \"Footnotes\", the second one will be replaced
344 by the footnotes themselves."
345 :group
'org-export-e-html
348 (defcustom org-e-html-footnote-format
"<sup>%s</sup>"
349 "The format for the footnote reference.
350 %s will be replaced by the footnote reference itself."
351 :group
'org-export-e-html
354 (defcustom org-e-html-footnote-separator
"<sup>, </sup>"
355 "Text used to separate footnotes."
356 :group
'org-export-e-html
362 (defcustom org-e-html-toplevel-hlevel
2
363 "The <H> level for level 1 headings in HTML export.
364 This is also important for the classes that will be wrapped around headlines
365 and outline structure. If this variable is 1, the top-level headlines will
366 be <h1>, and the corresponding classes will be outline-1, section-number-1,
367 and outline-text-1. If this is 2, all of these will get a 2 instead.
368 The default for this variable is 2, because we use <h1> for formatting the
370 :group
'org-export-e-html
373 (defcustom org-e-html-format-headline-function nil
374 "Function to format headline text.
376 This function will be called with 5 arguments:
377 TODO the todo keyword (string or nil).
378 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
379 PRIORITY the priority of the headline (integer or nil)
380 TEXT the main headline text (string).
381 TAGS the tags (string or nil).
383 The function result will be used in the section format string.
385 As an example, one could set the variable to the following, in
386 order to reproduce the default set-up:
388 \(defun org-e-html-format-headline \(todo todo-type priority text tags)
389 \"Default format function for an headline.\"
391 \(format \"\\\\textbf{\\\\textsc{\\\\textsf{%s}}} \" todo))
393 \(format \"\\\\framebox{\\\\#%c} \" priority))
395 \(when tags (format \"\\\\hfill{}\\\\textsc{%s}\" tags))))"
396 :group
'org-export-e-html
402 (defcustom org-e-html-allow-name-attribute-in-anchors t
403 "When nil, do not set \"name\" attribute in anchors.
404 By default, anchors are formatted with both \"id\" and \"name\"
405 attributes, when appropriate."
406 :group
'org-export-e-html
412 (defcustom org-e-html-format-inlinetask-function nil
413 "Function called to format an inlinetask in HTML code.
415 The function must accept six parameters:
416 TODO the todo keyword, as a string
417 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
418 PRIORITY the inlinetask priority, as a string
419 NAME the inlinetask name, as a string.
420 TAGS the inlinetask tags, as a list of strings.
421 CONTENTS the contents of the inlinetask, as a string.
423 The function should return the string to be exported.
425 For example, the variable could be set to the following function
426 in order to mimic default behaviour:
428 \(defun org-e-html-format-inlinetask \(todo type priority name tags contents\)
429 \"Format an inline task element for HTML export.\"
433 \(format \"\\\\textbf{\\\\textsf{\\\\textsc{%s}}} \" todo))
434 \(when priority (format \"\\\\framebox{\\\\#%c} \" priority))
436 \(when tags (format \"\\\\hfill{}\\\\textsc{%s}\" tags)))))
437 \(format (concat \"\\\\begin{center}\\n\"
439 \"\\\\begin{minipage}[c]{.6\\\\textwidth}\\n\"
441 \"\\\\rule[.8em]{\\\\textwidth}{2pt}\\n\\n\"
443 \"\\\\end{minipage}}\"
445 full-title contents))"
446 :group
'org-export-e-html
450 ;;;; Links :: Generic
452 (defcustom org-e-html-link-org-files-as-html t
453 "Non-nil means make file links to `file.org' point to `file.html'.
454 When org-mode is exporting an org-mode file to HTML, links to
455 non-html files are directly put into a href tag in HTML.
456 However, links to other Org-mode files (recognized by the
457 extension `.org.) should become links to the corresponding html
458 file, assuming that the linked org-mode file will also be
460 When nil, the links still point to the plain `.org' file."
461 :group
'org-export-e-html
465 ;;;; Links :: Inline images
467 (defcustom org-e-html-inline-images
'maybe
468 "Non-nil means inline images into exported HTML pages.
469 This is done using an <img> tag. When nil, an anchor with href is used to
470 link to the image. If this option is `maybe', then images in links with
471 an empty description will be inlined, while images with a description will
473 :group
'org-export-e-html
474 :type
'(choice (const :tag
"Never" nil
)
475 (const :tag
"Always" t
)
476 (const :tag
"When there is no description" maybe
)))
478 (defcustom org-e-html-inline-image-rules
479 '(("file" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
480 ("http" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
481 ("https" .
"\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
482 "Rules characterizing image files that can be inlined into HTML.
484 A rule consists in an association whose key is the type of link
485 to consider, and value is a regexp that will be matched against
488 Note that, by default, the image extension *actually* allowed
489 depend on the way the HTML file is processed. When used with
490 pdflatex, pdf, jpg and png images are OK. When processing
491 through dvi to Postscript, only ps and eps are allowed. The
492 default we use here encompasses both."
493 :group
'org-export-e-html
494 :type
'(alist :key-type
(string :tag
"Type")
495 :value-type
(regexp :tag
"Path")))
500 (defcustom org-e-html-protect-char-alist
504 "Alist of characters to be converted by `org-e-html-protect'."
505 :group
'org-export-e-html
506 :type
'(repeat (cons (string :tag
"Character")
507 (string :tag
"HTML equivalent"))))
512 (defcustom org-export-e-htmlize-output-type
'inline-css
513 "Output type to be used by htmlize when formatting code snippets.
514 Choices are `css', to export the CSS selectors only, or `inline-css', to
515 export the CSS attribute values inline in the HTML. We use as default
516 `inline-css', in order to make the resulting HTML self-containing.
518 However, this will fail when using Emacs in batch mode for export, because
519 then no rich font definitions are in place. It will also not be good if
520 people with different Emacs setup contribute HTML files to a website,
521 because the fonts will represent the individual setups. In these cases,
522 it is much better to let Org/Htmlize assign classes only, and to use
523 a style file to define the look of these classes.
524 To get a start for your css file, start Emacs session and make sure that
525 all the faces you are interested in are defined, for example by loading files
526 in all modes you want. Then, use the command
527 \\[org-export-e-htmlize-generate-css] to extract class definitions."
528 :group
'org-export-e-htmlize
529 :type
'(choice (const css
) (const inline-css
)))
531 (defcustom org-export-e-htmlize-css-font-prefix
"org-"
532 "The prefix for CSS class names for htmlize font specifications."
533 :group
'org-export-e-htmlize
536 (defcustom org-export-e-htmlized-org-css-url nil
537 "URL pointing to a CSS file defining text colors for htmlized Emacs buffers.
538 Normally when creating an htmlized version of an Org buffer, htmlize will
539 create CSS to define the font colors. However, this does not work when
540 converting in batch mode, and it also can look bad if different people
541 with different fontification setup work on the same website.
542 When this variable is non-nil, creating an htmlized version of an Org buffer
543 using `org-export-as-org' will remove the internal CSS section and replace it
544 with a link to this URL."
545 :group
'org-export-e-htmlize
547 (const :tag
"Keep internal css" nil
)
548 (string :tag
"URL or local href")))
553 (defcustom org-e-html-table-tag
554 "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
555 "The HTML tag that is used to start a table.
556 This must be a <table> tag, but you may change the options like
557 borders and spacing."
558 :group
'org-export-e-html
561 (defcustom org-e-html-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
562 "The opening tag for table header fields.
563 This is customizable so that alignment options can be specified.
564 The first %s will be filled with the scope of the field, either row or col.
565 The second %s will be replaced by a style entry to align the field.
566 See also the variable `org-e-html-table-use-header-tags-for-first-column'.
567 See also the variable `org-e-html-table-align-individual-fields'."
568 :group
'org-export-tables
; FIXME: change group?
569 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
571 (defcustom org-e-html-table-data-tags
'("<td%s>" .
"</td>")
572 "The opening tag for table data fields.
573 This is customizable so that alignment options can be specified.
574 The first %s will be filled with the scope of the field, either row or col.
575 The second %s will be replaced by a style entry to align the field.
576 See also the variable `org-e-html-table-align-individual-fields'."
577 :group
'org-export-tables
578 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
580 (defcustom org-e-html-table-row-tags
'("<tr>" .
"</tr>")
581 "The opening tag for table data fields.
582 This is customizable so that alignment options can be specified.
583 Instead of strings, these can be Lisp forms that will be evaluated
584 for each row in order to construct the table row tags. During evaluation,
585 the variable `head' will be true when this is a header line, nil when this
586 is a body line. And the variable `nline' will contain the line number,
587 starting from 1 in the first header line. For example
589 (setq org-e-html-table-row-tags
592 (if (= (mod nline 2) 1)
593 \"<tr class=\\\"tr-odd\\\">\"
594 \"<tr class=\\\"tr-even\\\">\"))
597 will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
598 :group
'org-export-tables
600 (choice :tag
"Opening tag"
601 (string :tag
"Specify")
603 (choice :tag
"Closing tag"
604 (string :tag
"Specify")
607 (defcustom org-e-html-table-align-individual-fields t
608 "Non-nil means attach style attributes for alignment to each table field.
609 When nil, alignment will only be specified in the column tags, but this
610 is ignored by some browsers (like Firefox, Safari). Opera does it right
612 :group
'org-export-tables
615 (defcustom org-e-html-table-use-header-tags-for-first-column nil
616 "Non-nil means format column one in tables with header tags.
617 When nil, also column one will use data tags."
618 :group
'org-export-tables
621 (defcustom org-e-html-table-caption-above t
622 "When non-nil, place caption string at the beginning of the table.
623 Otherwise, place it near the end."
624 :group
'org-export-e-html
630 (defcustom org-e-html-tag-class-prefix
""
631 "Prefix to class names for TODO keywords.
632 Each tag gets a class given by the tag itself, with this prefix.
633 The default prefix is empty because it is nice to just use the keyword
634 as a class name. But if you get into conflicts with other, existing
635 CSS classes, then this prefix can be very useful."
636 :group
'org-export-e-html
640 ;;;; Template :: Generic
642 (defcustom org-e-html-extension
"html"
643 "The extension for exported HTML files."
644 :group
'org-export-e-html
647 (defcustom org-e-html-xml-declaration
648 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
649 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
650 "The extension for exported HTML files.
651 %s will be replaced with the charset of the exported file.
652 This may be a string, or an alist with export extensions
653 and corresponding declarations."
654 :group
'org-export-e-html
656 (string :tag
"Single declaration")
657 (repeat :tag
"Dependent on extension"
658 (cons (string :tag
"Extension")
659 (string :tag
"Declaration")))))
661 (defcustom org-e-html-coding-system
'utf-8
662 "Coding system for HTML export.
663 Use utf-8 as the default value."
664 :group
'org-export-e-html
665 :type
'coding-system
)
667 (defcustom org-e-html-divs
'("preamble" "content" "postamble")
668 "The name of the main divs for HTML export.
669 This is a list of three strings, the first one for the preamble
670 DIV, the second one for the content DIV and the third one for the
672 :group
'org-export-e-html
674 (string :tag
" Div for the preamble:")
675 (string :tag
" Div for the content:")
676 (string :tag
"Div for the postamble:")))
679 ;;;; Template :: Mathjax
681 (defcustom org-e-html-mathjax-options
682 '((path "http://orgmode.org/mathjax/MathJax.js")
687 "Options for MathJax setup.
689 path The path where to find MathJax
690 scale Scaling for the HTML-CSS backend, usually between 100 and 133
691 align How to align display math: left, center, or right
692 indent If align is not center, how far from the left/right side?
693 mathml Should a MathML player be used if available?
694 This is faster and reduces bandwidth use, but currently
695 sometimes has lower spacing quality. Therefore, the default is
696 nil. When browsers get better, this switch can be flipped.
698 You can also customize this for each buffer, using something like
700 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
701 :group
'org-export-e-html
702 :type
'(list :greedy t
703 (list :tag
"path (the path from where to load MathJax.js)"
704 (const :format
" " path
) (string))
705 (list :tag
"scale (scaling for the displayed math)"
706 (const :format
" " scale
) (string))
707 (list :tag
"align (alignment of displayed equations)"
708 (const :format
" " align
) (string))
709 (list :tag
"indent (indentation with left or right alignment)"
710 (const :format
" " indent
) (string))
711 (list :tag
"mathml (should MathML display be used is possible)"
712 (const :format
" " mathml
) (boolean))))
714 (defcustom org-e-html-mathjax-template
715 "<script type=\"text/javascript\" src=\"%PATH\">
716 <!--/*--><![CDATA[/*><!--*/
718 // Only one of the two following lines, depending on user settings
719 // First allows browser-native MathML display, second forces HTML/CSS
720 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
721 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
722 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
723 \"TeX/noUndefined.js\"],
725 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
726 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
727 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
728 ignoreClass: \"tex2jax_ignore\",
729 processEscapes: false,
730 processEnvironments: true,
733 showProcessingMessages: true,
734 displayAlign: \"%ALIGN\",
735 displayIndent: \"%INDENT\",
739 availableFonts: [\"STIX\",\"TeX\"],
740 preferredFont: \"TeX\",
756 "The MathJax setup for XHTML files."
757 :group
'org-export-e-html
761 ;;;; Template :: Postamble
763 (defcustom org-e-html-postamble
'auto
764 "Non-nil means insert a postamble in HTML export.
766 When `t', insert a string as defined by the formatting string in
767 `org-e-html-postamble-format'. When set to a string, this
768 string overrides `org-e-html-postamble-format'. When set to
769 'auto, discard `org-e-html-postamble-format' and honor
770 `org-export-author/email/creator-info' variables. When set to a
771 function, apply this function and insert the returned string.
772 The function takes the property list of export options as its
775 Setting :html-postamble in publishing projects will take
776 precedence over this variable."
777 :group
'org-export-e-html
778 :type
'(choice (const :tag
"No postamble" nil
)
779 (const :tag
"Auto preamble" 'auto
)
780 (const :tag
"Default formatting string" t
)
781 (string :tag
"Custom formatting string")
782 (function :tag
"Function (must return a string)")))
784 (defcustom org-e-html-postamble-format
785 '(("en" "<p class=\"author\">Author: %a (%e)</p>
786 <p class=\"date\">Date: %d</p>
787 <p class=\"creator\">Generated by %c</p>
788 <p class=\"xhtml-validation\">%v</p>"))
789 "Alist of languages and format strings for the HTML postamble.
791 The first element of each list is the language code, as used for
792 the #+LANGUAGE keyword.
794 The second element of each list is a format string to format the
795 postamble itself. This format string can contain these elements:
797 %a stands for the author's name.
798 %e stands for the author's email.
799 %d stands for the date.
800 %c will be replaced by information about Org/Emacs versions.
801 %v will be replaced by `org-e-html-validation-link'.
803 If you need to use a \"%\" character, you need to escape it
805 :group
'org-export-e-html
806 :type
'(alist :key-type
(string :tag
"Language")
807 :value-type
(string :tag
"Format string")))
809 (defcustom org-e-html-validation-link
810 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
811 "Link to HTML validation service."
812 :group
'org-export-e-html
815 (defcustom org-e-html-creator-string
816 (format "Generated by <a href=\"http://orgmode.org\">Org</a> mode %s in <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s."
817 (if (fboundp 'org-version
) (org-version) "(Unknown)")
819 "String to insert at the end of the HTML document."
820 :group
'org-export-e-html
821 :type
'(string :tag
"Creator string"))
824 ;;;; Template :: Preamble
826 (defcustom org-e-html-preamble t
827 "Non-nil means insert a preamble in HTML export.
829 When `t', insert a string as defined by one of the formatting
830 strings in `org-e-html-preamble-format'. When set to a
831 string, this string overrides `org-e-html-preamble-format'.
832 When set to a function, apply this function and insert the
833 returned string. The function takes the property list of export
834 options as its only argument.
836 Setting :html-preamble in publishing projects will take
837 precedence over this variable."
838 :group
'org-export-e-html
839 :type
'(choice (const :tag
"No preamble" nil
)
840 (const :tag
"Default preamble" t
)
841 (string :tag
"Custom formatting string")
842 (function :tag
"Function (must return a string)")))
844 (defcustom org-e-html-preamble-format
'(("en" ""))
845 "Alist of languages and format strings for the HTML preamble.
847 The first element of each list is the language code, as used for
848 the #+LANGUAGE keyword.
850 The second element of each list is a format string to format the
851 preamble itself. This format string can contain these elements:
853 %t stands for the title.
854 %a stands for the author's name.
855 %e stands for the author's email.
856 %d stands for the date.
858 If you need to use a \"%\" character, you need to escape it
860 :group
'org-export-e-html
861 :type
'(alist :key-type
(string :tag
"Language")
862 :value-type
(string :tag
"Format string")))
864 (defcustom org-e-html-link-up
""
865 "Where should the \"UP\" link of exported HTML pages lead?"
866 :group
'org-export-e-html
867 :type
'(string :tag
"File or URL"))
869 (defcustom org-e-html-link-home
""
870 "Where should the \"HOME\" link of exported HTML pages lead?"
871 :group
'org-export-e-html
872 :type
'(string :tag
"File or URL"))
874 (defcustom org-e-html-home
/up-format
875 "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
876 <a accesskey=\"h\" href=\"%s\"> UP </a>
878 <a accesskey=\"H\" href=\"%s\"> HOME </a>
880 "Snippet used to insert the HOME and UP links.
881 This is a format string, the first %s will receive the UP link,
882 the second the HOME link. If both `org-e-html-link-up' and
883 `org-e-html-link-home' are empty, the entire snippet will be
885 :group
'org-export-e-html
889 ;;;; Template :: Scripts
891 (defcustom org-e-html-style-include-scripts t
892 "Non-nil means include the JavaScript snippets in exported HTML files.
893 The actual script is defined in `org-e-html-scripts' and should
895 :group
'org-export-e-html
899 ;;;; Template :: Styles
901 (defcustom org-e-html-style-include-default t
902 "Non-nil means include the default style in exported HTML files.
903 The actual style is defined in `org-e-html-style-default' and should
904 not be modified. Use the variables `org-e-html-style' to add
905 your own style information."
906 :group
'org-export-e-html
909 (put 'org-e-html-style-include-default
'safe-local-variable
'booleanp
)
911 (defcustom org-e-html-style
""
912 "Org-wide style definitions for exported HTML files.
914 This variable needs to contain the full HTML structure to provide a style,
915 including the surrounding HTML tags. If you set the value of this variable,
916 you should consider to include definitions for the following classes:
917 title, todo, done, timestamp, timestamp-kwd, tag, target.
919 For example, a valid value would be:
921 <style type=\"text/css\">
923 p { font-weight: normal; color: gray; }
925 .title { text-align: center; }
926 .todo, .timestamp-kwd { color: red; }
927 .done { color: green; }
931 If you'd like to refer to an external style file, use something like
933 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
935 As the value of this option simply gets inserted into the HTML <head> header,
936 you can \"misuse\" it to add arbitrary text to the header.
937 See also the variable `org-e-html-style-extra'."
938 :group
'org-export-e-html
941 (put 'org-e-html-style
'safe-local-variable
'stringp
)
943 (defcustom org-e-html-style-extra
""
944 "Additional style information for HTML export.
945 The value of this variable is inserted into the HTML buffer right after
946 the value of `org-e-html-style'. Use this variable for per-file
947 settings of style information, and do not forget to surround the style
948 settings with <style>...</style> tags."
949 :group
'org-export-e-html
952 (put 'org-e-html-style-extra
'safe-local-variable
'stringp
)
957 (defcustom org-e-html-todo-kwd-class-prefix
""
958 "Prefix to class names for TODO keywords.
959 Each TODO keyword gets a class given by the keyword itself, with this prefix.
960 The default prefix is empty because it is nice to just use the keyword
961 as a class name. But if you get into conflicts with other, existing
962 CSS classes, then this prefix can be very useful."
963 :group
'org-export-e-html
968 ;;; Internal Functions
970 (defun org-e-html-format-inline-image (src &optional
971 caption label attr standalone-p
)
972 (let* ((id (if (not label
) ""
973 (format " id=\"%s\"" (org-export-solidify-link-text label
))))
976 ((string-match "\\<alt=" (or attr
"")) "")
977 ((string-match "^ltxpng/" src
)
978 (format " alt=\"%s\""
979 (org-e-html-encode-plain-text
980 (org-find-text-property-in-string
981 'org-latex-src src
))))
982 (t (format " alt=\"%s\""
983 (file-name-nondirectory src
)))))))
986 (let ((img (format "<img src=\"%s\" %s/>" src attr
)))
987 (format "\n<div%s class=\"figure\">%s%s\n</div>"
988 id
(format "\n<p>%s</p>" img
)
989 (when caption
(format "\n<p>%s</p>" caption
)))))
990 (t (format "<img src=\"%s\" %s/>" src
(concat attr id
))))))
994 (defun org-e-html-bibliography ()
995 "Find bibliography, cut it out and return it."
997 (let (beg end
(cnt 1) bib
)
999 (goto-char (point-min))
1000 (when (re-search-forward
1001 "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t
)
1002 (setq beg
(match-beginning 0))
1003 (while (re-search-forward "</?div\\>" nil t
)
1004 (setq cnt
(+ cnt
(if (string= (match-string 0) "<div") +1 -
1)))
1006 (and (looking-at ">") (forward-char 1))
1007 (setq bib
(buffer-substring beg
(point)))
1008 (delete-region beg
(point))
1009 (throw 'exit bib
))))
1014 (defun org-e-html-splice-attributes (tag attributes
)
1015 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
1016 (if (not attributes
)
1018 (let (oldatt newatt
)
1019 (setq oldatt
(org-extract-attributes-from-string tag
)
1021 newatt
(cdr (org-extract-attributes-from-string attributes
)))
1023 (setq oldatt
(plist-put oldatt
(pop newatt
) (pop newatt
))))
1024 (if (string-match ">" tag
)
1026 (replace-match (concat (org-attributes-to-string oldatt
) ">")
1030 (defun org-export-splice-style (style extra
)
1031 "Splice EXTRA into STYLE, just before \"</style>\"."
1032 (if (and (stringp extra
)
1033 (string-match "\\S-" extra
)
1034 (string-match "</style>" style
))
1035 (concat (substring style
0 (match-beginning 0))
1037 (substring style
(match-beginning 0)))
1040 (defun org-export-e-htmlize-region-for-paste (beg end
)
1041 "Convert the region to HTML, using htmlize.el.
1042 This is much like `htmlize-region-for-paste', only that it uses
1043 the settings define in the org-... variables."
1044 (let* ((htmlize-output-type org-export-e-htmlize-output-type
)
1045 (htmlize-css-name-prefix org-export-e-htmlize-css-font-prefix
)
1046 (htmlbuf (htmlize-region beg end
)))
1048 (with-current-buffer htmlbuf
1049 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
1050 (plist-get htmlize-buffer-places
'content-end
)))
1051 (kill-buffer htmlbuf
))))
1054 (defun org-export-e-htmlize-generate-css ()
1055 "Create the CSS for all font definitions in the current Emacs session.
1056 Use this to create face definitions in your CSS style file that can then
1057 be used by code snippets transformed by htmlize.
1058 This command just produces a buffer that contains class definitions for all
1059 faces used in the current Emacs session. You can copy and paste the ones you
1060 need into your CSS file.
1062 If you then set `org-export-e-htmlize-output-type' to `css', calls to
1063 the function `org-export-e-htmlize-region-for-paste' will produce code
1064 that uses these same face definitions."
1067 (and (get-buffer "*html*") (kill-buffer "*html*"))
1069 (let ((fl (face-list))
1070 (htmlize-css-name-prefix "org-")
1071 (htmlize-output-type 'css
)
1073 (while (setq f
(pop fl
)
1074 i
(and f
(face-attribute f
:inherit
)))
1075 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
1076 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
1077 (htmlize-region (point-min) (point-max))))
1078 (org-pop-to-buffer-same-window "*html*")
1079 (goto-char (point-min))
1080 (if (re-search-forward "<style" nil t
)
1081 (delete-region (point-min) (match-beginning 0)))
1082 (if (re-search-forward "</style>" nil t
)
1083 (delete-region (1+ (match-end 0)) (point-max)))
1084 (beginning-of-line 1)
1085 (if (looking-at " +") (replace-match ""))
1086 (goto-char (point-min)))
1088 (defun org-e-html-make-string (n string
)
1089 (let (out) (dotimes (i n out
) (setq out
(concat string out
)))))
1091 (defun org-e-html-toc-text (toc-entries)
1092 (let* ((prev-level (1- (nth 1 (car toc-entries
))))
1093 (start-level prev-level
))
1097 (let ((headline (nth 0 entry
))
1098 (level (nth 1 entry
)))
1100 (let* ((cnt (- level prev-level
))
1101 (times (if (> cnt
0) (1- cnt
) (- cnt
)))
1103 (setq prev-level level
)
1105 (org-e-html-make-string
1106 times
(cond ((> cnt
0) "\n<ul>\n<li>")
1107 ((< cnt
0) "</li>\n</ul>\n")))
1108 (if (> cnt
0) "\n<ul>\n<li>" "</li>\n<li>")))
1111 (org-e-html-make-string
1112 (- prev-level start-level
) "</li>\n</ul>\n"))))
1114 (defun* org-e-html-format-toc-headline
1115 (todo todo-type priority text tags
1116 &key level section-number headline-label
&allow-other-keys
)
1117 (let ((headline (concat
1118 section-number
(and section-number
". ")
1120 (and tags
" ") (org-e-html--tags tags
))))
1121 (format "<a href=\"#%s\">%s</a>"
1122 (org-export-solidify-link-text headline-label
)
1123 (if (not nil
) headline
1124 (format "<span class=\"%s\">%s</span>" todo-type headline
)))))
1126 (defun org-e-html-toc (depth info
)
1127 (let* ((headlines (org-export-collect-headlines info depth
))
1129 (loop for headline in headlines collect
1130 (list (org-e-html-format-headline--wrap
1131 headline info
'org-e-html-format-toc-headline
)
1132 (org-export-get-relative-level headline info
)))))
1135 "<div id=\"table-of-contents\">\n"
1136 (format "<h%d>%s</h%d>\n"
1137 org-e-html-toplevel-hlevel
1138 (org-e-html--translate "Table of Contents" info
)
1139 org-e-html-toplevel-hlevel
)
1140 "<div id=\"text-table-of-contents\">"
1141 (org-e-html-toc-text toc-entries
)
1145 (defun org-e-html-fix-class-name (kwd) ; audit callers of this function
1146 "Turn todo keyword into a valid class name.
1147 Replaces invalid characters with \"_\"."
1149 (while (string-match "[^a-zA-Z0-9_]" kwd
)
1150 (setq kwd
(replace-match "_" t t kwd
))))
1153 (defun org-e-html-format-footnote-reference (n def refcnt
)
1154 (let ((extra (if (= refcnt
1) "" (format ".%d" refcnt
))))
1155 (format org-e-html-footnote-format
1156 (let* ((id (format "fnr.%s%s" n extra
))
1157 (href (format " href=\"#fn.%s\"" n
))
1158 (attributes (concat " class=\"footref\"" href
)))
1159 (org-e-html--anchor id n attributes
)))))
1161 (defun org-e-html-format-footnotes-section (section-name definitions
)
1162 (if (not definitions
) ""
1163 (format org-e-html-footnotes-section section-name definitions
)))
1165 (defun org-e-html-format-footnote-definition (fn)
1166 (let ((n (car fn
)) (def (cdr fn
)))
1168 "<tr>\n<td>%s</td>\n<td>%s</td>\n</tr>\n"
1169 (format org-e-html-footnote-format
1170 (let* ((id (format "fn.%s" n
))
1171 (href (format " href=\"#fnr.%s\"" n
))
1172 (attributes (concat " class=\"footnum\"" href
)))
1173 (org-e-html--anchor id n attributes
)))
1176 (defun org-e-html-footnote-section (info)
1177 (let* ((fn-alist (org-export-collect-footnote-definitions
1178 (plist-get info
:parse-tree
) info
))
1181 (loop for
(n type raw
) in fn-alist collect
1182 (cons n
(if (eq (org-element-type raw
) 'org-data
)
1183 (org-trim (org-export-data raw info
))
1185 (org-trim (org-export-data raw info
))))))))
1187 (org-e-html-format-footnotes-section
1188 (org-e-html--translate "Footnotes" info
)
1190 "<table>\n%s\n</table>\n"
1191 (mapconcat 'org-e-html-format-footnote-definition fn-alist
"\n"))))))
1193 (defun org-e-html-format-date (info)
1194 (let ((date (org-export-data (plist-get info
:date
) info
)))
1196 ((and date
(string-match "%" date
))
1197 (format-time-string date
))
1199 (t (format-time-string "%Y-%m-%d %T %Z")))))
1205 (defun org-e-html--build-meta-info (info)
1206 "Return meta tags for exported document.
1207 INFO is a plist used as a communication channel."
1208 (let* ((title (org-export-data (plist-get info
:title
) info
))
1209 (author (and (plist-get info
:with-author
)
1210 (let ((auth (plist-get info
:author
)))
1211 (and auth
(org-export-data auth info
)))))
1212 (description (plist-get info
:description
))
1213 (keywords (plist-get info
:keywords
)))
1215 (format "<title>%s</title>\n" title
)
1217 "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>"
1218 (or (and org-e-html-coding-system
1219 (fboundp 'coding-system-get
)
1220 (coding-system-get org-e-html-coding-system
1223 (format "<meta name=\"title\" content=\"%s\"/>\n" title
)
1224 (format "<meta name=\"generator\" content=\"Org-mode\"/>\n")
1225 (format "<meta name=\"generated\" content=\"%s\"/>\n"
1226 (org-e-html-format-date info
))
1227 (format "<meta name=\"author\" content=\"%s\"/>\n" author
)
1228 (format "<meta name=\"description\" content=\"%s\"/>\n" description
)
1229 (format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords
))))
1231 (defun org-e-html--build-style (info)
1232 "Return style information for exported document.
1233 INFO is a plist used as a communication channel."
1234 (org-element-normalize-string
1236 (when (plist-get info
:style-include-default
) org-e-html-style-default
)
1237 (org-element-normalize-string (plist-get info
:style
))
1238 (org-element-normalize-string (plist-get info
:style-extra
))
1239 (when (plist-get info
:style-include-scripts
) org-e-html-scripts
))))
1241 (defun org-e-html--build-mathjax-config (info)
1242 "Insert the user setup into the mathjax template.
1243 INFO is a plist used as a communication channel."
1244 (when (member (plist-get info
:LaTeX-fragments
) '(mathjax t
))
1245 (let ((template org-e-html-mathjax-template
)
1246 (options org-e-html-mathjax-options
)
1247 (in-buffer (or (plist-get info
:mathjax
) ""))
1248 name val
(yes " ") (no "// ") x
)
1251 (setq name
(car e
) val
(nth 1 e
))
1252 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
1253 (setq val
(car (read-from-string
1254 (substring in-buffer
(match-end 0))))))
1255 (if (not (stringp val
)) (setq val
(format "%s" val
)))
1256 (if (string-match (concat "%" (upcase (symbol-name name
))) template
)
1257 (setq template
(replace-match val t t template
))))
1259 (setq val
(nth 1 (assq 'mathml options
)))
1260 (if (string-match (concat "\\<mathml:") in-buffer
)
1261 (setq val
(car (read-from-string
1262 (substring in-buffer
(match-end 0))))))
1263 ;; Exchange prefixes depending on mathml setting.
1264 (if (not val
) (setq x yes yes no no x
))
1265 ;; Replace cookies to turn on or off the config/jax lines.
1266 (if (string-match ":MMLYES:" template
)
1267 (setq template
(replace-match yes t t template
)))
1268 (if (string-match ":MMLNO:" template
)
1269 (setq template
(replace-match no t t template
)))
1270 ;; Return the modified template.
1271 (org-element-normalize-string template
))))
1273 (defun org-e-html--build-preamble (info)
1274 "Return document preamble as a string, or nil.
1275 INFO is a plist used as a communication channel."
1276 (let ((preamble (plist-get info
:html-preamble
)))
1278 (let ((preamble-contents
1279 (if (functionp preamble
) (funcall preamble info
)
1280 (let ((title (org-export-data (plist-get info
:title
) info
))
1281 (date (org-e-html-format-date info
))
1282 (author (if (not (plist-get info
:with-author
)) ""
1283 (org-export-data (plist-get info
:author
) info
)))
1284 (email (if (not (plist-get info
:with-email
)) ""
1285 (plist-get info
:email
))))
1286 (if (stringp preamble
)
1287 (format-spec preamble
1288 `((?t .
,title
) (?a .
,author
)
1289 (?d .
,date
) (?e .
,email
)))
1291 (or (cadr (assoc (plist-get info
:language
)
1292 org-e-html-preamble-format
))
1293 (cadr (assoc "en" org-e-html-preamble-format
)))
1294 `((?t .
,title
) (?a .
,author
)
1295 (?d .
,date
) (?e .
,email
))))))))
1296 (when (org-string-nw-p preamble-contents
)
1297 (concat (format "<div id=\"%s\">\n" (nth 0 org-e-html-divs
))
1298 (org-element-normalize-string preamble-contents
)
1301 (defun org-e-html--build-postamble (info)
1302 "Return document postamble as a string, or nil.
1303 INFO is a plist used as a communication channel."
1304 (let ((postamble (plist-get info
:html-postamble
)))
1306 (let ((postamble-contents
1307 (if (functionp postamble
) (funcall postamble info
)
1308 (let ((date (org-e-html-format-date info
))
1309 (author (let ((author (plist-get info
:author
)))
1310 (and author
(org-export-data author info
))))
1313 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1314 (split-string (plist-get info
:email
) ",+ *")
1316 (html-validation-link (or org-e-html-validation-link
""))
1317 (creator-info (plist-get info
:creator
)))
1318 (cond ((stringp postamble
)
1319 (format-spec postamble
1320 `((?a .
,author
) (?e .
,email
)
1321 (?d .
,date
) (?c .
,creator-info
)
1322 (?v .
,html-validation-link
))))
1323 ((eq postamble
'auto
)
1325 (when (plist-get info
:time-stamp-file
)
1326 (format "<p class=\"date\">%s: %s</p>\n"
1327 (org-e-html--translate "Date" info
)
1329 (when (and (plist-get info
:with-author
) author
)
1330 (format "<p class=\"author\">%s : %s</p>\n"
1331 (org-e-html--translate "Author" info
)
1333 (when (and (plist-get info
:with-email
) email
)
1334 (format "<p class=\"email\">%s </p>\n" email
))
1335 (when (plist-get info
:with-creator
)
1336 (format "<p class=\"creator\">%s</p>\n"
1338 html-validation-link
"\n"))
1340 (or (cadr (assoc (plist-get info
:language
)
1341 org-e-html-postamble-format
))
1342 (cadr (assoc "en" org-e-html-postamble-format
)))
1343 `((?a .
,author
) (?e .
,email
)
1344 (?d .
,date
) (?c .
,creator-info
)
1345 (?v .
,html-validation-link
)))))))))
1346 (when (org-string-nw-p postamble-contents
)
1348 (format "<div id=\"%s\">\n" (nth 2 org-e-html-divs
))
1349 (org-element-normalize-string postamble-contents
)
1352 (defun org-e-html-template (contents info
)
1353 "Return complete document string after HTML conversion.
1354 CONTENTS is the transcoded contents string. INFO is a plist
1355 holding export options."
1358 (or (and (stringp org-e-html-xml-declaration
)
1359 org-e-html-xml-declaration
)
1360 (cdr (assoc (plist-get info
:html-extension
)
1361 org-e-html-xml-declaration
))
1362 (cdr (assoc "html" org-e-html-xml-declaration
))
1365 (or (and org-e-html-coding-system
1366 (fboundp 'coding-system-get
)
1367 (coding-system-get org-e-html-coding-system
'mime-charset
))
1370 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
1371 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
1372 (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n"
1373 (plist-get info
:language
) (plist-get info
:language
))
1375 (org-e-html--build-meta-info info
)
1376 (org-e-html--build-style info
)
1377 (org-e-html--build-mathjax-config info
)
1380 (let ((link-up (org-trim (plist-get info
:link-up
)))
1381 (link-home (org-trim (plist-get info
:link-home
))))
1382 (unless (and (string= link-up
"") (string= link-up
""))
1383 (format org-e-html-home
/up-format
1384 (or link-up link-home
)
1385 (or link-home link-up
))))
1387 (org-e-html--build-preamble info
)
1389 (format "<div id=\"%s\">\n" (nth 1 org-e-html-divs
))
1391 (format "<h1 class=\"title\">%s</h1>\n"
1392 (org-export-data (plist-get info
:title
) info
))
1393 ;; Table of contents.
1394 (let ((depth (plist-get info
:with-toc
)))
1395 (when depth
(org-e-html-toc depth info
)))
1396 ;; Document contents.
1398 ;; Footnotes section.
1399 (org-e-html-footnote-section info
)
1401 (org-e-html-bibliography)
1405 (org-e-html--build-postamble info
)
1406 ;; Closing document.
1407 "</body>\n</html>"))
1409 (defun org-e-html--translate (s info
)
1410 "Translate string S according to specified language.
1411 INFO is a plist used as a communication channel."
1412 (org-export-translate s
:html info
))
1416 (defun org-e-html--anchor (&optional id desc attributes
)
1417 (let* ((name (and org-e-html-allow-name-attribute-in-anchors id
))
1418 (attributes (concat (and id
(format " id=\"%s\"" id
))
1419 (and name
(format " name=\"%s\"" name
))
1421 (format "<a%s>%s</a>" attributes
(or desc
""))))
1425 (defun org-e-html--todo (todo)
1427 (format "<span class=\"%s %s%s\">%s</span>"
1428 (if (member todo org-done-keywords
) "done" "todo")
1429 org-e-html-todo-kwd-class-prefix
(org-e-html-fix-class-name todo
)
1434 (defun org-e-html--tags (tags)
1436 (format "<span class=\"tag\">%s</span>"
1439 (format "<span class=\"%s\">%s</span>"
1440 (concat org-e-html-tag-class-prefix
1441 (org-e-html-fix-class-name tag
))
1447 (defun* org-e-html-format-headline
1448 (todo todo-type priority text tags
1449 &key level section-number headline-label
&allow-other-keys
)
1450 (let ((section-number
1451 (when section-number
1452 (format "<span class=\"section-number-%d\">%s</span> "
1453 level section-number
)))
1454 (todo (org-e-html--todo todo
))
1455 (tags (org-e-html--tags tags
)))
1456 (concat section-number todo
(and todo
" ") text
1457 (and tags
" ") tags
)))
1461 (defun org-e-html-fontify-code (code lang
)
1464 ;; Case 1: No lang. Possibly an example block.
1466 ;; Simple transcoding.
1467 (org-e-html-encode-plain-text code
))
1468 ;; Case 2: No htmlize or an inferior version of htmlize
1469 ((not (and (require 'htmlize nil t
) (fboundp 'htmlize-region-for-paste
)))
1471 (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
1472 ;; Simple transcoding.
1473 (org-e-html-encode-plain-text code
))
1476 (setq lang
(or (assoc-default lang org-src-lang-modes
) lang
))
1477 (let* ((lang-mode (and lang
(intern (format "%s-mode" lang
)))))
1479 ;; Case 1: Language is not associated with any Emacs mode
1480 ((not (functionp lang-mode
))
1481 ;; Simple transcoding.
1482 (org-e-html-encode-plain-text code
))
1483 ;; Case 2: Default. Fontify code.
1486 (setq code
(with-temp-buffer
1488 ;; Switch to language-specific mode.
1491 (font-lock-fontify-buffer)
1492 ;; Remove formatting on newline characters.
1494 (let ((beg (point-min))
1497 (while (progn (end-of-line) (< (point) end
))
1498 (put-text-property (point) (1+ (point)) 'face nil
)
1501 (set-buffer-modified-p nil
)
1503 (org-export-e-htmlize-region-for-paste
1504 (point-min) (point-max))))
1505 ;; Strip any encolosing <pre></pre> tags.
1506 (if (string-match "<pre[^>]*>\n*\\([^\000]*\\)</pre>" code
)
1507 (match-string 1 code
)
1510 (defun org-e-html-do-format-code
1511 (code &optional lang refs retain-labels num-start textarea-p
)
1513 (setq num-start nil refs nil lang nil
))
1514 (let* ((code-lines (org-split-string code
"\n"))
1515 (code-length (length code-lines
))
1519 (length (number-to-string (+ code-length num-start
))))))
1520 (code (org-e-html-fontify-code code lang
)))
1521 (assert (= code-length
(length (org-split-string code
"\n"))))
1522 (org-export-format-code
1524 (lambda (loc line-num ref
)
1527 ;; Add line number, if needed.
1529 (format "<span class=\"linenr\">%s</span>"
1530 (format num-fmt line-num
)))
1531 ;; Transcoded src line.
1533 ;; Add label, if needed.
1534 (when (and ref retain-labels
) (format " (%s)" ref
))))
1535 ;; Mark transcoded line as an anchor, if needed.
1537 (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
1541 (defun org-e-html-format-code (element info
)
1542 (let* ((lang (org-element-property :language element
))
1543 ;; (switches (org-element-property :switches element))
1544 (switches nil
) ; FIXME
1545 (textarea-p (and switches
(string-match "-t\\>" switches
)))
1546 ;; Extract code and references.
1547 (code-info (org-export-unravel-code element
))
1548 (code (car code-info
))
1549 (refs (cdr code-info
))
1550 ;; Does the src block contain labels?
1551 (retain-labels (org-element-property :retain-labels element
))
1552 ;; Does it have line numbers?
1553 (num-start (case (org-element-property :number-lines element
)
1554 (continued (org-export-get-loc element info
))
1556 (org-e-html-do-format-code
1557 code lang refs retain-labels num-start textarea-p
)))
1561 ;;; Transcode Functions
1565 (defun org-e-html-bold (bold contents info
)
1566 "Transcode BOLD from Org to HTML.
1567 CONTENTS is the text with bold markup. INFO is a plist holding
1568 contextual information."
1569 (format (or (cdr (assq 'bold org-e-html-text-markup-alist
)) "%s")
1575 (defun org-e-html-center-block (center-block contents info
)
1576 "Transcode a CENTER-BLOCK element from Org to HTML.
1577 CONTENTS holds the contents of the block. INFO is a plist
1578 holding contextual information."
1579 (format "<div style=\"text-align: center\">\n%s</div>" contents
))
1584 (defun org-e-html-clock (clock contents info
)
1585 "Transcode a CLOCK element from Org to HTML.
1586 CONTENTS is nil. INFO is a plist used as a communication
1589 <span class=\"timestamp-wrapper\">
1590 <span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
1595 (org-element-property :raw-value
1596 (org-element-property :value clock
)))
1597 (let ((time (org-element-property :duration clock
)))
1598 (and time
(format " <span class=\"timestamp\">(%s)</span>" time
)))))
1603 (defun org-e-html-code (code contents info
)
1604 "Transcode CODE from Org to HTML.
1605 CONTENTS is nil. INFO is a plist holding contextual
1607 (format (or (cdr (assq 'code org-e-html-text-markup-alist
)) "%s")
1608 (org-element-property :value code
)))
1613 ;; Comments are ignored.
1618 ;; Comment Blocks are ignored.
1623 (defun org-e-html-drawer (drawer contents info
)
1624 "Transcode a DRAWER element from Org to HTML.
1625 CONTENTS holds the contents of the block. INFO is a plist
1626 holding contextual information."
1627 (if (functionp org-e-html-format-drawer-function
)
1628 (funcall org-e-html-format-drawer-function
1629 (org-element-property :drawer-name drawer
)
1631 ;; If there's no user defined function: simply
1632 ;; display contents of the drawer.
1638 (defun org-e-html-dynamic-block (dynamic-block contents info
)
1639 "Transcode a DYNAMIC-BLOCK element from Org to HTML.
1640 CONTENTS holds the contents of the block. INFO is a plist
1641 holding contextual information. See `org-export-data'."
1647 (defun org-e-html-entity (entity contents info
)
1648 "Transcode an ENTITY object from Org to HTML.
1649 CONTENTS are the definition itself. INFO is a plist holding
1650 contextual information."
1651 (org-element-property :html entity
))
1656 (defun org-e-html-example-block (example-block contents info
)
1657 "Transcode a EXAMPLE-BLOCK element from Org to HTML.
1658 CONTENTS is nil. INFO is a plist holding contextual information."
1659 (let ((attr (org-export-read-attribute :attr_html example-block
))
1660 (code (org-e-html-format-code example-block info
)))
1662 ((plist-get attr
:textarea
)
1663 (let ((cols (or (plist-get attr
:width
) 80))
1664 (rows (or (plist-get attr
:height
) (org-count-lines code
))))
1665 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>"
1667 (t (format "<pre class=\"example\">\n%s</pre>" code
)))))
1672 (defun org-e-html-export-snippet (export-snippet contents info
)
1673 "Transcode a EXPORT-SNIPPET object from Org to HTML.
1674 CONTENTS is nil. INFO is a plist holding contextual information."
1675 (when (eq (org-export-snippet-backend export-snippet
) 'e-html
)
1676 (org-element-property :value export-snippet
)))
1681 (defun org-e-html-export-block (export-block contents info
)
1682 "Transcode a EXPORT-BLOCK element from Org to HTML.
1683 CONTENTS is nil. INFO is a plist holding contextual information."
1684 (when (string= (org-element-property :type export-block
) "HTML")
1685 (org-remove-indentation (org-element-property :value export-block
))))
1690 (defun org-e-html-fixed-width (fixed-width contents info
)
1691 "Transcode a FIXED-WIDTH element from Org to HTML.
1692 CONTENTS is nil. INFO is a plist holding contextual information."
1693 (format "<pre class=\"example\">\n%s</pre>"
1694 (org-e-html-do-format-code
1695 (org-remove-indentation
1696 (org-element-property :value fixed-width
)))))
1699 ;;;; Footnote Definition
1701 ;; Footnote Definitions are ignored.
1704 ;;;; Footnote Reference
1706 (defun org-e-html-footnote-reference (footnote-reference contents info
)
1707 "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
1708 CONTENTS is nil. INFO is a plist holding contextual information."
1710 ;; Insert separator between two footnotes in a row.
1711 (let ((prev (org-export-get-previous-element footnote-reference info
)))
1712 (when (eq (org-element-type prev
) 'footnote-reference
)
1713 org-e-html-footnote-separator
))
1715 ((not (org-export-footnote-first-reference-p footnote-reference info
))
1716 (org-e-html-format-footnote-reference
1717 (org-export-get-footnote-number footnote-reference info
)
1719 ;; Inline definitions are secondary strings.
1720 ((eq (org-element-property :type footnote-reference
) 'inline
)
1721 (org-e-html-format-footnote-reference
1722 (org-export-get-footnote-number footnote-reference info
)
1724 ;; Non-inline footnotes definitions are full Org data.
1725 (t (org-e-html-format-footnote-reference
1726 (org-export-get-footnote-number footnote-reference info
)
1732 (defun org-e-html-format-headline--wrap (headline info
1733 &optional format-function
1735 "Transcode an HEADLINE element from Org to HTML.
1736 CONTENTS holds the contents of the headline. INFO is a plist
1737 holding contextual information."
1738 (let* ((level (+ (org-export-get-relative-level headline info
)
1739 (1- org-e-html-toplevel-hlevel
)))
1740 (headline-number (org-export-get-headline-number headline info
))
1741 (section-number (and (not (org-export-low-level-p headline info
))
1742 (org-export-numbered-headline-p headline info
)
1743 (mapconcat 'number-to-string
1744 headline-number
".")))
1745 (todo (and (plist-get info
:with-todo-keywords
)
1746 (let ((todo (org-element-property :todo-keyword headline
)))
1747 (and todo
(org-export-data todo info
)))))
1748 (todo-type (and todo
(org-element-property :todo-type headline
)))
1749 (priority (and (plist-get info
:with-priority
)
1750 (org-element-property :priority headline
)))
1751 (text (org-export-data (org-element-property :title headline
) info
))
1752 (tags (and (plist-get info
:with-tags
)
1753 (org-export-get-tags headline info
)))
1754 (headline-label (or (org-element-property :custom-id headline
)
1755 (concat "sec-" (mapconcat 'number-to-string
1756 headline-number
"-"))))
1757 (format-function (cond
1758 ((functionp format-function
) format-function
)
1759 ((functionp org-e-html-format-headline-function
)
1761 (lambda (todo todo-type priority text tags
1763 (funcall org-e-html-format-headline-function
1764 todo todo-type priority text tags
))))
1765 (t 'org-e-html-format-headline
))))
1766 (apply format-function
1767 todo todo-type priority text tags
1768 :headline-label headline-label
:level level
1769 :section-number section-number extra-keys
)))
1771 (defun org-e-html-headline (headline contents info
)
1772 "Transcode an HEADLINE element from Org to HTML.
1773 CONTENTS holds the contents of the headline. INFO is a plist
1774 holding contextual information."
1776 (setq contents
(or contents
""))
1777 (let* ((numberedp (org-export-numbered-headline-p headline info
))
1778 (level (org-export-get-relative-level headline info
))
1779 (text (org-export-data (org-element-property :title headline
) info
))
1780 (todo (and (plist-get info
:with-todo-keywords
)
1781 (let ((todo (org-element-property :todo-keyword headline
)))
1782 (and todo
(org-export-data todo info
)))))
1783 (todo-type (and todo
(org-element-property :todo-type headline
)))
1784 (tags (and (plist-get info
:with-tags
)
1785 (org-export-get-tags headline info
)))
1786 (priority (and (plist-get info
:with-priority
)
1787 (org-element-property :priority headline
)))
1788 (section-number (and (org-export-numbered-headline-p headline info
)
1789 (mapconcat 'number-to-string
1790 (org-export-get-headline-number
1791 headline info
) ".")))
1792 ;; Create the headline text.
1793 (full-text (org-e-html-format-headline--wrap headline info
)))
1795 ;; Case 1: This is a footnote section: ignore it.
1796 ((org-element-property :footnote-section-p headline
) nil
)
1797 ;; Case 2. This is a deep sub-tree: export it as a list item.
1798 ;; Also export as items headlines for which no section
1799 ;; format has been found.
1800 ((org-export-low-level-p headline info
)
1801 ;; Build the real contents of the sub-tree.
1802 (let* ((type (if numberedp
'ordered
'unordered
))
1803 (itemized-body (org-e-html-format-list-item
1804 contents type nil nil full-text
)))
1806 (and (org-export-first-sibling-p headline info
)
1807 (org-e-html-begin-plain-list type
))
1809 (and (org-export-last-sibling-p headline info
)
1810 (org-e-html-end-plain-list type
)))))
1811 ;; Case 3. Standard headline. Export it as a section.
1813 (let* ((section-number (mapconcat 'number-to-string
1814 (org-export-get-headline-number
1815 headline info
) "-"))
1817 (list (org-element-property :custom-id headline
)
1818 (concat "sec-" section-number
)
1819 (org-element-property :id headline
))))
1820 (preferred-id (car ids
))
1821 (extra-ids (cdr ids
))
1822 (extra-class (org-element-property :html-container-class headline
))
1823 (level1 (+ level
(1- org-e-html-toplevel-hlevel
))))
1824 (format "<div id=\"%s\" class=\"%s\">%s%s</div>\n"
1825 (format "outline-container-%s"
1826 (or (org-element-property :custom-id headline
)
1828 (concat (format "outline-%d" level1
) (and extra-class
" ")
1830 (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
1835 (let ((id (org-export-solidify-link-text
1836 (if (org-uuidgen-p x
) (concat "ID-" x
)
1838 (org-e-html--anchor id
)))
1845 ;;;; Horizontal Rule
1847 (defun org-e-html-horizontal-rule (horizontal-rule contents info
)
1848 "Transcode an HORIZONTAL-RULE object from Org to HTML.
1849 CONTENTS is nil. INFO is a plist holding contextual information."
1853 ;;;; Inline Babel Call
1855 ;; Inline Babel Calls are ignored.
1858 ;;;; Inline Src Block
1860 (defun org-e-html-inline-src-block (inline-src-block contents info
)
1861 "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
1862 CONTENTS holds the contents of the item. INFO is a plist holding
1863 contextual information."
1864 (let* ((org-lang (org-element-property :language inline-src-block
))
1865 (code (org-element-property :value inline-src-block
)))
1871 (defun org-e-html-format-section (text class
&optional id
)
1872 (let ((extra (concat (when id
(format " id=\"%s\"" id
)))))
1873 (concat (format "<div class=\"%s\"%s>\n" class extra
) text
"</div>\n")))
1875 (defun org-e-html-inlinetask (inlinetask contents info
)
1876 "Transcode an INLINETASK element from Org to HTML.
1877 CONTENTS holds the contents of the block. INFO is a plist
1878 holding contextual information."
1880 ;; If `org-e-html-format-inlinetask-function' is provided, call it
1881 ;; with appropriate arguments.
1882 ((functionp org-e-html-format-inlinetask-function
)
1883 (let ((format-function
1885 (lambda (todo todo-type priority text tags
1886 &key contents
&allow-other-keys
)
1887 (funcall org-e-html-format-inlinetask-function
1888 todo todo-type priority text tags contents
)))))
1889 (org-e-html-format-headline--wrap
1890 inlinetask info format-function
:contents contents
)))
1891 ;; Otherwise, use a default template.
1892 (t (format "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>"
1893 (org-e-html-format-headline--wrap inlinetask info
)
1899 (defun org-e-html-italic (italic contents info
)
1900 "Transcode ITALIC from Org to HTML.
1901 CONTENTS is the text with italic markup. INFO is a plist holding
1902 contextual information."
1903 (format (or (cdr (assq 'italic org-e-html-text-markup-alist
)) "%s") contents
))
1908 (defun org-e-html-checkbox (checkbox)
1909 (case checkbox
(on "<code>[X]</code>")
1910 (off "<code>[ ]</code>")
1911 (trans "<code>[-]</code>")
1914 (defun org-e-html-format-list-item (contents type checkbox
1915 &optional term-counter-id
1917 (let ((checkbox (concat (org-e-html-checkbox checkbox
) (and checkbox
" "))))
1921 (let* ((counter term-counter-id
)
1922 (extra (if counter
(format " value=\"%s\"" counter
) "")))
1924 (format "<li%s>" extra
)
1925 (when headline
(concat headline
"<br/>")))))
1927 (let* ((id term-counter-id
)
1928 (extra (if id
(format " id=\"%s\"" id
) "")))
1930 (format "<li%s>" extra
)
1931 (when headline
(concat headline
"<br/>")))))
1933 (let* ((term term-counter-id
))
1934 (setq term
(or term
"(no term)"))
1935 ;; Check-boxes in descriptive lists are associated to tag.
1936 (concat (format "<dt> %s </dt>"
1937 (concat checkbox term
))
1939 (unless (eq type
'descriptive
) checkbox
)
1944 (descriptive "</dd>")))))
1946 (defun org-e-html-item (item contents info
)
1947 "Transcode an ITEM element from Org to HTML.
1948 CONTENTS holds the contents of the item. INFO is a plist holding
1949 contextual information."
1950 (let* ((plain-list (org-export-get-parent item
))
1951 (type (org-element-property :type plain-list
))
1952 (counter (org-element-property :counter item
))
1953 (checkbox (org-element-property :checkbox item
))
1954 (tag (let ((tag (org-element-property :tag item
)))
1955 (and tag
(org-export-data tag info
)))))
1956 (org-e-html-format-list-item
1957 contents type checkbox
(or tag counter
))))
1962 (defun org-e-html-keyword (keyword contents info
)
1963 "Transcode a KEYWORD element from Org to HTML.
1964 CONTENTS is nil. INFO is a plist holding contextual information."
1965 (let ((key (org-element-property :key keyword
))
1966 (value (org-element-property :value keyword
)))
1968 ((string= key
"HTML") value
)
1969 ((string= key
"INDEX") (format "\\index{%s}" value
))
1970 ;; Invisible targets.
1971 ((string= key
"TARGET") nil
)
1972 ((string= key
"TOC")
1973 (let ((value (downcase value
)))
1975 ((string-match "\\<headlines\\>" value
)
1976 (let ((depth (or (and (string-match "[0-9]+" value
)
1977 (string-to-number (match-string 0 value
)))
1978 (plist-get info
:with-toc
))))
1979 (org-e-html-toc depth info
)))
1980 ((string= "tables" value
) "\\listoftables")
1981 ((string= "figures" value
) "\\listoffigures")
1982 ((string= "listings" value
)
1984 ;; At the moment, src blocks with a caption are wrapped
1985 ;; into a figure environment.
1986 (t "\\listoffigures")))))))))
1989 ;;;; Latex Environment
1991 (defun org-e-html-format-latex (latex-frag processing-type
)
1992 (let* ((cache-relpath
1993 (concat "ltxpng/" (file-name-sans-extension
1994 (file-name-nondirectory (buffer-file-name)))))
1995 (cache-dir (file-name-directory (buffer-file-name )))
1996 (display-msg "Creating LaTeX Image..."))
2000 (org-format-latex cache-relpath cache-dir nil display-msg
2001 nil nil processing-type
)
2004 (defun org-e-html-latex-environment (latex-environment contents info
)
2005 "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
2006 CONTENTS is nil. INFO is a plist holding contextual information."
2007 (let ((processing-type (plist-get info
:LaTeX-fragments
))
2008 (latex-frag (org-remove-indentation
2009 (org-element-property :value latex-environment
)))
2010 (caption (org-export-data
2011 (org-export-get-caption latex-environment
) info
))
2013 (label (org-element-property :name latex-environment
)))
2015 ((memq processing-type
'(t mathjax
))
2016 (org-e-html-format-latex latex-frag
'mathjax
))
2017 ((eq processing-type
'dvipng
)
2018 (let* ((formula-link (org-e-html-format-latex
2019 latex-frag processing-type
)))
2020 (when (and formula-link
2021 (string-match "file:\\([^]]*\\)" formula-link
))
2022 (org-e-html-format-inline-image
2023 (match-string 1 formula-link
) caption label attr t
))))
2029 (defun org-e-html-latex-fragment (latex-fragment contents info
)
2030 "Transcode a LATEX-FRAGMENT object from Org to HTML.
2031 CONTENTS is nil. INFO is a plist holding contextual information."
2032 (let ((latex-frag (org-element-property :value latex-fragment
))
2033 (processing-type (plist-get info
:LaTeX-fragments
)))
2034 (case processing-type
2036 (org-e-html-format-latex latex-frag
'mathjax
))
2038 (let* ((formula-link (org-e-html-format-latex
2039 latex-frag processing-type
)))
2040 (when (and formula-link
2041 (string-match "file:\\([^]]*\\)" formula-link
))
2042 (org-e-html-format-inline-image
2043 (match-string 1 formula-link
)))))
2048 (defun org-e-html-line-break (line-break contents info
)
2049 "Transcode a LINE-BREAK object from Org to HTML.
2050 CONTENTS is nil. INFO is a plist holding contextual information."
2056 (defun org-e-html-link--inline-image (link desc info
)
2057 "Return HTML code for an inline image.
2058 LINK is the link pointing to the inline image. INFO is a plist
2059 used as a communication channel."
2060 (let* ((type (org-element-property :type link
))
2061 (raw-path (org-element-property :path link
))
2062 (path (cond ((member type
'("http" "https"))
2063 (concat type
":" raw-path
))
2064 ((file-name-absolute-p raw-path
)
2065 (expand-file-name raw-path
))
2067 (parent (org-export-get-parent-element link
))
2068 (caption (org-export-data (org-export-get-caption parent
) info
))
2069 (label (org-element-property :name parent
))
2070 ;; Retrieve latex attributes from the element around.
2071 (attr (let ((raw-attr
2072 (mapconcat #'identity
2073 (org-element-property :attr_html parent
)
2075 (unless (string= raw-attr
"") raw-attr
))))
2076 ;; Now clear ATTR from any special keyword and set a default
2077 ;; value if nothing is left.
2078 (setq attr
(if (not attr
) "" (org-trim attr
)))
2079 ;; Return proper string, depending on DISPOSITION.
2080 (org-e-html-format-inline-image
2081 path caption label attr
(org-e-html-standalone-image-p link info
))))
2083 (defvar org-e-html-standalone-image-predicate
)
2084 (defun org-e-html-standalone-image-p (element info
&optional predicate
)
2085 "Test if ELEMENT is a standalone image for the purpose HTML export.
2086 INFO is a plist holding contextual information.
2088 Return non-nil, if ELEMENT is of type paragraph and it's sole
2089 content, save for whitespaces, is a link that qualifies as an
2092 Return non-nil, if ELEMENT is of type link and it's containing
2093 paragraph has no other content save for leading and trailing
2096 Return nil, otherwise.
2098 Bind `org-e-html-standalone-image-predicate' to constrain
2099 paragraph further. For example, to check for only captioned
2100 standalone images, do the following.
2102 \(setq org-e-html-standalone-image-predicate
2103 \(lambda \(paragraph\)
2104 \(org-element-property :caption paragraph\)\)\)
2106 (let ((paragraph (case (org-element-type element
)
2108 (link (and (org-export-inline-image-p
2109 element org-e-html-inline-image-rules
)
2110 (org-export-get-parent element
)))
2113 (assert (eq (org-element-type paragraph
) 'paragraph
))
2114 (when (or (not (and (boundp 'org-e-html-standalone-image-predicate
)
2115 (functionp org-e-html-standalone-image-predicate
)))
2116 (funcall org-e-html-standalone-image-predicate paragraph
))
2117 (let ((contents (org-element-contents paragraph
)))
2118 (loop for x in contents
2119 with inline-image-count
= 0
2121 ((eq (org-element-type x
) 'plain-text
)
2122 (not (org-string-nw-p x
)))
2123 ((eq (org-element-type x
) 'link
)
2124 (when (org-export-inline-image-p
2125 x org-e-html-inline-image-rules
)
2126 (= (incf inline-image-count
) 1)))
2129 (defun org-e-html-link (link desc info
)
2130 "Transcode a LINK object from Org to HTML.
2132 DESC is the description part of the link, or the empty string.
2133 INFO is a plist holding contextual information. See
2135 (let* ((--link-org-files-as-html-maybe
2137 (lambda (raw-path info
)
2138 "Treat links to `file.org' as links to `file.html', if needed.
2139 See `org-e-html-link-org-files-as-html'."
2141 ((and org-e-html-link-org-files-as-html
2143 (downcase (file-name-extension raw-path
"."))))
2144 (concat (file-name-sans-extension raw-path
) "."
2145 (plist-get info
:html-extension
)))
2147 (type (org-element-property :type link
))
2148 (raw-path (org-element-property :path link
))
2149 ;; Ensure DESC really exists, or set it to nil.
2150 (desc (and (not (string= desc
"")) desc
))
2152 ((member type
'("http" "https" "ftp" "mailto"))
2153 (concat type
":" raw-path
))
2154 ((string= type
"file")
2155 ;; Treat links to ".org" files as ".html", if needed.
2156 (setq raw-path
(funcall --link-org-files-as-html-maybe
2158 ;; If file path is absolute, prepend it with protocol
2159 ;; component - "file://".
2160 (if (not (file-name-absolute-p raw-path
)) raw-path
2161 (concat "file://" (expand-file-name raw-path
))))
2163 ;; Extract attributes from parent's paragraph.
2165 (let ((attr (mapconcat
2167 (org-element-property
2168 :attr_html
(org-export-get-parent-element link
))
2170 (if attr
(concat " " attr
) "")))
2174 ((and (or (eq t org-e-html-inline-images
)
2175 (and org-e-html-inline-images
(not desc
)))
2176 (org-export-inline-image-p link org-e-html-inline-image-rules
))
2177 (org-e-html-link--inline-image link desc info
))
2178 ;; Radio target: Transcode target's contents and use them as
2179 ;; link's description.
2180 ((string= type
"radio")
2181 (let ((destination (org-export-resolve-radio-link link info
)))
2183 (format "<a href=\"#%s\"%s>%s</a>"
2184 (org-export-solidify-link-text path
)
2186 (org-export-data (org-element-contents destination
) info
)))))
2187 ;; Links pointing to an headline: Find destination and build
2188 ;; appropriate referencing command.
2189 ((member type
'("custom-id" "fuzzy" "id"))
2190 (let ((destination (if (string= type
"fuzzy")
2191 (org-export-resolve-fuzzy-link link info
)
2192 (org-export-resolve-id-link link info
))))
2193 (case (org-element-type destination
)
2194 ;; ID link points to an external file.
2196 (assert (org-uuidgen-p path
))
2197 (let ((fragment (concat "ID-" path
))
2198 ;; Treat links to ".org" files as ".html", if needed.
2199 (path (funcall --link-org-files-as-html-maybe
2201 (format "<a href=\"%s#%s\"%s>%s</a>"
2202 path fragment attributes
(or desc destination
))))
2203 ;; Fuzzy link points nowhere.
2208 (org-element-property :raw-link link
) info
))))
2209 ;; Fuzzy link points to an invisible target.
2211 ;; Link points to an headline.
2214 ;; What href to use?
2216 ;; Case 1: Headline is linked via it's CUSTOM_ID
2217 ;; property. Use CUSTOM_ID.
2218 ((string= type
"custom-id")
2219 (org-element-property :custom-id destination
))
2220 ;; Case 2: Headline is linked via it's ID property
2221 ;; or through other means. Use the default href.
2222 ((member type
'("id" "fuzzy"))
2224 (mapconcat 'number-to-string
2225 (org-export-get-headline-number
2226 destination info
) "-")))
2227 (t (error "Shouldn't reach here"))))
2228 ;; What description to use?
2230 ;; Case 1: Headline is numbered and LINK has no
2231 ;; description or LINK's description matches
2232 ;; headline's title. Display section number.
2233 (if (and (org-export-numbered-headline-p destination info
)
2235 (string= desc
(org-element-property
2236 :raw-value destination
))))
2237 (mapconcat 'number-to-string
2238 (org-export-get-headline-number
2239 destination info
) ".")
2240 ;; Case 2: Either the headline is un-numbered or
2241 ;; LINK has a custom description. Display LINK's
2242 ;; description or headline's title.
2243 (or desc
(org-export-data (org-element-property
2244 :title destination
) info
)))))
2245 (format "<a href=\"#%s\"%s>%s</a>"
2246 (org-export-solidify-link-text href
) attributes desc
)))
2247 ;; Fuzzy link points to a target. Do as above.
2249 (let ((path (org-export-solidify-link-text path
)) number
)
2252 ((org-e-html-standalone-image-p destination info
)
2253 (org-export-get-ordinal
2254 (assoc 'link
(org-element-contents destination
))
2255 info
'link
'org-e-html-standalone-image-p
))
2256 (t (org-export-get-ordinal destination info
))))
2257 (setq desc
(when number
2258 (if (atom number
) (number-to-string number
)
2259 (mapconcat 'number-to-string number
".")))))
2260 (format "<a href=\"#%s\"%s>%s</a>"
2261 path attributes
(or desc
"FIXME")))))))
2262 ;; Coderef: replace link with the reference name or the
2263 ;; equivalent line number.
2264 ((string= type
"coderef")
2265 (let ((fragment (concat "coderef-" path
)))
2266 (format "<a href=\"#%s\" %s%s>%s</a>"
2268 (format (concat "class=\"coderef\""
2269 " onmouseover=\"CodeHighlightOn(this, '%s');\""
2270 " onmouseout=\"CodeHighlightOff(this, '%s');\"")
2273 (format (org-export-get-coderef-format path desc
)
2274 (org-export-resolve-coderef path info
)))))
2275 ;; Link type is handled by a special function.
2276 ((functionp (setq protocol
(nth 2 (assoc type org-link-protocols
))))
2277 (funcall protocol
(org-link-unescape path
) desc
'html
))
2278 ;; External link with a description part.
2279 ((and path desc
) (format "<a href=\"%s\"%s>%s</a>" path attributes desc
))
2280 ;; External link without a description part.
2281 (path (format "<a href=\"%s\"%s>%s</a>" path attributes path
))
2282 ;; No path, only description. Try to do something useful.
2283 (t (format "<i>%s</i>" desc
)))))
2288 (defun org-e-html-paragraph (paragraph contents info
)
2289 "Transcode a PARAGRAPH element from Org to HTML.
2290 CONTENTS is the contents of the paragraph, as a string. INFO is
2291 the plist used as a communication channel."
2292 (let* ((style nil
) ; FIXME
2293 (class (cdr (assoc style
'((footnote .
"footnote")
2295 (extra (if class
(format " class=\"%s\"" class
) ""))
2296 (parent (org-export-get-parent paragraph
)))
2298 ((and (eq (org-element-type parent
) 'item
)
2299 (= (org-element-property :begin paragraph
)
2300 (org-element-property :contents-begin parent
)))
2301 ;; leading paragraph in a list item have no tags
2303 ((org-e-html-standalone-image-p paragraph info
)
2306 (t (format "<p%s>\n%s</p>" extra contents
)))))
2311 (defun org-e-html-begin-plain-list (type &optional arg1
)
2314 (format "<ol%s>" (if arg1
; FIXME
2315 (format " start=\"%d\"" arg1
)
2318 (descriptive "<dl>")))
2320 (defun org-e-html-end-plain-list (type)
2324 (descriptive "</dl>")))
2326 (defun org-e-html-plain-list (plain-list contents info
)
2327 "Transcode a PLAIN-LIST element from Org to HTML.
2328 CONTENTS is the contents of the list. INFO is a plist holding
2329 contextual information."
2330 (let* (arg1 ;; FIXME
2331 (type (org-element-property :type plain-list
)))
2333 (org-e-html-begin-plain-list type
)
2334 contents
(org-e-html-end-plain-list type
))))
2338 (defun org-e-html-convert-special-strings (string)
2339 "Convert special characters in STRING to HTML."
2340 (let ((all org-e-html-special-string-regexps
)
2342 (while (setq a
(pop all
))
2343 (setq re
(car a
) rpl
(cdr a
) start
0)
2344 (while (string-match re string start
)
2345 (setq string
(replace-match rpl t nil string
))))
2348 (defun org-e-html-encode-plain-text (text)
2349 "Convert plain text characters to HTML equivalent.
2350 Possible conversions are set in `org-export-html-protect-char-alist'."
2353 (setq text
(replace-regexp-in-string (car pair
) (cdr pair
) text t t
)))
2354 org-e-html-protect-char-alist
)
2357 (defun org-e-html-plain-text (text info
)
2358 "Transcode a TEXT string from Org to HTML.
2359 TEXT is the string to transcode. INFO is a plist holding
2360 contextual information."
2361 (let ((output text
))
2362 ;; Protect following characters: <, >, &.
2363 (setq output
(org-e-html-encode-plain-text output
))
2364 ;; Handle smart quotes. Be sure to provide original string since
2365 ;; OUTPUT may have been modified.
2366 (when (plist-get info
:with-smart-quotes
)
2367 (setq output
(org-export-activate-smart-quotes output
:html info text
)))
2368 ;; Handle special strings.
2369 (when (plist-get info
:with-special-strings
)
2370 (setq output
(org-e-html-convert-special-strings output
)))
2371 ;; Handle break preservation if required.
2372 (when (plist-get info
:preserve-breaks
)
2374 (replace-regexp-in-string
2375 "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output
)))
2382 (defun org-e-html-planning (planning contents info
)
2383 "Transcode a PLANNING element from Org to HTML.
2384 CONTENTS is nil. INFO is a plist used as a communication
2386 (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
2388 "<p><span class=\"timestamp-wrapper\">%s</span></p>"
2393 (let ((closed (org-element-property :closed planning
)))
2395 (format span-fmt org-closed-string
2397 (org-element-property :raw-value closed
)))))
2398 (let ((deadline (org-element-property :deadline planning
)))
2400 (format span-fmt org-deadline-string
2402 (org-element-property :raw-value deadline
)))))
2403 (let ((scheduled (org-element-property :scheduled planning
)))
2405 (format span-fmt org-scheduled-string
2407 (org-element-property :raw-value scheduled
)))))))
2411 ;;;; Property Drawer
2413 (defun org-e-html-property-drawer (property-drawer contents info
)
2414 "Transcode a PROPERTY-DRAWER element from Org to HTML.
2415 CONTENTS is nil. INFO is a plist holding contextual
2417 ;; The property drawer isn't exported but we want separating blank
2418 ;; lines nonetheless.
2424 (defun org-e-html-quote-block (quote-block contents info
)
2425 "Transcode a QUOTE-BLOCK element from Org to HTML.
2426 CONTENTS holds the contents of the block. INFO is a plist
2427 holding contextual information."
2428 (format "<blockquote>\n%s</blockquote>" contents
))
2433 (defun org-e-html-quote-section (quote-section contents info
)
2434 "Transcode a QUOTE-SECTION element from Org to HTML.
2435 CONTENTS is nil. INFO is a plist holding contextual information."
2436 (let ((value (org-remove-indentation
2437 (org-element-property :value quote-section
))))
2438 (when value
(format "<pre>\n%s</pre>" value
))))
2443 (defun org-e-html-section (section contents info
)
2444 "Transcode a SECTION element from Org to HTML.
2445 CONTENTS holds the contents of the section. INFO is a plist
2446 holding contextual information."
2447 (let ((parent (org-export-get-parent-headline section
)))
2448 ;; Before first headline: no container, just return CONTENTS.
2449 (if (not parent
) contents
2450 ;; Get div's class and id references.
2451 (let* ((class-num (+ (org-export-get-relative-level parent info
)
2452 (1- org-e-html-toplevel-hlevel
)))
2456 (org-export-get-headline-number parent info
) "-")))
2457 ;; Build return value.
2458 (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
2460 (or (org-element-property :custom-id parent
) section-number
)
2465 (defun org-e-html-radio-target (radio-target text info
)
2466 "Transcode a RADIO-TARGET object from Org to HTML.
2467 TEXT is the text of the target. INFO is a plist holding
2468 contextual information."
2469 (let ((id (org-export-solidify-link-text
2470 (org-element-property :value radio-target
))))
2471 (org-e-html--anchor id text
)))
2476 (defun org-e-html-special-block (special-block contents info
)
2477 "Transcode a SPECIAL-BLOCK element from Org to HTML.
2478 CONTENTS holds the contents of the block. INFO is a plist
2479 holding contextual information."
2480 (format "<div class=\"%s\">\n%s\n</div>"
2481 (downcase (org-element-property :type special-block
))
2487 (defun org-e-html-src-block (src-block contents info
)
2488 "Transcode a SRC-BLOCK element from Org to HTML.
2489 CONTENTS holds the contents of the item. INFO is a plist holding
2490 contextual information."
2491 (let ((lang (org-element-property :language src-block
))
2492 (caption (org-export-get-caption src-block
))
2493 (attr (org-export-read-attribute :attr_html src-block
))
2494 (code (org-e-html-format-code src-block info
)))
2497 (format "<div class=\"org-src-container\">\n%s%s\n</div>"
2498 (if (not caption
) ""
2499 (format "<label class=\"org-src-name\">%s</label>"
2500 (org-export-data caption info
)))
2501 (format "\n<pre class=\"src src-%s\">%s</pre>" lang code
)))
2502 ((plist-get attr
:textarea
)
2503 (let ((cols (or (plist-get attr
:width
) 80))
2504 (rows (or (plist-get attr
:height
) (org-count-lines code
))))
2505 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">\n%s</textarea>\n</p>"
2507 (t (format "<pre class=\"example\">\n%s</pre>" code
)))))
2510 ;;;; Statistics Cookie
2512 (defun org-e-html-statistics-cookie (statistics-cookie contents info
)
2513 "Transcode a STATISTICS-COOKIE object from Org to HTML.
2514 CONTENTS is nil. INFO is a plist holding contextual information."
2515 (let ((cookie-value (org-element-property :value statistics-cookie
)))
2516 (format "<code>%s</code>" cookie-value
)))
2521 (defun org-e-html-strike-through (strike-through contents info
)
2522 "Transcode STRIKE-THROUGH from Org to HTML.
2523 CONTENTS is the text with strike-through markup. INFO is a plist
2524 holding contextual information."
2525 (format (or (cdr (assq 'strike-through org-e-html-text-markup-alist
)) "%s")
2531 (defun org-e-html-subscript (subscript contents info
)
2532 "Transcode a SUBSCRIPT object from Org to HTML.
2533 CONTENTS is the contents of the object. INFO is a plist holding
2534 contextual information."
2535 (format "<sub>%s</sub>" contents
))
2540 (defun org-e-html-superscript (superscript contents info
)
2541 "Transcode a SUPERSCRIPT object from Org to HTML.
2542 CONTENTS is the contents of the object. INFO is a plist holding
2543 contextual information."
2544 (format "<sup>%s</sup>" contents
))
2549 (defun org-e-html-table-cell (table-cell contents info
)
2550 "Transcode a TABLE-CELL element from Org to HTML.
2551 CONTENTS is nil. INFO is a plist used as a communication
2553 (let* ((table-row (org-export-get-parent table-cell
))
2554 (table (org-export-get-parent-table table-cell
))
2556 (if (not org-e-html-table-align-individual-fields
) ""
2557 (format (if (and (boundp 'org-e-html-format-table-no-css
)
2558 org-e-html-format-table-no-css
)
2559 " align=\"%s\"" " class=\"%s\"")
2560 (org-export-table-cell-alignment table-cell info
)))))
2561 (when (or (not contents
) (string= "" (org-trim contents
)))
2562 (setq contents
" "))
2564 ((and (org-export-table-has-header-p table info
)
2565 (= 1 (org-export-table-row-group table-row info
)))
2566 (concat "\n" (format (car org-e-html-table-header-tags
) "col" cell-attrs
)
2567 contents
(cdr org-e-html-table-header-tags
)))
2568 ((and org-e-html-table-use-header-tags-for-first-column
2569 (zerop (cdr (org-export-table-cell-address table-cell info
))))
2570 (concat "\n" (format (car org-e-html-table-header-tags
) "row" cell-attrs
)
2571 contents
(cdr org-e-html-table-header-tags
)))
2572 (t (concat "\n" (format (car org-e-html-table-data-tags
) cell-attrs
)
2573 contents
(cdr org-e-html-table-data-tags
))))))
2578 (defun org-e-html-table-row (table-row contents info
)
2579 "Transcode a TABLE-ROW element from Org to HTML.
2580 CONTENTS is the contents of the row. INFO is a plist used as a
2581 communication channel."
2582 ;; Rules are ignored since table separators are deduced from
2583 ;; borders of the current row.
2584 (when (eq (org-element-property :type table-row
) 'standard
)
2585 (let* ((first-rowgroup-p (= 1 (org-export-table-row-group table-row info
)))
2588 ;; Case 1: Row belongs to second or subsequent rowgroups.
2589 ((not (= 1 (org-export-table-row-group table-row info
)))
2590 '("<tbody>" .
"\n</tbody>"))
2591 ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
2592 ((org-export-table-has-header-p
2593 (org-export-get-parent-table table-row
) info
)
2594 '("<thead>" .
"\n</thead>"))
2595 ;; Case 2: Row is from first and only row group.
2596 (t '("<tbody>" .
"\n</tbody>")))))
2598 ;; Begin a rowgroup?
2599 (when (org-export-table-row-starts-rowgroup-p table-row info
)
2600 (car rowgroup-tags
))
2602 (concat "\n" (eval (car org-e-html-table-row-tags
))
2605 (eval (cdr org-e-html-table-row-tags
)))
2607 (when (org-export-table-row-ends-rowgroup-p table-row info
)
2608 (cdr rowgroup-tags
))))))
2613 (defun org-e-html-table-first-row-data-cells (table info
)
2618 (unless (eq (org-element-property :type row
) 'rule
) row
))
2620 (special-column-p (org-export-table-has-special-column-p table
)))
2621 (if (not special-column-p
) (org-element-contents table-row
)
2622 (cdr (org-element-contents table-row
)))))
2624 (defun org-e-html-table--table.el-table
(table info
)
2625 (when (eq (org-element-property :type table
) 'table.el
)
2627 (let ((outbuf (with-current-buffer
2628 (get-buffer-create "*org-export-table*")
2629 (erase-buffer) (current-buffer))))
2631 (insert (org-element-property :value table
))
2633 (re-search-forward "^[ \t]*|[^|]" nil t
)
2634 (table-generate-source 'html outbuf
))
2635 (with-current-buffer outbuf
2636 (prog1 (org-trim (buffer-string))
2639 (defun org-e-html-table (table contents info
)
2640 "Transcode a TABLE element from Org to HTML.
2641 CONTENTS is the contents of the table. INFO is a plist holding
2642 contextual information."
2643 (case (org-element-property :type table
)
2644 ;; Case 1: table.el table. Convert it using appropriate tools.
2645 (table.el
(org-e-html-table--table.el-table table info
))
2646 ;; Case 2: Standard table.
2648 (let* ((label (org-element-property :name table
))
2649 (caption (org-export-get-caption table
))
2650 (attributes (mapconcat #'identity
2651 (org-element-property :attr_html table
)
2654 (if (and (boundp 'org-e-html-format-table-no-css
)
2655 org-e-html-format-table-no-css
)
2656 "align=\"%s\"" "class=\"%s\""))
2659 (lambda (table info
)
2661 (lambda (table-cell)
2662 (let ((alignment (org-export-table-cell-alignment
2665 ;; Begin a colgroup?
2666 (when (org-export-table-cell-starts-colgroup-p
2669 ;; Add a column. Also specify it's alignment.
2670 (format "\n<col %s/>" (format alignspec alignment
))
2672 (when (org-export-table-cell-ends-colgroup-p
2675 (org-e-html-table-first-row-data-cells table info
) "\n"))))
2677 (let ((table-tag (plist-get info
:html-table-tag
)))
2679 (and (string-match "<table\\(.*\\)>" table-tag
)
2680 (match-string 1 table-tag
))
2681 (and label
(format " id=\"%s\""
2682 (org-export-solidify-link-text label
)))))))
2683 ;; Remove last blank line.
2684 (setq contents
(substring contents
0 -
1))
2685 (format "<table%s>\n%s\n%s\n%s\n</table>"
2687 (if (not caption
) ""
2688 (format "<caption>%s</caption>"
2689 (org-export-data caption info
)))
2690 (funcall table-column-specs table info
)
2695 (defun org-e-html-target (target contents info
)
2696 "Transcode a TARGET object from Org to HTML.
2697 CONTENTS is nil. INFO is a plist holding contextual
2699 (let ((id (org-export-solidify-link-text
2700 (org-element-property :value target
))))
2701 (org-e-html--anchor id
)))
2706 (defun org-e-html-timestamp (timestamp contents info
)
2707 "Transcode a TIMESTAMP object from Org to HTML.
2708 CONTENTS is nil. INFO is a plist holding contextual
2710 (let ((value (org-translate-time
2711 (org-element-property :raw-value timestamp
))))
2712 (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
2713 (replace-regexp-in-string "--" "–" value
))))
2718 (defun org-e-html-underline (underline contents info
)
2719 "Transcode UNDERLINE from Org to HTML.
2720 CONTENTS is the text with underline markup. INFO is a plist
2721 holding contextual information."
2722 (format (or (cdr (assq 'underline org-e-html-text-markup-alist
)) "%s")
2728 (defun org-e-html-verbatim (verbatim contents info
)
2729 "Transcode VERBATIM from Org to HTML.
2730 CONTENTS is nil. INFO is a plist holding contextual
2732 (format (or (cdr (assq 'verbatim org-e-html-text-markup-alist
)) "%s")
2733 (org-element-property :value verbatim
)))
2738 (defun org-e-html-verse-block (verse-block contents info
)
2739 "Transcode a VERSE-BLOCK element from Org to HTML.
2740 CONTENTS is verse block contents. INFO is a plist holding
2741 contextual information."
2742 ;; Replace each newline character with line break. Also replace
2743 ;; each blank line with a line break.
2744 (setq contents
(replace-regexp-in-string
2745 "^ *\\\\\\\\$" "<br/>\n"
2746 (replace-regexp-in-string
2747 "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents
)))
2748 ;; Replace each white space at beginning of a line with a
2749 ;; non-breaking space.
2750 (while (string-match "^[ \t]+" contents
)
2751 (let* ((num-ws (length (match-string 0 contents
)))
2752 (ws (let (out) (dotimes (i num-ws out
)
2753 (setq out
(concat out
" "))))))
2754 (setq contents
(replace-match ws nil t contents
))))
2755 (format "<p class=\"verse\">\n%s</p>" contents
))
2760 ;;; Filter Functions
2762 (defun org-e-html-final-function (contents backend info
)
2763 (if (not org-e-html-pretty-output
) contents
2767 (indent-region (point-min) (point-max))
2768 (buffer-substring-no-properties (point-min) (point-max)))))
2771 ;;; End-user functions
2774 (defun org-e-html-export-as-html
2775 (&optional subtreep visible-only body-only ext-plist
)
2776 "Export current buffer to an HTML buffer.
2778 If narrowing is active in the current buffer, only export its
2781 If a region is active, export that region.
2783 When optional argument SUBTREEP is non-nil, export the sub-tree
2784 at point, extracting information from the headline properties
2787 When optional argument VISIBLE-ONLY is non-nil, don't export
2788 contents of hidden elements.
2790 When optional argument BODY-ONLY is non-nil, only write code
2791 between \"<body>\" and \"</body>\" tags.
2793 EXT-PLIST, when provided, is a property list with external
2794 parameters overriding Org default settings, but still inferior to
2795 file-local settings.
2797 Export is done in a buffer named \"*Org E-HTML Export*\", which
2798 will be displayed when `org-export-show-temporary-export-buffer'
2802 (org-export-to-buffer
2803 'e-html
"*Org E-HTML Export*"
2804 subtreep visible-only body-only ext-plist
)))
2806 (with-current-buffer outbuf
(nxml-mode))
2807 (when org-export-show-temporary-export-buffer
2808 (switch-to-buffer-other-window outbuf
))))
2811 (defun org-e-html-export-to-html
2812 (&optional subtreep visible-only body-only ext-plist pub-dir
)
2813 "Export current buffer to a HTML file.
2815 If narrowing is active in the current buffer, only export its
2818 If a region is active, export that region.
2820 When optional argument SUBTREEP is non-nil, export the sub-tree
2821 at point, extracting information from the headline properties
2824 When optional argument VISIBLE-ONLY is non-nil, don't export
2825 contents of hidden elements.
2827 When optional argument BODY-ONLY is non-nil, only write code
2828 between \"<body>\" and \"</body>\" tags.
2830 EXT-PLIST, when provided, is a property list with external
2831 parameters overriding Org default settings, but still inferior to
2832 file-local settings.
2834 When optional argument PUB-DIR is set, use it as the publishing
2837 Return output file's name."
2839 (let* ((extension (concat "." org-e-html-extension
))
2840 (file (org-export-output-file-name extension subtreep pub-dir
))
2841 (org-export-coding-system org-e-html-coding-system
))
2843 'e-html file subtreep visible-only body-only ext-plist
)))
2846 (defun org-e-html-publish-to-html (plist filename pub-dir
)
2847 "Publish an org file to HTML.
2849 FILENAME is the filename of the Org file to be published. PLIST
2850 is the property list for the given project. PUB-DIR is the
2851 publishing directory.
2853 Return output file name."
2854 (org-e-publish-org-to 'e-html filename
".html" plist pub-dir
))
2860 ;;;; org-format-table-html
2861 ;;;; org-format-org-table-html
2862 ;;;; org-format-table-table-html
2863 ;;;; org-table-number-fraction
2864 ;;;; org-table-number-regexp
2865 ;;;; org-e-html-table-caption-above
2867 ;;;; org-e-html-with-timestamp
2868 ;;;; org-e-html-html-helper-timestamp
2870 ;;;; org-export-as-html-and-open
2871 ;;;; org-export-as-html-batch
2872 ;;;; org-export-as-html-to-buffer
2873 ;;;; org-replace-region-by-html
2874 ;;;; org-export-region-as-html
2875 ;;;; org-export-as-html
2877 ;;;; (org-export-directory :html opt-plist)
2878 ;;;; (plist-get opt-plist :html-extension)
2879 ;;;; org-e-html-toplevel-hlevel
2880 ;;;; org-e-html-special-string-regexps
2881 ;;;; org-e-html-inline-images
2882 ;;;; org-e-html-inline-image-extensions
2883 ;;;; org-e-html-protect-char-alist
2884 ;;;; org-e-html-table-use-header-tags-for-first-column
2885 ;;;; org-e-html-todo-kwd-class-prefix
2886 ;;;; org-e-html-tag-class-prefix
2887 ;;;; org-e-html-footnote-separator
2889 ;;;; org-export-preferred-target-alist
2890 ;;;; org-export-solidify-link-text
2891 ;;;; class for anchors
2892 ;;;; org-export-with-section-numbers, body-only
2893 ;;;; org-export-mark-todo-in-toc
2895 ;;;; org-e-html-format-org-link
2896 ;;;; (caption (and caption (org-xml-encode-org-text caption)))
2897 ;;;; alt = (file-name-nondirectory path)
2899 ;;;; org-export-time-stamp-file'
2901 (provide 'org-e-html
)
2902 ;;; org-e-html.el ends here