1 ;;; org-html.el --- HTML export for Org-mode
3 ;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Keywords: outlines, hypermedia, calendar, wp
7 ;; Homepage: http://orgmode.org
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
30 (require 'format-spec
)
32 (eval-when-compile (require 'cl
))
34 (declare-function org-id-find-id-file
"org-id" (id))
35 (declare-function htmlize-region
"ext:htmlize" (beg end
))
36 (declare-function org-pop-to-buffer-same-window
37 "org-compat" (&optional buffer-or-name norecord label
))
39 (defgroup org-export-html nil
40 "Options specific for HTML export of Org-mode files."
41 :tag
"Org Export HTML"
44 (defcustom org-export-html-footnotes-section
"<div id=\"footnotes\">
45 <h2 class=\"footnotes\">%s: </h2>
46 <div id=\"text-footnotes\">
50 "Format for the footnotes section.
51 Should contain a two instances of %s. The first will be replaced with the
52 language-specific word for \"Footnotes\", the second one will be replaced
53 by the footnotes themselves."
54 :group
'org-export-html
57 (defcustom org-export-html-footnote-format
"<sup>%s</sup>"
58 "The format for the footnote reference.
59 %s will be replaced by the footnote reference itself."
60 :group
'org-export-html
64 (defcustom org-export-html-footnote-separator
"<sup>, </sup>"
65 "Text used to separate footnotes."
66 :group
'org-export-html
70 (defcustom org-export-html-coding-system nil
71 "Coding system for HTML export, defaults to `buffer-file-coding-system'."
72 :group
'org-export-html
75 (defcustom org-export-html-extension
"html"
76 "The extension for exported HTML files."
77 :group
'org-export-html
80 (defcustom org-export-html-xml-declaration
81 '(("html" .
"<?xml version=\"1.0\" encoding=\"%s\"?>")
82 ("php" .
"<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
83 "The extension for exported HTML files.
84 %s will be replaced with the charset of the exported file.
85 This may be a string, or an alist with export extensions
86 and corresponding declarations."
87 :group
'org-export-html
89 (string :tag
"Single declaration")
90 (repeat :tag
"Dependent on extension"
91 (cons (string :tag
"Extension")
92 (string :tag
"Declaration")))))
94 (defcustom org-export-html-style-include-scripts t
95 "Non-nil means include the JavaScript snippets in exported HTML files.
96 The actual script is defined in `org-export-html-scripts' and should
98 :group
'org-export-html
101 (defvar org-export-html-scripts
102 "<script type=\"text/javascript\">
104 @licstart The following is the entire license notice for the
105 JavaScript code in this tag.
107 Copyright (C) 2012-2013 Free Software Foundation, Inc.
109 The JavaScript code in this tag is free software: you can
110 redistribute it and/or modify it under the terms of the GNU
111 General Public License (GNU GPL) as published by the Free Software
112 Foundation, either version 3 of the License, or (at your option)
113 any later version. The code is distributed WITHOUT ANY WARRANTY;
114 without even the implied warranty of MERCHANTABILITY or FITNESS
115 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
117 As additional permission under GNU GPL version 3 section 7, you
118 may distribute non-source (e.g., minimized or compacted) forms of
119 that code without the copy of the GNU GPL normally required by
120 section 4, provided you include this license notice and a URL
121 through which recipients can access the Corresponding Source.
124 @licend The above is the entire license notice
125 for the JavaScript code in this tag.
127 <!--/*--><![CDATA[/*><!--*/
128 function CodeHighlightOn(elem, id)
130 var target = document.getElementById(id);
132 elem.cacheClassElem = elem.className;
133 elem.cacheClassTarget = target.className;
134 target.className = \"code-highlighted\";
135 elem.className = \"code-highlighted\";
138 function CodeHighlightOff(elem, id)
140 var target = document.getElementById(id);
141 if(elem.cacheClassElem)
142 elem.className = elem.cacheClassElem;
143 if(elem.cacheClassTarget)
144 target.className = elem.cacheClassTarget;
148 "Basic JavaScript that is needed by HTML files produced by Org-mode.")
150 (defconst org-export-html-style-default
151 "<style type=\"text/css\">
152 <!--/*--><![CDATA[/*><!--*/
153 html { font-family: Times, serif; font-size: 12pt; }
154 .title { text-align: center; }
155 .todo { color: red; }
156 .done { color: green; }
157 .tag { background-color: #add8e6; font-weight:normal }
159 .timestamp { color: #bebebe; }
160 .timestamp-kwd { color: #5f9ea0; }
161 .right {margin-left:auto; margin-right:0px; text-align:right;}
162 .left {margin-left:0px; margin-right:auto; text-align:left;}
163 .center {margin-left:auto; margin-right:auto; text-align:center;}
164 p.verse { margin-left: 3% }
166 border: 1pt solid #AEBDCC;
167 background-color: #F3F5F7;
169 font-family: courier, monospace;
173 table { border-collapse: collapse; }
174 td, th { vertical-align: top; }
175 th.right { text-align:center; }
176 th.left { text-align:center; }
177 th.center { text-align:center; }
178 td.right { text-align:right; }
179 td.left { text-align:left; }
180 td.center { text-align:center; }
181 dt { font-weight: bold; }
182 div.figure { padding: 0.5em; }
183 div.figure p { text-align: center; }
186 border:2px solid gray;
190 textarea { overflow-x: auto; }
191 .linenr { font-size:smaller }
192 .code-highlighted {background-color:#ffff00;}
193 .org-info-js_info-navigation { border-style:none; }
194 #org-info-js_console-label { font-size:10px; font-weight:bold;
195 white-space:nowrap; }
196 .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
200 "The default style specification for exported HTML files.
201 Please use the variables `org-export-html-style' and
202 `org-export-html-style-extra' to add to this style. If you wish to not
203 have the default style included, customize the variable
204 `org-export-html-style-include-default'.")
206 (defcustom org-export-html-style-include-default t
207 "Non-nil means include the default style in exported HTML files.
208 The actual style is defined in `org-export-html-style-default' and should
209 not be modified. Use the variables `org-export-html-style' to add
210 your own style information."
211 :group
'org-export-html
215 (put 'org-export-html-style-include-default
'safe-local-variable
'booleanp
)
217 (defcustom org-export-html-style
""
218 "Org-wide style definitions for exported HTML files.
220 This variable needs to contain the full HTML structure to provide a style,
221 including the surrounding HTML tags. If you set the value of this variable,
222 you should consider to include definitions for the following classes:
223 title, todo, done, timestamp, timestamp-kwd, tag, target.
225 For example, a valid value would be:
227 <style type=\"text/css\">
229 p { font-weight: normal; color: gray; }
231 .title { text-align: center; }
232 .todo, .timestamp-kwd { color: red; }
233 .done { color: green; }
237 If you'd like to refer to an external style file, use something like
239 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
241 As the value of this option simply gets inserted into the HTML <head> header,
242 you can \"misuse\" it to add arbitrary text to the header.
243 See also the variable `org-export-html-style-extra'."
244 :group
'org-export-html
247 (put 'org-export-html-style
'safe-local-variable
'stringp
)
249 (defcustom org-export-html-style-extra
""
250 "Additional style information for HTML export.
251 The value of this variable is inserted into the HTML buffer right after
252 the value of `org-export-html-style'. Use this variable for per-file
253 settings of style information, and do not forget to surround the style
254 settings with <style>...</style> tags."
255 :group
'org-export-html
258 (put 'org-export-html-style-extra
'safe-local-variable
'stringp
)
260 (defcustom org-export-html-mathjax-options
261 '((path "http://orgmode.org/mathjax/MathJax.js")
266 "Options for MathJax setup.
268 path The path where to find MathJax
269 scale Scaling for the HTML-CSS backend, usually between 100 and 133
270 align How to align display math: left, center, or right
271 indent If align is not center, how far from the left/right side?
272 mathml Should a MathML player be used if available?
273 This is faster and reduces bandwidth use, but currently
274 sometimes has lower spacing quality. Therefore, the default is
275 nil. When browsers get better, this switch can be flipped.
277 You can also customize this for each buffer, using something like
279 #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
280 :group
'org-export-html
282 :type
'(list :greedy t
283 (list :tag
"path (the path from where to load MathJax.js)"
284 (const :format
" " path
) (string))
285 (list :tag
"scale (scaling for the displayed math)"
286 (const :format
" " scale
) (string))
287 (list :tag
"align (alignment of displayed equations)"
288 (const :format
" " align
) (string))
289 (list :tag
"indent (indentation with left or right alignment)"
290 (const :format
" " indent
) (string))
291 (list :tag
"mathml (should MathML display be used is possible)"
292 (const :format
" " mathml
) (boolean))))
294 (defun org-export-html-mathjax-config (template options in-buffer
)
295 "Insert the user setup into the matchjax template."
296 (let (name val
(yes " ") (no "// ") x
)
299 (setq name
(car e
) val
(nth 1 e
))
300 (if (string-match (concat "\\<" (symbol-name name
) ":") in-buffer
)
301 (setq val
(car (read-from-string
302 (substring in-buffer
(match-end 0))))))
303 (if (not (stringp val
)) (setq val
(format "%s" val
)))
305 (replace-regexp-in-string
306 (concat "%" (upcase (symbol-name name
))) val template t t
)))
308 (setq val
(nth 1 (assq 'mathml options
)))
309 (if (string-match (concat "\\<mathml:") in-buffer
)
310 (setq val
(car (read-from-string
311 (substring in-buffer
(match-end 0))))))
312 ;; Exchange prefixes depending on mathml setting
313 (if (not val
) (setq x yes yes no no x
))
314 ;; Replace cookies to turn on or off the config/jax lines
315 (if (string-match ":MMLYES:" template
)
316 (setq template
(replace-match yes t t template
)))
317 (if (string-match ":MMLNO:" template
)
318 (setq template
(replace-match no t t template
)))
319 ;; Return the modified template
322 (defcustom org-export-html-mathjax-template
323 "<script type=\"text/javascript\" src=\"%PATH\">
328 * @licstart The following is the entire license notice for the
329 * JavaScript code in %PATH.
331 * Copyright (C) 2012-2013 MathJax
333 * Licensed under the Apache License, Version 2.0 (the \"License\");
334 * you may not use this file except in compliance with the License.
335 * You may obtain a copy of the License at
337 * http://www.apache.org/licenses/LICENSE-2.0
339 * Unless required by applicable law or agreed to in writing, software
340 * distributed under the License is distributed on an \"AS IS\" BASIS,
341 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
342 * See the License for the specific language governing permissions and
343 * limitations under the License.
345 * @licend The above is the entire license notice
346 * for the JavaScript code in %PATH.
351 @licstart The following is the entire license notice for the
352 JavaScript code below.
354 Copyright (C) 2012-2013 Free Software Foundation, Inc.
356 The JavaScript code below is free software: you can
357 redistribute it and/or modify it under the terms of the GNU
358 General Public License (GNU GPL) as published by the Free Software
359 Foundation, either version 3 of the License, or (at your option)
360 any later version. The code is distributed WITHOUT ANY WARRANTY;
361 without even the implied warranty of MERCHANTABILITY or FITNESS
362 FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
364 As additional permission under GNU GPL version 3 section 7, you
365 may distribute non-source (e.g., minimized or compacted) forms of
366 that code without the copy of the GNU GPL normally required by
367 section 4, provided you include this license notice and a URL
368 through which recipients can access the Corresponding Source.
371 @licend The above is the entire license notice
372 for the JavaScript code below.
374 <!--/*--><![CDATA[/*><!--*/
376 // Only one of the two following lines, depending on user settings
377 // First allows browser-native MathML display, second forces HTML/CSS
378 :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
379 :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
380 extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
381 \"TeX/noUndefined.js\"],
383 inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
384 displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
385 skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
386 ignoreClass: \"tex2jax_ignore\",
387 processEscapes: false,
388 processEnvironments: true,
391 showProcessingMessages: true,
392 displayAlign: \"%ALIGN\",
393 displayIndent: \"%INDENT\",
397 availableFonts: [\"STIX\",\"TeX\"],
398 preferredFont: \"TeX\",
414 "The MathJax setup for XHTML files."
415 :group
'org-export-html
419 (defcustom org-export-html-tag-class-prefix
""
420 "Prefix to class names for TODO keywords.
421 Each tag gets a class given by the tag itself, with this prefix.
422 The default prefix is empty because it is nice to just use the keyword
423 as a class name. But if you get into conflicts with other, existing
424 CSS classes, then this prefix can be very useful."
425 :group
'org-export-html
428 (defcustom org-export-html-todo-kwd-class-prefix
""
429 "Prefix to class names for TODO keywords.
430 Each TODO keyword gets a class given by the keyword itself, with this prefix.
431 The default prefix is empty because it is nice to just use the keyword
432 as a class name. But if you get into conflicts with other, existing
433 CSS classes, then this prefix can be very useful."
434 :group
'org-export-html
437 (defcustom org-export-html-headline-anchor-format
"<a name=\"%s\" id=\"%s\"></a>"
438 "Format for anchors in HTML headlines.
439 It requires to %s: both will be replaced by the anchor referring
440 to the headline (e.g. \"sec-2\"). When set to `nil', don't insert
441 HTML anchors in headlines."
442 :group
'org-export-html
446 (defcustom org-export-html-preamble t
447 "Non-nil means insert a preamble in HTML export.
449 When `t', insert a string as defined by one of the formatting
450 strings in `org-export-html-preamble-format'. When set to a
451 string, this string overrides `org-export-html-preamble-format'.
452 When set to a function, apply this function and insert the
453 returned string. The function takes no argument, but you can
454 use `opt-plist' to access the current export options.
456 Setting :html-preamble in publishing projects will take
457 precedence over this variable."
458 :group
'org-export-html
459 :type
'(choice (const :tag
"No preamble" nil
)
460 (const :tag
"Default preamble" t
)
461 (string :tag
"Custom format string")
462 (function :tag
"Function (must return a string)")))
464 (defcustom org-export-html-preamble-format
'(("en" ""))
465 "Alist of languages and format strings for the HTML preamble.
467 To enable the HTML exporter to use these formats, you need to set
468 `org-export-html-preamble' to `t'.
470 The first element of each list is the language code, as used for
471 the #+LANGUAGE keyword.
473 The second element of each list is a format string to format the
474 preamble itself. This format string can contain these elements:
476 %t stands for the title.
477 %a stands for the author's name.
478 %e stands for the author's email.
479 %d stands for the date.
481 If you need to use a \"%\" character, you need to escape it
483 :group
'org-export-html
487 (defcustom org-export-html-postamble
'auto
488 "Non-nil means insert a postamble in HTML export.
490 When `t', insert a string as defined by the format string in
491 `org-export-html-postamble-format'. When set to a string, this
492 string overrides `org-export-html-postamble-format'. When set to
493 'auto, discard `org-export-html-postamble-format' and honor
494 `org-export-author/email/creator-info' variables. When set to a
495 function, apply this function and insert the returned string.
496 The function takes no argument, but you can use `opt-plist' to
497 access the current export options.
499 Setting :html-postamble in publishing projects will take
500 precedence over this variable."
501 :group
'org-export-html
502 :type
'(choice (const :tag
"No postamble" nil
)
503 (const :tag
"Auto preamble" 'auto
)
504 (const :tag
"Default format string" t
)
505 (string :tag
"Custom format string")
506 (function :tag
"Function (must return a string)")))
508 (defcustom org-export-html-postamble-format
509 '(("en" "<p class=\"author\">Author: %a (%e)</p>
510 <p class=\"date\">Date: %d</p>
511 <p class=\"creator\">Generated by %c</p>
512 <p class=\"xhtml-validation\">%v</p>
514 "Alist of languages and format strings for the HTML postamble.
516 To enable the HTML exporter to use these formats, you need to set
517 `org-export-html-postamble' to `t'.
519 The first element of each list is the language code, as used for
520 the #+LANGUAGE keyword.
522 The second element of each list is a format string to format the
523 postamble itself. This format string can contain these elements:
525 %a stands for the author's name.
526 %e stands for the author's email.
527 %d stands for the date.
528 %c will be replaced by information about Org/Emacs versions.
529 %v will be replaced by `org-export-html-validation-link'.
531 If you need to use a \"%\" character, you need to escape it
533 :group
'org-export-html
537 (defcustom org-export-html-home
/up-format
538 "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
539 <a accesskey=\"h\" href=\"%s\"> UP </a>
541 <a accesskey=\"H\" href=\"%s\"> HOME </a>
543 "Snippet used to insert the HOME and UP links.
544 This is a format string, the first %s will receive the UP link,
545 the second the HOME link. If both `org-export-html-link-up' and
546 `org-export-html-link-home' are empty, the entire snippet will be
548 :group
'org-export-html
551 (defcustom org-export-html-toplevel-hlevel
2
552 "The <H> level for level 1 headings in HTML export.
553 This is also important for the classes that will be wrapped around headlines
554 and outline structure. If this variable is 1, the top-level headlines will
555 be <h1>, and the corresponding classes will be outline-1, section-number-1,
556 and outline-text-1. If this is 2, all of these will get a 2 instead.
557 The default for this variable is 2, because we use <h1> for formatting the
559 :group
'org-export-html
562 (defcustom org-export-html-link-org-files-as-html t
563 "Non-nil means make file links to `file.org' point to `file.html'.
564 When org-mode is exporting an org-mode file to HTML, links to
565 non-html files are directly put into a href tag in HTML.
566 However, links to other Org-mode files (recognized by the
567 extension `.org.) should become links to the corresponding html
568 file, assuming that the linked org-mode file will also be
570 When nil, the links still point to the plain `.org' file."
571 :group
'org-export-html
574 (defcustom org-export-html-inline-images
'maybe
575 "Non-nil means inline images into exported HTML pages.
576 This is done using an <img> tag. When nil, an anchor with href is used to
577 link to the image. If this option is `maybe', then images in links with
578 an empty description will be inlined, while images with a description will
580 :group
'org-export-html
581 :type
'(choice (const :tag
"Never" nil
)
582 (const :tag
"Always" t
)
583 (const :tag
"When there is no description" maybe
)))
585 (defcustom org-export-html-inline-image-extensions
586 '("png" "jpeg" "jpg" "gif" "svg")
587 "Extensions of image files that can be inlined into HTML."
588 :group
'org-export-html
589 :type
'(repeat (string :tag
"Extension")))
591 (defcustom org-export-html-table-tag
592 "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
593 "The HTML tag that is used to start a table.
594 This must be a <table> tag, but you may change the options like
595 borders and spacing."
596 :group
'org-export-html
599 (defcustom org-export-table-header-tags
'("<th scope=\"%s\"%s>" .
"</th>")
600 "The opening tag for table header fields.
601 This is customizable so that alignment options can be specified.
602 The first %s will be filled with the scope of the field, either row or col.
603 The second %s will be replaced by a style entry to align the field.
604 See also the variable `org-export-html-table-use-header-tags-for-first-column'.
605 See also the variable `org-export-html-table-align-individual-fields'."
606 :group
'org-export-tables
607 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
609 (defcustom org-export-table-data-tags
'("<td%s>" .
"</td>")
610 "The opening tag for table data fields.
611 This is customizable so that alignment options can be specified.
612 The first %s will be filled with the scope of the field, either row or col.
613 The second %s will be replaced by a style entry to align the field.
614 See also the variable `org-export-html-table-align-individual-fields'."
615 :group
'org-export-tables
616 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
618 (defcustom org-export-table-row-tags
'("<tr>" .
"</tr>")
619 "The opening tag for table data fields.
620 This is customizable so that alignment options can be specified.
621 Instead of strings, these can be Lisp forms that will be evaluated
622 for each row in order to construct the table row tags. During evaluation,
623 the variable `head' will be true when this is a header line, nil when this
624 is a body line. And the variable `nline' will contain the line number,
625 starting from 1 in the first header line. For example
627 (setq org-export-table-row-tags
630 (if (= (mod nline 2) 1)
631 \"<tr class=\\\"tr-odd\\\">\"
632 \"<tr class=\\\"tr-even\\\">\"))
635 will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
636 :group
'org-export-tables
638 (choice :tag
"Opening tag"
639 (string :tag
"Specify")
641 (choice :tag
"Closing tag"
642 (string :tag
"Specify")
645 (defcustom org-export-html-table-align-individual-fields t
646 "Non-nil means attach style attributes for alignment to each table field.
647 When nil, alignment will only be specified in the column tags, but this
648 is ignored by some browsers (like Firefox, Safari). Opera does it right
650 :group
'org-export-tables
654 (defcustom org-export-html-table-use-header-tags-for-first-column nil
655 "Non-nil means format column one in tables with header tags.
656 When nil, also column one will use data tags."
657 :group
'org-export-tables
660 (defcustom org-export-html-validation-link
661 "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
662 "Link to HTML validation service."
663 :group
'org-export-html
666 ;; FIXME Obsolete since Org 7.7
667 ;; Use the :timestamp option or `org-export-time-stamp-file' instead
668 (defvar org-export-html-with-timestamp nil
669 "If non-nil, write container for HTML-helper-mode timestamp.")
671 ;; FIXME Obsolete since Org 7.7
672 (defvar org-export-html-html-helper-timestamp
673 "\n<p><br/><br/>\n<!-- hhmts start --> <!-- hhmts end --></p>\n"
674 "The HTML tag used as timestamp delimiter for HTML-helper-mode.")
676 (defcustom org-export-html-protect-char-alist
680 "Alist of characters to be converted by `org-html-protect'."
681 :group
'org-export-html
683 :type
'(repeat (cons (string :tag
"Character")
684 (string :tag
"HTML equivalent"))))
686 (defgroup org-export-htmlize nil
687 "Options for processing examples with htmlize.el."
688 :tag
"Org Export Htmlize"
689 :group
'org-export-html
)
691 (defcustom org-export-htmlize-output-type
'inline-css
692 "Output type to be used by htmlize when formatting code snippets.
693 Choices are `css', to export the CSS selectors only, or `inline-css', to
694 export the CSS attribute values inline in the HTML. We use as default
695 `inline-css', in order to make the resulting HTML self-containing.
697 However, this will fail when using Emacs in batch mode for export, because
698 then no rich font definitions are in place. It will also not be good if
699 people with different Emacs setup contribute HTML files to a website,
700 because the fonts will represent the individual setups. In these cases,
701 it is much better to let Org/Htmlize assign classes only, and to use
702 a style file to define the look of these classes.
703 To get a start for your css file, start Emacs session and make sure that
704 all the faces you are interested in are defined, for example by loading files
705 in all modes you want. Then, use the command
706 \\[org-export-htmlize-generate-css] to extract class definitions."
707 :group
'org-export-htmlize
708 :type
'(choice (const css
) (const inline-css
)))
710 (defcustom org-export-htmlize-css-font-prefix
"org-"
711 "The prefix for CSS class names for htmlize font specifications."
712 :group
'org-export-htmlize
715 (defcustom org-export-htmlized-org-css-url nil
716 "URL pointing to a CSS file defining text colors for htmlized Emacs buffers.
717 Normally when creating an htmlized version of an Org buffer, htmlize will
718 create CSS to define the font colors. However, this does not work when
719 converting in batch mode, and it also can look bad if different people
720 with different fontification setup work on the same website.
721 When this variable is non-nil, creating an htmlized version of an Org buffer
722 using `org-export-as-org' will remove the internal CSS section and replace it
723 with a link to this URL."
724 :group
'org-export-htmlize
726 (const :tag
"Keep internal css" nil
)
727 (string :tag
"URL or local href")))
729 ;; FIXME: The following variable is obsolete since Org 7.7 but is
730 ;; still declared and checked within code for compatibility reasons.
731 ;; Use the custom variables `org-export-html-divs' instead.
732 (defvar org-export-html-content-div
"content"
733 "The name of the container DIV that holds all the page contents.
735 This variable is obsolete since Org version 7.7.
736 Please set `org-export-html-divs' instead.")
738 (defcustom org-export-html-divs
'("preamble" "content" "postamble")
739 "The name of the main divs for HTML export.
740 This is a list of three strings, the first one for the preamble
741 DIV, the second one for the content DIV and the third one for the
743 :group
'org-export-html
746 (string :tag
" Div for the preamble:")
747 (string :tag
" Div for the content:")
748 (string :tag
"Div for the postamble:")))
750 (defcustom org-export-html-date-format-string
"%Y-%m-%dT%R%z"
751 "Format string to format the date and time.
753 The default is an extended format of the ISO 8601 specification."
754 :group
'org-export-html
760 (defvar org-export-html-after-blockquotes-hook nil
761 "Hook run during HTML export, after blockquote, verse, center are done.")
763 (defvar org-export-html-final-hook nil
764 "Hook run at the end of HTML export, in the new buffer.")
768 (defun org-export-html-preprocess (parameters)
769 "Convert LaTeX fragments to images."
770 (when (and org-current-export-file
771 (plist-get parameters
:LaTeX-fragments
))
773 (concat org-latex-preview-ltxpng-directory
(file-name-sans-extension
774 (file-name-nondirectory
775 org-current-export-file
)))
776 org-current-export-dir nil
"Creating LaTeX image %s"
779 ((eq (plist-get parameters
:LaTeX-fragments
) 'verbatim
) 'verbatim
)
780 ((eq (plist-get parameters
:LaTeX-fragments
) 'mathjax
) 'mathjax
)
781 ((eq (plist-get parameters
:LaTeX-fragments
) t
) 'mathjax
)
782 ((eq (plist-get parameters
:LaTeX-fragments
) 'imagemagick
) 'imagemagick
)
783 ((eq (plist-get parameters
:LaTeX-fragments
) 'dvipng
) 'dvipng
))))
784 (goto-char (point-min))
786 (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t
)
787 (org-if-unprotected-at (match-beginning 1)
788 (setq label
(match-string 1))
790 (if (string-match "\\`[a-z]\\{1,10\\}:\\(.+\\)" label
)
791 (setq l1
(substring label
(match-beginning 1)))
793 (replace-match (format "[[#%s][%s]]" label l1
) t t
)))))
796 (defun org-export-as-html-and-open (arg)
797 "Export the outline as HTML and immediately open it with a browser.
798 If there is an active region, export only the region.
799 The prefix ARG specifies how many levels of the outline should become
800 headlines. The default is 3. Lower levels will become bulleted lists."
802 (org-export-as-html arg
)
803 (org-open-file buffer-file-name
)
804 (when org-export-kill-product-buffer-when-displayed
805 (kill-buffer (current-buffer))))
808 (defun org-export-as-html-batch ()
809 "Call the function `org-export-as-html'.
810 This function can be used in batch processing as:
812 --load=$HOME/lib/emacs/org.el
813 --eval \"(setq org-export-headline-levels 2)\"
814 --visit=MyFile --funcall org-export-as-html-batch"
815 (org-export-as-html org-export-headline-levels
))
818 (defun org-export-as-html-to-buffer (arg)
819 "Call `org-export-as-html` with output to a temporary buffer.
820 No file is created. The prefix ARG is passed through to `org-export-as-html'."
822 (org-export-as-html arg nil
"*Org HTML Export*")
823 (when org-export-show-temporary-export-buffer
824 (switch-to-buffer-other-window "*Org HTML Export*")))
827 (defun org-replace-region-by-html (beg end
)
828 "Assume the current region has org-mode syntax, and convert it to HTML.
829 This can be used in any buffer. For example, you could write an
830 itemized list in org-mode syntax in an HTML buffer and then use this
831 command to convert it."
833 (let (reg html buf pop-up-frames
)
834 (save-window-excursion
835 (if (derived-mode-p 'org-mode
)
836 (setq html
(org-export-region-as-html
838 (setq reg
(buffer-substring beg end
)
839 buf
(get-buffer-create "*Org tmp*"))
840 (with-current-buffer buf
844 (setq html
(org-export-region-as-html
845 (point-min) (point-max) t
'string
)))
847 (delete-region beg end
)
851 (defun org-export-region-as-html (beg end
&optional body-only buffer
)
852 "Convert region from BEG to END in org-mode buffer to HTML.
853 If prefix arg BODY-ONLY is set, omit file header, footer, and table of
854 contents, and only produce the region of converted text, useful for
855 cut-and-paste operations.
856 If BUFFER is a buffer or a string, use/create that buffer as a target
857 of the converted HTML. If BUFFER is the symbol `string', return the
858 produced HTML as a string and leave not buffer behind. For example,
859 a Lisp program could call this function in the following way:
861 (setq html (org-export-region-as-html beg end t 'string))
863 When called interactively, the output buffer is selected, and shown
864 in a window. A non-interactive call will only return the buffer."
866 (when (org-called-interactively-p 'any
)
867 (setq buffer
"*Org HTML Export*"))
868 (let ((transient-mark-mode t
) (zmacs-regions t
)
870 (setq ext-plist
(plist-put ext-plist
:ignore-subtree-p t
))
872 (set-mark (point)) ;; to activate the region
874 (setq rtn
(org-export-as-html nil ext-plist buffer body-only
))
875 (if (fboundp 'deactivate-mark
) (deactivate-mark))
876 (if (and (org-called-interactively-p 'any
) (bufferp rtn
))
877 (switch-to-buffer-other-window rtn
)
880 (defvar html-table-tag nil
) ; dynamically scoped into this.
881 (defvar org-par-open nil
)
883 ;;; org-html-cvt-link-fn
884 (defconst org-html-cvt-link-fn
886 "Function to convert link URLs to exportable URLs.
887 Takes two arguments, TYPE and PATH.
888 Returns exportable url as (TYPE PATH), or nil to signal that it
889 didn't handle this case.
890 Intended to be locally bound around a call to `org-export-as-html'." )
892 (defun org-html-cvt-org-as-html (opt-plist type path
)
893 "Convert an org filename to an equivalent html filename.
894 If TYPE is not file, just return `nil'.
895 See variable `org-export-html-link-org-files-as-html'"
899 org-export-html-link-org-files-as-html
900 (string= type
"file")
901 (string-match "\\.org$" path
)
906 (substring path
0 (match-beginning 0))
908 (plist-get opt-plist
:html-extension
)))))))
911 ;;; org-html-should-inline-p
912 (defun org-html-should-inline-p (filename descp
)
913 "Return non-nil if link FILENAME should be inlined.
914 The decision to inline the FILENAME link is based on the current
915 settings. DESCP is the boolean of whether there was a link
916 description. See variables `org-export-html-inline-images' and
917 `org-export-html-inline-image-extensions'."
919 org-export-html-inline-images
920 org-export-html-inline-image-extensions
))
921 (and (or (eq t org-export-html-inline-images
)
922 (and org-export-html-inline-images
(not descp
)))
924 filename org-export-html-inline-image-extensions
)))
926 ;;; org-html-make-link
927 (defun org-html-make-link (opt-plist type path fragment desc attr
930 OPT-PLIST is an options list.
931 TYPE is the device-type of the link (THIS://foo.html).
932 PATH is the path of the link (http://THIS#location).
933 FRAGMENT is the fragment part of the link, if any (foo.html#THIS).
934 DESC is the link description, if any.
935 ATTR is a string of other attributes of the \"a\" element.
936 MAY-INLINE-P allows inlining it as an image."
938 (declare (special org-par-open
))
940 (let* ((filename path
)
941 ;;First pass. Just sanity stuff.
944 ((string= type
"file")
947 ;;Substitute just if original path was absolute.
948 ;;(Otherwise path must remain relative)
949 (if (file-name-absolute-p path
)
950 (concat "file://" (expand-file-name path
))
954 (t (list type path
))))
956 ;;Second pass. Components converted so they can refer
960 (and org-html-cvt-link-fn
961 (apply org-html-cvt-link-fn
962 opt-plist components-1
))
963 (apply #'org-html-cvt-org-as-html
964 opt-plist components-1
)
966 (type (first components-2
))
967 (thefile (second components-2
)))
970 ;;Third pass. Build final link except for leading type
975 (string= type
"http")
976 (string= type
"https")
977 (string= type
"file")
978 (string= type
"coderef"))
980 (setq thefile
(concat thefile
"#" fragment
))))
984 ;;Final URL-build, for all types.
987 ((str (org-export-html-format-href thefile
)))
988 (if (and type
(not (or (string= "file" type
)
989 (string= "coderef" type
))))
990 (concat type
":" str
)
995 ;;Can't inline a URL with a fragment.
998 (message "image %s %s" thefile org-par-open
)
999 (org-export-html-format-image thefile org-par-open
))
1001 "<a href=\"" thefile
"\"" (if attr
(concat " " attr
)) ">"
1002 (org-export-html-format-desc desc
)
1005 (defun org-html-handle-links (org-line opt-plist
)
1006 "Return ORG-LINE with markup of Org mode links.
1007 OPT-PLIST is the export options list."
1009 (current-dir (if buffer-file-name
1010 (file-name-directory buffer-file-name
)
1012 (link-validate (plist-get opt-plist
:link-validation-function
))
1014 rpl path attr desc descp desc1 desc2 link
)
1015 (while (string-match org-bracket-link-analytic-regexp
++ org-line start
)
1016 (setq start
(match-beginning 0))
1017 (setq path
(save-match-data (org-link-unescape
1018 (match-string 3 org-line
))))
1020 ((match-end 2) (match-string 2 org-line
))
1022 (or (file-name-absolute-p path
)
1023 (string-match "^\\.\\.?/" path
)))
1026 (setq path
(org-extract-attributes path
))
1027 (setq attr
(get-text-property 0 'org-attributes path
))
1028 (setq desc1
(if (match-end 5) (match-string 5 org-line
))
1029 desc2
(if (match-end 2) (concat type
":" path
) path
)
1030 descp
(and desc1
(not (equal desc1 desc2
)))
1031 desc
(or desc1 desc2
))
1032 ;; Make an image out of the description if that is so wanted
1033 (when (and descp
(org-file-image-p
1034 desc org-export-html-inline-image-extensions
))
1036 (if (string-match "^file:" desc
)
1037 (setq desc
(substring desc
(match-end 0)))))
1038 (setq desc
(org-add-props
1039 (concat "<img src=\"" desc
"\" "
1040 (when (save-match-data (string-match "width=" attr
))
1041 (prog1 (concat attr
" ") (setq attr
"")))
1043 (file-name-nondirectory desc
) "\"/>")
1044 '(org-protected t
))))
1046 ((equal type
"internal")
1049 (if (= (string-to-char path
) ?
#)
1057 (org-solidify-link-text
1058 (save-match-data (org-link-unescape frag-0
))
1061 ((and (equal type
"id")
1062 (setq id-file
(org-id-find-id-file path
)))
1063 ;; This is an id: link to another file (if it was the same file,
1064 ;; it would have become an internal link...)
1066 (setq id-file
(file-relative-name
1068 (file-name-directory org-current-export-file
)))
1070 (org-html-make-link opt-plist
1072 (concat (if (org-uuidgen-p path
) "ID-") path
)
1076 ((member type
'("http" "https"))
1077 ;; standard URL, can inline as image
1079 (org-html-make-link opt-plist
1083 (org-html-should-inline-p path descp
))))
1084 ((member type
'("ftp" "mailto" "news"))
1085 ;; standard URL, can't inline as image
1087 (org-html-make-link opt-plist
1093 ((string= type
"coderef")
1095 ((coderef-str (format "coderef-%s" path
))
1097 (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
1098 coderef-str coderef-str
)))
1100 (org-html-make-link opt-plist
1103 (org-export-get-coderef-format
1106 (cdr (assoc path org-export-code-refs
)))
1110 ((functionp (setq fnc
(nth 2 (assoc type org-link-protocols
))))
1111 ;; The link protocol has a function for format the link
1114 (funcall fnc
(org-link-unescape path
) desc1
'html
))))
1116 ((string= type
"file")
1122 (string-match "::\\(.*\\)" path
)
1124 (replace-match "" t nil path
)
1125 (match-string 1 path
))
1128 ;;The proper path, without a fragment
1134 (second components
))
1136 ;;Check the fragment. If it can't be used as
1137 ;;target fragment we'll pass nil instead.
1141 (not (string-match "^[0-9]*$" fragment-0
))
1142 (not (string-match "^\\*" fragment-0
))
1143 (not (string-match "^/.*/$" fragment-0
)))
1144 (org-solidify-link-text
1145 (org-link-unescape fragment-0
))
1148 ;;Description minus "file:" and ".org"
1149 (if (string-match "^file:" desc
)
1151 ((desc-1 (replace-match "" t t desc
)))
1152 (if (string-match "\\.org$" desc-1
)
1153 (replace-match "" t t desc-1
)
1160 (functionp link-validate
)
1161 (not (funcall link-validate path-1 current-dir
)))
1163 (org-html-make-link opt-plist
1164 "file" path-1 fragment-1 desc-2 attr
1165 (org-html-should-inline-p path-1 descp
)))))))
1168 ;; just publish the path, as default
1169 (setq rpl
(concat "<i><" type
":"
1170 (save-match-data (org-link-unescape path
))
1172 (setq org-line
(replace-match rpl t t org-line
)
1173 start
(+ start
(length rpl
))))
1176 ;;; org-export-as-html
1178 (defvar org-heading-keyword-regexp-format
) ; defined in org.el
1181 (defun org-export-as-html (arg &optional ext-plist to-buffer body-only pub-dir
)
1182 "Export the outline as a pretty HTML file.
1183 If there is an active region, export only the region. The prefix
1184 ARG specifies how many levels of the outline should become
1185 headlines. The default is 3. Lower levels will become bulleted
1186 lists. EXT-PLIST is a property list with external parameters overriding
1187 org-mode's default settings, but still inferior to file-local
1188 settings. When TO-BUFFER is non-nil, create a buffer with that
1189 name and export to that buffer. If TO-BUFFER is the symbol
1190 `string', don't leave any buffer behind but just return the
1191 resulting HTML as a string. When BODY-ONLY is set, don't produce
1192 the file header and footer, simply return the content of
1193 <body>...</body>, without even the body tags themselves. When
1194 PUB-DIR is set, use this as the publishing directory."
1196 (run-hooks 'org-export-first-hook
)
1198 ;; Make sure we have a file name when we need it.
1199 (when (and (not (or to-buffer body-only
))
1200 (not buffer-file-name
))
1201 (if (buffer-base-buffer)
1202 (org-set-local 'buffer-file-name
1203 (with-current-buffer (buffer-base-buffer)
1205 (error "Need a file name to be able to export")))
1207 (message "Exporting...")
1208 (setq-default org-todo-line-regexp org-todo-line-regexp
)
1209 (setq-default org-deadline-line-regexp org-deadline-line-regexp
)
1210 (setq-default org-done-keywords org-done-keywords
)
1211 (setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp
)
1213 (org-export-process-option-filters
1214 (org-combine-plists (org-default-export-plist)
1216 (org-infile-export-plist))))
1217 (body-only (or body-only
(plist-get opt-plist
:body-only
)))
1218 (style (concat (if (plist-get opt-plist
:style-include-default
)
1219 org-export-html-style-default
)
1220 (plist-get opt-plist
:style
)
1221 (plist-get opt-plist
:style-extra
)
1223 (if (plist-get opt-plist
:style-include-scripts
)
1224 org-export-html-scripts
)))
1225 (html-extension (plist-get opt-plist
:html-extension
))
1226 valid thetoc have-headings first-heading-pos
1227 (odd org-odd-levels-only
)
1228 (region-p (org-region-active-p))
1229 (rbeg (and region-p
(region-beginning)))
1230 (rend (and region-p
(region-end)))
1232 (if (plist-get opt-plist
:ignore-subtree-p
)
1237 (and (org-at-heading-p)
1238 (>= (org-end-of-subtree t t
) rend
))))))
1239 (level-offset (if subtree-p
1242 (+ (funcall outline-level
)
1243 (if org-odd-levels-only
1 0)))
1245 (opt-plist (setq org-export-opt-plist
1247 (org-export-add-subtree-options opt-plist rbeg
)
1249 ;; The following two are dynamically scoped into other
1251 (org-current-export-dir
1252 (or pub-dir
(org-export-directory :html opt-plist
)))
1253 (org-current-export-file buffer-file-name
)
1254 (level 0) (org-line "") (origline "") txt todo
1257 (filename (if to-buffer nil
1260 (file-name-sans-extension
1262 (org-entry-get (region-beginning)
1263 "EXPORT_FILE_NAME" t
))
1264 (file-name-nondirectory buffer-file-name
)))
1266 (file-name-as-directory
1267 (or pub-dir
(org-export-directory :html opt-plist
))))))
1268 (current-dir (if buffer-file-name
1269 (file-name-directory buffer-file-name
)
1271 (auto-insert nil
); Avoid any auto-insert stuff for the new file
1272 (buffer (if to-buffer
1274 ((eq to-buffer
'string
) (get-buffer-create "*Org HTML Export*"))
1275 (t (get-buffer-create to-buffer
)))
1276 (find-file-noselect filename
)))
1277 (org-levels-open (make-vector org-level-max nil
))
1278 (date (org-html-expand (plist-get opt-plist
:date
)))
1279 (author (org-html-expand (plist-get opt-plist
:author
)))
1280 (html-validation-link (or org-export-html-validation-link
""))
1281 (title (org-html-expand
1282 (or (and subtree-p
(org-export-get-title-from-subtree))
1283 (plist-get opt-plist
:title
)
1284 (and (not body-only
)
1286 (plist-get opt-plist
:skip-before-1st-heading
))
1287 (org-export-grab-title-from-buffer))
1288 (and buffer-file-name
1289 (file-name-sans-extension
1290 (file-name-nondirectory buffer-file-name
)))
1292 (link-up (and (plist-get opt-plist
:link-up
)
1293 (string-match "\\S-" (plist-get opt-plist
:link-up
))
1294 (plist-get opt-plist
:link-up
)))
1295 (link-home (and (plist-get opt-plist
:link-home
)
1296 (string-match "\\S-" (plist-get opt-plist
:link-home
))
1297 (plist-get opt-plist
:link-home
)))
1298 (dummy (setq opt-plist
(plist-put opt-plist
:title title
)))
1299 (html-table-tag (plist-get opt-plist
:html-table-tag
))
1300 (quote-re0 (concat "^ *" org-quote-string
"\\( +\\|[ \t]*$\\)"))
1301 (quote-re (format org-heading-keyword-regexp-format
1306 (email (plist-get opt-plist
:email
))
1307 (language (plist-get opt-plist
:language
))
1308 (keywords (org-html-expand (plist-get opt-plist
:keywords
)))
1309 (description (org-html-expand (plist-get opt-plist
:description
)))
1310 (num (plist-get opt-plist
:section-numbers
))
1314 (coding-system (and (boundp 'buffer-file-coding-system
)
1315 buffer-file-coding-system
))
1316 (coding-system-for-write (or org-export-html-coding-system
1318 (save-buffer-coding-system (or org-export-html-coding-system
1320 (charset (and coding-system-for-write
1321 (fboundp 'coding-system-get
)
1322 (coding-system-get coding-system-for-write
1326 (if region-p
(region-beginning) (point-min))
1327 (if region-p
(region-end) (point-max))))
1328 (org-export-have-math nil
)
1329 (org-export-footnotes-seen nil
)
1330 (org-export-footnotes-data (org-footnote-all-labels 'with-defs
))
1331 (custom-id (or (org-entry-get nil
"CUSTOM_ID" t
) ""))
1332 (footnote-def-prefix (format "fn-%s" custom-id
))
1333 (footnote-ref-prefix (format "fnr-%s" custom-id
))
1336 (org-export-preprocess-string
1340 :skip-before-1st-heading
1341 (plist-get opt-plist
:skip-before-1st-heading
)
1342 :drawers
(plist-get opt-plist
:drawers
)
1343 :todo-keywords
(plist-get opt-plist
:todo-keywords
)
1344 :tasks
(plist-get opt-plist
:tasks
)
1345 :tags
(plist-get opt-plist
:tags
)
1346 :priority
(plist-get opt-plist
:priority
)
1347 :footnotes
(plist-get opt-plist
:footnotes
)
1348 :timestamps
(plist-get opt-plist
:timestamps
)
1350 (plist-get opt-plist
:archived-trees
)
1351 :select-tags
(plist-get opt-plist
:select-tags
)
1352 :exclude-tags
(plist-get opt-plist
:exclude-tags
)
1354 (plist-get opt-plist
:text
)
1356 (plist-get opt-plist
:LaTeX-fragments
))
1359 (if (or (eq (plist-get opt-plist
:LaTeX-fragments
) 'mathjax
)
1360 (and org-export-have-math
1361 (eq (plist-get opt-plist
:LaTeX-fragments
) t
)))
1363 (org-export-html-mathjax-config
1364 org-export-html-mathjax-template
1365 org-export-html-mathjax-options
1366 (or (plist-get opt-plist
:mathjax
) ""))
1369 table-buffer table-orig-buffer
1371 rpl path attr desc descp desc1 desc2 link
1373 footnotes footref-seen
1376 (let ((inhibit-read-only t
))
1378 (remove-text-properties (point-min) (point-max)
1379 '(:org-license-to-kill t
))))
1381 (message "Exporting...")
1383 (setq org-min-level
(org-get-min-level lines level-offset
))
1384 (setq org-last-level org-min-level
)
1385 (org-init-section-numbers)
1388 ((and date
(string-match "%" date
))
1389 (setq date
(format-time-string date
)))
1391 (t (setq date
(format-time-string org-export-html-date-format-string
))))
1393 ;; Get the language-dependent settings
1394 (setq lang-words
(or (assoc language org-export-language-setup
)
1395 (assoc "en" org-export-language-setup
)))
1397 ;; Switch to the output buffer
1399 (let ((inhibit-read-only t
)) (erase-buffer))
1401 (org-install-letbind)
1403 (and (fboundp 'set-buffer-file-coding-system
)
1404 (set-buffer-file-coding-system coding-system-for-write
))
1406 (let ((case-fold-search nil
)
1407 (org-odd-levels-only odd
))
1408 ;; create local variables for all options, to make sure all called
1409 ;; functions get the correct information
1411 (set (make-local-variable (nth 2 x
))
1412 (plist-get opt-plist
(car x
))))
1413 org-export-plist-vars
)
1414 (setq umax
(if arg
(prefix-numeric-value arg
)
1415 org-export-headline-levels
))
1416 (setq umax-toc
(if (integerp org-export-with-toc
)
1417 (min org-export-with-toc umax
)
1423 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
1424 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
1425 <html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">
1428 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
1429 <meta name=\"title\" content=\"%s\"/>
1430 <meta name=\"generator\" content=\"Org-mode\"/>
1431 <meta name=\"generated\" content=\"%s\"/>
1432 <meta name=\"author\" content=\"%s\"/>
1433 <meta name=\"description\" content=\"%s\"/>
1434 <meta name=\"keywords\" content=\"%s\"/>
1442 (or (and (stringp org-export-html-xml-declaration
)
1443 org-export-html-xml-declaration
)
1444 (cdr (assoc html-extension org-export-html-xml-declaration
))
1445 (cdr (assoc "html" org-export-html-xml-declaration
))
1448 (or charset
"iso-8859-1"))
1451 (or charset
"iso-8859-1")
1452 title date author description keywords
1455 (if (or link-up link-home
)
1457 (format org-export-html-home
/up-format
1458 (or link-up link-home
)
1459 (or link-home link-up
))
1463 ;; insert html preamble
1464 (when (plist-get opt-plist
:html-preamble
)
1465 (let ((html-pre (plist-get opt-plist
:html-preamble
))
1466 (html-pre-real-contents ""))
1467 (cond ((stringp html-pre
)
1468 (setq html-pre-real-contents
1469 (format-spec html-pre
`((?t .
,title
) (?a .
,author
)
1470 (?d .
,date
) (?e .
,email
)))))
1471 ((functionp html-pre
)
1472 (insert "<div id=\"" (nth 0 org-export-html-divs
) "\">\n")
1473 (if (stringp (funcall html-pre
)) (insert (funcall html-pre
)))
1474 (insert "\n</div>\n"))
1476 (setq html-pre-real-contents
1478 (or (cadr (assoc (nth 0 lang-words
)
1479 org-export-html-preamble-format
))
1480 (cadr (assoc "en" org-export-html-preamble-format
)))
1481 `((?t .
,title
) (?a .
,author
)
1482 (?d .
,date
) (?e .
,email
))))))
1483 ;; don't output an empty preamble DIV
1484 (unless (and (functionp html-pre
)
1485 (equal html-pre-real-contents
""))
1486 (insert "<div id=\"" (nth 0 org-export-html-divs
) "\">\n")
1487 (insert html-pre-real-contents
)
1488 (insert "\n</div>\n"))))
1490 ;; begin wrap around body
1491 (insert (format "\n<div id=\"%s\">"
1492 ;; FIXME org-export-html-content-div is obsolete since 7.7
1493 (or org-export-html-content-div
1494 (nth 1 org-export-html-divs
)))
1495 ;; FIXME this should go in the preamble but is here so
1496 ;; that org-infojs can still find it
1497 "\n<h1 class=\"title\">" title
"</h1>\n"))
1500 (if org-export-with-toc
1502 (push (format "<h%d>%s</h%d>\n"
1503 org-export-html-toplevel-hlevel
1505 org-export-html-toplevel-hlevel
)
1507 (push "<div id=\"text-table-of-contents\">\n" thetoc
)
1508 (push "<ul>\n<li>" thetoc
)
1511 #'(lambda (org-line)
1512 (if (and (string-match org-todo-line-regexp org-line
)
1513 (not (get-text-property 0 'org-protected org-line
)))
1514 ;; This is a headline
1516 (setq have-headings t
)
1517 (setq level
(- (match-end 1) (match-beginning 1)
1519 level
(org-tr-level level
)
1520 txt
(save-match-data
1522 (org-export-cleanup-toc-line
1523 (match-string 3 org-line
))))
1525 (or (and org-export-mark-todo-in-toc
1527 (not (member (match-string 2 org-line
)
1528 org-done-keywords
)))
1530 (and org-export-mark-todo-in-toc
1532 (org-search-todo-below
1533 org-line lines level
))))
1535 (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt
)
1536 (setq txt
(replace-match
1537 " <span class=\"tag\">\\1</span>" t nil txt
)))
1538 (if (string-match quote-re0 txt
)
1539 (setq txt
(replace-match "" t t txt
)))
1540 (setq snumber
(org-section-number level
))
1541 (if (and num
(if (integerp num
)
1544 (setq txt
(concat snumber
" " txt
)))
1545 (if (<= level
(max umax umax-toc
))
1546 (setq head-count
(+ head-count
1)))
1547 (if (<= level umax-toc
)
1549 (if (> level org-last-level
)
1551 (setq cnt
(- level org-last-level
))
1552 (while (>= (setq cnt
(1- cnt
)) 0)
1553 (push "\n<ul>\n<li>" thetoc
))
1554 (push "\n" thetoc
)))
1555 (if (< level org-last-level
)
1557 (setq cnt
(- org-last-level level
))
1558 (while (>= (setq cnt
(1- cnt
)) 0)
1559 (push "</li>\n</ul>" thetoc
))
1560 (push "\n" thetoc
)))
1561 ;; Check for targets
1562 (while (string-match org-any-target-regexp org-line
)
1563 (setq org-line
(replace-match
1564 (concat "@<span class=\"target\">"
1565 (match-string 1 org-line
) "@</span> ")
1567 (while (string-match "<\\(<\\)+\\|>\\(>\\)+" txt
)
1568 (setq txt
(replace-match "" t t txt
)))
1570 (replace-regexp-in-string
1571 "\\." "-" (format "sec-%s" snumber
)))
1572 (setq href
(org-solidify-link-text
1573 (or (cdr (assoc href
1574 org-export-preferred-target-alist
)) href
)))
1578 "</li>\n<li><a href=\"#%s\"><span class=\"todo\">%s</span></a>"
1579 "</li>\n<li><a href=\"#%s\">%s</a>")
1582 (setq org-last-level level
)))))
1585 (while (> org-last-level
(1- org-min-level
))
1586 (setq org-last-level
(1- org-last-level
))
1587 (push "</li>\n</ul>\n" thetoc
))
1588 (push "</div>\n" thetoc
)
1589 (setq thetoc
(if have-headings
(nreverse thetoc
) nil
))))
1592 (org-init-section-numbers)
1596 (while (setq org-line
(pop lines
) origline org-line
)
1599 ;; end of quote section?
1600 (when (and inquote
(string-match org-outline-regexp-bol org-line
))
1604 ;; inside a quote section?
1606 (insert (org-html-protect org-line
) "\n")
1607 (throw 'nextline nil
))
1609 ;; Fixed-width, verbatim lines (examples)
1610 (when (and org-export-with-fixed-width
1611 (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" org-line
))
1614 (org-close-par-maybe)
1616 (insert "<pre class=\"example\">\n"))
1617 (insert (org-html-protect (match-string 3 org-line
)) "\n")
1618 (when (or (not lines
)
1619 (not (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)"
1624 (throw 'nextline nil
))
1627 (when (and (get-text-property 0 'org-protected org-line
)
1628 ;; Make sure it is the entire line that is protected
1629 (not (< (or (next-single-property-change
1630 0 'org-protected org-line
) 10000)
1631 (length org-line
))))
1632 (let (par (ind (get-text-property 0 'original-indentation org-line
)))
1633 (when (re-search-backward
1634 "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t
)
1635 (setq par
(match-string 1))
1636 (replace-match "\\2\n"))
1637 (insert org-line
"\n")
1639 (or (= (length (car lines
)) 0)
1641 (equal ind
(get-text-property 0 'original-indentation
(car lines
))))
1642 (or (= (length (car lines
)) 0)
1643 (get-text-property 0 'org-protected
(car lines
))))
1644 (insert (pop lines
) "\n"))
1645 (and par
(insert "<p>\n")))
1646 (throw 'nextline nil
))
1648 ;; Blockquotes, verse, and center
1649 (when (equal "ORG-BLOCKQUOTE-START" org-line
)
1650 (org-close-par-maybe)
1651 (insert "<blockquote>\n")
1653 (throw 'nextline nil
))
1654 (when (equal "ORG-BLOCKQUOTE-END" org-line
)
1655 (org-close-par-maybe)
1656 (insert "\n</blockquote>\n")
1658 (throw 'nextline nil
))
1659 (when (equal "ORG-VERSE-START" org-line
)
1660 (org-close-par-maybe)
1661 (insert "\n<p class=\"verse\">\n")
1662 (setq org-par-open t
)
1664 (throw 'nextline nil
))
1665 (when (equal "ORG-VERSE-END" org-line
)
1667 (setq org-par-open nil
)
1670 (throw 'nextline nil
))
1671 (when (equal "ORG-CENTER-START" org-line
)
1672 (org-close-par-maybe)
1673 (insert "\n<div style=\"text-align: center\">")
1675 (throw 'nextline nil
))
1676 (when (equal "ORG-CENTER-END" org-line
)
1677 (org-close-par-maybe)
1680 (throw 'nextline nil
))
1681 (run-hooks 'org-export-html-after-blockquotes-hook
)
1683 (let ((i (org-get-string-indentation org-line
)))
1685 (setq org-line
(concat (mapconcat 'identity
1686 (make-list (* 2 i
) "\\nbsp") "")
1687 " " (org-trim org-line
))))
1688 (unless (string-match "\\\\\\\\[ \t]*$" org-line
)
1689 (setq org-line
(concat org-line
"\\\\")))))
1691 ;; make targets to anchors
1693 (while (string-match
1694 "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" org-line start
)
1696 ((get-text-property (match-beginning 1) 'org-protected org-line
)
1697 (setq start
(match-end 1)))
1699 (setq org-line
(replace-match
1701 "@<a name=\"%s\" id=\"%s\">@</a>"
1702 (org-solidify-link-text (match-string 1 org-line
))
1703 (org-solidify-link-text (match-string 1 org-line
)))
1705 ((and org-export-with-toc
(equal (string-to-char org-line
) ?
*))
1706 ;; FIXME: NOT DEPENDENT on TOC?????????????????????
1707 (setq org-line
(replace-match
1708 (concat "@<span class=\"target\">"
1709 (match-string 1 org-line
) "@</span> ")
1710 ;; (concat "@<i>" (match-string 1 org-line) "@</i> ")
1713 (setq org-line
(replace-match
1714 (concat "@<a name=\""
1715 (org-solidify-link-text (match-string 1 org-line
))
1716 "\" class=\"target\">" (match-string 1 org-line
)
1720 (setq org-line
(org-html-handle-time-stamps org-line
))
1722 ;; replace "&" by "&", "<" and ">" by "<" and ">"
1723 ;; handle @<..> HTML tags (replace "@>..<" by "<..>")
1724 ;; Also handle sub_superscripts and checkboxes
1725 (or (string-match org-table-hline-regexp org-line
)
1726 (string-match "^[ \t]*\\([+]-\\||[ ]\\)[-+ |]*[+|][ \t]*$" org-line
)
1727 (setq org-line
(org-html-expand org-line
)))
1730 (setq org-line
(org-html-handle-links org-line opt-plist
))
1733 (if (and org-todo-line-regexp
1734 (string-match org-todo-line-regexp org-line
)
1735 (match-beginning 2))
1738 (concat (substring org-line
0 (match-beginning 2))
1740 (if (member (match-string 2 org-line
)
1743 " " (org-export-html-get-todo-kwd-class-name
1744 (match-string 2 org-line
))
1745 "\">" (match-string 2 org-line
)
1746 "</span>" (substring org-line
(match-end 2)))))
1748 ;; Does this contain a reference to a footnote?
1749 (when org-export-with-footnotes
1751 (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" org-line start
)
1752 ;; Discard protected matches not clearly identified as
1753 ;; footnote markers.
1754 (if (or (get-text-property (match-beginning 2) 'org-protected org-line
)
1755 (not (get-text-property (match-beginning 2) 'org-footnote org-line
)))
1756 (setq start
(match-end 2))
1757 (let ((n (match-string 2 org-line
)) extra a
)
1758 (if (setq a
(assoc n footref-seen
))
1760 (setcdr a
(1+ (cdr a
)))
1761 (setq extra
(format ".%d" (cdr a
))))
1763 (push (cons n
1) footref-seen
))
1769 (format org-export-html-footnote-format
1770 (concat "<a class=\"footref\" name=\"" footnote-ref-prefix
".%s%s\" href=\"#" footnote-def-prefix
".%s\">%s</a>")))
1771 (or (match-string 1 org-line
) "") n extra n n
)
1772 ;; If another footnote is following the
1773 ;; current one, add a separator.
1774 (if (save-match-data
1775 (string-match "\\`\\[[0-9]+\\]"
1776 (substring org-line
(match-end 0))))
1777 org-export-html-footnote-separator
1782 ((string-match "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" org-line
)
1783 ;; This is a headline
1784 (setq level
(org-tr-level (- (match-end 1) (match-beginning 1)
1786 txt
(or (match-string 2 org-line
) ""))
1787 (if (string-match quote-re0 txt
)
1788 (setq txt
(replace-match "" t t txt
)))
1789 (if (<= level
(max umax umax-toc
))
1790 (setq head-count
(+ head-count
1)))
1791 (setq first-heading-pos
(or first-heading-pos
(point)))
1792 (org-html-level-start level txt umax
1793 (and org-export-with-toc
(<= level umax
))
1794 head-count opt-plist
)
1797 (when (string-match quote-re org-line
)
1798 (org-close-par-maybe)
1802 ((and org-export-with-tables
1803 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" org-line
))
1804 (when (not table-open
)
1806 (setq table-open t table-buffer nil table-orig-buffer nil
))
1809 (setq table-buffer
(cons org-line table-buffer
)
1810 table-orig-buffer
(cons origline table-orig-buffer
))
1811 (when (or (not lines
)
1812 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
1814 (setq table-open nil
1815 table-buffer
(nreverse table-buffer
)
1816 table-orig-buffer
(nreverse table-orig-buffer
))
1817 (org-close-par-maybe)
1818 (insert (org-format-table-html table-buffer table-orig-buffer
))))
1823 ;; This line either is list item or end a list.
1824 (when (get-text-property 0 'list-item org-line
)
1825 (setq org-line
(org-html-export-list-line
1827 (get-text-property 0 'list-item org-line
)
1828 (get-text-property 0 'list-struct org-line
)
1829 (get-text-property 0 'list-prevs org-line
))))
1832 (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" org-line
)
1834 (insert "\n</p>\n<hr/>\n<p>\n")
1835 (insert "\n<hr/>\n"))
1836 (throw 'nextline nil
))
1838 ;; Empty lines start a new paragraph. If hand-formatted lists
1839 ;; are not fully interpreted, lines starting with "-", "+", "*"
1840 ;; also start a new paragraph.
1841 (if (string-match "^ [-+*]-\\|^[ \t]*$" org-line
) (org-open-par))
1843 ;; Is this the start of a footnote?
1844 (when org-export-with-footnotes
1845 (when (and (boundp 'footnote-section-tag-regexp
)
1846 (string-match (concat "^" footnote-section-tag-regexp
)
1849 (throw 'nextline nil
))
1850 (when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" org-line
)
1851 (org-close-par-maybe)
1852 (let ((n (match-string 1 org-line
)))
1853 (setq org-par-open t
1854 org-line
(replace-match
1856 (concat "<p class=\"footnote\">"
1857 (format org-export-html-footnote-format
1859 "<a class=\"footnum\" name=\"" footnote-def-prefix
".%s\" href=\"#" footnote-ref-prefix
".%s\">%s</a>")))
1860 n n n
) t t org-line
)))))
1861 ;; Check if the line break needs to be conserved
1863 ((string-match "\\\\\\\\[ \t]*$" org-line
)
1864 (setq org-line
(replace-match "<br/>" t t org-line
)))
1865 (org-export-preserve-breaks
1866 (setq org-line
(concat org-line
"<br/>"))))
1868 ;; Check if a paragraph should be started
1870 (while (and org-par-open
1871 (string-match "\\\\par\\>" org-line start
))
1872 ;; Leave a space in the </p> so that the footnote matcher
1873 ;; does not see this.
1874 (if (not (get-text-property (match-beginning 0)
1875 'org-protected org-line
))
1876 (setq org-line
(replace-match "</p ><p >" t t org-line
)))
1877 (setq start
(match-end 0))))
1879 (insert org-line
"\n")))))
1881 ;; Properly close all local lists and other lists
1886 (org-html-level-start 1 nil umax
1887 (and org-export-with-toc
(<= level umax
))
1888 head-count opt-plist
)
1889 ;; the </div> to close the last text-... div.
1890 (when (and (> umax
0) first-heading-pos
) (insert "</div>\n"))
1893 (goto-char (point-min))
1894 (while (re-search-forward
1895 "\\(\\(<p class=\"footnote\">\\)[^\000]*?\\)\\(\\(\\2\\)\\|\\'\\)"
1897 (push (match-string 1) footnotes
)
1898 (replace-match "\\4" t nil
)
1899 (goto-char (match-beginning 0))))
1901 (insert (format org-export-html-footnotes-section
1903 (mapconcat 'identity
(nreverse footnotes
) "\n"))
1905 (let ((bib (org-export-html-get-bibliography)))
1907 (insert "\n" bib
"\n")))
1910 ;; end wrap around body
1913 ;; export html postamble
1914 (let ((html-post (plist-get opt-plist
:html-postamble
))
1916 (mapconcat (lambda(e)
1917 (format "<a href=\"mailto:%s\">%s</a>" e e
))
1918 (split-string email
",+ *")
1921 (concat "<a href=\"http://orgmode.org\">Org</a> version "
1922 (org-version) " with <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> version "
1923 (number-to-string emacs-major-version
))))
1925 (when (plist-get opt-plist
:html-postamble
)
1926 (insert "\n<div id=\"" (nth 2 org-export-html-divs
) "\">\n")
1927 (cond ((stringp html-post
)
1928 (insert (format-spec html-post
1929 `((?a .
,author
) (?e .
,email
)
1930 (?d .
,date
) (?c .
,creator-info
)
1931 (?v .
,html-validation-link
)))))
1932 ((functionp html-post
)
1933 (if (stringp (funcall html-post
)) (insert (funcall html-post
))))
1934 ((eq html-post
'auto
)
1935 ;; fall back on default postamble
1936 (when (plist-get opt-plist
:time-stamp-file
)
1937 (insert "<p class=\"date\">" (nth 2 lang-words
) ": " date
"</p>\n"))
1938 (when (and (plist-get opt-plist
:author-info
) author
)
1939 (insert "<p class=\"author\">" (nth 1 lang-words
) ": " author
"</p>\n"))
1940 (when (and (plist-get opt-plist
:email-info
) email
)
1941 (insert "<p class=\"email\">" email
"</p>\n"))
1942 (when (plist-get opt-plist
:creator-info
)
1943 (insert "<p class=\"creator\">"
1944 (concat "<a href=\"http://orgmode.org\">Org</a> version "
1945 (org-version) " with <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> version "
1946 (number-to-string emacs-major-version
) "</p>\n")))
1947 (insert html-validation-link
"\n"))
1949 (insert (format-spec
1950 (or (cadr (assoc (nth 0 lang-words
)
1951 org-export-html-postamble-format
))
1952 (cadr (assoc "en" org-export-html-postamble-format
)))
1953 `((?a .
,author
) (?e .
,email
)
1954 (?d .
,date
) (?c .
,creator-info
)
1955 (?v .
,html-validation-link
))))))
1956 (insert "\n</div>"))))
1958 ;; FIXME `org-export-html-with-timestamp' has been declared
1959 ;; obsolete since Org 7.7 -- don't forget to remove this.
1960 (if org-export-html-with-timestamp
1961 (insert org-export-html-html-helper-timestamp
))
1963 (unless body-only
(insert "\n</body>\n</html>\n"))
1965 (unless (plist-get opt-plist
:buffer-will-be-killed
)
1967 (if (eq major-mode
(default-value 'major-mode
))
1970 ;; insert the table of contents
1971 (goto-char (point-min))
1973 (if (or (re-search-forward
1974 "<p>\\s-*\\[TABLE-OF-CONTENTS\\]\\s-*</p>" nil t
)
1976 "\\[TABLE-OF-CONTENTS\\]" nil t
))
1978 (goto-char (match-beginning 0))
1980 (goto-char first-heading-pos
)
1981 (when (looking-at "\\s-*</p>")
1982 (goto-char (match-end 0))
1984 (insert "<div id=\"table-of-contents\">\n")
1985 (let ((beg (point)))
1986 (mapc 'insert thetoc
)
1988 (while (re-search-backward "<li>[ \r\n\t]*</li>\n?" beg t
)
1989 (replace-match ""))))
1990 ;; remove empty paragraphs
1991 (goto-char (point-min))
1992 (while (re-search-forward "<p>[ \r\n\t]*</p>" nil t
)
1994 (goto-char (point-min))
1995 ;; Convert whitespace place holders
1996 (goto-char (point-min))
1998 (while (setq beg
(next-single-property-change (point) 'org-whitespace
))
1999 (setq n
(get-text-property beg
'org-whitespace
)
2000 end
(next-single-property-change beg
'org-whitespace
))
2002 (delete-region beg end
)
2003 (insert (format "<span style=\"visibility:hidden;\">%s</span>"
2004 (make-string n ?x
)))))
2005 ;; Remove empty lines at the beginning of the file.
2006 (goto-char (point-min))
2007 (when (looking-at "\\s-+\n") (replace-match ""))
2008 ;; Remove display properties
2009 (remove-text-properties (point-min) (point-max) '(display t
))
2011 (run-hooks 'org-export-html-final-hook
)
2012 (or to-buffer
(save-buffer))
2013 (goto-char (point-min))
2014 (or (org-export-push-to-kill-ring "HTML")
2015 (message "Exporting... done"))
2016 (if (eq to-buffer
'string
)
2017 (prog1 (buffer-substring (point-min) (point-max))
2018 (kill-buffer (current-buffer)))
2019 (current-buffer)))))
2021 (defun org-export-html-format-href (s)
2022 "Make sure the S is valid as a href reference in an XHTML document."
2025 (while (string-match "&" s start
)
2026 (setq start
(+ (match-beginning 0) 3)
2027 s
(replace-match "&" t t s
)))))
2030 (defun org-export-html-format-desc (s)
2031 "Make sure the S is valid as a description in a link."
2032 (if (and s
(not (get-text-property 1 'org-protected s
)))
2034 (org-html-do-expand s
))
2037 (defun org-export-html-format-image (src par-open
)
2038 "Create image tag with source and attributes."
2040 (if (string-match (regexp-quote org-latex-preview-ltxpng-directory
) src
)
2041 (format "<img src=\"%s\" alt=\"%s\"/>"
2042 src
(org-find-text-property-in-string 'org-latex-src src
))
2043 (let* ((caption (org-find-text-property-in-string 'org-caption src
))
2044 (attr (org-find-text-property-in-string 'org-attributes src
))
2045 (label (org-find-text-property-in-string 'org-label src
)))
2046 (setq caption
(and caption
(org-html-do-expand caption
)))
2049 (format "%s<div %sclass=\"figure\">
2051 (if org-par-open
"</p>\n" "")
2052 (if label
(format "id=\"%s\" " (org-solidify-link-text label
)) "")))
2053 (format "<img src=\"%s\"%s />"
2055 (if (string-match "\\<alt=" (or attr
""))
2057 (concat " " attr
" alt=\"" src
"\"")))
2061 (concat "\n<p>" caption
"</p>")
2062 (if org-par-open
"\n<p>" ""))))))))
2064 (defun org-export-html-get-bibliography ()
2065 "Find bibliography, cut it out and return it."
2067 (let (beg end
(cnt 1) bib
)
2069 (goto-char (point-min))
2070 (when (re-search-forward "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t
)
2071 (setq beg
(match-beginning 0))
2072 (while (re-search-forward "</?div\\>" nil t
)
2073 (setq cnt
(+ cnt
(if (string= (match-string 0) "<div") +1 -
1)))
2075 (and (looking-at ">") (forward-char 1))
2076 (setq bib
(buffer-substring beg
(point)))
2077 (delete-region beg
(point))
2078 (throw 'exit bib
))))
2081 (defvar org-table-number-regexp
) ; defined in org-table.el
2082 (defun org-format-table-html (lines olines
&optional no-css
)
2083 "Find out which HTML converter to use and return the HTML code.
2084 NO-CSS is passed to the exporter."
2086 (setq lines
(org-split-string lines
"\n")))
2087 (if (string-match "^[ \t]*|" (car lines
))
2088 ;; A normal org table
2089 (org-format-org-table-html lines nil no-css
)
2090 ;; Table made by table.el
2091 (or (org-format-table-table-html-using-table-generate-source
2092 olines
(not org-export-prefer-native-exporter-for-tables
))
2093 ;; We are here only when table.el table has NO col or row
2094 ;; spanning and the user prefers using org's own converter for
2095 ;; exporting of such simple table.el tables.
2096 (org-format-table-table-html lines
))))
2098 (defvar org-table-number-fraction
) ; defined in org-table.el
2099 (defun org-format-org-table-html (lines &optional splice no-css
)
2100 "Format a table into HTML.
2101 LINES is a list of lines. Optional argument SPLICE means, do not
2102 insert header and surrounding <table> tags, just format the lines.
2103 Optional argument NO-CSS means use XHTML attributes instead of CSS
2104 for formatting. This is required for the DocBook exporter."
2105 (require 'org-table
)
2106 ;; Get rid of hlines at beginning and end
2107 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
2108 (setq lines
(nreverse lines
))
2109 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
2110 (setq lines
(nreverse lines
))
2111 (when org-export-table-remove-special-lines
2112 ;; Check if the table has a marking column. If yes remove the
2113 ;; column and the special lines
2114 (setq lines
(org-table-clean-before-export lines
)))
2116 (let* ((caption (org-find-text-property-in-string 'org-caption
(car lines
)))
2117 (label (org-find-text-property-in-string 'org-label
(car lines
)))
2118 (col-cookies (org-find-text-property-in-string 'org-col-cookies
2120 (attributes (org-find-text-property-in-string 'org-attributes
2122 (html-table-tag (org-export-splice-attributes
2123 html-table-tag attributes
))
2124 (head (and org-export-highlight-first-table-line
2126 (lambda (x) (string-match "^[ \t]*|-" x
))
2128 (nline 0) fnum nfields i
(cnt 0)
2129 tbopen org-line fields html gr colgropen rowstart rowend
2131 (setq caption
(and caption
(org-html-do-expand caption
)))
2132 (when (and col-cookies org-table-clean-did-remove-column
)
2134 (mapcar (lambda (x) (cons (1- (car x
)) (cdr x
))) col-cookies
)))
2135 (if splice
(setq head nil
))
2136 (unless splice
(push (if head
"<thead>" "<tbody>") html
))
2138 (while (setq org-line
(pop lines
))
2140 (if (string-match "^[ \t]*|-" org-line
)
2143 (push (if head
"</thead>" "</tbody>") html
)
2144 (if lines
(push "<tbody>" html
) (setq tbopen nil
)))
2145 (setq head nil
) ;; head ends here, first time around
2147 (throw 'next-line t
)))
2148 ;; Break the line into fields
2149 (setq fields
(org-split-string org-line
"[ \t]*|[ \t]*"))
2150 (unless fnum
(setq fnum
(make-vector (length fields
) 0)
2151 nfields
(length fnum
)))
2152 (setq nline
(1+ nline
) i -
1
2153 rowstart
(eval (car org-export-table-row-tags
))
2154 rowend
(eval (cdr org-export-table-row-tags
)))
2155 (push (concat rowstart
2158 (setq i
(1+ i
) ali
(format "@@class%03d@@" i
))
2159 (if (and (< i nfields
) ; make sure no rogue line causes an error here
2160 (string-match org-table-number-regexp x
))
2161 (incf (aref fnum i
)))
2165 (format (car org-export-table-header-tags
)
2168 (cdr org-export-table-header-tags
)))
2169 ((and (= i
0) org-export-html-table-use-header-tags-for-first-column
)
2171 (format (car org-export-table-header-tags
)
2174 (cdr org-export-table-header-tags
)))
2176 (concat (format (car org-export-table-data-tags
) ali
)
2178 (cdr org-export-table-data-tags
)))))
2182 (unless splice
(if tbopen
(push "</tbody>" html
)))
2183 (unless splice
(push "</table>\n" html
))
2184 (setq html
(nreverse html
))
2186 ;; Put in col tags with the alignment (unfortunately often ignored...)
2187 (unless (car org-table-colgroup-info
)
2188 (setq org-table-colgroup-info
2189 (cons :start
(cdr org-table-colgroup-info
))))
2193 (setq gr
(pop org-table-colgroup-info
)
2195 align
(if (nth 1 (assoc i col-cookies
))
2196 (cdr (assoc (nth 1 (assoc i col-cookies
))
2197 '(("l" .
"left") ("r" .
"right")
2199 (if (> (/ (float x
) nline
)
2200 org-table-number-fraction
)
2204 "%s<col align=\"%s\" />%s"
2205 "%s<col class=\"%s\" />%s")
2206 (if (memq gr
'(:start
:startend
))
2209 "</colgroup>\n<colgroup>"
2214 (if (memq gr
'(:end
:startend
))
2215 (progn (setq colgropen nil
) "</colgroup>")
2219 (setq aligns
(nreverse aligns
))
2220 (if colgropen
(setq html
(cons (car html
)
2221 (cons "</colgroup>" (cdr html
)))))
2222 ;; Since the output of HTML table formatter can also be used in
2223 ;; DocBook document, include empty captions for the DocBook
2224 ;; export only so that it produces valid XML.
2225 (when (or caption
(eq org-export-current-backend
'docbook
))
2226 (push (format "<caption>%s</caption>" (or caption
"")) html
))
2228 (setq html-table-tag
(org-export-splice-attributes html-table-tag
(format "id=\"%s\"" (org-solidify-link-text label
)))))
2229 (push html-table-tag html
))
2232 (replace-regexp-in-string
2233 "@@class\\([0-9]+\\)@@"
2235 (if (not org-export-html-table-align-individual-fields
)
2237 (setq n
(string-to-number (match-string 1 txt
)))
2238 (format (if no-css
" align=\"%s\"" " class=\"%s\"")
2239 (or (nth n aligns
) "left"))))
2242 (concat (mapconcat 'identity html
"\n") "\n")))
2244 (defun org-export-splice-attributes (tag attributes
)
2245 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
2246 (if (not attributes
)
2248 (let (oldatt newatt
)
2249 (setq oldatt
(org-extract-attributes-from-string tag
)
2251 newatt
(cdr (org-extract-attributes-from-string attributes
)))
2253 (setq oldatt
(plist-put oldatt
(pop newatt
) (pop newatt
))))
2254 (if (string-match ">" tag
)
2256 (replace-match (concat (org-attributes-to-string oldatt
) ">")
2260 (defun org-format-table-table-html (lines)
2261 "Format a table generated by table.el into HTML.
2262 This conversion does *not* use `table-generate-source' from table.el.
2263 This has the advantage that Org-mode's HTML conversions can be used.
2264 But it has the disadvantage, that no cell- or row-spanning is allowed."
2265 (let (org-line field-buffer
2266 (head org-export-highlight-first-table-line
)
2267 fields html empty i
)
2268 (setq html
(concat html-table-tag
"\n"))
2269 (while (setq org-line
(pop lines
))
2270 (setq empty
" ")
2272 (if (string-match "^[ \t]*\\+-" org-line
)
2283 (if (equal x
"") (setq x empty
))
2286 (format (car org-export-table-header-tags
) "col" "")
2288 (cdr org-export-table-header-tags
))
2289 (concat (format (car org-export-table-data-tags
) "") x
2290 (cdr org-export-table-data-tags
))))
2294 (setq field-buffer nil
)))
2296 (throw 'next-line t
)))
2297 ;; Break the line into fields and store the fields
2298 (setq fields
(org-split-string org-line
"[ \t]*|[ \t]*"))
2300 (setq field-buffer
(mapcar
2302 (concat x
"<br/>" (pop fields
)))
2304 (setq field-buffer fields
))))
2305 (setq html
(concat html
"</table>\n"))
2308 (defun org-format-table-table-html-using-table-generate-source (lines
2311 "Format a table into html, using `table-generate-source' from table.el.
2312 Use SPANNED-ONLY to suppress exporting of simple table.el tables.
2314 When SPANNED-ONLY is nil, all table.el tables are exported. When
2315 SPANNED-ONLY is non-nil, only tables with either row or column
2318 This routine returns the generated source or nil as appropriate.
2320 Refer docstring of `org-export-prefer-native-exporter-for-tables'
2321 for further information."
2323 (with-current-buffer (get-buffer-create " org-tmp1 ")
2325 (insert (mapconcat 'identity lines
"\n"))
2326 (goto-char (point-min))
2327 (if (not (re-search-forward "|[^+]" nil t
))
2328 (error "Error processing table"))
2329 (table-recognize-table)
2330 (when (or (not spanned-only
)
2331 (let* ((dim (table-query-dimension))
2332 (c (nth 4 dim
)) (r (nth 5 dim
)) (cells (nth 6 dim
)))
2333 (not (= (* c r
) cells
))))
2334 (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
2335 (table-generate-source 'html
" org-tmp2 ")
2336 (set-buffer " org-tmp2 ")
2337 (buffer-substring (point-min) (point-max)))))
2339 (defun org-export-splice-style (style extra
)
2340 "Splice EXTRA into STYLE, just before \"</style>\"."
2341 (if (and (stringp extra
)
2342 (string-match "\\S-" extra
)
2343 (string-match "</style>" style
))
2344 (concat (substring style
0 (match-beginning 0))
2346 (substring style
(match-beginning 0)))
2349 (defun org-html-handle-time-stamps (s)
2350 "Format time stamps in string S, or remove them."
2353 (when org-maybe-keyword-time-regexp
2354 (while (string-match org-maybe-keyword-time-regexp s
)
2355 (or b
(setq b
(substring s
0 (match-beginning 0))))
2357 r
(substring s
0 (match-beginning 0))
2358 " @<span class=\"timestamp-wrapper\">"
2360 (format "@<span class=\"timestamp-kwd\">%s @</span>"
2361 (match-string 1 s
)))
2362 (format " @<span class=\"timestamp\">%s@</span>"
2364 (org-translate-time (match-string 3 s
)) 1 -
1))
2366 s
(substring s
(match-end 0)))))
2367 ;; Line break if line started and ended with time stamp stuff
2370 (setq r
(concat r s
))
2371 (unless (string-match "\\S-" (concat b s
))
2372 (setq r
(concat r
"@<br/>")))
2375 (defvar htmlize-buffer-places
) ; from htmlize.el
2376 (defun org-export-htmlize-region-for-paste (beg end
)
2377 "Convert the region to HTML, using htmlize.el.
2378 This is much like `htmlize-region-for-paste', only that it uses
2379 the settings define in the org-... variables."
2380 (let* ((htmlize-output-type org-export-htmlize-output-type
)
2381 (htmlize-css-name-prefix org-export-htmlize-css-font-prefix
)
2382 (htmlbuf (htmlize-region beg end
)))
2384 (with-current-buffer htmlbuf
2385 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
2386 (plist-get htmlize-buffer-places
'content-end
)))
2387 (kill-buffer htmlbuf
))))
2389 (defun org-export-htmlize-generate-css ()
2390 "Create the CSS for all font definitions in the current Emacs session.
2391 Use this to create face definitions in your CSS style file that can then
2392 be used by code snippets transformed by htmlize.
2393 This command just produces a buffer that contains class definitions for all
2394 faces used in the current Emacs session. You can copy and paste the ones you
2395 need into your CSS file.
2397 If you then set `org-export-htmlize-output-type' to `css', calls to
2398 the function `org-export-htmlize-region-for-paste' will produce code
2399 that uses these same face definitions."
2402 (and (get-buffer "*html*") (kill-buffer "*html*"))
2404 (let ((fl (face-list))
2405 (htmlize-css-name-prefix "org-")
2406 (htmlize-output-type 'css
)
2408 (while (setq f
(pop fl
)
2409 i
(and f
(face-attribute f
:inherit
)))
2410 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
2411 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
2412 (htmlize-region (point-min) (point-max))))
2413 (org-pop-to-buffer-same-window "*html*")
2414 (goto-char (point-min))
2415 (if (re-search-forward "<style" nil t
)
2416 (delete-region (point-min) (match-beginning 0)))
2417 (if (re-search-forward "</style>" nil t
)
2418 (delete-region (1+ (match-end 0)) (point-max)))
2419 (beginning-of-line 1)
2420 (if (looking-at " +") (replace-match ""))
2421 (goto-char (point-min)))
2423 (defun org-html-protect (s)
2424 "Convert characters to HTML equivalent.
2425 Possible conversions are set in `org-export-html-protect-char-alist'."
2426 (let ((cl org-export-html-protect-char-alist
) c
)
2427 (while (setq c
(pop cl
))
2429 (while (string-match (car c
) s start
)
2430 (setq s
(replace-match (cdr c
) t t s
)
2431 start
(1+ (match-beginning 0))))))
2434 (defun org-html-expand (string)
2435 "Prepare STRING for HTML export. Apply all active conversions.
2436 If there are links in the string, don't modify these. If STRING
2437 is nil, return nil."
2439 (let* ((re (concat org-bracket-link-regexp
"\\|"
2440 (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
2442 (while (setq m
(string-match re string
))
2443 (setq s
(substring string
0 m
)
2444 l
(match-string 0 string
)
2445 string
(substring string
(match-end 0)))
2446 (push (org-html-do-expand s
) res
)
2448 (push (org-html-do-expand string
) res
)
2449 (apply 'concat
(nreverse res
)))))
2451 (defun org-html-do-expand (s)
2452 "Apply all active conversions to translate special ASCII to HTML."
2453 (setq s
(org-html-protect s
))
2454 (if org-export-html-expand
2455 (while (string-match "@<\\([^&]*\\)>" s
)
2456 (setq s
(replace-match "<\\1>" t nil s
))))
2457 (if org-export-with-emphasize
2458 (setq s
(org-export-html-convert-emphasize s
)))
2459 (if org-export-with-special-strings
2460 (setq s
(org-export-html-convert-special-strings s
)))
2461 (if org-export-with-sub-superscripts
2462 (setq s
(org-export-html-convert-sub-super s
)))
2463 (if org-export-with-TeX-macros
2464 (let ((start 0) wd rep
)
2465 (while (setq start
(string-match "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?"
2467 (if (get-text-property (match-beginning 0) 'org-protected s
)
2468 (setq start
(match-end 0))
2469 (setq wd
(match-string 1 s
))
2470 (if (setq rep
(org-entity-get-representation wd
'html
))
2471 (setq s
(replace-match rep t t s
))
2472 (setq start
(+ start
(length wd
))))))))
2475 (defun org-export-html-convert-special-strings (string)
2476 "Convert special characters in STRING to HTML."
2477 (let ((all org-export-html-special-string-regexps
)
2479 (while (setq a
(pop all
))
2480 (setq re
(car a
) rpl
(cdr a
) start
0)
2481 (while (string-match re string start
)
2482 (if (get-text-property (match-beginning 0) 'org-protected string
)
2483 (setq start
(match-end 0))
2484 (setq string
(replace-match rpl t nil string
)))))
2487 (defun org-export-html-convert-sub-super (string)
2488 "Convert sub- and superscripts in STRING to HTML."
2489 (let (key c
(s 0) (requireb (eq org-export-with-sub-superscripts
'{})))
2490 (while (string-match org-match-substring-regexp string s
)
2492 ((and requireb
(match-end 8)) (setq s
(match-end 2)))
2493 ((get-text-property (match-beginning 2) 'org-protected string
)
2494 (setq s
(match-end 2)))
2496 (setq s
(match-end 1)
2497 key
(if (string= (match-string 2 string
) "_") "sub" "sup")
2498 c
(or (match-string 8 string
)
2499 (match-string 6 string
)
2500 (match-string 5 string
))
2501 string
(replace-match
2502 (concat (match-string 1 string
)
2503 "<" key
">" c
"</" key
">")
2505 (while (string-match "\\\\\\([_^]\\)" string
)
2506 (setq string
(replace-match (match-string 1 string
) t t string
)))
2509 (defun org-export-html-convert-emphasize (string)
2512 (while (string-match org-emph-re string s
)
2514 (substring string
(match-beginning 3) (1+ (match-beginning 3)))
2515 (substring string
(match-beginning 4) (1+ (match-beginning 4)))))
2516 (setq s
(match-beginning 0)
2519 (match-string 1 string
)
2520 (nth 2 (assoc (match-string 3 string
) org-emphasis-alist
))
2521 (match-string 4 string
)
2522 (nth 3 (assoc (match-string 3 string
)
2523 org-emphasis-alist
))
2524 (match-string 5 string
))
2525 string
(replace-match rpl t t string
)
2526 s
(+ s
(- (length rpl
) 2)))
2530 (defun org-open-par ()
2531 "Insert <p>, but first close previous paragraph if any."
2532 (org-close-par-maybe)
2534 (setq org-par-open t
))
2535 (defun org-close-par-maybe ()
2536 "Close paragraph if there is one open."
2539 (setq org-par-open nil
)))
2540 (defun org-close-li (&optional type
)
2541 "Close <li> if necessary."
2542 (org-close-par-maybe)
2543 (insert (if (equal type
"d") "</dd>\n" "</li>\n")))
2545 (defvar body-only
) ; dynamically scoped into this.
2546 (defun org-html-level-start (level title umax with-toc head-count
&optional opt-plist
)
2547 "Insert a new level in HTML export.
2548 When TITLE is nil, just close all open levels."
2549 (org-close-par-maybe)
2550 (let* ((target (and title
(org-get-text-property-any 0 'target title
)))
2551 (extra-targets (and target
2552 (assoc target org-export-target-aliases
)))
2553 (extra-class (and title
(org-get-text-property-any 0 'html-container-class title
)))
2554 (preferred (and target
2555 (cdr (assoc target org-export-preferred-target-alist
))))
2557 (num (plist-get opt-plist
:section-numbers
))
2558 snumber snu href suffix
)
2559 (setq extra-targets
(remove (or preferred target
) extra-targets
))
2561 (mapconcat (lambda (x)
2562 (setq x
(org-solidify-link-text
2563 (if (org-uuidgen-p x
) (concat "ID-" x
) x
)))
2564 (if (stringp org-export-html-headline-anchor-format
)
2565 (format org-export-html-headline-anchor-format x x
)
2570 (if (aref org-levels-open
(1- l
))
2572 (org-html-level-close l umax
)
2573 (aset org-levels-open
(1- l
) nil
)))
2576 ;; If title is nil, this means this function is called to close
2577 ;; all levels, so the rest is done only if title is given
2578 (when (string-match (org-re "\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title
)
2579 (setq title
(replace-match
2580 (if org-export-with-tags
2583 " <span class=\"tag\">"
2586 (format "<span class=\"%s\">%s</span>"
2587 (org-export-html-get-tag-class-name x
)
2589 (org-split-string (match-string 1 title
) ":")
2596 (if (aref org-levels-open
(1- level
))
2600 (insert (format "<li id=\"%s\">" (org-solidify-link-text (or preferred target
)))
2601 extra-targets title
"<br/>\n")
2602 (insert "<li>" title
"<br/>\n")))
2603 (aset org-levels-open
(1- level
) t
)
2604 (org-close-par-maybe)
2606 (insert (format "<ul>\n<li id=\"%s\">" (org-solidify-link-text (or preferred target
)))
2607 extra-targets title
"<br/>\n")
2608 (insert "<ul>\n<li>" title
"<br/>\n"))))
2609 (aset org-levels-open
(1- level
) t
)
2610 (setq snumber
(org-section-number level
)
2611 snu
(replace-regexp-in-string "\\." "-" snumber
))
2612 (setq level
(+ level org-export-html-toplevel-hlevel -
1))
2613 (if (and num
(not body-only
))
2615 (format "<span class=\"section-number-%d\">%s</span>"
2619 ;; fix up num to take into
2620 ;; account the top-level
2622 (>= (+ num org-export-html-toplevel-hlevel -
1)
2628 (unless (= head-count
1) (insert "\n</div>\n"))
2629 (setq href
(cdr (assoc (concat "sec-" snu
) org-export-preferred-target-alist
)))
2630 (setq suffix
(org-solidify-link-text (or href snu
)))
2631 (setq href
(org-solidify-link-text (or href
(concat "sec-" snu
))))
2632 (insert (format "\n<div id=\"outline-container-%s\" class=\"outline-%d%s\">\n<h%d id=\"%s\">%s%s</h%d>\n<div class=\"outline-text-%d\" id=\"text-%s\">\n"
2633 suffix level
(if extra-class
(concat " " extra-class
) "")
2636 title level level suffix
))
2639 (defun org-export-html-get-tag-class-name (tag)
2640 "Turn tag into a valid class name.
2641 Replaces invalid characters with \"_\" and then prepends a prefix."
2643 (while (string-match "[^a-zA-Z0-9_]" tag
)
2644 (setq tag
(replace-match "_" t t tag
))))
2645 (concat org-export-html-tag-class-prefix tag
))
2647 (defun org-export-html-get-todo-kwd-class-name (kwd)
2648 "Turn todo keyword into a valid class name.
2649 Replaces invalid characters with \"_\" and then prepends a prefix."
2651 (while (string-match "[^a-zA-Z0-9_]" kwd
)
2652 (setq kwd
(replace-match "_" t t kwd
))))
2653 (concat org-export-html-todo-kwd-class-prefix kwd
))
2655 (defun org-html-level-close (level max-outline-level
)
2656 "Terminate one level in HTML export."
2657 (if (<= level max-outline-level
)
2660 (insert "</ul>\n")))
2662 (defun org-html-export-list-line (org-line pos struct prevs
)
2663 "Insert list syntax in export buffer. Return ORG-LINE, maybe modified.
2665 POS is the item position or org-line position the org-line had before
2666 modifications to buffer. STRUCT is the list structure. PREVS is
2667 the alist of previous items."
2670 ;; Translate type of list containing POS to "d", "o" or
2672 (lambda (pos struct prevs
)
2673 (let ((type (org-list-get-list-type pos struct prevs
)))
2675 ((eq 'ordered type
) "o")
2676 ((eq 'descriptive type
) "d")
2680 ;; Return list of all items and sublists ending at POS, in
2686 (let ((end (nth 6 e
))
2689 ((= end pos
) (push item out
))
2690 ((>= item pos
) (throw 'exit nil
)))))
2693 ;; First close any previous item, or list, ending at POS.
2695 (let* ((lastp (= (org-list-get-last-item e struct prevs
) e
))
2696 (first-item (org-list-get-list-begin e struct prevs
))
2697 (type (funcall get-type first-item struct prevs
)))
2698 (org-close-par-maybe)
2699 ;; Ending for every item
2701 ;; We're ending last item of the list: end list.
2703 (insert (format "</%sl>\n" type
))
2705 (funcall get-closings pos
))
2707 ;; At an item: insert appropriate tags in export buffer.
2710 (concat "[ \t]*\\(\\S-+[ \t]*\\)"
2711 "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?"
2712 "\\(?:\\(\\[[ X-]\\]\\)[ \t]+\\)?"
2713 "\\(?:\\(.*\\)[ \t]+::\\(?:[ \t]+\\|$\\)\\)?"
2714 "\\(.*\\)") org-line
)
2715 (let* ((checkbox (match-string 3 org-line
))
2716 (desc-tag (or (match-string 4 org-line
) "???"))
2717 (body (or (match-string 5 org-line
) ""))
2718 (list-beg (org-list-get-list-begin pos struct prevs
))
2719 (firstp (= list-beg pos
))
2720 ;; Always refer to first item to determine list type, in
2721 ;; case list is ill-formed.
2722 (type (funcall get-type list-beg struct prevs
))
2723 (counter (let ((count-tmp (org-list-get-counter pos struct
)))
2725 ((not count-tmp
) nil
)
2726 ((string-match "[A-Za-z]" count-tmp
)
2727 (- (string-to-char (upcase count-tmp
)) 64))
2728 ((string-match "[0-9]+" count-tmp
)
2731 (org-close-par-maybe)
2732 (insert (format "<%sl>\n" type
)))
2735 (format "<dt>%s</dt><dd>" desc-tag
))
2736 ((and (equal type
"o") counter
)
2737 (format "<li value=\"%s\">" counter
))
2739 ;; If line had a checkbox, some additional modification is required.
2744 ((string-match "X" checkbox
) "<code>[X]</code> ")
2745 ((string-match " " checkbox
) "<code>[ ]</code> ")
2746 (t "<code>[-]</code> "))
2748 ;; Return modified line
2750 ;; At a list ender: go to next line (side-effects only).
2751 ((equal "ORG-LIST-END-MARKER" org-line
) (throw 'nextline nil
))
2752 ;; Not at an item: return line unchanged (side-effects only).
2758 ;; generated-autoload-file: "org-loaddefs.el"
2761 ;;; org-html.el ends here