1 ;;; org-exp.el --- ASCII, HTML, XOXO and iCalendar export for Org-mode
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
4 ;; Free Software Foundation, Inc.
6 ;; Author: Carsten Dominik <carsten at orgmode dot org>
7 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; Homepage: http://orgmode.org
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34 (declare-function org-export-latex-preprocess
"org-export-latex" (parameters))
35 (declare-function org-export-docbook-preprocess
"org-docbook" (parameters))
36 (declare-function org-agenda-skip
"org-agenda" ())
37 (declare-function org-infojs-options-inbuffer-template
"org-jsinfo" ())
38 (declare-function htmlize-region
"ext:htmlize" (beg end
))
39 (declare-function org-id-find-id-file
"org-id" (id))
40 (defvar htmlize-buffer-places
) ; from htmlize.el
42 (defgroup org-export nil
43 "Options for exporting org-listings."
47 (defgroup org-export-general nil
48 "General options for exporting Org-mode files."
49 :tag
"Org Export General"
53 (defvar org-export-publishing-directory nil
)
55 (defcustom org-export-run-in-background nil
56 "Non-nil means export and publishing commands will run in background.
57 This works by starting up a separate Emacs process visiting the same file
58 and doing the export from there.
59 Not all export commands are affected by this - only the ones which
60 actually write to a file, and that do not depend on the buffer state.
62 If this option is nil, you can still get background export by calling
63 `org-export' with a double prefix arg: `C-u C-u C-c C-e'.
65 If this option is t, the double prefix can be used to exceptionally
66 force an export command into the current process."
67 :group
'org-export-general
71 (defcustom org-export-select-tags
'("export")
72 "Tags that select a tree for export.
73 If any such tag is found in a buffer, all trees that do not carry one
74 of these tags will be deleted before export.
75 Inside trees that are selected like this, you can still deselect a
76 subtree by tagging it with one of the `org-export-exclude-tags'."
77 :group
'org-export-general
78 :type
'(repeat (string :tag
"Tag")))
80 (defcustom org-export-exclude-tags
'("noexport")
81 "Tags that exclude a tree from export.
82 All trees carrying any of these tags will be excluded from export.
83 This is without condition, so even subtrees inside that carry one of the
84 `org-export-select-tags' will be removed."
85 :group
'org-export-general
86 :type
'(repeat (string :tag
"Tag")))
88 (defcustom org-export-with-special-strings t
89 "Non-nil means, interpret \"\-\", \"--\" and \"---\" for export.
90 When this option is turned on, these strings will be exported as:
93 -----+----------+--------
99 This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
100 :group
'org-export-translation
103 (defcustom org-export-language-setup
104 '(("en" "Author" "Date" "Table of Contents" "Footnotes")
105 ("ca" "Autor" "Data" "Índex" "Peus de pàgina")
106 ("cs" "Autor" "Datum" "Obsah" "Pozn\xe1mky pod carou")
107 ("da" "Ophavsmand" "Dato" "Indhold" "Fodnoter")
108 ("de" "Autor" "Datum" "Inhaltsverzeichnis" "Fußnoten")
109 ("eo" "Aŭtoro" "Dato" "Enhavo" "Piednotoj")
110 ("es" "Autor" "Fecha" "Índice" "Pies de página")
111 ("fi" "Tekijä" "Päivämäärä" "Sisällysluettelo" "Alaviitteet")
112 ("fr" "Auteur" "Date" "Table des matières" "Notes de bas de page")
113 ("hu" "Szerzõ" "Dátum" "Tartalomjegyzék" "Lábjegyzet")
114 ("is" "Höfundur" "Dagsetning" "Efnisyfirlit" "Aftanmálsgreinar")
115 ("it" "Autore" "Data" "Indice" "Note a piè di pagina")
116 ("nl" "Auteur" "Datum" "Inhoudsopgave" "Voetnoten")
117 ("no" "Forfatter" "Dato" "Innhold" "Fotnoter")
118 ("nb" "Forfatter" "Dato" "Innhold" "Fotnoter") ;; nb = Norsk (bokm.l)
119 ("nn" "Forfattar" "Dato" "Innhald" "Fotnotar") ;; nn = Norsk (nynorsk)
120 ("pl" "Autor" "Data" "Spis treści" "Przypis")
121 ("sv" "Författare" "Datum" "Innehåll" "Fotnoter"))
122 "Terms used in export text, translated to different languages.
123 Use the variable `org-export-default-language' to set the language,
124 or use the +OPTION lines for a per-file setting."
125 :group
'org-export-general
128 (string :tag
"HTML language tag")
129 (string :tag
"Author")
131 (string :tag
"Table of Contents")
132 (string :tag
"Footnotes"))))
134 (defcustom org-export-default-language
"en"
135 "The default language of HTML export, as a string.
136 This should have an association in `org-export-language-setup'."
137 :group
'org-export-general
140 (defvar org-export-page-description
""
141 "The page description, for the XHTML meta tag.
142 This is best set with the #+DESCRIPTION line in a file, it does not make
143 sense to set this globally.")
145 (defvar org-export-page-keywords
""
146 "The page description, for the XHTML meta tag.
147 This is best set with the #+KEYWORDS line in a file, it does not make
148 sense to set this globally.")
150 (defcustom org-export-skip-text-before-1st-heading nil
151 "Non-nil means, skip all text before the first headline when exporting.
152 When nil, that text is exported as well."
153 :group
'org-export-general
156 (defcustom org-export-headline-levels
3
157 "The last level which is still exported as a headline.
158 Inferior levels will produce itemize lists when exported.
159 Note that a numeric prefix argument to an exporter function overrides
162 This option can also be set with the +OPTIONS line, e.g. \"H:2\"."
163 :group
'org-export-general
166 (defcustom org-export-with-section-numbers t
167 "Non-nil means, add section numbers to headlines when exporting.
169 This option can also be set with the +OPTIONS line, e.g. \"num:t\"."
170 :group
'org-export-general
173 (defcustom org-export-section-number-format
'((("1" ".")) .
"")
174 "Format of section numbers for export.
175 The variable has two components.
176 1. A list of lists, each indicating a counter type and a separator.
177 The counter type can be any of \"1\", \"A\", \"a\", \"I\", or \"a\".
178 It causes causes numeric, alphabetic, or roman counters, respectively.
179 The separator is only used if another counter for a subsection is being
181 If there are more numbered section levels than entries in this lists,
182 then the last entry will be reused.
183 2. A terminator string that will be added after the entire
185 :group
'org-export-general
189 (string :tag
"Counter Type")
190 (string :tag
"Separator ")))
191 (string :tag
"Terminator")))
193 (defcustom org-export-with-toc t
194 "Non-nil means, create a table of contents in exported files.
195 The TOC contains headlines with levels up to`org-export-headline-levels'.
196 When an integer, include levels up to N in the toc, this may then be
197 different from `org-export-headline-levels', but it will not be allowed
198 to be larger than the number of headline levels.
199 When nil, no table of contents is made.
201 Headlines which contain any TODO items will be marked with \"(*)\" in
202 ASCII export, and with red color in HTML output, if the option
203 `org-export-mark-todo-in-toc' is set.
205 In HTML output, the TOC will be clickable.
207 This option can also be set with the +OPTIONS line, e.g. \"toc:nil\"
209 :group
'org-export-general
211 (const :tag
"No Table of Contents" nil
)
212 (const :tag
"Full Table of Contents" t
)
213 (integer :tag
"TOC to level")))
215 (defcustom org-export-mark-todo-in-toc nil
216 "Non-nil means, mark TOC lines that contain any open TODO items."
217 :group
'org-export-general
220 (defcustom org-export-with-todo-keywords t
221 "Non-nil means, include TODO keywords in export.
222 When nil, remove all these keywords from the export."
223 :group
'org-export-general
226 (defcustom org-export-with-priority nil
227 "Non-nil means, include priority cookies in export.
228 When nil, remove priority cookies for export."
229 :group
'org-export-general
232 (defcustom org-export-preserve-breaks nil
233 "Non-nil means, preserve all line breaks when exporting.
234 Normally, in HTML output paragraphs will be reformatted. In ASCII
235 export, line breaks will always be preserved, regardless of this variable.
237 This option can also be set with the +OPTIONS line, e.g. \"\\n:t\"."
238 :group
'org-export-general
241 (defcustom org-export-with-archived-trees
'headline
242 "Whether subtrees with the ARCHIVE tag should be exported.
243 This can have three different values
244 nil Do not export, pretend this tree is not present
245 t Do export the entire tree
246 headline Only export the headline, but skip the tree below it."
247 :group
'org-export-general
250 (const :tag
"not at all" nil
)
251 (const :tag
"headline only" 'headline
)
252 (const :tag
"entirely" t
)))
254 (defcustom org-export-author-info t
255 "Non-nil means, insert author name and email into the exported file.
257 This option can also be set with the +OPTIONS line,
258 e.g. \"author-info:nil\"."
259 :group
'org-export-general
262 (defcustom org-export-creator-info t
263 "Non-nil means, the postamble should contain a creator sentence.
264 This sentence is \"HTML generated by org-mode XX in emacs XXX\"."
265 :group
'org-export-general
268 (defcustom org-export-time-stamp-file t
269 "Non-nil means, insert a time stamp into the exported file.
270 The time stamp shows when the file was created.
272 This option can also be set with the +OPTIONS line,
273 e.g. \"timestamp:nil\"."
274 :group
'org-export-general
277 (defcustom org-export-with-timestamps t
278 "If nil, do not export time stamps and associated keywords."
279 :group
'org-export-general
282 (defcustom org-export-remove-timestamps-from-toc t
283 "If nil, remove timestamps from the table of contents entries."
284 :group
'org-export-general
287 (defcustom org-export-with-tags
'not-in-toc
288 "If nil, do not export tags, just remove them from headlines.
289 If this is the symbol `not-in-toc', tags will be removed from table of
290 contents entries, but still be shown in the headlines of the document.
292 This option can also be set with the +OPTIONS line, e.g. \"tags:nil\"."
293 :group
'org-export-general
295 (const :tag
"Off" nil
)
296 (const :tag
"Not in TOC" not-in-toc
)
297 (const :tag
"On" t
)))
299 (defcustom org-export-with-drawers nil
300 "Non-nil means, export with drawers like the property drawer.
301 When t, all drawers are exported. This may also be a list of
302 drawer names to export."
303 :group
'org-export-general
305 (const :tag
"All drawers" t
)
306 (const :tag
"None" nil
)
307 (repeat :tag
"Selected drawers"
308 (string :tag
"Drawer name"))))
310 (defvar org-export-preprocess-hook nil
311 "Hook for preprocessing an export buffer.
312 Pretty much the first thing when exporting is running this hook.")
314 (defvar org-export-preprocess-after-include-files-hook nil
315 "Hook for preprocessing an export buffer.
316 This is run after the contents of included files have been inserted.")
318 (defvar org-export-preprocess-after-tree-selection-hook nil
319 "Hook for preprocessing an export buffer.
320 This is run after selection of trees to be exported has happened.
321 This selection includes tags-based selection, as well as removal
322 of commented and archived trees.")
324 (defvar org-export-preprocess-before-backend-specifics-hook nil
325 "Hook run before backend-specific functions are called during preprocessing.")
327 (defvar org-export-preprocess-final-hook nil
328 "Hook for preprocessing an export buffer.
329 This is run as the last thing in the preprocessing buffer, just before
330 returning the buffer string to the backend.")
332 (defgroup org-export-translation nil
333 "Options for translating special ascii sequences for the export backends."
334 :tag
"Org Export Translation"
337 (defcustom org-export-with-emphasize t
338 "Non-nil means, interpret *word*, /word/, and _word_ as emphasized text.
339 If the export target supports emphasizing text, the word will be
340 typeset in bold, italic, or underlined, respectively. Works only for
341 single words, but you can say: I *really* *mean* *this*.
342 Not all export backends support this.
344 This option can also be set with the +OPTIONS line, e.g. \"*:nil\"."
345 :group
'org-export-translation
348 (defcustom org-export-with-footnotes t
349 "If nil, export [1] as a footnote marker.
350 Lines starting with [1] will be formatted as footnotes.
352 This option can also be set with the +OPTIONS line, e.g. \"f:nil\"."
353 :group
'org-export-translation
356 (defcustom org-export-html-footnotes-section
"<div id=\"footnotes\">
357 <h2 class=\"footnotes\">%s: </h2>
358 <div id=\"text-footnotes\">
362 "Format for the footnotes section.
363 Should contain a two instances of %s. The first will be replaced with the
364 language-specific word for \"Footnotes\", the second one will be replaced
365 by the footnotes themselves."
366 :group
'org-export-html
369 (defcustom org-export-with-sub-superscripts t
370 "Non-nil means, interpret \"_\" and \"^\" for export.
371 When this option is turned on, you can use TeX-like syntax for sub- and
372 superscripts. Several characters after \"_\" or \"^\" will be
373 considered as a single item - so grouping with {} is normally not
374 needed. For example, the following things will be parsed as single
375 sub- or superscripts.
377 10^24 or 10^tau several digits will be considered 1 item.
378 10^-12 or 10^-tau a leading sign with digits or a word
379 x^2-y^3 will be read as x^2 - y^3, because items are
380 terminated by almost any nonword/nondigit char.
381 x_{i^2} or x^(2-i) braces or parenthesis do grouping.
383 Still, ambiguity is possible - so when in doubt use {} to enclose the
384 sub/superscript. If you set this variable to the symbol `{}',
385 the braces are *required* in order to trigger interpretations as
386 sub/superscript. This can be helpful in documents that need \"_\"
387 frequently in plain text.
389 Not all export backends support this, but HTML does.
391 This option can also be set with the +OPTIONS line, e.g. \"^:nil\"."
392 :group
'org-export-translation
394 (const :tag
"Always interpret" t
)
395 (const :tag
"Only with braces" {})
396 (const :tag
"Never interpret" nil
)))
398 (defcustom org-export-with-TeX-macros t
399 "Non-nil means, interpret simple TeX-like macros when exporting.
400 For example, HTML export converts \\alpha to α and \\AA to Å.
401 Not only real TeX macros will work here, but the standard HTML entities
402 for math can be used as macro names as well. For a list of supported
403 names in HTML export, see the constant `org-html-entities'.
404 Not all export backends support this.
406 This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"."
407 :group
'org-export-translation
408 :group
'org-export-latex
411 (defcustom org-export-with-LaTeX-fragments nil
412 "Non-nil means, convert LaTeX fragments to images when exporting to HTML.
413 When set, the exporter will find LaTeX environments if the \\begin line is
414 the first non-white thing on a line. It will also find the math delimiters
415 like $a=b$ and \\( a=b \\) for inline math, $$a=b$$ and \\[ a=b \\] for
418 This option can also be set with the +OPTIONS line, e.g. \"LaTeX:t\"."
419 :group
'org-export-translation
420 :group
'org-export-latex
423 (defcustom org-export-with-fixed-width t
424 "Non-nil means, lines starting with \":\" will be in fixed width font.
425 This can be used to have pre-formatted text, fragments of code etc. For
427 : ;; Some Lisp examples
430 will be looking just like this in also HTML. See also the QUOTE keyword.
431 Not all export backends support this.
433 This option can also be set with the +OPTIONS line, e.g. \"::nil\"."
434 :group
'org-export-translation
437 (defcustom org-match-sexp-depth
3
438 "Number of stacked braces for sub/superscript matching.
439 This has to be set before loading org.el to be effective."
440 :group
'org-export-translation
443 (defgroup org-export-tables nil
444 "Options for exporting tables in Org-mode."
445 :tag
"Org Export Tables"
448 (defcustom org-export-with-tables t
449 "If non-nil, lines starting with \"|\" define a table.
452 | Name | Address | Birthday |
453 |-------------+----------+-----------|
454 | Arthur Dent | England | 29.2.2100 |
456 Not all export backends support this.
458 This option can also be set with the +OPTIONS line, e.g. \"|:nil\"."
459 :group
'org-export-tables
462 (defcustom org-export-highlight-first-table-line t
463 "Non-nil means, highlight the first table line.
464 In HTML export, this means use <th> instead of <td>.
465 In tables created with table.el, this applies to the first table line.
466 In Org-mode tables, all lines before the first horizontal separator
467 line will be formatted with <th> tags."
468 :group
'org-export-tables
471 (defcustom org-export-table-remove-special-lines t
472 "Remove special lines and marking characters in calculating tables.
473 This removes the special marking character column from tables that are set
474 up for spreadsheet calculations. It also removes the entire lines
475 marked with `!', `_', or `^'. The lines with `$' are kept, because
476 the values of constants may be useful to have."
477 :group
'org-export-tables
480 (defcustom org-export-prefer-native-exporter-for-tables nil
481 "Non-nil means, always export tables created with table.el natively.
482 Natively means, use the HTML code generator in table.el.
483 When nil, Org-mode's own HTML generator is used when possible (i.e. if
484 the table does not use row- or column-spanning). This has the
485 advantage, that the automatic HTML conversions for math symbols and
486 sub/superscripts can be applied. Org-mode's HTML generator is also
488 :group
'org-export-tables
491 (defgroup org-export-ascii nil
492 "Options specific for ASCII export of Org-mode files."
493 :tag
"Org Export ASCII"
496 (defcustom org-export-ascii-underline
'(?\$ ?\
# ?^ ?\~ ?\
= ?\-
)
497 "Characters for underlining headings in ASCII export.
498 In the given sequence, these characters will be used for level 1, 2, ..."
499 :group
'org-export-ascii
500 :type
'(repeat character
))
502 (defcustom org-export-ascii-bullets
'(?
* ?
+ ?-
)
503 "Bullet characters for headlines converted to lists in ASCII export.
504 The first character is used for the first lest level generated in this
505 way, and so on. If there are more levels than characters given here,
506 the list will be repeated.
507 Note that plain lists will keep the same bullets as the have in the
509 :group
'org-export-ascii
510 :type
'(repeat character
))
512 (defcustom org-export-ascii-links-to-notes t
513 "Non-nil means, convert links to notes before the next headline.
514 When nil, the link will be exported in place. If the line becomes long
515 in this way, it will be wrapped."
516 :group
'org-export-ascii
519 (defgroup org-export-xml nil
520 "Options specific for XML export of Org-mode files."
521 :tag
"Org Export XML"
524 (defgroup org-export-html nil
525 "Options specific for HTML export of Org-mode files."
526 :tag
"Org Export HTML"
529 (defcustom org-export-html-coding-system nil
530 "Coding system for HTML export, defaults to buffer-file-coding-system."
531 :group
'org-export-html
532 :type
'coding-system
)
534 (defcustom org-export-html-extension
"html"
535 "The extension for exported HTML files."
536 :group
'org-export-html
539 (defcustom org-export-html-link-up
""
540 "Where should the \"UP\" link of exported HTML pages lead?"
541 :group
'org-export-html
542 :type
'(string :tag
"File or URL"))
544 (defcustom org-export-html-link-home
""
545 "Where should the \"HOME\" link of exported HTML pages lead?"
546 :group
'org-export-html
547 :type
'(string :tag
"File or URL"))
549 (defcustom org-export-html-style-include-scripts t
550 "Non-nil means, include the javascript snippets in exported HTML files.
551 The actual script is defined in `org-export-html-scripts' and should
553 :group
'org-export-html
556 (defconst org-export-html-scripts
557 "<script type=\"text/javascript\">
558 <!--/*--><![CDATA[/*><!--*/
559 function CodeHighlightOn(elem, id)
561 var target = document.getElementById(id);
563 elem.cacheClassElem = elem.className;
564 elem.cacheClassTarget = target.className;
565 target.className = \"code-highlighted\";
566 elem.className = \"code-highlighted\";
569 function CodeHighlightOff(elem, id)
571 var target = document.getElementById(id);
572 if(elem.cacheClassElem)
573 elem.className = elem.cacheClassElem;
574 if(elem.cacheClassTarget)
575 target.className = elem.cacheClassTarget;
579 "Basic javascript that is needed by HTML files produced by Org-mode.")
581 (defconst org-export-html-style-default
582 "<style type=\"text/css\">
583 <!--/*--><![CDATA[/*><!--*/
584 html { font-family: Times, serif; font-size: 12pt; }
585 .title { text-align: center; }
586 .todo { color: red; }
587 .done { color: green; }
588 .tag { background-color: #add8e6; font-weight:normal }
590 .timestamp { color: #bebebe; }
591 .timestamp-kwd { color: #5f9ea0; }
592 p.verse { margin-left: 3% }
594 border: 1pt solid #AEBDCC;
595 background-color: #F3F5F7;
597 font-family: courier, monospace;
601 table { border-collapse: collapse; }
602 td, th { vertical-align: top; }
603 dt { font-weight: bold; }
604 div.figure { padding: 0.5em; }
605 div.figure p { text-align: center; }
606 .linenr { font-size:smaller }
607 .code-highlighted {background-color:#ffff00;}
608 .org-info-js_info-navigation { border-style:none; }
609 #org-info-js_console-label { font-size:10px; font-weight:bold;
610 white-space:nowrap; }
611 .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
615 "The default style specification for exported HTML files.
616 Please use the variables `org-export-html-style' and
617 `org-export-html-style-extra' to add to this style. If you wish to not
618 have the default style included, customize the variable
619 `org-export-html-style-include-default'.")
621 (defcustom org-export-html-style-include-default t
622 "Non-nil means, include the default style in exported HTML files.
623 The actual style is defined in `org-export-html-style-default' and should
624 not be modified. Use the variables `org-export-html-style' to add
625 your own style information."
626 :group
'org-export-html
629 (put 'org-export-html-style
'safe-local-variable
'booleanp
)
631 (defcustom org-export-html-style
""
632 "Org-wide style definitions for exported HTML files.
634 This variable needs to contain the full HTML structure to provide a style,
635 including the surrounding HTML tags. If you set the value of this variable,
636 you should consider to include definitions for the following classes:
637 title, todo, done, timestamp, timestamp-kwd, tag, target.
639 For example, a valid value would be:
641 <style type=\"text/css\">
643 p { font-weight: normal; color: gray; }
645 .title { text-align: center; }
646 .todo, .timestamp-kwd { color: red; }
647 .done { color: green; }
651 If you'd like to refer to en external style file, use something like
653 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
655 As the value of this option simply gets inserted into the HTML <head> header,
656 you can \"misuse\" it to add arbitrary text to the header.
657 See also the variable `org-export-html-style-extra'."
658 :group
'org-export-html
661 (put 'org-export-html-style
'safe-local-variable
'stringp
)
663 (defcustom org-export-html-style-extra
""
664 "Additional style information for HTML export.
665 The value of this variable is inserted into the HTML buffer right after
666 the value of `org-export-html-style'. Use this variable for per-file
667 settings of style information, and do not forget to surround the style
668 settings with <style>...</style> tags."
669 :group
'org-export-html
672 (put 'org-export-html-style-extra
'safe-local-variable
'stringp
)
674 (defcustom org-export-html-tag-class-prefix
""
675 "Prefix to clas names for TODO keywords.
676 Each tag gets a class given by the tag itself, with this prefix.
677 The default prefix is empty because it is nice to just use the keyword
678 as a class name. But if you get into conflicts with other, existing
679 CSS classes, then this prefic can be very useful."
680 :group
'org-export-html
683 (defcustom org-export-html-todo-kwd-class-prefix
""
684 "Prefix to clas names for TODO keywords.
685 Each TODO keyword gets a class given by the keyword itself, with this prefix.
686 The default prefix is empty because it is nice to just use the keyword
687 as a class name. But if you get into conflicts with other, existing
688 CSS classes, then this prefic can be very useful."
689 :group
'org-export-html
692 (defcustom org-export-html-title-format
"<h1 class=\"title\">%s</h1>\n"
693 "Format for typesetting the document title in HTML export."
694 :group
'org-export-html
697 (defcustom org-export-html-toplevel-hlevel
2
698 "The <H> level for level 1 headings in HTML export.
699 This is also important for the classes that will be wrapped around headlines
700 and outline structure. If this variable is 1, the top-level headlines will
701 be <h1>, and the corresponding classes will be outline-1, section-number-1,
702 and outline-text-1. If this is 2, all of these will get a 2 instead.
703 The default for this variable is 2, because we use <h1> for formatting the
705 :group
'org-export-html
708 (defcustom org-export-html-link-org-files-as-html t
709 "Non-nil means, make file links to `file.org' point to `file.html'.
710 When org-mode is exporting an org-mode file to HTML, links to
711 non-html files are directly put into a href tag in HTML.
712 However, links to other Org-mode files (recognized by the
713 extension `.org.) should become links to the corresponding html
714 file, assuming that the linked org-mode file will also be
716 When nil, the links still point to the plain `.org' file."
717 :group
'org-export-html
720 (defcustom org-export-html-inline-images
'maybe
721 "Non-nil means, inline images into exported HTML pages.
722 This is done using an <img> tag. When nil, an anchor with href is used to
723 link to the image. If this option is `maybe', then images in links with
724 an empty description will be inlined, while images with a description will
726 :group
'org-export-html
727 :type
'(choice (const :tag
"Never" nil
)
728 (const :tag
"Always" t
)
729 (const :tag
"When there is no description" maybe
)))
731 (defcustom org-export-html-inline-image-extensions
732 '("png" "jpeg" "jpg" "gif")
733 "Extensions of image files that can be inlined into HTML."
734 :group
'org-export-html
735 :type
'(repeat (string :tag
"Extension")))
738 (defcustom org-export-html-expand t
739 "Non-nil means, for HTML export, treat @<...> as HTML tag.
740 When nil, these tags will be exported as plain text and therefore
741 not be interpreted by a browser.
743 This option can also be set with the +OPTIONS line, e.g. \"@:nil\"."
744 :group
'org-export-html
747 (defcustom org-export-html-table-tag
748 "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
749 "The HTML tag that is used to start a table.
750 This must be a <table> tag, but you may change the options like
751 borders and spacing."
752 :group
'org-export-html
755 (defcustom org-export-table-header-tags
'("<th>" .
"</th>")
756 "The opening tag for table header fields.
757 This is customizable so that alignment options can be specified."
758 :group
'org-export-tables
759 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
761 (defcustom org-export-table-data-tags
'("<td>" .
"</td>")
762 "The opening tag for table data fields.
763 This is customizable so that alignment options can be specified."
764 :group
'org-export-tables
765 :type
'(cons (string :tag
"Opening tag") (string :tag
"Closing tag")))
767 (defcustom org-export-html-validation-link nil
768 "Non-nil means, add validationlink to postamble of HTML exported files."
769 :group
'org-export-html
771 (const :tag
"Nothing" nil
)
772 (const :tag
"XHTML 1.0" "<p class=\"xhtml-validation\"><a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a></p>")
773 (string :tag
"Specify full HTML")))
776 (defcustom org-export-html-with-timestamp nil
777 "If non-nil, write `org-export-html-html-helper-timestamp'
778 into the exported HTML text. Otherwise, the buffer will just be saved
780 :group
'org-export-html
783 (defcustom org-export-html-html-helper-timestamp
784 "<br/><br/><hr><p><!-- hhmts start --> <!-- hhmts end --></p>\n"
785 "The HTML tag used as timestamp delimiter for HTML-helper-mode."
786 :group
'org-export-html
789 (defgroup org-export-htmlize nil
790 "Options for processing examples with htmlize.el."
791 :tag
"Org Export Htmlize"
792 :group
'org-export-html
)
794 (defcustom org-export-htmlize-output-type
'inline-css
795 "Output type to be used by htmlize when formatting code snippets.
796 We use as default `inline-css', in order to make the resulting
797 HTML self-containing.
798 However, this will fail when using Emacs in batch mode for export, because
799 then no rich font definitions are in place. It will also not be good if
800 people with different Emacs setup contribute HTML files to a website,
801 because the fonts will represent the individual setups. In these cases,
802 it is much better to let Org/Htmlize assign classes only, and to use
803 a style file to define the look of these classes.
804 To get a start for your css file, start Emacs session nnd make sure that
805 all the faces you are interested in are defined, for example by loading files
806 in all modes you want. Then, use the command
807 \\[org-export-htmlize-generate-css] to extract class definitions."
808 :group
'org-export-htmlize
809 :type
'(choice (const css
) (const inline-css
)))
811 (defcustom org-export-htmlize-css-font-prefix
"org-"
812 "The prefix for CSS class names for htmlize font specifications."
813 :group
'org-export-htmlize
816 (defgroup org-export-icalendar nil
817 "Options specific for iCalendar export of Org-mode files."
818 :tag
"Org Export iCalendar"
821 (defcustom org-combined-agenda-icalendar-file
"~/org.ics"
822 "The file name for the iCalendar file covering all agenda files.
823 This file is created with the command \\[org-export-icalendar-all-agenda-files].
824 The file name should be absolute, the file will be overwritten without warning."
825 :group
'org-export-icalendar
828 (defcustom org-icalendar-combined-name
"OrgMode"
829 "Calendar name for the combined iCalendar representing all agenda files."
830 :group
'org-export-icalendar
833 (defcustom org-icalendar-use-deadline
'(event-if-not-todo todo-due
)
834 "Contexts where iCalendar export should use a deadline time stamp.
835 This is a list with several symbols in it. Valid symbol are:
837 event-if-todo Deadlines in TODO entries become calendar events.
838 event-if-not-todo Deadlines in non-TODO entries become calendar events.
839 todo-due Use deadlines in TODO entries as due-dates"
840 :group
'org-export-icalendar
841 :type
'(set :greedy t
842 (const :tag
"Deadlines in non-TODO entries become events"
844 (const :tag
"Deadline in TODO entries become events"
846 (const :tag
"Deadlines in TODO entries become due-dates"
849 (defcustom org-icalendar-use-scheduled
'(todo-start)
850 "Contexts where iCalendar export should use a scheduling time stamp.
851 This is a list with several symbols in it. Valid symbol are:
853 event-if-todo Scheduling time stamps in TODO entries become an event.
854 event-if-not-todo Scheduling time stamps in non-TODO entries become an event.
855 todo-start Scheduling time stamps in TODO entries become start date.
856 Some calendar applications show TODO entries only after
858 :group
'org-export-icalendar
859 :type
'(set :greedy t
861 "SCHEDULED timestamps in non-TODO entries become events"
863 (const :tag
"SCHEDULED timestamps in TODO entries become events"
865 (const :tag
"SCHEDULED in TODO entries become start date"
868 (defcustom org-icalendar-categories
'(local-tags category
)
869 "Items that should be entered into the categories field.
870 This is a list of symbols, the following are valid:
872 category The Org-mode category of the current file or tree
873 todo-state The todo state, if any
874 local-tags The tags, defined in the current line
875 all-tags All tags, including inherited ones."
876 :group
'org-export-icalendar
879 (const :tag
"The file or tree category" category
)
880 (const :tag
"The TODO state" todo-state
)
881 (const :tag
"Tags defined in current line" local-tags
)
882 (const :tag
"All tags, including inherited ones" all-tags
))))
884 (defcustom org-icalendar-include-todo nil
885 "Non-nil means, export to iCalendar files should also cover TODO items."
886 :group
'org-export-icalendar
888 (const :tag
"None" nil
)
889 (const :tag
"Unfinished" t
)
890 (const :tag
"All" all
)))
892 (defcustom org-icalendar-include-sexps t
893 "Non-nil means, export to iCalendar files should also cover sexp entries.
894 These are entries like in the diary, but directly in an Org-mode file."
895 :group
'org-export-icalendar
898 (defcustom org-icalendar-include-body
100
899 "Amount of text below headline to be included in iCalendar export.
900 This is a number of characters that should maximally be included.
901 Properties, scheduling and clocking lines will always be removed.
902 The text will be inserted into the DESCRIPTION field."
903 :group
'org-export-icalendar
905 (const :tag
"Nothing" nil
)
906 (const :tag
"Everything" t
)
907 (integer :tag
"Max characters")))
909 (defcustom org-icalendar-store-UID nil
910 "Non-nil means, store any created UIDs in properties.
911 The iCalendar standard requires that all entries have a unique identifier.
912 Org will create these identifiers as needed. When this variable is non-nil,
913 the created UIDs will be stored in the ID property of the entry. Then the
914 next time this entry is exported, it will be exported with the same UID,
915 superceding the previous form of it. This is essential for
916 synchronization services.
917 This variable is not turned on by default because we want to avoid creating
918 a property drawer in every entry if people are only playing with this feature,
919 or if they are only using it locally."
920 :group
'org-export-icalendar
925 ;;; Variables, constants, and parameter plists
927 (defconst org-level-max
20)
929 (defvar org-export-html-preamble nil
930 "Preamble, to be inserted just before <body>. Set by publishing functions.")
931 (defvar org-export-html-postamble nil
932 "Preamble, to be inserted just after </body>. Set by publishing functions.")
933 (defvar org-export-html-auto-preamble t
934 "Should default preamble be inserted? Set by publishing functions.")
935 (defvar org-export-html-auto-postamble t
936 "Should default postamble be inserted? Set by publishing functions.")
937 (defvar org-current-export-file nil
) ; dynamically scoped parameter
938 (defvar org-current-export-dir nil
) ; dynamically scoped parameter
939 (defvar org-export-opt-plist nil
940 "Contains the current option plist.")
942 (defconst org-export-plist-vars
943 '((:link-up nil org-export-html-link-up
)
944 (:link-home nil org-export-html-link-home
)
945 (:language nil org-export-default-language
)
946 (:keywords nil org-export-page-keywords
)
947 (:description nil org-export-page-description
)
948 (:customtime nil org-display-custom-times
)
949 (:headline-levels
"H" org-export-headline-levels
)
950 (:section-numbers
"num" org-export-with-section-numbers
)
951 (:section-number-format nil org-export-section-number-format
)
952 (:table-of-contents
"toc" org-export-with-toc
)
953 (:preserve-breaks
"\\n" org-export-preserve-breaks
)
954 (:archived-trees nil org-export-with-archived-trees
)
955 (:emphasize
"*" org-export-with-emphasize
)
956 (:sub-superscript
"^" org-export-with-sub-superscripts
)
957 (:special-strings
"-" org-export-with-special-strings
)
958 (:footnotes
"f" org-export-with-footnotes
)
959 (:drawers
"d" org-export-with-drawers
)
960 (:tags
"tags" org-export-with-tags
)
961 (:todo-keywords
"todo" org-export-with-todo-keywords
)
962 (:priority
"pri" org-export-with-priority
)
963 (:TeX-macros
"TeX" org-export-with-TeX-macros
)
964 (:LaTeX-fragments
"LaTeX" org-export-with-LaTeX-fragments
)
965 (:skip-before-1st-heading
"skip" org-export-skip-text-before-1st-heading
)
966 (:fixed-width
":" org-export-with-fixed-width
)
967 (:timestamps
"<" org-export-with-timestamps
)
968 (:author-info
"author" org-export-author-info
)
969 (:creator-info
"creator" org-export-creator-info
)
970 (:time-stamp-file
"timestamp" org-export-time-stamp-file
)
971 (:tables
"|" org-export-with-tables
)
972 (:table-auto-headline nil org-export-highlight-first-table-line
)
973 (:style-include-default nil org-export-html-style-include-default
)
974 (:style-include-scripts nil org-export-html-style-include-scripts
)
975 (:style nil org-export-html-style
)
976 (:style-extra nil org-export-html-style-extra
)
977 (:agenda-style nil org-agenda-export-html-style
)
978 (:convert-org-links nil org-export-html-link-org-files-as-html
)
979 (:inline-images nil org-export-html-inline-images
)
980 (:html-extension nil org-export-html-extension
)
981 (:html-table-tag nil org-export-html-table-tag
)
982 (:expand-quoted-html
"@" org-export-html-expand
)
983 (:timestamp nil org-export-html-with-timestamp
)
984 (:publishing-directory nil org-export-publishing-directory
)
985 (:preamble nil org-export-html-preamble
)
986 (:postamble nil org-export-html-postamble
)
987 (:auto-preamble nil org-export-html-auto-preamble
)
988 (:auto-postamble nil org-export-html-auto-postamble
)
989 (:author nil user-full-name
)
990 (:email nil user-mail-address
)
991 (:select-tags nil org-export-select-tags
)
992 (:exclude-tags nil org-export-exclude-tags
))
993 "List of properties that represent export/publishing variables.
994 Each element is a list of 3 items:
995 1. The property that is used internally, and also for org-publish-project-alist
996 2. The string that can be used in the OPTION lines to set this option,
997 or nil if this option cannot be changed in this way
998 3. The customization variable that sets the default for this option."
1002 (defun org-default-export-plist ()
1003 "Return the property list with default settings for the export variables."
1004 (let ((l org-export-plist-vars
) rtn e
)
1005 (while (setq e
(pop l
))
1006 (setq rtn
(cons (car e
) (cons (symbol-value (nth 2 e
)) rtn
))))
1009 (defvar org-export-inbuffer-options-extra nil
1010 "List of additional in-buffer options that should be detected.
1011 Just before export, the buffer is scanned for options like #+TITLE, #+EMAIL,
1012 etc. Extensions can add to this list to get their options detected, and they
1013 can then add a function to `org-export-options-filters' to process these
1015 Each element in this list must be a list, with the in-buffer keyword as car,
1016 and a property (a symbol) as the next element. All occurrences of the
1017 keyword will be found, the values concatenated with a space character
1018 in between, and the result stored in the export options property list.")
1020 (defvar org-export-options-filters nil
1021 "Functions to be called to finalize the export/publishing options.
1022 All these options are stored in a property list, and each of the functions
1023 in this hook gets a chance to modify this property list. Each function
1024 must accept the property list as an argument, and must return the (possibly
1027 ;; FIXME: should we fold case here?
1028 (defun org-infile-export-plist ()
1029 "Return the property list with file-local settings for export."
1033 (goto-char (point-min))
1034 (let ((re (org-make-options-regexp
1036 '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
1037 "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE" "LATEX_HEADER"
1038 "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS"
1039 "KEYWORDS" "DESCRIPTION")
1040 (mapcar 'car org-export-inbuffer-options-extra
))))
1041 p key val text options a pr style
1043 ext-setup-or-nil setup-contents
(start 0))
1044 (while (or (and ext-setup-or-nil
1045 (string-match re ext-setup-or-nil start
)
1046 (setq start
(match-end 0)))
1047 (and (setq ext-setup-or-nil nil start
0)
1048 (re-search-forward re nil t
)))
1049 (setq key
(upcase (org-match-string-no-properties 1 ext-setup-or-nil
))
1050 val
(org-match-string-no-properties 2 ext-setup-or-nil
))
1052 ((setq a
(assoc key org-export-inbuffer-options-extra
))
1054 (setq p
(plist-put p pr
(concat (plist-get p pr
) " " val
))))
1055 ((string-equal key
"TITLE") (setq p
(plist-put p
:title val
)))
1056 ((string-equal key
"AUTHOR")(setq p
(plist-put p
:author val
)))
1057 ((string-equal key
"EMAIL") (setq p
(plist-put p
:email val
)))
1058 ((string-equal key
"DATE") (setq p
(plist-put p
:date val
)))
1059 ((string-equal key
"KEYWORDS") (setq p
(plist-put p
:keywords val
)))
1060 ((string-equal key
"DESCRIPTION")
1061 (setq p
(plist-put p
:description val
)))
1062 ((string-equal key
"LANGUAGE") (setq p
(plist-put p
:language val
)))
1063 ((string-equal key
"STYLE")
1064 (setq style
(concat style
"\n" val
)))
1065 ((string-equal key
"LATEX_HEADER")
1066 (setq latex-header
(concat latex-header
"\n" val
)))
1067 ((string-equal key
"TEXT")
1068 (setq text
(if text
(concat text
"\n" val
) val
)))
1069 ((string-equal key
"OPTIONS")
1070 (setq options
(concat val
" " options
)))
1071 ((string-equal key
"LINK_UP")
1072 (setq p
(plist-put p
:link-up val
)))
1073 ((string-equal key
"LINK_HOME")
1074 (setq p
(plist-put p
:link-home val
)))
1075 ((string-equal key
"EXPORT_SELECT_TAGS")
1076 (setq p
(plist-put p
:select-tags
(org-split-string val
))))
1077 ((string-equal key
"EXPORT_EXCLUDE_TAGS")
1078 (setq p
(plist-put p
:exclude-tags
(org-split-string val
))))
1079 ((equal key
"SETUPFILE")
1080 (setq setup-contents
(org-file-contents
1082 (org-remove-double-quotes
1085 (if (not ext-setup-or-nil
)
1086 (setq ext-setup-or-nil setup-contents start
0)
1087 (setq ext-setup-or-nil
1088 (concat (substring ext-setup-or-nil
0 start
)
1089 "\n" setup-contents
"\n"
1090 (substring ext-setup-or-nil start
)))))))
1091 (setq p
(plist-put p
:text text
))
1092 (when style
(setq p
(plist-put p
:style-extra style
)))
1094 (setq p
(plist-put p
:latex-header-extra
(substring latex-header
1))))
1096 (setq p
(org-export-add-options-to-plist p options
)))
1097 ;; Add macro definitions
1098 (goto-char (point-min))
1099 (while (re-search-forward
1100 "^#\\+macro:[ \t]+\\([-a-zA-Z0-9_]+\\)[ \t]+\\(.*?[ \t]*$\\)"
1102 (setq p
(plist-put p
(intern (concat ":macro-"
1103 (downcase (match-string 1))))
1107 (defun org-export-add-options-to-plist (p options
)
1108 "Parse an OPTIONS line and set values in the property list P."
1111 (let ((op org-export-plist-vars
))
1112 (while (setq o
(pop op
))
1114 (string-match (concat (regexp-quote (nth 1 o
))
1115 ":\\([^ \t\n\r;,.]*\\)")
1117 (setq p
(plist-put p
(car o
)
1118 (car (read-from-string
1119 (match-string 1 options
))))))))))
1122 (defun org-export-add-subtree-options (p pos
)
1123 "Add options in subtree at position POS to property list P."
1126 (when (org-at-heading-p)
1128 ;; This is actually read in `org-export-get-title-from-subtree'
1129 ;; (when (setq a (org-entry-get pos "EXPORT_TITLE"))
1130 ;; (setq p (plist-put p :title a)))
1131 (when (setq a
(org-entry-get pos
"EXPORT_TEXT"))
1132 (setq p
(plist-put p
:text a
)))
1133 (when (setq a
(org-entry-get pos
"EXPORT_OPTIONS"))
1134 (setq p
(org-export-add-options-to-plist p a
)))))
1137 (defun org-export-directory (type plist
)
1138 (let* ((val (plist-get plist
:publishing-directory
))
1139 (dir (if (listp val
)
1140 (or (cdr (assoc type val
)) ".")
1144 (defun org-export-process-option-filters (plist)
1145 (let ((functions org-export-options-filters
) f
)
1146 (while (setq f
(pop functions
))
1147 (setq plist
(funcall f plist
))))
1151 (defun org-export (&optional arg
)
1152 "Export dispatcher for Org-mode.
1153 When `org-export-run-in-background' is non-nil, try to run the command
1154 in the background. This will be done only for commands that write
1155 to a file. For details see the docstring of `org-export-run-in-background'.
1157 The prefix argument ARG will be passed to the exporter. However, if
1158 ARG is a double universal prefix `C-u C-u', that means to inverse the
1159 value of `org-export-run-in-background'."
1161 (let* ((bg (org-xor (equal arg
'(16)) org-export-run-in-background
))
1162 (help "[t] insert the export option template
1163 \[v] limit export to visible part of outline tree
1165 \[a] export as ASCII
1167 \[h] export as HTML [H] to temporary buffer [R] export region
1168 \[b] export as HTML and open in browser
1170 \[l] export as LaTeX [L] to temporary buffer
1171 \[p] export as LaTeX and process to PDF
1172 \[d] export as LaTeX, process to PDF, and open the resulting PDF document
1174 \[D] export as DocBook
1175 \[V] export as DocBook, process to PDF, and open the resulting PDF document
1179 \[i] export current file as iCalendar file
1180 \[I] export all agenda files as iCalendar files
1181 \[c] export agenda files into combined iCalendar file
1183 \[F] publish current file [P] publish current project
1184 \[X] publish a project... [A] publish all projects")
1186 '((?t org-insert-export-options-template nil
)
1187 (?v org-export-visible nil
)
1188 (?a org-export-as-ascii t
)
1189 (?h org-export-as-html t
)
1190 (?b org-export-as-html-and-open t
)
1191 (?H org-export-as-html-to-buffer nil
)
1192 (?R org-export-region-as-html nil
)
1193 (?x org-export-as-xoxo t
)
1194 (?D org-export-as-docbook t
)
1195 (?V org-export-as-docbook-pdf-and-open t
)
1196 (?l org-export-as-latex t
)
1197 (?p org-export-as-pdf t
)
1198 (?d org-export-as-pdf-and-open t
)
1199 (?L org-export-as-latex-to-buffer nil
)
1200 (?i org-export-icalendar-this-file t
)
1201 (?I org-export-icalendar-all-agenda-files t
)
1202 (?c org-export-icalendar-combine-agenda-files t
)
1203 (?F org-publish-current-file t
)
1204 (?P org-publish-current-project t
)
1206 (?A org-publish-all t
)))
1209 (save-window-excursion
1210 (delete-other-windows)
1211 (with-output-to-temp-buffer "*Org Export/Publishing Help*"
1213 (org-fit-window-to-buffer (get-buffer-window
1214 "*Org Export/Publishing Help*"))
1215 (message "Select command: ")
1216 (setq r1
(read-char-exclusive))))
1217 (setq r2
(if (< r1
27) (+ r1
96) r1
))
1218 (unless (setq ass
(assq r2 cmds
))
1219 (error "No command associated with key %c" r1
))
1220 (if (and bg
(nth 2 ass
)
1221 (not (buffer-base-buffer))
1222 (not (org-region-active-p)))
1223 ;; execute in background
1224 (let ((p (start-process
1225 (concat "Exporting " (file-name-nondirectory (buffer-file-name)))
1227 (expand-file-name invocation-name invocation-directory
)
1230 "--eval" "(require 'org-exp)"
1231 "--eval" "(setq org-wait .2)"
1233 "-f" (symbol-name (nth 1 ass
)))))
1234 (set-process-sentinel p
'org-export-process-sentinel
)
1235 (message "Background process \"%s\": started" p
))
1236 ;; background processing not requested, or not possible
1237 (call-interactively (nth 1 ass
)))))
1239 (defun org-export-process-sentinel (process status
)
1240 (if (string-match "\n+\\'" status
)
1241 (setq status
(substring status
0 -
1)))
1242 (message "Background process \"%s\": %s" process status
))
1244 (defconst org-html-entities
1285 ("Aring") ("AA".
"Å")
1374 ("varepsilon".
"ε")
1387 ("sigmaf") ("varsigma".
"ς")
1395 ("thetasym") ("vartheta".
"ϑ")
1398 ("bull") ("bullet".
"•")
1399 ("hellip") ("dots".
"…")
1409 ("larr") ("leftarrow".
"←") ("gets".
"←")
1410 ("uarr") ("uparrow".
"↑")
1411 ("rarr") ("to".
"→") ("rightarrow".
"→")
1412 ("darr")("downarrow".
"↓")
1413 ("harr") ("leftrightarrow".
"↔")
1414 ("crarr") ("hookleftarrow".
"↵") ; has round hook, not quite CR
1415 ("lArr") ("Leftarrow".
"⇐")
1416 ("uArr") ("Uparrow".
"⇑")
1417 ("rArr") ("Rightarrow".
"⇒")
1418 ("dArr") ("Downarrow".
"⇓")
1419 ("hArr") ("Leftrightarrow".
"⇔")
1421 ("part") ("partial".
"∂")
1422 ("exist") ("exists".
"∃")
1423 ("empty") ("emptyset".
"∅")
1425 ("isin") ("in".
"∈")
1431 ("lowast") ("ast".
"∗")
1433 ("prop") ("proptp".
"∝")
1434 ("infin") ("infty".
"∞")
1435 ("ang") ("angle".
"∠")
1436 ("and") ("wedge".
"∧")
1437 ("or") ("vee".
"∨")
1443 ("cong") ("simeq".
"≅")
1444 ("asymp")("approx".
"≈")
1445 ("ne") ("neq".
"≠")
1449 ("sub") ("subset".
"⊂")
1450 ("sup") ("supset".
"⊃")
1457 ("sdot") ("cdot".
"⋅")
1464 ("loz") ("Diamond".
"◊")
1465 ("spades") ("spadesuit".
"♠")
1466 ("clubs") ("clubsuit".
"♣")
1467 ("hearts") ("diamondsuit".
"♥")
1468 ("diams") ("diamondsuit".
"♦")
1469 ("smile".
"☺") ("blacksmile".
"☻") ("sad".
"☹")
1536 "Entities for TeX->HTML translation.
1537 Entries can be like (\"ent\"), in which case \"\\ent\" will be translated to
1538 \"&ent;\". An entry can also be a dotted pair like (\"ent\".\"&other;\").
1539 In that case, \"\\ent\" will be translated to \"&other;\".
1540 The list contains HTML entities for Latin-1, Greek and other symbols.
1541 It is supplemented by a number of commonly used TeX macros with appropriate
1542 translations. There is currently no way for users to extend this.")
1544 ;;; General functions for all backends
1546 (defvar org-export-target-aliases nil
1547 "Alist of targets with invisible aliases.")
1548 (defvar org-export-code-refs nil
1549 "Alist of code references and line numbers")
1551 (defun org-export-preprocess-string (string &rest parameters
)
1552 "Cleanup STRING so that that the true exported has a more consistent source.
1553 This function takes STRING, which should be a buffer-string of an org-file
1554 to export. It then creates a temporary buffer where it does its job.
1555 The result is then again returned as a string, and the exporter works
1556 on this string to produce the exported version."
1558 (let* ((htmlp (plist-get parameters
:for-html
))
1559 (asciip (plist-get parameters
:for-ascii
))
1560 (latexp (plist-get parameters
:for-LaTeX
))
1561 (docbookp (plist-get parameters
:for-docbook
))
1562 (backend (cond (htmlp 'html
)
1565 (docbookp 'docbook
)))
1566 (archived-trees (plist-get parameters
:archived-trees
))
1567 (inhibit-read-only t
)
1568 (drawers org-drawers
)
1569 (outline-regexp "\\*+ ")
1572 (setq org-export-target-aliases nil
)
1573 (setq org-export-code-refs nil
)
1575 (with-current-buffer (get-buffer-create " org-mode-tmp")
1578 (setq case-fold-search t
)
1580 ;; Remove license-to-kill stuff
1581 ;; The caller marks some stuff for killing, stuff that has been
1582 ;; used to create the page title, for example.
1583 (org-export-kill-licensed-text)
1585 (let ((org-inhibit-startup t
)) (org-mode))
1586 (setq case-fold-search t
)
1589 (run-hooks 'org-export-preprocess-hook
)
1591 ;; Process the macros
1592 (org-export-preprocess-apply-macros)
1593 (run-hooks 'org-export-preprocess-after-macros-hook
)
1595 (untabify (point-min) (point-max))
1597 ;; Handle include files, and call a hook
1598 (org-export-handle-include-files)
1599 (run-hooks 'org-export-preprocess-after-include-files-hook
)
1601 ;; Get rid of archived trees
1602 (org-export-remove-archived-trees archived-trees
)
1604 ;; Remove comment environment and comment subtrees
1605 (org-export-remove-comment-blocks-and-subtrees)
1607 ;; Get rid of excluded trees, and call a hook
1608 (org-export-handle-export-tags (plist-get parameters
:select-tags
)
1609 (plist-get parameters
:exclude-tags
))
1610 (run-hooks 'org-export-preprocess-after-tree-selection-hook
)
1612 ;; Handle source code snippets
1613 (org-export-replace-src-segments-and-examples backend
)
1615 ;; Protect short examples marked by a leading colon
1616 (org-export-protect-colon-examples)
1618 ;; Normalize footnotes
1619 (when (plist-get parameters
:footnotes
)
1620 (org-footnote-normalize nil t
))
1622 ;; Find all headings and compute the targets for them
1623 (setq target-alist
(org-export-define-heading-targets target-alist
))
1625 ;; Get rid of drawers
1626 (org-export-remove-or-extract-drawers drawers
1627 (plist-get parameters
:drawers
))
1629 ;; Get the correct stuff before the first headline
1630 (when (plist-get parameters
:skip-before-1st-heading
)
1631 (goto-char (point-min))
1632 (when (re-search-forward "^\\(#.*\n\\)?\\*+[ \t]" nil t
)
1633 (delete-region (point-min) (match-beginning 0))
1634 (goto-char (point-min))
1636 (when (plist-get parameters
:add-text
)
1637 (goto-char (point-min))
1638 (insert (plist-get parameters
:add-text
) "\n"))
1640 ;; Remove todo-keywords before exporting, if the user has requested so
1641 (org-export-remove-headline-metadata parameters
)
1643 ;; Find targets in comments and move them out of comments,
1644 ;; but mark them as targets that should be invisible
1645 (setq target-alist
(org-export-handle-invisible-targets target-alist
))
1647 ;; Select and protect backend specific stuff, throw away stuff
1648 ;; that is specific for other backends
1649 (org-export-select-backend-specific-text backend
)
1651 ;; Protect quoted subtrees
1652 (org-export-protect-quoted-subtrees)
1654 ;; Remove clock lines
1655 (org-export-remove-clock-lines)
1657 ;; Protect verbatim elements
1658 (org-export-protect-verbatim)
1660 ;; Blockquotes, verse, and center
1661 (org-export-mark-blockquote-verse-center)
1663 ;; Remove timestamps, if the user has requested so
1664 (unless (plist-get parameters
:timestamps
)
1665 (org-export-remove-timestamps))
1667 ;; Attach captions to the correct object
1668 (setq target-alist
(org-export-attach-captions-and-attributes
1669 backend target-alist
))
1671 ;; Find matches for radio targets and turn them into internal links
1672 (org-export-mark-radio-links)
1674 ;; Find all links that contain a newline and put them into a single line
1675 (org-export-concatenate-multiline-links)
1677 ;; Normalize links: Convert angle and plain links into bracket links
1678 ;; and expand link abbreviations
1679 (org-export-normalize-links)
1681 ;; Find all internal links. If they have a fuzzy match (i.e. not
1682 ;; a *dedicated* target match, let the link point to the
1683 ;; corresponding section.
1684 (org-export-target-internal-links target-alist
)
1686 ;; Find multiline emphasis and put them into single line
1687 (when (plist-get parameters
:emph-multiline
)
1688 (org-export-concatenate-multiline-emphasis))
1690 ;; Remove special table lines
1691 (when org-export-table-remove-special-lines
1692 (org-export-remove-special-table-lines))
1695 (run-hooks 'org-export-preprocess-before-backend-specifics-hook
)
1697 ;; LaTeX-specific preprocessing
1699 (require 'org-export-latex nil
)
1700 (org-export-latex-preprocess parameters
))
1702 ;; ASCII-specific preprocessing
1704 (org-export-ascii-preprocess))
1706 ;; HTML-specific preprocessing
1708 (org-export-html-preprocess parameters
))
1710 ;; DocBook-specific preprocessing
1712 (require 'org-docbook nil
)
1713 (org-export-docbook-preprocess parameters
))
1715 ;; Remove or replace comments
1716 (org-export-handle-comments (plist-get parameters
:comments
))
1718 ;; Run the final hook
1719 (run-hooks 'org-export-preprocess-final-hook
)
1721 (setq rtn
(buffer-string)))
1722 (kill-buffer " org-mode-tmp")
1725 (defun org-export-kill-licensed-text ()
1726 "Remove all text that is marked with a :org-license-to-kill property."
1728 (while (setq p
(text-property-any (point-min) (point-max)
1729 :org-license-to-kill t
))
1731 p
(or (next-single-property-change p
:org-license-to-kill
)
1734 (defun org-export-define-heading-targets (target-alist)
1735 "Find all headings and define the targets for them.
1736 The new targets are added to TARGET-ALIST, which is also returned."
1737 (goto-char (point-min))
1738 (org-init-section-numbers)
1739 (let ((re (concat "^" org-outline-regexp
1740 "\\| [ \t]*:ID:[ \t]*\\([^ \t\r\n]+\\)"))
1741 level target last-section-target a
)
1742 (while (re-search-forward re nil t
)
1745 (push (cons (org-match-string-no-properties 1)
1746 target
) target-alist
)
1747 (setq a
(or (assoc last-section-target org-export-target-aliases
)
1749 (push (list last-section-target
)
1750 org-export-target-aliases
)
1751 (car org-export-target-aliases
))))
1752 (push (caar target-alist
) (cdr a
)))
1753 (setq level
(org-reduced-level
1754 (save-excursion (goto-char (point-at-bol))
1755 (org-outline-level))))
1756 (setq target
(org-solidify-link-text
1757 (format "sec-%s" (org-section-number level
))))
1758 (setq last-section-target target
)
1759 (push (cons target target
) target-alist
)
1760 (add-text-properties
1761 (point-at-bol) (point-at-eol)
1762 (list 'target target
)))))
1765 (defun org-export-handle-invisible-targets (target-alist)
1766 "Find targets in comments and move them out of comments.
1767 Mark them as invisible targets."
1769 (goto-char (point-min))
1770 (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t
)
1771 ;; Check if the line before or after is a headline with a target
1772 (if (setq target
(or (get-text-property (point-at-bol 0) 'target
)
1773 (get-text-property (point-at-bol 2) 'target
)))
1775 ;; use the existing target in a neighboring line
1776 (setq tmp
(match-string 2))
1778 (and (looking-at "\n") (delete-char 1))
1779 (push (cons (setq tmp
(org-solidify-link-text tmp
)) target
)
1781 (setq a
(or (assoc target org-export-target-aliases
)
1783 (push (list target
) org-export-target-aliases
)
1784 (car org-export-target-aliases
))))
1786 ;; Make an invisible target
1787 (replace-match "\\1(INVISIBLE)"))))
1790 (defun org-export-target-internal-links (target-alist)
1791 "Find all internal links and assign targets to them.
1792 If a link has a fuzzy match (i.e. not a *dedicated* target match),
1793 let the link point to the corresponding section.
1794 This function also handles the id links, if they have a match in
1796 (goto-char (point-min))
1797 (while (re-search-forward org-bracket-link-regexp nil t
)
1799 (let* ((md (match-data))
1800 (desc (match-end 2))
1801 (link (org-link-unescape (match-string 1)))
1802 (slink (org-solidify-link-text link
))
1803 found props pos cref
1806 ((= (string-to-char link
) ?
#)
1807 ;; user wants exactly this link
1809 ((cdr (assoc slink target-alist
)))
1810 ((and (string-match "^id:" link
)
1811 (cdr (assoc (substring link
3) target-alist
))))
1812 ((string-match "^(\\(.*\\))$" link
)
1813 (setq cref
(match-string 1 link
))
1814 (concat "coderef:" cref
))
1815 ((string-match org-link-types-re link
) nil
)
1816 ((or (file-name-absolute-p link
)
1817 (string-match "^\\." link
))
1821 (setq found
(condition-case nil
(org-link-search link
)
1824 (or (org-on-heading-p)
1825 (not (eq found
'dedicated
))))
1826 (or (get-text-property (point) 'target
)
1829 (1- (or (previous-single-property-change
1830 (point) 'target
) 0)))
1834 (goto-char (match-beginning 1))
1835 (setq props
(text-properties-at (point)))
1836 (delete-region (match-beginning 1) (match-end 1))
1839 (unless desc
(insert "][" link
))
1840 (add-text-properties pos
(point) props
))))))
1842 (defun org-export-remove-or-extract-drawers (all-drawers exp-drawers
)
1843 "Remove drawers, or extract the content.
1844 ALL-DRAWERS is a list of all drawer names valid in the current buffer.
1845 EXP-DRAWERS can be t to keep all drawer contents, or a list of drawers
1846 whose content to keep."
1847 (unless (eq t exp-drawers
)
1848 (goto-char (point-min))
1849 (let ((re (concat "^[ \t]*:\\("
1852 (org-delete-all exp-drawers
1853 (copy-sequence all-drawers
))
1855 "\\):[ \t]*\n\\([^\000]*?\n\\)?[ \t]*:END:[ \t]*\n")))
1856 (while (re-search-forward re nil t
)
1858 (replace-match ""))))))
1860 (defun org-export-handle-export-tags (select-tags exclude-tags
)
1861 "Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS.
1862 Both arguments are lists of tags.
1863 If any of SELECT-TAGS is found, all trees not marked by a SELECT-TAG
1865 After that, all subtrees that are marked by EXCLUDE-TAGS will be
1867 (remove-text-properties (point-min) (point-max) '(:org-delete t
))
1868 (let* ((re-sel (concat ":\\(" (mapconcat 'regexp-quote
1871 (re-excl (concat ":\\(" (mapconcat 'regexp-quote
1875 (goto-char (point-min))
1876 (when (and select-tags
1878 (concat "^\\*+[ \t].*" re-sel
"[^ \t\n]*[ \t]*$") nil t
))
1879 ;; At least one tree is marked for export, this means
1880 ;; all the unmarked stuff needs to go.
1881 ;; Dig out the trees that should be exported
1882 (goto-char (point-min))
1883 (outline-next-heading)
1885 (put-text-property beg
(point-max) :org-delete t
)
1886 (while (re-search-forward re-sel nil t
)
1887 (when (org-on-heading-p)
1888 (org-back-to-heading)
1889 (remove-text-properties
1890 (max (1- (point)) (point-min))
1891 (setq cont
(save-excursion (org-end-of-subtree t t
)))
1893 (while (and (org-up-heading-safe)
1894 (get-text-property (point) :org-delete
))
1895 (remove-text-properties (max (1- (point)) (point-min))
1896 (point-at-eol) '(:org-delete t
)))
1898 ;; Remove the trees explicitly marked for noexport
1900 (goto-char (point-min))
1901 (while (re-search-forward re-excl nil t
)
1902 (when (org-at-heading-p)
1903 (org-back-to-heading t
)
1905 (org-end-of-subtree t
)
1906 (delete-region beg
(point)))))
1907 ;; Remove everything that is now still marked for deletion
1908 (goto-char (point-min))
1909 (while (setq beg
(text-property-any (point-min) (point-max) :org-delete t
))
1910 (setq end
(or (next-single-property-change beg
:org-delete
)
1912 (delete-region beg end
))))
1914 (defun org-export-remove-archived-trees (export-archived-trees)
1915 "Remove archived trees.
1916 When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported.
1917 When it is t, the entire archived tree will be exported.
1918 When it is nil the entire tree including the headline will be removed
1920 (let ((re-archive (concat ":" org-archive-tag
":"))
1922 (when (not (eq export-archived-trees t
))
1923 (goto-char (point-min))
1924 (while (re-search-forward re-archive nil t
)
1925 (if (not (org-on-heading-p t
))
1926 (org-end-of-subtree t
)
1927 (beginning-of-line 1)
1928 (setq a
(if export-archived-trees
1929 (1+ (point-at-eol)) (point))
1930 b
(org-end-of-subtree t
))
1931 (if (> b a
) (delete-region a b
)))))))
1933 (defun org-export-remove-headline-metadata (opts)
1934 "Remove meta data from the headline, according to user options."
1935 (let ((re org-complex-heading-regexp
)
1936 (todo (plist-get opts
:todo-keywords
))
1937 (tags (plist-get opts
:tags
))
1938 (pri (plist-get opts
:priority
))
1941 (setq elts
(delq nil
(list 1 (if todo
2) (if pri
3) 4 (if tags
5))))
1942 (when (or (not todo
) (not tags
) (not pri
))
1943 (goto-char (point-min))
1944 (while (re-search-forward re nil t
)
1946 (setq rpl
(mapconcat (lambda (i) (if (match-end i
) (match-string i
) ""))
1948 (replace-match rpl t t
))))))
1950 (defun org-export-remove-timestamps ()
1951 "Remove timestamps and keywords for export."
1952 (while (re-search-forward org-maybe-keyword-time-regexp nil t
)
1955 (unless (save-match-data (org-at-table-p))
1957 (beginning-of-line 1)
1958 (if (looking-at "[- \t]*\\(=>[- \t0-9:]*\\)?[ \t]*\n")
1959 (replace-match ""))))))
1961 (defun org-export-remove-clock-lines ()
1962 "Remove clock lines for export."
1963 (let ((re (concat "^[ \t]*" org-clock-string
".*\n?")))
1964 (while (re-search-forward re nil t
)
1966 (replace-match "")))))
1968 (defun org-export-protect-quoted-subtrees ()
1969 "Mark quoted subtrees with the protection property."
1970 (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string
"\\>")))
1971 (goto-char (point-min))
1972 (while (re-search-forward re-quote nil t
)
1973 (goto-char (match-beginning 0))
1975 (add-text-properties (point) (org-end-of-subtree t
)
1976 '(org-protected t
)))))
1978 (defun org-export-protect-verbatim ()
1979 "Mark verbatim snippets with the protection property."
1980 (goto-char (point-min))
1981 (while (re-search-forward org-verbatim-re nil t
)
1982 (add-text-properties (match-beginning 4) (match-end 4)
1984 (goto-char (1+ (match-end 4)))))
1986 (defun org-export-protect-colon-examples ()
1987 "Protect lines starting with a colon."
1988 (goto-char (point-min))
1989 (let ((re "^[ \t]*:\\([ \t]\\|$\\)") beg
)
1990 (while (re-search-forward re nil t
)
1991 (beginning-of-line 1)
1993 (while (looking-at re
)
1995 (or (eobp) (forward-char 1)))
1996 (add-text-properties beg
(if (bolp) (1- (point)) (point))
1997 '(org-protected t
)))))
1999 (defun org-export-select-backend-specific-text (backend)
2001 '((docbook "DOCBOOK" "BEGIN_DOCBOOK" "END_DOCBOOK")
2002 (html "HTML" "BEGIN_HTML" "END_HTML")
2003 (ascii "ASCII" "BEGIN_ASCII" "END_ASCII")
2004 (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
2005 (case-fold-search t
)
2009 (setq fmt
(pop formatters
))
2010 (when (eq (car fmt
) backend
)
2011 ;; This is selected code, put it into the file for real
2012 (goto-char (point-min))
2013 (while (re-search-forward (concat "^#\\+" (cadr fmt
)
2014 ":[ \t]*\\(.*\\)") nil t
)
2015 (replace-match "\\1" t
)
2016 (add-text-properties
2017 (point-at-bol) (min (1+ (point-at-eol)) (point-max))
2018 '(org-protected t
))))
2019 (goto-char (point-min))
2020 (while (re-search-forward
2022 (caddr fmt
) "\\>.*\\(\\(\n.*\\)*?\n\\)#\\+"
2023 (cadddr fmt
) "\\>.*\n?") nil t
)
2024 (if (eq (car fmt
) backend
)
2026 (add-text-properties (match-beginning 1) (1+ (match-end 1))
2028 ;; No, this is for a different backend, kill it
2029 (delete-region (match-beginning 0) (match-end 0)))))))
2031 (defun org-export-mark-blockquote-verse-center ()
2032 "Mark block quote and verse environments with special cookies.
2033 These special cookies will later be interpreted by the backend."
2035 (goto-char (point-min))
2036 (while (re-search-forward "^#\\+\\(begin\\|end\\)_\\(block\\)?quote\\>.*"
2038 (replace-match (if (equal (downcase (match-string 1)) "end")
2039 "ORG-BLOCKQUOTE-END" "ORG-BLOCKQUOTE-START")
2042 (goto-char (point-min))
2043 (while (re-search-forward "^#\\+\\(begin\\|end\\)_verse\\>.*" nil t
)
2044 (replace-match (if (equal (downcase (match-string 1)) "end")
2045 "ORG-VERSE-END" "ORG-VERSE-START")
2048 (goto-char (point-min))
2049 (while (re-search-forward "^#\\+\\(begin\\|end\\)_center\\>.*" nil t
)
2050 (replace-match (if (equal (downcase (match-string 1)) "end")
2051 "ORG-CENTER-END" "ORG-CENTER-START")
2054 (defun org-export-attach-captions-and-attributes (backend target-alist
)
2055 "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties.
2056 If the next thing following is a table, add the text properties to the first
2057 table line. If it is a link, add it to the line containing the link."
2058 (goto-char (point-min))
2059 (remove-text-properties (point-min) (point-max)
2060 '(org-caption nil org-attributes nil
))
2061 (let ((case-fold-search t
)
2062 (re (concat "^#\\+caption:[ \t]+\\(.*\\)"
2064 "^#\\+attr_" (symbol-name backend
) ":[ \t]+\\(.*\\)"
2066 "^#\\+label:[ \t]+\\(.*\\)"
2070 "^[ \t]*\\[\\[.*\\]\\][ \t]*$"))
2072 (while (re-search-forward re nil t
)
2075 (setq cap
(concat cap
(if cap
" " "") (org-trim (match-string 1)))))
2077 (setq attr
(concat attr
(if attr
" " "") (org-trim (match-string 2)))))
2079 (setq label
(org-trim (match-string 3))))
2081 (add-text-properties (point-at-bol) (point-at-eol)
2082 (list 'org-caption cap
2083 'org-attributes attr
2085 (if label
(push (cons label label
) target-alist
))
2086 (setq cap nil attr nil label nil
)))))
2089 (defun org-export-remove-comment-blocks-and-subtrees ()
2090 "Remove the comment environment, and also commented subtrees."
2091 (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string
"\\>"))
2092 (case-fold-search nil
))
2093 ;; Remove comment environment
2094 (goto-char (point-min))
2095 (while (re-search-forward
2096 "^#\\+BEGIN_COMMENT[ \t]*\n[^\000]*?^#\\+END_COMMENT\\>.*" nil t
)
2097 (replace-match "" t t
))
2098 ;; Remove subtrees that are commented
2099 (goto-char (point-min))
2100 (while (re-search-forward re-commented nil t
)
2101 (goto-char (match-beginning 0))
2102 (delete-region (point) (org-end-of-subtree t
)))))
2104 (defun org-export-handle-comments (commentsp)
2105 "Remove comments, or convert to backend-specific format.
2106 COMMENTSP can be a format string for publishing comments.
2107 When it is nil, all comments will be removed."
2108 (let ((re "^#\\(.*\n?\\)")
2110 (goto-char (point-min))
2111 (while (or (looking-at re
)
2112 (re-search-forward re nil t
))
2113 (setq pos
(match-beginning 0))
2115 (progn (add-text-properties
2116 (match-beginning 0) (match-end 0) '(org-protected t
))
2117 (replace-match (format commentsp
(match-string 1)) t t
))
2118 (goto-char (1+ pos
))
2121 (goto-char (max (point-min) (1- pos
))))))))
2123 (defun org-export-mark-radio-links ()
2124 "Find all matches for radio targets and turn them into internal links."
2125 (let ((re-radio (and org-target-link-regexp
2126 (concat "\\([^<]\\)\\(" org-target-link-regexp
"\\)"))))
2127 (goto-char (point-min))
2129 (while (re-search-forward re-radio nil t
)
2131 (replace-match "\\1[[\\2]]"))))))
2133 (defun org-export-remove-special-table-lines ()
2134 "Remove tables lines that are used for internal purposes."
2135 (goto-char (point-min))
2136 (while (re-search-forward "^[ \t]*|" nil t
)
2137 (beginning-of-line 1)
2138 (if (or (looking-at "[ \t]*| *[!_^] *|")
2139 (and (looking-at ".*?| *<[0-9]+> *|")
2140 (not (looking-at ".*?| *[^ <|]"))))
2141 (delete-region (max (point-min) (1- (point-at-bol)))
2145 (defun org-export-normalize-links ()
2146 "Convert all links to bracket links, and expand link abbreviations."
2147 (let ((re-plain-link (concat "\\([^[<]\\)" org-plain-link-re
))
2148 (re-angle-link (concat "\\([^[]\\)" org-angle-link-re
)))
2149 (goto-char (point-min))
2150 (while (re-search-forward re-plain-link nil t
)
2151 (goto-char (1- (match-end 0)))
2152 (org-if-unprotected-at (1+ (match-beginning 0))
2153 (let* ((s (concat (match-string 1) "[[" (match-string 2)
2154 ":" (match-string 3) "]]")))
2155 ;; added 'org-link face to links
2156 (put-text-property 0 (length s
) 'face
'org-link s
)
2157 (replace-match s t t
))))
2158 (goto-char (point-min))
2159 (while (re-search-forward re-angle-link nil t
)
2160 (goto-char (1- (match-end 0)))
2162 (let* ((s (concat (match-string 1) "[[" (match-string 2)
2163 ":" (match-string 3) "]]")))
2164 (put-text-property 0 (length s
) 'face
'org-link s
)
2165 (replace-match s t t
))))
2166 (goto-char (point-min))
2167 (while (re-search-forward org-bracket-link-regexp nil t
)
2168 (goto-char (1- (match-end 0)))
2170 (let* ((xx (save-match-data
2172 (org-link-expand-abbrev (match-string 1)))))
2174 "[[" (org-add-props (copy-sequence xx
)
2175 nil
'org-protected t
)
2179 (concat "[" (org-add-props
2184 (put-text-property 0 (length s
) 'face
'org-link s
)
2185 (replace-match s t t
))))))
2187 (defun org-export-concatenate-multiline-links ()
2188 "Find multi-line links and put it all into a single line.
2189 This is to make sure that the line-processing export backends
2190 can work correctly."
2191 (goto-char (point-min))
2192 (while (re-search-forward "\\(\\(\\[\\|\\]\\)\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\(\\[\\|\\]\\)\\)" nil t
)
2194 (replace-match "\\1 \\3")
2195 (goto-char (match-beginning 0)))))
2197 (defun org-export-concatenate-multiline-emphasis ()
2198 "Find multi-line emphasis and put it all into a single line.
2199 This is to make sure that the line-processing export backends
2200 can work correctly."
2201 (goto-char (point-min))
2202 (while (re-search-forward org-emph-re nil t
)
2203 (if (and (not (= (char-after (match-beginning 3))
2204 (char-after (match-beginning 4))))
2205 (save-excursion (goto-char (match-beginning 0))
2206 (save-match-data (not (org-at-table-p)))))
2208 (subst-char-in-region (match-beginning 0) (match-end 0)
2210 (goto-char (1- (match-end 0))))
2211 (goto-char (1+ (match-beginning 0))))))
2213 (defun org-export-grab-title-from-buffer ()
2214 "Get a title for the current document, from looking at the buffer."
2215 (let ((inhibit-read-only t
))
2217 (goto-char (point-min))
2218 (let ((end (if (looking-at org-outline-regexp
)
2220 (save-excursion (outline-next-heading) (point)))))
2221 (when (re-search-forward "^[ \t]*[^|# \t\r\n].*\n" end t
)
2222 ;; Mark the line so that it will not be exported as normal text.
2224 (add-text-properties (match-beginning 0) (match-end 0)
2225 (list :org-license-to-kill t
)))
2226 ;; Return the title string
2227 (org-trim (match-string 0)))))))
2229 (defun org-export-get-title-from-subtree ()
2230 "Return subtree title and exclude it from export."
2231 (let (title (rbeg (region-beginning)) (rend (region-end)))
2234 (when (and (org-at-heading-p)
2235 (>= (org-end-of-subtree t t
) rend
))
2236 ;; This is a subtree, we take the title from the first heading
2238 (looking-at org-todo-line-regexp
)
2239 (setq title
(match-string 3))
2241 (add-text-properties (point) (1+ (point-at-eol))
2242 (list :org-license-to-kill t
)))
2243 (setq title
(or (org-entry-get nil
"EXPORT_TITLE") title
))))
2246 (defun org-solidify-link-text (s &optional alist
)
2247 "Take link text and make a safe target out of it."
2252 (org-split-string s
"[ \t\r\n]+") "=="))
2253 (a (assoc rtn alist
)))
2256 (defun org-get-min-level (lines &optional offset
)
2257 "Get the minimum level in LINES."
2258 (let ((re "^\\(\\*+\\) ") l
)
2260 (while (setq l
(pop lines
))
2261 (if (string-match re l
)
2262 (throw 'exit
(org-tr-level (- (length (match-string 1 l
))
2266 ;; Variable holding the vector with section numbers
2267 (defvar org-section-numbers
(make-vector org-level-max
0))
2269 (defun org-init-section-numbers ()
2270 "Initialize the vector for the section numbers."
2272 (numbers (nreverse (org-split-string "" "\\.")))
2273 (depth (1- (length org-section-numbers
)))
2274 (i depth
) number-string
)
2277 (aset org-section-numbers i
0)
2278 (setq number-string
(or (car numbers
) "0"))
2279 (if (string-match "\\`[A-Z]\\'" number-string
)
2280 (aset org-section-numbers i
2281 (- (string-to-char number-string
) ?A -
1))
2282 (aset org-section-numbers i
(string-to-number number-string
)))
2286 (defun org-section-number (&optional level
)
2287 "Return a string with the current section number.
2288 When LEVEL is non-nil, increase section numbers on that level."
2289 (let* ((depth (1- (length org-section-numbers
)))
2291 (fmts (car org-export-section-number-format
))
2292 (term (cdr org-export-section-number-format
))
2297 (aset org-section-numbers
2298 level
(1+ (aref org-section-numbers level
))))
2299 (setq idx
(1+ level
))
2300 (while (<= idx depth
)
2302 (aset org-section-numbers idx
0))
2303 (setq idx
(1+ idx
))))
2305 (while (<= idx depth
)
2306 (when (> (aref org-section-numbers idx
) 0)
2307 (setq fmt
(or (pop fmts
) fmt
)
2309 n
(aref org-section-numbers idx
)
2311 (concat string sep
(org-number-to-counter n ctype
))
2312 (concat string
".0"))
2314 (setq idx
(1+ idx
)))
2316 (if (string-match "\\`\\([@0]\\.\\)+" string
)
2317 (setq string
(replace-match "" t nil string
)))
2318 (if (string-match "\\(\\.0\\)+\\'" string
)
2319 (setq string
(replace-match "" t nil string
))))
2320 (concat string term
)))
2322 (defun org-number-to-counter (n type
)
2323 "Concert number N to a string counter, according to TYPE.
2324 TYPE must be a string, any of:
2328 I upper case roman numeral
2329 i lower case roman numeral"
2331 ((equal type
"1") (number-to-string n
))
2332 ((equal type
"A") (char-to-string (+ ?A n -
1)))
2333 ((equal type
"a") (char-to-string (+ ?a n -
1)))
2334 ((equal type
"I") (org-number-to-roman n
))
2335 ((equal type
"i") (downcase (org-number-to-roman n
)))
2336 (t (error "Invalid counter type `%s'" type
))))
2338 (defun org-number-to-roman (n)
2339 "Convert integer N into a roman numeral."
2340 (let ((roman '((1000 .
"M") (900 .
"CM") (500 .
"D") (400 .
"CD")
2341 ( 100 .
"C") ( 90 .
"XC") ( 50 .
"L") ( 40 .
"XL")
2342 ( 10 .
"X") ( 9 .
"IX") ( 5 .
"V") ( 4 .
"IV")
2346 (number-to-string n
)
2348 (if (>= n
(caar roman
))
2349 (setq n
(- n
(caar roman
))
2350 res
(concat res
(cdar roman
)))
2356 (defun org-export-preprocess-apply-macros ()
2357 "Replace macro references."
2358 (goto-char (point-min))
2360 (while (re-search-forward "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)}}}" nil t
)
2361 (setq key
(downcase (match-string 1)))
2362 (when (setq val
(or (plist-get org-export-opt-plist
2363 (intern (concat ":macro-" key
)))
2364 (plist-get org-export-opt-plist
2365 (intern (concat ":" key
)))))
2367 (replace-match val t t
))))))
2369 (defun org-export-apply-macros-in-string (s)
2370 "Apply the macros in string S."
2374 (org-export-preprocess-apply-macros)
2379 (defun org-export-handle-include-files ()
2380 "Include the contents of include files, with proper formatting."
2381 (let ((case-fold-search t
)
2382 params file markup lang start end prefix prefix1 switches
)
2383 (goto-char (point-min))
2384 (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t
)
2385 (setq params
(read (concat "(" (match-string 1) ")"))
2386 prefix
(org-get-and-remove-property 'params
:prefix
)
2387 prefix1
(org-get-and-remove-property 'params
:prefix1
)
2388 file
(org-symname-or-string (pop params
))
2389 markup
(org-symname-or-string (pop params
))
2390 lang
(and (member markup
'("src" "SRC"))
2391 (org-symname-or-string (pop params
)))
2392 switches
(mapconcat '(lambda (x) (format "%s" x
)) params
" "))
2393 (delete-region (match-beginning 0) (match-end 0))
2395 (not (file-exists-p file
))
2396 (not (file-readable-p file
)))
2397 (insert (format "CANNOT INCLUDE FILE %s" file
))
2399 (if (equal (downcase markup
) "src")
2400 (setq start
(format "#+begin_src %s %s\n"
2401 (or lang
"fundamental")
2404 (setq start
(format "#+begin_%s %s\n" markup switches
)
2405 end
(format "#+end_%s" markup
))))
2406 (insert (or start
""))
2407 (insert (org-get-file-contents (expand-file-name file
) prefix prefix1
))
2408 (or (bolp) (newline))
2409 (insert (or end
""))))))
2411 (defun org-get-file-contents (file &optional prefix prefix1
)
2412 "Get the contents of FILE and return them as a string.
2413 If PREFIX is a string, prepend it to each line. If PREFIX1
2414 is a string, prepend it to the first line instead of PREFIX."
2416 (insert-file-contents file
)
2417 (when (or prefix prefix1
)
2418 (goto-char (point-min))
2420 (insert (or prefix1 prefix
))
2422 (beginning-of-line 2)))
2425 (defun org-get-and-remove-property (listvar prop
)
2426 "Check if the value of LISTVAR contains PROP as a property.
2427 If yes, return the value of that property (i.e. the element following
2428 in the list) and remove property and value from the list in LISTVAR."
2429 (let ((list (symbol-value listvar
)) m v
)
2430 (when (setq m
(member prop list
))
2432 (if (equal (car list
) prop
)
2433 (set listvar
(cddr list
))
2434 (setcdr (nthcdr (- (length list
) (length m
) 1) list
)
2436 (set listvar list
)))
2439 (defun org-symname-or-string (s)
2441 (if s
(symbol-name s
) s
)
2444 ;;; Fontification and line numbers for code examples
2446 (defvar org-export-last-code-line-counter-value
0)
2448 (defun org-export-replace-src-segments-and-examples (backend)
2449 "Replace source code segments with special code for export."
2450 (setq org-export-last-code-line-counter-value
0)
2451 (let ((case-fold-search t
)
2452 lang code trans opts
)
2453 (goto-char (point-min))
2454 (while (re-search-forward
2455 "\\(^#\\+BEGIN_SRC:?[ \t]+\\([^ \t\n]+\\)\\(.*\\)\n\\([^\000]+?\n\\)#\\+END_SRC.*\\)\\|\\(^#\\+BEGIN_EXAMPLE:?\\(?:[ \t]+\\(.*\\)\\)?\n\\([^\000]+?\n\\)#\\+END_EXAMPLE.*\\)"
2459 (setq lang
(match-string 2)
2460 opts
(match-string 3)
2461 code
(match-string 4))
2463 opts
(match-string 6)
2464 code
(match-string 7)))
2466 (setq trans
(org-export-format-source-code-or-example
2467 backend lang code opts
))
2468 (replace-match trans t t
))))
2470 (defvar htmlp
) ;; dynamically scoped
2471 (defvar latexp
) ;; dynamically scoped
2473 (defun org-export-format-source-code-or-example (backend
2474 lang code
&optional opts
)
2475 "Format CODE from language LANG and return it formatted for export.
2476 If LANG is nil, do not add any fontification.
2477 OPTS contains formatting optons, like `-n' for triggering numbering lines,
2478 and `+n' for continuing previous numering.
2479 Code formatting according to language currently only works for HTML.
2480 Numbering lines works for all three major backends (html, latex, and ascii)."
2482 (let (num cont rtn rpllbl keepp textareap cols rows fmt
)
2483 (setq opts
(or opts
"")
2484 num
(string-match "[-+]n\\>" opts
)
2485 cont
(string-match "\\+n\\>" opts
)
2486 rpllbl
(string-match "-r\\>" opts
)
2487 keepp
(string-match "-k\\>" opts
)
2488 textareap
(string-match "-t\\>" opts
)
2489 cols
(if (string-match "-w[ \t]+\\([0-9]+\\)" opts
)
2490 (string-to-number (match-string 1 opts
))
2492 rows
(if (string-match "-h[ \t]+\\([0-9]+\\)" opts
)
2493 (string-to-number (match-string 1 opts
))
2494 (org-count-lines code
))
2495 fmt
(if (string-match "-l[ \t]+\"\\([^\"\n]+\\)\"" opts
)
2496 (match-string 1 opts
)))
2497 (when (and textareap
(eq backend
'html
))
2498 ;; we cannot use numbering or highlighting.
2499 (setq num nil cont nil lang nil
))
2500 (if keepp
(setq rpllbl
'keep
))
2502 (when (equal lang
"org")
2503 (setq rtn
(with-temp-buffer
2505 ;; Free up the protected lines
2506 (goto-char (point-min))
2507 (while (re-search-forward "^," nil t
)
2511 ;; Now backend-specific coding
2513 ((eq backend
'docbook
)
2514 (setq rtn
(org-export-number-lines rtn
'docbook
0 0 num cont rpllbl fmt
))
2515 (concat "\n#+BEGIN_DOCBOOK\n"
2516 (org-add-props (concat "<programlisting><![CDATA["
2518 "]]>\n</programlisting>\n")
2522 ;; We are exporting to HTML
2524 (require 'htmlize nil t
)
2525 (when (not (fboundp 'htmlize-region-for-paste
))
2526 ;; we do not have htmlize.el, or an old version of it
2529 "htmlize.el 1.34 or later is needed for source code formatting")))
2532 (let* ((mode (and lang
(intern (concat lang
"-mode"))))
2533 (org-inhibit-startup t
)
2534 (org-startup-folded nil
))
2538 (if (functionp mode
)
2541 (font-lock-fontify-buffer)
2542 (set-buffer-modified-p nil
)
2543 (org-export-htmlize-region-for-paste
2544 (point-min) (point-max))))
2545 (if (string-match "<pre\\([^>]*\\)>\n?" rtn
)
2546 (setq rtn
(replace-match
2547 (format "<pre class=\"src src-%s\">\n" lang
)
2551 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\" overflow-x:scroll >\n"
2553 rtn
"</textarea>\n</p>\n"))
2556 (goto-char (point-min))
2557 (while (re-search-forward "[<>&]" nil t
)
2558 (replace-match (cdr (assq (char-before)
2559 '((?
&.
"&")(?
<.
"<")(?
>.
">"))))
2561 (setq rtn
(buffer-string)))
2562 (setq rtn
(concat "<pre class=\"example\">\n" rtn
"</pre>\n"))))
2564 (setq rtn
(org-export-number-lines rtn
'html
1 1 num
2566 (concat "\n#+BEGIN_HTML\n" (org-add-props rtn
'(org-protected t
)) "\n#+END_HTML\n\n"))
2567 ((eq backend
'latex
)
2568 (setq rtn
(org-export-number-lines rtn
'latex
0 0 num cont rpllbl fmt
))
2569 (concat "\n#+BEGIN_LaTeX\n"
2570 (org-add-props (concat "\\begin{verbatim}\n" rtn
"\n\\end{verbatim}\n")
2573 ((eq backend
'ascii
)
2574 ;; This is not HTML or LaTeX, so just make it an example.
2575 (setq rtn
(org-export-number-lines rtn
'ascii
0 0 num cont rpllbl fmt
))
2576 (concat "#+BEGIN_ASCII\n"
2580 (lambda (l) (concat " " l
))
2581 (org-split-string rtn
"\n")
2585 "#+END_ASCII\n"))))))
2587 (defun org-export-number-lines (text backend
2588 &optional skip1 skip2 number cont
2589 replace-labels label-format
)
2590 (if (and (not number
) (not (eq replace-labels
'keep
)))
2591 (setq replace-labels nil
)) ;; must use names if no numbers
2592 (setq skip1
(or skip1
0) skip2
(or skip2
0))
2593 (if (not cont
) (setq org-export-last-code-line-counter-value
0))
2596 (goto-char (point-max))
2597 (skip-chars-backward " \t\n\r")
2598 (delete-region (point) (point-max))
2599 (beginning-of-line (- 1 skip2
))
2600 (let* ((last (org-current-line))
2601 (n org-export-last-code-line-counter-value
)
2602 (nmax (+ n
(- last skip1
)))
2603 (fmt (format "%%%dd: " (length (number-to-string nmax
))))
2606 ((eq backend
'html
) (format "<span class=\"linenr\">%s</span>"
2608 ((eq backend
'ascii
) fmt
)
2609 ((eq backend
'latex
) fmt
)
2610 ((eq backend
'docbook
) fmt
)
2612 (label-format (or label-format org-coderef-label-format
))
2613 (label-pre (if (string-match "%s" label-format
)
2614 (substring label-format
0 (match-beginning 0))
2616 (label-post (if (string-match "%s" label-format
)
2617 (substring label-format
(match-end 0))
2621 ".*?\\S-.*?\\([ \t]*\\("
2622 (regexp-quote label-pre
)
2623 "\\([-a-zA-Z0-9_]+\\)"
2624 (regexp-quote label-post
)
2628 (goto-line (1+ skip1
))
2629 (while (and (re-search-forward "^" nil t
) (not (eobp)) (< n nmax
))
2631 (insert (format fm
(incf n
)))
2633 (when (and (not (eq replace-labels
'keep
))
2634 (looking-at lbl-re
))
2635 (setq ref
(match-string 3))
2638 (delete-region (match-beginning 1) (match-end 1))
2639 (push (cons ref n
) org-export-code-refs
))
2640 (goto-char (match-beginning 2))
2641 (delete-region (match-beginning 2) (match-end 2))
2642 (insert "(" ref
")")
2643 (push (cons ref
(concat "(" ref
")")) org-export-code-refs
))
2644 (when (eq backend
'html
)
2646 (beginning-of-line 1)
2647 (insert (format "<span id=\"coderef-%s\" class=\"coderef-off\">"
2650 (insert "</span>")))))
2651 (setq org-export-last-code-line-counter-value n
)
2652 (goto-char (point-max))
2658 (defvar org-last-level nil
) ; dynamically scoped variable
2659 (defvar org-min-level nil
) ; dynamically scoped variable
2660 (defvar org-levels-open nil
) ; dynamically scoped parameter
2661 (defvar org-ascii-current-indentation nil
) ; For communication
2664 (defun org-export-as-ascii (arg)
2665 "Export the outline as a pretty ASCII file.
2666 If there is an active region, export only the region.
2667 The prefix ARG specifies how many levels of the outline should become
2668 underlined headlines. The default is 3."
2670 (setq-default org-todo-line-regexp org-todo-line-regexp
)
2671 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
2672 (org-infile-export-plist)))
2673 (region-p (org-region-active-p))
2674 (rbeg (and region-p
(region-beginning)))
2675 (rend (and region-p
(region-end)))
2680 (and (org-at-heading-p)
2681 (>= (org-end-of-subtree t t
) rend
)))))
2682 (level-offset (if subtree-p
2685 (+ (funcall outline-level
)
2686 (if org-odd-levels-only
1 0)))
2688 (opt-plist (setq org-export-opt-plist
2690 (org-export-add-subtree-options opt-plist rbeg
)
2692 (custom-times org-display-custom-times
)
2693 (org-ascii-current-indentation '(0 .
0))
2697 (case-fold-search nil
)
2698 (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
2699 (filename (concat (file-name-as-directory
2700 (org-export-directory :ascii opt-plist
))
2701 (file-name-sans-extension
2703 (org-entry-get (region-beginning)
2704 "EXPORT_FILE_NAME" t
))
2705 (file-name-nondirectory bfname
)))
2707 (filename (if (equal (file-truename filename
)
2708 (file-truename bfname
))
2709 (concat filename
".txt")
2711 (buffer (find-file-noselect filename
))
2712 (org-levels-open (make-vector org-level-max nil
))
2713 (odd org-odd-levels-only
)
2714 (date (plist-get opt-plist
:date
))
2715 (author (plist-get opt-plist
:author
))
2716 (title (or (and subtree-p
(org-export-get-title-from-subtree))
2717 (plist-get opt-plist
:title
)
2719 (plist-get opt-plist
:skip-before-1st-heading
))
2720 (org-export-grab-title-from-buffer))
2721 (file-name-sans-extension
2722 (file-name-nondirectory bfname
))))
2723 (email (plist-get opt-plist
:email
))
2724 (language (plist-get opt-plist
:language
))
2725 (quote-re0 (concat "^[ \t]*" org-quote-string
"\\>"))
2726 ; (quote-re (concat "^\\(\\*+\\)\\([ \t]*" org-quote-string "\\>\\)"))
2731 (if (org-region-active-p) (region-beginning) (point-min))
2732 (if (org-region-active-p) (region-end) (point-max))))
2733 (lines (org-split-string
2734 (org-export-preprocess-string
2737 :skip-before-1st-heading
2738 (plist-get opt-plist
:skip-before-1st-heading
)
2739 :drawers
(plist-get opt-plist
:drawers
)
2740 :tags
(plist-get opt-plist
:tags
)
2741 :priority
(plist-get opt-plist
:priority
)
2742 :footnotes
(plist-get opt-plist
:footnotes
)
2743 :timestamps
(plist-get opt-plist
:timestamps
)
2744 :todo-keywords
(plist-get opt-plist
:todo-keywords
)
2745 :verbatim-multiline t
2746 :select-tags
(plist-get opt-plist
:select-tags
)
2747 :exclude-tags
(plist-get opt-plist
:exclude-tags
)
2749 (plist-get opt-plist
:archived-trees
)
2750 :add-text
(plist-get opt-plist
:text
))
2752 thetoc have-headings first-heading-pos
2753 table-open table-buffer link-buffer link desc desc0 rpl wrap
)
2754 (let ((inhibit-read-only t
))
2756 (remove-text-properties (point-min) (point-max)
2757 '(:org-license-to-kill t
))))
2759 (setq org-min-level
(org-get-min-level lines level-offset
))
2760 (setq org-last-level org-min-level
)
2761 (org-init-section-numbers)
2763 (find-file-noselect filename
)
2765 (setq lang-words
(or (assoc language org-export-language-setup
)
2766 (assoc "en" org-export-language-setup
)))
2767 (switch-to-buffer-other-window buffer
)
2770 ;; create local variables for all options, to make sure all called
2771 ;; functions get the correct information
2773 (set (make-local-variable (nth 2 x
))
2774 (plist-get opt-plist
(car x
))))
2775 org-export-plist-vars
)
2776 (org-set-local 'org-odd-levels-only odd
)
2777 (setq umax
(if arg
(prefix-numeric-value arg
)
2778 org-export-headline-levels
))
2779 (setq umax-toc
(if (integerp org-export-with-toc
)
2780 (min org-export-with-toc umax
)
2784 (if title
(org-insert-centered title ?
=))
2786 (if (and (or author email
)
2787 org-export-author-info
)
2788 (insert (concat (nth 1 lang-words
) ": " (or author
"")
2789 (if email
(concat " <" email
">") "")
2793 ((and date
(string-match "%" date
))
2794 (setq date
(format-time-string date
)))
2796 (t (setq date
(format-time-string "%Y-%m-%d %T %Z"))))
2798 (if (and date org-export-time-stamp-file
)
2799 (insert (concat (nth 2 lang-words
) ": " date
"\n")))
2803 (if org-export-with-toc
2805 (push (concat (nth 3 lang-words
) "\n") thetoc
)
2806 (push (concat (make-string (string-width (nth 3 lang-words
)) ?
=)
2808 (mapc '(lambda (line)
2809 (if (string-match org-todo-line-regexp
2811 ;; This is a headline
2813 (setq have-headings t
)
2814 (setq level
(- (match-end 1) (match-beginning 1)
2816 level
(org-tr-level level
)
2817 txt
(match-string 3 line
)
2819 (or (and org-export-mark-todo-in-toc
2821 (not (member (match-string 2 line
)
2822 org-done-keywords
)))
2824 (and org-export-mark-todo-in-toc
2826 (org-search-todo-below
2827 line lines level
))))
2828 (setq txt
(org-html-expand-for-ascii txt
))
2830 (while (string-match org-bracket-link-regexp txt
)
2833 (match-string (if (match-end 2) 3 1) txt
)
2836 (if (and (memq org-export-with-tags
'(not-in-toc nil
))
2838 (org-re "[ \t]+:[[:alnum:]_@:]+:[ \t]*$")
2840 (setq txt
(replace-match "" t t txt
)))
2841 (if (string-match quote-re0 txt
)
2842 (setq txt
(replace-match "" t t txt
)))
2844 (if org-export-with-section-numbers
2845 (setq txt
(concat (org-section-number level
)
2847 (if (<= level umax-toc
)
2852 (* (max 0 (- level org-min-level
)) 4) ?\
)
2853 (format (if todo
"%s (*)\n" "%s\n") txt
))
2855 (setq org-last-level level
))
2858 (setq thetoc
(if have-headings
(nreverse thetoc
) nil
))))
2860 (org-init-section-numbers)
2861 (while (setq line
(pop lines
))
2862 (when (and link-buffer
(string-match "^\\*+ " line
))
2863 (org-export-ascii-push-links (nreverse link-buffer
))
2864 (setq link-buffer nil
))
2866 ;; Remove the quoted HTML tags.
2867 (setq line
(org-html-expand-for-ascii line
))
2868 ;; Replace links with the description when possible
2869 (while (string-match org-bracket-link-regexp line
)
2870 (setq link
(match-string 1 line
)
2871 desc0
(match-string 3 line
)
2872 desc
(or desc0
(match-string 1 line
)))
2873 (if (and (> (length link
) 8)
2874 (equal (substring link
0 8) "coderef:"))
2875 (setq line
(replace-match
2876 (format (org-export-get-coderef-format (substring link
8) desc
)
2879 org-export-code-refs
)))
2881 (setq rpl
(concat "["
2882 (or (match-string 3 line
) (match-string 1 line
))
2884 (when (and desc0
(not (equal desc0 link
)))
2885 (if org-export-ascii-links-to-notes
2886 (push (cons desc0 link
) link-buffer
)
2887 (setq rpl
(concat rpl
" (" link
")")
2888 wrap
(+ (length line
) (- (length (match-string 0)))
2890 (setq line
(replace-match rpl t t line
))))
2892 (setq line
(org-translate-time line
)))
2894 ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line
)
2896 (setq first-heading-pos
(or first-heading-pos
(point)))
2897 (setq level
(org-tr-level (- (match-end 1) (match-beginning 1)
2899 txt
(match-string 2 line
))
2900 (org-ascii-level-start level txt umax lines
))
2902 ((and org-export-with-tables
2903 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line
))
2904 (if (not table-open
)
2906 (setq table-open t table-buffer nil
))
2908 (setq table-buffer
(cons line table-buffer
))
2909 (when (or (not lines
)
2910 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
2912 (setq table-open nil
2913 table-buffer
(nreverse table-buffer
))
2916 (org-fix-indentation x org-ascii-current-indentation
))
2917 (org-format-table-ascii table-buffer
)
2920 (if (string-match "^\\([ \t]*\\)\\([-+*][ \t]+\\)\\(.*?\\)\\( ::\\)" line
)
2921 (setq line
(replace-match "\\1\\3:" t nil line
)))
2922 (setq line
(org-fix-indentation line org-ascii-current-indentation
))
2923 ;; Remove forced line breaks
2924 (if (string-match "\\\\\\\\[ \t]*$" line
)
2925 (setq line
(replace-match "" t t line
)))
2926 (if (and org-export-with-fixed-width
2927 (string-match "^\\([ \t]*\\)\\(:\\( \\|$\\)\\)" line
))
2928 (setq line
(replace-match "\\1" nil nil line
))
2929 (if wrap
(setq line
(org-export-ascii-wrap line wrap
))))
2930 (insert line
"\n"))))
2932 (org-export-ascii-push-links (nreverse link-buffer
))
2936 ;; insert the table of contents
2938 (goto-char (point-min))
2939 (if (re-search-forward "^[ \t]*\\[TABLE-OF-CONTENTS\\][ \t]*$" nil t
)
2941 (goto-char (match-beginning 0))
2943 (goto-char first-heading-pos
))
2944 (mapc 'insert thetoc
)
2945 (or (looking-at "[ \t]*\n[ \t]*\n")
2948 ;; Convert whitespace place holders
2949 (goto-char (point-min))
2951 (while (setq beg
(next-single-property-change (point) 'org-whitespace
))
2952 (setq end
(next-single-property-change beg
'org-whitespace
))
2954 (delete-region beg end
)
2955 (insert (make-string (- end beg
) ?\
))))
2958 ;; remove display and invisible chars
2960 (goto-char (point-min))
2961 (while (setq beg
(next-single-property-change (point) 'display
))
2962 (setq end
(next-single-property-change beg
'display
))
2963 (delete-region beg end
)
2966 (goto-char (point-min))
2967 (while (setq beg
(next-single-property-change (point) 'org-cwidth
))
2968 (setq end
(next-single-property-change beg
'org-cwidth
))
2969 (delete-region beg end
)
2971 (goto-char (point-min))))
2973 (defun org-export-ascii-preprocess ()
2974 "Do extra work for ASCII export"
2975 ;; Put quotes around verbatim text
2976 (goto-char (point-min))
2977 (while (re-search-forward org-verbatim-re nil t
)
2978 (goto-char (match-end 2))
2979 (backward-delete-char 1) (insert "'")
2980 (goto-char (match-beginning 2))
2981 (delete-char 1) (insert "`")
2982 (goto-char (match-end 2)))
2983 ;; Remove target markers
2984 (goto-char (point-min))
2985 (while (re-search-forward "<<<?\\([^<>]*\\)>>>?\\([ \t]*\\)" nil t
)
2986 (replace-match "\\1\\2")))
2988 (defun org-search-todo-below (line lines level
)
2989 "Search the subtree below LINE for any TODO entries."
2990 (let ((rest (cdr (memq line lines
)))
2991 (re org-todo-line-regexp
)
2994 (while (setq line
(pop rest
))
2995 (if (string-match re line
)
2997 (setq lv
(- (match-end 1) (match-beginning 1))
2998 todo
(and (match-beginning 2)
2999 (not (member (match-string 2 line
)
3000 org-done-keywords
))))
3002 (if (<= lv level
) (throw 'exit nil
))
3003 (if todo
(throw 'exit t
))))))))
3005 (defun org-html-expand-for-ascii (line)
3006 "Handle quoted HTML for ASCII export."
3007 (if org-export-html-expand
3008 (while (string-match "@<[^<>\n]*>" line
)
3009 ;; We just remove the tags for now.
3010 (setq line
(replace-match "" nil nil line
))))
3014 (defun org-export-ascii-wrap (line where
)
3015 "Wrap LINE at or before WHERE."
3016 (let ((ind (org-get-indentation line
))
3019 (loop for i from where downto
(/ where
2) do
3020 (and (equal (aref line i
) ?\
)
3024 (concat (substring line
0 pos
) "\n"
3025 (make-string ind ?\
)
3026 (substring line
(1+ pos
)))
3029 (defun org-export-ascii-push-links (link-buffer)
3030 "Push out links in the buffer."
3032 ;; We still have links to push out.
3038 "^\\(\\([ \t]*\\)\\|\\(\\*+ \\)\\)[^ \t\n]" nil t
))
3039 (setq ind
(or (match-string 2)
3040 (make-string (length (match-string 3)) ?\
)))))
3041 (mapc (lambda (x) (insert ind
"[" (car x
) "]: " (cdr x
) "\n"))
3045 (defun org-insert-centered (s &optional underline
)
3046 "Insert the string S centered and underline it with character UNDERLINE."
3047 (let ((ind (max (/ (- fill-column
(string-width s
)) 2) 0)))
3048 (insert (make-string ind ?\
) s
"\n")
3050 (insert (make-string ind ?\
)
3051 (make-string (string-width s
) underline
)
3054 (defun org-ascii-level-start (level title umax
&optional lines
)
3055 "Insert a new level in ASCII export."
3056 (let (char (n (- level umax
1)) (ind 0))
3059 (insert (make-string (* 2 n
) ?\
)
3060 (char-to-string (nth (% n
(length org-export-ascii-bullets
))
3061 org-export-ascii-bullets
))
3063 ;; find the indentation of the next non-empty line
3066 (if (string-match "^\\* " (car lines
)) (throw 'stop nil
))
3067 (if (string-match "^\\([ \t]*\\)\\S-" (car lines
))
3068 (throw 'stop
(setq ind
(org-get-indentation (car lines
)))))
3070 (setq org-ascii-current-indentation
(cons (* 2 (1+ n
)) ind
)))
3071 (if (or (not (equal (char-before) ?
\n))
3072 (not (equal (char-before (1- (point))) ?
\n)))
3074 (setq char
(nth (- umax level
) (reverse org-export-ascii-underline
)))
3075 (unless org-export-with-tags
3076 (if (string-match (org-re "[ \t]+\\(:[[:alnum:]_@:]+:\\)[ \t]*$") title
)
3077 (setq title
(replace-match "" t t title
))))
3078 (if org-export-with-section-numbers
3079 (setq title
(concat (org-section-number level
) " " title
)))
3080 (insert title
"\n" (make-string (string-width title
) char
) "\n")
3081 (setq org-ascii-current-indentation
'(0 .
0)))))
3084 (defun org-export-visible (type arg
)
3085 "Create a copy of the visible part of the current buffer, and export it.
3086 The copy is created in a temporary buffer and removed after use.
3087 TYPE is the final key (as a string) that also select the export command in
3088 the `C-c C-e' export dispatcher.
3089 As a special case, if the you type SPC at the prompt, the temporary
3090 org-mode file will not be removed but presented to you so that you can
3091 continue to use it. The prefix arg ARG is passed through to the exporting
3095 (message "Export visible: [a]SCII [h]tml [b]rowse HTML [H/R]uffer with HTML [D]ocBook [x]OXO [ ]keep buffer")
3096 (read-char-exclusive))
3097 current-prefix-arg
))
3098 (if (not (member type
'(?a ?\C-a ?b ?\C-b ?h ?D ?x ?\
)))
3099 (error "Invalid export key"))
3100 (let* ((binding (cdr (assoc type
3101 '((?a . org-export-as-ascii
)
3102 (?\C-a . org-export-as-ascii
)
3103 (?b . org-export-as-html-and-open
)
3104 (?\C-b . org-export-as-html-and-open
)
3105 (?h . org-export-as-html
)
3106 (?H . org-export-as-html-to-buffer
)
3107 (?R . org-export-region-as-html
)
3108 (?D . org-export-as-docbook
)
3109 (?x . org-export-as-xoxo
)))))
3110 (keepp (equal type ?\
))
3111 (file buffer-file-name
)
3112 (buffer (get-buffer-create "*Org Export Visible*"))
3114 ;; Need to hack the drawers here.
3116 (goto-char (point-min))
3117 (while (re-search-forward org-drawer-regexp nil t
)
3118 (goto-char (match-beginning 1))
3119 (or (org-invisible-p) (org-flag-drawer nil
))))
3120 (with-current-buffer buffer
(erase-buffer))
3122 (setq s
(goto-char (point-min)))
3123 (while (not (= (point) (point-max)))
3124 (goto-char (org-find-invisible))
3125 (append-to-buffer buffer s
(point))
3126 (setq s
(goto-char (org-find-visible))))
3127 (org-cycle-hide-drawers 'all
)
3128 (goto-char (point-min))
3130 ;; Copy all comment lines to the end, to make sure #+ settings are
3131 ;; still available for the second export step. Kind of a hack, but
3132 ;; does do the trick.
3133 (if (looking-at "#[^\r\n]*")
3134 (append-to-buffer buffer
(match-beginning 0) (1+ (match-end 0))))
3135 (while (re-search-forward "[\n\r]#[^\n\r]*" nil t
)
3136 (append-to-buffer buffer
(1+ (match-beginning 0))
3137 (min (point-max) (1+ (match-end 0))))))
3139 (let ((buffer-file-name file
)
3140 (org-inhibit-startup t
))
3143 (unless keepp
(funcall binding arg
))))
3145 (kill-buffer buffer
)
3146 (switch-to-buffer-other-window buffer
)
3147 (goto-char (point-min)))))
3149 (defun org-find-visible ()
3151 (while (and (not (= (point-max) (setq s
(next-overlay-change s
))))
3152 (get-char-property s
'invisible
)))
3154 (defun org-find-invisible ()
3156 (while (and (not (= (point-max) (setq s
(next-overlay-change s
))))
3157 (not (get-char-property s
'invisible
))))
3162 (defvar org-archive-location
) ;; gets loaded with the org-archive require.
3163 (defun org-get-current-options ()
3164 "Return a string with current options as keyword options.
3165 Does include HTML export options as well as TODO and CATEGORY stuff."
3166 (require 'org-archive
)
3175 #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s <:%s
3176 #+OPTIONS: TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s
3178 #+EXPORT_SELECT_TAGS: %s
3179 #+EXPORT_EXCLUDE_TAGS: %s
3185 #+PRIORITIES: %c %c %c
3187 #+STARTUP: %s %s %s %s %s
3193 (buffer-name) (user-full-name) user-mail-address
3194 (format-time-string (substring (car org-time-stamp-formats
) 1 -
1))
3195 org-export-default-language
3196 org-export-headline-levels
3197 org-export-with-section-numbers
3199 org-export-preserve-breaks
3200 org-export-html-expand
3201 org-export-with-fixed-width
3202 org-export-with-tables
3203 org-export-with-sub-superscripts
3204 org-export-with-special-strings
3205 org-export-with-footnotes
3206 org-export-with-emphasize
3207 org-export-with-timestamps
3208 org-export-with-TeX-macros
3209 org-export-with-LaTeX-fragments
3210 org-export-skip-text-before-1st-heading
3211 org-export-with-drawers
3212 org-export-with-todo-keywords
3213 org-export-with-priority
3214 org-export-with-tags
3215 (if (featurep 'org-jsinfo
) (org-infojs-options-inbuffer-template) "")
3216 (mapconcat 'identity org-export-select-tags
" ")
3217 (mapconcat 'identity org-export-exclude-tags
" ")
3218 org-export-html-link-up
3219 org-export-html-link-home
3221 (file-name-sans-extension
3222 (file-name-nondirectory (buffer-file-name (buffer-base-buffer)))))
3224 "TODO FEEDBACK VERIFY DONE"
3225 "Me Jason Marie DONE"
3226 org-highest-priority org-lowest-priority org-default-priority
3227 (mapconcat 'identity org-drawers
" ")
3228 (cdr (assoc org-startup-folded
3229 '((nil .
"showall") (t .
"overview") (content .
"content"))))
3230 (if org-odd-levels-only
"odd" "oddeven")
3231 (if org-hide-leading-stars
"hidestars" "showstars")
3232 (if org-startup-align-all-tables
"align" "noalign")
3233 (cond ((eq org-log-done t
) "logdone")
3234 ((equal org-log-done
'note
) "lognotedone")
3235 ((not org-log-done
) "nologdone"))
3236 (or (mapconcat (lambda (x)
3238 ((equal '(:startgroup
) x
) "{")
3239 ((equal '(:endgroup
) x
) "}")
3240 ((cdr x
) (format "%s(%c)" (car x
) (cdr x
)))
3242 (or org-tag-alist
(org-get-buffer-tags)) " ") "")
3243 (mapconcat 'identity org-file-tags
" ")
3244 org-archive-location
3245 "org file:~/org/%s.org"
3248 (defun org-export-html-preprocess (parameters)
3249 ;; Convert LaTeX fragments to images
3250 (when (and org-current-export-file
3251 (plist-get parameters
:LaTeX-fragments
))
3253 (concat "ltxpng/" (file-name-sans-extension
3254 (file-name-nondirectory
3255 org-current-export-file
)))
3256 org-current-export-dir nil
"Creating LaTeX image %s"))
3257 (message "Exporting..."))
3260 (defun org-insert-export-options-template ()
3261 "Insert into the buffer a template with information for exporting."
3263 (if (not (bolp)) (newline))
3264 (let ((s (org-get-current-options)))
3265 (and (string-match "#\\+CATEGORY" s
)
3266 (setq s
(substring s
0 (match-beginning 0))))
3270 (defun org-export-as-html-and-open (arg)
3271 "Export the outline as HTML and immediately open it with a browser.
3272 If there is an active region, export only the region.
3273 The prefix ARG specifies how many levels of the outline should become
3274 headlines. The default is 3. Lower levels will become bulleted lists."
3276 (org-export-as-html arg
'hidden
)
3277 (org-open-file buffer-file-name
))
3280 (defun org-export-as-html-batch ()
3281 "Call `org-export-as-html', may be used in batch processing as
3283 --load=$HOME/lib/emacs/org.el
3284 --eval \"(setq org-export-headline-levels 2)\"
3285 --visit=MyFile --funcall org-export-as-html-batch"
3286 (org-export-as-html org-export-headline-levels
'hidden
))
3289 (defun org-export-as-html-to-buffer (arg)
3290 "Call `org-export-as-html` with output to a temporary buffer.
3291 No file is created. The prefix ARG is passed through to `org-export-as-html'."
3293 (org-export-as-html arg nil nil
"*Org HTML Export*")
3294 (switch-to-buffer-other-window "*Org HTML Export*"))
3297 (defun org-replace-region-by-html (beg end
)
3298 "Assume the current region has org-mode syntax, and convert it to HTML.
3299 This can be used in any buffer. For example, you could write an
3300 itemized list in org-mode syntax in an HTML buffer and then use this
3301 command to convert it."
3303 (let (reg html buf pop-up-frames
)
3304 (save-window-excursion
3306 (setq html
(org-export-region-as-html
3308 (setq reg
(buffer-substring beg end
)
3309 buf
(get-buffer-create "*Org tmp*"))
3310 (with-current-buffer buf
3314 (setq html
(org-export-region-as-html
3315 (point-min) (point-max) t
'string
)))
3317 (delete-region beg end
)
3321 (defun org-export-region-as-html (beg end
&optional body-only buffer
)
3322 "Convert region from BEG to END in org-mode buffer to HTML.
3323 If prefix arg BODY-ONLY is set, omit file header, footer, and table of
3324 contents, and only produce the region of converted text, useful for
3325 cut-and-paste operations.
3326 If BUFFER is a buffer or a string, use/create that buffer as a target
3327 of the converted HTML. If BUFFER is the symbol `string', return the
3328 produced HTML as a string and leave not buffer behind. For example,
3329 a Lisp program could call this function in the following way:
3331 (setq html (org-export-region-as-html beg end t 'string))
3333 When called interactively, the output buffer is selected, and shown
3334 in a window. A non-interactive call will only return the buffer."
3335 (interactive "r\nP")
3336 (when (interactive-p)
3337 (setq buffer
"*Org HTML Export*"))
3338 (let ((transient-mark-mode t
) (zmacs-regions t
)
3340 (setq ext-plist
(plist-put ext-plist
:ignore-subree-p t
))
3342 (set-mark (point)) ;; to activate the region
3344 (setq rtn
(org-export-as-html
3347 (if (fboundp 'deactivate-mark
) (deactivate-mark))
3348 (if (and (interactive-p) (bufferp rtn
))
3349 (switch-to-buffer-other-window rtn
)
3352 (defvar html-table-tag nil
) ; dynamically scoped into this.
3353 (defvar org-par-open nil
)
3355 (defun org-export-as-html (arg &optional hidden ext-plist
3356 to-buffer body-only pub-dir
)
3357 "Export the outline as a pretty HTML file.
3358 If there is an active region, export only the region. The prefix
3359 ARG specifies how many levels of the outline should become
3360 headlines. The default is 3. Lower levels will become bulleted
3361 lists. When HIDDEN is non-nil, don't display the HTML buffer.
3362 EXT-PLIST is a property list with external parameters overriding
3363 org-mode's default settings, but still inferior to file-local
3364 settings. When TO-BUFFER is non-nil, create a buffer with that
3365 name and export to that buffer. If TO-BUFFER is the symbol
3366 `string', don't leave any buffer behind but just return the
3367 resulting HTML as a string. When BODY-ONLY is set, don't produce
3368 the file header and footer, simply return the content of
3369 <body>...</body>, without even the body tags themselves. When
3370 PUB-DIR is set, use this as the publishing directory."
3373 ;; Make sure we have a file name when we need it.
3374 (when (and (not (or to-buffer body-only
))
3375 (not buffer-file-name
))
3376 (if (buffer-base-buffer)
3377 (org-set-local 'buffer-file-name
3378 (with-current-buffer (buffer-base-buffer)
3380 (error "Need a file name to be able to export.")))
3382 (message "Exporting...")
3383 (setq-default org-todo-line-regexp org-todo-line-regexp
)
3384 (setq-default org-deadline-line-regexp org-deadline-line-regexp
)
3385 (setq-default org-done-keywords org-done-keywords
)
3386 (setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp
)
3388 (org-export-process-option-filters
3389 (org-combine-plists (org-default-export-plist)
3391 (org-infile-export-plist))))
3392 (style (concat (if (plist-get opt-plist
:style-include-default
)
3393 org-export-html-style-default
)
3394 (plist-get opt-plist
:style
)
3395 (plist-get opt-plist
:style-extra
)
3397 (if (plist-get opt-plist
:style-include-scripts
)
3398 org-export-html-scripts
)))
3399 (html-extension (plist-get opt-plist
:html-extension
))
3400 (link-validate (plist-get opt-plist
:link-validation-function
))
3401 valid thetoc have-headings first-heading-pos
3402 (odd org-odd-levels-only
)
3403 (region-p (org-region-active-p))
3404 (rbeg (and region-p
(region-beginning)))
3405 (rend (and region-p
(region-end)))
3407 (if (plist-get opt-plist
:ignore-subree-p
)
3412 (and (org-at-heading-p)
3413 (>= (org-end-of-subtree t t
) rend
))))))
3414 (level-offset (if subtree-p
3417 (+ (funcall outline-level
)
3418 (if org-odd-levels-only
1 0)))
3420 (opt-plist (setq org-export-opt-plist
3422 (org-export-add-subtree-options opt-plist rbeg
)
3424 ;; The following two are dynamically scoped into other
3426 (org-current-export-dir
3427 (or pub-dir
(org-export-directory :html opt-plist
)))
3428 (org-current-export-file buffer-file-name
)
3429 (level 0) (line "") (origline "") txt todo
3432 (filename (if to-buffer nil
3435 (file-name-sans-extension
3437 (org-entry-get (region-beginning)
3438 "EXPORT_FILE_NAME" t
))
3439 (file-name-nondirectory buffer-file-name
)))
3441 (file-name-as-directory
3442 (or pub-dir
(org-export-directory :html opt-plist
))))))
3443 (current-dir (if buffer-file-name
3444 (file-name-directory buffer-file-name
)
3446 (buffer (if to-buffer
3448 ((eq to-buffer
'string
) (get-buffer-create "*Org HTML Export*"))
3449 (t (get-buffer-create to-buffer
)))
3450 (find-file-noselect filename
)))
3451 (org-levels-open (make-vector org-level-max nil
))
3452 (date (plist-get opt-plist
:date
))
3453 (author (plist-get opt-plist
:author
))
3454 (title (or (and subtree-p
(org-export-get-title-from-subtree))
3455 (plist-get opt-plist
:title
)
3457 (plist-get opt-plist
:skip-before-1st-heading
))
3458 (org-export-grab-title-from-buffer))
3459 (and buffer-file-name
3460 (file-name-sans-extension
3461 (file-name-nondirectory buffer-file-name
)))
3463 (html-table-tag (plist-get opt-plist
:html-table-tag
))
3464 (quote-re0 (concat "^[ \t]*" org-quote-string
"\\>"))
3465 (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string
"\\>\\)"))
3470 (local-list-type nil
)
3471 (local-list-indent nil
)
3472 (llt org-plain-list-ordered-item-terminator
)
3473 (email (plist-get opt-plist
:email
))
3474 (language (plist-get opt-plist
:language
))
3475 (keywords (plist-get opt-plist
:keywords
))
3476 (description (plist-get opt-plist
:description
))
3480 (coding-system (and (boundp 'buffer-file-coding-system
)
3481 buffer-file-coding-system
))
3482 (coding-system-for-write (or org-export-html-coding-system
3484 (save-buffer-coding-system (or org-export-html-coding-system
3486 (charset (and coding-system-for-write
3487 (fboundp 'coding-system-get
)
3488 (coding-system-get coding-system-for-write
3492 (if region-p
(region-beginning) (point-min))
3493 (if region-p
(region-end) (point-max))))
3496 (org-export-preprocess-string
3500 :skip-before-1st-heading
3501 (plist-get opt-plist
:skip-before-1st-heading
)
3502 :drawers
(plist-get opt-plist
:drawers
)
3503 :todo-keywords
(plist-get opt-plist
:todo-keywords
)
3504 :tags
(plist-get opt-plist
:tags
)
3505 :priority
(plist-get opt-plist
:priority
)
3506 :footnotes
(plist-get opt-plist
:footnotes
)
3507 :timestamps
(plist-get opt-plist
:timestamps
)
3509 (plist-get opt-plist
:archived-trees
)
3510 :select-tags
(plist-get opt-plist
:select-tags
)
3511 :exclude-tags
(plist-get opt-plist
:exclude-tags
)
3513 (plist-get opt-plist
:text
)
3515 (plist-get opt-plist
:LaTeX-fragments
))
3518 table-buffer table-orig-buffer
3519 ind item-type starter didclose
3520 rpl path attr desc descp desc1 desc2 link
3521 snumber fnc item-tag
3522 footnotes footref-seen
3526 (let ((inhibit-read-only t
))
3528 (remove-text-properties (point-min) (point-max)
3529 '(:org-license-to-kill t
))))
3531 (message "Exporting...")
3533 (setq org-min-level
(org-get-min-level lines level-offset
))
3534 (setq org-last-level org-min-level
)
3535 (org-init-section-numbers)
3538 ((and date
(string-match "%" date
))
3539 (setq date
(format-time-string date
)))
3541 (t (setq date
(format-time-string "%Y-%m-%d %T %Z"))))
3543 ;; Get the language-dependent settings
3544 (setq lang-words
(or (assoc language org-export-language-setup
)
3545 (assoc "en" org-export-language-setup
)))
3547 ;; Switch to the output buffer
3549 (let ((inhibit-read-only t
)) (erase-buffer))
3552 (and (fboundp 'set-buffer-file-coding-system
)
3553 (set-buffer-file-coding-system coding-system-for-write
))
3555 (let ((case-fold-search nil
)
3556 (org-odd-levels-only odd
))
3557 ;; create local variables for all options, to make sure all called
3558 ;; functions get the correct information
3560 (set (make-local-variable (nth 2 x
))
3561 (plist-get opt-plist
(car x
))))
3562 org-export-plist-vars
)
3563 (setq umax
(if arg
(prefix-numeric-value arg
)
3564 org-export-headline-levels
))
3565 (setq umax-toc
(if (integerp org-export-with-toc
)
3566 (min org-export-with-toc umax
)
3571 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
3572 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
3573 <html xmlns=\"http://www.w3.org/1999/xhtml\"
3574 lang=\"%s\" xml:lang=\"%s\">
3577 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
3578 <meta name=\"generator\" content=\"Org-mode\"/>
3579 <meta name=\"generated\" content=\"%s\"/>
3580 <meta name=\"author\" content=\"%s\"/>
3581 <meta name=\"description\" content=\"%s\"/>
3582 <meta name=\"keywords\" content=\"%s\"/>
3586 <div id=\"content\">
3588 language language
(org-html-expand title
)
3589 (or charset
"iso-8859-1")
3590 date author description keywords
3593 (insert (or (plist-get opt-plist
:preamble
) ""))
3595 (when (plist-get opt-plist
:auto-preamble
)
3596 (if title
(insert (format org-export-html-title-format
3597 (org-html-expand title
))))))
3599 (if (and org-export-with-toc
(not body-only
))
3601 (push (format "<h%d>%s</h%d>\n"
3602 org-export-html-toplevel-hlevel
3604 org-export-html-toplevel-hlevel
)
3606 (push "<div id=\"text-table-of-contents\">\n" thetoc
)
3607 (push "<ul>\n<li>" thetoc
)
3609 (mapcar '(lambda (line)
3610 (if (string-match org-todo-line-regexp line
)
3611 ;; This is a headline
3613 (setq have-headings t
)
3614 (setq level
(- (match-end 1) (match-beginning 1)
3616 level
(org-tr-level level
)
3617 txt
(save-match-data
3619 (org-export-cleanup-toc-line
3620 (match-string 3 line
))))
3622 (or (and org-export-mark-todo-in-toc
3624 (not (member (match-string 2 line
)
3625 org-done-keywords
)))
3627 (and org-export-mark-todo-in-toc
3629 (org-search-todo-below
3630 line lines level
))))
3632 (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt
)
3633 (setq txt
(replace-match " <span class=\"tag\"> \\1</span>" t nil txt
)))
3634 (if (string-match quote-re0 txt
)
3635 (setq txt
(replace-match "" t t txt
)))
3636 (setq snumber
(org-section-number level
))
3637 (if org-export-with-section-numbers
3638 (setq txt
(concat snumber
" " txt
)))
3639 (if (<= level
(max umax umax-toc
))
3640 (setq head-count
(+ head-count
1)))
3641 (if (<= level umax-toc
)
3643 (if (> level org-last-level
)
3645 (setq cnt
(- level org-last-level
))
3646 (while (>= (setq cnt
(1- cnt
)) 0)
3647 (push "\n<ul>\n<li>" thetoc
))
3648 (push "\n" thetoc
)))
3649 (if (< level org-last-level
)
3651 (setq cnt
(- org-last-level level
))
3652 (while (>= (setq cnt
(1- cnt
)) 0)
3653 (push "</li>\n</ul>" thetoc
))
3654 (push "\n" thetoc
)))
3655 ;; Check for targets
3656 (while (string-match org-any-target-regexp line
)
3657 (setq line
(replace-match
3658 (concat "@<span class=\"target\">" (match-string 1 line
) "@</span> ")
3660 (while (string-match "<\\(<\\)+\\|>\\(>\\)+" txt
)
3661 (setq txt
(replace-match "" t t txt
)))
3665 "</li>\n<li><a href=\"#sec-%s\"><span class=\"todo\">%s</span></a>"
3666 "</li>\n<li><a href=\"#sec-%s\">%s</a>")
3667 snumber txt
) thetoc
)
3669 (setq org-last-level level
))
3673 (while (> org-last-level
(1- org-min-level
))
3674 (setq org-last-level
(1- org-last-level
))
3675 (push "</li>\n</ul>\n" thetoc
))
3676 (push "</div>\n" thetoc
)
3677 (setq thetoc
(if have-headings
(nreverse thetoc
) nil
))))
3680 (org-init-section-numbers)
3684 (while (setq line
(pop lines
) origline line
)
3687 ;; end of quote section?
3688 (when (and inquote
(string-match "^\\*+ " line
))
3691 ;; inside a quote section?
3693 (insert (org-html-protect line
) "\n")
3694 (throw 'nextline nil
))
3696 ;; Fixed-width, verbatim lines (examples)
3697 (when (and org-export-with-fixed-width
3698 (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line
))
3701 (org-close-par-maybe)
3703 (insert "<pre class=\"example\">\n"))
3704 (insert (org-html-protect (match-string 3 line
)) "\n")
3705 (when (or (not lines
)
3706 (not (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)"
3709 (insert "</pre>\n"))
3710 (throw 'nextline nil
))
3713 (when (get-text-property 0 'org-protected line
)
3715 (when (re-search-backward
3716 "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t
)
3717 (setq par
(match-string 1))
3718 (replace-match "\\2\n"))
3721 (or (= (length (car lines
)) 0)
3722 (get-text-property 0 'org-protected
(car lines
))))
3723 (insert (pop lines
) "\n"))
3724 (and par
(insert "<p>\n")))
3725 (throw 'nextline nil
))
3728 (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line
)
3730 (insert "\n</p>\n<hr/>\n<p>\n")
3731 (insert "\n<hr/>\n"))
3732 (throw 'nextline nil
))
3734 ;; Blockquotes, verse, and center
3735 (when (equal "ORG-BLOCKQUOTE-START" line
)
3736 (org-close-par-maybe)
3737 (insert "<blockquote>\n")
3739 (throw 'nextline nil
))
3740 (when (equal "ORG-BLOCKQUOTE-END" line
)
3741 (org-close-par-maybe)
3742 (insert "\n</blockquote>\n")
3743 (throw 'nextline nil
))
3744 (when (equal "ORG-VERSE-START" line
)
3745 (org-close-par-maybe)
3746 (insert "\n<p class=\"verse\">\n")
3748 (throw 'nextline nil
))
3749 (when (equal "ORG-VERSE-END" line
)
3752 (throw 'nextline nil
))
3753 (when (equal "ORG-CENTER-START" line
)
3754 (org-close-par-maybe)
3755 (insert "\n<div style=\"text-align: center\">")
3757 (throw 'nextline nil
))
3758 (when (equal "ORG-CENTER-END" line
)
3759 (org-close-par-maybe)
3761 (throw 'nextline nil
))
3763 (let ((i (org-get-string-indentation line
)))
3765 (setq line
(concat (mapconcat 'identity
3766 (make-list (* 2 i
) "\\nbsp") "")
3767 " " (org-trim line
))))
3768 (unless (string-match "\\\\\\\\[ \t]*$" line
)
3769 (setq line
(concat line
"\\\\")))))
3771 ;; make targets to anchors
3772 (while (string-match
3773 "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line
)
3776 (setq line
(replace-match
3778 "@<a name=\"%s\" id=\"%s\">@</a>"
3779 (org-solidify-link-text (match-string 1 line
))
3780 (org-solidify-link-text (match-string 1 line
)))
3782 ((and org-export-with-toc
(equal (string-to-char line
) ?
*))
3783 ;; FIXME: NOT DEPENDENT on TOC?????????????????????
3784 (setq line
(replace-match
3785 (concat "@<span class=\"target\">" (match-string 1 line
) "@</span> ")
3786 ; (concat "@<i>" (match-string 1 line) "@</i> ")
3789 (setq line
(replace-match
3790 (concat "@<a name=\""
3791 (org-solidify-link-text (match-string 1 line
))
3792 "\" class=\"target\">" (match-string 1 line
) "@</a> ")
3795 (setq line
(org-html-handle-time-stamps line
))
3797 ;; replace "&" by "&", "<" and ">" by "<" and ">"
3798 ;; handle @<..> HTML tags (replace "@>..<" by "<..>")
3799 ;; Also handle sub_superscripts and checkboxes
3800 (or (string-match org-table-hline-regexp line
)
3801 (setq line
(org-html-expand line
)))
3805 (while (string-match org-bracket-link-analytic-regexp
++ line start
)
3806 (setq start
(match-beginning 0))
3807 (setq path
(save-match-data (org-link-unescape
3808 (match-string 3 line
))))
3810 ((match-end 2) (match-string 2 line
))
3812 (or (file-name-absolute-p path
)
3813 (string-match "^\\.\\.?/" path
)))
3816 (setq path
(org-extract-attributes (org-link-unescape path
)))
3817 (setq attr
(get-text-property 0 'org-attributes path
))
3818 (setq desc1
(if (match-end 5) (match-string 5 line
))
3819 desc2
(if (match-end 2) (concat type
":" path
) path
)
3820 descp
(and desc1
(not (equal desc1 desc2
)))
3821 desc
(or desc1 desc2
))
3822 ;; Make an image out of the description if that is so wanted
3823 (when (and descp
(org-file-image-p
3824 desc org-export-html-inline-image-extensions
))
3826 (if (string-match "^file:" desc
)
3827 (setq desc
(substring desc
(match-end 0)))))
3828 (setq desc
(org-add-props
3829 (concat "<img src=\"" desc
"\"/>")
3830 '(org-protected t
))))
3831 ;; FIXME: do we need to unescape here somewhere?
3833 ((equal type
"internal")
3837 (if (= (string-to-char path
) ?
#) "" "#")
3838 (org-solidify-link-text
3839 (save-match-data (org-link-unescape path
)) nil
)
3841 (org-export-html-format-desc desc
)
3843 ((and (equal type
"id")
3844 (setq id-file
(org-id-find-id-file path
)))
3845 ;; This is an id: link to another file (if it was the same file,
3846 ;; it would have become an internal link...)
3847 (setq id-file
(file-relative-name
3848 id-file
(file-name-directory org-current-export-file
)))
3849 (setq id-file
(concat (file-name-sans-extension id-file
)
3850 "." html-extension
))
3851 (setq rpl
(concat "<a href=\"" id-file
"#"
3852 (if (org-uuidgen-p path
) "ID-")
3855 (org-export-html-format-desc desc
)
3857 ((member type
'("http" "https"))
3858 ;; standard URL, just check if we need to inline an image
3859 (if (and (or (eq t org-export-html-inline-images
)
3860 (and org-export-html-inline-images
(not descp
)))
3862 path org-export-html-inline-image-extensions
))
3863 (setq rpl
(org-export-html-format-image
3864 (concat type
":" path
) org-par-open
))
3865 (setq link
(concat type
":" path
))
3866 (setq rpl
(concat "<a href=\""
3867 (org-export-html-format-href link
)
3869 (org-export-html-format-desc desc
)
3871 ((member type
'("ftp" "mailto" "news"))
3873 (setq link
(concat type
":" path
))
3874 (setq rpl
(concat "<a href=\""
3875 (org-export-html-format-href link
)
3877 (org-export-html-format-desc desc
)
3880 ((string= type
"coderef")
3882 (setq rpl
(format "<a href=\"#coderef-%s\" class=\"coderef\" onmouseover=\"CodeHighlightOn(this, 'coderef-%s');\" onmouseout=\"CodeHighlightOff(this, 'coderef-%s');\">%s</a>"
3884 (format (org-export-get-coderef-format path
(and descp desc
))
3885 (cdr (assoc path org-export-code-refs
))))))
3887 ((functionp (setq fnc
(nth 2 (assoc type org-link-protocols
))))
3888 ;; The link protocol has a function for format the link
3891 (funcall fnc
(org-link-unescape path
) desc1
'html
))))
3893 ((string= type
"file")
3895 (let* ((filename path
)
3896 (abs-p (file-name-absolute-p filename
))
3897 thefile file-is-image-p search
)
3899 (if (string-match "::\\(.*\\)" filename
)
3900 (setq search
(match-string 1 filename
)
3901 filename
(replace-match "" t nil filename
)))
3903 (if (functionp link-validate
)
3904 (funcall link-validate filename current-dir
)
3906 (setq file-is-image-p
3908 filename org-export-html-inline-image-extensions
))
3909 (setq thefile
(if abs-p
(expand-file-name filename
) filename
))
3910 (when (and org-export-html-link-org-files-as-html
3911 (string-match "\\.org$" thefile
))
3912 (setq thefile
(concat (substring thefile
0
3913 (match-beginning 0))
3914 "." html-extension
))
3916 ;; make sure this is can be used as target search
3917 (not (string-match "^[0-9]*$" search
))
3918 (not (string-match "^\\*" search
))
3919 (not (string-match "^/.*/$" search
)))
3920 (setq thefile
(concat thefile
"#"
3921 (org-solidify-link-text
3922 (org-link-unescape search
)))))
3923 (when (string-match "^file:" desc
)
3924 (setq desc
(replace-match "" t t desc
))
3925 (if (string-match "\\.org$" desc
)
3926 (setq desc
(replace-match "" t t desc
))))))
3927 (setq rpl
(if (and file-is-image-p
3928 (or (eq t org-export-html-inline-images
)
3929 (and org-export-html-inline-images
3932 (message "image %s %s" thefile org-par-open
)
3933 (org-export-html-format-image thefile org-par-open
))
3934 (concat "<a href=\"" thefile
"\"" attr
">"
3935 (org-export-html-format-desc desc
)
3937 (if (not valid
) (setq rpl desc
))))
3940 ;; just publish the path, as default
3941 (setq rpl
(concat "<i><" type
":"
3942 (save-match-data (org-link-unescape path
))
3944 (setq line
(replace-match rpl t t line
)
3945 start
(+ start
(length rpl
))))
3948 (if (and (string-match org-todo-line-regexp line
)
3949 (match-beginning 2))
3952 (concat (substring line
0 (match-beginning 2))
3954 (if (member (match-string 2 line
)
3957 " " (match-string 2 line
)
3958 "\"> " (org-export-html-get-todo-kwd-class-name
3959 (match-string 2 line
))
3960 "</span>" (substring line
(match-end 2)))))
3962 ;; Does this contain a reference to a footnote?
3963 (when org-export-with-footnotes
3965 (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start
)
3966 (if (get-text-property (match-beginning 2) 'org-protected line
)
3967 (setq start
(match-end 2))
3968 (let ((n (match-string 2 line
)) extra a
)
3969 (if (setq a
(assoc n footref-seen
))
3971 (setcdr a
(1+ (cdr a
)))
3972 (setq extra
(format ".%d" (cdr a
))))
3974 (push (cons n
1) footref-seen
))
3978 "%s<sup><a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a></sup>"
3979 (match-string 1 line
) n extra n n
)
3983 ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line
)
3984 ;; This is a headline
3985 (setq level
(org-tr-level (- (match-end 1) (match-beginning 1)
3987 txt
(match-string 2 line
))
3988 (if (string-match quote-re0 txt
)
3989 (setq txt
(replace-match "" t t txt
)))
3990 (if (<= level
(max umax umax-toc
))
3991 (setq head-count
(+ head-count
1)))
3993 ;; Close any local lists before inserting a new header line
3994 (while local-list-type
3995 (org-close-li (car local-list-type
))
3996 (insert (format "</%sl>\n" (car local-list-type
)))
3997 (pop local-list-type
))
3998 (setq local-list-indent nil
4000 (setq first-heading-pos
(or first-heading-pos
(point)))
4001 (org-html-level-start level txt umax
4002 (and org-export-with-toc
(<= level umax
))
4006 (when (string-match quote-re line
)
4007 (org-close-par-maybe)
4011 ((string-match "^[ \t]*- __+[ \t]*$" line
)
4012 ;; Explicit list closure
4013 (when local-list-type
4014 (let ((ind (org-get-indentation line
)))
4015 (while (and local-list-indent
4016 (<= ind
(car local-list-indent
)))
4017 (org-close-li (car local-list-type
))
4018 (insert (format "</%sl>\n" (car local-list-type
)))
4019 (pop local-list-type
)
4020 (pop local-list-indent
))
4021 (or local-list-indent
(setq in-local-list nil
))))
4022 (throw 'nextline nil
))
4024 ((and org-export-with-tables
4025 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line
))
4026 (when (not table-open
)
4028 (setq table-open t table-buffer nil table-orig-buffer nil
))
4031 (setq table-buffer
(cons line table-buffer
)
4032 table-orig-buffer
(cons origline table-orig-buffer
))
4033 (when (or (not lines
)
4034 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
4036 (setq table-open nil
4037 table-buffer
(nreverse table-buffer
)
4038 table-orig-buffer
(nreverse table-orig-buffer
))
4039 (org-close-par-maybe)
4040 (insert (org-format-table-html table-buffer table-orig-buffer
))))
4045 ((eq llt t
) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+[.)]\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
4046 ((= llt ?.
) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+\\.\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
4047 ((= llt ?\
)) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+)\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
4048 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))
4050 (setq ind
(org-get-string-indentation line
)
4051 item-type
(if (match-beginning 4) "o" "u")
4052 starter
(if (match-beginning 2)
4053 (substring (match-string 2 line
) 0 -
1))
4054 line
(substring line
(match-beginning 5))
4056 (if (and starter
(string-match "\\(.*?\\) ::[ \t]*" line
))
4058 item-tag
(match-string 1 line
)
4059 line
(substring line
(match-end 0))))
4060 (when (and (not (equal item-type
"d"))
4061 (not (string-match "[^ \t]" line
)))
4062 ;; empty line. Pretend indentation is large.
4063 (setq ind
(if org-empty-line-terminates-plain-lists
4065 (1+ (or (car local-list-indent
) 1)))))
4067 (while (and in-local-list
4068 (or (and (= ind
(car local-list-indent
))
4070 (< ind
(car local-list-indent
))))
4072 (org-close-li (car local-list-type
))
4073 (insert (format "</%sl>\n" (car local-list-type
)))
4074 (pop local-list-type
) (pop local-list-indent
)
4075 (setq in-local-list local-list-indent
))
4078 (or (not in-local-list
)
4079 (> ind
(car local-list-indent
))))
4080 ;; Start new (level of) list
4081 (org-close-par-maybe)
4083 ((equal item-type
"u") "<ul>\n<li>\n")
4084 ((equal item-type
"o") "<ol>\n<li>\n")
4085 ((equal item-type
"d")
4086 (format "<dl>\n<dt>%s</dt><dd>\n" item-tag
))))
4087 (push item-type local-list-type
)
4088 (push ind local-list-indent
)
4089 (setq in-local-list t
))
4091 ;; continue current list
4092 (org-close-li (car local-list-type
))
4094 ((equal (car local-list-type
) "d")
4095 (format "<dt>%s</dt><dd>\n" (or item-tag
"???")))
4098 ;; we did close a list, normal text follows: need <p>
4100 (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line
)
4103 (if (equal (match-string 1 line
) "X")
4105 "<b>[<span style=\"visibility:hidden;\">X</span>]</b>")
4108 ;; Empty lines start a new paragraph. If hand-formatted lists
4109 ;; are not fully interpreted, lines starting with "-", "+", "*"
4110 ;; also start a new paragraph.
4111 (if (string-match "^ [-+*]-\\|^[ \t]*$" line
) (org-open-par))
4113 ;; Is this the start of a footnote?
4114 (when org-export-with-footnotes
4115 (when (and (boundp 'footnote-section-tag-regexp
)
4116 (string-match (concat "^" footnote-section-tag-regexp
)
4119 (throw 'nextline nil
))
4120 (when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" line
)
4121 (org-close-par-maybe)
4122 (let ((n (match-string 1 line
)))
4123 (setq org-par-open t
4125 (format "<p class=\"footnote\"><sup><a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a></sup>" n n n
) t t line
)))))
4127 ;; Check if the line break needs to be conserved
4129 ((string-match "\\\\\\\\[ \t]*$" line
)
4130 (setq line
(replace-match "<br/>" t t line
)))
4131 (org-export-preserve-breaks
4132 (setq line
(concat line
"<br/>"))))
4134 ;; Check if a paragraph should be started
4136 (while (and org-par-open
4137 (string-match "\\\\par\\>" line start
))
4138 ;; Leave a space in the </p> so that the footnote matcher
4139 ;; does not see this.
4140 (if (not (get-text-property (match-beginning 0)
4141 'org-protected line
))
4142 (setq line
(replace-match "</p ><p >" t t line
)))
4143 (setq start
(match-end 0))))
4145 (insert line
"\n")))))
4147 ;; Properly close all local lists and other lists
4152 ;; Close any local lists before inserting a new header line
4153 (while local-list-type
4154 (org-close-li (car local-list-type
))
4155 (insert (format "</%sl>\n" (car local-list-type
)))
4156 (pop local-list-type
))
4157 (setq local-list-indent nil
4159 (org-html-level-start 1 nil umax
4160 (and org-export-with-toc
(<= level umax
))
4162 ;; the </div> to close the last text-... div.
4163 (when (and (> umax
0) first-heading-pos
) (insert "</div>\n"))
4166 (goto-char (point-min))
4167 (while (re-search-forward "<p class=\"footnote\">[^\000]*?\\(</p>\\|\\'\\)" nil t
)
4168 (push (match-string 0) footnotes
)
4169 (replace-match "" t t
)))
4171 (insert (format org-export-html-footnotes-section
4172 (or (nth 4 lang-words
) "Footnotes")
4173 (mapconcat 'identity
(nreverse footnotes
) "\n"))
4175 (let ((bib (org-export-html-get-bibliography)))
4177 (insert "\n" bib
"\n")))
4179 (when (plist-get opt-plist
:auto-postamble
)
4180 (insert "<div id=\"postamble\">\n")
4181 (when (and org-export-author-info author
)
4182 (insert "<p class=\"author\"> "
4183 (nth 1 lang-words
) ": " author
"\n")
4185 (if (listp (split-string email
",+ *"))
4187 (insert "<a href=\"mailto:" e
"\"><"
4189 (split-string email
",+ *"))
4190 (insert "<a href=\"mailto:" email
"\"><"
4191 email
"></a>\n")))
4193 (when (and date org-export-time-stamp-file
)
4194 (insert "<p class=\"date\"> "
4195 (nth 2 lang-words
) ": "
4197 (when org-export-creator-info
4198 (insert (format "<p class=\"creator\">HTML generated by org-mode %s in emacs %s</p>\n"
4199 org-version emacs-major-version
)))
4200 (when org-export-html-validation-link
4201 (insert org-export-html-validation-link
"\n"))
4204 (if org-export-html-with-timestamp
4205 (insert org-export-html-html-helper-timestamp
))
4206 (insert (or (plist-get opt-plist
:postamble
) ""))
4207 (insert "\n</div>\n</body>\n</html>\n"))
4209 (unless (plist-get opt-plist
:buffer-will-be-killed
)
4211 (if (eq major-mode default-major-mode
) (html-mode)))
4213 ;; insert the table of contents
4214 (goto-char (point-min))
4216 (if (or (re-search-forward
4217 "<p>\\s-*\\[TABLE-OF-CONTENTS\\]\\s-*</p>" nil t
)
4219 "\\[TABLE-OF-CONTENTS\\]" nil t
))
4221 (goto-char (match-beginning 0))
4223 (goto-char first-heading-pos
)
4224 (when (looking-at "\\s-*</p>")
4225 (goto-char (match-end 0))
4227 (insert "<div id=\"table-of-contents\">\n")
4228 (mapc 'insert thetoc
)
4229 (insert "</div>\n"))
4230 ;; remove empty paragraphs and lists
4231 (goto-char (point-min))
4232 (while (re-search-forward "<p>[ \r\n\t]*</p>" nil t
)
4234 (goto-char (point-min))
4235 (while (re-search-forward "<li>[ \r\n\t]*</li>\n?" nil t
)
4237 (goto-char (point-min))
4238 (while (re-search-forward "</ul>\\s-*<ul>\n?" nil t
)
4240 ;; Convert whitespace place holders
4241 (goto-char (point-min))
4243 (while (setq beg
(next-single-property-change (point) 'org-whitespace
))
4244 (setq n
(get-text-property beg
'org-whitespace
)
4245 end
(next-single-property-change beg
'org-whitespace
))
4247 (delete-region beg end
)
4248 (insert (format "<span style=\"visibility:hidden;\">%s</span>"
4249 (make-string n ?x
)))))
4250 (or to-buffer
(save-buffer))
4251 (goto-char (point-min))
4252 (message "Exporting... done")
4253 (if (eq to-buffer
'string
)
4254 (prog1 (buffer-substring (point-min) (point-max))
4255 (kill-buffer (current-buffer)))
4256 (current-buffer)))))
4258 (defun org-export-get-coderef-format (path desc
)
4260 (if (and desc
(string-match
4261 (regexp-quote (concat "(" path
")"))
4263 (replace-match "%s" t t desc
)
4267 (defun org-export-html-format-href (s)
4268 "Make sure the S is valid as a href reference in an XHTML document."
4271 (while (string-match "&" s start
)
4272 (setq start
(+ (match-beginning 0) 3)
4273 s
(replace-match "&" t t s
)))))
4276 (defun org-export-html-format-desc (s)
4277 "Make sure the S is valid as a description in a link."
4278 (if (and s
(not (get-text-property 1 'org-protected s
)))
4280 (org-html-do-expand s
))
4283 (defun org-export-html-format-image (src par-open
)
4284 "Create image tag with source and attributes."
4286 (if (string-match "^ltxpng/" src
)
4287 (format "<img src=\"%s\"/>" src
)
4288 (let* ((caption (org-find-text-property-in-string 'org-caption src
))
4289 (attr (org-find-text-property-in-string 'org-attributes src
))
4290 (label (org-find-text-property-in-string 'org-label src
)))
4291 (format "%s<div %sclass=\"figure\">
4292 <p><img src=\"%s\"%s /></p>%s
4294 (if org-par-open
"</p>\n" "")
4295 (if label
(format "id=\"%s\" " label
) "")
4297 (if (string-match "\\<alt=" (or attr
""))
4299 (concat " " attr
" alt=\"" src
"\""))
4300 (if caption
(concat "\n<p>" caption
"</p>") "")
4301 (if org-par-open
"\n<p>" ""))))))
4303 (defun org-export-html-get-bibliography ()
4304 "Find bibliography, cut it out and return it."
4306 (let (beg end
(cnt 1) bib
)
4308 (goto-char (point-min))
4309 (when (re-search-forward "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t
)
4310 (setq beg
(match-beginning 0))
4311 (while (re-search-forward "</?div\\>" nil t
)
4312 (setq cnt
(+ cnt
(if (string= (match-string 0) "<div") +1 -
1)))
4314 (and (looking-at ">") (forward-char 1))
4315 (setq bib
(buffer-substring beg
(point)))
4316 (delete-region beg
(point))
4317 (throw 'exit bib
))))
4320 (defvar org-table-colgroup-info nil
)
4321 (defun org-format-table-ascii (lines)
4322 "Format a table for ascii export."
4324 (setq lines
(org-split-string lines
"\n")))
4325 (if (not (string-match "^[ \t]*|" (car lines
)))
4326 ;; Table made by table.el - test for spanning
4329 ;; A normal org table
4330 ;; Get rid of hlines at beginning and end
4331 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
4332 (setq lines
(nreverse lines
))
4333 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
4334 (setq lines
(nreverse lines
))
4335 (when org-export-table-remove-special-lines
4336 ;; Check if the table has a marking column. If yes remove the
4337 ;; column and the special lines
4338 (setq lines
(org-table-clean-before-export lines
)))
4339 ;; Get rid of the vertical lines except for grouping
4340 (let ((vl (org-colgroup-info-to-vline-list org-table-colgroup-info
))
4342 (while (setq line
(pop lines
))
4343 (if (string-match org-table-hline-regexp line
)
4344 (and (string-match "|\\(.*\\)|" line
)
4345 (setq line
(replace-match " \\1" t nil line
)))
4346 (setq start
0 vl1 vl
)
4347 (while (string-match "|" line start
)
4348 (setq start
(match-end 0))
4349 (or (pop vl1
) (setq line
(replace-match " " t t line
)))))
4353 (defun org-colgroup-info-to-vline-list (info)
4356 (setq last new new
(pop info
))
4357 (if (or (memq last
'(:end
:startend
))
4358 (memq new
'(:start
:startend
)))
4361 (setq vl
(nreverse vl
))
4362 (and vl
(setcar vl nil
))
4365 (defvar org-table-number-regexp
) ; defined in org-table.el
4366 (defun org-format-table-html (lines olines
)
4367 "Find out which HTML converter to use and return the HTML code."
4369 (setq lines
(org-split-string lines
"\n")))
4370 (if (string-match "^[ \t]*|" (car lines
))
4371 ;; A normal org table
4372 (org-format-org-table-html lines
)
4373 ;; Table made by table.el - test for spanning
4374 (let* ((hlines (delq nil
(mapcar
4376 (if (string-match "^[ \t]*\\+-" x
) x
4379 (first (car hlines
))
4380 (ll (and (string-match "\\S-+" first
)
4381 (match-string 0 first
)))
4382 (re (concat "^[ \t]*" (regexp-quote ll
)))
4383 (spanning (delq nil
(mapcar (lambda (x) (not (string-match re x
)))
4385 (if (and (not spanning
)
4386 (not org-export-prefer-native-exporter-for-tables
))
4387 ;; We can use my own converter with HTML conversions
4388 (org-format-table-table-html lines
)
4389 ;; Need to use the code generator in table.el, with the original text.
4390 (org-format-table-table-html-using-table-generate-source olines
)))))
4392 (defvar org-table-number-fraction
) ; defined in org-table.el
4393 (defun org-format-org-table-html (lines &optional splice
)
4394 "Format a table into HTML."
4395 (require 'org-table
)
4396 ;; Get rid of hlines at beginning and end
4397 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
4398 (setq lines
(nreverse lines
))
4399 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
4400 (setq lines
(nreverse lines
))
4401 (when org-export-table-remove-special-lines
4402 ;; Check if the table has a marking column. If yes remove the
4403 ;; column and the special lines
4404 (setq lines
(org-table-clean-before-export lines
)))
4406 (let* ((caption (or (get-text-property 0 'org-caption
(car lines
))
4407 (get-text-property (or (next-single-property-change
4408 0 'org-caption
(car lines
))
4410 'org-caption
(car lines
))))
4411 (attributes (or (get-text-property 0 'org-attributes
(car lines
))
4412 (get-text-property (or (next-single-property-change
4413 0 'org-attributes
(car lines
))
4415 'org-attributes
(car lines
))))
4416 (html-table-tag (org-export-splice-attributes
4417 html-table-tag attributes
))
4418 (head (and org-export-highlight-first-table-line
4420 (lambda (x) (string-match "^[ \t]*|-" x
))
4424 tbopen line fields html gr colgropen
)
4425 (if splice
(setq head nil
))
4426 (unless splice
(push (if head
"<thead>" "<tbody>") html
))
4428 (while (setq line
(pop lines
))
4430 (if (string-match "^[ \t]*|-" line
)
4433 (push (if head
"</thead>" "</tbody>") html
)
4434 (if lines
(push "<tbody>" html
) (setq tbopen nil
)))
4435 (setq head nil
) ;; head ends here, first time around
4437 (throw 'next-line t
)))
4438 ;; Break the line into fields
4439 (setq fields
(org-split-string line
"[ \t]*|[ \t]*"))
4440 (unless fnum
(setq fnum
(make-vector (length fields
) 0)))
4441 (setq nlines
(1+ nlines
) i -
1)
4442 (push (concat "<tr>"
4446 (if (and (< i nlines
)
4447 (string-match org-table-number-regexp x
))
4448 (incf (aref fnum i
)))
4450 (concat (car org-export-table-header-tags
) x
4451 (cdr org-export-table-header-tags
))
4452 (concat (car org-export-table-data-tags
) x
4453 (cdr org-export-table-data-tags
))))
4457 (unless splice
(if tbopen
(push "</tbody>" html
)))
4458 (unless splice
(push "</table>\n" html
))
4459 (setq html
(nreverse html
))
4461 ;; Put in col tags with the alignment (unfortunately often ignored...)
4464 (setq gr
(pop org-table-colgroup-info
))
4465 (format "%s<col align=\"%s\"></col>%s"
4466 (if (memq gr
'(:start
:startend
))
4468 (if colgropen
"</colgroup>\n<colgroup>" "<colgroup>")
4471 (if (> (/ (float x
) nlines
) org-table-number-fraction
)
4473 (if (memq gr
'(:end
:startend
))
4474 (progn (setq colgropen nil
) "</colgroup>")
4478 (if colgropen
(setq html
(cons (car html
) (cons "</colgroup>" (cdr html
)))))
4479 ;; Since the output of HTML table formatter can also be used in
4480 ;; DocBook document, we want to always include the caption to make
4481 ;; DocBook XML file valid.
4482 (push (format "<caption>%s</caption>" (or caption
"")) html
)
4483 (push html-table-tag html
))
4484 (concat (mapconcat 'identity html
"\n") "\n")))
4486 (defun org-export-splice-attributes (tag attributes
)
4487 "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
4488 (if (not attributes
)
4490 (let (oldatt newatt
)
4491 (setq oldatt
(org-extract-attributes-from-string tag
)
4493 newatt
(cdr (org-extract-attributes-from-string attributes
)))
4495 (setq oldatt
(plist-put oldatt
(pop newatt
) (pop newatt
))))
4496 (if (string-match ">" tag
)
4498 (replace-match (concat (org-attributes-to-string oldatt
) ">")
4502 (defun org-table-clean-before-export (lines &optional maybe-quoted
)
4503 "Check if the table has a marking column.
4504 If yes remove the column and the special lines."
4505 (setq org-table-colgroup-info nil
)
4508 (lambda (x) (or (string-match "^[ \t]*|-" x
)
4511 "^[ \t]*| *\\\\?\\([\#!$*_^ /]\\) *|"
4512 "^[ \t]*| *\\([\#!$*_^ /]\\) *|")
4516 (setq org-table-clean-did-remove-column nil
)
4521 ((string-match "^[ \t]*| */ *|" x
)
4522 (setq org-table-colgroup-info
4524 (cond ((member x
'("<" "<")) :start
)
4525 ((member x
'(">" ">")) :end
)
4526 ((member x
'("<>" "<>")) :startend
)
4528 (org-split-string x
"[ \t]*|[ \t]*")))
4532 (setq org-table-clean-did-remove-column t
)
4537 ((string-match "^[ \t]*| */ *|" x
)
4538 (setq org-table-colgroup-info
4540 (cond ((member x
'("<" "<")) :start
)
4541 ((member x
'(">" ">")) :end
)
4542 ((member x
'("<>" "<>")) :startend
)
4544 (cdr (org-split-string x
"[ \t]*|[ \t]*"))))
4546 ((string-match "^[ \t]*| *[!_^/] *|" x
)
4547 nil
) ; ignore this line
4548 ((or (string-match "^\\([ \t]*\\)|-+\\+" x
)
4549 (string-match "^\\([ \t]*\\)|[^|]*|" x
))
4550 ;; remove the first column
4551 (replace-match "\\1|" t nil x
))))
4554 (defun org-format-table-table-html (lines)
4555 "Format a table generated by table.el into HTML.
4556 This conversion does *not* use `table-generate-source' from table.el.
4557 This has the advantage that Org-mode's HTML conversions can be used.
4558 But it has the disadvantage, that no cell- or row-spanning is allowed."
4559 (let (line field-buffer
4560 (head org-export-highlight-first-table-line
)
4562 (setq html
(concat html-table-tag
"\n"))
4563 (while (setq line
(pop lines
))
4564 (setq empty
" ")
4566 (if (string-match "^[ \t]*\\+-" line
)
4577 (if (equal x
"") (setq x empty
))
4579 (concat (car org-export-table-header-tags
) x
4580 (cdr org-export-table-header-tags
))
4581 (concat (car org-export-table-data-tags
) x
4582 (cdr org-export-table-data-tags
))))
4586 (setq field-buffer nil
)))
4588 (throw 'next-line t
)))
4589 ;; Break the line into fields and store the fields
4590 (setq fields
(org-split-string line
"[ \t]*|[ \t]*"))
4592 (setq field-buffer
(mapcar
4594 (concat x
"<br/>" (pop fields
)))
4596 (setq field-buffer fields
))))
4597 (setq html
(concat html
"</table>\n"))
4600 (defun org-format-table-table-html-using-table-generate-source (lines)
4601 "Format a table into html, using `table-generate-source' from table.el.
4602 This has the advantage that cell- or row-spanning is allowed.
4603 But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
4605 (with-current-buffer (get-buffer-create " org-tmp1 ")
4607 (insert (mapconcat 'identity lines
"\n"))
4608 (goto-char (point-min))
4609 (if (not (re-search-forward "|[^+]" nil t
))
4610 (error "Error processing table"))
4611 (table-recognize-table)
4612 (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
4613 (table-generate-source 'html
" org-tmp2 ")
4614 (set-buffer " org-tmp2 ")
4615 (buffer-substring (point-min) (point-max))))
4617 (defun org-export-splice-style (style extra
)
4618 "Splice EXTRA into STYLE, just before \"</style>\"."
4619 (if (and (stringp extra
)
4620 (string-match "\\S-" extra
)
4621 (string-match "</style>" style
))
4622 (concat (substring style
0 (match-beginning 0))
4624 (substring style
(match-beginning 0)))
4627 (defun org-html-handle-time-stamps (s)
4628 "Format time stamps in string S, or remove them."
4631 (while (string-match org-maybe-keyword-time-regexp s
)
4632 (or b
(setq b
(substring s
0 (match-beginning 0))))
4634 r
(substring s
0 (match-beginning 0))
4636 (format "@<span class=\"timestamp-kwd\">%s @</span>"
4637 (match-string 1 s
)))
4638 (format " @<span class=\"timestamp\">%s@</span>"
4640 (org-translate-time (match-string 3 s
)) 1 -
1)))
4641 s
(substring s
(match-end 0))))
4642 ;; Line break if line started and ended with time stamp stuff
4645 (setq r
(concat r s
))
4646 (unless (string-match "\\S-" (concat b s
))
4647 (setq r
(concat r
"@<br/>")))
4650 (defun org-export-htmlize-region-for-paste (beg end
)
4651 "Convert the region to HTML, using htmlize.el.
4652 This is much like `htmlize-region-for-paste', only that it uses
4653 the settings define in the org-... variables."
4654 (let* ((htmlize-output-type org-export-htmlize-output-type
)
4655 (htmlize-css-name-prefix org-export-htmlize-css-font-prefix
)
4656 (htmlbuf (htmlize-region beg end
)))
4658 (with-current-buffer htmlbuf
4659 (buffer-substring (plist-get htmlize-buffer-places
'content-start
)
4660 (plist-get htmlize-buffer-places
'content-end
)))
4661 (kill-buffer htmlbuf
))))
4664 (defun org-export-htmlize-generate-css ()
4665 "Create the CSS for all font definitions in the current Emacs session.
4666 Use this to create face definitions in your CSS style file that can then
4667 be used by code snippets transformed by htmlize.
4668 This command just produces a buffer that contains class definitions for all
4669 faces used in the current Emacs session. You can copy and paste the ones you
4670 need into your CSS file.
4672 If you then set `org-export-htmlize-output-type' to `css', calls to
4673 the function `org-export-htmlize-region-for-paste' will produce code
4674 that uses these same face definitions."
4677 (and (get-buffer "*html*") (kill-buffer "*html*"))
4679 (let ((fl (face-list))
4680 (htmlize-css-name-prefix "org-")
4681 (htmlize-output-type 'css
)
4683 (while (setq f
(pop fl
)
4684 i
(and f
(face-attribute f
:inherit
)))
4685 (when (and (symbolp f
) (or (not i
) (not (listp i
))))
4686 (insert (org-add-props (copy-sequence "1") nil
'face f
))))
4687 (htmlize-region (point-min) (point-max))))
4688 (switch-to-buffer "*html*")
4689 (goto-char (point-min))
4690 (if (re-search-forward "<style" nil t
)
4691 (delete-region (point-min) (match-beginning 0)))
4692 (if (re-search-forward "</style>" nil t
)
4693 (delete-region (1+ (match-end 0)) (point-max)))
4694 (beginning-of-line 1)
4695 (if (looking-at " +") (replace-match ""))
4696 (goto-char (point-min)))
4698 (defun org-html-protect (s)
4699 ;; convert & to &, < to < and > to >
4701 (while (string-match "&" s start
)
4702 (setq s
(replace-match "&" t t s
)
4703 start
(1+ (match-beginning 0))))
4704 (while (string-match "<" s
)
4705 (setq s
(replace-match "<" t t s
)))
4706 (while (string-match ">" s
)
4707 (setq s
(replace-match ">" t t s
)))
4708 ; (while (string-match "\"" s)
4709 ; (setq s (replace-match """ t t s)))
4713 (defun org-export-cleanup-toc-line (s)
4714 "Remove tags and timestamps from lines going into the toc."
4715 (when (memq org-export-with-tags
'(not-in-toc nil
))
4716 (if (string-match (org-re " +:[[:alnum:]_@:]+: *$") s
)
4717 (setq s
(replace-match "" t t s
))))
4718 (when org-export-remove-timestamps-from-toc
4719 (while (string-match org-maybe-keyword-time-regexp s
)
4720 (setq s
(replace-match "" t t s
))))
4721 (while (string-match org-bracket-link-regexp s
)
4722 (setq s
(replace-match (match-string (if (match-end 3) 3 1) s
)
4726 (defun org-html-expand (string)
4727 "Prepare STRING for HTML export. Applies all active conversions.
4728 If there are links in the string, don't modify these."
4729 (let* ((re (concat org-bracket-link-regexp
"\\|"
4730 (org-re "[ \t]+\\(:[[:alnum:]_@:]+:\\)[ \t]*$")))
4732 (while (setq m
(string-match re string
))
4733 (setq s
(substring string
0 m
)
4734 l
(match-string 0 string
)
4735 string
(substring string
(match-end 0)))
4736 (push (org-html-do-expand s
) res
)
4738 (push (org-html-do-expand string
) res
)
4739 (apply 'concat
(nreverse res
))))
4741 (defun org-html-do-expand (s)
4742 "Apply all active conversions to translate special ASCII to HTML."
4743 (setq s
(org-html-protect s
))
4744 (if org-export-html-expand
4745 (while (string-match "@<\\([^&]*\\)>" s
)
4746 (setq s
(replace-match "<\\1>" t nil s
))))
4747 (if org-export-with-emphasize
4748 (setq s
(org-export-html-convert-emphasize s
)))
4749 (if org-export-with-special-strings
4750 (setq s
(org-export-html-convert-special-strings s
)))
4751 (if org-export-with-sub-superscripts
4752 (setq s
(org-export-html-convert-sub-super s
)))
4753 (if org-export-with-TeX-macros
4754 (let ((start 0) wd ass
)
4755 (while (setq start
(string-match "\\\\\\([a-zA-Z]+\\)\\({}\\)?"
4757 (if (get-text-property (match-beginning 0) 'org-protected s
)
4758 (setq start
(match-end 0))
4759 (setq wd
(match-string 1 s
))
4760 (if (setq ass
(assoc wd org-html-entities
))
4761 (setq s
(replace-match (or (cdr ass
)
4762 (concat "&" (car ass
) ";"))
4764 (setq start
(+ start
(length wd
))))))))
4767 (defun org-create-multibrace-regexp (left right n
)
4768 "Create a regular expression which will match a balanced sexp.
4769 Opening delimiter is LEFT, and closing delimiter is RIGHT, both given
4770 as single character strings.
4771 The regexp returned will match the entire expression including the
4772 delimiters. It will also define a single group which contains the
4773 match except for the outermost delimiters. The maximum depth of
4774 stacked delimiters is N. Escaping delimiters is not possible."
4775 (let* ((nothing (concat "[^" left right
"]*?"))
4778 (next (concat "\\(?:" nothing left nothing right
"\\)+" nothing
)))
4781 re
(concat re or next
)
4782 next
(concat "\\(?:" nothing left next right
"\\)+" nothing
)))
4783 (concat left
"\\(" re
"\\)" right
)))
4785 (defvar org-match-substring-regexp
4787 "\\([^\\]\\)\\([_^]\\)\\("
4788 "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth
) "\\)"
4790 "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth
) "\\)"
4792 "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)")
4793 "The regular expression matching a sub- or superscript.")
4795 (defvar org-match-substring-with-braces-regexp
4797 "\\([^\\]\\)\\([_^]\\)\\("
4798 "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth
) "\\)"
4800 "The regular expression matching a sub- or superscript, forcing braces.")
4802 (defconst org-export-html-special-string-regexps
4803 '(("\\\\-" .
"­")
4804 ("---\\([^-]\\)" .
"—\\1")
4805 ("--\\([^-]\\)" .
"–\\1")
4806 ("\\.\\.\\." .
"…"))
4807 "Regular expressions for special string conversion.")
4809 (defun org-export-html-convert-special-strings (string)
4810 "Convert special characters in STRING to HTML."
4811 (let ((all org-export-html-special-string-regexps
)
4813 (while (setq a
(pop all
))
4814 (setq re
(car a
) rpl
(cdr a
) start
0)
4815 (while (string-match re string start
)
4816 (if (get-text-property (match-beginning 0) 'org-protected string
)
4817 (setq start
(match-end 0))
4818 (setq string
(replace-match rpl t nil string
)))))
4821 (defun org-export-html-convert-sub-super (string)
4822 "Convert sub- and superscripts in STRING to HTML."
4823 (let (key c
(s 0) (requireb (eq org-export-with-sub-superscripts
'{})))
4824 (while (string-match org-match-substring-regexp string s
)
4826 ((and requireb
(match-end 8)) (setq s
(match-end 2)))
4827 ((get-text-property (match-beginning 2) 'org-protected string
)
4828 (setq s
(match-end 2)))
4830 (setq s
(match-end 1)
4831 key
(if (string= (match-string 2 string
) "_") "sub" "sup")
4832 c
(or (match-string 8 string
)
4833 (match-string 6 string
)
4834 (match-string 5 string
))
4835 string
(replace-match
4836 (concat (match-string 1 string
)
4837 "<" key
">" c
"</" key
">")
4839 (while (string-match "\\\\\\([_^]\\)" string
)
4840 (setq string
(replace-match (match-string 1 string
) t t string
)))
4843 (defun org-export-html-convert-emphasize (string)
4846 (while (string-match org-emph-re string s
)
4848 (substring string
(match-beginning 3) (1+ (match-beginning 3)))
4849 (substring string
(match-beginning 4) (1+ (match-beginning 4)))))
4850 (setq s
(match-beginning 0)
4853 (match-string 1 string
)
4854 (nth 2 (assoc (match-string 3 string
) org-emphasis-alist
))
4855 (match-string 4 string
)
4856 (nth 3 (assoc (match-string 3 string
)
4857 org-emphasis-alist
))
4858 (match-string 5 string
))
4859 string
(replace-match rpl t t string
)
4860 s
(+ s
(- (length rpl
) 2)))
4864 (defun org-open-par ()
4865 "Insert <p>, but first close previous paragraph if any."
4866 (org-close-par-maybe)
4868 (setq org-par-open t
))
4869 (defun org-close-par-maybe ()
4870 "Close paragraph if there is one open."
4873 (setq org-par-open nil
)))
4874 (defun org-close-li (&optional type
)
4875 "Close <li> if necessary."
4876 (org-close-par-maybe)
4877 (insert (if (equal type
"d") "</dd>\n" "</li>\n")))
4879 (defvar body-only
) ; dynamically scoped into this.
4880 (defun org-html-level-start (level title umax with-toc head-count
)
4881 "Insert a new level in HTML export.
4882 When TITLE is nil, just close all open levels."
4883 (org-close-par-maybe)
4884 (let* ((target (and title
(org-get-text-property-any 0 'target title
)))
4886 (mapconcat (lambda (x)
4887 (if (org-uuidgen-p x
) (setq x
(concat "ID-" x
)))
4888 (format "<a name=\"%s\" id=\"%s\"></a>"
4890 (cdr (assoc target org-export-target-aliases
))
4895 (if (aref org-levels-open
(1- l
))
4897 (org-html-level-close l umax
)
4898 (aset org-levels-open
(1- l
) nil
)))
4901 ;; If title is nil, this means this function is called to close
4902 ;; all levels, so the rest is done only if title is given
4903 (when (string-match (org-re "\\(:[[:alnum:]_@:]+:\\)[ \t]*$") title
)
4904 (setq title
(replace-match
4905 (if org-export-with-tags
4908 " <span class=\"tag\">"
4911 (format "<span class=\"%s\">%s</span>"
4912 (org-export-html-get-tag-class-name x
)
4914 (org-split-string (match-string 1 title
) ":")
4921 (if (aref org-levels-open
(1- level
))
4925 (insert (format "<li id=\"%s\">" target
) extra-targets title
"<br/>\n")
4926 (insert "<li>" title
"<br/>\n")))
4927 (aset org-levels-open
(1- level
) t
)
4928 (org-close-par-maybe)
4930 (insert (format "<ul>\n<li id=\"%s\">" target
)
4931 extra-targets title
"<br/>\n")
4932 (insert "<ul>\n<li>" title
"<br/>\n"))))
4933 (aset org-levels-open
(1- level
) t
)
4934 (setq snumber
(org-section-number level
))
4935 (setq level
(+ level org-export-html-toplevel-hlevel -
1))
4936 (if (and org-export-with-section-numbers
(not body-only
))
4938 (format "<span class=\"section-number-%d\">%s</span>"
4941 (unless (= head-count
1) (insert "\n</div>\n"))
4942 (insert (format "\n<div id=\"outline-container-%s\" class=\"outline-%d\">\n<h%d id=\"sec-%s\">%s%s</h%d>\n<div class=\"outline-text-%d\" id=\"text-%s\">\n"
4943 snumber level level snumber extra-targets
4944 title level level snumber
))
4947 (defun org-get-text-property-any (pos prop
&optional object
)
4948 (or (get-text-property pos prop object
)
4949 (and (setq pos
(next-single-property-change pos prop object
))
4950 (get-text-property pos prop object
))))
4952 (defun org-export-html-get-tag-class-name (tag)
4953 "Turn tag into a valid class name.
4954 Replaces invalid characters with \"_\" and then prepends a prefix."
4956 (while (string-match "[^a-zA-Z0-9_]" tag
)
4957 (setq tag
(replace-match "_" t t tag
))))
4958 (concat org-export-html-tag-class-prefix tag
))
4960 (defun org-export-html-get-todo-kwd-class-name (kwd)
4961 "Turn todo keyword into a valid class name.
4962 Replaces invalid characters with \"_\" and then prepends a prefix."
4964 (while (string-match "[^a-zA-Z0-9_]" kwd
)
4965 (setq kwd
(replace-match "_" t t kwd
))))
4966 (concat org-export-html-todo-kwd-class-prefix kwd
))
4968 (defun org-html-level-close (level max-outline-level
)
4969 "Terminate one level in HTML export."
4970 (if (<= level max-outline-level
)
4973 (insert "</ul>\n")))
4975 ;;; iCalendar export
4978 (defun org-export-icalendar-this-file ()
4979 "Export current file as an iCalendar file.
4980 The iCalendar file will be located in the same directory as the Org-mode
4981 file, but with extension `.ics'."
4983 (org-export-icalendar nil buffer-file-name
))
4986 (defun org-export-icalendar-all-agenda-files ()
4987 "Export all files in `org-agenda-files' to iCalendar .ics files.
4988 Each iCalendar file will be located in the same directory as the Org-mode
4989 file, but with extension `.ics'."
4991 (apply 'org-export-icalendar nil
(org-agenda-files t
)))
4994 (defun org-export-icalendar-combine-agenda-files ()
4995 "Export all files in `org-agenda-files' to a single combined iCalendar file.
4996 The file is stored under the name `org-combined-agenda-icalendar-file'."
4998 (apply 'org-export-icalendar t
(org-agenda-files t
)))
5000 (defun org-export-icalendar (combine &rest files
)
5001 "Create iCalendar files for all elements of FILES.
5002 If COMBINE is non-nil, combine all calendar entries into a single large
5003 file and store it under the name `org-combined-agenda-icalendar-file'."
5005 (org-prepare-agenda-buffers files
)
5006 (let* ((dir (org-export-directory
5007 :ical
(list :publishing-directory
5008 org-export-publishing-directory
)))
5009 file ical-file ical-buffer category started org-agenda-new-buffers
)
5010 (and (get-buffer "*ical-tmp*") (kill-buffer "*ical-tmp*"))
5013 (if (file-name-absolute-p org-combined-agenda-icalendar-file
)
5014 org-combined-agenda-icalendar-file
5015 (expand-file-name org-combined-agenda-icalendar-file dir
))
5016 ical-buffer
(org-get-agenda-file-buffer ical-file
))
5017 (set-buffer ical-buffer
) (erase-buffer))
5018 (while (setq file
(pop files
))
5020 (org-check-agenda-file file
)
5021 (set-buffer (org-get-agenda-file-buffer file
))
5023 (setq ical-file
(concat (file-name-as-directory dir
)
5024 (file-name-sans-extension
5025 (file-name-nondirectory buffer-file-name
))
5027 (setq ical-buffer
(org-get-agenda-file-buffer ical-file
))
5028 (with-current-buffer ical-buffer
(erase-buffer)))
5029 (setq category
(or org-category
5030 (file-name-sans-extension
5031 (file-name-nondirectory buffer-file-name
))))
5032 (if (symbolp category
) (setq category
(symbol-name category
)))
5033 (let ((standard-output ical-buffer
))
5035 (and (not started
) (setq started t
)
5036 (org-start-icalendar-file org-icalendar-combined-name
))
5037 (org-start-icalendar-file category
))
5038 (org-print-icalendar-entries combine
)
5039 (when (or (and combine
(not files
)) (not combine
))
5040 (org-finish-icalendar-file)
5041 (set-buffer ical-buffer
)
5042 (run-hooks 'org-before-save-iCalendar-file-hook
)
5044 (run-hooks 'org-after-save-iCalendar-file-hook
)
5045 (and (boundp 'org-wait
) (numberp org-wait
) (sit-for org-wait
))
5047 (org-release-buffers org-agenda-new-buffers
))))
5049 (defvar org-before-save-iCalendar-file-hook nil
5050 "Hook run before an iCalendar file has been saved.
5051 This can be used to modify the result of the export.")
5053 (defvar org-after-save-iCalendar-file-hook nil
5054 "Hook run after an iCalendar file has been saved.
5055 The iCalendar buffer is still current when this hook is run.
5056 A good way to use this is to tell a desktop calendar application to re-read
5057 the iCalendar file.")
5059 (defvar org-agenda-default-appointment-duration
) ; defined in org-agenda.el
5060 (defun org-print-icalendar-entries (&optional combine
)
5061 "Print iCalendar entries for the current Org-mode file to `standard-output'.
5062 When COMBINE is non nil, add the category to each line."
5063 (require 'org-agenda
)
5064 (let ((re1 (concat org-ts-regexp
"\\|<%%([^>\n]+>"))
5065 (re2 (concat "--?-?\\(" org-ts-regexp
"\\)"))
5066 (dts (org-ical-ts-to-string
5067 (format-time-string (cdr org-time-stamp-formats
) (current-time))
5069 hd ts ts2 state status
(inc t
) pos b sexp rrule
5070 scheduledp deadlinep todo prefix due start
5071 tmp pri categories location summary desc uid
5072 (sexp-buffer (get-buffer-create "*ical-tmp*")))
5073 (org-refresh-category-properties)
5075 (goto-char (point-min))
5076 (while (re-search-forward re1 nil t
)
5079 (when (boundp 'org-icalendar-verify-function
)
5080 (unless (funcall org-icalendar-verify-function
)
5081 (outline-next-heading)
5084 (setq pos
(match-beginning 0)
5087 hd
(condition-case nil
5088 (org-icalendar-cleanup-string
5090 (error (throw :skip nil
)))
5091 summary
(org-icalendar-cleanup-string
5092 (org-entry-get nil
"SUMMARY"))
5093 desc
(org-icalendar-cleanup-string
5094 (or (org-entry-get nil
"DESCRIPTION")
5095 (and org-icalendar-include-body
(org-get-entry)))
5096 t org-icalendar-include-body
)
5097 location
(org-icalendar-cleanup-string
5098 (org-entry-get nil
"LOCATION" 'selective
))
5099 uid
(if org-icalendar-store-UID
5101 (or (org-id-get) (org-id-new)))
5102 categories
(org-export-get-categories)
5103 deadlinep nil scheduledp nil
)
5104 (if (looking-at re2
)
5106 (goto-char (match-end 0))
5107 (setq ts2
(match-string 1)
5108 inc
(not (string-match "[0-9]\\{1,2\\}:[0-9][0-9]" ts2
))))
5109 (setq tmp
(buffer-substring (max (point-min)
5110 (- pos org-ds-keyword-length
))
5112 ts2
(if (string-match "[0-9]\\{1,2\\}:[0-9][0-9]-\\([0-9]\\{1,2\\}:[0-9][0-9]\\)" ts
)
5115 (replace-match "\\1" t nil ts
))
5117 deadlinep
(string-match org-deadline-regexp tmp
)
5118 scheduledp
(string-match org-scheduled-regexp tmp
)
5119 todo
(org-get-todo-state)
5120 ;; donep (org-entry-is-done-p)
5125 (not (memq 'event-if-todo org-icalendar-use-deadline
))
5126 (not (memq 'event-if-not-todo org-icalendar-use-deadline
))))
5131 (not (memq 'event-if-todo org-icalendar-use-scheduled
))
5132 (not (memq 'event-if-not-todo org-icalendar-use-scheduled
))))
5134 (setq prefix
(if deadlinep
"DL-" (if scheduledp
"SC-" "TS-")))
5135 (if (or (string-match org-tr-regexp hd
)
5136 (string-match org-ts-regexp hd
))
5137 (setq hd
(replace-match "" t t hd
)))
5138 (if (string-match "\\+\\([0-9]+\\)\\([dwmy]\\)>" ts
)
5140 (concat "\nRRULE:FREQ="
5143 '(("d" .
"DAILY")("w" .
"WEEKLY")
5144 ("m" .
"MONTHLY")("y" .
"YEARLY"))))
5145 ";INTERVAL=" (match-string 1 ts
)))
5147 (setq summary
(or summary hd
))
5148 (if (string-match org-bracket-link-regexp summary
)
5150 (replace-match (if (match-end 3)
5151 (match-string 3 summary
)
5152 (match-string 1 summary
))
5154 (if deadlinep
(setq summary
(concat "DL: " summary
)))
5155 (if scheduledp
(setq summary
(concat "S: " summary
)))
5156 (if (string-match "\\`<%%" ts
)
5157 (with-current-buffer sexp-buffer
5158 (insert (substring ts
1 -
1) " " summary
"\n"))
5159 (princ (format "BEGIN:VEVENT
5167 (org-ical-ts-to-string ts
"DTSTART")
5168 (org-ical-ts-to-string ts2
"DTEND" inc
)
5170 (if (and desc
(string-match "\\S-" desc
))
5171 (concat "\nDESCRIPTION: " desc
) "")
5172 (if (and location
(string-match "\\S-" location
))
5173 (concat "\nLOCATION: " location
) "")
5175 (when (and org-icalendar-include-sexps
5176 (condition-case nil
(require 'icalendar
) (error nil
))
5177 (fboundp 'icalendar-export-region
))
5178 ;; Get all the literal sexps
5179 (goto-char (point-min))
5180 (while (re-search-forward "^&?%%(" nil t
)
5183 (setq b
(match-beginning 0))
5184 (goto-char (1- (match-end 0)))
5187 (setq sexp
(buffer-substring b
(point)))
5188 (with-current-buffer sexp-buffer
5189 (insert sexp
"\n"))))
5190 (princ (org-diary-to-ical-string sexp-buffer
))
5191 (kill-buffer sexp-buffer
))
5193 (when org-icalendar-include-todo
5194 (setq prefix
"TODO-")
5195 (goto-char (point-min))
5196 (while (re-search-forward org-todo-line-regexp nil t
)
5199 (when (boundp 'org-icalendar-verify-function
)
5200 (unless (funcall org-icalendar-verify-function
)
5201 (outline-next-heading)
5204 (setq state
(match-string 2))
5205 (setq status
(if (member state org-done-keywords
)
5206 "COMPLETED" "NEEDS-ACTION"))
5208 (or (not (member state org-done-keywords
))
5209 (eq org-icalendar-include-todo
'all
))
5210 (not (member org-archive-tag
(org-get-tags-at)))
5212 (setq hd
(match-string 3)
5213 summary
(org-icalendar-cleanup-string
5214 (org-entry-get nil
"SUMMARY"))
5215 desc
(org-icalendar-cleanup-string
5216 (or (org-entry-get nil
"DESCRIPTION")
5217 (and org-icalendar-include-body
(org-get-entry)))
5218 t org-icalendar-include-body
)
5219 location
(org-icalendar-cleanup-string
5220 (org-entry-get nil
"LOCATION" 'selective
))
5221 due
(and (member 'todo-due org-icalendar-use-deadline
)
5222 (org-entry-get nil
"DEADLINE"))
5223 start
(and (member 'todo-start org-icalendar-use-scheduled
)
5224 (org-entry-get nil
"SCHEDULED"))
5225 categories
(org-export-get-categories)
5226 uid
(if org-icalendar-store-UID
5228 (or (org-id-get) (org-id-new))))
5229 (and due
(setq due
(org-ical-ts-to-string due
"DUE")))
5230 (and start
(setq start
(org-ical-ts-to-string start
"DTSTART")))
5232 (if (string-match org-bracket-link-regexp hd
)
5233 (setq hd
(replace-match (if (match-end 3) (match-string 3 hd
)
5234 (match-string 1 hd
))
5236 (if (string-match org-priority-regexp hd
)
5237 (setq pri
(string-to-char (match-string 2 hd
))
5238 hd
(concat (substring hd
0 (match-beginning 1))
5239 (substring hd
(match-end 1))))
5240 (setq pri org-default-priority
))
5241 (setq pri
(floor (- 9 (* 8.
(/ (float (- org-lowest-priority pri
))
5242 (- org-lowest-priority org-highest-priority
))))))
5244 (princ (format "BEGIN:VTODO
5256 (if (and location
(string-match "\\S-" location
))
5257 (concat "\nLOCATION: " location
) "")
5258 (if (and desc
(string-match "\\S-" desc
))
5259 (concat "\nDESCRIPTION: " desc
) "")
5260 (if due
(concat "\n" due
) "")
5264 (defun org-export-get-categories ()
5265 "Get categories according to `org-icalendar-categories'."
5266 (let ((cs org-icalendar-categories
) c rtn tmp
)
5267 (while (setq c
(pop cs
))
5269 ((eq c
'category
) (push (org-get-category) rtn
))
5271 (setq tmp
(org-get-todo-state))
5272 (and tmp
(push tmp rtn
)))
5274 (setq rtn
(append (nreverse (org-get-local-tags-at (point))) rtn
)))
5276 (setq rtn
(append (nreverse (org-get-tags-at (point))) rtn
)))))
5277 (mapconcat 'identity
(nreverse rtn
) ",")))
5279 (defun org-icalendar-cleanup-string (s &optional is-body maxlength
)
5280 "Take out stuff and quote what needs to be quoted.
5281 When IS-BODY is non-nil, assume that this is the body of an item, clean up
5282 whitespace, newlines, drawers, and timestamps, and cut it down to MAXLENGTH
5287 (let ((re (concat "\\(" org-drawer-regexp
"\\)[^\000]*?:END:.*\n?"))
5288 (re2 (concat "^[ \t]*" org-keyword-time-regexp
".*\n?")))
5289 (while (string-match re s
) (setq s
(replace-match "" t t s
)))
5290 (while (string-match re2 s
) (setq s
(replace-match "" t t s
)))))
5292 (while (string-match "\\([,;]\\)" s start
)
5293 (setq start
(+ (match-beginning 0) 2)
5294 s
(replace-match "\\\\\\1" nil nil s
))))
5295 (setq s
(org-trim s
))
5297 (while (string-match "[ \t]*\n[ \t]*" s
)
5298 (setq s
(replace-match "\\n" t t s
))))
5301 (if (and (numberp maxlength
)
5302 (> (length s
) maxlength
))
5303 (setq s
(substring s
0 maxlength
)))))
5306 (defun org-icalendar-cleanup-string-rfc2455 (s &optional is-body maxlength
)
5307 "Take out stuff and quote what needs to be quoted.
5308 When IS-BODY is non-nil, assume that this is the body of an item, clean up
5309 whitespace, newlines, drawers, and timestamps, and cut it down to MAXLENGTH
5311 This seems to be more like RFC 2455, but it causes problems, so it is
5312 not used right now."
5316 (let ((re (concat "\\(" org-drawer-regexp
"\\)[^\000]*?:END:.*\n?"))
5317 (re2 (concat "^[ \t]*" org-keyword-time-regexp
".*\n?")))
5318 (while (string-match re s
) (setq s
(replace-match "" t t s
)))
5319 (while (string-match re2 s
) (setq s
(replace-match "" t t s
)))
5320 (setq s
(org-trim s
))
5321 (while (string-match "[ \t]*\n[ \t]*" s
)
5322 (setq s
(replace-match "\\n" t t s
)))
5324 (if (and (numberp maxlength
)
5325 (> (length s
) maxlength
))
5326 (setq s
(substring s
0 maxlength
)))))
5327 (setq s
(org-trim s
)))
5328 (while (string-match "\"" s
) (setq s
(replace-match "''" t t s
)))
5329 (when (string-match "[;,:]" s
) (setq s
(concat "\"" s
"\"")))
5332 (defun org-get-entry ()
5333 "Clean-up description string."
5335 (org-back-to-heading t
)
5336 (buffer-substring (point-at-bol 2) (org-end-of-subtree t
))))
5338 (defun org-start-icalendar-file (name)
5339 "Start an iCalendar file by inserting the header."
5340 (let ((user user-full-name
)
5341 (name (or name
"unknown"))
5342 (timezone (cadr (current-time-zone))))
5344 (format "BEGIN:VCALENDAR
5347 PRODID:-//%s//Emacs with Org-mode//EN
5349 CALSCALE:GREGORIAN\n" name user timezone
))))
5351 (defun org-finish-icalendar-file ()
5352 "Finish an iCalendar file by inserting the END statement."
5353 (princ "END:VCALENDAR\n"))
5355 (defun org-ical-ts-to-string (s keyword
&optional inc
)
5356 "Take a time string S and convert it to iCalendar format.
5357 KEYWORD is added in front, to make a complete line like DTSTART....
5358 When INC is non-nil, increase the hour by two (if time string contains
5359 a time), or the day by one (if it does not contain a time)."
5360 (let ((t1 (org-parse-time-string s
'nodefault
))
5361 t2 fmt have-time time
)
5362 (if (and (car t1
) (nth 1 t1
) (nth 2 t1
))
5363 (setq t2 t1 have-time t
)
5364 (setq t2
(org-parse-time-string s
)))
5365 (let ((s (car t2
)) (mi (nth 1 t2
)) (h (nth 2 t2
))
5366 (d (nth 3 t2
)) (m (nth 4 t2
)) (y (nth 5 t2
)))
5369 (if org-agenda-default-appointment-duration
5370 (setq mi
(+ org-agenda-default-appointment-duration mi
))
5373 (setq time
(encode-time s mi h d m y
)))
5374 (setq fmt
(if have-time
":%Y%m%dT%H%M%S" ";VALUE=DATE:%Y%m%d"))
5375 (concat keyword
(format-time-string fmt time
))))
5379 (defun org-export-as-xoxo-insert-into (buffer &rest output
)
5380 (with-current-buffer buffer
5381 (apply 'insert output
)))
5382 (put 'org-export-as-xoxo-insert-into
'lisp-indent-function
1)
5385 (defun org-export-as-xoxo (&optional buffer
)
5386 "Export the org buffer as XOXO.
5387 The XOXO buffer is named *xoxo-<source buffer name>*"
5388 (interactive (list (current-buffer)))
5389 ;; A quickie abstraction
5391 ;; Output everything as XOXO
5392 (with-current-buffer (get-buffer buffer
)
5393 (let* ((pos (point))
5394 (opt-plist (org-combine-plists (org-default-export-plist)
5395 (org-infile-export-plist)))
5396 (filename (concat (file-name-as-directory
5397 (org-export-directory :xoxo opt-plist
))
5398 (file-name-sans-extension
5399 (file-name-nondirectory buffer-file-name
))
5401 (out (find-file-noselect filename
))
5404 (goto-char (point-min)) ;; CD: beginning-of-buffer is not allowed.
5405 ;; Check the output buffer is empty.
5406 (with-current-buffer out
(erase-buffer))
5407 ;; Kick off the output
5408 (org-export-as-xoxo-insert-into out
"<ol class='xoxo'>\n")
5409 (while (re-search-forward "^\\(\\*+\\)[ \t]+\\(.+\\)" (point-max) 't
)
5410 (let* ((hd (match-string-no-properties 1))
5413 (match-string-no-properties 2)
5415 (goto-char (match-end 0))
5420 (if (looking-at "^[ \t]\\(.*\\)")
5421 (setq str
(concat str
(match-string-no-properties 1)))
5422 (throw 'loop str
)))))))))
5424 ;; Handle level rendering
5426 ((> level last-level
)
5427 (org-export-as-xoxo-insert-into out
"\n<ol>\n"))
5429 ((< level last-level
)
5430 (dotimes (- (- last-level level
) 1)
5432 (org-export-as-xoxo-insert-into out
"</li>\n"))
5433 (org-export-as-xoxo-insert-into out
"</ol>\n"))
5435 (org-export-as-xoxo-insert-into out
"</li>\n")
5436 (setq hanging-li nil
)))
5438 ((equal level last-level
)
5440 (org-export-as-xoxo-insert-into out
"</li>\n")))
5443 (setq last-level level
)
5445 ;; And output the new li
5446 (setq hanging-li
't
)
5447 (if (equal ?
+ (elt text
0))
5448 (org-export-as-xoxo-insert-into out
"<li class='" (substring text
1) "'>")
5449 (org-export-as-xoxo-insert-into out
"<li>" text
))))
5451 ;; Finally finish off the ol
5452 (dotimes (- last-level
1)
5454 (org-export-as-xoxo-insert-into out
"</li>\n"))
5455 (org-export-as-xoxo-insert-into out
"</ol>\n"))
5458 ;; Finish the buffer off and clean it up.
5459 (switch-to-buffer-other-window out
)
5460 (indent-region (point-min) (point-max) nil
)
5462 (goto-char (point-min))
5467 ;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
5469 ;;; org-exp.el ends here