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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
32 (require 'org-exp-blocks
)
37 (declare-function org-export-latex-preprocess
"org-latex" (parameters))
38 (declare-function org-export-ascii-preprocess
"org-ascii" (parameters))
39 (declare-function org-export-html-preprocess
"org-html" (parameters))
40 (declare-function org-export-docbook-preprocess
"org-docbook" (parameters))
41 (declare-function org-infojs-options-inbuffer-template
"org-jsinfo" ())
42 (declare-function org-export-htmlize-region-for-paste
"org-html" (beg end
))
43 (declare-function htmlize-buffer
"ext:htmlize" (&optional buffer
))
44 (declare-function org-inlinetask-remove-END-maybe
"org-inlinetask" ())
45 (autoload 'org-export-generic
"org-export-generic" "Export using the generic exporter" t
)
46 (defgroup org-export nil
47 "Options for exporting org-listings."
51 (defgroup org-export-general nil
52 "General options for exporting Org-mode files."
53 :tag
"Org Export General"
56 (defcustom org-export-allow-BIND
'confirm
57 "Non-nil means, allow #+BIND to define local variable values for export.
58 This is a potential security risk, which is why the user must confirm the
60 :group
'org-export-general
62 (const :tag
"Never" nil
)
63 (const :tag
"Always" t
)
64 (const :tag
"Make the user confirm for each file" confirm
)))
67 (defvar org-export-publishing-directory nil
)
69 (defcustom org-export-show-temporary-export-buffer t
70 "Non-nil means, show buffer after exporting to temp buffer.
71 When Org exports to a file, the buffer visiting that file is ever
72 shown, but remains buried. However, when exporting to a temporary
73 buffer, that buffer is popped up in a second window. When this variable
74 is nil, the buffer remains buried also in these cases."
75 :group
'org-export-general
78 (defcustom org-export-copy-to-kill-ring t
79 "Non-nil means, exported stuff will also be pushed onto the kill ring."
80 :group
'org-export-general
83 (defcustom org-export-run-in-background nil
84 "Non-nil means export and publishing commands will run in background.
85 This works by starting up a separate Emacs process visiting the same file
86 and doing the export from there.
87 Not all export commands are affected by this - only the ones which
88 actually write to a file, and that do not depend on the buffer state.
90 If this option is nil, you can still get background export by calling
91 `org-export' with a double prefix arg: `C-u C-u C-c C-e'.
93 If this option is t, the double prefix can be used to exceptionally
94 force an export command into the current process."
95 :group
'org-export-general
98 (defcustom org-export-select-tags
'("export")
99 "Tags that select a tree for export.
100 If any such tag is found in a buffer, all trees that do not carry one
101 of these tags will be deleted before export.
102 Inside trees that are selected like this, you can still deselect a
103 subtree by tagging it with one of the `org-export-exclude-tags'."
104 :group
'org-export-general
105 :type
'(repeat (string :tag
"Tag")))
107 (defcustom org-export-exclude-tags
'("noexport")
108 "Tags that exclude a tree from export.
109 All trees carrying any of these tags will be excluded from export.
110 This is without condition, so even subtrees inside that carry one of the
111 `org-export-select-tags' will be removed."
112 :group
'org-export-general
113 :type
'(repeat (string :tag
"Tag")))
115 ;; FIXME: rename, this is a general variable
116 (defcustom org-export-html-expand t
117 "Non-nil means, for HTML export, treat @<...> as HTML tag.
118 When nil, these tags will be exported as plain text and therefore
119 not be interpreted by a browser.
121 This option can also be set with the +OPTIONS line, e.g. \"@:nil\"."
122 :group
'org-export-html
123 :group
'org-export-general
126 (defcustom org-export-with-special-strings t
127 "Non-nil means, interpret \"\-\", \"--\" and \"---\" for export.
128 When this option is turned on, these strings will be exported as:
131 -----+----------+--------
137 This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
138 :group
'org-export-translation
141 (defcustom org-export-html-link-up
""
142 "Where should the \"UP\" link of exported HTML pages lead?"
143 :group
'org-export-html
144 :group
'org-export-general
145 :type
'(string :tag
"File or URL"))
147 (defcustom org-export-html-link-home
""
148 "Where should the \"HOME\" link of exported HTML pages lead?"
149 :group
'org-export-html
150 :group
'org-export-general
151 :type
'(string :tag
"File or URL"))
153 (defcustom org-export-language-setup
154 '(("en" "Author" "Date" "Table of Contents" "Footnotes")
155 ("ca" "Autor" "Data" "Índex" "Peus de pàgina")
156 ("cs" "Autor" "Datum" "Obsah" "Pozn\xe1mky pod carou")
157 ("da" "Ophavsmand" "Dato" "Indhold" "Fodnoter")
158 ("de" "Autor" "Datum" "Inhaltsverzeichnis" "Fußnoten")
159 ("eo" "Aŭtoro" "Dato" "Enhavo" "Piednotoj")
160 ("es" "Autor" "Fecha" "Índice" "Pies de página")
161 ("fi" "Tekijä" "Päivämäärä" "Sisällysluettelo" "Alaviitteet")
162 ("fr" "Auteur" "Date" "Table des matières" "Notes de bas de page")
163 ("hu" "Szerzõ" "Dátum" "Tartalomjegyzék" "Lábjegyzet")
164 ("is" "Höfundur" "Dagsetning" "Efnisyfirlit" "Aftanmálsgreinar")
165 ("it" "Autore" "Data" "Indice" "Note a piè di pagina")
166 ("nl" "Auteur" "Datum" "Inhoudsopgave" "Voetnoten")
167 ("no" "Forfatter" "Dato" "Innhold" "Fotnoter")
168 ("nb" "Forfatter" "Dato" "Innhold" "Fotnoter") ;; nb = Norsk (bokm.l)
169 ("nn" "Forfattar" "Dato" "Innhald" "Fotnotar") ;; nn = Norsk (nynorsk)
170 ("pl" "Autor" "Data" "Spis treści" "Przypis")
171 ("sv" "Författare" "Datum" "Innehåll" "Fotnoter"))
172 "Terms used in export text, translated to different languages.
173 Use the variable `org-export-default-language' to set the language,
174 or use the +OPTION lines for a per-file setting."
175 :group
'org-export-general
178 (string :tag
"HTML language tag")
179 (string :tag
"Author")
181 (string :tag
"Table of Contents")
182 (string :tag
"Footnotes"))))
184 (defcustom org-export-default-language
"en"
185 "The default language of HTML export, as a string.
186 This should have an association in `org-export-language-setup'."
187 :group
'org-export-general
190 (defvar org-export-page-description
""
191 "The page description, for the XHTML meta tag.
192 This is best set with the #+DESCRIPTION line in a file, it does not make
193 sense to set this globally.")
195 (defvar org-export-page-keywords
""
196 "The page description, for the XHTML meta tag.
197 This is best set with the #+KEYWORDS line in a file, it does not make
198 sense to set this globally.")
200 (defcustom org-export-skip-text-before-1st-heading nil
201 "Non-nil means, skip all text before the first headline when exporting.
202 When nil, that text is exported as well."
203 :group
'org-export-general
206 (defcustom org-export-headline-levels
3
207 "The last level which is still exported as a headline.
208 Inferior levels will produce itemize lists when exported.
209 Note that a numeric prefix argument to an exporter function overrides
212 This option can also be set with the +OPTIONS line, e.g. \"H:2\"."
213 :group
'org-export-general
216 (defcustom org-export-with-section-numbers t
217 "Non-nil means, add section numbers to headlines when exporting.
219 This option can also be set with the +OPTIONS line, e.g. \"num:t\"."
220 :group
'org-export-general
223 (defcustom org-export-section-number-format
'((("1" ".")) .
"")
224 "Format of section numbers for export.
225 The variable has two components.
226 1. A list of lists, each indicating a counter type and a separator.
227 The counter type can be any of \"1\", \"A\", \"a\", \"I\", or \"a\".
228 It causes causes numeric, alphabetic, or roman counters, respectively.
229 The separator is only used if another counter for a subsection is being
231 If there are more numbered section levels than entries in this lists,
232 then the last entry will be reused.
233 2. A terminator string that will be added after the entire
235 :group
'org-export-general
239 (string :tag
"Counter Type")
240 (string :tag
"Separator ")))
241 (string :tag
"Terminator")))
243 (defcustom org-export-with-toc t
244 "Non-nil means, create a table of contents in exported files.
245 The TOC contains headlines with levels up to`org-export-headline-levels'.
246 When an integer, include levels up to N in the toc, this may then be
247 different from `org-export-headline-levels', but it will not be allowed
248 to be larger than the number of headline levels.
249 When nil, no table of contents is made.
251 Headlines which contain any TODO items will be marked with \"(*)\" in
252 ASCII export, and with red color in HTML output, if the option
253 `org-export-mark-todo-in-toc' is set.
255 In HTML output, the TOC will be clickable.
257 This option can also be set with the +OPTIONS line, e.g. \"toc:nil\"
259 :group
'org-export-general
261 (const :tag
"No Table of Contents" nil
)
262 (const :tag
"Full Table of Contents" t
)
263 (integer :tag
"TOC to level")))
265 (defcustom org-export-mark-todo-in-toc nil
266 "Non-nil means, mark TOC lines that contain any open TODO items."
267 :group
'org-export-general
270 (defcustom org-export-with-todo-keywords t
271 "Non-nil means, include TODO keywords in export.
272 When nil, remove all these keywords from the export."
273 :group
'org-export-general
276 (defcustom org-export-with-priority nil
277 "Non-nil means, include priority cookies in export.
278 When nil, remove priority cookies for export."
279 :group
'org-export-general
282 (defcustom org-export-preserve-breaks nil
283 "Non-nil means, preserve all line breaks when exporting.
284 Normally, in HTML output paragraphs will be reformatted. In ASCII
285 export, line breaks will always be preserved, regardless of this variable.
287 This option can also be set with the +OPTIONS line, e.g. \"\\n:t\"."
288 :group
'org-export-general
291 (defcustom org-export-with-archived-trees
'headline
292 "Whether subtrees with the ARCHIVE tag should be exported.
293 This can have three different values
294 nil Do not export, pretend this tree is not present
295 t Do export the entire tree
296 headline Only export the headline, but skip the tree below it."
297 :group
'org-export-general
300 (const :tag
"not at all" nil
)
301 (const :tag
"headline only" 'headline
)
302 (const :tag
"entirely" t
)))
304 (defcustom org-export-author-info t
305 "Non-nil means, insert author name and email into the exported file.
307 This option can also be set with the +OPTIONS line,
308 e.g. \"author-info:nil\"."
309 :group
'org-export-general
312 (defcustom org-export-creator-info t
313 "Non-nil means, the postamble should contain a creator sentence.
314 This sentence is \"HTML generated by org-mode XX in emacs XXX\"."
315 :group
'org-export-general
318 (defcustom org-export-time-stamp-file t
319 "Non-nil means, insert a time stamp into the exported file.
320 The time stamp shows when the file was created.
322 This option can also be set with the +OPTIONS line,
323 e.g. \"timestamp:nil\"."
324 :group
'org-export-general
327 (defcustom org-export-with-timestamps t
328 "If nil, do not export time stamps and associated keywords."
329 :group
'org-export-general
332 (defcustom org-export-remove-timestamps-from-toc t
333 "If t, remove timestamps from the table of contents entries."
334 :group
'org-export-general
337 (defcustom org-export-with-tags
'not-in-toc
338 "If nil, do not export tags, just remove them from headlines.
339 If this is the symbol `not-in-toc', tags will be removed from table of
340 contents entries, but still be shown in the headlines of the document.
342 This option can also be set with the +OPTIONS line, e.g. \"tags:nil\"."
343 :group
'org-export-general
345 (const :tag
"Off" nil
)
346 (const :tag
"Not in TOC" not-in-toc
)
347 (const :tag
"On" t
)))
349 (defcustom org-export-with-drawers nil
350 "Non-nil means, export with drawers like the property drawer.
351 When t, all drawers are exported. This may also be a list of
352 drawer names to export."
353 :group
'org-export-general
355 (const :tag
"All drawers" t
)
356 (const :tag
"None" nil
)
357 (repeat :tag
"Selected drawers"
358 (string :tag
"Drawer name"))))
360 (defvar org-export-first-hook nil
361 "Hook called as the first thing in each exporter.
362 Good for general initialization")
364 (defvar org-export-preprocess-hook nil
365 "Hook for preprocessing an export buffer.
366 Pretty much the first thing when exporting is running this hook.")
368 (defvar org-export-preprocess-after-include-files-hook nil
369 "Hook for preprocessing an export buffer.
370 This is run after the contents of included files have been inserted.")
372 (defvar org-export-preprocess-after-tree-selection-hook nil
373 "Hook for preprocessing an export buffer.
374 This is run after selection of trees to be exported has happened.
375 This selection includes tags-based selection, as well as removal
376 of commented and archived trees.")
378 (defvar org-export-preprocess-before-selecting-backend-code-hook nil
379 "Hook for preprocessing an export buffer.
380 This is run just before backend-specific blocks get selected.")
382 (defvar org-export-preprocess-after-blockquote-hook nil
383 "Hook for preprocessing an export buffer.
384 This is run after blockquote/quote/verse/center have been marked
387 (defvar org-export-preprocess-before-normalizing-links-hook nil
388 "Hook for preprocessing an export buffer.
389 This hook is run before links are normalized.")
391 (defvar org-export-preprocess-before-backend-specifics-hook nil
392 "Hook run before backend-specific functions are called during preprocessing.")
394 (defvar org-export-preprocess-final-hook nil
395 "Hook for preprocessing an export buffer.
396 This is run as the last thing in the preprocessing buffer, just before
397 returning the buffer string to the backend.")
399 (defgroup org-export-translation nil
400 "Options for translating special ascii sequences for the export backends."
401 :tag
"Org Export Translation"
404 (defcustom org-export-with-emphasize t
405 "Non-nil means, interpret *word*, /word/, and _word_ as emphasized text.
406 If the export target supports emphasizing text, the word will be
407 typeset in bold, italic, or underlined, respectively. Works only for
408 single words, but you can say: I *really* *mean* *this*.
409 Not all export backends support this.
411 This option can also be set with the +OPTIONS line, e.g. \"*:nil\"."
412 :group
'org-export-translation
415 (defcustom org-export-with-footnotes t
416 "If nil, export [1] as a footnote marker.
417 Lines starting with [1] will be formatted as footnotes.
419 This option can also be set with the +OPTIONS line, e.g. \"f:nil\"."
420 :group
'org-export-translation
423 (defcustom org-export-with-sub-superscripts t
424 "Non-nil means, interpret \"_\" and \"^\" for export.
425 When this option is turned on, you can use TeX-like syntax for sub- and
426 superscripts. Several characters after \"_\" or \"^\" will be
427 considered as a single item - so grouping with {} is normally not
428 needed. For example, the following things will be parsed as single
429 sub- or superscripts.
431 10^24 or 10^tau several digits will be considered 1 item.
432 10^-12 or 10^-tau a leading sign with digits or a word
433 x^2-y^3 will be read as x^2 - y^3, because items are
434 terminated by almost any nonword/nondigit char.
435 x_{i^2} or x^(2-i) braces or parenthesis do grouping.
437 Still, ambiguity is possible - so when in doubt use {} to enclose the
438 sub/superscript. If you set this variable to the symbol `{}',
439 the braces are *required* in order to trigger interpretations as
440 sub/superscript. This can be helpful in documents that need \"_\"
441 frequently in plain text.
443 Not all export backends support this, but HTML does.
445 This option can also be set with the +OPTIONS line, e.g. \"^:nil\"."
446 :group
'org-export-translation
448 (const :tag
"Always interpret" t
)
449 (const :tag
"Only with braces" {})
450 (const :tag
"Never interpret" nil
)))
452 (defcustom org-export-with-TeX-macros t
453 "Non-nil means, interpret simple TeX-like macros when exporting.
454 For example, HTML export converts \\alpha to α and \\AA to Å.
455 Not only real TeX macros will work here, but the standard HTML entities
456 for math can be used as macro names as well. For a list of supported
457 names in HTML export, see the constant `org-html-entities'.
458 Not all export backends support this.
460 This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"."
461 :group
'org-export-translation
462 :group
'org-export-latex
465 (defcustom org-export-with-LaTeX-fragments nil
466 "Non-nil means, convert LaTeX fragments to images when exporting to HTML.
467 When set, the exporter will find LaTeX environments if the \\begin line is
468 the first non-white thing on a line. It will also find the math delimiters
469 like $a=b$ and \\( a=b \\) for inline math, $$a=b$$ and \\[ a=b \\] for
472 This option can also be set with the +OPTIONS line, e.g. \"LaTeX:t\".
474 The default is nil, because this option needs the `dvipng' program which
475 is not available on all systems."
476 :group
'org-export-translation
477 :group
'org-export-latex
480 (defcustom org-export-with-fixed-width t
481 "Non-nil means, lines starting with \":\" will be in fixed width font.
482 This can be used to have pre-formatted text, fragments of code etc. For
484 : ;; Some Lisp examples
487 will be looking just like this in also HTML. See also the QUOTE keyword.
488 Not all export backends support this.
490 This option can also be set with the +OPTIONS line, e.g. \"::nil\"."
491 :group
'org-export-translation
494 (defcustom org-match-sexp-depth
3
495 "Number of stacked braces for sub/superscript matching.
496 This has to be set before loading org.el to be effective."
497 :group
'org-export-translation
500 (defgroup org-export-tables nil
501 "Options for exporting tables in Org-mode."
502 :tag
"Org Export Tables"
505 (defcustom org-export-with-tables t
506 "If non-nil, lines starting with \"|\" define a table.
509 | Name | Address | Birthday |
510 |-------------+----------+-----------|
511 | Arthur Dent | England | 29.2.2100 |
513 Not all export backends support this.
515 This option can also be set with the +OPTIONS line, e.g. \"|:nil\"."
516 :group
'org-export-tables
519 (defcustom org-export-highlight-first-table-line t
520 "Non-nil means, highlight the first table line.
521 In HTML export, this means use <th> instead of <td>.
522 In tables created with table.el, this applies to the first table line.
523 In Org-mode tables, all lines before the first horizontal separator
524 line will be formatted with <th> tags."
525 :group
'org-export-tables
528 (defcustom org-export-table-remove-special-lines t
529 "Remove special lines and marking characters in calculating tables.
530 This removes the special marking character column from tables that are set
531 up for spreadsheet calculations. It also removes the entire lines
532 marked with `!', `_', or `^'. The lines with `$' are kept, because
533 the values of constants may be useful to have."
534 :group
'org-export-tables
537 (defcustom org-export-prefer-native-exporter-for-tables nil
538 "Non-nil means, always export tables created with table.el natively.
539 Natively means, use the HTML code generator in table.el.
540 When nil, Org-mode's own HTML generator is used when possible (i.e. if
541 the table does not use row- or column-spanning). This has the
542 advantage, that the automatic HTML conversions for math symbols and
543 sub/superscripts can be applied. Org-mode's HTML generator is also
545 :group
'org-export-tables
549 (defgroup org-export-xml nil
550 "Options specific for XML export of Org-mode files."
551 :tag
"Org Export XML"
556 ;;; Variables, constants, and parameter plists
558 (defconst org-level-max
20)
560 (defvar org-current-export-file nil
) ; dynamically scoped parameter
561 (defvar org-current-export-dir nil
) ; dynamically scoped parameter
562 (defvar org-export-opt-plist nil
563 "Contains the current option plist.")
564 (defvar org-last-level nil
) ; dynamically scoped variable
565 (defvar org-min-level nil
) ; dynamically scoped variable
566 (defvar org-levels-open nil
) ; dynamically scoped parameter
568 (defconst org-export-plist-vars
569 '((:link-up nil org-export-html-link-up
)
570 (:link-home nil org-export-html-link-home
)
571 (:language nil org-export-default-language
)
572 (:keywords nil org-export-page-keywords
)
573 (:description nil org-export-page-description
)
574 (:customtime nil org-display-custom-times
)
575 (:headline-levels
"H" org-export-headline-levels
)
576 (:section-numbers
"num" org-export-with-section-numbers
)
577 (:section-number-format nil org-export-section-number-format
)
578 (:table-of-contents
"toc" org-export-with-toc
)
579 (:preserve-breaks
"\\n" org-export-preserve-breaks
)
580 (:archived-trees nil org-export-with-archived-trees
)
581 (:emphasize
"*" org-export-with-emphasize
)
582 (:sub-superscript
"^" org-export-with-sub-superscripts
)
583 (:special-strings
"-" org-export-with-special-strings
)
584 (:footnotes
"f" org-export-with-footnotes
)
585 (:drawers
"d" org-export-with-drawers
)
586 (:tags
"tags" org-export-with-tags
)
587 (:todo-keywords
"todo" org-export-with-todo-keywords
)
588 (:priority
"pri" org-export-with-priority
)
589 (:TeX-macros
"TeX" org-export-with-TeX-macros
)
590 (:LaTeX-fragments
"LaTeX" org-export-with-LaTeX-fragments
)
591 (:latex-listings nil org-export-latex-listings
)
592 (:skip-before-1st-heading
"skip" org-export-skip-text-before-1st-heading
)
593 (:fixed-width
":" org-export-with-fixed-width
)
594 (:timestamps
"<" org-export-with-timestamps
)
595 (:author-info
"author" org-export-author-info
)
596 (:creator-info
"creator" org-export-creator-info
)
597 (:time-stamp-file
"timestamp" org-export-time-stamp-file
)
598 (:tables
"|" org-export-with-tables
)
599 (:table-auto-headline nil org-export-highlight-first-table-line
)
600 (:style-include-default nil org-export-html-style-include-default
)
601 (:style-include-scripts nil org-export-html-style-include-scripts
)
602 (:style nil org-export-html-style
)
603 (:style-extra nil org-export-html-style-extra
)
604 (:agenda-style nil org-agenda-export-html-style
)
605 (:convert-org-links nil org-export-html-link-org-files-as-html
)
606 (:inline-images nil org-export-html-inline-images
)
607 (:html-extension nil org-export-html-extension
)
608 (:xml-declaration nil org-export-html-xml-declaration
)
609 (:html-table-tag nil org-export-html-table-tag
)
610 (:expand-quoted-html
"@" org-export-html-expand
)
611 (:timestamp nil org-export-html-with-timestamp
)
612 (:publishing-directory nil org-export-publishing-directory
)
613 (:preamble nil org-export-html-preamble
)
614 (:postamble nil org-export-html-postamble
)
615 (:auto-preamble nil org-export-html-auto-preamble
)
616 (:auto-postamble nil org-export-html-auto-postamble
)
617 (:author nil user-full-name
)
618 (:email nil user-mail-address
)
619 (:select-tags nil org-export-select-tags
)
620 (:exclude-tags nil org-export-exclude-tags
)
622 (:latex-image-options nil org-export-latex-image-default-option
))
623 "List of properties that represent export/publishing variables.
624 Each element is a list of 3 items:
625 1. The property that is used internally, and also for org-publish-project-alist
626 2. The string that can be used in the OPTION lines to set this option,
627 or nil if this option cannot be changed in this way
628 3. The customization variable that sets the default for this option."
631 (defun org-default-export-plist ()
632 "Return the property list with default settings for the export variables."
633 (let* ((infile (org-infile-export-plist))
634 (letbind (plist-get infile
:let-bind
))
635 (l org-export-plist-vars
) rtn e s v
)
636 (while (setq e
(pop l
))
639 ((assq s letbind
) (nth 1 (assq s letbind
)))
640 ((boundp s
) (symbol-value s
))
642 rtn
(cons (car e
) (cons v rtn
))))
645 (defvar org-export-inbuffer-options-extra nil
646 "List of additional in-buffer options that should be detected.
647 Just before export, the buffer is scanned for options like #+TITLE, #+EMAIL,
648 etc. Extensions can add to this list to get their options detected, and they
649 can then add a function to `org-export-options-filters' to process these
651 Each element in this list must be a list, with the in-buffer keyword as car,
652 and a property (a symbol) as the next element. All occurrences of the
653 keyword will be found, the values concatenated with a space character
654 in between, and the result stored in the export options property list.")
656 (defvar org-export-options-filters nil
657 "Functions to be called to finalize the export/publishing options.
658 All these options are stored in a property list, and each of the functions
659 in this hook gets a chance to modify this property list. Each function
660 must accept the property list as an argument, and must return the (possibly
663 ;; FIXME: should we fold case here?
664 (defun org-infile-export-plist ()
665 "Return the property list with file-local settings for export."
669 (goto-char (point-min))
670 (let ((re (org-make-options-regexp
672 '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
673 "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE"
674 "LATEX_HEADER" "LATEX_CLASS"
675 "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS"
676 "KEYWORDS" "DESCRIPTION" "MACRO" "BIND")
677 (mapcar 'car org-export-inbuffer-options-extra
))))
678 p key val text options a pr style
679 latex-header latex-class macros letbind
680 ext-setup-or-nil setup-contents
(start 0))
681 (while (or (and ext-setup-or-nil
682 (string-match re ext-setup-or-nil start
)
683 (setq start
(match-end 0)))
684 (and (setq ext-setup-or-nil nil start
0)
685 (re-search-forward re nil t
)))
686 (setq key
(upcase (org-match-string-no-properties 1 ext-setup-or-nil
))
687 val
(org-match-string-no-properties 2 ext-setup-or-nil
))
689 ((setq a
(assoc key org-export-inbuffer-options-extra
))
691 (setq p
(plist-put p pr
(concat (plist-get p pr
) " " val
))))
692 ((string-equal key
"TITLE") (setq p
(plist-put p
:title val
)))
693 ((string-equal key
"AUTHOR")(setq p
(plist-put p
:author val
)))
694 ((string-equal key
"EMAIL") (setq p
(plist-put p
:email val
)))
695 ((string-equal key
"DATE") (setq p
(plist-put p
:date val
)))
696 ((string-equal key
"KEYWORDS") (setq p
(plist-put p
:keywords val
)))
697 ((string-equal key
"DESCRIPTION")
698 (setq p
(plist-put p
:description val
)))
699 ((string-equal key
"LANGUAGE") (setq p
(plist-put p
:language val
)))
700 ((string-equal key
"STYLE")
701 (setq style
(concat style
"\n" val
)))
702 ((string-equal key
"LATEX_HEADER")
703 (setq latex-header
(concat latex-header
"\n" val
)))
704 ((string-equal key
"LATEX_CLASS")
705 (setq latex-class val
))
706 ((string-equal key
"TEXT")
707 (setq text
(if text
(concat text
"\n" val
) val
)))
708 ((string-equal key
"OPTIONS")
709 (setq options
(concat val
" " options
)))
710 ((string-equal key
"BIND")
711 (push (read (concat "(" val
")")) letbind
))
712 ((string-equal key
"LINK_UP")
713 (setq p
(plist-put p
:link-up val
)))
714 ((string-equal key
"LINK_HOME")
715 (setq p
(plist-put p
:link-home val
)))
716 ((string-equal key
"EXPORT_SELECT_TAGS")
717 (setq p
(plist-put p
:select-tags
(org-split-string val
))))
718 ((string-equal key
"EXPORT_EXCLUDE_TAGS")
719 (setq p
(plist-put p
:exclude-tags
(org-split-string val
))))
720 ((string-equal key
"MACRO")
722 ((equal key
"SETUPFILE")
723 (setq setup-contents
(org-file-contents
725 (org-remove-double-quotes
728 (if (not ext-setup-or-nil
)
729 (setq ext-setup-or-nil setup-contents start
0)
730 (setq ext-setup-or-nil
731 (concat (substring ext-setup-or-nil
0 start
)
732 "\n" setup-contents
"\n"
733 (substring ext-setup-or-nil start
)))))))
734 (setq p
(plist-put p
:text text
))
735 (when (and letbind
(org-export-confirm-letbind))
736 (setq p
(plist-put p
:let-bind letbind
)))
737 (when style
(setq p
(plist-put p
:style-extra style
)))
739 (setq p
(plist-put p
:latex-header-extra
(substring latex-header
1))))
741 (setq p
(plist-put p
:latex-class latex-class
)))
743 (setq p
(org-export-add-options-to-plist p options
)))
744 ;; Add macro definitions
745 (setq p
(plist-put p
:macro-date
"(eval (format-time-string \"$1\"))"))
746 (setq p
(plist-put p
:macro-time
"(eval (format-time-string \"$1\"))"))
748 p
:macro-modification-time
749 (and (buffer-file-name)
750 (file-exists-p (buffer-file-name))
752 "(eval (format-time-string \"$1\" '"
753 (prin1-to-string (nth 5 (file-attributes
754 (buffer-file-name))))
756 (setq p
(plist-put p
:macro-input-file
(and (buffer-file-name)
757 (file-name-nondirectory
758 (buffer-file-name)))))
759 (while (setq val
(pop macros
))
760 (when (string-match "^\\([-a-zA-Z0-9_]+\\)[ \t]+\\(.*?[ \t]*$\\)" val
)
763 (concat ":macro-" (downcase (match-string 1 val
))))
764 (org-export-interpolate-newlines (match-string 2 val
))))))
767 (defun org-export-interpolate-newlines (s)
768 (while (string-match "\\\\n" s
)
769 (setq s
(replace-match "\n" t t s
)))
772 (defvar org-export-allow-BIND-local nil
)
773 (defun org-export-confirm-letbind ()
774 "Can we use #+BIND values during export?
775 By default this will ask fro confirmation by the user, to divert possible
778 ((not org-export-allow-BIND
) nil
)
779 ((eq org-export-allow-BIND t
) t
)
780 ((local-variable-p 'org-export-allow-BIND-local
(current-buffer))
781 org-export-allow-BIND-local
)
782 (t (org-set-local 'org-export-allow-BIND-local
783 (yes-or-no-p "Allow BIND values in this buffer? ")))))
785 (defun org-install-letbind ()
786 "Install the values from #+BIND lines as local variables."
787 (let ((letbind (plist-get org-export-opt-plist
:let-bind
))
789 (while (setq pair
(pop letbind
))
790 (org-set-local (car pair
) (nth 1 pair
)))))
792 (defun org-export-add-options-to-plist (p options
)
793 "Parse an OPTIONS line and set values in the property list P."
796 (let ((op org-export-plist-vars
))
797 (while (setq o
(pop op
))
799 (string-match (concat (regexp-quote (nth 1 o
))
800 ":\\([^ \t\n\r;,.]*\\)")
802 (setq p
(plist-put p
(car o
)
803 (car (read-from-string
804 (match-string 1 options
))))))))))
807 (defun org-export-add-subtree-options (p pos
)
808 "Add options in subtree at position POS to property list P."
811 (when (org-at-heading-p)
813 ;; This is actually read in `org-export-get-title-from-subtree'
814 ;; (when (setq a (org-entry-get pos "EXPORT_TITLE"))
815 ;; (setq p (plist-put p :title a)))
816 (when (setq a
(org-entry-get pos
"EXPORT_TEXT"))
817 (setq p
(plist-put p
:text a
)))
818 (when (setq a
(org-entry-get pos
"EXPORT_AUTHOR"))
819 (setq p
(plist-put p
:author a
)))
820 (when (setq a
(org-entry-get pos
"EXPORT_DATE"))
821 (setq p
(plist-put p
:date a
)))
822 (when (setq a
(org-entry-get pos
"EXPORT_OPTIONS"))
823 (setq p
(org-export-add-options-to-plist p a
)))))
826 (defun org-export-directory (type plist
)
827 (let* ((val (plist-get plist
:publishing-directory
))
829 (or (cdr (assoc type val
)) ".")
833 (defun org-export-process-option-filters (plist)
834 (let ((functions org-export-options-filters
) f
)
835 (while (setq f
(pop functions
))
836 (setq plist
(funcall f plist
))))
840 (defun org-export (&optional arg
)
841 "Export dispatcher for Org-mode.
842 When `org-export-run-in-background' is non-nil, try to run the command
843 in the background. This will be done only for commands that write
844 to a file. For details see the docstring of `org-export-run-in-background'.
846 The prefix argument ARG will be passed to the exporter. However, if
847 ARG is a double universal prefix `C-u C-u', that means to inverse the
848 value of `org-export-run-in-background'."
850 (let* ((bg (org-xor (equal arg
'(16)) org-export-run-in-background
))
852 (help "[t] insert the export option template
853 \[v] limit export to visible part of outline tree
854 \[1] only export the current subtree
856 \[a] export as ASCII [A] to temporary buffer
858 \[h] export as HTML [H] to temporary buffer [R] export region
859 \[b] export as HTML and open in browser
861 \[l] export as LaTeX [L] to temporary buffer
862 \[p] export as LaTeX and process to PDF
863 \[d] export as LaTeX, process to PDF, and open the resulting PDF document
865 \[D] export as DocBook
866 \[V] export as DocBook, process to PDF, and open the resulting PDF document
868 \[m] export as Freemind mind map
871 \[g] export using Wes Hardaker's generic exporter
873 \[i] export current file as iCalendar file
874 \[I] export all agenda files as iCalendar files
875 \[c] export agenda files into combined iCalendar file
877 \[F] publish current file [P] publish current project
878 \[X] publish a project... [E] publish every projects")
880 '((?t org-insert-export-options-template nil
)
881 (?v org-export-visible nil
)
882 (?a org-export-as-ascii t
)
883 (?A org-export-as-ascii-to-buffer t
)
884 (?h org-export-as-html t
)
885 (?b org-export-as-html-and-open t
)
886 (?H org-export-as-html-to-buffer nil
)
887 (?R org-export-region-as-html nil
)
888 (?x org-export-as-xoxo t
)
889 (?g org-export-generic t
)
890 (?D org-export-as-docbook t
)
891 (?V org-export-as-docbook-pdf-and-open t
)
892 (?m org-export-as-freemind t
)
893 (?l org-export-as-latex t
)
894 (?p org-export-as-pdf t
)
895 (?d org-export-as-pdf-and-open t
)
896 (?L org-export-as-latex-to-buffer nil
)
897 (?i org-export-icalendar-this-file t
)
898 (?I org-export-icalendar-all-agenda-files t
)
899 (?c org-export-icalendar-combine-agenda-files t
)
900 (?F org-publish-current-file t
)
901 (?P org-publish-current-project t
)
903 (?E org-publish-all t
)))
906 (save-window-excursion
907 (delete-other-windows)
908 (with-output-to-temp-buffer "*Org Export/Publishing Help*"
910 (org-fit-window-to-buffer (get-buffer-window
911 "*Org Export/Publishing Help*"))
912 (message "Select command: ")
913 (setq r1
(read-char-exclusive))
916 (message "Select command (for subtree): ")
917 (setq r1
(read-char-exclusive)))))
918 (setq r2
(if (< r1
27) (+ r1
96) r1
))
919 (unless (setq ass
(assq r2 cmds
))
920 (error "No command associated with key %c" r1
))
921 (if (and bg
(nth 2 ass
)
922 (not (buffer-base-buffer))
923 (not (org-region-active-p)))
924 ;; execute in background
925 (let ((p (start-process
926 (concat "Exporting " (file-name-nondirectory (buffer-file-name)))
928 (expand-file-name invocation-name invocation-directory
)
931 "--eval" "(require 'org-exp)"
932 "--eval" "(setq org-wait .2)"
934 "-f" (symbol-name (nth 1 ass
)))))
935 (set-process-sentinel p
'org-export-process-sentinel
)
936 (message "Background process \"%s\": started" p
))
937 ;; background processing not requested, or not possible
938 (if subtree-p
(progn (outline-mark-subtree) (activate-mark)))
939 (call-interactively (nth 1 ass
)))))
941 (defun org-export-process-sentinel (process status
)
942 (if (string-match "\n+\\'" status
)
943 (setq status
(substring status
0 -
1)))
944 (message "Background process \"%s\": %s" process status
))
946 (defconst org-html-entities
988 ("Aring") ("AA".
"Å")
1077 ("varepsilon".
"ε")
1090 ("sigmaf") ("varsigma".
"ς")
1098 ("thetasym") ("vartheta".
"ϑ")
1101 ("bull") ("bullet".
"•")
1102 ("hellip") ("dots".
"…")
1112 ("larr") ("leftarrow".
"←") ("gets".
"←")
1113 ("uarr") ("uparrow".
"↑")
1114 ("rarr") ("to".
"→") ("rightarrow".
"→")
1115 ("darr")("downarrow".
"↓")
1116 ("harr") ("leftrightarrow".
"↔")
1117 ("crarr") ("hookleftarrow".
"↵") ; has round hook, not quite CR
1118 ("lArr") ("Leftarrow".
"⇐")
1119 ("uArr") ("Uparrow".
"⇑")
1120 ("rArr") ("Rightarrow".
"⇒")
1121 ("dArr") ("Downarrow".
"⇓")
1122 ("hArr") ("Leftrightarrow".
"⇔")
1124 ("part") ("partial".
"∂")
1125 ("exist") ("exists".
"∃")
1126 ("empty") ("emptyset".
"∅")
1128 ("isin") ("in".
"∈")
1134 ("lowast") ("ast".
"∗")
1136 ("prop") ("proptp".
"∝")
1137 ("infin") ("infty".
"∞")
1138 ("ang") ("angle".
"∠")
1139 ("and") ("wedge".
"∧")
1140 ("or") ("vee".
"∨")
1146 ("cong") ("simeq".
"≅")
1147 ("asymp")("approx".
"≈")
1148 ("ne") ("neq".
"≠")
1152 ("sub") ("subset".
"⊂")
1153 ("sup") ("supset".
"⊃")
1160 ("sdot") ("cdot".
"⋅")
1167 ("loz") ("Diamond".
"◊")
1168 ("spades") ("spadesuit".
"♠")
1169 ("clubs") ("clubsuit".
"♣")
1170 ("hearts") ("diamondsuit".
"♥")
1171 ("diams") ("diamondsuit".
"♦")
1172 ("smile".
"☺") ("blacksmile".
"☻") ("sad".
"☹")
1243 "Entities for TeX->HTML translation.
1244 Entries can be like (\"ent\"), in which case \"\\ent\" will be translated to
1245 \"&ent;\". An entry can also be a dotted pair like (\"ent\".\"&other;\").
1246 In that case, \"\\ent\" will be translated to \"&other;\".
1247 The list contains HTML entities for Latin-1, Greek and other symbols.
1248 It is supplemented by a number of commonly used TeX macros with appropriate
1249 translations. There is currently no way for users to extend this.")
1251 ;;; General functions for all backends
1253 (defvar org-export-target-aliases nil
1254 "Alist of targets with invisible aliases.")
1255 (defvar org-export-preferred-target-alist nil
1256 "Alist of section id's with preferred aliases.")
1257 (defvar org-export-code-refs nil
1258 "Alist of code references and line numbers")
1260 (defun org-export-preprocess-string (string &rest parameters
)
1261 "Cleanup STRING so that that the true exported has a more consistent source.
1262 This function takes STRING, which should be a buffer-string of an org-file
1263 to export. It then creates a temporary buffer where it does its job.
1264 The result is then again returned as a string, and the exporter works
1265 on this string to produce the exported version."
1267 (let* ((htmlp (plist-get parameters
:for-html
))
1268 (asciip (plist-get parameters
:for-ascii
))
1269 (latexp (plist-get parameters
:for-LaTeX
))
1270 (docbookp (plist-get parameters
:for-docbook
))
1271 (backend (cond (htmlp 'html
)
1274 (docbookp 'docbook
)))
1275 (archived-trees (plist-get parameters
:archived-trees
))
1276 (inhibit-read-only t
)
1277 (drawers org-drawers
)
1278 (outline-regexp "\\*+ ")
1281 (setq org-export-target-aliases nil
)
1282 (setq org-export-preferred-target-alist nil
)
1283 (setq org-export-code-refs nil
)
1285 (with-current-buffer (get-buffer-create " org-mode-tmp")
1288 (setq case-fold-search t
)
1290 (let ((inhibit-read-only t
))
1291 (remove-text-properties (point-min) (point-max)
1294 ;; Remove license-to-kill stuff
1295 ;; The caller marks some stuff for killing, stuff that has been
1296 ;; used to create the page title, for example.
1297 (org-export-kill-licensed-text)
1299 (let ((org-inhibit-startup t
)) (org-mode))
1300 (setq case-fold-search t
)
1301 (org-install-letbind)
1304 (run-hooks 'org-export-preprocess-hook
)
1306 ;; Process the macros
1307 (org-export-preprocess-apply-macros)
1308 (run-hooks 'org-export-preprocess-after-macros-hook
)
1310 (untabify (point-min) (point-max))
1312 ;; Handle include files, and call a hook
1313 (org-export-handle-include-files)
1314 (run-hooks 'org-export-preprocess-after-include-files-hook
)
1316 ;; Get rid of archived trees
1317 (org-export-remove-archived-trees archived-trees
)
1319 ;; Remove comment environment and comment subtrees
1320 (org-export-remove-comment-blocks-and-subtrees)
1322 ;; Get rid of excluded trees, and call a hook
1323 (org-export-handle-export-tags (plist-get parameters
:select-tags
)
1324 (plist-get parameters
:exclude-tags
))
1325 (run-hooks 'org-export-preprocess-after-tree-selection-hook
)
1327 ;; Handle source code snippets
1328 (org-export-replace-src-segments-and-examples backend
)
1330 ;; Protect short examples marked by a leading colon
1331 (org-export-protect-colon-examples)
1333 ;; Normalize footnotes
1334 (when (plist-get parameters
:footnotes
)
1335 (org-footnote-normalize nil t
))
1337 ;; Find all headings and compute the targets for them
1338 (setq target-alist
(org-export-define-heading-targets target-alist
))
1340 ;; Get rid of drawers
1341 (org-export-remove-or-extract-drawers
1342 drawers
(plist-get parameters
:drawers
) backend
)
1344 ;; Get the correct stuff before the first headline
1345 (when (plist-get parameters
:skip-before-1st-heading
)
1346 (goto-char (point-min))
1347 (when (re-search-forward "^\\(#.*\n\\)?\\*+[ \t]" nil t
)
1348 (delete-region (point-min) (match-beginning 0))
1349 (goto-char (point-min))
1351 (when (plist-get parameters
:add-text
)
1352 (goto-char (point-min))
1353 (insert (plist-get parameters
:add-text
) "\n"))
1355 ;; Remove todo-keywords before exporting, if the user has requested so
1356 (org-export-remove-headline-metadata parameters
)
1358 ;; Find targets in comments and move them out of comments,
1359 ;; but mark them as targets that should be invisible
1360 (setq target-alist
(org-export-handle-invisible-targets target-alist
))
1362 ;; Select and protect backend specific stuff, throw away stuff
1363 ;; that is specific for other backends
1364 (run-hooks 'org-export-preprocess-before-selecting-backend-code-hook
)
1365 (org-export-select-backend-specific-text backend
)
1367 ;; Protect quoted subtrees
1368 (org-export-protect-quoted-subtrees)
1370 ;; Remove clock lines
1371 (org-export-remove-clock-lines)
1373 ;; Protect verbatim elements
1374 (org-export-protect-verbatim)
1376 ;; Blockquotes, verse, and center
1377 (org-export-mark-blockquote-verse-center)
1378 (run-hooks 'org-export-preprocess-after-blockquote-hook
)
1380 ;; Remove timestamps, if the user has requested so
1381 (unless (plist-get parameters
:timestamps
)
1382 (org-export-remove-timestamps))
1384 ;; Attach captions to the correct object
1385 (setq target-alist
(org-export-attach-captions-and-attributes
1386 backend target-alist
))
1388 ;; Find matches for radio targets and turn them into internal links
1389 (org-export-mark-radio-links)
1391 ;; Find all links that contain a newline and put them into a single line
1392 (org-export-concatenate-multiline-links)
1394 ;; Normalize links: Convert angle and plain links into bracket links
1395 ;; and expand link abbreviations
1396 (run-hooks 'org-export-preprocess-before-normalizing-links-hook
)
1397 (org-export-normalize-links)
1399 ;; Find all internal links. If they have a fuzzy match (i.e. not
1400 ;; a *dedicated* target match, let the link point to the
1401 ;; corresponding section.
1402 (org-export-target-internal-links target-alist
)
1404 ;; Find multiline emphasis and put them into single line
1405 (when (plist-get parameters
:emph-multiline
)
1406 (org-export-concatenate-multiline-emphasis))
1408 ;; Remove special table lines
1409 (when org-export-table-remove-special-lines
1410 (org-export-remove-special-table-lines))
1413 (run-hooks 'org-export-preprocess-before-backend-specifics-hook
)
1415 ;; LaTeX-specific preprocessing
1417 (require 'org-latex nil
)
1418 (org-export-latex-preprocess parameters
))
1420 ;; ASCII-specific preprocessing
1422 (org-export-ascii-preprocess parameters
))
1424 ;; HTML-specific preprocessing
1426 (org-export-html-preprocess parameters
))
1428 ;; DocBook-specific preprocessing
1430 (require 'org-docbook nil
)
1431 (org-export-docbook-preprocess parameters
))
1433 ;; Remove or replace comments
1434 (org-export-handle-comments (plist-get parameters
:comments
))
1436 ;; Run the final hook
1437 (run-hooks 'org-export-preprocess-final-hook
)
1439 (setq rtn
(buffer-string)))
1440 (kill-buffer " org-mode-tmp")
1443 (defun org-export-kill-licensed-text ()
1444 "Remove all text that is marked with a :org-license-to-kill property."
1446 (while (setq p
(text-property-any (point-min) (point-max)
1447 :org-license-to-kill t
))
1449 p
(or (next-single-property-change p
:org-license-to-kill
)
1452 (defun org-export-define-heading-targets (target-alist)
1453 "Find all headings and define the targets for them.
1454 The new targets are added to TARGET-ALIST, which is also returned."
1455 (goto-char (point-min))
1456 (org-init-section-numbers)
1457 (let ((re (concat "^" org-outline-regexp
1458 "\\| [ \t]*:\\(ID\\|CUSTOM_ID\\):[ \t]*\\([^ \t\r\n]+\\)"))
1459 level target last-section-target a id
)
1460 (while (re-search-forward re nil t
)
1463 (setq id
(org-match-string-no-properties 2))
1464 (push (cons id target
) target-alist
)
1465 (setq a
(or (assoc last-section-target org-export-target-aliases
)
1467 (push (list last-section-target
)
1468 org-export-target-aliases
)
1469 (car org-export-target-aliases
))))
1470 (push (caar target-alist
) (cdr a
))
1471 (when (equal (match-string 1) "CUSTOM_ID")
1472 (if (not (assoc last-section-target
1473 org-export-preferred-target-alist
))
1474 (push (cons last-section-target id
)
1475 org-export-preferred-target-alist
))))
1476 (setq level
(org-reduced-level
1477 (save-excursion (goto-char (point-at-bol))
1478 (org-outline-level))))
1479 (setq target
(org-solidify-link-text
1480 (format "sec-%s" (org-section-number level
))))
1481 (setq last-section-target target
)
1482 (push (cons target target
) target-alist
)
1483 (add-text-properties
1484 (point-at-bol) (point-at-eol)
1485 (list 'target target
)))))
1488 (defun org-export-handle-invisible-targets (target-alist)
1489 "Find targets in comments and move them out of comments.
1490 Mark them as invisible targets."
1492 (goto-char (point-min))
1493 (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t
)
1494 ;; Check if the line before or after is a headline with a target
1495 (if (setq target
(or (get-text-property (point-at-bol 0) 'target
)
1496 (get-text-property (point-at-bol 2) 'target
)))
1498 ;; use the existing target in a neighboring line
1499 (setq tmp
(match-string 2))
1501 (and (looking-at "\n") (delete-char 1))
1502 (push (cons (setq tmp
(org-solidify-link-text tmp
)) target
)
1504 (setq a
(or (assoc target org-export-target-aliases
)
1506 (push (list target
) org-export-target-aliases
)
1507 (car org-export-target-aliases
))))
1509 ;; Make an invisible target
1510 (replace-match "\\1(INVISIBLE)"))))
1513 (defun org-export-target-internal-links (target-alist)
1514 "Find all internal links and assign targets to them.
1515 If a link has a fuzzy match (i.e. not a *dedicated* target match),
1516 let the link point to the corresponding section.
1517 This function also handles the id links, if they have a match in
1519 (goto-char (point-min))
1520 (while (re-search-forward org-bracket-link-regexp nil t
)
1521 (org-if-unprotected-at (match-beginning 1)
1522 (let* ((md (match-data))
1523 (desc (match-end 2))
1524 (link (org-link-unescape (match-string 1)))
1525 (slink (org-solidify-link-text link
))
1526 found props pos cref
1529 ((= (string-to-char link
) ?
#)
1530 ;; user wants exactly this link
1532 ((cdr (assoc slink target-alist
))
1533 (or (cdr (assoc (assoc slink target-alist
)
1534 org-export-preferred-target-alist
))
1535 (cdr (assoc slink target-alist
))))
1536 ((and (string-match "^id:" link
)
1537 (cdr (assoc (substring link
3) target-alist
))))
1538 ((string-match "^(\\(.*\\))$" link
)
1539 (setq cref
(match-string 1 link
))
1540 (concat "coderef:" cref
))
1541 ((string-match org-link-types-re link
) nil
)
1542 ((or (file-name-absolute-p link
)
1543 (string-match "^\\." link
))
1547 (setq found
(condition-case nil
(org-link-search link
)
1550 (or (org-on-heading-p)
1551 (not (eq found
'dedicated
))))
1552 (or (get-text-property (point) 'target
)
1555 (1- (or (previous-single-property-change
1556 (point) 'target
) 0)))
1560 (goto-char (match-beginning 1))
1561 (setq props
(text-properties-at (point)))
1562 (delete-region (match-beginning 1) (match-end 1))
1565 (unless desc
(insert "][" link
))
1566 (add-text-properties pos
(point) props
))))))
1568 (defvar org-export-format-drawer-function nil
1569 "Function to be called to format the contents of a drawer.
1570 The function must accept three parameters:
1571 BACKEND one of the symbols html, docbook, latex, ascii, xoxo
1572 NAME the drawer name, like \"PROPERTIES\"
1573 CONTENT the content of the drawer.
1574 The function should return the text to be inserted into the buffer.
1575 If this is nil, `org-export-format-drawer' is used as a default.")
1577 (defun org-export-remove-or-extract-drawers (all-drawers exp-drawers backend
)
1578 "Remove drawers, or extract and format the content.
1579 ALL-DRAWERS is a list of all drawer names valid in the current buffer.
1580 EXP-DRAWERS can be t to keep all drawer contents, or a list of drawers
1581 whose content to keep. Any drawers that are in ALL-DRAWERS but not in
1582 EXP-DRAWERS will be removed.
1583 BACKEND is the current export backend."
1584 (goto-char (point-min))
1585 (let ((re (concat "^[ \t]*:\\("
1586 (mapconcat 'identity all-drawers
"\\|")
1588 name beg beg-content eol content
)
1589 (while (re-search-forward re nil t
)
1591 (setq name
(match-string 1))
1592 (setq beg
(match-beginning 0)
1593 beg-content
(1+ (point-at-eol))
1595 (if (not (and (re-search-forward
1596 "^\\([ \t]*:END:[ \t]*\n?\\)\\|^\\*+[ \t]" nil t
)
1599 (goto-char (match-beginning 0))
1600 (and (looking-at ".*\n?") (replace-match ""))
1601 (setq content
(buffer-substring beg-content
(point)))
1602 (delete-region beg
(point))
1603 (when (or (eq exp-drawers t
)
1604 (member name exp-drawers
))
1605 (setq content
(funcall (or org-export-format-drawer-function
1606 'org-export-format-drawer
)
1607 name content backend
))
1608 (insert content
)))))))
1610 (defun org-export-format-drawer (name content backend
)
1611 "Format the content of a drawer as a colon example."
1612 (if (string-match "[ \t]+\\'" content
)
1613 (setq content
(substring content
(match-beginning 0))))
1614 (while (string-match "\\`[ \t]*\n" content
)
1615 (setq content
(substring content
(match-end 0))))
1616 (setq content
(org-remove-indentation content
))
1617 (setq content
(concat ": " (mapconcat 'identity
1618 (org-split-string content
"\n")
1621 (setq content
(concat " : " (upcase name
) "\n" content
))
1622 (org-add-props content nil
'org-protected t
))
1624 (defun org-export-handle-export-tags (select-tags exclude-tags
)
1625 "Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS.
1626 Both arguments are lists of tags.
1627 If any of SELECT-TAGS is found, all trees not marked by a SELECT-TAG
1629 After that, all subtrees that are marked by EXCLUDE-TAGS will be
1631 (remove-text-properties (point-min) (point-max) '(:org-delete t
))
1632 (let* ((re-sel (concat ":\\(" (mapconcat 'regexp-quote
1635 (re-excl (concat ":\\(" (mapconcat 'regexp-quote
1639 (goto-char (point-min))
1640 (when (and select-tags
1642 (concat "^\\*+[ \t].*" re-sel
"[^ \t\n]*[ \t]*$") nil t
))
1643 ;; At least one tree is marked for export, this means
1644 ;; all the unmarked stuff needs to go.
1645 ;; Dig out the trees that should be exported
1646 (goto-char (point-min))
1647 (outline-next-heading)
1649 (put-text-property beg
(point-max) :org-delete t
)
1650 (while (re-search-forward re-sel nil t
)
1651 (when (org-on-heading-p)
1652 (org-back-to-heading)
1653 (remove-text-properties
1654 (max (1- (point)) (point-min))
1655 (setq cont
(save-excursion (org-end-of-subtree t t
)))
1657 (while (and (org-up-heading-safe)
1658 (get-text-property (point) :org-delete
))
1659 (remove-text-properties (max (1- (point)) (point-min))
1660 (point-at-eol) '(:org-delete t
)))
1662 ;; Remove the trees explicitly marked for noexport
1664 (goto-char (point-min))
1665 (while (re-search-forward re-excl nil t
)
1666 (when (org-at-heading-p)
1667 (org-back-to-heading t
)
1669 (org-end-of-subtree t t
)
1670 (delete-region beg
(point))
1671 (when (featurep 'org-inlinetask
)
1672 (org-inlinetask-remove-END-maybe)))))
1673 ;; Remove everything that is now still marked for deletion
1674 (goto-char (point-min))
1675 (while (setq beg
(text-property-any (point-min) (point-max) :org-delete t
))
1676 (setq end
(or (next-single-property-change beg
:org-delete
)
1678 (delete-region beg end
))))
1680 (defun org-export-remove-archived-trees (export-archived-trees)
1681 "Remove archived trees.
1682 When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported.
1683 When it is t, the entire archived tree will be exported.
1684 When it is nil the entire tree including the headline will be removed
1686 (let ((re-archive (concat ":" org-archive-tag
":"))
1688 (when (not (eq export-archived-trees t
))
1689 (goto-char (point-min))
1690 (while (re-search-forward re-archive nil t
)
1691 (if (not (org-on-heading-p t
))
1692 (org-end-of-subtree t
)
1693 (beginning-of-line 1)
1694 (setq a
(if export-archived-trees
1695 (1+ (point-at-eol)) (point))
1696 b
(org-end-of-subtree t
))
1697 (if (> b a
) (delete-region a b
)))))))
1699 (defun org-export-remove-headline-metadata (opts)
1700 "Remove meta data from the headline, according to user options."
1701 (let ((re org-complex-heading-regexp
)
1702 (todo (plist-get opts
:todo-keywords
))
1703 (tags (plist-get opts
:tags
))
1704 (pri (plist-get opts
:priority
))
1707 (setq elts
(delq nil
(list 1 (if todo
2) (if pri
3) 4 (if tags
5))))
1708 (when (or (not todo
) (not tags
) (not pri
))
1709 (goto-char (point-min))
1710 (while (re-search-forward re nil t
)
1712 (setq rpl
(mapconcat (lambda (i) (if (match-end i
) (match-string i
) ""))
1714 (replace-match rpl t t
))))))
1716 (defun org-export-remove-timestamps ()
1717 "Remove timestamps and keywords for export."
1718 (goto-char (point-min))
1719 (while (re-search-forward org-maybe-keyword-time-regexp nil t
)
1722 (unless (save-match-data (org-at-table-p))
1724 (beginning-of-line 1)
1725 (if (looking-at "[- \t]*\\(=>[- \t0-9:]*\\)?[ \t]*\n")
1726 (replace-match ""))))))
1728 (defun org-export-remove-clock-lines ()
1729 "Remove clock lines for export."
1730 (goto-char (point-min))
1731 (let ((re (concat "^[ \t]*" org-clock-string
".*\n?")))
1732 (while (re-search-forward re nil t
)
1734 (replace-match "")))))
1736 (defun org-export-protect-quoted-subtrees ()
1737 "Mark quoted subtrees with the protection property."
1738 (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string
"\\>")))
1739 (goto-char (point-min))
1740 (while (re-search-forward re-quote nil t
)
1741 (goto-char (match-beginning 0))
1743 (add-text-properties (point) (org-end-of-subtree t
)
1744 '(org-protected t
)))))
1746 (defun org-export-protect-verbatim ()
1747 "Mark verbatim snippets with the protection property."
1748 (goto-char (point-min))
1749 (while (re-search-forward org-verbatim-re nil t
)
1751 (add-text-properties (match-beginning 4) (match-end 4)
1752 '(org-protected t org-verbatim-emph t
))
1753 (goto-char (1+ (match-end 4))))))
1755 (defun org-export-protect-colon-examples ()
1756 "Protect lines starting with a colon."
1757 (goto-char (point-min))
1758 (let ((re "^[ \t]*:\\([ \t]\\|$\\)") beg
)
1759 (while (re-search-forward re nil t
)
1760 (beginning-of-line 1)
1762 (while (looking-at re
)
1764 (or (eobp) (forward-char 1)))
1765 (add-text-properties beg
(if (bolp) (1- (point)) (point))
1766 '(org-protected t
)))))
1768 (defun org-export-select-backend-specific-text (backend)
1770 '((docbook "DOCBOOK" "BEGIN_DOCBOOK" "END_DOCBOOK")
1771 (html "HTML" "BEGIN_HTML" "END_HTML")
1772 (beamer "BEAMER" "BEGIN_BEAMER" "END_BEAMER")
1773 (ascii "ASCII" "BEGIN_ASCII" "END_ASCII")
1774 (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
1775 (case-fold-search t
)
1776 fmt beg beg-content end end-content
)
1779 (setq fmt
(pop formatters
))
1780 (when (eq (car fmt
) backend
)
1781 ;; This is selected code, put it into the file for real
1782 (goto-char (point-min))
1783 (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" (cadr fmt
)
1784 ":[ \t]*\\(.*\\)") nil t
)
1785 (replace-match "\\1\\2" t
)
1786 (add-text-properties
1787 (point-at-bol) (min (1+ (point-at-eol)) (point-max))
1788 '(org-protected t
))))
1789 (goto-char (point-min))
1790 (while (re-search-forward (concat "^[ \t]*#\\+" (caddr fmt
) "\\>.*\n?")
1792 (setq beg
(match-beginning 0) beg-content
(match-end 0))
1793 (when (re-search-forward (concat "^[ \t]*#\\+" (cadddr fmt
) "\\>.*\n?")
1795 (setq end
(match-end 0) end-content
(match-beginning 0))
1796 (if (eq (car fmt
) backend
)
1799 (add-text-properties beg-content end-content
'(org-protected t
))
1800 (delete-region (match-beginning 0) (match-end 0))
1803 (delete-region (point) (1+ (point-at-eol)))))
1804 ;; No, this is for a different backend, kill it
1805 (delete-region beg end
)))))))
1807 (defun org-export-mark-blockquote-verse-center ()
1808 "Mark block quote and verse environments with special cookies.
1809 These special cookies will later be interpreted by the backend."
1811 (let (type t1 ind beg end beg1 end1 content
)
1812 (goto-char (point-min))
1813 (while (re-search-forward
1814 "^\\([ \t]*\\)#\\+\\(begin_\\(\\(block\\)?quote\\|verse\\|center\\)\\>.*\\)"
1816 (setq ind
(length (match-string 1))
1817 type
(downcase (match-string 3))
1818 t1
(if (equal type
"quote") "blockquote" type
))
1819 (setq beg
(match-beginning 0)
1820 beg1
(1+ (match-end 0)))
1821 (when (re-search-forward (concat "^[ \t]*#\\+end_" type
"\\>.*") nil t
)
1822 (setq end
(1+ (point-at-eol))
1823 end1
(1- (match-beginning 0)))
1824 (setq content
(org-remove-indentation (buffer-substring beg1 end1
)))
1825 (setq content
(concat "ORG-" (upcase t1
) "-START\n"
1827 "ORG-" (upcase t1
) "-END\n"))
1828 (delete-region beg end
)
1829 (insert (org-add-props content nil
'original-indentation ind
))))))
1831 (defun org-export-attach-captions-and-attributes (backend target-alist
)
1832 "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties.
1833 If the next thing following is a table, add the text properties to the first
1834 table line. If it is a link, add it to the line containing the link."
1835 (goto-char (point-min))
1836 (remove-text-properties (point-min) (point-max)
1837 '(org-caption nil org-attributes nil
))
1838 (let ((case-fold-search t
)
1839 (re (concat "^[ \t]*#\\+caption:[ \t]+\\(.*\\)"
1841 "^[ \t]*#\\+attr_" (symbol-name backend
) ":[ \t]+\\(.*\\)"
1843 "^[ \t]*#\\+label:[ \t]+\\(.*\\)"
1847 "^[ \t]*\\[\\[.*\\]\\][ \t]*$"))
1849 (while (re-search-forward re nil t
)
1852 (setq cap
(concat cap
(if cap
" " "") (org-trim (match-string 1)))))
1854 (setq attr
(concat attr
(if attr
" " "") (org-trim (match-string 2)))))
1856 (setq label
(org-trim (match-string 3))))
1858 (add-text-properties (point-at-bol) (point-at-eol)
1859 (list 'org-caption cap
1860 'org-attributes attr
1862 (if label
(push (cons label label
) target-alist
))
1863 (setq cap nil attr nil label nil
)))))
1866 (defun org-export-remove-comment-blocks-and-subtrees ()
1867 "Remove the comment environment, and also commented subtrees."
1868 (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string
"\\>"))
1870 ;; Remove comment environment
1871 (goto-char (point-min))
1872 (setq case-fold-search t
)
1873 (while (re-search-forward
1874 "^#\\+begin_comment[ \t]*\n[^\000]*?^#\\+end_comment\\>.*" nil t
)
1875 (replace-match "" t t
))
1876 ;; Remove subtrees that are commented
1877 (goto-char (point-min))
1878 (setq case-fold-search nil
)
1879 (while (re-search-forward re-commented nil t
)
1880 (goto-char (match-beginning 0))
1881 (delete-region (point) (org-end-of-subtree t
)))))
1883 (defun org-export-handle-comments (commentsp)
1884 "Remove comments, or convert to backend-specific format.
1885 COMMENTSP can be a format string for publishing comments.
1886 When it is nil, all comments will be removed."
1887 (let ((re "^\\(#\\|[ \t]*#\\+\\)\\(.*\n?\\)")
1889 (goto-char (point-min))
1890 (while (or (looking-at re
)
1891 (re-search-forward re nil t
))
1892 (setq pos
(match-beginning 0))
1894 (not (equal (char-before (match-end 1)) ?
+)))
1895 (progn (add-text-properties
1896 (match-beginning 0) (match-end 0) '(org-protected t
))
1897 (replace-match (format commentsp
(match-string 2)) t t
))
1898 (goto-char (1+ pos
))
1901 (goto-char (max (point-min) (1- pos
))))))))
1903 (defun org-export-mark-radio-links ()
1904 "Find all matches for radio targets and turn them into internal links."
1905 (let ((re-radio (and org-target-link-regexp
1906 (concat "\\([^<]\\)\\(" org-target-link-regexp
"\\)"))))
1907 (goto-char (point-min))
1909 (while (re-search-forward re-radio nil t
)
1912 (or (org-in-regexp org-bracket-link-regexp
)
1913 (org-in-regexp org-plain-link-re
)
1914 (org-in-regexp "<<[^<>]+>>")))
1916 (replace-match "\\1[[\\2]]")))))))
1918 (defun org-export-remove-special-table-lines ()
1919 "Remove tables lines that are used for internal purposes."
1920 (goto-char (point-min))
1921 (while (re-search-forward "^[ \t]*|" nil t
)
1922 (beginning-of-line 1)
1923 (if (or (looking-at "[ \t]*| *[!_^] *|")
1929 (or (= (length f
) 0)
1931 "\\`<\\([0-9]\\|[rl]\\|[rl][0-9]+\\)>\\'" f
)))
1932 (org-split-string ;; FIXME, can't we do this without splitting???
1933 (buffer-substring (point-at-bol) (point-at-eol))
1934 "[ \t]*|[ \t]*")))))
1935 (delete-region (max (point-min) (1- (point-at-bol)))
1939 (defun org-export-protect-sub-super (s)
1941 (while (string-match "\\([^\\\\]\\)\\([_^]\\)" s
)
1942 (setq s
(replace-match "\\1\\\\\\2" nil nil s
)))
1945 (defun org-export-normalize-links ()
1946 "Convert all links to bracket links, and expand link abbreviations."
1947 (let ((re-plain-link (concat "\\([^[<]\\)" org-plain-link-re
))
1948 (re-angle-link (concat "\\([^[]\\)" org-angle-link-re
))
1950 (goto-char (point-min))
1951 (while (re-search-forward re-plain-link nil t
)
1952 (goto-char (1- (match-end 0)))
1953 (org-if-unprotected-at (1+ (match-beginning 0))
1954 (let* ((s (concat (match-string 1)
1955 "[[" (match-string 2) ":" (match-string 3)
1956 "][" (match-string 2) ":" (org-export-protect-sub-super
1959 ;; added 'org-link face to links
1960 (put-text-property 0 (length s
) 'face
'org-link s
)
1961 (replace-match s t t
))))
1962 (goto-char (point-min))
1963 (while (re-search-forward re-angle-link nil t
)
1964 (goto-char (1- (match-end 0)))
1966 (let* ((s (concat (match-string 1)
1967 "[[" (match-string 2) ":" (match-string 3)
1968 "][" (match-string 2) ":" (org-export-protect-sub-super
1971 (put-text-property 0 (length s
) 'face
'org-link s
)
1972 (replace-match s t t
))))
1973 (goto-char (point-min))
1974 (while (re-search-forward org-bracket-link-regexp nil t
)
1975 (goto-char (1- (match-end 0)))
1976 (setq nodesc
(not (match-end 3)))
1978 (let* ((xx (save-match-data
1980 (org-link-expand-abbrev (match-string 1)))))
1982 "[[" (org-add-props (copy-sequence xx
)
1983 nil
'org-protected t
'org-no-description nodesc
)
1987 (concat "[" (copy-sequence xx
)
1990 (put-text-property 0 (length s
) 'face
'org-link s
)
1991 (replace-match s t t
))))))
1993 (defun org-export-concatenate-multiline-links ()
1994 "Find multi-line links and put it all into a single line.
1995 This is to make sure that the line-processing export backends
1996 can work correctly."
1997 (goto-char (point-min))
1998 (while (re-search-forward "\\(\\(\\[\\|\\]\\)\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\(\\[\\|\\]\\)\\)" nil t
)
2000 (replace-match "\\1 \\3")
2001 (goto-char (match-beginning 0)))))
2003 (defun org-export-concatenate-multiline-emphasis ()
2004 "Find multi-line emphasis and put it all into a single line.
2005 This is to make sure that the line-processing export backends
2006 can work correctly."
2007 (goto-char (point-min))
2008 (while (re-search-forward org-emph-re nil t
)
2009 (if (and (not (= (char-after (match-beginning 3))
2010 (char-after (match-beginning 4))))
2011 (save-excursion (goto-char (match-beginning 0))
2012 (save-match-data (not (org-at-table-p)))))
2014 (subst-char-in-region (match-beginning 0) (match-end 0)
2016 (goto-char (1- (match-end 0))))
2017 (goto-char (1+ (match-beginning 0))))))
2019 (defun org-export-grab-title-from-buffer ()
2020 "Get a title for the current document, from looking at the buffer."
2021 (let ((inhibit-read-only t
))
2023 (goto-char (point-min))
2024 (let ((end (if (looking-at org-outline-regexp
)
2026 (save-excursion (outline-next-heading) (point)))))
2027 (when (re-search-forward "^[ \t]*[^|# \t\r\n].*\n" end t
)
2028 ;; Mark the line so that it will not be exported as normal text.
2030 (add-text-properties (match-beginning 0) (match-end 0)
2031 (list :org-license-to-kill t
)))
2032 ;; Return the title string
2033 (org-trim (match-string 0)))))))
2035 (defun org-export-get-title-from-subtree ()
2036 "Return subtree title and exclude it from export."
2037 (let (title (rbeg (region-beginning)) (rend (region-end)))
2040 (when (and (org-at-heading-p)
2041 (>= (org-end-of-subtree t t
) rend
))
2042 ;; This is a subtree, we take the title from the first heading
2044 (looking-at org-todo-line-regexp
)
2045 (setq title
(match-string 3))
2047 (add-text-properties (point) (1+ (point-at-eol))
2048 (list :org-license-to-kill t
)))
2049 (setq title
(or (org-entry-get nil
"EXPORT_TITLE") title
))))
2052 (defun org-solidify-link-text (s &optional alist
)
2053 "Take link text and make a safe target out of it."
2058 (org-split-string s
"[ \t\r\n]+") "=="))
2059 (a (assoc rtn alist
)))
2062 (defun org-get-min-level (lines &optional offset
)
2063 "Get the minimum level in LINES."
2064 (let ((re "^\\(\\*+\\) ") l
)
2066 (while (setq l
(pop lines
))
2067 (if (string-match re l
)
2068 (throw 'exit
(org-tr-level (- (length (match-string 1 l
))
2072 ;; Variable holding the vector with section numbers
2073 (defvar org-section-numbers
(make-vector org-level-max
0))
2075 (defun org-init-section-numbers ()
2076 "Initialize the vector for the section numbers."
2078 (numbers (nreverse (org-split-string "" "\\.")))
2079 (depth (1- (length org-section-numbers
)))
2080 (i depth
) number-string
)
2083 (aset org-section-numbers i
0)
2084 (setq number-string
(or (car numbers
) "0"))
2085 (if (string-match "\\`[A-Z]\\'" number-string
)
2086 (aset org-section-numbers i
2087 (- (string-to-char number-string
) ?A -
1))
2088 (aset org-section-numbers i
(string-to-number number-string
)))
2092 (defun org-section-number (&optional level
)
2093 "Return a string with the current section number.
2094 When LEVEL is non-nil, increase section numbers on that level."
2095 (let* ((depth (1- (length org-section-numbers
)))
2097 (fmts (car org-export-section-number-format
))
2098 (term (cdr org-export-section-number-format
))
2103 (aset org-section-numbers
2104 level
(1+ (aref org-section-numbers level
))))
2105 (setq idx
(1+ level
))
2106 (while (<= idx depth
)
2108 (aset org-section-numbers idx
0))
2109 (setq idx
(1+ idx
))))
2111 (while (<= idx depth
)
2112 (when (> (aref org-section-numbers idx
) 0)
2113 (setq fmt
(or (pop fmts
) fmt
)
2115 n
(aref org-section-numbers idx
)
2117 (concat string sep
(org-number-to-counter n ctype
))
2118 (concat string
".0"))
2120 (setq idx
(1+ idx
)))
2122 (if (string-match "\\`\\([@0]\\.\\)+" string
)
2123 (setq string
(replace-match "" t nil string
)))
2124 (if (string-match "\\(\\.0\\)+\\'" string
)
2125 (setq string
(replace-match "" t nil string
))))
2126 (concat string term
)))
2128 (defun org-number-to-counter (n type
)
2129 "Concert number N to a string counter, according to TYPE.
2130 TYPE must be a string, any of:
2134 I upper case roman numeral
2135 i lower case roman numeral"
2137 ((equal type
"1") (number-to-string n
))
2138 ((equal type
"A") (char-to-string (+ ?A n -
1)))
2139 ((equal type
"a") (char-to-string (+ ?a n -
1)))
2140 ((equal type
"I") (org-number-to-roman n
))
2141 ((equal type
"i") (downcase (org-number-to-roman n
)))
2142 (t (error "Invalid counter type `%s'" type
))))
2144 (defun org-number-to-roman (n)
2145 "Convert integer N into a roman numeral."
2146 (let ((roman '((1000 .
"M") (900 .
"CM") (500 .
"D") (400 .
"CD")
2147 ( 100 .
"C") ( 90 .
"XC") ( 50 .
"L") ( 40 .
"XL")
2148 ( 10 .
"X") ( 9 .
"IX") ( 5 .
"V") ( 4 .
"IV")
2152 (number-to-string n
)
2154 (if (>= n
(caar roman
))
2155 (setq n
(- n
(caar roman
))
2156 res
(concat res
(cdar roman
)))
2162 (defun org-export-preprocess-apply-macros ()
2163 "Replace macro references."
2164 (goto-char (point-min))
2165 (let (sy val key args args2 s n
)
2166 (while (re-search-forward
2167 "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\(([ \t\n]*\\([^\000]*?\\))\\)?}}}"
2169 (unless (save-match-data
2171 (goto-char (point-at-bol))
2172 (looking-at "[ \t]*#\\+macro")))
2173 (setq key
(downcase (match-string 1))
2174 args
(match-string 3))
2175 (when (setq val
(or (plist-get org-export-opt-plist
2176 (intern (concat ":macro-" key
)))
2177 (plist-get org-export-opt-plist
2178 (intern (concat ":" key
)))))
2181 (setq args
(org-split-string args
",[ \t\n]*") args2 nil
)
2182 (setq args
(mapcar 'org-trim args
))
2184 (while (string-match "\\\\\\'" (car args
))
2185 ;; repair bad splits
2186 (setcar (cdr args
) (concat (substring (car args
) 0 -
1)
2189 (push (pop args
) args2
))
2190 (setq args
(nreverse args2
))
2192 (while (string-match "\\$\\([0-9]+\\)" val s
)
2193 (setq s
(1+ (match-beginning 0))
2194 n
(string-to-number (match-string 1 val
)))
2195 (and (>= (length args
) n
)
2196 (setq val
(replace-match (nth (1- n
) args
) t t val
)))))
2197 (when (string-match "\\`(eval\\>" val
)
2198 (setq val
(eval (read val
))))
2199 (if (and val
(not (stringp val
)))
2200 (setq val
(format "%s" val
))))
2202 (prog1 (replace-match val t t
)
2203 (goto-char (match-beginning 0)))))))))
2205 (defun org-export-apply-macros-in-string (s)
2206 "Apply the macros in string S."
2210 (org-export-preprocess-apply-macros)
2215 (defun org-export-handle-include-files ()
2216 "Include the contents of include files, with proper formatting."
2217 (let ((case-fold-search t
)
2218 params file markup lang start end prefix prefix1 switches
)
2219 (goto-char (point-min))
2220 (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t
)
2221 (setq params
(read (concat "(" (match-string 1) ")"))
2222 prefix
(org-get-and-remove-property 'params
:prefix
)
2223 prefix1
(org-get-and-remove-property 'params
:prefix1
)
2224 file
(org-symname-or-string (pop params
))
2225 markup
(org-symname-or-string (pop params
))
2226 lang
(and (member markup
'("src" "SRC"))
2227 (org-symname-or-string (pop params
)))
2228 switches
(mapconcat '(lambda (x) (format "%s" x
)) params
" ")
2230 (delete-region (match-beginning 0) (match-end 0))
2232 (not (file-exists-p file
))
2233 (not (file-readable-p file
)))
2234 (insert (format "CANNOT INCLUDE FILE %s" file
))
2236 (if (equal (downcase markup
) "src")
2237 (setq start
(format "#+begin_src %s %s\n"
2238 (or lang
"fundamental")
2241 (setq start
(format "#+begin_%s %s\n" markup switches
)
2242 end
(format "#+end_%s" markup
))))
2243 (insert (or start
""))
2244 (insert (org-get-file-contents (expand-file-name file
)
2245 prefix prefix1 markup
))
2246 (or (bolp) (newline))
2247 (insert (or end
""))))))
2249 (defun org-get-file-contents (file &optional prefix prefix1 markup
)
2250 "Get the contents of FILE and return them as a string.
2251 If PREFIX is a string, prepend it to each line. If PREFIX1
2252 is a string, prepend it to the first line instead of PREFIX.
2253 If MARKUP, don't protect org-like lines, the exporter will
2254 take care of the block they are in."
2255 (if (stringp markup
) (setq markup
(downcase markup
)))
2257 (insert-file-contents file
)
2258 (when (or prefix prefix1
)
2259 (goto-char (point-min))
2261 (insert (or prefix1 prefix
))
2263 (beginning-of-line 2)))
2265 (when (member markup
'("src" "example"))
2266 (goto-char (point-min))
2267 (while (re-search-forward "^\\([*#]\\|[ \t]*#\\+\\)" nil t
)
2268 (goto-char (match-beginning 0))
2273 (defun org-get-and-remove-property (listvar prop
)
2274 "Check if the value of LISTVAR contains PROP as a property.
2275 If yes, return the value of that property (i.e. the element following
2276 in the list) and remove property and value from the list in LISTVAR."
2277 (let ((list (symbol-value listvar
)) m v
)
2278 (when (setq m
(member prop list
))
2280 (if (equal (car list
) prop
)
2281 (set listvar
(cddr list
))
2282 (setcdr (nthcdr (- (length list
) (length m
) 1) list
)
2284 (set listvar list
)))
2287 (defun org-symname-or-string (s)
2289 (if s
(symbol-name s
) s
)
2292 ;;; Fontification and line numbers for code examples
2294 (defvar org-export-last-code-line-counter-value
0)
2296 (defun org-export-replace-src-segments-and-examples (backend)
2297 "Replace source code segments with special code for export."
2298 (setq org-export-last-code-line-counter-value
0)
2299 (let ((case-fold-search t
)
2300 lang code trans opts indent caption
)
2301 (goto-char (point-min))
2302 (while (re-search-forward
2303 "\\(^\\([ \t]*\\)#\\+BEGIN_SRC:?[ \t]+\\([^ \t\n]+\\)\\(.*\\)\n\\([^\000]+?\n\\)[ \t]*#\\+END_SRC.*\n?\\)\\|\\(^\\([ \t]*\\)#\\+BEGIN_EXAMPLE:?\\(?:[ \t]+\\(.*\\)\\)?\n\\([^\000]+?\n\\)[ \t]*#\\+END_EXAMPLE.*\n?\\)"
2307 (setq lang
(match-string 3)
2308 opts
(match-string 4)
2309 code
(match-string 5)
2310 indent
(length (match-string 2))
2311 caption
(get-text-property 0 'org-caption
(match-string 0)))
2313 opts
(match-string 8)
2314 code
(match-string 9)
2315 indent
(length (match-string 7))
2316 caption
(get-text-property 0 'org-caption
(match-string 0))))
2318 (setq trans
(org-export-format-source-code-or-example
2319 backend lang code opts indent caption
))
2320 (replace-match trans t t
))))
2322 (defvar htmlp
) ;; dynamically scoped
2323 (defvar latexp
) ;; dynamically scoped
2324 (defvar org-export-latex-verbatim-wrap
) ;; defined in org-latex.el
2325 (defvar org-export-latex-listings
) ;; defined in org-latex.el
2326 (defvar org-export-latex-listings-langs
) ;; defined in org-latex.el
2328 (defun org-export-format-source-code-or-example
2329 (backend lang code
&optional opts indent caption
)
2330 "Format CODE from language LANG and return it formatted for export.
2331 If LANG is nil, do not add any fontification.
2332 OPTS contains formatting options, like `-n' for triggering numbering lines,
2333 and `+n' for continuing previous numbering.
2334 Code formatting according to language currently only works for HTML.
2335 Numbering lines works for all three major backends (html, latex, and ascii).
2336 INDENT was the original indentation of the block."
2338 (let (num cont rtn rpllbl keepp textareap preserve-indentp cols rows fmt
)
2339 (setq opts
(or opts
"")
2340 num
(string-match "[-+]n\\>" opts
)
2341 cont
(string-match "\\+n\\>" opts
)
2342 rpllbl
(string-match "-r\\>" opts
)
2343 keepp
(string-match "-k\\>" opts
)
2344 textareap
(string-match "-t\\>" opts
)
2345 preserve-indentp
(or org-src-preserve-indentation
2346 (string-match "-i\\>" opts
))
2347 cols
(if (string-match "-w[ \t]+\\([0-9]+\\)" opts
)
2348 (string-to-number (match-string 1 opts
))
2350 rows
(if (string-match "-h[ \t]+\\([0-9]+\\)" opts
)
2351 (string-to-number (match-string 1 opts
))
2352 (org-count-lines code
))
2353 fmt
(if (string-match "-l[ \t]+\"\\([^\"\n]+\\)\"" opts
)
2354 (match-string 1 opts
)))
2355 (when (and textareap
(eq backend
'html
))
2356 ;; we cannot use numbering or highlighting.
2357 (setq num nil cont nil lang nil
))
2358 (if keepp
(setq rpllbl
'keep
))
2359 (setq rtn
(if preserve-indentp code
(org-remove-indentation code
)))
2360 (when (string-match "^," rtn
)
2361 (setq rtn
(with-temp-buffer
2363 ;; Free up the protected lines
2364 (goto-char (point-min))
2365 (while (re-search-forward "^," nil t
)
2366 (if (or (equal lang
"org")
2368 (looking-at "\\([*#]\\|[ \t]*#\\+\\)")))
2372 ;; Now backend-specific coding
2375 ((eq backend
'docbook
)
2376 (setq rtn
(org-export-number-lines rtn
'docbook
0 0 num cont rpllbl fmt
))
2377 (concat "\n#+BEGIN_DOCBOOK\n"
2378 (org-add-props (concat "<programlisting><![CDATA["
2380 "]]>\n</programlisting>\n")
2384 ;; We are exporting to HTML
2386 (require 'htmlize nil t
)
2387 (when (not (fboundp 'htmlize-region-for-paste
))
2388 ;; we do not have htmlize.el, or an old version of it
2391 "htmlize.el 1.34 or later is needed for source code formatting")))
2394 (let* ((lang-m (when lang
2395 (or (cdr (assoc lang org-src-lang-modes
))
2397 (mode (and lang-m
(intern
2399 (if (symbolp lang-m
)
2400 (symbol-name lang-m
)
2403 (org-inhibit-startup t
)
2404 (org-startup-folded nil
))
2408 (if (functionp mode
)
2411 (font-lock-fontify-buffer)
2413 (set-buffer-modified-p nil
)
2414 (org-export-htmlize-region-for-paste
2415 (point-min) (point-max))))
2416 (if (string-match "<pre\\([^>]*\\)>\n*" rtn
)
2420 (format "<label class=\"org-src-name\">%s</label>\n" caption
)
2423 (format "<pre class=\"src src-%s\">\n" lang
)
2427 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\" overflow-x:scroll >\n"
2429 rtn
"</textarea>\n</p>\n"))
2432 (goto-char (point-min))
2433 (while (re-search-forward "[<>&]" nil t
)
2434 (replace-match (cdr (assq (char-before)
2435 '((?
&.
"&")(?
<.
"<")(?
>.
">"))))
2437 (setq rtn
(buffer-string)))
2438 (setq rtn
(concat "<pre class=\"example\">\n" rtn
"</pre>\n"))))
2440 (setq rtn
(org-export-number-lines rtn
'html
1 1 num
2442 (if (string-match "\\(\\`<[^>]*>\\)\n" rtn
)
2443 (setq rtn
(replace-match "\\1" t nil rtn
)))
2444 (concat "\n#+BEGIN_HTML\n" (org-add-props rtn
'(org-protected t
)) "\n#+END_HTML\n\n"))
2445 ((eq backend
'latex
)
2446 (setq rtn
(org-export-number-lines rtn
'latex
0 0 num cont rpllbl fmt
))
2447 (concat "#+BEGIN_LaTeX\n"
2449 (if org-export-latex-listings
2453 ((lang-sym (intern lang
))
2458 org-export-latex-listings-langs
))
2460 (format "\\lstset{language=%s}" lstlang
))
2462 "\\begin{lstlisting}"
2463 (if caption
(format "[title={%s}]\n" caption
) "\n")
2464 rtn
"\\end{lstlisting}\n")
2465 (concat (car org-export-latex-verbatim-wrap
)
2466 rtn
(cdr org-export-latex-verbatim-wrap
)))
2469 ((eq backend
'ascii
)
2470 ;; This is not HTML or LaTeX, so just make it an example.
2471 (setq rtn
(org-export-number-lines rtn
'ascii
0 0 num cont rpllbl fmt
))
2472 (concat caption
"\n"
2477 (lambda (l) (concat " " l
))
2478 (org-split-string rtn
"\n")
2483 (org-add-props rtn nil
'original-indentation indent
))))
2485 (defun org-export-number-lines (text backend
2486 &optional skip1 skip2 number cont
2487 replace-labels label-format
)
2488 (setq skip1
(or skip1
0) skip2
(or skip2
0))
2489 (if (not cont
) (setq org-export-last-code-line-counter-value
0))
2492 (goto-char (point-max))
2493 (skip-chars-backward " \t\n\r")
2494 (delete-region (point) (point-max))
2495 (beginning-of-line (- 1 skip2
))
2496 (let* ((last (org-current-line))
2497 (n org-export-last-code-line-counter-value
)
2498 (nmax (+ n
(- last skip1
)))
2499 (fmt (format "%%%dd: " (length (number-to-string nmax
))))
2502 ((eq backend
'html
) (format "<span class=\"linenr\">%s</span>"
2504 ((eq backend
'ascii
) fmt
)
2505 ((eq backend
'latex
) fmt
)
2506 ((eq backend
'docbook
) fmt
)
2508 (label-format (or label-format org-coderef-label-format
))
2509 (label-pre (if (string-match "%s" label-format
)
2510 (substring label-format
0 (match-beginning 0))
2512 (label-post (if (string-match "%s" label-format
)
2513 (substring label-format
(match-end 0))
2517 ".*?\\S-.*?\\([ \t]*\\("
2518 (regexp-quote label-pre
)
2519 "\\([-a-zA-Z0-9_ ]+\\)"
2520 (regexp-quote label-post
)
2524 (org-goto-line (1+ skip1
))
2525 (while (and (re-search-forward "^" nil t
) (not (eobp)) (< n nmax
))
2527 (insert (format fm
(incf n
)))
2529 (when (looking-at lbl-re
)
2530 (setq ref
(match-string 3))
2531 (cond ((numberp replace-labels
)
2532 ;; remove labels; use numbers for references when lines
2533 ;; are numbered, use labels otherwise
2534 (delete-region (match-beginning 1) (match-end 1))
2535 (push (cons ref
(if (> n
0) n ref
)) org-export-code-refs
))
2536 ((eq replace-labels
'keep
)
2537 ;; don't remove labels; use numbers for references when
2538 ;; lines are numbered, use labels otherwise
2539 (goto-char (match-beginning 2))
2540 (delete-region (match-beginning 2) (match-end 2))
2541 (insert "(" ref
")")
2542 (push (cons ref
(if (> n
0) n
(concat "(" ref
")")))
2543 org-export-code-refs
))
2545 ;; don't remove labels and don't use numbers for
2547 (goto-char (match-beginning 2))
2548 (delete-region (match-beginning 2) (match-end 2))
2549 (insert "(" ref
")")
2550 (push (cons ref
(concat "(" ref
")")) org-export-code-refs
)))
2551 (when (eq backend
'html
)
2553 (beginning-of-line 1)
2554 (insert (format "<span id=\"coderef-%s\" class=\"coderef-off\">"
2557 (insert "</span>")))))
2558 (setq org-export-last-code-line-counter-value n
)
2559 (goto-char (point-max))
2563 (defun org-search-todo-below (line lines level
)
2564 "Search the subtree below LINE for any TODO entries."
2565 (let ((rest (cdr (memq line lines
)))
2566 (re org-todo-line-regexp
)
2569 (while (setq line
(pop rest
))
2570 (if (string-match re line
)
2572 (setq lv
(- (match-end 1) (match-beginning 1))
2573 todo
(and (match-beginning 2)
2574 (not (member (match-string 2 line
)
2575 org-done-keywords
))))
2577 (if (<= lv level
) (throw 'exit nil
))
2578 (if todo
(throw 'exit t
))))))))
2581 (defun org-export-visible (type arg
)
2582 "Create a copy of the visible part of the current buffer, and export it.
2583 The copy is created in a temporary buffer and removed after use.
2584 TYPE is the final key (as a string) that also select the export command in
2585 the `C-c C-e' export dispatcher.
2586 As a special case, if the you type SPC at the prompt, the temporary
2587 org-mode file will not be removed but presented to you so that you can
2588 continue to use it. The prefix arg ARG is passed through to the exporting
2592 (message "Export visible: [a]SCII [h]tml [b]rowse HTML [H/R]buffer with HTML [D]ocBook [l]atex [p]df [d]view pdf [L]atex buffer [x]OXO [ ]keep buffer")
2593 (read-char-exclusive))
2594 current-prefix-arg
))
2595 (if (not (member type
'(?a ?\C-a ?b ?\C-b ?h ?D ?x ?\ ?l ?p ?d ?L
)))
2596 (error "Invalid export key"))
2597 (let* ((binding (cdr (assoc type
2598 '((?a . org-export-as-ascii
)
2599 (?A . org-export-as-ascii-to-buffer
)
2600 (?\C-a . org-export-as-ascii
)
2601 (?b . org-export-as-html-and-open
)
2602 (?\C-b . org-export-as-html-and-open
)
2603 (?h . org-export-as-html
)
2604 (?H . org-export-as-html-to-buffer
)
2605 (?R . org-export-region-as-html
)
2606 (?D . org-export-as-docbook
)
2608 (?l . org-export-as-latex
)
2609 (?p . org-export-as-pdf
)
2610 (?d . org-export-as-pdf-and-open
)
2611 (?L . org-export-as-latex-to-buffer
)
2613 (?x . org-export-as-xoxo
)))))
2614 (keepp (equal type ?\
))
2615 (file buffer-file-name
)
2616 (buffer (get-buffer-create "*Org Export Visible*"))
2618 ;; Need to hack the drawers here.
2620 (goto-char (point-min))
2621 (while (re-search-forward org-drawer-regexp nil t
)
2622 (goto-char (match-beginning 1))
2623 (or (org-invisible-p) (org-flag-drawer nil
))))
2624 (with-current-buffer buffer
(erase-buffer))
2626 (setq s
(goto-char (point-min)))
2627 (while (not (= (point) (point-max)))
2628 (goto-char (org-find-invisible))
2629 (append-to-buffer buffer s
(point))
2630 (setq s
(goto-char (org-find-visible))))
2631 (org-cycle-hide-drawers 'all
)
2632 (goto-char (point-min))
2634 ;; Copy all comment lines to the end, to make sure #+ settings are
2635 ;; still available for the second export step. Kind of a hack, but
2636 ;; does do the trick.
2637 (if (looking-at "#[^\r\n]*")
2638 (append-to-buffer buffer
(match-beginning 0) (1+ (match-end 0))))
2639 (while (re-search-forward "[\n\r]#[^\n\r]*" nil t
)
2640 (append-to-buffer buffer
(1+ (match-beginning 0))
2641 (min (point-max) (1+ (match-end 0))))))
2643 (let ((buffer-file-name file
)
2644 (org-inhibit-startup t
))
2647 (unless keepp
(funcall binding arg
))))
2649 (kill-buffer buffer
)
2650 (switch-to-buffer-other-window buffer
)
2651 (goto-char (point-min)))))
2653 (defun org-find-visible ()
2655 (while (and (not (= (point-max) (setq s
(next-overlay-change s
))))
2656 (get-char-property s
'invisible
)))
2658 (defun org-find-invisible ()
2660 (while (and (not (= (point-max) (setq s
(next-overlay-change s
))))
2661 (not (get-char-property s
'invisible
))))
2664 (defvar org-export-htmlized-org-css-url
) ;; defined in org-html.el
2667 (defun org-export-as-org (arg &optional hidden ext-plist
2668 to-buffer body-only pub-dir
)
2669 "Make a copy with not-exporting stuff removed.
2670 The purpose of this function is to provide a way to export the source
2671 Org file of a webpage in Org format, but with sensitive and/or irrelevant
2672 stuff removed. This command will remove the following:
2674 - archived trees (if the variable `org-export-with-archived-trees' is nil)
2675 - comment blocks and trees starting with the COMMENT keyword
2676 - only trees that are consistent with `org-export-select-tags'
2677 and `org-export-exclude-tags'.
2679 The only arguments that will be used are EXT-PLIST and PUB-DIR,
2680 all the others will be ignored (but are present so that the general
2681 mechanism to call publishing functions will work).
2683 EXT-PLIST is a property list with external parameters overriding
2684 org-mode's default settings, but still inferior to file-local
2685 settings. When PUB-DIR is set, use this as the publishing
2688 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
2690 (org-infile-export-plist)))
2691 (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
2692 (filename (concat (file-name-as-directory
2694 (org-export-directory :org opt-plist
)))
2695 (file-name-sans-extension
2696 (file-name-nondirectory bfname
))
2698 (filename (and filename
2699 (if (equal (file-truename filename
)
2700 (file-truename bfname
))
2701 (concat (file-name-sans-extension filename
)
2703 (file-name-extension filename
))
2705 (backup-inhibited t
)
2706 (buffer (find-file-noselect filename
))
2707 (region (buffer-string)))
2709 (switch-to-buffer buffer
)
2712 (let ((org-inhibit-startup t
)) (org-mode))
2713 (org-install-letbind)
2715 ;; Get rid of archived trees
2716 (org-export-remove-archived-trees (plist-get opt-plist
:archived-trees
))
2718 ;; Remove comment environment and comment subtrees
2719 (org-export-remove-comment-blocks-and-subtrees)
2721 ;; Get rid of excluded trees
2722 (org-export-handle-export-tags (plist-get opt-plist
:select-tags
)
2723 (plist-get opt-plist
:exclude-tags
))
2725 (when (or (plist-get opt-plist
:plain-source
)
2726 (not (or (plist-get opt-plist
:plain-source
)
2727 (plist-get opt-plist
:htmlized-source
))))
2728 ;; Either nothing special is requested (default call)
2729 ;; or the plain source is explicitly requested
2732 (when (plist-get opt-plist
:htmlized-source
)
2733 ;; Make the htmlized version
2736 (font-lock-fontify-buffer)
2737 (let* ((htmlize-output-type 'css
)
2738 (newbuf (htmlize-buffer)))
2739 (with-current-buffer newbuf
2740 (when org-export-htmlized-org-css-url
2741 (goto-char (point-min))
2742 (and (re-search-forward
2743 "<style type=\"text/css\">[^\000]*?\n[ \t]*</style>.*"
2747 "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"
2748 org-export-htmlized-org-css-url
)
2750 (write-file (concat filename
".html")))
2751 (kill-buffer newbuf
)))
2752 (set-buffer-modified-p nil
)
2753 (kill-buffer (current-buffer)))))
2755 (defvar org-archive-location
) ;; gets loaded with the org-archive require.
2756 (defun org-get-current-options ()
2757 "Return a string with current options as keyword options.
2758 Does include HTML export options as well as TODO and CATEGORY stuff."
2759 (require 'org-archive
)
2768 #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s <:%s
2769 #+OPTIONS: TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s
2771 #+EXPORT_SELECT_TAGS: %s
2772 #+EXPORT_EXCLUDE_TAGS: %s
2778 #+PRIORITIES: %c %c %c
2780 #+STARTUP: %s %s %s %s %s
2786 (buffer-name) (user-full-name) user-mail-address
2787 (format-time-string (substring (car org-time-stamp-formats
) 1 -
1))
2788 org-export-default-language
2789 org-export-headline-levels
2790 org-export-with-section-numbers
2792 org-export-preserve-breaks
2793 org-export-html-expand
2794 org-export-with-fixed-width
2795 org-export-with-tables
2796 org-export-with-sub-superscripts
2797 org-export-with-special-strings
2798 org-export-with-footnotes
2799 org-export-with-emphasize
2800 org-export-with-timestamps
2801 org-export-with-TeX-macros
2802 org-export-with-LaTeX-fragments
2803 org-export-skip-text-before-1st-heading
2804 org-export-with-drawers
2805 org-export-with-todo-keywords
2806 org-export-with-priority
2807 org-export-with-tags
2808 (if (featurep 'org-jsinfo
) (org-infojs-options-inbuffer-template) "")
2809 (mapconcat 'identity org-export-select-tags
" ")
2810 (mapconcat 'identity org-export-exclude-tags
" ")
2811 org-export-html-link-up
2812 org-export-html-link-home
2814 (file-name-sans-extension
2815 (file-name-nondirectory (buffer-file-name (buffer-base-buffer)))))
2817 "TODO FEEDBACK VERIFY DONE"
2818 "Me Jason Marie DONE"
2819 org-highest-priority org-lowest-priority org-default-priority
2820 (mapconcat 'identity org-drawers
" ")
2821 (cdr (assoc org-startup-folded
2822 '((nil .
"showall") (t .
"overview") (content .
"content"))))
2823 (if org-odd-levels-only
"odd" "oddeven")
2824 (if org-hide-leading-stars
"hidestars" "showstars")
2825 (if org-startup-align-all-tables
"align" "noalign")
2826 (cond ((eq org-log-done t
) "logdone")
2827 ((equal org-log-done
'note
) "lognotedone")
2828 ((not org-log-done
) "nologdone"))
2829 (or (mapconcat (lambda (x)
2831 ((equal :startgroup
(car x
)) "{")
2832 ((equal :endgroup
(car x
)) "}")
2833 ((equal :newline
(car x
)) "")
2834 ((cdr x
) (format "%s(%c)" (car x
) (cdr x
)))
2836 (or org-tag-alist
(org-get-buffer-tags)) " ") "")
2837 (mapconcat 'identity org-file-tags
" ")
2838 org-archive-location
2839 "org file:~/org/%s.org"
2843 (defun org-insert-export-options-template ()
2844 "Insert into the buffer a template with information for exporting."
2846 (if (not (bolp)) (newline))
2847 (let ((s (org-get-current-options)))
2848 (and (string-match "#\\+CATEGORY" s
)
2849 (setq s
(substring s
0 (match-beginning 0))))
2852 (defvar org-table-colgroup-info nil
)
2854 (defun org-table-clean-before-export (lines &optional maybe-quoted
)
2855 "Check if the table has a marking column.
2856 If yes remove the column and the special lines."
2857 (setq org-table-colgroup-info nil
)
2860 (lambda (x) (or (string-match "^[ \t]*|-" x
)
2863 "^[ \t]*| *\\\\?\\([\#!$*_^ /]\\) *|"
2864 "^[ \t]*| *\\([\#!$*_^ /]\\) *|")
2868 (setq org-table-clean-did-remove-column nil
)
2873 ((string-match "^[ \t]*| */ *|" x
)
2874 (setq org-table-colgroup-info
2876 (cond ((member x
'("<" "<")) :start
)
2877 ((member x
'(">" ">")) :end
)
2878 ((member x
'("<>" "<>")) :startend
)
2880 (org-split-string x
"[ \t]*|[ \t]*")))
2884 (setq org-table-clean-did-remove-column t
)
2889 ((string-match "^[ \t]*| */ *|" x
)
2890 (setq org-table-colgroup-info
2892 (cond ((member x
'("<" "<")) :start
)
2893 ((member x
'(">" ">")) :end
)
2894 ((member x
'("<>" "<>")) :startend
)
2896 (cdr (org-split-string x
"[ \t]*|[ \t]*"))))
2898 ((string-match "^[ \t]*| *[!_^/] *|" x
)
2899 nil
) ; ignore this line
2900 ((or (string-match "^\\([ \t]*\\)|-+\\+" x
)
2901 (string-match "^\\([ \t]*\\)|[^|]*|" x
))
2902 ;; remove the first column
2903 (replace-match "\\1|" t nil x
))))
2906 (defun org-export-cleanup-toc-line (s)
2907 "Remove tags and timestamps from lines going into the toc."
2908 (when (memq org-export-with-tags
'(not-in-toc nil
))
2909 (if (string-match (org-re " +:[[:alnum:]_@:]+: *$") s
)
2910 (setq s
(replace-match "" t t s
))))
2911 (when org-export-remove-timestamps-from-toc
2912 (while (string-match org-maybe-keyword-time-regexp s
)
2913 (setq s
(replace-match "" t t s
))))
2914 (while (string-match org-bracket-link-regexp s
)
2915 (setq s
(replace-match (match-string (if (match-end 3) 3 1) s
)
2917 (while (string-match "\\[\\([0-9]\\|fn:[^]]*\\)\\]" s
)
2918 (setq s
(replace-match "" t t s
)))
2921 (defun org-create-multibrace-regexp (left right n
)
2922 "Create a regular expression which will match a balanced sexp.
2923 Opening delimiter is LEFT, and closing delimiter is RIGHT, both given
2924 as single character strings.
2925 The regexp returned will match the entire expression including the
2926 delimiters. It will also define a single group which contains the
2927 match except for the outermost delimiters. The maximum depth of
2928 stacked delimiters is N. Escaping delimiters is not possible."
2929 (let* ((nothing (concat "[^" left right
"]*?"))
2932 (next (concat "\\(?:" nothing left nothing right
"\\)+" nothing
)))
2935 re
(concat re or next
)
2936 next
(concat "\\(?:" nothing left next right
"\\)+" nothing
)))
2937 (concat left
"\\(" re
"\\)" right
)))
2939 (defvar org-match-substring-regexp
2941 "\\([^\\]\\)\\([_^]\\)\\("
2942 "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth
) "\\)"
2944 "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth
) "\\)"
2946 "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)")
2947 "The regular expression matching a sub- or superscript.")
2949 (defvar org-match-substring-with-braces-regexp
2951 "\\([^\\]\\)\\([_^]\\)\\("
2952 "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth
) "\\)"
2954 "The regular expression matching a sub- or superscript, forcing braces.")
2957 (defun org-get-text-property-any (pos prop
&optional object
)
2958 (or (get-text-property pos prop object
)
2959 (and (setq pos
(next-single-property-change pos prop object
))
2960 (get-text-property pos prop object
))))
2962 (defun org-export-get-coderef-format (path desc
)
2964 (if (and desc
(string-match
2965 (regexp-quote (concat "(" path
")"))
2967 (replace-match "%s" t t desc
)
2970 (defun org-export-push-to-kill-ring (format)
2971 "Push buffer content to kill ring.
2972 The depends on the variable `org-export-copy-to-kill'."
2973 (when org-export-copy-to-kill-ring
2974 (org-kill-new (buffer-string))
2975 (when (fboundp 'x-set-selection
)
2976 (ignore-errors (x-set-selection 'PRIMARY
(buffer-string)))
2977 (ignore-errors (x-set-selection 'CLIPBOARD
(buffer-string))))
2978 (message "%s export done, pushed to kill ring and clipboard" format
)))
2982 ;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
2984 ;;; org-exp.el ends here