1 ;;; org-exp.el --- ASCII, HTML, XOXO and iCalendar export for Org-mode
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
6 ;; Author: Carsten Dominik <carsten at orgmode dot org>
7 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; Homepage: http://orgmode.org
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34 (require 'org-exp-blocks
)
41 (declare-function org-export-latex-preprocess
"org-latex" (parameters))
42 (declare-function org-export-ascii-preprocess
"org-ascii" (parameters))
43 (declare-function org-export-html-preprocess
"org-html" (parameters))
44 (declare-function org-export-docbook-preprocess
"org-docbook" (parameters))
45 (declare-function org-infojs-options-inbuffer-template
"org-jsinfo" ())
46 (declare-function org-export-htmlize-region-for-paste
"org-html" (beg end
))
47 (declare-function htmlize-buffer
"ext:htmlize" (&optional buffer
))
48 (declare-function org-inlinetask-remove-END-maybe
"org-inlinetask" ())
49 (declare-function org-table-cookie-line-p
"org-table" (line))
50 (declare-function org-table-colgroup-line-p
"org-table" (line))
51 (autoload 'org-export-generic
"org-export-generic" "Export using the generic exporter" t
)
52 (defgroup org-export nil
53 "Options for exporting org-listings."
57 (defgroup org-export-general nil
58 "General options for exporting Org-mode files."
59 :tag
"Org Export General"
62 (defcustom org-export-allow-BIND
'confirm
63 "Non-nil means allow #+BIND to define local variable values for export.
64 This is a potential security risk, which is why the user must confirm the
66 :group
'org-export-general
68 (const :tag
"Never" nil
)
69 (const :tag
"Always" t
)
70 (const :tag
"Make the user confirm for each file" confirm
)))
73 (defvar org-export-publishing-directory nil
)
75 (defcustom org-export-show-temporary-export-buffer t
76 "Non-nil means show buffer after exporting to temp buffer.
77 When Org exports to a file, the buffer visiting that file is ever
78 shown, but remains buried. However, when exporting to a temporary
79 buffer, that buffer is popped up in a second window. When this variable
80 is nil, the buffer remains buried also in these cases."
81 :group
'org-export-general
84 (defcustom org-export-copy-to-kill-ring t
85 "Non-nil means exported stuff will also be pushed onto the kill ring."
86 :group
'org-export-general
89 (defcustom org-export-kill-product-buffer-when-displayed nil
90 "Non-nil means kill the product buffer if it is displayed immediately.
91 This applied to the commands `org-export-as-html-and-open' and
92 `org-export-as-pdf-and-open'."
93 :group
'org-export-general
96 (defcustom org-export-run-in-background nil
97 "Non-nil means export and publishing commands will run in background.
98 This works by starting up a separate Emacs process visiting the same file
99 and doing the export from there.
100 Not all export commands are affected by this - only the ones which
101 actually write to a file, and that do not depend on the buffer state.
103 If this option is nil, you can still get background export by calling
104 `org-export' with a double prefix arg: \
105 \\[universal-argument] \\[universal-argument] \\[org-export].
107 If this option is t, the double prefix can be used to exceptionally
108 force an export command into the current process."
109 :group
'org-export-general
112 (defcustom org-export-initial-scope
'buffer
113 "The initial scope when exporting with `org-export'.
114 This variable can be either set to 'buffer or 'subtree."
115 :group
'org-export-general
117 (const :tag
"Export current buffer" 'buffer
)
118 (const :tag
"Export current subtree" 'subtree
)))
120 (defcustom org-export-select-tags
'("export")
121 "Tags that select a tree for export.
122 If any such tag is found in a buffer, all trees that do not carry one
123 of these tags will be deleted before export.
124 Inside trees that are selected like this, you can still deselect a
125 subtree by tagging it with one of the `org-export-exclude-tags'."
126 :group
'org-export-general
127 :type
'(repeat (string :tag
"Tag")))
129 (defcustom org-export-exclude-tags
'("noexport")
130 "Tags that exclude a tree from export.
131 All trees carrying any of these tags will be excluded from export.
132 This is without condition, so even subtrees inside that carry one of the
133 `org-export-select-tags' will be removed."
134 :group
'org-export-general
135 :type
'(repeat (string :tag
"Tag")))
137 ;; FIXME: rename, this is a general variable
138 (defcustom org-export-html-expand t
139 "Non-nil means for HTML export, treat @<...> as HTML tag.
140 When nil, these tags will be exported as plain text and therefore
141 not be interpreted by a browser.
143 This option can also be set with the +OPTIONS line, e.g. \"@:nil\"."
144 :group
'org-export-html
145 :group
'org-export-general
148 (defcustom org-export-with-special-strings t
149 "Non-nil means interpret \"\-\", \"--\" and \"---\" for export.
150 When this option is turned on, these strings will be exported as:
153 -----+----------+--------
159 This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
160 :group
'org-export-translation
163 (defcustom org-export-html-link-up
""
164 "Where should the \"UP\" link of exported HTML pages lead?"
165 :group
'org-export-html
166 :group
'org-export-general
167 :type
'(string :tag
"File or URL"))
169 (defcustom org-export-html-link-home
""
170 "Where should the \"HOME\" link of exported HTML pages lead?"
171 :group
'org-export-html
172 :group
'org-export-general
173 :type
'(string :tag
"File or URL"))
175 (defcustom org-export-language-setup
176 '(("en" "Author" "Date" "Table of Contents" "Footnotes")
177 ("ca" "Autor" "Data" "Índex" "Peus de pàgina")
178 ("cs" "Autor" "Datum" "Obsah" "Pozn\xe1mky pod carou")
179 ("da" "Ophavsmand" "Dato" "Indhold" "Fodnoter")
180 ("de" "Autor" "Datum" "Inhaltsverzeichnis" "Fußnoten")
181 ("eo" "Aŭtoro" "Dato" "Enhavo" "Piednotoj")
182 ("es" "Autor" "Fecha" "Índice" "Pies de página")
183 ("fi" "Tekijä" "Päivämäärä" "Sisällysluettelo" "Alaviitteet")
184 ("fr" "Auteur" "Date" "Table des matières" "Notes de bas de page")
185 ("hu" "Szerzõ" "Dátum" "Tartalomjegyzék" "Lábjegyzet")
186 ("is" "Höfundur" "Dagsetning" "Efnisyfirlit" "Aftanmálsgreinar")
187 ("it" "Autore" "Data" "Indice" "Note a piè di pagina")
188 ("nl" "Auteur" "Datum" "Inhoudsopgave" "Voetnoten")
189 ("no" "Forfatter" "Dato" "Innhold" "Fotnoter")
190 ("nb" "Forfatter" "Dato" "Innhold" "Fotnoter") ;; nb = Norsk (bokm.l)
191 ("nn" "Forfattar" "Dato" "Innhald" "Fotnotar") ;; nn = Norsk (nynorsk)
192 ("pl" "Autor" "Data" "Spis treści" "Przypis")
193 ("sv" "Författare" "Datum" "Innehåll" "Fotnoter"))
194 "Terms used in export text, translated to different languages.
195 Use the variable `org-export-default-language' to set the language,
196 or use the +OPTION lines for a per-file setting."
197 :group
'org-export-general
200 (string :tag
"HTML language tag")
201 (string :tag
"Author")
203 (string :tag
"Table of Contents")
204 (string :tag
"Footnotes"))))
206 (defcustom org-export-default-language
"en"
207 "The default language for export and clocktable translations, as a string.
208 This should have an association in `org-export-language-setup'
209 and in `org-clock-clocktable-language-setup'."
210 :group
'org-export-general
213 (defvar org-export-page-description
""
214 "The page description, for the XHTML meta tag.
215 This is best set with the #+DESCRIPTION line in a file, it does not make
216 sense to set this globally.")
218 (defvar org-export-page-keywords
""
219 "The page description, for the XHTML meta tag.
220 This is best set with the #+KEYWORDS line in a file, it does not make
221 sense to set this globally.")
223 (defcustom org-export-skip-text-before-1st-heading nil
224 "Non-nil means skip all text before the first headline when exporting.
225 When nil, that text is exported as well."
226 :group
'org-export-general
229 (defcustom org-export-headline-levels
3
230 "The last level which is still exported as a headline.
231 Inferior levels will produce itemize lists when exported.
232 Note that a numeric prefix argument to an exporter function overrides
235 This option can also be set with the +OPTIONS line, e.g. \"H:2\"."
236 :group
'org-export-general
239 (defcustom org-export-with-section-numbers t
240 "Non-nil means add section numbers to headlines when exporting.
242 This option can also be set with the +OPTIONS line, e.g. \"num:t\"."
243 :group
'org-export-general
246 (defcustom org-export-section-number-format
'((("1" ".")) .
"")
247 "Format of section numbers for export.
248 The variable has two components.
249 1. A list of lists, each indicating a counter type and a separator.
250 The counter type can be any of \"1\", \"A\", \"a\", \"I\", or \"i\".
251 It causes causes numeric, alphabetic, or roman counters, respectively.
252 The separator is only used if another counter for a subsection is being
254 If there are more numbered section levels than entries in this lists,
255 then the last entry will be reused.
256 2. A terminator string that will be added after the entire
258 :group
'org-export-general
262 (string :tag
"Counter Type")
263 (string :tag
"Separator ")))
264 (string :tag
"Terminator")))
266 (defcustom org-export-with-toc t
267 "Non-nil means create a table of contents in exported files.
268 The TOC contains headlines with levels up to`org-export-headline-levels'.
269 When an integer, include levels up to N in the toc, this may then be
270 different from `org-export-headline-levels', but it will not be allowed
271 to be larger than the number of headline levels.
272 When nil, no table of contents is made.
274 Headlines which contain any TODO items will be marked with \"(*)\" in
275 ASCII export, and with red color in HTML output, if the option
276 `org-export-mark-todo-in-toc' is set.
278 In HTML output, the TOC will be clickable.
280 This option can also be set with the +OPTIONS line, e.g. \"toc:nil\"
282 :group
'org-export-general
284 (const :tag
"No Table of Contents" nil
)
285 (const :tag
"Full Table of Contents" t
)
286 (integer :tag
"TOC to level")))
288 (defcustom org-export-mark-todo-in-toc nil
289 "Non-nil means mark TOC lines that contain any open TODO items."
290 :group
'org-export-general
293 (defcustom org-export-with-todo-keywords t
294 "Non-nil means include TODO keywords in export.
295 When nil, remove all these keywords from the export."
296 :group
'org-export-general
299 (defcustom org-export-with-tasks t
300 "Non-nil means include TODO items for export.
301 This may have the following values:
302 t include tasks independent of state.
303 todo include only tasks that are not yet done.
304 done include only tasks that are already done.
305 nil remove all tasks before export
306 list of TODO kwds keep only tasks with these keywords"
307 :group
'org-export-general
309 (const :tag
"All tasks" t
)
310 (const :tag
"No tasks" nil
)
311 (const :tag
"Not-done tasks" todo
)
312 (const :tag
"Only done tasks" done
)
313 (repeat :tag
"Specific TODO keywords"
314 (string :tag
"Keyword"))))
316 (defcustom org-export-with-priority nil
317 "Non-nil means include priority cookies in export.
318 When nil, remove priority cookies for export."
319 :group
'org-export-general
322 (defcustom org-export-preserve-breaks nil
323 "Non-nil means preserve all line breaks when exporting.
324 Normally, in HTML output paragraphs will be reformatted. In ASCII
325 export, line breaks will always be preserved, regardless of this variable.
327 This option can also be set with the +OPTIONS line, e.g. \"\\n:t\"."
328 :group
'org-export-general
331 (defcustom org-export-with-archived-trees
'headline
332 "Whether subtrees with the ARCHIVE tag should be exported.
333 This can have three different values
334 nil Do not export, pretend this tree is not present
335 t Do export the entire tree
336 headline Only export the headline, but skip the tree below it."
337 :group
'org-export-general
340 (const :tag
"not at all" nil
)
341 (const :tag
"headline only" 'headline
)
342 (const :tag
"entirely" t
)))
344 (defcustom org-export-author-info t
345 "Non-nil means insert author name and email into the exported file.
347 This option can also be set with the +OPTIONS line,
348 e.g. \"author:nil\"."
349 :group
'org-export-general
352 (defcustom org-export-email-info nil
353 "Non-nil means insert author name and email into the exported file.
355 This option can also be set with the +OPTIONS line,
357 :group
'org-export-general
360 (defcustom org-export-creator-info t
361 "Non-nil means the postamble should contain a creator sentence.
362 This sentence is \"HTML generated by org-mode XX in emacs XXX\"."
363 :group
'org-export-general
366 (defcustom org-export-time-stamp-file t
367 "Non-nil means insert a time stamp into the exported file.
368 The time stamp shows when the file was created.
370 This option can also be set with the +OPTIONS line,
371 e.g. \"timestamp:nil\"."
372 :group
'org-export-general
375 (defcustom org-export-with-timestamps t
376 "If nil, do not export time stamps and associated keywords."
377 :group
'org-export-general
380 (defcustom org-export-remove-timestamps-from-toc t
381 "If t, remove timestamps from the table of contents entries."
382 :group
'org-export-general
385 (defcustom org-export-with-tags
'not-in-toc
386 "If nil, do not export tags, just remove them from headlines.
387 If this is the symbol `not-in-toc', tags will be removed from table of
388 contents entries, but still be shown in the headlines of the document.
390 This option can also be set with the +OPTIONS line, e.g. \"tags:nil\"."
391 :group
'org-export-general
393 (const :tag
"Off" nil
)
394 (const :tag
"Not in TOC" not-in-toc
)
395 (const :tag
"On" t
)))
397 (defcustom org-export-with-drawers nil
398 "Non-nil means export with drawers like the property drawer.
399 When t, all drawers are exported. This may also be a list of
400 drawer names to export."
401 :group
'org-export-general
403 (const :tag
"All drawers" t
)
404 (const :tag
"None" nil
)
405 (repeat :tag
"Selected drawers"
406 (string :tag
"Drawer name"))))
408 (defvar org-export-first-hook nil
409 "Hook called as the first thing in each exporter.
410 Point will be still in the original buffer.
411 Good for general initialization")
413 (defvar org-export-preprocess-hook nil
414 "Hook for preprocessing an export buffer.
415 Pretty much the first thing when exporting is running this hook.
416 Point will be in a temporary buffer that contains a copy of
417 the original buffer, or of the section that is being exported.
418 All the other hooks in the org-export-preprocess... category
419 also work in that temporary buffer, already modified by various
420 stages of the processing.")
422 (defvar org-export-preprocess-after-include-files-hook nil
423 "Hook for preprocessing an export buffer.
424 This is run after the contents of included files have been inserted.")
426 (defvar org-export-preprocess-after-tree-selection-hook nil
427 "Hook for preprocessing an export buffer.
428 This is run after selection of trees to be exported has happened.
429 This selection includes tags-based selection, as well as removal
430 of commented and archived trees.")
432 (defvar org-export-preprocess-after-headline-targets-hook nil
433 "Hook for preprocessing export buffer.
434 This is run just after the headline targets have been defined and
435 the target-alist has been set up.")
437 (defvar org-export-preprocess-before-selecting-backend-code-hook nil
438 "Hook for preprocessing an export buffer.
439 This is run just before backend-specific blocks get selected.")
441 (defvar org-export-preprocess-after-blockquote-hook nil
442 "Hook for preprocessing an export buffer.
443 This is run after blockquote/quote/verse/center have been marked
446 (defvar org-export-preprocess-after-radio-targets-hook nil
447 "Hook for preprocessing an export buffer.
448 This is run after radio target processing.")
450 (defvar org-export-preprocess-before-normalizing-links-hook nil
451 "Hook for preprocessing an export buffer.
452 This hook is run before links are normalized.")
454 (defvar org-export-preprocess-before-backend-specifics-hook nil
455 "Hook run before backend-specific functions are called during preprocessing.")
457 (defvar org-export-preprocess-final-hook nil
458 "Hook for preprocessing an export buffer.
459 This is run as the last thing in the preprocessing buffer, just before
460 returning the buffer string to the backend.")
462 (defgroup org-export-translation nil
463 "Options for translating special ascii sequences for the export backends."
464 :tag
"Org Export Translation"
467 (defcustom org-export-with-emphasize t
468 "Non-nil means interpret *word*, /word/, and _word_ as emphasized text.
469 If the export target supports emphasizing text, the word will be
470 typeset in bold, italic, or underlined, respectively. Works only for
471 single words, but you can say: I *really* *mean* *this*.
472 Not all export backends support this.
474 This option can also be set with the +OPTIONS line, e.g. \"*:nil\"."
475 :group
'org-export-translation
478 (defcustom org-export-with-footnotes t
479 "If nil, export [1] as a footnote marker.
480 Lines starting with [1] will be formatted as footnotes.
482 This option can also be set with the +OPTIONS line, e.g. \"f:nil\"."
483 :group
'org-export-translation
486 (defcustom org-export-with-TeX-macros t
487 "Non-nil means interpret simple TeX-like macros when exporting.
488 For example, HTML export converts \\alpha to α and \\AA to Å.
489 Not only real TeX macros will work here, but the standard HTML entities
490 for math can be used as macro names as well. For a list of supported
491 names in HTML export, see the constant `org-entities' and the user option
493 Not all export backends support this.
495 This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"."
496 :group
'org-export-translation
497 :group
'org-export-latex
500 (defcustom org-export-with-LaTeX-fragments t
501 "Non-nil means process LaTeX math fragments for HTML display.
502 When set, the exporter will find and process LaTeX environments if the
503 \\begin line is the first non-white thing on a line. It will also find
504 and process the math delimiters like $a=b$ and \\( a=b \\) for inline math,
505 $$a=b$$ and \\=\\[ a=b \\] for display math.
507 This option can also be set with the +OPTIONS line, e.g. \"LaTeX:mathjax\".
511 nil Don't do anything.
512 verbatim Keep everything in verbatim
513 dvipng Process the LaTeX fragments to images.
514 This will also include processing of non-math environments.
515 t Do MathJax preprocessing if there is at least on math snippet,
516 and arrange for MathJax.js to be loaded.
518 The default is nil, because this option needs the `dvipng' program which
519 is not available on all systems."
520 :group
'org-export-translation
521 :group
'org-export-latex
523 (const :tag
"Do not process math in any way" nil
)
524 (const :tag
"Obsolete, use dvipng setting" t
)
525 (const :tag
"Use dvipng to make images" dvipng
)
526 (const :tag
"Use MathJax to display math" mathjax
)
527 (const :tag
"Leave math verbatim" verbatim
)))
529 (defcustom org-export-with-fixed-width t
530 "Non-nil means lines starting with \":\" will be in fixed width font.
531 This can be used to have pre-formatted text, fragments of code etc. For
533 : ;; Some Lisp examples
536 will be looking just like this in also HTML. See also the QUOTE keyword.
537 Not all export backends support this.
539 This option can also be set with the +OPTIONS line, e.g. \"::nil\"."
540 :group
'org-export-translation
543 (defgroup org-export-tables nil
544 "Options for exporting tables in Org-mode."
545 :tag
"Org Export Tables"
548 (defcustom org-export-with-tables t
549 "If non-nil, lines starting with \"|\" define a table.
552 | Name | Address | Birthday |
553 |-------------+----------+-----------|
554 | Arthur Dent | England | 29.2.2100 |
556 Not all export backends support this.
558 This option can also be set with the +OPTIONS line, e.g. \"|:nil\"."
559 :group
'org-export-tables
562 (defcustom org-export-highlight-first-table-line t
563 "Non-nil means highlight the first table line.
564 In HTML export, this means use <th> instead of <td>.
565 In tables created with table.el, this applies to the first table line.
566 In Org-mode tables, all lines before the first horizontal separator
567 line will be formatted with <th> tags."
568 :group
'org-export-tables
571 (defcustom org-export-table-remove-special-lines t
572 "Remove special lines and marking characters in calculating tables.
573 This removes the special marking character column from tables that are set
574 up for spreadsheet calculations. It also removes the entire lines
575 marked with `!', `_', or `^'. The lines with `$' are kept, because
576 the values of constants may be useful to have."
577 :group
'org-export-tables
580 (defcustom org-export-table-remove-empty-lines t
581 "Remove empty lines when exporting tables.
582 This is the global equivalent of the :remove-nil-lines option
583 when locally sending a table with #+ORGTBL."
584 :group
'org-export-tables
587 (defcustom org-export-prefer-native-exporter-for-tables nil
588 "Non-nil means always export tables created with table.el natively.
589 Natively means use the HTML code generator in table.el.
590 When nil, Org-mode's own HTML generator is used when possible (i.e. if
591 the table does not use row- or column-spanning). This has the
592 advantage, that the automatic HTML conversions for math symbols and
593 sub/superscripts can be applied. Org-mode's HTML generator is also
594 much faster. The LaTeX exporter always use the native exporter for
596 :group
'org-export-tables
601 ;;; Variables, constants, and parameter plists
603 (defconst org-level-max
20)
605 (defvar org-export-current-backend nil
606 "During export, this will be bound to a symbol such as 'html,
607 'latex, 'docbook, 'ascii, etc, indicating which of the export
608 backends is in use. Otherwise it has the value nil. Users
609 should not attempt to change the value of this variable
610 directly, but it can be used in code to test whether export is
611 in progress, and if so, what the backend is.")
613 (defvar org-current-export-file nil
) ; dynamically scoped parameter
614 (defvar org-current-export-dir nil
) ; dynamically scoped parameter
615 (defvar org-export-opt-plist nil
616 "Contains the current option plist.")
617 (defvar org-last-level nil
) ; dynamically scoped variable
618 (defvar org-min-level nil
) ; dynamically scoped variable
619 (defvar org-levels-open nil
) ; dynamically scoped parameter
621 (defconst org-export-plist-vars
622 '((:link-up nil org-export-html-link-up
)
623 (:link-home nil org-export-html-link-home
)
624 (:language nil org-export-default-language
)
625 (:keywords nil org-export-page-keywords
)
626 (:description nil org-export-page-description
)
627 (:customtime nil org-display-custom-times
)
628 (:headline-levels
"H" org-export-headline-levels
)
629 (:section-numbers
"num" org-export-with-section-numbers
)
630 (:section-number-format nil org-export-section-number-format
)
631 (:table-of-contents
"toc" org-export-with-toc
)
632 (:preserve-breaks
"\\n" org-export-preserve-breaks
)
633 (:archived-trees nil org-export-with-archived-trees
)
634 (:emphasize
"*" org-export-with-emphasize
)
635 (:sub-superscript
"^" org-export-with-sub-superscripts
)
636 (:special-strings
"-" org-export-with-special-strings
)
637 (:footnotes
"f" org-export-with-footnotes
)
638 (:drawers
"d" org-export-with-drawers
)
639 (:tags
"tags" org-export-with-tags
)
640 (:todo-keywords
"todo" org-export-with-todo-keywords
)
641 (:tasks
"tasks" org-export-with-tasks
)
642 (:priority
"pri" org-export-with-priority
)
643 (:TeX-macros
"TeX" org-export-with-TeX-macros
)
644 (:LaTeX-fragments
"LaTeX" org-export-with-LaTeX-fragments
)
645 (:latex-listings nil org-export-latex-listings
)
646 (:skip-before-1st-heading
"skip" org-export-skip-text-before-1st-heading
)
647 (:fixed-width
":" org-export-with-fixed-width
)
648 (:timestamps
"<" org-export-with-timestamps
)
649 (:author nil user-full-name
)
650 (:email nil user-mail-address
)
651 (:author-info
"author" org-export-author-info
)
652 (:email-info
"email" org-export-email-info
)
653 (:creator-info
"creator" org-export-creator-info
)
654 (:time-stamp-file
"timestamp" org-export-time-stamp-file
)
655 (:tables
"|" org-export-with-tables
)
656 (:table-auto-headline nil org-export-highlight-first-table-line
)
657 (:style-include-default nil org-export-html-style-include-default
)
658 (:style-include-scripts nil org-export-html-style-include-scripts
)
659 (:style nil org-export-html-style
)
660 (:style-extra nil org-export-html-style-extra
)
661 (:agenda-style nil org-agenda-export-html-style
)
662 (:convert-org-links nil org-export-html-link-org-files-as-html
)
663 (:inline-images nil org-export-html-inline-images
)
664 (:html-extension nil org-export-html-extension
)
665 (:html-preamble nil org-export-html-preamble
)
666 (:html-postamble nil org-export-html-postamble
)
667 (:xml-declaration nil org-export-html-xml-declaration
)
668 (:html-table-tag nil org-export-html-table-tag
)
669 (:expand-quoted-html
"@" org-export-html-expand
)
670 (:timestamp nil org-export-html-with-timestamp
)
671 (:publishing-directory nil org-export-publishing-directory
)
672 (:select-tags nil org-export-select-tags
)
673 (:exclude-tags nil org-export-exclude-tags
)
675 (:latex-image-options nil org-export-latex-image-default-option
))
676 "List of properties that represent export/publishing variables.
677 Each element is a list of 3 items:
678 1. The property that is used internally, and also for org-publish-project-alist
679 2. The string that can be used in the OPTION lines to set this option,
680 or nil if this option cannot be changed in this way
681 3. The customization variable that sets the default for this option."
684 (defun org-default-export-plist ()
685 "Return the property list with default settings for the export variables."
686 (let* ((infile (org-infile-export-plist))
687 (letbind (plist-get infile
:let-bind
))
688 (l org-export-plist-vars
) rtn e s v
)
689 (while (setq e
(pop l
))
692 ((assq s letbind
) (nth 1 (assq s letbind
)))
693 ((boundp s
) (symbol-value s
))
695 rtn
(cons (car e
) (cons v rtn
))))
698 (defvar org-export-inbuffer-options-extra nil
699 "List of additional in-buffer options that should be detected.
700 Just before export, the buffer is scanned for options like #+TITLE, #+EMAIL,
701 etc. Extensions can add to this list to get their options detected, and they
702 can then add a function to `org-export-options-filters' to process these
704 Each element in this list must be a list, with the in-buffer keyword as car,
705 and a property (a symbol) as the next element. All occurrences of the
706 keyword will be found, the values concatenated with a space character
707 in between, and the result stored in the export options property list.")
709 (defvar org-export-options-filters nil
710 "Functions to be called to finalize the export/publishing options.
711 All these options are stored in a property list, and each of the functions
712 in this hook gets a chance to modify this property list. Each function
713 must accept the property list as an argument, and must return the (possibly
716 ;; FIXME: should we fold case here?
717 (defun org-infile-export-plist ()
718 "Return the property list with file-local settings for export."
722 (goto-char (point-min))
723 (let ((re (org-make-options-regexp
725 '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
727 "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE"
728 "LATEX_HEADER" "LATEX_CLASS"
729 "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS"
730 "KEYWORDS" "DESCRIPTION" "MACRO" "BIND" "XSLT")
731 (mapcar 'car org-export-inbuffer-options-extra
))))
733 p key val text options mathjax a pr style
734 latex-header latex-class macros letbind
735 ext-setup-or-nil setup-contents
(start 0))
736 (while (or (and ext-setup-or-nil
737 (string-match re ext-setup-or-nil start
)
738 (setq start
(match-end 0)))
739 (and (setq ext-setup-or-nil nil start
0)
740 (re-search-forward re nil t
)))
741 (setq key
(upcase (org-match-string-no-properties 1 ext-setup-or-nil
))
742 val
(org-match-string-no-properties 2 ext-setup-or-nil
))
744 ((setq a
(assoc key org-export-inbuffer-options-extra
))
746 (setq p
(plist-put p pr
(concat (plist-get p pr
) " " val
))))
747 ((string-equal key
"TITLE") (setq p
(plist-put p
:title val
)))
748 ((string-equal key
"AUTHOR")(setq p
(plist-put p
:author val
)))
749 ((string-equal key
"EMAIL") (setq p
(plist-put p
:email val
)))
750 ((string-equal key
"DATE") (setq p
(plist-put p
:date val
)))
751 ((string-equal key
"KEYWORDS") (setq p
(plist-put p
:keywords val
)))
752 ((string-equal key
"DESCRIPTION")
753 (setq p
(plist-put p
:description val
)))
754 ((string-equal key
"LANGUAGE") (setq p
(plist-put p
:language val
)))
755 ((string-equal key
"STYLE")
756 (setq style
(concat style
"\n" val
)))
757 ((string-equal key
"LATEX_HEADER")
758 (setq latex-header
(concat latex-header
"\n" val
)))
759 ((string-equal key
"LATEX_CLASS")
760 (setq latex-class val
))
761 ((string-equal key
"TEXT")
762 (setq text
(if text
(concat text
"\n" val
) val
)))
763 ((string-equal key
"OPTIONS")
764 (setq options
(concat val
" " options
)))
765 ((string-equal key
"MATHJAX")
766 (setq mathjax
(concat val
" " mathjax
)))
767 ((string-equal key
"BIND")
768 (push (read (concat "(" val
")")) letbind
))
769 ((string-equal key
"XSLT")
770 (setq p
(plist-put p
:xslt val
)))
771 ((string-equal key
"LINK_UP")
772 (setq p
(plist-put p
:link-up val
)))
773 ((string-equal key
"LINK_HOME")
774 (setq p
(plist-put p
:link-home val
)))
775 ((string-equal key
"EXPORT_SELECT_TAGS")
776 (setq p
(plist-put p
:select-tags
(org-split-string val
))))
777 ((string-equal key
"EXPORT_EXCLUDE_TAGS")
778 (setq p
(plist-put p
:exclude-tags
(org-split-string val
))))
779 ((string-equal key
"MACRO")
781 ((equal key
"SETUPFILE")
782 (setq setup-contents
(org-file-contents
784 (org-remove-double-quotes
787 (if (not ext-setup-or-nil
)
788 (setq ext-setup-or-nil setup-contents start
0)
789 (setq ext-setup-or-nil
790 (concat (substring ext-setup-or-nil
0 start
)
791 "\n" setup-contents
"\n"
792 (substring ext-setup-or-nil start
)))))))
793 (setq p
(plist-put p
:text text
))
794 (when (and letbind
(org-export-confirm-letbind))
795 (setq p
(plist-put p
:let-bind letbind
)))
796 (when style
(setq p
(plist-put p
:style-extra style
)))
798 (setq p
(plist-put p
:latex-header-extra
(substring latex-header
1))))
800 (setq p
(plist-put p
:latex-class latex-class
)))
802 (setq p
(org-export-add-options-to-plist p options
)))
804 (setq p
(plist-put p
:mathjax mathjax
)))
805 ;; Add macro definitions
806 (setq p
(plist-put p
:macro-date
"(eval (format-time-string \"$1\"))"))
807 (setq p
(plist-put p
:macro-time
"(eval (format-time-string \"$1\"))"))
808 (setq p
(plist-put p
:macro-property
"(eval (org-entry-get nil \"$1\" 'selective))"))
810 p
:macro-modification-time
811 (and (buffer-file-name)
812 (file-exists-p (buffer-file-name))
814 "(eval (format-time-string \"$1\" '"
815 (prin1-to-string (nth 5 (file-attributes
816 (buffer-file-name))))
818 (setq p
(plist-put p
:macro-input-file
(and (buffer-file-name)
819 (file-name-nondirectory
820 (buffer-file-name)))))
821 (while (setq val
(pop macros
))
822 (when (string-match "^\\([-a-zA-Z0-9_]+\\)[ \t]+\\(.*?[ \t]*$\\)" val
)
825 (concat ":macro-" (downcase (match-string 1 val
))))
826 (org-export-interpolate-newlines (match-string 2 val
))))))
829 (defun org-export-interpolate-newlines (s)
830 (while (string-match "\\\\n" s
)
831 (setq s
(replace-match "\n" t t s
)))
834 (defvar org-export-allow-BIND-local nil
)
835 (defun org-export-confirm-letbind ()
836 "Can we use #+BIND values during export?
837 By default this will ask for confirmation by the user, to divert possible
840 ((not org-export-allow-BIND
) nil
)
841 ((eq org-export-allow-BIND t
) t
)
842 ((local-variable-p 'org-export-allow-BIND-local
(current-buffer))
843 org-export-allow-BIND-local
)
844 (t (org-set-local 'org-export-allow-BIND-local
845 (yes-or-no-p "Allow BIND values in this buffer? ")))))
847 (defun org-install-letbind ()
848 "Install the values from #+BIND lines as local variables."
849 (let ((letbind (plist-get org-export-opt-plist
:let-bind
))
851 (while (setq pair
(pop letbind
))
852 (org-set-local (car pair
) (nth 1 pair
)))))
854 (defun org-export-add-options-to-plist (p options
)
855 "Parse an OPTIONS line and set values in the property list P."
858 (let ((op org-export-plist-vars
))
859 (while (setq o
(pop op
))
861 (string-match (concat "\\(\\`\\|[ \t]\\)"
862 (regexp-quote (nth 1 o
))
863 ":\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)")
865 (setq p
(plist-put p
(car o
)
866 (car (read-from-string
867 (match-string 2 options
))))))))))
870 (defun org-export-add-subtree-options (p pos
)
871 "Add options in subtree at position POS to property list P."
874 (when (org-at-heading-p)
876 ;; This is actually read in `org-export-get-title-from-subtree'
877 ;; (when (setq a (org-entry-get pos "EXPORT_TITLE"))
878 ;; (setq p (plist-put p :title a)))
879 (when (setq a
(org-entry-get pos
"EXPORT_TEXT"))
880 (setq p
(plist-put p
:text a
)))
881 (when (setq a
(org-entry-get pos
"EXPORT_AUTHOR"))
882 (setq p
(plist-put p
:author a
)))
883 (when (setq a
(org-entry-get pos
"EXPORT_DATE"))
884 (setq p
(plist-put p
:date a
)))
885 (when (setq a
(org-entry-get pos
"EXPORT_OPTIONS"))
886 (setq p
(org-export-add-options-to-plist p a
)))))
889 (defun org-export-directory (type plist
)
890 (let* ((val (plist-get plist
:publishing-directory
))
892 (or (cdr (assoc type val
)) ".")
896 (defun org-export-process-option-filters (plist)
897 (let ((functions org-export-options-filters
) f
)
898 (while (setq f
(pop functions
))
899 (setq plist
(funcall f plist
))))
903 (defun org-export (&optional arg
)
904 "Export dispatcher for Org-mode.
905 When `org-export-run-in-background' is non-nil, try to run the command
906 in the background. This will be done only for commands that write
907 to a file. For details see the docstring of `org-export-run-in-background'.
909 The prefix argument ARG will be passed to the exporter. However, if
910 ARG is a double universal prefix \\[universal-argument] \\[universal-argument], \
911 that means to inverse the
912 value of `org-export-run-in-background'.
914 If `org-export-initial-scope' is set to 'subtree, try to export
915 the current subtree, otherwise try to export the whole buffer.
916 Pressing `1' will switch between these two options."
918 (let* ((bg (org-xor (equal arg
'(16)) org-export-run-in-background
))
919 (subtree-p (or (org-region-active-p)
920 (eq org-export-initial-scope
'subtree
)))
921 (help "[t] insert the export option template
922 \[v] limit export to visible part of outline tree
923 \[1] switch buffer/subtree export
924 \[SPC] publish enclosing subtree (with LaTeX_CLASS or EXPORT_FILE_NAME prop)
926 \[a/n/u] export as ASCII/Latin-1/UTF-8 [A/N/U] to temporary buffer
928 \[h] export as HTML [H] to temporary buffer [R] export region
929 \[b] export as HTML and open in browser
931 \[l] export as LaTeX [L] to temporary buffer
932 \[p] export as LaTeX and process to PDF [d] ... and open PDF file
934 \[D] export as DocBook [V] export as DocBook, process to PDF, and open
936 \[o] export as ODT [O] export as ODT and open
938 \[j] export as TaskJuggler [J] ... and open
940 \[m] export as Freemind mind map
942 \[g] export using Wes Hardaker's generic exporter
944 \[i] export current file as iCalendar file
945 \[I] export all agenda files as iCalendar files [c] ...as one combined file
947 \[F] publish current file [P] publish current project
948 \[X] publish a project... [E] publish every projects")
950 '((?t org-insert-export-options-template nil
)
951 (?v org-export-visible nil
)
952 (?a org-export-as-ascii t
)
953 (?A org-export-as-ascii-to-buffer t
)
954 (?n org-export-as-latin1 t
)
955 (?N org-export-as-latin1-to-buffer t
)
956 (?u org-export-as-utf8 t
)
957 (?U org-export-as-utf8-to-buffer t
)
958 (?h org-export-as-html t
)
959 (?b org-export-as-html-and-open t
)
960 (?H org-export-as-html-to-buffer nil
)
961 (?R org-export-region-as-html nil
)
962 (?x org-export-as-xoxo t
)
963 (?g org-export-generic t
)
964 (?D org-export-as-docbook t
)
965 (?V org-export-as-docbook-pdf-and-open t
)
966 (?o org-export-as-odt t
)
967 (?O org-export-as-odt-and-open nil
)
968 (?j org-export-as-taskjuggler t
)
969 (?J org-export-as-taskjuggler-and-open t
)
970 (?m org-export-as-freemind t
)
971 (?l org-export-as-latex t
)
972 (?p org-export-as-pdf t
)
973 (?d org-export-as-pdf-and-open t
)
974 (?L org-export-as-latex-to-buffer nil
)
975 (?i org-export-icalendar-this-file t
)
976 (?I org-export-icalendar-all-agenda-files t
)
977 (?c org-export-icalendar-combine-agenda-files t
)
978 (?F org-publish-current-file t
)
979 (?P org-publish-current-project t
)
981 (?E org-publish-all t
)))
983 (cpos (point)) (cbuf (current-buffer)) bpos
)
985 (save-window-excursion
987 (message "Export subtree: ")
988 (message "Export buffer: "))
989 (delete-other-windows)
990 (with-output-to-temp-buffer "*Org Export/Publishing Help*"
992 (org-fit-window-to-buffer (get-buffer-window
993 "*Org Export/Publishing Help*"))
994 (while (eq (setq r1
(read-char-exclusive)) ?
1)
997 (message "Export buffer: "))
1000 (message "Export subtree: "))))
1002 (let ((case-fold-search t
)
1003 (end (save-excursion (while (org-up-heading-safe)) (point))))
1004 (outline-next-heading)
1005 (if (re-search-backward
1006 "^[ \t]+\\(:latex_class:\\|:export_title:\\|:export_file_name:\\)[ \t]+\\S-"
1009 (org-back-to-heading t
)
1012 (message "Select command (for subtree): ")
1013 (setq r1
(read-char-exclusive)))
1014 (error "No enclosing node with LaTeX_CLASS or EXPORT_TITLE or EXPORT_FILE_NAME")
1017 (and bpos
(goto-char bpos
))
1018 (setq r2
(if (< r1
27) (+ r1
96) r1
))
1019 (unless (setq ass
(assq r2 cmds
))
1020 (error "No command associated with key %c" r1
))
1021 (if (and bg
(nth 2 ass
)
1022 (not (buffer-base-buffer))
1023 (not (org-region-active-p)))
1024 ;; execute in background
1025 (let ((p (start-process
1026 (concat "Exporting " (file-name-nondirectory (buffer-file-name)))
1028 (expand-file-name invocation-name invocation-directory
)
1031 "--eval" "(require 'org-exp)"
1032 "--eval" "(setq org-wait .2)"
1034 "-f" (symbol-name (nth 1 ass
)))))
1035 (set-process-sentinel p
'org-export-process-sentinel
)
1036 (message "Background process \"%s\": started" p
))
1037 ;; background processing not requested, or not possible
1038 (if subtree-p
(progn (org-mark-subtree) (org-activate-mark)))
1039 (call-interactively (nth 1 ass
))
1040 (when (and bpos
(get-buffer-window cbuf
))
1041 (let ((cw (selected-window)))
1042 (select-window (get-buffer-window cbuf
))
1045 (select-window cw
))))))
1047 (defun org-export-process-sentinel (process status
)
1048 (if (string-match "\n+\\'" status
)
1049 (setq status
(substring status
0 -
1)))
1050 (message "Background process \"%s\": %s" process status
))
1052 ;;; General functions for all backends
1054 (defvar org-export-target-aliases nil
1055 "Alist of targets with invisible aliases.")
1056 (defvar org-export-preferred-target-alist nil
1057 "Alist of section id's with preferred aliases.")
1058 (defvar org-export-id-target-alist nil
1059 "Alist of section id's with preferred aliases.")
1060 (defvar org-export-code-refs nil
1061 "Alist of code references and line numbers.")
1063 (defun org-export-preprocess-string (string &rest parameters
)
1064 "Cleanup STRING so that the true exported has a more consistent source.
1065 This function takes STRING, which should be a buffer-string of an org-file
1066 to export. It then creates a temporary buffer where it does its job.
1067 The result is then again returned as a string, and the exporter works
1068 on this string to produce the exported version."
1070 (let* ((org-export-current-backend (plist-get parameters
:for-backend
))
1071 (archived-trees (plist-get parameters
:archived-trees
))
1072 (inhibit-read-only t
)
1073 (drawers org-drawers
)
1074 (outline-regexp "\\*+ ")
1075 (source-buffer (current-buffer))
1078 (setq org-export-target-aliases nil
1079 org-export-preferred-target-alist nil
1080 org-export-id-target-alist nil
1081 org-export-code-refs nil
)
1083 (with-current-buffer (get-buffer-create " org-mode-tmp")
1086 (setq case-fold-search t
)
1088 (let ((inhibit-read-only t
))
1089 (remove-text-properties (point-min) (point-max)
1092 ;; Remove license-to-kill stuff
1093 ;; The caller marks some stuff for killing, stuff that has been
1094 ;; used to create the page title, for example.
1095 (org-export-kill-licensed-text)
1097 (let ((org-inhibit-startup t
)) (org-mode))
1098 (setq case-fold-search t
)
1099 (org-clone-local-variables source-buffer
"^\\(org-\\|orgtbl-\\)")
1100 (org-install-letbind)
1103 (run-hooks 'org-export-preprocess-hook
)
1105 (untabify (point-min) (point-max))
1107 ;; Handle include files, and call a hook
1108 (org-export-handle-include-files-recurse)
1109 (run-hooks 'org-export-preprocess-after-include-files-hook
)
1111 ;; Change lists ending. Other parts of export may insert blank
1112 ;; lines and lists' structure could be altered.
1113 (org-export-mark-list-end)
1115 ;; Process the macros
1116 (org-export-preprocess-apply-macros)
1117 (run-hooks 'org-export-preprocess-after-macros-hook
)
1119 ;; Get rid of archived trees
1120 (org-export-remove-archived-trees archived-trees
)
1122 ;; Remove comment environment and comment subtrees
1123 (org-export-remove-comment-blocks-and-subtrees)
1125 ;; Get rid of excluded trees, and call a hook
1126 (org-export-handle-export-tags (plist-get parameters
:select-tags
)
1127 (plist-get parameters
:exclude-tags
))
1128 (run-hooks 'org-export-preprocess-after-tree-selection-hook
)
1130 ;; Get rid of tasks, depending on configuration
1131 (org-export-remove-tasks (plist-get parameters
:tasks
))
1133 ;; Export code blocks
1134 (org-export-blocks-preprocess)
1136 ;; Mark lists with properties
1137 (org-export-mark-list-properties)
1139 ;; Handle source code snippets
1140 (org-export-replace-src-segments-and-examples)
1142 ;; Protect short examples marked by a leading colon
1143 (org-export-protect-colon-examples)
1146 (org-export-convert-protected-spaces)
1148 ;; Normalize footnotes
1149 (when (plist-get parameters
:footnotes
)
1150 (org-footnote-normalize nil t
))
1152 ;; Find all headings and compute the targets for them
1153 (setq target-alist
(org-export-define-heading-targets target-alist
))
1155 (run-hooks 'org-export-preprocess-after-headline-targets-hook
)
1157 ;; Find HTML special classes for headlines
1158 (org-export-remember-html-container-classes)
1160 ;; Get rid of drawers
1161 (org-export-remove-or-extract-drawers
1162 drawers
(plist-get parameters
:drawers
))
1164 ;; Get the correct stuff before the first headline
1165 (when (plist-get parameters
:skip-before-1st-heading
)
1166 (goto-char (point-min))
1167 (when (re-search-forward "^\\(#.*\n\\)?\\*+[ \t]" nil t
)
1168 (delete-region (point-min) (match-beginning 0))
1169 (goto-char (point-min))
1171 (when (plist-get parameters
:add-text
)
1172 (goto-char (point-min))
1173 (insert (plist-get parameters
:add-text
) "\n"))
1175 ;; Remove todo-keywords before exporting, if the user has requested so
1176 (org-export-remove-headline-metadata parameters
)
1178 ;; Find targets in comments and move them out of comments,
1179 ;; but mark them as targets that should be invisible
1180 (setq target-alist
(org-export-handle-invisible-targets target-alist
))
1182 ;; Select and protect backend specific stuff, throw away stuff
1183 ;; that is specific for other backends
1184 (run-hooks 'org-export-preprocess-before-selecting-backend-code-hook
)
1185 (org-export-select-backend-specific-text)
1187 ;; Protect quoted subtrees
1188 (org-export-protect-quoted-subtrees)
1190 ;; Remove clock lines
1191 (org-export-remove-clock-lines)
1193 ;; Protect verbatim elements
1194 (org-export-protect-verbatim)
1196 ;; Blockquotes, verse, and center
1197 (org-export-mark-blockquote-verse-center)
1198 (run-hooks 'org-export-preprocess-after-blockquote-hook
)
1200 ;; Remove timestamps, if the user has requested so
1201 (unless (plist-get parameters
:timestamps
)
1202 (org-export-remove-timestamps))
1204 ;; Attach captions to the correct object
1205 (setq target-alist
(org-export-attach-captions-and-attributes target-alist
))
1207 ;; Find matches for radio targets and turn them into internal links
1208 (org-export-mark-radio-links)
1209 (run-hooks 'org-export-preprocess-after-radio-targets-hook
)
1211 ;; Find all links that contain a newline and put them into a single line
1212 (org-export-concatenate-multiline-links)
1214 ;; Normalize links: Convert angle and plain links into bracket links
1215 ;; and expand link abbreviations
1216 (run-hooks 'org-export-preprocess-before-normalizing-links-hook
)
1217 (org-export-normalize-links)
1219 ;; Find all internal links. If they have a fuzzy match (i.e. not
1220 ;; a *dedicated* target match, let the link point to the
1221 ;; corresponding section.
1222 (org-export-target-internal-links target-alist
)
1224 ;; Find multiline emphasis and put them into single line
1225 (when (plist-get parameters
:emph-multiline
)
1226 (org-export-concatenate-multiline-emphasis))
1228 ;; Remove special table lines, and store alignment information
1229 (org-store-forced-table-alignment)
1230 (when org-export-table-remove-special-lines
1231 (org-export-remove-special-table-lines))
1234 (run-hooks 'org-export-preprocess-before-backend-specifics-hook
)
1236 ;; Backend-specific preprocessing
1237 (let* ((backend-name (symbol-name org-export-current-backend
))
1238 (f (intern (format "org-export-%s-preprocess" backend-name
))))
1239 (require (intern (concat "org-" backend-name
)) nil
)
1240 (funcall f parameters
))
1242 ;; Remove or replace comments
1243 (org-export-handle-comments (plist-get parameters
:comments
))
1245 ;; Remove #+TBLFM and #+TBLNAME lines
1246 (org-export-handle-table-metalines)
1248 ;; Run the final hook
1249 (run-hooks 'org-export-preprocess-final-hook
)
1251 (setq rtn
(buffer-string)))
1252 (kill-buffer " org-mode-tmp")
1255 (defun org-export-kill-licensed-text ()
1256 "Remove all text that is marked with a :org-license-to-kill property."
1258 (while (setq p
(text-property-any (point-min) (point-max)
1259 :org-license-to-kill t
))
1261 p
(or (next-single-property-change p
:org-license-to-kill
)
1264 (defvar org-export-define-heading-targets-headline-hook nil
1265 "Hook that is run when a headline was matched during target search.
1266 This is part of the preprocessing for export.")
1268 (defun org-export-define-heading-targets (target-alist)
1269 "Find all headings and define the targets for them.
1270 The new targets are added to TARGET-ALIST, which is also returned.
1271 Also find all ID and CUSTOM_ID properties and store them."
1272 (goto-char (point-min))
1273 (org-init-section-numbers)
1274 (let ((re (concat "^" org-outline-regexp
1276 "^[ \t]*:\\(ID\\|CUSTOM_ID\\):[ \t]*\\([^ \t\r\n]+\\)"))
1277 level target last-section-target a id
)
1278 (while (re-search-forward re nil t
)
1279 (org-if-unprotected-at (match-beginning 0)
1282 (setq id
(org-match-string-no-properties 2))
1283 (push (cons id target
) target-alist
)
1284 (setq a
(or (assoc last-section-target org-export-target-aliases
)
1286 (push (list last-section-target
)
1287 org-export-target-aliases
)
1288 (car org-export-target-aliases
))))
1289 (push (caar target-alist
) (cdr a
))
1290 (when (equal (match-string 1) "CUSTOM_ID")
1291 (if (not (assoc last-section-target
1292 org-export-preferred-target-alist
))
1293 (push (cons last-section-target id
)
1294 org-export-preferred-target-alist
)))
1295 (when (equal (match-string 1) "ID")
1296 (if (not (assoc last-section-target
1297 org-export-id-target-alist
))
1298 (push (cons last-section-target
(concat "ID-" id
))
1299 org-export-id-target-alist
))))
1300 (setq level
(org-reduced-level
1301 (save-excursion (goto-char (point-at-bol))
1302 (org-outline-level))))
1303 (setq target
(org-solidify-link-text
1304 (format "sec-%s" (replace-regexp-in-string
1306 (org-section-number level
)))))
1307 (setq last-section-target target
)
1308 (push (cons target target
) target-alist
)
1309 (add-text-properties
1310 (point-at-bol) (point-at-eol)
1311 (list 'target target
))
1312 (run-hooks 'org-export-define-heading-targets-headline-hook
)))))
1315 (defun org-export-handle-invisible-targets (target-alist)
1316 "Find targets in comments and move them out of comments.
1317 Mark them as invisible targets."
1319 (goto-char (point-min))
1320 (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t
)
1321 ;; Check if the line before or after is a headline with a target
1322 (if (setq target
(or (get-text-property (point-at-bol 0) 'target
)
1323 (get-text-property (point-at-bol 2) 'target
)))
1325 ;; use the existing target in a neighboring line
1326 (setq tmp
(match-string 2))
1328 (and (looking-at "\n") (delete-char 1))
1329 (push (cons (setq tmp
(org-solidify-link-text tmp
)) target
)
1331 (setq a
(or (assoc target org-export-target-aliases
)
1333 (push (list target
) org-export-target-aliases
)
1334 (car org-export-target-aliases
))))
1336 ;; Make an invisible target
1337 (replace-match "\\1(INVISIBLE)"))))
1340 (defun org-export-target-internal-links (target-alist)
1341 "Find all internal links and assign targets to them.
1342 If a link has a fuzzy match (i.e. not a *dedicated* target match),
1343 let the link point to the corresponding section.
1344 This function also handles the id links, if they have a match in
1346 (goto-char (point-min))
1347 (while (re-search-forward org-bracket-link-regexp nil t
)
1348 (org-if-unprotected-at (1+ (match-beginning 0))
1349 (let* ((org-link-search-must-match-exact-headline t
)
1351 (desc (match-end 2))
1352 (link (org-link-unescape (match-string 1)))
1353 (slink (org-solidify-link-text link
))
1354 found props pos cref
1357 ((= (string-to-char link
) ?
#)
1358 ;; user wants exactly this link
1360 ((cdr (assoc slink target-alist
))
1361 (or (cdr (assoc (assoc slink target-alist
)
1362 org-export-preferred-target-alist
))
1363 (cdr (assoc slink target-alist
))))
1364 ((and (string-match "^id:" link
)
1365 (cdr (assoc (substring link
3) target-alist
))))
1366 ((string-match "^(\\(.*\\))$" link
)
1367 (setq cref
(match-string 1 link
))
1368 (concat "coderef:" cref
))
1369 ((string-match org-link-types-re link
) nil
)
1370 ((or (file-name-absolute-p link
)
1371 (string-match "^\\." link
))
1374 (let ((org-link-search-inhibit-query t
))
1376 (setq found
(condition-case nil
(org-link-search link
)
1379 (or (org-on-heading-p)
1380 (not (eq found
'dedicated
))))
1381 (or (get-text-property (point) 'target
)
1384 (1- (or (previous-single-property-change
1385 (point) 'target
) 0)))
1389 (goto-char (match-beginning 1))
1390 (setq props
(text-properties-at (point)))
1391 (delete-region (match-beginning 1) (match-end 1))
1394 (unless desc
(insert "][" link
))
1395 (add-text-properties pos
(point) props
))))))
1397 (defun org-export-remember-html-container-classes ()
1398 "Store the HTML_CONTAINER_CLASS properties in a text property."
1399 (goto-char (point-min))
1401 (while (re-search-forward
1402 "^[ \t]*:HTML_CONTAINER_CLASS:[ \t]+\\(.+\\)$" nil t
)
1403 (setq class
(match-string 1))
1405 (org-back-to-heading t
)
1406 (put-text-property (point-at-bol) (point-at-eol) 'html-container-class class
)))))
1408 (defvar org-export-format-drawer-function nil
1409 "Function to be called to format the contents of a drawer.
1410 The function must accept three parameters:
1411 NAME the drawer name, like \"PROPERTIES\"
1412 CONTENT the content of the drawer.
1413 You can check the export backend through `org-export-current-backend'.
1414 The function should return the text to be inserted into the buffer.
1415 If this is nil, `org-export-format-drawer' is used as a default.")
1417 (defun org-export-remove-or-extract-drawers (all-drawers exp-drawers
)
1418 "Remove drawers, or extract and format the content.
1419 ALL-DRAWERS is a list of all drawer names valid in the current buffer.
1420 EXP-DRAWERS can be t to keep all drawer contents, or a list of drawers
1421 whose content to keep. Any drawers that are in ALL-DRAWERS but not in
1422 EXP-DRAWERS will be removed."
1423 (goto-char (point-min))
1424 (let ((re (concat "^[ \t]*:\\("
1425 (mapconcat 'identity all-drawers
"\\|")
1427 name beg beg-content eol content
)
1428 (while (re-search-forward re nil t
)
1430 (setq name
(match-string 1))
1431 (setq beg
(match-beginning 0)
1432 beg-content
(1+ (point-at-eol))
1434 (if (not (and (re-search-forward
1435 "^\\([ \t]*:END:[ \t]*\n?\\)\\|^\\*+[ \t]" nil t
)
1438 (goto-char (match-beginning 0))
1439 (and (looking-at ".*\n?") (replace-match ""))
1440 (setq content
(buffer-substring beg-content
(point)))
1441 (delete-region beg
(point))
1442 (when (or (eq exp-drawers t
)
1443 (member name exp-drawers
))
1444 (setq content
(funcall (or org-export-format-drawer-function
1445 'org-export-format-drawer
)
1447 (insert content
)))))))
1449 (defun org-export-format-drawer (name content
)
1450 "Format the content of a drawer as a colon example."
1451 (if (string-match "[ \t]+\\'" content
)
1452 (setq content
(substring content
(match-beginning 0))))
1453 (while (string-match "\\`[ \t]*\n" content
)
1454 (setq content
(substring content
(match-end 0))))
1455 (setq content
(org-remove-indentation content
))
1456 (setq content
(concat ": " (mapconcat 'identity
1457 (org-split-string content
"\n")
1460 (setq content
(concat " : " (upcase name
) "\n" content
))
1461 (org-add-props content nil
'org-protected t
))
1463 (defun org-export-handle-export-tags (select-tags exclude-tags
)
1464 "Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS.
1465 Both arguments are lists of tags.
1466 If any of SELECT-TAGS is found, all trees not marked by a SELECT-TAG
1468 After that, all subtrees that are marked by EXCLUDE-TAGS will be
1470 (remove-text-properties (point-min) (point-max) '(:org-delete t
))
1471 (let* ((re-sel (concat ":\\(" (mapconcat 'regexp-quote
1474 (re-excl (concat ":\\(" (mapconcat 'regexp-quote
1478 (goto-char (point-min))
1479 (when (and select-tags
1481 (concat "^\\*+[ \t].*" re-sel
"[^ \t\n]*[ \t]*$") nil t
))
1482 ;; At least one tree is marked for export, this means
1483 ;; all the unmarked stuff needs to go.
1484 ;; Dig out the trees that should be exported
1485 (goto-char (point-min))
1486 (outline-next-heading)
1488 (put-text-property beg
(point-max) :org-delete t
)
1489 (while (re-search-forward re-sel nil t
)
1490 (when (org-on-heading-p)
1491 (org-back-to-heading)
1492 (remove-text-properties
1493 (max (1- (point)) (point-min))
1494 (setq cont
(save-excursion (org-end-of-subtree t t
)))
1496 (while (and (org-up-heading-safe)
1497 (get-text-property (point) :org-delete
))
1498 (remove-text-properties (max (1- (point)) (point-min))
1499 (point-at-eol) '(:org-delete t
)))
1501 ;; Remove the trees explicitly marked for noexport
1503 (goto-char (point-min))
1504 (while (re-search-forward re-excl nil t
)
1505 (when (org-at-heading-p)
1506 (org-back-to-heading t
)
1508 (org-end-of-subtree t t
)
1509 (delete-region beg
(point))
1510 (when (featurep 'org-inlinetask
)
1511 (org-inlinetask-remove-END-maybe)))))
1512 ;; Remove everything that is now still marked for deletion
1513 (goto-char (point-min))
1514 (while (setq beg
(text-property-any (point-min) (point-max) :org-delete t
))
1515 (setq end
(or (next-single-property-change beg
:org-delete
)
1517 (delete-region beg end
))))
1519 (defun org-export-remove-tasks (keep)
1520 "Remove tasks depending on configuration.
1521 When KEEP is nil, remove all tasks.
1522 When KEEP is `todo', remove the tasks that are DONE.
1523 When KEEP is `done', remove the tasks that are not yet done.
1524 When it is a list of strings, keep only tasks with these TODO keywords."
1525 (when (or (listp keep
) (memq keep
'(todo done nil
)))
1526 (let ((re (concat "^\\*+[ \t]+\\("
1529 (cond ((not keep
) org-todo-keywords-1
)
1530 ((eq keep
'todo
) org-done-keywords
)
1531 ((eq keep
'done
) org-not-done-keywords
)
1533 (org-delete-all keep
(copy-sequence
1534 org-todo-keywords-1
))))
1536 "\\)\\($\\|[ \t]\\)"))
1537 (case-fold-search nil
)
1539 (goto-char (point-min))
1540 (while (re-search-forward re nil t
)
1542 (setq beg
(match-beginning 0))
1543 (org-end-of-subtree t t
)
1544 (if (looking-at "^\\*+[ \t]+END[ \t]*$")
1545 ;; Kill the END line of the inline task
1546 (goto-char (min (point-max) (1+ (match-end 0)))))
1547 (delete-region beg
(point)))))))
1549 (defun org-export-remove-archived-trees (export-archived-trees)
1550 "Remove archived trees.
1551 When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported.
1552 When it is t, the entire archived tree will be exported.
1553 When it is nil the entire tree including the headline will be removed
1555 (let ((re-archive (concat ":" org-archive-tag
":"))
1557 (when (not (eq export-archived-trees t
))
1558 (goto-char (point-min))
1559 (while (re-search-forward re-archive nil t
)
1560 (if (not (org-on-heading-p t
))
1561 (goto-char (point-at-eol))
1562 (beginning-of-line 1)
1563 (setq a
(if export-archived-trees
1564 (1+ (point-at-eol)) (point))
1565 b
(org-end-of-subtree t
))
1566 (if (> b a
) (delete-region a b
)))))))
1568 (defun org-export-remove-headline-metadata (opts)
1569 "Remove meta data from the headline, according to user options."
1570 (let ((re org-complex-heading-regexp
)
1571 (todo (plist-get opts
:todo-keywords
))
1572 (tags (plist-get opts
:tags
))
1573 (pri (plist-get opts
:priority
))
1575 (case-fold-search nil
)
1577 (setq elts
(delq nil
(list 1 (if todo
2) (if pri
3) 4 (if tags
5))))
1578 (when (or (not todo
) (not tags
) (not pri
))
1579 (goto-char (point-min))
1580 (while (re-search-forward re nil t
)
1582 (setq rpl
(mapconcat (lambda (i) (if (match-end i
) (match-string i
) ""))
1584 (replace-match rpl t t
))))))
1586 (defun org-export-remove-timestamps ()
1587 "Remove timestamps and keywords for export."
1588 (goto-char (point-min))
1589 (while (re-search-forward org-maybe-keyword-time-regexp nil t
)
1592 (unless (save-match-data (org-at-table-p))
1594 (beginning-of-line 1)
1595 (if (looking-at "[- \t]*\\(=>[- \t0-9:]*\\)?[ \t]*\n")
1596 (replace-match ""))))))
1598 (defun org-export-remove-clock-lines ()
1599 "Remove clock lines for export."
1600 (goto-char (point-min))
1601 (let ((re (concat "^[ \t]*" org-clock-string
".*\n?")))
1602 (while (re-search-forward re nil t
)
1604 (replace-match "")))))
1606 (defun org-export-protect-quoted-subtrees ()
1607 "Mark quoted subtrees with the protection property."
1608 (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string
"\\>")))
1609 (goto-char (point-min))
1610 (while (re-search-forward re-quote nil t
)
1611 (goto-char (match-beginning 0))
1613 (add-text-properties (point) (org-end-of-subtree t
)
1614 '(org-protected t
)))))
1616 (defun org-export-convert-protected-spaces ()
1617 "Convert strings like \\____ to protected spaces in all backends."
1618 (goto-char (point-min))
1619 (while (re-search-forward "\\\\__+" nil t
)
1620 (org-if-unprotected-1
1624 ((eq org-export-current-backend
'latex
)
1625 (format "\\hspace{%dex}" (- (match-end 0) (match-beginning 0))))
1626 ((eq org-export-current-backend
'html
)
1627 (org-add-props (match-string 0) nil
1628 'org-whitespace
(- (match-end 0) (match-beginning 0))))
1629 ;; ((eq org-export-current-backend 'docbook))
1630 ((eq org-export-current-backend
'ascii
)
1631 (org-add-props (match-string 0) '(org-whitespace t
)))
1632 (t (make-string (- (match-end 0) (match-beginning 0)) ?\
)))
1636 (defun org-export-protect-verbatim ()
1637 "Mark verbatim snippets with the protection property."
1638 (goto-char (point-min))
1639 (while (re-search-forward org-verbatim-re nil t
)
1641 (add-text-properties (match-beginning 4) (match-end 4)
1642 '(org-protected t org-verbatim-emph t
))
1643 (goto-char (1+ (match-end 4))))))
1645 (defun org-export-protect-colon-examples ()
1646 "Protect lines starting with a colon."
1647 (goto-char (point-min))
1648 (let ((re "^[ \t]*:\\([ \t]\\|$\\)") beg
)
1649 (while (re-search-forward re nil t
)
1650 (beginning-of-line 1)
1652 (while (looking-at re
)
1654 (or (eobp) (forward-char 1)))
1655 (add-text-properties beg
(if (bolp) (1- (point)) (point))
1656 '(org-protected t
)))))
1658 (defun org-export-select-backend-specific-text ()
1660 '((docbook "DOCBOOK" "BEGIN_DOCBOOK" "END_DOCBOOK")
1661 (html "HTML" "BEGIN_HTML" "END_HTML")
1662 (beamer "BEAMER" "BEGIN_BEAMER" "END_BEAMER")
1663 (ascii "ASCII" "BEGIN_ASCII" "END_ASCII")
1664 (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX")
1665 (odt "ODT" "BEGIN_ODT" "END_ODT")))
1666 (case-fold-search t
)
1667 fmt beg beg-content end end-content ind
)
1670 (setq fmt
(pop formatters
))
1671 ;; Handle #+backend: stuff
1672 (goto-char (point-min))
1673 (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" (cadr fmt
)
1674 ":[ \t]*\\(.*\\)") nil t
)
1675 (if (not (eq (car fmt
) org-export-current-backend
))
1676 (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
1677 (replace-match "\\1\\2" t
)
1678 (add-text-properties
1679 (point-at-bol) (min (1+ (point-at-eol)) (point-max))
1680 `(org-protected t original-indentation
,ind org-native-text t
))))
1681 ;; Delete #+attr_Backend: stuff of another backend. Those
1682 ;; matching the current backend will be taken care of by
1683 ;; `org-export-attach-captions-and-attributes'
1684 (goto-char (point-min))
1685 (while (re-search-forward (concat "^\\([ \t]*\\)#\\+attr_" (cadr fmt
)
1686 ":[ \t]*\\(.*\\)") nil t
)
1687 (setq ind
(org-get-indentation))
1688 (when (not (eq (car fmt
) org-export-current-backend
))
1689 (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
1690 ;; Handle #+begin_backend and #+end_backend stuff
1691 (goto-char (point-min))
1692 (while (re-search-forward (concat "^[ \t]*#\\+" (caddr fmt
) "\\>.*\n?")
1694 (setq beg
(match-beginning 0) beg-content
(match-end 0))
1695 (setq ind
(save-excursion (goto-char beg
) (org-get-indentation)))
1696 (when (re-search-forward (concat "^[ \t]*#\\+" (cadddr fmt
) "\\>.*\n?")
1698 (setq end
(match-end 0) end-content
(match-beginning 0))
1699 (if (eq (car fmt
) org-export-current-backend
)
1702 (add-text-properties
1703 beg-content end-content
1704 `(org-protected t original-indentation
,ind org-native-text t
))
1705 (delete-region (match-beginning 0) (match-end 0))
1708 (delete-region (point) (1+ (point-at-eol)))))
1709 ;; No, this is for a different backend, kill it
1710 (delete-region beg end
)))))))
1712 (defun org-export-mark-blockquote-verse-center ()
1713 "Mark block quote and verse environments with special cookies.
1714 These special cookies will later be interpreted by the backend."
1716 (let (type t1 ind beg end beg1 end1 content
)
1717 (goto-char (point-min))
1718 (while (re-search-forward
1719 "^\\([ \t]*\\)#\\+\\(begin_\\(\\(block\\)?quote\\|verse\\|center\\)\\>.*\\)"
1721 (setq ind
(length (match-string 1))
1722 type
(downcase (match-string 3))
1723 t1
(if (equal type
"quote") "blockquote" type
))
1724 (setq beg
(match-beginning 0)
1725 beg1
(1+ (match-end 0)))
1726 (when (re-search-forward (concat "^[ \t]*#\\+end_" type
"\\>.*") nil t
)
1727 (setq end1
(1- (match-beginning 0))
1728 end
(+ (point-at-eol) (if (looking-at "\n$") 1 0)))
1729 (setq content
(org-remove-indentation (buffer-substring beg1 end1
)))
1730 (setq content
(concat "ORG-" (upcase t1
) "-START\n"
1732 "ORG-" (upcase t1
) "-END\n"))
1733 (delete-region beg end
)
1734 (insert (org-add-props content nil
'original-indentation ind
))))))
1736 (defun org-export-mark-list-end ()
1737 "Mark all list endings with a special string."
1738 (unless (eq org-export-current-backend
'ascii
)
1741 ;; For each type allowing list export, find every list, remove
1742 ;; ending regexp if needed, and insert org-list-end.
1743 (goto-char (point-min))
1744 (while (re-search-forward (org-item-beginning-re) nil t
)
1745 (when (eq (nth 2 (org-list-context)) e
)
1746 (let* ((struct (org-list-struct))
1747 (bottom (org-list-get-bottom-point struct
))
1748 (top (point-at-bol))
1749 (top-ind (org-list-get-ind top struct
)))
1751 (when (and (not (eq org-list-ending-method
'indent
))
1752 (looking-at org-list-end-re
))
1754 (unless (bolp) (insert "\n"))
1755 ;; As org-list-end is inserted at column 0, it would end
1756 ;; by indentation any list. It can be problematic when
1757 ;; there are lists within lists: the inner list end would
1758 ;; also become the outer list end. To avoid this, text
1759 ;; property `original-indentation' is added, as
1760 ;; `org-list-struct' pays attention to it when reading a
1762 (insert (org-add-props
1763 "ORG-LIST-END-MARKER\n"
1764 (list 'original-indentation top-ind
)))))))
1765 (cons nil org-list-export-context
))))
1767 (defun org-export-mark-list-properties ()
1768 "Mark list with special properties.
1769 These special properties will later be interpreted by the backend."
1772 ;; Mark a list with 3 properties: `list-item' which is
1773 ;; position at beginning of line, `list-struct' which is
1774 ;; list structure, and `list-prevs' which is the alist of
1775 ;; item and its predecessor. Leave point at list ending.
1777 (let* ((struct (org-list-struct))
1778 (top (org-list-get-top-point struct
))
1779 (bottom (org-list-get-bottom-point struct
))
1780 (prevs (org-list-prevs-alist struct
))
1782 ;; Get every item and ending position, without dups and
1783 ;; without bottom point of list.
1787 (unless (memq pos poi
)
1789 (unless (or (= end bottom
) (memq end poi
))
1792 (setq poi
(sort poi
'<))
1793 ;; For every point of interest, mark the whole line with
1794 ;; its position in list.
1798 (add-text-properties (point-at-bol) (point-at-eol)
1799 (list 'list-item
(point-at-bol)
1801 'list-prevs prevs
)))
1803 ;; Take care of bottom point. As babel may have inserted
1804 ;; a new list in buffer, list ending isn't always
1805 ;; marked. Now mark every list ending and add properties
1806 ;; useful to line processing exporters.
1808 (when (or (looking-at "^ORG-LIST-END-MARKER\n")
1809 (and (not (eq org-list-ending-method
'indent
))
1810 (looking-at org-list-end-re
)))
1812 (unless (bolp) (insert "\n"))
1814 (org-add-props "ORG-LIST-END-MARKER\n" (list 'list-item bottom
1816 'list-prevs prevs
)))
1817 ;; Following property is used by LaTeX exporter.
1818 (add-text-properties top
(point) (list 'list-context ctxt
)))))))
1819 ;; Mark lists except for backends not interpreting them.
1820 (unless (eq org-export-current-backend
'ascii
)
1821 (let ((org-list-end-re "^ORG-LIST-END-MARKER\n"))
1824 (goto-char (point-min))
1825 (while (re-search-forward (org-item-beginning-re) nil t
)
1826 (let ((context (nth 2 (org-list-context))))
1828 (funcall mark-list e
)
1829 (put-text-property (point-at-bol) (point-at-eol)
1830 'list-context context
)))))
1831 (cons nil org-list-export-context
))))))
1833 (defun org-export-attach-captions-and-attributes (target-alist)
1834 "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties.
1835 If the next thing following is a table, add the text properties to the first
1836 table line. If it is a link, add it to the line containing the link."
1837 (goto-char (point-min))
1838 (remove-text-properties (point-min) (point-max)
1839 '(org-caption nil org-attributes nil
))
1840 (let ((case-fold-search t
)
1841 (re (concat "^[ \t]*#\\+caption:[ \t]+\\(.*\\)"
1843 "^[ \t]*#\\+attr_" (symbol-name org-export-current-backend
) ":[ \t]+\\(.*\\)"
1845 "^[ \t]*#\\+label:[ \t]+\\(.*\\)"
1847 "^[ \t]*\\(|[^-]\\)"
1849 "^[ \t]*\\[\\[.*\\]\\][ \t]*$"))
1850 cap shortn attr label end
)
1851 (while (re-search-forward re nil t
)
1853 ;; there is a caption
1856 (setq cap
(concat cap
(if cap
" " "") (org-trim (match-string 1))))
1857 (when (string-match "\\[\\(.*\\)\\]{\\(.*\\)}" cap
)
1858 (setq shortn
(match-string 1 cap
)
1859 cap
(match-string 2 cap
)))
1860 (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
1861 ;; there is an attribute
1864 (setq attr
(concat attr
(if attr
" " "") (org-trim (match-string 2))))
1865 (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
1869 (setq label
(org-trim (match-string 3)))
1870 (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
1872 (setq end
(if (match-end 4)
1873 (let ((ee (org-table-end)))
1874 (prog1 (1- (marker-position ee
)) (move-marker ee nil
)))
1876 (add-text-properties (point-at-bol) end
1877 (list 'org-caption cap
1878 'org-caption-shortn shortn
1879 'org-attributes attr
1881 (if label
(push (cons label label
) target-alist
))
1883 (setq cap nil shortn nil attr nil label nil
)))))
1886 (defun org-export-remove-comment-blocks-and-subtrees ()
1887 "Remove the comment environment, and also commented subtrees."
1888 (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string
"\\>"))
1890 ;; Remove comment environment
1891 (goto-char (point-min))
1892 (setq case-fold-search t
)
1893 (while (re-search-forward
1894 "^#\\+begin_comment[ \t]*\n[^\000]*?\n#\\+end_comment\\>.*" nil t
)
1895 (replace-match "" t t
))
1896 ;; Remove subtrees that are commented
1897 (goto-char (point-min))
1898 (setq case-fold-search nil
)
1899 (while (re-search-forward re-commented nil t
)
1900 (goto-char (match-beginning 0))
1901 (delete-region (point) (org-end-of-subtree t
)))))
1903 (defun org-export-handle-comments (commentsp)
1904 "Remove comments, or convert to backend-specific format.
1905 COMMENTSP can be a format string for publishing comments.
1906 When it is nil, all comments will be removed."
1907 (let ((re "^\\(#\\|[ \t]*#\\+ \\)\\(.*\n?\\)")
1909 (goto-char (point-min))
1910 (while (or (looking-at re
)
1911 (re-search-forward re nil t
))
1912 (setq pos
(match-beginning 0))
1913 (if (get-text-property pos
'org-protected
)
1914 (goto-char (1+ pos
))
1916 (not (equal (char-before (match-end 1)) ?
+)))
1917 (progn (add-text-properties
1918 (match-beginning 0) (match-end 0) '(org-protected t
))
1919 (replace-match (org-add-props
1920 (format commentsp
(match-string 2))
1921 nil
'org-protected t
)
1923 (goto-char (1+ pos
))
1925 (goto-char (max (point-min) (1- pos
))))))))
1927 (defun org-export-handle-table-metalines ()
1928 "Remove table specific metalines #+TBLNAME: and #+TBLFM:."
1929 (let ((re "^[ \t]*#\\+TBL\\(NAME\\|FM\\):\\(.*\n?\\)")
1931 (goto-char (point-min))
1932 (while (or (looking-at re
)
1933 (re-search-forward re nil t
))
1934 (setq pos
(match-beginning 0))
1935 (if (get-text-property (match-beginning 1) 'org-protected
)
1936 (goto-char (1+ pos
))
1937 (goto-char (1+ pos
))
1939 (goto-char (max (point-min) (1- pos
)))))))
1941 (defun org-export-mark-radio-links ()
1942 "Find all matches for radio targets and turn them into internal links."
1943 (let ((re-radio (and org-target-link-regexp
1944 (concat "\\([^<]\\)\\(" org-target-link-regexp
"\\)"))))
1945 (goto-char (point-min))
1947 (while (re-search-forward re-radio nil t
)
1950 (or (org-in-regexp org-bracket-link-regexp
)
1951 (org-in-regexp org-plain-link-re
)
1952 (org-in-regexp "<<[^<>]+>>")))
1954 (replace-match "\\1[[\\2]]")))))))
1956 (defun org-store-forced-table-alignment ()
1957 "Find table lines which force alignment, store the results in properties."
1958 (let (line cnt aligns
)
1959 (goto-char (point-min))
1960 (while (re-search-forward "|[ \t]*<[lrc][0-9]*>[ \t]*|" nil t
)
1961 ;; OK, this looks like a table line with an alignment cookie
1963 (setq line
(buffer-substring (point-at-bol) (point-at-eol)))
1964 (when (and (org-at-table-p)
1965 (org-table-cookie-line-p line
))
1966 (setq cnt
0 aligns nil
)
1970 (if (string-match "\\`<\\([lrc]\\)" x
)
1971 (push (cons cnt
(downcase (match-string 1 x
))) aligns
)))
1972 (org-split-string line
"[ \t]*|[ \t]*"))
1973 (add-text-properties (org-table-begin) (org-table-end)
1974 (list 'org-forced-aligns aligns
))))
1975 (goto-char (point-at-eol)))))
1977 (defun org-export-remove-special-table-lines ()
1978 "Remove tables lines that are used for internal purposes.
1979 Also, store forced alignment information found in such lines."
1980 (goto-char (point-min))
1981 (while (re-search-forward "^[ \t]*|" nil t
)
1982 (org-if-unprotected-at (1- (point))
1983 (beginning-of-line 1)
1984 (if (or (looking-at "[ \t]*| *[!_^] *|")
1990 (or (and org-export-table-remove-empty-lines
(= (length f
) 0))
1992 "\\`<\\([0-9]\\|[lrc]\\|[lrc][0-9]+\\)>\\'" f
)))
1993 (org-split-string ;; FIXME, can't we do without splitting???
1994 (buffer-substring (point-at-bol) (point-at-eol))
1995 "[ \t]*|[ \t]*")))))
1996 (delete-region (max (point-min) (1- (point-at-bol)))
2000 (defun org-export-protect-sub-super (s)
2002 (while (string-match "\\([^\\\\]\\)\\([_^]\\)" s
)
2003 (setq s
(replace-match "\\1\\\\\\2" nil nil s
)))
2006 (defun org-export-normalize-links ()
2007 "Convert all links to bracket links, and expand link abbreviations."
2008 (let ((re-plain-link (concat "\\([^[<]\\)" org-plain-link-re
))
2009 (re-angle-link (concat "\\([^[]\\)" org-angle-link-re
))
2011 (goto-char (point-min))
2012 (while (re-search-forward re-plain-link nil t
)
2013 (unless (org-string-match-p
2014 "\\[\\[\\S-+:\\S-*?\\<"
2015 (buffer-substring (point-at-bol) (match-beginning 0)))
2016 (goto-char (1- (match-end 0)))
2017 (org-if-unprotected-at (1+ (match-beginning 0))
2018 (let* ((s (concat (match-string 1)
2019 "[[" (match-string 2) ":" (match-string 3)
2020 "][" (match-string 2) ":" (org-export-protect-sub-super
2023 ;; added 'org-link face to links
2024 (put-text-property 0 (length s
) 'face
'org-link s
)
2025 (replace-match s t t
)))))
2026 (goto-char (point-min))
2027 (while (re-search-forward re-angle-link nil t
)
2028 (goto-char (1- (match-end 0)))
2030 (let* ((s (concat (match-string 1)
2031 "[[" (match-string 2) ":" (match-string 3)
2032 "][" (match-string 2) ":" (org-export-protect-sub-super
2035 (put-text-property 0 (length s
) 'face
'org-link s
)
2036 (replace-match s t t
))))
2037 (goto-char (point-min))
2038 (while (re-search-forward org-bracket-link-regexp nil t
)
2039 (goto-char (1- (match-end 0)))
2040 (setq nodesc
(not (match-end 3)))
2042 (let* ((xx (save-match-data
2044 (org-link-expand-abbrev (match-string 1)))))
2046 "[[" (org-add-props (copy-sequence xx
)
2047 nil
'org-protected t
'org-no-description nodesc
)
2051 (concat "[" (copy-sequence xx
)
2054 (put-text-property 0 (length s
) 'face
'org-link s
)
2055 (replace-match s t t
))))))
2057 (defun org-export-concatenate-multiline-links ()
2058 "Find multi-line links and put it all into a single line.
2059 This is to make sure that the line-processing export backends
2060 can work correctly."
2061 (goto-char (point-min))
2062 (while (re-search-forward "\\(\\(\\[\\|\\]\\)\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\(\\[\\|\\]\\)\\)" nil t
)
2063 (org-if-unprotected-at (match-beginning 1)
2064 (replace-match "\\1 \\3")
2065 (goto-char (match-beginning 0)))))
2067 (defun org-export-concatenate-multiline-emphasis ()
2068 "Find multi-line emphasis and put it all into a single line.
2069 This is to make sure that the line-processing export backends
2070 can work correctly."
2071 (goto-char (point-min))
2072 (while (re-search-forward org-emph-re nil t
)
2073 (if (and (not (= (char-after (match-beginning 3))
2074 (char-after (match-beginning 4))))
2075 (save-excursion (goto-char (match-beginning 0))
2077 (and (not (org-at-table-p))
2078 (not (org-at-heading-p))))))
2080 (subst-char-in-region (match-beginning 0) (match-end 0)
2082 (goto-char (1- (match-end 0))))
2083 (goto-char (1+ (match-beginning 0))))))
2085 (defun org-export-grab-title-from-buffer ()
2086 "Get a title for the current document, from looking at the buffer."
2087 (let ((inhibit-read-only t
))
2089 (goto-char (point-min))
2090 (let ((end (if (looking-at org-outline-regexp
)
2092 (save-excursion (outline-next-heading) (point)))))
2093 (when (re-search-forward "^[ \t]*[^|# \t\r\n].*\n" end t
)
2094 ;; Mark the line so that it will not be exported as normal text.
2096 (add-text-properties (match-beginning 0) (match-end 0)
2097 (list :org-license-to-kill t
)))
2098 ;; Return the title string
2099 (org-trim (match-string 0)))))))
2101 (defun org-export-get-title-from-subtree ()
2102 "Return subtree title and exclude it from export."
2103 (let ((rbeg (region-beginning)) (rend (region-end))
2104 (inhibit-read-only t
) title
)
2107 (when (and (org-at-heading-p)
2108 (>= (org-end-of-subtree t t
) rend
))
2109 ;; This is a subtree, we take the title from the first heading
2111 (looking-at org-todo-line-regexp
)
2112 (setq title
(match-string 3))
2114 (add-text-properties (point) (1+ (point-at-eol))
2115 (list :org-license-to-kill t
)))
2116 (setq title
(or (org-entry-get nil
"EXPORT_TITLE") title
))))
2119 (defun org-solidify-link-text (s &optional alist
)
2120 "Take link text and make a safe target out of it."
2125 (org-split-string s
"[^a-zA-Z0-9_\\.-]+") "-"))
2126 (a (assoc rtn alist
)))
2129 (defun org-get-min-level (lines &optional offset
)
2130 "Get the minimum level in LINES."
2131 (let ((re "^\\(\\*+\\) ") l
)
2133 (while (setq l
(pop lines
))
2134 (if (string-match re l
)
2135 (throw 'exit
(org-tr-level (- (length (match-string 1 l
))
2139 ;; Variable holding the vector with section numbers
2140 (defvar org-section-numbers
(make-vector org-level-max
0))
2142 (defun org-init-section-numbers ()
2143 "Initialize the vector for the section numbers."
2145 (numbers (nreverse (org-split-string "" "\\.")))
2146 (depth (1- (length org-section-numbers
)))
2147 (i depth
) number-string
)
2150 (aset org-section-numbers i
0)
2151 (setq number-string
(or (car numbers
) "0"))
2152 (if (string-match "\\`[A-Z]\\'" number-string
)
2153 (aset org-section-numbers i
2154 (- (string-to-char number-string
) ?A -
1))
2155 (aset org-section-numbers i
(string-to-number number-string
)))
2159 (defun org-section-number (&optional level
)
2160 "Return a string with the current section number.
2161 When LEVEL is non-nil, increase section numbers on that level."
2162 (let* ((depth (1- (length org-section-numbers
)))
2164 (fmts (car org-export-section-number-format
))
2165 (term (cdr org-export-section-number-format
))
2170 (aset org-section-numbers
2171 level
(1+ (aref org-section-numbers level
))))
2172 (setq idx
(1+ level
))
2173 (while (<= idx depth
)
2175 (aset org-section-numbers idx
0))
2176 (setq idx
(1+ idx
))))
2178 (while (<= idx depth
)
2179 (when (> (aref org-section-numbers idx
) 0)
2180 (setq fmt
(or (pop fmts
) fmt
)
2182 n
(aref org-section-numbers idx
)
2184 (concat string sep
(org-number-to-counter n ctype
))
2185 (concat string
".0"))
2187 (setq idx
(1+ idx
)))
2189 (if (string-match "\\`\\([@0]\\.\\)+" string
)
2190 (setq string
(replace-match "" t nil string
)))
2191 (if (string-match "\\(\\.0\\)+\\'" string
)
2192 (setq string
(replace-match "" t nil string
))))
2193 (concat string term
)))
2195 (defun org-number-to-counter (n type
)
2196 "Concert number N to a string counter, according to TYPE.
2197 TYPE must be a string, any of:
2201 I upper case roman numeral
2202 i lower case roman numeral"
2204 ((equal type
"1") (number-to-string n
))
2205 ((equal type
"A") (char-to-string (+ ?A n -
1)))
2206 ((equal type
"a") (char-to-string (+ ?a n -
1)))
2207 ((equal type
"I") (org-number-to-roman n
))
2208 ((equal type
"i") (downcase (org-number-to-roman n
)))
2209 (t (error "Invalid counter type `%s'" type
))))
2211 (defun org-number-to-roman (n)
2212 "Convert integer N into a roman numeral."
2213 (let ((roman '((1000 .
"M") (900 .
"CM") (500 .
"D") (400 .
"CD")
2214 ( 100 .
"C") ( 90 .
"XC") ( 50 .
"L") ( 40 .
"XL")
2215 ( 10 .
"X") ( 9 .
"IX") ( 5 .
"V") ( 4 .
"IV")
2219 (number-to-string n
)
2221 (if (>= n
(caar roman
))
2222 (setq n
(- n
(caar roman
))
2223 res
(concat res
(cdar roman
)))
2229 (defun org-export-preprocess-apply-macros ()
2230 "Replace macro references."
2231 (goto-char (point-min))
2232 (let (sy val key args args2 ind-str s n
)
2233 (while (re-search-forward
2234 "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\(([ \t\n]*\\([^\000]*?\\))\\)?}}}"
2236 (unless (save-match-data (save-excursion
2237 (goto-char (point-at-bol))
2238 (looking-at "[ \t]*#\\+macro")))
2239 ;; Get macro name (KEY), arguments (ARGS), and indentation of
2240 ;; current line (IND-STR) as strings.
2241 (setq key
(downcase (match-string 1))
2242 args
(match-string 3)
2243 ind-str
(save-match-data (save-excursion
2245 (looking-at "^\\([ \t]*\\).*")
2247 ;; When macro is defined, retrieve replacement text in VAL,
2248 ;; and proceed with expansion.
2249 (when (setq val
(or (plist-get org-export-opt-plist
2250 (intern (concat ":macro-" key
)))
2251 (plist-get org-export-opt-plist
2252 (intern (concat ":" key
)))))
2254 ;; If arguments are provided, first retreive them properly
2255 ;; (in ARGS, as a list), then replace them in VAL.
2257 (setq args
(org-split-string args
",") args2 nil
)
2259 (while (string-match "\\\\\\'" (car args
))
2260 ;; Repair bad splits.
2261 (setcar (cdr args
) (concat (substring (car args
) 0 -
1)
2264 (push (pop args
) args2
))
2265 (setq args
(mapcar 'org-trim
(nreverse args2
)))
2267 (while (string-match "\\$\\([0-9]+\\)" val s
)
2268 (setq s
(1+ (match-beginning 0))
2269 n
(string-to-number (match-string 1 val
)))
2270 (and (>= (length args
) n
)
2271 (setq val
(replace-match (nth (1- n
) args
) t t val
)))))
2272 ;; VAL starts with "(eval": it is a sexp, `eval' it.
2273 (when (string-match "\\`(eval\\>" val
)
2274 (setq val
(eval (read val
))))
2275 ;; Ensure VAL is a string (or nil) and that each new line
2276 ;; is indented as the first one.
2278 (mapconcat 'identity
2280 (if (stringp val
) val
(format "%s" val
))
2282 (concat "\n" ind-str
)))))
2283 ;; Eventually do the replacement, if VAL isn't nil. Move
2284 ;; point at beginning of macro for recursive expansions.
2286 (replace-match val t t
)
2287 (goto-char (match-beginning 0))))))))
2289 (defun org-export-apply-macros-in-string (s)
2290 "Apply the macros in string S."
2294 (org-export-preprocess-apply-macros)
2299 (defun org-export-handle-include-files ()
2300 "Include the contents of include files, with proper formatting."
2301 (let ((case-fold-search t
)
2302 params file markup lang start end prefix prefix1 switches all minlevel lines
)
2303 (goto-char (point-min))
2304 (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t
)
2305 (setq params
(read (concat "(" (match-string 1) ")"))
2306 prefix
(org-get-and-remove-property 'params
:prefix
)
2307 prefix1
(org-get-and-remove-property 'params
:prefix1
)
2308 minlevel
(org-get-and-remove-property 'params
:minlevel
)
2309 lines
(org-get-and-remove-property 'params
:lines
)
2310 file
(org-symname-or-string (pop params
))
2311 markup
(org-symname-or-string (pop params
))
2312 lang
(and (member markup
'("src" "SRC"))
2313 (org-symname-or-string (pop params
)))
2314 switches
(mapconcat '(lambda (x) (format "%s" x
)) params
" ")
2316 (delete-region (match-beginning 0) (match-end 0))
2318 (not (file-exists-p file
))
2319 (not (file-readable-p file
)))
2320 (insert (format "CANNOT INCLUDE FILE %s" file
))
2321 (setq all
(cons file all
))
2323 (if (equal (downcase markup
) "src")
2324 (setq start
(format "#+begin_src %s %s\n"
2325 (or lang
"fundamental")
2328 (setq start
(format "#+begin_%s %s\n" markup switches
)
2329 end
(format "#+end_%s" markup
))))
2330 (insert (or start
""))
2331 (insert (org-get-file-contents (expand-file-name file
)
2332 prefix prefix1 markup minlevel lines
))
2333 (or (bolp) (newline))
2334 (insert (or end
""))))
2337 (defun org-export-handle-include-files-recurse ()
2338 "Recursively include files aborting on circular inclusion."
2339 (let ((now (list org-current-export-file
)) all
)
2341 (setq all
(append now all
))
2342 (setq now
(org-export-handle-include-files))
2345 (mapcar (lambda (el) (when (member el all
) el
)) now
))))
2347 (error "Recursive #+INCLUDE: %S" intersection
))))))
2349 (defun org-get-file-contents (file &optional prefix prefix1 markup minlevel lines
)
2350 "Get the contents of FILE and return them as a string.
2351 If PREFIX is a string, prepend it to each line. If PREFIX1
2352 is a string, prepend it to the first line instead of PREFIX.
2353 If MARKUP, don't protect org-like lines, the exporter will
2354 take care of the block they are in. If LINES is a string
2355 specifying a range of lines, include only those lines ."
2356 (if (stringp markup
) (setq markup
(downcase markup
)))
2358 (insert-file-contents file
)
2360 (let* ((lines (split-string lines
"-"))
2361 (lbeg (string-to-number (car lines
)))
2362 (lend (string-to-number (cadr lines
)))
2363 (beg (if (zerop lbeg
) (point-min)
2364 (goto-char (point-min))
2365 (forward-line (1- lbeg
))
2367 (end (if (zerop lend
) (point-max)
2368 (goto-char (point-min))
2369 (forward-line (1- lend
))
2371 (narrow-to-region beg end
)))
2372 (when (or prefix prefix1
)
2373 (goto-char (point-min))
2375 (insert (or prefix1 prefix
))
2377 (beginning-of-line 2)))
2379 (when (member markup
'("src" "example"))
2380 (goto-char (point-min))
2381 (while (re-search-forward "^\\([*#]\\|[ \t]*#\\+\\)" nil t
)
2382 (goto-char (match-beginning 0))
2386 (dotimes (lvl minlevel
)
2387 (org-map-region 'org-demote
(point-min) (point-max))))
2390 (defun org-get-and-remove-property (listvar prop
)
2391 "Check if the value of LISTVAR contains PROP as a property.
2392 If yes, return the value of that property (i.e. the element following
2393 in the list) and remove property and value from the list in LISTVAR."
2394 (let ((list (symbol-value listvar
)) m v
)
2395 (when (setq m
(member prop list
))
2397 (if (equal (car list
) prop
)
2398 (set listvar
(cddr list
))
2399 (setcdr (nthcdr (- (length list
) (length m
) 1) list
)
2401 (set listvar list
)))
2404 (defun org-symname-or-string (s)
2406 (if s
(symbol-name s
) s
)
2409 ;;; Fontification and line numbers for code examples
2411 (defvar org-export-last-code-line-counter-value
0)
2413 (defun org-export-replace-src-segments-and-examples ()
2414 "Replace source code segments with special code for export."
2415 (setq org-export-last-code-line-counter-value
0)
2416 (let ((case-fold-search t
)
2417 lang code trans opts indent caption
)
2418 (goto-char (point-min))
2419 (while (re-search-forward
2420 "\\(^\\([ \t]*\\)#\\+BEGIN_SRC:?\\([ \t]+\\([^ \t\n]+\\)\\)?\\(.*\\)\n\\([^\000]+?\n\\)[ \t]*#\\+END_SRC.*\n?\\)\\|\\(^\\([ \t]*\\)#\\+BEGIN_EXAMPLE:?\\(?:[ \t]+\\(.*\\)\\)?\n\\([^\000]+?\n\\)[ \t]*#\\+END_EXAMPLE.*\n?\\)"
2423 (if (not (match-string 4))
2424 (error "Source block missing language specification: %s"
2425 (let* ((body (match-string 6))
2426 (nothing (message "body:%s" body
))
2427 (preview (or (and (string-match
2428 "^[ \t]*\\([^\n\r]*\\)" body
)
2429 (match-string 1 body
)) body
)))
2430 (if (> (length preview
) 35)
2431 (concat (substring preview
0 32) "...")
2434 (setq lang
(match-string 4)
2435 opts
(match-string 5)
2436 code
(match-string 6)
2437 indent
(length (match-string 2))
2438 caption
(get-text-property 0 'org-caption
(match-string 0))))
2440 opts
(match-string 9)
2441 code
(match-string 10)
2442 indent
(length (match-string 8))
2443 caption
(get-text-property 0 'org-caption
(match-string 0))))
2445 (setq trans
(org-export-format-source-code-or-example
2446 lang code opts indent caption
))
2447 (replace-match trans t t
))))
2449 (defvar org-export-latex-verbatim-wrap
) ;; defined in org-latex.el
2450 (defvar org-export-latex-listings
) ;; defined in org-latex.el
2451 (defvar org-export-latex-listings-langs
) ;; defined in org-latex.el
2452 (defvar org-export-latex-listings-w-names
) ;; defined in org-latex.el
2453 (defvar org-export-latex-minted-langs
) ;; defined in org-latex.el
2454 (defvar org-export-latex-custom-lang-environments
) ;; defined in org-latex.el
2455 (defvar org-export-latex-listings-options
) ;; defined in org-latex.el
2456 (defvar org-export-latex-minted-options
) ;; defined in org-latex.el
2458 (defun org-export-format-source-code-or-example
2459 (lang code
&optional opts indent caption
)
2460 "Format CODE from language LANG and return it formatted for export.
2461 If LANG is nil, do not add any fontification.
2462 OPTS contains formatting options, like `-n' for triggering numbering lines,
2463 and `+n' for continuing previous numbering.
2464 Code formatting according to language currently only works for HTML.
2465 Numbering lines works for all three major backends (html, latex, and ascii).
2466 INDENT was the original indentation of the block."
2468 (let (num cont rtn rpllbl keepp textareap preserve-indentp cols rows fmt
)
2469 (setq opts
(or opts
"")
2470 num
(string-match "[-+]n\\>" opts
)
2471 cont
(string-match "\\+n\\>" opts
)
2472 rpllbl
(string-match "-r\\>" opts
)
2473 keepp
(string-match "-k\\>" opts
)
2474 textareap
(string-match "-t\\>" opts
)
2475 preserve-indentp
(or org-src-preserve-indentation
2476 (string-match "-i\\>" opts
))
2477 cols
(if (string-match "-w[ \t]+\\([0-9]+\\)" opts
)
2478 (string-to-number (match-string 1 opts
))
2480 rows
(if (string-match "-h[ \t]+\\([0-9]+\\)" opts
)
2481 (string-to-number (match-string 1 opts
))
2482 (org-count-lines code
))
2483 fmt
(if (string-match "-l[ \t]+\"\\([^\"\n]+\\)\"" opts
)
2484 (match-string 1 opts
)))
2485 (when (and textareap
(eq org-export-current-backend
'html
))
2486 ;; we cannot use numbering or highlighting.
2487 (setq num nil cont nil lang nil
))
2488 (if keepp
(setq rpllbl
'keep
))
2489 (setq rtn
(if preserve-indentp code
(org-remove-indentation code
)))
2490 (when (string-match "^," rtn
)
2491 (setq rtn
(with-temp-buffer
2493 ;; Free up the protected lines
2494 (goto-char (point-min))
2495 (while (re-search-forward "^," nil t
)
2496 (if (or (equal lang
"org")
2498 (looking-at "\\([*#]\\|[ \t]*#\\+\\)")))
2502 ;; Now backend-specific coding
2505 ((eq org-export-current-backend
'docbook
)
2506 (setq rtn
(org-export-number-lines rtn
0 0 num cont rpllbl fmt
))
2507 (concat "\n#+BEGIN_DOCBOOK\n"
2508 (org-add-props (concat "<programlisting><![CDATA["
2510 "]]></programlisting>\n")
2511 '(org-protected t org-example t
))
2513 ((eq org-export-current-backend
'html
)
2514 ;; We are exporting to HTML
2516 (if (featurep 'xemacs
)
2518 (require 'htmlize nil t
))
2519 (when (not (fboundp 'htmlize-region-for-paste
))
2520 ;; we do not have htmlize.el, or an old version of it
2523 "htmlize.el 1.34 or later is needed for source code formatting")))
2526 (let* ((lang-m (when lang
2527 (or (cdr (assoc lang org-src-lang-modes
))
2529 (mode (and lang-m
(intern
2531 (if (symbolp lang-m
)
2532 (symbol-name lang-m
)
2535 (org-inhibit-startup t
)
2536 (org-startup-folded nil
))
2540 (if (functionp mode
)
2543 (font-lock-fontify-buffer)
2545 (set-buffer-modified-p nil
)
2546 (org-export-htmlize-region-for-paste
2547 (point-min) (point-max))))
2548 (if (string-match "<pre\\([^>]*\\)>\n*" rtn
)
2553 "<div class=\"org-src-container\">"
2555 "<label class=\"org-src-name\">%s</label>"
2559 (format "<pre class=\"src src-%s\">\n" lang
)
2561 (if caption
"</div>" "")))))
2564 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">"
2566 rtn
"</textarea>\n</p>\n"))
2569 (goto-char (point-min))
2570 (while (re-search-forward "[<>&]" nil t
)
2571 (replace-match (cdr (assq (char-before)
2572 '((?
&.
"&")(?
<.
"<")(?
>.
">"))))
2574 (setq rtn
(buffer-string)))
2575 (setq rtn
(concat "<pre class=\"example\">\n" rtn
"</pre>\n"))))
2577 (setq rtn
(org-export-number-lines rtn
1 1 num cont rpllbl fmt
)))
2578 (if (string-match "\\(\\`<[^>]*>\\)\n" rtn
)
2579 (setq rtn
(replace-match "\\1" t nil rtn
)))
2580 (concat "\n#+BEGIN_HTML\n" (org-add-props rtn
'(org-protected t org-example t org-native-text t
)) "\n#+END_HTML\n\n"))
2581 ((eq org-export-current-backend
'odt
)
2582 (concat "\n#+BEGIN_ODT\n"
2584 (org-odt-format-example
2585 (org-export-number-lines
2586 (org-html-protect-lines rtn
) 0 0 num cont rpllbl fmt
))
2587 '(org-protected t org-example t org-native-text t
))
2590 ((eq org-export-current-backend
'latex
)
2591 (setq rtn
(org-export-number-lines rtn
0 0 num cont rpllbl fmt
))
2596 ((and lang org-export-latex-listings
)
2597 (flet ((make-option-string
2599 (concat (first pair
)
2600 (if (> (length (second pair
)) 0)
2601 (concat "=" (second pair
))))))
2602 (let* ((lang-sym (intern lang
))
2603 (minted-p (eq org-export-latex-listings
'minted
))
2604 (listings-p (not minted-p
))
2610 (minted-p org-export-latex-minted-langs
)
2611 (listings-p org-export-latex-listings-langs
))))
2617 org-export-latex-custom-lang-environments
))))
2619 (when (and listings-p
(not custom-environment
))
2623 #'make-option-string
2624 (append org-export-latex-listings-options
2625 `(("language" ,backend-lang
))) ",")))
2626 (when (and caption org-export-latex-listings-w-names
)
2629 (replace-regexp-in-string "_" "\\\\_" caption
)))
2632 (format "\\begin{%s}\n%s\\end{%s}\n"
2633 custom-environment rtn custom-environment
))
2635 (format "\\begin{%s}\n%s\\end{%s}\n"
2636 "lstlisting" rtn
"lstlisting"))
2639 "\\begin{minted}[%s]{%s}\n%s\\end{minted}\n"
2640 (mapconcat #'make-option-string
2641 org-export-latex-minted-options
",")
2642 backend-lang rtn
)))))))
2643 (t (concat (car org-export-latex-verbatim-wrap
)
2644 rtn
(cdr org-export-latex-verbatim-wrap
))))
2645 '(org-protected t org-example t
))
2647 ((eq org-export-current-backend
'ascii
)
2648 ;; This is not HTML or LaTeX, so just make it an example.
2649 (setq rtn
(org-export-number-lines rtn
0 0 num cont rpllbl fmt
))
2650 (concat caption
"\n"
2655 (lambda (l) (concat " " l
))
2656 (org-split-string rtn
"\n")
2659 '(org-protected t org-example t
))
2661 (org-add-props rtn nil
'original-indentation indent
))))
2663 (defun org-export-number-lines (text &optional skip1 skip2 number cont
2664 replace-labels label-format
)
2665 (setq skip1
(or skip1
0) skip2
(or skip2
0))
2666 (if (not cont
) (setq org-export-last-code-line-counter-value
0))
2669 (goto-char (point-max))
2670 (skip-chars-backward " \t\n\r")
2671 (delete-region (point) (point-max))
2672 (beginning-of-line (- 1 skip2
))
2673 (let* ((last (org-current-line))
2674 (n org-export-last-code-line-counter-value
)
2675 (nmax (+ n
(- last skip1
)))
2676 (fmt (format "%%%dd: " (length (number-to-string nmax
))))
2679 ((member org-export-current-backend
'(html odt
))
2680 (org-parse-format 'FONTIFY fmt
"linenr"))
2681 ((eq org-export-current-backend
'ascii
) fmt
)
2682 ((eq org-export-current-backend
'latex
) fmt
)
2683 ((eq org-export-current-backend
'docbook
) fmt
)
2685 (label-format (or label-format org-coderef-label-format
))
2686 (label-pre (if (string-match "%s" label-format
)
2687 (substring label-format
0 (match-beginning 0))
2689 (label-post (if (string-match "%s" label-format
)
2690 (substring label-format
(match-end 0))
2694 ".*?\\S-.*?\\([ \t]*\\("
2695 (regexp-quote label-pre
)
2696 "\\([-a-zA-Z0-9_ ]+\\)"
2697 (regexp-quote label-post
)
2701 (org-goto-line (1+ skip1
))
2702 (while (and (re-search-forward "^" nil t
) (not (eobp)) (< n nmax
))
2704 (insert (format fm
(incf n
)))
2706 (when (looking-at lbl-re
)
2707 (setq ref
(match-string 3))
2708 (cond ((numberp replace-labels
)
2709 ;; remove labels; use numbers for references when lines
2710 ;; are numbered, use labels otherwise
2711 (delete-region (match-beginning 1) (match-end 1))
2712 (push (cons ref
(if (> n
0) n ref
)) org-export-code-refs
))
2713 ((eq replace-labels
'keep
)
2714 ;; don't remove labels; use numbers for references when
2715 ;; lines are numbered, use labels otherwise
2716 (goto-char (match-beginning 2))
2717 (delete-region (match-beginning 2) (match-end 2))
2718 (insert "(" ref
")")
2719 (push (cons ref
(if (> n
0) n
(concat "(" ref
")")))
2720 org-export-code-refs
))
2722 ;; don't remove labels and don't use numbers for
2724 (goto-char (match-beginning 2))
2725 (delete-region (match-beginning 2) (match-end 2))
2726 (insert "(" ref
")")
2727 (push (cons ref
(concat "(" ref
")")) org-export-code-refs
)))
2728 (when (member org-export-current-backend
'(html odt
))
2729 (beginning-of-line 1)
2730 (re-search-forward "^\\(.*\\)$" nil t
1)
2732 (let ((id (concat "coderef-" ref
)))
2734 'ANCHOR
(match-string 1) id
"coderef-off")) t t
))))
2735 (setq org-export-last-code-line-counter-value n
)
2736 (goto-char (point-max))
2740 (defun org-search-todo-below (line lines level
)
2741 "Search the subtree below LINE for any TODO entries."
2742 (let ((rest (cdr (memq line lines
)))
2743 (re org-todo-line-regexp
)
2746 (while (setq line
(pop rest
))
2747 (if (string-match re line
)
2749 (setq lv
(- (match-end 1) (match-beginning 1))
2750 todo
(and (match-beginning 2)
2751 (not (member (match-string 2 line
)
2752 org-done-keywords
))))
2754 (if (<= lv level
) (throw 'exit nil
))
2755 (if todo
(throw 'exit t
))))))))
2758 (defun org-export-visible (type arg
)
2759 "Create a copy of the visible part of the current buffer, and export it.
2760 The copy is created in a temporary buffer and removed after use.
2761 TYPE is the final key (as a string) that also selects the export command in
2762 the \\<org-mode-map>\\[org-export] export dispatcher.
2763 As a special case, if the you type SPC at the prompt, the temporary
2764 org-mode file will not be removed but presented to you so that you can
2765 continue to use it. The prefix arg ARG is passed through to the exporting
2769 (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")
2770 (read-char-exclusive))
2771 current-prefix-arg
))
2772 (if (not (member type
'(?a ?n ?u ?\C-a ?b ?\C-b ?h ?D ?x ?\ ?l ?p ?d ?L ?H ?R
)))
2773 (error "Invalid export key"))
2774 (let* ((binding (cdr (assoc type
2776 (?a . org-export-as-ascii
)
2777 (?A . org-export-as-ascii-to-buffer
)
2778 (?n . org-export-as-latin1
)
2779 (?N . org-export-as-latin1-to-buffer
)
2780 (?u . org-export-as-utf8
)
2781 (?U . org-export-as-utf8-to-buffer
)
2782 (?\C-a . org-export-as-ascii
)
2783 (?b . org-export-as-html-and-open
)
2784 (?\C-b . org-export-as-html-and-open
)
2785 (?h . org-export-as-html
)
2786 (?H . org-export-as-html-to-buffer
)
2787 (?R . org-export-region-as-html
)
2788 (?D . org-export-as-docbook
)
2790 (?l . org-export-as-latex
)
2791 (?p . org-export-as-pdf
)
2792 (?d . org-export-as-pdf-and-open
)
2793 (?L . org-export-as-latex-to-buffer
)
2795 (?x . org-export-as-xoxo
)))))
2796 (keepp (equal type ?\
))
2797 (file buffer-file-name
)
2798 (buffer (get-buffer-create "*Org Export Visible*"))
2800 ;; Need to hack the drawers here.
2802 (goto-char (point-min))
2803 (while (re-search-forward org-drawer-regexp nil t
)
2804 (goto-char (match-beginning 1))
2805 (or (outline-invisible-p) (org-flag-drawer nil
))))
2806 (with-current-buffer buffer
(erase-buffer))
2808 (setq s
(goto-char (point-min)))
2809 (while (not (= (point) (point-max)))
2810 (goto-char (org-find-invisible))
2811 (append-to-buffer buffer s
(point))
2812 (setq s
(goto-char (org-find-visible))))
2813 (org-cycle-hide-drawers 'all
)
2814 (goto-char (point-min))
2816 ;; Copy all comment lines to the end, to make sure #+ settings are
2817 ;; still available for the second export step. Kind of a hack, but
2818 ;; does do the trick.
2819 (if (looking-at "#[^\r\n]*")
2820 (append-to-buffer buffer
(match-beginning 0) (1+ (match-end 0))))
2821 (when (re-search-forward "^\\*+[ \t]+" nil t
)
2822 (while (re-search-backward "[\n\r]#[^\n\r]*" nil t
)
2823 (append-to-buffer buffer
(1+ (match-beginning 0))
2824 (min (point-max) (1+ (match-end 0)))))))
2826 (let ((buffer-file-name file
)
2827 (org-inhibit-startup t
))
2830 (unless keepp
(funcall binding arg
))))
2832 (kill-buffer buffer
)
2833 (switch-to-buffer-other-window buffer
)
2834 (goto-char (point-min)))))
2836 (defun org-find-visible ()
2838 (while (and (not (= (point-max) (setq s
(next-overlay-change s
))))
2839 (get-char-property s
'invisible
)))
2841 (defun org-find-invisible ()
2843 (while (and (not (= (point-max) (setq s
(next-overlay-change s
))))
2844 (not (get-char-property s
'invisible
))))
2847 (defvar org-export-htmlized-org-css-url
) ;; defined in org-html.el
2849 (defun org-export-string (string fmt
&optional dir
)
2850 "Export STRING to FMT using existing export facilities.
2851 During export STRING is saved to a temporary file whose location
2852 could vary. Optional argument DIR can be used to force the
2853 directory in which the temporary file is created during export
2854 which can be useful for resolving relative paths. Dir defaults
2855 to the value of `temporary-file-directory'."
2856 (let ((temporary-file-directory (or dir temporary-file-directory
))
2857 (tmp-file (make-temp-file "org-")))
2861 (write-file tmp-file
)
2862 (org-load-modules-maybe)
2863 (unless org-local-vars
2864 (setq org-local-vars
(org-get-local-variables)))
2865 (eval ;; convert to fmt -- mimicing `org-run-like-in-org-mode'
2866 (list 'let org-local-vars
2867 (list (intern (format "org-export-as-%s" fmt
))
2868 nil nil nil
''string t
))))
2869 (delete-file tmp-file
))))
2872 (defun org-export-as-org (arg &optional hidden ext-plist
2873 to-buffer body-only pub-dir
)
2874 "Make a copy with not-exporting stuff removed.
2875 The purpose of this function is to provide a way to export the source
2876 Org file of a webpage in Org format, but with sensitive and/or irrelevant
2877 stuff removed. This command will remove the following:
2879 - archived trees (if the variable `org-export-with-archived-trees' is nil)
2880 - comment blocks and trees starting with the COMMENT keyword
2881 - only trees that are consistent with `org-export-select-tags'
2882 and `org-export-exclude-tags'.
2884 The only arguments that will be used are EXT-PLIST and PUB-DIR,
2885 all the others will be ignored (but are present so that the general
2886 mechanism to call publishing functions will work).
2888 EXT-PLIST is a property list with external parameters overriding
2889 org-mode's default settings, but still inferior to file-local
2890 settings. When PUB-DIR is set, use this as the publishing
2893 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
2895 (org-infile-export-plist)))
2896 (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
2897 (filename (concat (file-name-as-directory
2899 (org-export-directory :org opt-plist
)))
2900 (file-name-sans-extension
2901 (file-name-nondirectory bfname
))
2903 (filename (and filename
2904 (if (equal (file-truename filename
)
2905 (file-truename bfname
))
2906 (concat (file-name-sans-extension filename
)
2908 (file-name-extension filename
))
2910 (backup-inhibited t
)
2911 (buffer (find-file-noselect filename
))
2912 (region (buffer-string))
2915 (switch-to-buffer buffer
)
2918 (let ((org-inhibit-startup t
)) (org-mode))
2919 (org-install-letbind)
2921 ;; Get rid of archived trees
2922 (org-export-remove-archived-trees (plist-get opt-plist
:archived-trees
))
2924 ;; Remove comment environment and comment subtrees
2925 (org-export-remove-comment-blocks-and-subtrees)
2927 ;; Get rid of excluded trees
2928 (org-export-handle-export-tags (plist-get opt-plist
:select-tags
)
2929 (plist-get opt-plist
:exclude-tags
))
2931 (when (or (plist-get opt-plist
:plain-source
)
2932 (not (or (plist-get opt-plist
:plain-source
)
2933 (plist-get opt-plist
:htmlized-source
))))
2934 ;; Either nothing special is requested (default call)
2935 ;; or the plain source is explicitly requested
2938 (when (plist-get opt-plist
:htmlized-source
)
2939 ;; Make the htmlized version
2942 (font-lock-fontify-buffer)
2943 (let* ((htmlize-output-type 'css
)
2944 (newbuf (htmlize-buffer)))
2945 (with-current-buffer newbuf
2946 (when org-export-htmlized-org-css-url
2947 (goto-char (point-min))
2948 (and (re-search-forward
2949 "<style type=\"text/css\">[^\000]*?\n[ \t]*</style>.*"
2953 "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"
2954 org-export-htmlized-org-css-url
)
2956 (write-file (concat filename
".html")))
2957 (kill-buffer newbuf
)))
2958 (set-buffer-modified-p nil
)
2959 (if (equal to-buffer
'string
)
2960 (progn (setq str-ret
(buffer-string))
2961 (kill-buffer (current-buffer))
2963 (kill-buffer (current-buffer))))))
2965 (defvar org-archive-location
) ;; gets loaded with the org-archive require.
2966 (defun org-get-current-options ()
2967 "Return a string with current options as keyword options.
2968 Does include HTML export options as well as TODO and CATEGORY stuff."
2969 (require 'org-archive
)
2978 #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s <:%s
2979 #+OPTIONS: TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s
2981 #+EXPORT_SELECT_TAGS: %s
2982 #+EXPORT_EXCLUDE_TAGS: %s
2989 #+PRIORITIES: %c %c %c
2991 #+STARTUP: %s %s %s %s %s
2997 (buffer-name) (user-full-name) user-mail-address
2998 (format-time-string (substring (car org-time-stamp-formats
) 1 -
1))
2999 org-export-default-language
3000 org-export-headline-levels
3001 org-export-with-section-numbers
3003 org-export-preserve-breaks
3004 org-export-html-expand
3005 org-export-with-fixed-width
3006 org-export-with-tables
3007 org-export-with-sub-superscripts
3008 org-export-with-special-strings
3009 org-export-with-footnotes
3010 org-export-with-emphasize
3011 org-export-with-timestamps
3012 org-export-with-TeX-macros
3013 org-export-with-LaTeX-fragments
3014 org-export-skip-text-before-1st-heading
3015 org-export-with-drawers
3016 org-export-with-todo-keywords
3017 org-export-with-priority
3018 org-export-with-tags
3019 (if (featurep 'org-jsinfo
) (org-infojs-options-inbuffer-template) "")
3020 (mapconcat 'identity org-export-select-tags
" ")
3021 (mapconcat 'identity org-export-exclude-tags
" ")
3022 org-export-html-link-up
3023 org-export-html-link-home
3025 (file-name-sans-extension
3026 (file-name-nondirectory (buffer-file-name (buffer-base-buffer)))))
3028 "TODO FEEDBACK VERIFY DONE"
3029 "Me Jason Marie DONE"
3030 org-highest-priority org-lowest-priority org-default-priority
3031 (mapconcat 'identity org-drawers
" ")
3032 (cdr (assoc org-startup-folded
3033 '((nil .
"showall") (t .
"overview") (content .
"content"))))
3034 (if org-odd-levels-only
"odd" "oddeven")
3035 (if org-hide-leading-stars
"hidestars" "showstars")
3036 (if org-startup-align-all-tables
"align" "noalign")
3037 (cond ((eq org-log-done t
) "logdone")
3038 ((equal org-log-done
'note
) "lognotedone")
3039 ((not org-log-done
) "nologdone"))
3040 (or (mapconcat (lambda (x)
3042 ((equal :startgroup
(car x
)) "{")
3043 ((equal :endgroup
(car x
)) "}")
3044 ((equal :newline
(car x
)) "")
3045 ((cdr x
) (format "%s(%c)" (car x
) (cdr x
)))
3047 (or org-tag-alist
(org-get-buffer-tags)) " ") "")
3048 (mapconcat 'identity org-file-tags
" ")
3049 org-archive-location
3050 "org file:~/org/%s.org"
3054 (defun org-insert-export-options-template ()
3055 "Insert into the buffer a template with information for exporting."
3057 (if (not (bolp)) (newline))
3058 (let ((s (org-get-current-options)))
3059 (and (string-match "#\\+CATEGORY" s
)
3060 (setq s
(substring s
0 (match-beginning 0))))
3063 (defvar org-table-colgroup-info nil
)
3065 (defun org-table-clean-before-export (lines &optional maybe-quoted
)
3066 "Check if the table has a marking column.
3067 If yes remove the column and the special lines."
3068 (setq org-table-colgroup-info nil
)
3071 (lambda (x) (or (string-match "^[ \t]*|-" x
)
3074 "^[ \t]*| *\\\\?\\([\#!$*_^ /]\\) *|"
3075 "^[ \t]*| *\\([\#!$*_^ /]\\) *|")
3078 ;; No special marking column
3080 (setq org-table-clean-did-remove-column nil
)
3085 ((org-table-colgroup-line-p x
)
3086 ;; This line contains colgroup info, extract it
3087 ;; and then discard the line
3088 (setq org-table-colgroup-info
3090 (cond ((member x
'("<" "<")) :start
)
3091 ((member x
'(">" ">")) :end
)
3092 ((member x
'("<>" "<>")) :startend
)
3094 (org-split-string x
"[ \t]*|[ \t]*")))
3096 ((org-table-cookie-line-p x
)
3097 ;; This line contains formatting cookies, discard it
3101 ;; there is a special marking column
3102 (setq org-table-clean-did-remove-column t
)
3107 ((org-table-colgroup-line-p x
)
3108 ;; This line contains colgroup info, extract it
3109 ;; and then discard the line
3110 (setq org-table-colgroup-info
3112 (cond ((member x
'("<" "<")) :start
)
3113 ((member x
'(">" ">")) :end
)
3114 ((member x
'("<>" "<>")) :startend
)
3116 (cdr (org-split-string x
"[ \t]*|[ \t]*"))))
3118 ((org-table-cookie-line-p x
)
3119 ;; This line contains formatting cookies, discard it
3121 ((string-match "^[ \t]*| *[!_^/] *|" x
)
3124 ((or (string-match "^\\([ \t]*\\)|-+\\+" x
)
3125 (string-match "^\\([ \t]*\\)|[^|]*|" x
))
3126 ;; remove the first column
3127 (replace-match "\\1|" t nil x
))))
3130 (defun org-export-cleanup-toc-line (s)
3131 "Remove tags and timestamps from lines going into the toc."
3132 (when (memq org-export-with-tags
'(not-in-toc nil
))
3133 (if (string-match (org-re " +:[[:alnum:]_@#%:]+: *$") s
)
3134 (setq s
(replace-match "" t t s
))))
3135 (when org-export-remove-timestamps-from-toc
3136 (while (string-match org-maybe-keyword-time-regexp s
)
3137 (setq s
(replace-match "" t t s
))))
3138 (while (string-match org-bracket-link-regexp s
)
3139 (setq s
(replace-match (match-string (if (match-end 3) 3 1) s
)
3141 (while (string-match "\\[\\([0-9]\\|fn:[^]]*\\)\\]" s
)
3142 (setq s
(replace-match "" t t s
)))
3146 (defun org-get-text-property-any (pos prop
&optional object
)
3147 (or (get-text-property pos prop object
)
3148 (and (setq pos
(next-single-property-change pos prop object
))
3149 (get-text-property pos prop object
))))
3151 (defun org-export-get-coderef-format (path desc
)
3153 (if (and desc
(string-match
3154 (regexp-quote (concat "(" path
")"))
3156 (replace-match "%s" t t desc
)
3159 (defun org-export-push-to-kill-ring (format)
3160 "Push buffer content to kill ring.
3161 The depends on the variable `org-export-copy-to-kill'."
3162 (when org-export-copy-to-kill-ring
3163 (org-kill-new (buffer-string))
3164 (when (fboundp 'x-set-selection
)
3165 (ignore-errors (x-set-selection 'PRIMARY
(buffer-string)))
3166 (ignore-errors (x-set-selection 'CLIPBOARD
(buffer-string))))
3167 (message "%s export done, pushed to kill ring and clipboard" format
)))
3171 ;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
3173 ;;; org-exp.el ends here