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 \[j] export as TaskJuggler [J] ... and open
938 \[m] export as Freemind mind map
940 \[g] export using Wes Hardaker's generic exporter
942 \[i] export current file as iCalendar file
943 \[I] export all agenda files as iCalendar files [c] ...as one combined file
945 \[F] publish current file [P] publish current project
946 \[X] publish a project... [E] publish every projects")
948 '((?t org-insert-export-options-template nil
)
949 (?v org-export-visible nil
)
950 (?a org-export-as-ascii t
)
951 (?A org-export-as-ascii-to-buffer t
)
952 (?n org-export-as-latin1 t
)
953 (?N org-export-as-latin1-to-buffer t
)
954 (?u org-export-as-utf8 t
)
955 (?U org-export-as-utf8-to-buffer t
)
956 (?h org-export-as-html t
)
957 (?b org-export-as-html-and-open t
)
958 (?H org-export-as-html-to-buffer nil
)
959 (?R org-export-region-as-html nil
)
960 (?x org-export-as-xoxo t
)
961 (?g org-export-generic t
)
962 (?D org-export-as-docbook t
)
963 (?V org-export-as-docbook-pdf-and-open t
)
964 (?j org-export-as-taskjuggler t
)
965 (?J org-export-as-taskjuggler-and-open t
)
966 (?m org-export-as-freemind t
)
967 (?l org-export-as-latex t
)
968 (?p org-export-as-pdf t
)
969 (?d org-export-as-pdf-and-open t
)
970 (?L org-export-as-latex-to-buffer nil
)
971 (?i org-export-icalendar-this-file t
)
972 (?I org-export-icalendar-all-agenda-files t
)
973 (?c org-export-icalendar-combine-agenda-files t
)
974 (?F org-publish-current-file t
)
975 (?P org-publish-current-project t
)
977 (?E org-publish-all t
)))
979 (cpos (point)) (cbuf (current-buffer)) bpos
)
981 (save-window-excursion
983 (message "Export subtree: ")
984 (message "Export buffer: "))
985 (delete-other-windows)
986 (with-output-to-temp-buffer "*Org Export/Publishing Help*"
988 (org-fit-window-to-buffer (get-buffer-window
989 "*Org Export/Publishing Help*"))
990 (while (eq (setq r1
(read-char-exclusive)) ?
1)
993 (message "Export buffer: "))
996 (message "Export subtree: "))))
998 (let ((case-fold-search t
)
999 (end (save-excursion (while (org-up-heading-safe)) (point))))
1000 (outline-next-heading)
1001 (if (re-search-backward
1002 "^[ \t]+\\(:latex_class:\\|:export_title:\\|:export_file_name:\\)[ \t]+\\S-"
1005 (org-back-to-heading t
)
1008 (message "Select command (for subtree): ")
1009 (setq r1
(read-char-exclusive)))
1010 (error "No enclosing node with LaTeX_CLASS or EXPORT_TITLE or EXPORT_FILE_NAME")
1013 (and bpos
(goto-char bpos
))
1014 (setq r2
(if (< r1
27) (+ r1
96) r1
))
1015 (unless (setq ass
(assq r2 cmds
))
1016 (error "No command associated with key %c" r1
))
1017 (if (and bg
(nth 2 ass
)
1018 (not (buffer-base-buffer))
1019 (not (org-region-active-p)))
1020 ;; execute in background
1021 (let ((p (start-process
1022 (concat "Exporting " (file-name-nondirectory (buffer-file-name)))
1024 (expand-file-name invocation-name invocation-directory
)
1027 "--eval" "(require 'org-exp)"
1028 "--eval" "(setq org-wait .2)"
1030 "-f" (symbol-name (nth 1 ass
)))))
1031 (set-process-sentinel p
'org-export-process-sentinel
)
1032 (message "Background process \"%s\": started" p
))
1033 ;; background processing not requested, or not possible
1034 (if subtree-p
(progn (org-mark-subtree) (org-activate-mark)))
1035 (call-interactively (nth 1 ass
))
1036 (when (and bpos
(get-buffer-window cbuf
))
1037 (let ((cw (selected-window)))
1038 (select-window (get-buffer-window cbuf
))
1041 (select-window cw
))))))
1043 (defun org-export-process-sentinel (process status
)
1044 (if (string-match "\n+\\'" status
)
1045 (setq status
(substring status
0 -
1)))
1046 (message "Background process \"%s\": %s" process status
))
1048 ;;; General functions for all backends
1050 (defvar org-export-target-aliases nil
1051 "Alist of targets with invisible aliases.")
1052 (defvar org-export-preferred-target-alist nil
1053 "Alist of section id's with preferred aliases.")
1054 (defvar org-export-id-target-alist nil
1055 "Alist of section id's with preferred aliases.")
1056 (defvar org-export-code-refs nil
1057 "Alist of code references and line numbers.")
1059 (defun org-export-preprocess-string (string &rest parameters
)
1060 "Cleanup STRING so that the true exported has a more consistent source.
1061 This function takes STRING, which should be a buffer-string of an org-file
1062 to export. It then creates a temporary buffer where it does its job.
1063 The result is then again returned as a string, and the exporter works
1064 on this string to produce the exported version."
1066 (let* ((org-export-current-backend (plist-get parameters
:for-backend
))
1067 (archived-trees (plist-get parameters
:archived-trees
))
1068 (inhibit-read-only t
)
1069 (drawers org-drawers
)
1070 (outline-regexp "\\*+ ")
1071 (source-buffer (current-buffer))
1074 (setq org-export-target-aliases nil
1075 org-export-preferred-target-alist nil
1076 org-export-id-target-alist nil
1077 org-export-code-refs nil
)
1079 (with-current-buffer (get-buffer-create " org-mode-tmp")
1082 (setq case-fold-search t
)
1084 (let ((inhibit-read-only t
))
1085 (remove-text-properties (point-min) (point-max)
1088 ;; Remove license-to-kill stuff
1089 ;; The caller marks some stuff for killing, stuff that has been
1090 ;; used to create the page title, for example.
1091 (org-export-kill-licensed-text)
1093 (let ((org-inhibit-startup t
)) (org-mode))
1094 (setq case-fold-search t
)
1095 (org-clone-local-variables source-buffer
"^\\(org-\\|orgtbl-\\)")
1096 (org-install-letbind)
1099 (run-hooks 'org-export-preprocess-hook
)
1101 (untabify (point-min) (point-max))
1103 ;; Handle include files, and call a hook
1104 (org-export-handle-include-files-recurse)
1105 (run-hooks 'org-export-preprocess-after-include-files-hook
)
1107 ;; Change lists ending. Other parts of export may insert blank
1108 ;; lines and lists' structure could be altered.
1109 (org-export-mark-list-end)
1111 ;; Process the macros
1112 (org-export-preprocess-apply-macros)
1113 (run-hooks 'org-export-preprocess-after-macros-hook
)
1115 ;; Get rid of archived trees
1116 (org-export-remove-archived-trees archived-trees
)
1118 ;; Remove comment environment and comment subtrees
1119 (org-export-remove-comment-blocks-and-subtrees)
1121 ;; Get rid of excluded trees, and call a hook
1122 (org-export-handle-export-tags (plist-get parameters
:select-tags
)
1123 (plist-get parameters
:exclude-tags
))
1124 (run-hooks 'org-export-preprocess-after-tree-selection-hook
)
1126 ;; Get rid of tasks, depending on configuration
1127 (org-export-remove-tasks (plist-get parameters
:tasks
))
1129 ;; Export code blocks
1130 (org-export-blocks-preprocess)
1132 ;; Mark lists with properties
1133 (org-export-mark-list-properties)
1135 ;; Handle source code snippets
1136 (org-export-replace-src-segments-and-examples)
1138 ;; Protect short examples marked by a leading colon
1139 (org-export-protect-colon-examples)
1142 (org-export-convert-protected-spaces)
1144 ;; Normalize footnotes
1145 (when (plist-get parameters
:footnotes
)
1146 (org-footnote-normalize nil t
))
1148 ;; Find all headings and compute the targets for them
1149 (setq target-alist
(org-export-define-heading-targets target-alist
))
1151 (run-hooks 'org-export-preprocess-after-headline-targets-hook
)
1153 ;; Find HTML special classes for headlines
1154 (org-export-remember-html-container-classes)
1156 ;; Get rid of drawers
1157 (org-export-remove-or-extract-drawers
1158 drawers
(plist-get parameters
:drawers
))
1160 ;; Get the correct stuff before the first headline
1161 (when (plist-get parameters
:skip-before-1st-heading
)
1162 (goto-char (point-min))
1163 (when (re-search-forward "^\\(#.*\n\\)?\\*+[ \t]" nil t
)
1164 (delete-region (point-min) (match-beginning 0))
1165 (goto-char (point-min))
1167 (when (plist-get parameters
:add-text
)
1168 (goto-char (point-min))
1169 (insert (plist-get parameters
:add-text
) "\n"))
1171 ;; Remove todo-keywords before exporting, if the user has requested so
1172 (org-export-remove-headline-metadata parameters
)
1174 ;; Find targets in comments and move them out of comments,
1175 ;; but mark them as targets that should be invisible
1176 (setq target-alist
(org-export-handle-invisible-targets target-alist
))
1178 ;; Select and protect backend specific stuff, throw away stuff
1179 ;; that is specific for other backends
1180 (run-hooks 'org-export-preprocess-before-selecting-backend-code-hook
)
1181 (org-export-select-backend-specific-text)
1183 ;; Protect quoted subtrees
1184 (org-export-protect-quoted-subtrees)
1186 ;; Remove clock lines
1187 (org-export-remove-clock-lines)
1189 ;; Protect verbatim elements
1190 (org-export-protect-verbatim)
1192 ;; Blockquotes, verse, and center
1193 (org-export-mark-blockquote-verse-center)
1194 (run-hooks 'org-export-preprocess-after-blockquote-hook
)
1196 ;; Remove timestamps, if the user has requested so
1197 (unless (plist-get parameters
:timestamps
)
1198 (org-export-remove-timestamps))
1200 ;; Attach captions to the correct object
1201 (setq target-alist
(org-export-attach-captions-and-attributes target-alist
))
1203 ;; Find matches for radio targets and turn them into internal links
1204 (org-export-mark-radio-links)
1205 (run-hooks 'org-export-preprocess-after-radio-targets-hook
)
1207 ;; Find all links that contain a newline and put them into a single line
1208 (org-export-concatenate-multiline-links)
1210 ;; Normalize links: Convert angle and plain links into bracket links
1211 ;; and expand link abbreviations
1212 (run-hooks 'org-export-preprocess-before-normalizing-links-hook
)
1213 (org-export-normalize-links)
1215 ;; Find all internal links. If they have a fuzzy match (i.e. not
1216 ;; a *dedicated* target match, let the link point to the
1217 ;; corresponding section.
1218 (org-export-target-internal-links target-alist
)
1220 ;; Find multiline emphasis and put them into single line
1221 (when (plist-get parameters
:emph-multiline
)
1222 (org-export-concatenate-multiline-emphasis))
1224 ;; Remove special table lines, and store alignment information
1225 (org-store-forced-table-alignment)
1226 (when org-export-table-remove-special-lines
1227 (org-export-remove-special-table-lines))
1230 (run-hooks 'org-export-preprocess-before-backend-specifics-hook
)
1232 ;; Backend-specific preprocessing
1233 (let* ((backend-name (symbol-name org-export-current-backend
))
1234 (f (intern (format "org-export-%s-preprocess" backend-name
))))
1235 (require (intern (concat "org-" backend-name
)) nil
)
1236 (funcall f parameters
))
1238 ;; Remove or replace comments
1239 (org-export-handle-comments (plist-get parameters
:comments
))
1241 ;; Remove #+TBLFM and #+TBLNAME lines
1242 (org-export-handle-table-metalines)
1244 ;; Run the final hook
1245 (run-hooks 'org-export-preprocess-final-hook
)
1247 (setq rtn
(buffer-string)))
1248 (kill-buffer " org-mode-tmp")
1251 (defun org-export-kill-licensed-text ()
1252 "Remove all text that is marked with a :org-license-to-kill property."
1254 (while (setq p
(text-property-any (point-min) (point-max)
1255 :org-license-to-kill t
))
1257 p
(or (next-single-property-change p
:org-license-to-kill
)
1260 (defvar org-export-define-heading-targets-headline-hook nil
1261 "Hook that is run when a headline was matched during target search.
1262 This is part of the preprocessing for export.")
1264 (defun org-export-define-heading-targets (target-alist)
1265 "Find all headings and define the targets for them.
1266 The new targets are added to TARGET-ALIST, which is also returned.
1267 Also find all ID and CUSTOM_ID properties and store them."
1268 (goto-char (point-min))
1269 (org-init-section-numbers)
1270 (let ((re (concat "^" org-outline-regexp
1272 "^[ \t]*:\\(ID\\|CUSTOM_ID\\):[ \t]*\\([^ \t\r\n]+\\)"))
1273 level target last-section-target a id
)
1274 (while (re-search-forward re nil t
)
1275 (org-if-unprotected-at (match-beginning 0)
1278 (setq id
(org-match-string-no-properties 2))
1279 (push (cons id target
) target-alist
)
1280 (setq a
(or (assoc last-section-target org-export-target-aliases
)
1282 (push (list last-section-target
)
1283 org-export-target-aliases
)
1284 (car org-export-target-aliases
))))
1285 (push (caar target-alist
) (cdr a
))
1286 (when (equal (match-string 1) "CUSTOM_ID")
1287 (if (not (assoc last-section-target
1288 org-export-preferred-target-alist
))
1289 (push (cons last-section-target id
)
1290 org-export-preferred-target-alist
)))
1291 (when (equal (match-string 1) "ID")
1292 (if (not (assoc last-section-target
1293 org-export-id-target-alist
))
1294 (push (cons last-section-target
(concat "ID-" id
))
1295 org-export-id-target-alist
))))
1296 (setq level
(org-reduced-level
1297 (save-excursion (goto-char (point-at-bol))
1298 (org-outline-level))))
1299 (setq target
(org-solidify-link-text
1300 (format "sec-%s" (replace-regexp-in-string
1302 (org-section-number level
)))))
1303 (setq last-section-target target
)
1304 (push (cons target target
) target-alist
)
1305 (add-text-properties
1306 (point-at-bol) (point-at-eol)
1307 (list 'target target
))
1308 (run-hooks 'org-export-define-heading-targets-headline-hook
)))))
1311 (defun org-export-handle-invisible-targets (target-alist)
1312 "Find targets in comments and move them out of comments.
1313 Mark them as invisible targets."
1315 (goto-char (point-min))
1316 (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t
)
1317 ;; Check if the line before or after is a headline with a target
1318 (if (setq target
(or (get-text-property (point-at-bol 0) 'target
)
1319 (get-text-property (point-at-bol 2) 'target
)))
1321 ;; use the existing target in a neighboring line
1322 (setq tmp
(match-string 2))
1324 (and (looking-at "\n") (delete-char 1))
1325 (push (cons (setq tmp
(org-solidify-link-text tmp
)) target
)
1327 (setq a
(or (assoc target org-export-target-aliases
)
1329 (push (list target
) org-export-target-aliases
)
1330 (car org-export-target-aliases
))))
1332 ;; Make an invisible target
1333 (replace-match "\\1(INVISIBLE)"))))
1336 (defun org-export-target-internal-links (target-alist)
1337 "Find all internal links and assign targets to them.
1338 If a link has a fuzzy match (i.e. not a *dedicated* target match),
1339 let the link point to the corresponding section.
1340 This function also handles the id links, if they have a match in
1342 (goto-char (point-min))
1343 (while (re-search-forward org-bracket-link-regexp nil t
)
1344 (org-if-unprotected-at (1+ (match-beginning 0))
1345 (let* ((org-link-search-must-match-exact-headline t
)
1347 (desc (match-end 2))
1348 (link (org-link-unescape (match-string 1)))
1349 (slink (org-solidify-link-text link
))
1350 found props pos cref
1353 ((= (string-to-char link
) ?
#)
1354 ;; user wants exactly this link
1356 ((cdr (assoc slink target-alist
))
1357 (or (cdr (assoc (assoc slink target-alist
)
1358 org-export-preferred-target-alist
))
1359 (cdr (assoc slink target-alist
))))
1360 ((and (string-match "^id:" link
)
1361 (cdr (assoc (substring link
3) target-alist
))))
1362 ((string-match "^(\\(.*\\))$" link
)
1363 (setq cref
(match-string 1 link
))
1364 (concat "coderef:" cref
))
1365 ((string-match org-link-types-re link
) nil
)
1366 ((or (file-name-absolute-p link
)
1367 (string-match "^\\." link
))
1370 (let ((org-link-search-inhibit-query t
))
1372 (setq found
(condition-case nil
(org-link-search link
)
1375 (or (org-on-heading-p)
1376 (not (eq found
'dedicated
))))
1377 (or (get-text-property (point) 'target
)
1380 (1- (or (previous-single-property-change
1381 (point) 'target
) 0)))
1385 (goto-char (match-beginning 1))
1386 (setq props
(text-properties-at (point)))
1387 (delete-region (match-beginning 1) (match-end 1))
1390 (unless desc
(insert "][" link
))
1391 (add-text-properties pos
(point) props
))))))
1393 (defun org-export-remember-html-container-classes ()
1394 "Store the HTML_CONTAINER_CLASS properties in a text property."
1395 (goto-char (point-min))
1397 (while (re-search-forward
1398 "^[ \t]*:HTML_CONTAINER_CLASS:[ \t]+\\(.+\\)$" nil t
)
1399 (setq class
(match-string 1))
1401 (org-back-to-heading t
)
1402 (put-text-property (point-at-bol) (point-at-eol) 'html-container-class class
)))))
1404 (defvar org-export-format-drawer-function nil
1405 "Function to be called to format the contents of a drawer.
1406 The function must accept three parameters:
1407 NAME the drawer name, like \"PROPERTIES\"
1408 CONTENT the content of the drawer.
1409 You can check the export backend through `org-export-current-backend'.
1410 The function should return the text to be inserted into the buffer.
1411 If this is nil, `org-export-format-drawer' is used as a default.")
1413 (defun org-export-remove-or-extract-drawers (all-drawers exp-drawers
)
1414 "Remove drawers, or extract and format the content.
1415 ALL-DRAWERS is a list of all drawer names valid in the current buffer.
1416 EXP-DRAWERS can be t to keep all drawer contents, or a list of drawers
1417 whose content to keep. Any drawers that are in ALL-DRAWERS but not in
1418 EXP-DRAWERS will be removed."
1419 (goto-char (point-min))
1420 (let ((re (concat "^[ \t]*:\\("
1421 (mapconcat 'identity all-drawers
"\\|")
1423 name beg beg-content eol content
)
1424 (while (re-search-forward re nil t
)
1426 (setq name
(match-string 1))
1427 (setq beg
(match-beginning 0)
1428 beg-content
(1+ (point-at-eol))
1430 (if (not (and (re-search-forward
1431 "^\\([ \t]*:END:[ \t]*\n?\\)\\|^\\*+[ \t]" nil t
)
1434 (goto-char (match-beginning 0))
1435 (and (looking-at ".*\n?") (replace-match ""))
1436 (setq content
(buffer-substring beg-content
(point)))
1437 (delete-region beg
(point))
1438 (when (or (eq exp-drawers t
)
1439 (member name exp-drawers
))
1440 (setq content
(funcall (or org-export-format-drawer-function
1441 'org-export-format-drawer
)
1443 (insert content
)))))))
1445 (defun org-export-format-drawer (name content
)
1446 "Format the content of a drawer as a colon example."
1447 (if (string-match "[ \t]+\\'" content
)
1448 (setq content
(substring content
(match-beginning 0))))
1449 (while (string-match "\\`[ \t]*\n" content
)
1450 (setq content
(substring content
(match-end 0))))
1451 (setq content
(org-remove-indentation content
))
1452 (setq content
(concat ": " (mapconcat 'identity
1453 (org-split-string content
"\n")
1456 (setq content
(concat " : " (upcase name
) "\n" content
))
1457 (org-add-props content nil
'org-protected t
))
1459 (defun org-export-handle-export-tags (select-tags exclude-tags
)
1460 "Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS.
1461 Both arguments are lists of tags.
1462 If any of SELECT-TAGS is found, all trees not marked by a SELECT-TAG
1464 After that, all subtrees that are marked by EXCLUDE-TAGS will be
1466 (remove-text-properties (point-min) (point-max) '(:org-delete t
))
1467 (let* ((re-sel (concat ":\\(" (mapconcat 'regexp-quote
1470 (re-excl (concat ":\\(" (mapconcat 'regexp-quote
1474 (goto-char (point-min))
1475 (when (and select-tags
1477 (concat "^\\*+[ \t].*" re-sel
"[^ \t\n]*[ \t]*$") nil t
))
1478 ;; At least one tree is marked for export, this means
1479 ;; all the unmarked stuff needs to go.
1480 ;; Dig out the trees that should be exported
1481 (goto-char (point-min))
1482 (outline-next-heading)
1484 (put-text-property beg
(point-max) :org-delete t
)
1485 (while (re-search-forward re-sel nil t
)
1486 (when (org-on-heading-p)
1487 (org-back-to-heading)
1488 (remove-text-properties
1489 (max (1- (point)) (point-min))
1490 (setq cont
(save-excursion (org-end-of-subtree t t
)))
1492 (while (and (org-up-heading-safe)
1493 (get-text-property (point) :org-delete
))
1494 (remove-text-properties (max (1- (point)) (point-min))
1495 (point-at-eol) '(:org-delete t
)))
1497 ;; Remove the trees explicitly marked for noexport
1499 (goto-char (point-min))
1500 (while (re-search-forward re-excl nil t
)
1501 (when (org-at-heading-p)
1502 (org-back-to-heading t
)
1504 (org-end-of-subtree t t
)
1505 (delete-region beg
(point))
1506 (when (featurep 'org-inlinetask
)
1507 (org-inlinetask-remove-END-maybe)))))
1508 ;; Remove everything that is now still marked for deletion
1509 (goto-char (point-min))
1510 (while (setq beg
(text-property-any (point-min) (point-max) :org-delete t
))
1511 (setq end
(or (next-single-property-change beg
:org-delete
)
1513 (delete-region beg end
))))
1515 (defun org-export-remove-tasks (keep)
1516 "Remove tasks depending on configuration.
1517 When KEEP is nil, remove all tasks.
1518 When KEEP is `todo', remove the tasks that are DONE.
1519 When KEEP is `done', remove the tasks that are not yet done.
1520 When it is a list of strings, keep only tasks with these TODO keywords."
1521 (when (or (listp keep
) (memq keep
'(todo done nil
)))
1522 (let ((re (concat "^\\*+[ \t]+\\("
1525 (cond ((not keep
) org-todo-keywords-1
)
1526 ((eq keep
'todo
) org-done-keywords
)
1527 ((eq keep
'done
) org-not-done-keywords
)
1529 (org-delete-all keep
(copy-sequence
1530 org-todo-keywords-1
))))
1532 "\\)\\($\\|[ \t]\\)"))
1533 (case-fold-search nil
)
1535 (goto-char (point-min))
1536 (while (re-search-forward re nil t
)
1538 (setq beg
(match-beginning 0))
1539 (org-end-of-subtree t t
)
1540 (if (looking-at "^\\*+[ \t]+END[ \t]*$")
1541 ;; Kill the END line of the inline task
1542 (goto-char (min (point-max) (1+ (match-end 0)))))
1543 (delete-region beg
(point)))))))
1545 (defun org-export-remove-archived-trees (export-archived-trees)
1546 "Remove archived trees.
1547 When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported.
1548 When it is t, the entire archived tree will be exported.
1549 When it is nil the entire tree including the headline will be removed
1551 (let ((re-archive (concat ":" org-archive-tag
":"))
1553 (when (not (eq export-archived-trees t
))
1554 (goto-char (point-min))
1555 (while (re-search-forward re-archive nil t
)
1556 (if (not (org-on-heading-p t
))
1557 (goto-char (point-at-eol))
1558 (beginning-of-line 1)
1559 (setq a
(if export-archived-trees
1560 (1+ (point-at-eol)) (point))
1561 b
(org-end-of-subtree t
))
1562 (if (> b a
) (delete-region a b
)))))))
1564 (defun org-export-remove-headline-metadata (opts)
1565 "Remove meta data from the headline, according to user options."
1566 (let ((re org-complex-heading-regexp
)
1567 (todo (plist-get opts
:todo-keywords
))
1568 (tags (plist-get opts
:tags
))
1569 (pri (plist-get opts
:priority
))
1571 (case-fold-search nil
)
1573 (setq elts
(delq nil
(list 1 (if todo
2) (if pri
3) 4 (if tags
5))))
1574 (when (or (not todo
) (not tags
) (not pri
))
1575 (goto-char (point-min))
1576 (while (re-search-forward re nil t
)
1578 (setq rpl
(mapconcat (lambda (i) (if (match-end i
) (match-string i
) ""))
1580 (replace-match rpl t t
))))))
1582 (defun org-export-remove-timestamps ()
1583 "Remove timestamps and keywords for export."
1584 (goto-char (point-min))
1585 (while (re-search-forward org-maybe-keyword-time-regexp nil t
)
1588 (unless (save-match-data (org-at-table-p))
1590 (beginning-of-line 1)
1591 (if (looking-at "[- \t]*\\(=>[- \t0-9:]*\\)?[ \t]*\n")
1592 (replace-match ""))))))
1594 (defun org-export-remove-clock-lines ()
1595 "Remove clock lines for export."
1596 (goto-char (point-min))
1597 (let ((re (concat "^[ \t]*" org-clock-string
".*\n?")))
1598 (while (re-search-forward re nil t
)
1600 (replace-match "")))))
1602 (defun org-export-protect-quoted-subtrees ()
1603 "Mark quoted subtrees with the protection property."
1604 (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string
"\\>")))
1605 (goto-char (point-min))
1606 (while (re-search-forward re-quote nil t
)
1607 (goto-char (match-beginning 0))
1609 (add-text-properties (point) (org-end-of-subtree t
)
1610 '(org-protected t
)))))
1612 (defun org-export-convert-protected-spaces ()
1613 "Convert strings like \\____ to protected spaces in all backends."
1614 (goto-char (point-min))
1615 (while (re-search-forward "\\\\__+" nil t
)
1616 (org-if-unprotected-1
1620 ((eq org-export-current-backend
'latex
)
1621 (format "\\hspace{%dex}" (- (match-end 0) (match-beginning 0))))
1622 ((eq org-export-current-backend
'html
)
1623 (org-add-props (match-string 0) nil
1624 'org-whitespace
(- (match-end 0) (match-beginning 0))))
1625 ;; ((eq org-export-current-backend 'docbook))
1626 ((eq org-export-current-backend
'ascii
)
1627 (org-add-props (match-string 0) '(org-whitespace t
)))
1628 (t (make-string (- (match-end 0) (match-beginning 0)) ?\
)))
1632 (defun org-export-protect-verbatim ()
1633 "Mark verbatim snippets with the protection property."
1634 (goto-char (point-min))
1635 (while (re-search-forward org-verbatim-re nil t
)
1637 (add-text-properties (match-beginning 4) (match-end 4)
1638 '(org-protected t org-verbatim-emph t
))
1639 (goto-char (1+ (match-end 4))))))
1641 (defun org-export-protect-colon-examples ()
1642 "Protect lines starting with a colon."
1643 (goto-char (point-min))
1644 (let ((re "^[ \t]*:\\([ \t]\\|$\\)") beg
)
1645 (while (re-search-forward re nil t
)
1646 (beginning-of-line 1)
1648 (while (looking-at re
)
1650 (or (eobp) (forward-char 1)))
1651 (add-text-properties beg
(if (bolp) (1- (point)) (point))
1652 '(org-protected t
)))))
1654 (defun org-export-select-backend-specific-text ()
1656 '((docbook "DOCBOOK" "BEGIN_DOCBOOK" "END_DOCBOOK")
1657 (html "HTML" "BEGIN_HTML" "END_HTML")
1658 (beamer "BEAMER" "BEGIN_BEAMER" "END_BEAMER")
1659 (ascii "ASCII" "BEGIN_ASCII" "END_ASCII")
1660 (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
1661 (case-fold-search t
)
1662 fmt beg beg-content end end-content ind
)
1665 (setq fmt
(pop formatters
))
1666 ;; Handle #+backend: stuff
1667 (goto-char (point-min))
1668 (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" (cadr fmt
)
1669 ":[ \t]*\\(.*\\)") nil t
)
1670 (if (not (eq (car fmt
) org-export-current-backend
))
1671 (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
1672 (replace-match "\\1\\2" t
)
1673 (add-text-properties
1674 (point-at-bol) (min (1+ (point-at-eol)) (point-max))
1675 `(org-protected t original-indentation
,ind
))))
1676 ;; Delete #+attr_Backend: stuff of another backend. Those
1677 ;; matching the current backend will be taken care of by
1678 ;; `org-export-attach-captions-and-attributes'
1679 (goto-char (point-min))
1680 (while (re-search-forward (concat "^\\([ \t]*\\)#\\+attr_" (cadr fmt
)
1681 ":[ \t]*\\(.*\\)") nil t
)
1682 (setq ind
(org-get-indentation))
1683 (when (not (eq (car fmt
) org-export-current-backend
))
1684 (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
1685 ;; Handle #+begin_backend and #+end_backend stuff
1686 (goto-char (point-min))
1687 (while (re-search-forward (concat "^[ \t]*#\\+" (caddr fmt
) "\\>.*\n?")
1689 (setq beg
(match-beginning 0) beg-content
(match-end 0))
1690 (setq ind
(save-excursion (goto-char beg
) (org-get-indentation)))
1691 (when (re-search-forward (concat "^[ \t]*#\\+" (cadddr fmt
) "\\>.*\n?")
1693 (setq end
(match-end 0) end-content
(match-beginning 0))
1694 (if (eq (car fmt
) org-export-current-backend
)
1697 (add-text-properties
1698 beg-content end-content
1699 `(org-protected t original-indentation
,ind
))
1700 (delete-region (match-beginning 0) (match-end 0))
1703 (delete-region (point) (1+ (point-at-eol)))))
1704 ;; No, this is for a different backend, kill it
1705 (delete-region beg end
)))))))
1707 (defun org-export-mark-blockquote-verse-center ()
1708 "Mark block quote and verse environments with special cookies.
1709 These special cookies will later be interpreted by the backend."
1711 (let (type t1 ind beg end beg1 end1 content
)
1712 (goto-char (point-min))
1713 (while (re-search-forward
1714 "^\\([ \t]*\\)#\\+\\(begin_\\(\\(block\\)?quote\\|verse\\|center\\)\\>.*\\)"
1716 (setq ind
(length (match-string 1))
1717 type
(downcase (match-string 3))
1718 t1
(if (equal type
"quote") "blockquote" type
))
1719 (setq beg
(match-beginning 0)
1720 beg1
(1+ (match-end 0)))
1721 (when (re-search-forward (concat "^[ \t]*#\\+end_" type
"\\>.*") nil t
)
1722 (setq end1
(1- (match-beginning 0))
1723 end
(+ (point-at-eol) (if (looking-at "\n$") 1 0)))
1724 (setq content
(org-remove-indentation (buffer-substring beg1 end1
)))
1725 (setq content
(concat "ORG-" (upcase t1
) "-START\n"
1727 "ORG-" (upcase t1
) "-END\n"))
1728 (delete-region beg end
)
1729 (insert (org-add-props content nil
'original-indentation ind
))))))
1731 (defun org-export-mark-list-end ()
1732 "Mark all list endings with a special string."
1733 (unless (eq org-export-current-backend
'ascii
)
1736 ;; For each type allowing list export, find every list, remove
1737 ;; ending regexp if needed, and insert org-list-end.
1738 (goto-char (point-min))
1739 (while (re-search-forward (org-item-beginning-re) nil t
)
1740 (when (eq (nth 2 (org-list-context)) e
)
1741 (let* ((struct (org-list-struct))
1742 (bottom (org-list-get-bottom-point struct
))
1743 (top (point-at-bol))
1744 (top-ind (org-list-get-ind top struct
)))
1746 (when (and (not (eq org-list-ending-method
'indent
))
1747 (looking-at org-list-end-re
))
1749 (unless (bolp) (insert "\n"))
1750 ;; As org-list-end is inserted at column 0, it would end
1751 ;; by indentation any list. It can be problematic when
1752 ;; there are lists within lists: the inner list end would
1753 ;; also become the outer list end. To avoid this, text
1754 ;; property `original-indentation' is added, as
1755 ;; `org-list-struct' pays attention to it when reading a
1757 (insert (org-add-props
1758 "ORG-LIST-END-MARKER\n"
1759 (list 'original-indentation top-ind
)))))))
1760 (cons nil org-list-export-context
))))
1762 (defun org-export-mark-list-properties ()
1763 "Mark list with special properties.
1764 These special properties will later be interpreted by the backend."
1767 ;; Mark a list with 3 properties: `list-item' which is
1768 ;; position at beginning of line, `list-struct' which is
1769 ;; list structure, and `list-prevs' which is the alist of
1770 ;; item and its predecessor. Leave point at list ending.
1772 (let* ((struct (org-list-struct))
1773 (top (org-list-get-top-point struct
))
1774 (bottom (org-list-get-bottom-point struct
))
1775 (prevs (org-list-prevs-alist struct
))
1777 ;; Get every item and ending position, without dups and
1778 ;; without bottom point of list.
1782 (unless (memq pos poi
)
1784 (unless (or (= end bottom
) (memq end poi
))
1787 (setq poi
(sort poi
'<))
1788 ;; For every point of interest, mark the whole line with
1789 ;; its position in list.
1793 (add-text-properties (point-at-bol) (point-at-eol)
1794 (list 'list-item
(point-at-bol)
1796 'list-prevs prevs
)))
1798 ;; Take care of bottom point. As babel may have inserted
1799 ;; a new list in buffer, list ending isn't always
1800 ;; marked. Now mark every list ending and add properties
1801 ;; useful to line processing exporters.
1803 (when (or (looking-at "^ORG-LIST-END-MARKER\n")
1804 (and (not (eq org-list-ending-method
'indent
))
1805 (looking-at org-list-end-re
)))
1807 (unless (bolp) (insert "\n"))
1809 (org-add-props "ORG-LIST-END-MARKER\n" (list 'list-item bottom
1811 'list-prevs prevs
)))
1812 ;; Following property is used by LaTeX exporter.
1813 (add-text-properties top
(point) (list 'list-context ctxt
)))))))
1814 ;; Mark lists except for backends not interpreting them.
1815 (unless (eq org-export-current-backend
'ascii
)
1816 (let ((org-list-end-re "^ORG-LIST-END-MARKER\n"))
1819 (goto-char (point-min))
1820 (while (re-search-forward (org-item-beginning-re) nil t
)
1821 (let ((context (nth 2 (org-list-context))))
1823 (funcall mark-list e
)
1824 (put-text-property (point-at-bol) (point-at-eol)
1825 'list-context context
)))))
1826 (cons nil org-list-export-context
))))))
1828 (defun org-export-attach-captions-and-attributes (target-alist)
1829 "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties.
1830 If the next thing following is a table, add the text properties to the first
1831 table line. If it is a link, add it to the line containing the link."
1832 (goto-char (point-min))
1833 (remove-text-properties (point-min) (point-max)
1834 '(org-caption nil org-attributes nil
))
1835 (let ((case-fold-search t
)
1836 (re (concat "^[ \t]*#\\+caption:[ \t]+\\(.*\\)"
1838 "^[ \t]*#\\+attr_" (symbol-name org-export-current-backend
) ":[ \t]+\\(.*\\)"
1840 "^[ \t]*#\\+label:[ \t]+\\(.*\\)"
1842 "^[ \t]*\\(|[^-]\\)"
1844 "^[ \t]*\\[\\[.*\\]\\][ \t]*$"))
1845 cap shortn attr label end
)
1846 (while (re-search-forward re nil t
)
1848 ;; there is a caption
1851 (setq cap
(concat cap
(if cap
" " "") (org-trim (match-string 1))))
1852 (when (string-match "\\[\\(.*\\)\\]{\\(.*\\)}" cap
)
1853 (setq shortn
(match-string 1 cap
)
1854 cap
(match-string 2 cap
)))
1855 (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
1856 ;; there is an attribute
1859 (setq attr
(concat attr
(if attr
" " "") (org-trim (match-string 2))))
1860 (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
1864 (setq label
(org-trim (match-string 3)))
1865 (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
1867 (setq end
(if (match-end 4)
1868 (let ((ee (org-table-end)))
1869 (prog1 (1- (marker-position ee
)) (move-marker ee nil
)))
1871 (add-text-properties (point-at-bol) end
1872 (list 'org-caption cap
1873 'org-caption-shortn shortn
1874 'org-attributes attr
1876 (if label
(push (cons label label
) target-alist
))
1878 (setq cap nil shortn nil attr nil label nil
)))))
1881 (defun org-export-remove-comment-blocks-and-subtrees ()
1882 "Remove the comment environment, and also commented subtrees."
1883 (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string
"\\>"))
1885 ;; Remove comment environment
1886 (goto-char (point-min))
1887 (setq case-fold-search t
)
1888 (while (re-search-forward
1889 "^#\\+begin_comment[ \t]*\n[^\000]*?\n#\\+end_comment\\>.*" nil t
)
1890 (replace-match "" t t
))
1891 ;; Remove subtrees that are commented
1892 (goto-char (point-min))
1893 (setq case-fold-search nil
)
1894 (while (re-search-forward re-commented nil t
)
1895 (goto-char (match-beginning 0))
1896 (delete-region (point) (org-end-of-subtree t
)))))
1898 (defun org-export-handle-comments (commentsp)
1899 "Remove comments, or convert to backend-specific format.
1900 COMMENTSP can be a format string for publishing comments.
1901 When it is nil, all comments will be removed."
1902 (let ((re "^\\(#\\|[ \t]*#\\+ \\)\\(.*\n?\\)")
1904 (goto-char (point-min))
1905 (while (or (looking-at re
)
1906 (re-search-forward re nil t
))
1907 (setq pos
(match-beginning 0))
1908 (if (get-text-property pos
'org-protected
)
1909 (goto-char (1+ pos
))
1911 (not (equal (char-before (match-end 1)) ?
+)))
1912 (progn (add-text-properties
1913 (match-beginning 0) (match-end 0) '(org-protected t
))
1914 (replace-match (org-add-props
1915 (format commentsp
(match-string 2))
1916 nil
'org-protected t
)
1918 (goto-char (1+ pos
))
1920 (goto-char (max (point-min) (1- pos
))))))))
1922 (defun org-export-handle-table-metalines ()
1923 "Remove table specific metalines #+TBLNAME: and #+TBLFM:."
1924 (let ((re "^[ \t]*#\\+TBL\\(NAME\\|FM\\):\\(.*\n?\\)")
1926 (goto-char (point-min))
1927 (while (or (looking-at re
)
1928 (re-search-forward re nil t
))
1929 (setq pos
(match-beginning 0))
1930 (if (get-text-property (match-beginning 1) 'org-protected
)
1931 (goto-char (1+ pos
))
1932 (goto-char (1+ pos
))
1934 (goto-char (max (point-min) (1- pos
)))))))
1936 (defun org-export-mark-radio-links ()
1937 "Find all matches for radio targets and turn them into internal links."
1938 (let ((re-radio (and org-target-link-regexp
1939 (concat "\\([^<]\\)\\(" org-target-link-regexp
"\\)"))))
1940 (goto-char (point-min))
1942 (while (re-search-forward re-radio nil t
)
1945 (or (org-in-regexp org-bracket-link-regexp
)
1946 (org-in-regexp org-plain-link-re
)
1947 (org-in-regexp "<<[^<>]+>>")))
1949 (replace-match "\\1[[\\2]]")))))))
1951 (defun org-store-forced-table-alignment ()
1952 "Find table lines which force alignment, store the results in properties."
1953 (let (line cnt aligns
)
1954 (goto-char (point-min))
1955 (while (re-search-forward "|[ \t]*<[lrc][0-9]*>[ \t]*|" nil t
)
1956 ;; OK, this looks like a table line with an alignment cookie
1958 (setq line
(buffer-substring (point-at-bol) (point-at-eol)))
1959 (when (and (org-at-table-p)
1960 (org-table-cookie-line-p line
))
1961 (setq cnt
0 aligns nil
)
1965 (if (string-match "\\`<\\([lrc]\\)" x
)
1966 (push (cons cnt
(downcase (match-string 1 x
))) aligns
)))
1967 (org-split-string line
"[ \t]*|[ \t]*"))
1968 (add-text-properties (org-table-begin) (org-table-end)
1969 (list 'org-forced-aligns aligns
))))
1970 (goto-char (point-at-eol)))))
1972 (defun org-export-remove-special-table-lines ()
1973 "Remove tables lines that are used for internal purposes.
1974 Also, store forced alignment information found in such lines."
1975 (goto-char (point-min))
1976 (while (re-search-forward "^[ \t]*|" nil t
)
1977 (org-if-unprotected-at (1- (point))
1978 (beginning-of-line 1)
1979 (if (or (looking-at "[ \t]*| *[!_^] *|")
1985 (or (and org-export-table-remove-empty-lines
(= (length f
) 0))
1987 "\\`<\\([0-9]\\|[lrc]\\|[lrc][0-9]+\\)>\\'" f
)))
1988 (org-split-string ;; FIXME, can't we do without splitting???
1989 (buffer-substring (point-at-bol) (point-at-eol))
1990 "[ \t]*|[ \t]*")))))
1991 (delete-region (max (point-min) (1- (point-at-bol)))
1995 (defun org-export-protect-sub-super (s)
1997 (while (string-match "\\([^\\\\]\\)\\([_^]\\)" s
)
1998 (setq s
(replace-match "\\1\\\\\\2" nil nil s
)))
2001 (defun org-export-normalize-links ()
2002 "Convert all links to bracket links, and expand link abbreviations."
2003 (let ((re-plain-link (concat "\\([^[<]\\)" org-plain-link-re
))
2004 (re-angle-link (concat "\\([^[]\\)" org-angle-link-re
))
2006 (goto-char (point-min))
2007 (while (re-search-forward re-plain-link nil t
)
2008 (unless (org-string-match-p
2009 "\\[\\[\\S-+:\\S-*?\\<"
2010 (buffer-substring (point-at-bol) (match-beginning 0)))
2011 (goto-char (1- (match-end 0)))
2012 (org-if-unprotected-at (1+ (match-beginning 0))
2013 (let* ((s (concat (match-string 1)
2014 "[[" (match-string 2) ":" (match-string 3)
2015 "][" (match-string 2) ":" (org-export-protect-sub-super
2018 ;; added 'org-link face to links
2019 (put-text-property 0 (length s
) 'face
'org-link s
)
2020 (replace-match s t t
)))))
2021 (goto-char (point-min))
2022 (while (re-search-forward re-angle-link nil t
)
2023 (goto-char (1- (match-end 0)))
2025 (let* ((s (concat (match-string 1)
2026 "[[" (match-string 2) ":" (match-string 3)
2027 "][" (match-string 2) ":" (org-export-protect-sub-super
2030 (put-text-property 0 (length s
) 'face
'org-link s
)
2031 (replace-match s t t
))))
2032 (goto-char (point-min))
2033 (while (re-search-forward org-bracket-link-regexp nil t
)
2034 (goto-char (1- (match-end 0)))
2035 (setq nodesc
(not (match-end 3)))
2037 (let* ((xx (save-match-data
2039 (org-link-expand-abbrev (match-string 1)))))
2041 "[[" (org-add-props (copy-sequence xx
)
2042 nil
'org-protected t
'org-no-description nodesc
)
2046 (concat "[" (copy-sequence xx
)
2049 (put-text-property 0 (length s
) 'face
'org-link s
)
2050 (replace-match s t t
))))))
2052 (defun org-export-concatenate-multiline-links ()
2053 "Find multi-line links and put it all into a single line.
2054 This is to make sure that the line-processing export backends
2055 can work correctly."
2056 (goto-char (point-min))
2057 (while (re-search-forward "\\(\\(\\[\\|\\]\\)\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\(\\[\\|\\]\\)\\)" nil t
)
2058 (org-if-unprotected-at (match-beginning 1)
2059 (replace-match "\\1 \\3")
2060 (goto-char (match-beginning 0)))))
2062 (defun org-export-concatenate-multiline-emphasis ()
2063 "Find multi-line emphasis and put it all into a single line.
2064 This is to make sure that the line-processing export backends
2065 can work correctly."
2066 (goto-char (point-min))
2067 (while (re-search-forward org-emph-re nil t
)
2068 (if (and (not (= (char-after (match-beginning 3))
2069 (char-after (match-beginning 4))))
2070 (save-excursion (goto-char (match-beginning 0))
2072 (and (not (org-at-table-p))
2073 (not (org-at-heading-p))))))
2075 (subst-char-in-region (match-beginning 0) (match-end 0)
2077 (goto-char (1- (match-end 0))))
2078 (goto-char (1+ (match-beginning 0))))))
2080 (defun org-export-grab-title-from-buffer ()
2081 "Get a title for the current document, from looking at the buffer."
2082 (let ((inhibit-read-only t
))
2084 (goto-char (point-min))
2085 (let ((end (if (looking-at org-outline-regexp
)
2087 (save-excursion (outline-next-heading) (point)))))
2088 (when (re-search-forward "^[ \t]*[^|# \t\r\n].*\n" end t
)
2089 ;; Mark the line so that it will not be exported as normal text.
2091 (add-text-properties (match-beginning 0) (match-end 0)
2092 (list :org-license-to-kill t
)))
2093 ;; Return the title string
2094 (org-trim (match-string 0)))))))
2096 (defun org-export-get-title-from-subtree ()
2097 "Return subtree title and exclude it from export."
2098 (let ((rbeg (region-beginning)) (rend (region-end))
2099 (inhibit-read-only t
) title
)
2102 (when (and (org-at-heading-p)
2103 (>= (org-end-of-subtree t t
) rend
))
2104 ;; This is a subtree, we take the title from the first heading
2106 (looking-at org-todo-line-regexp
)
2107 (setq title
(match-string 3))
2109 (add-text-properties (point) (1+ (point-at-eol))
2110 (list :org-license-to-kill t
)))
2111 (setq title
(or (org-entry-get nil
"EXPORT_TITLE") title
))))
2114 (defun org-solidify-link-text (s &optional alist
)
2115 "Take link text and make a safe target out of it."
2120 (org-split-string s
"[^a-zA-Z0-9_\\.-]+") "-"))
2121 (a (assoc rtn alist
)))
2124 (defun org-get-min-level (lines &optional offset
)
2125 "Get the minimum level in LINES."
2126 (let ((re "^\\(\\*+\\) ") l
)
2128 (while (setq l
(pop lines
))
2129 (if (string-match re l
)
2130 (throw 'exit
(org-tr-level (- (length (match-string 1 l
))
2134 ;; Variable holding the vector with section numbers
2135 (defvar org-section-numbers
(make-vector org-level-max
0))
2137 (defun org-init-section-numbers ()
2138 "Initialize the vector for the section numbers."
2140 (numbers (nreverse (org-split-string "" "\\.")))
2141 (depth (1- (length org-section-numbers
)))
2142 (i depth
) number-string
)
2145 (aset org-section-numbers i
0)
2146 (setq number-string
(or (car numbers
) "0"))
2147 (if (string-match "\\`[A-Z]\\'" number-string
)
2148 (aset org-section-numbers i
2149 (- (string-to-char number-string
) ?A -
1))
2150 (aset org-section-numbers i
(string-to-number number-string
)))
2154 (defun org-section-number (&optional level
)
2155 "Return a string with the current section number.
2156 When LEVEL is non-nil, increase section numbers on that level."
2157 (let* ((depth (1- (length org-section-numbers
)))
2159 (fmts (car org-export-section-number-format
))
2160 (term (cdr org-export-section-number-format
))
2165 (aset org-section-numbers
2166 level
(1+ (aref org-section-numbers level
))))
2167 (setq idx
(1+ level
))
2168 (while (<= idx depth
)
2170 (aset org-section-numbers idx
0))
2171 (setq idx
(1+ idx
))))
2173 (while (<= idx depth
)
2174 (when (> (aref org-section-numbers idx
) 0)
2175 (setq fmt
(or (pop fmts
) fmt
)
2177 n
(aref org-section-numbers idx
)
2179 (concat string sep
(org-number-to-counter n ctype
))
2180 (concat string
".0"))
2182 (setq idx
(1+ idx
)))
2184 (if (string-match "\\`\\([@0]\\.\\)+" string
)
2185 (setq string
(replace-match "" t nil string
)))
2186 (if (string-match "\\(\\.0\\)+\\'" string
)
2187 (setq string
(replace-match "" t nil string
))))
2188 (concat string term
)))
2190 (defun org-number-to-counter (n type
)
2191 "Concert number N to a string counter, according to TYPE.
2192 TYPE must be a string, any of:
2196 I upper case roman numeral
2197 i lower case roman numeral"
2199 ((equal type
"1") (number-to-string n
))
2200 ((equal type
"A") (char-to-string (+ ?A n -
1)))
2201 ((equal type
"a") (char-to-string (+ ?a n -
1)))
2202 ((equal type
"I") (org-number-to-roman n
))
2203 ((equal type
"i") (downcase (org-number-to-roman n
)))
2204 (t (error "Invalid counter type `%s'" type
))))
2206 (defun org-number-to-roman (n)
2207 "Convert integer N into a roman numeral."
2208 (let ((roman '((1000 .
"M") (900 .
"CM") (500 .
"D") (400 .
"CD")
2209 ( 100 .
"C") ( 90 .
"XC") ( 50 .
"L") ( 40 .
"XL")
2210 ( 10 .
"X") ( 9 .
"IX") ( 5 .
"V") ( 4 .
"IV")
2214 (number-to-string n
)
2216 (if (>= n
(caar roman
))
2217 (setq n
(- n
(caar roman
))
2218 res
(concat res
(cdar roman
)))
2224 (defun org-export-preprocess-apply-macros ()
2225 "Replace macro references."
2226 (goto-char (point-min))
2227 (let (sy val key args args2 ind-str s n
)
2228 (while (re-search-forward
2229 "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\(([ \t\n]*\\([^\000]*?\\))\\)?}}}"
2231 (unless (save-match-data (save-excursion
2232 (goto-char (point-at-bol))
2233 (looking-at "[ \t]*#\\+macro")))
2234 ;; Get macro name (KEY), arguments (ARGS), and indentation of
2235 ;; current line (IND-STR) as strings.
2236 (setq key
(downcase (match-string 1))
2237 args
(match-string 3)
2238 ind-str
(save-match-data (save-excursion
2240 (looking-at "^\\([ \t]*\\).*")
2242 ;; When macro is defined, retrieve replacement text in VAL,
2243 ;; and proceed with expansion.
2244 (when (setq val
(or (plist-get org-export-opt-plist
2245 (intern (concat ":macro-" key
)))
2246 (plist-get org-export-opt-plist
2247 (intern (concat ":" key
)))))
2249 ;; If arguments are provided, first retreive them properly
2250 ;; (in ARGS, as a list), then replace them in VAL.
2252 (setq args
(org-split-string args
",") args2 nil
)
2254 (while (string-match "\\\\\\'" (car args
))
2255 ;; Repair bad splits.
2256 (setcar (cdr args
) (concat (substring (car args
) 0 -
1)
2259 (push (pop args
) args2
))
2260 (setq args
(mapcar 'org-trim
(nreverse args2
)))
2262 (while (string-match "\\$\\([0-9]+\\)" val s
)
2263 (setq s
(1+ (match-beginning 0))
2264 n
(string-to-number (match-string 1 val
)))
2265 (and (>= (length args
) n
)
2266 (setq val
(replace-match (nth (1- n
) args
) t t val
)))))
2267 ;; VAL starts with "(eval": it is a sexp, `eval' it.
2268 (when (string-match "\\`(eval\\>" val
)
2269 (setq val
(eval (read val
))))
2270 ;; Ensure VAL is a string (or nil) and that each new line
2271 ;; is indented as the first one.
2273 (mapconcat 'identity
2275 (if (stringp val
) val
(format "%s" val
))
2277 (concat "\n" ind-str
)))))
2278 ;; Eventually do the replacement, if VAL isn't nil. Move
2279 ;; point at beginning of macro for recursive expansions.
2281 (replace-match val t t
)
2282 (goto-char (match-beginning 0))))))))
2284 (defun org-export-apply-macros-in-string (s)
2285 "Apply the macros in string S."
2289 (org-export-preprocess-apply-macros)
2294 (defun org-export-handle-include-files ()
2295 "Include the contents of include files, with proper formatting."
2296 (let ((case-fold-search t
)
2297 params file markup lang start end prefix prefix1 switches all minlevel lines
)
2298 (goto-char (point-min))
2299 (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t
)
2300 (setq params
(read (concat "(" (match-string 1) ")"))
2301 prefix
(org-get-and-remove-property 'params
:prefix
)
2302 prefix1
(org-get-and-remove-property 'params
:prefix1
)
2303 minlevel
(org-get-and-remove-property 'params
:minlevel
)
2304 lines
(org-get-and-remove-property 'params
:lines
)
2305 file
(org-symname-or-string (pop params
))
2306 markup
(org-symname-or-string (pop params
))
2307 lang
(and (member markup
'("src" "SRC"))
2308 (org-symname-or-string (pop params
)))
2309 switches
(mapconcat #'(lambda (x) (format "%s" x
)) params
" ")
2311 (delete-region (match-beginning 0) (match-end 0))
2313 (not (file-exists-p file
))
2314 (not (file-readable-p file
)))
2315 (insert (format "CANNOT INCLUDE FILE %s" file
))
2316 (setq all
(cons file all
))
2318 (if (equal (downcase markup
) "src")
2319 (setq start
(format "#+begin_src %s %s\n"
2320 (or lang
"fundamental")
2323 (setq start
(format "#+begin_%s %s\n" markup switches
)
2324 end
(format "#+end_%s" markup
))))
2325 (insert (or start
""))
2326 (insert (org-get-file-contents (expand-file-name file
)
2327 prefix prefix1 markup minlevel lines
))
2328 (or (bolp) (newline))
2329 (insert (or end
""))))
2332 (defun org-export-handle-include-files-recurse ()
2333 "Recursively include files aborting on circular inclusion."
2334 (let ((now (list org-current-export-file
)) all
)
2336 (setq all
(append now all
))
2337 (setq now
(org-export-handle-include-files))
2340 (mapcar (lambda (el) (when (member el all
) el
)) now
))))
2342 (error "Recursive #+INCLUDE: %S" intersection
))))))
2344 (defun org-get-file-contents (file &optional prefix prefix1 markup minlevel lines
)
2345 "Get the contents of FILE and return them as a string.
2346 If PREFIX is a string, prepend it to each line. If PREFIX1
2347 is a string, prepend it to the first line instead of PREFIX.
2348 If MARKUP, don't protect org-like lines, the exporter will
2349 take care of the block they are in. If LINES is a string
2350 specifying a range of lines, include only those lines ."
2351 (if (stringp markup
) (setq markup
(downcase markup
)))
2353 (insert-file-contents file
)
2355 (let* ((lines (split-string lines
"-"))
2356 (lbeg (string-to-number (car lines
)))
2357 (lend (string-to-number (cadr lines
)))
2358 (beg (if (zerop lbeg
) (point-min)
2359 (goto-char (point-min))
2360 (forward-line (1- lbeg
))
2362 (end (if (zerop lend
) (point-max)
2363 (goto-char (point-min))
2364 (forward-line (1- lend
))
2366 (narrow-to-region beg end
)))
2367 (when (or prefix prefix1
)
2368 (goto-char (point-min))
2370 (insert (or prefix1 prefix
))
2372 (beginning-of-line 2)))
2374 (when (member markup
'("src" "example"))
2375 (goto-char (point-min))
2376 (while (re-search-forward "^\\([*#]\\|[ \t]*#\\+\\)" nil t
)
2377 (goto-char (match-beginning 0))
2381 (dotimes (lvl minlevel
)
2382 (org-map-region 'org-demote
(point-min) (point-max))))
2385 (defun org-get-and-remove-property (listvar prop
)
2386 "Check if the value of LISTVAR contains PROP as a property.
2387 If yes, return the value of that property (i.e. the element following
2388 in the list) and remove property and value from the list in LISTVAR."
2389 (let ((list (symbol-value listvar
)) m v
)
2390 (when (setq m
(member prop list
))
2392 (if (equal (car list
) prop
)
2393 (set listvar
(cddr list
))
2394 (setcdr (nthcdr (- (length list
) (length m
) 1) list
)
2396 (set listvar list
)))
2399 (defun org-symname-or-string (s)
2401 (if s
(symbol-name s
) s
)
2404 ;;; Fontification and line numbers for code examples
2406 (defvar org-export-last-code-line-counter-value
0)
2408 (defun org-export-replace-src-segments-and-examples ()
2409 "Replace source code segments with special code for export."
2410 (setq org-export-last-code-line-counter-value
0)
2411 (let ((case-fold-search t
)
2412 lang code trans opts indent caption
)
2413 (goto-char (point-min))
2414 (while (re-search-forward
2415 "\\(^\\([ \t]*\\)#\\+BEGIN_SRC:?\\([ \t]+\\([^ \t\n]+\\)\\)?\\(.*\\)\n\\([^\000]+?\n\\)[ \t]*#\\+END_SRC.*\n?\\)\\|\\(^\\([ \t]*\\)#\\+BEGIN_EXAMPLE:?\\(?:[ \t]+\\(.*\\)\\)?\n\\([^\000]+?\n\\)[ \t]*#\\+END_EXAMPLE.*\n?\\)"
2418 (if (not (match-string 4))
2419 (error "Source block missing language specification: %s"
2420 (let* ((body (match-string 6))
2421 (nothing (message "body:%s" body
))
2422 (preview (or (and (string-match
2423 "^[ \t]*\\([^\n\r]*\\)" body
)
2424 (match-string 1 body
)) body
)))
2425 (if (> (length preview
) 35)
2426 (concat (substring preview
0 32) "...")
2429 (setq lang
(match-string 4)
2430 opts
(match-string 5)
2431 code
(match-string 6)
2432 indent
(length (match-string 2))
2433 caption
(get-text-property 0 'org-caption
(match-string 0))))
2435 opts
(match-string 9)
2436 code
(match-string 10)
2437 indent
(length (match-string 8))
2438 caption
(get-text-property 0 'org-caption
(match-string 0))))
2440 (setq trans
(org-export-format-source-code-or-example
2441 lang code opts indent caption
))
2442 (replace-match trans t t
))))
2444 (defvar org-export-latex-verbatim-wrap
) ;; defined in org-latex.el
2445 (defvar org-export-latex-listings
) ;; defined in org-latex.el
2446 (defvar org-export-latex-listings-langs
) ;; defined in org-latex.el
2447 (defvar org-export-latex-listings-w-names
) ;; defined in org-latex.el
2448 (defvar org-export-latex-minted-langs
) ;; defined in org-latex.el
2449 (defvar org-export-latex-custom-lang-environments
) ;; defined in org-latex.el
2450 (defvar org-export-latex-listings-options
) ;; defined in org-latex.el
2451 (defvar org-export-latex-minted-options
) ;; defined in org-latex.el
2453 (defun org-remove-formatting-on-newlines-in-region (beg end
)
2454 "Remove formatting on newline characters"
2458 (while (progn (end-of-line) (< (point) end
))
2459 (put-text-property (point) (1+ (point)) 'face nil
)
2462 (defun org-export-format-source-code-or-example
2463 (lang code
&optional opts indent caption
)
2464 "Format CODE from language LANG and return it formatted for export.
2465 If LANG is nil, do not add any fontification.
2466 OPTS contains formatting options, like `-n' for triggering numbering lines,
2467 and `+n' for continuing previous numbering.
2468 Code formatting according to language currently only works for HTML.
2469 Numbering lines works for all three major backends (html, latex, and ascii).
2470 INDENT was the original indentation of the block."
2472 (let (num cont rtn rpllbl keepp textareap preserve-indentp cols rows fmt
)
2473 (setq opts
(or opts
"")
2474 num
(string-match "[-+]n\\>" opts
)
2475 cont
(string-match "\\+n\\>" opts
)
2476 rpllbl
(string-match "-r\\>" opts
)
2477 keepp
(string-match "-k\\>" opts
)
2478 textareap
(string-match "-t\\>" opts
)
2479 preserve-indentp
(or org-src-preserve-indentation
2480 (string-match "-i\\>" opts
))
2481 cols
(if (string-match "-w[ \t]+\\([0-9]+\\)" opts
)
2482 (string-to-number (match-string 1 opts
))
2484 rows
(if (string-match "-h[ \t]+\\([0-9]+\\)" opts
)
2485 (string-to-number (match-string 1 opts
))
2486 (org-count-lines code
))
2487 fmt
(if (string-match "-l[ \t]+\"\\([^\"\n]+\\)\"" opts
)
2488 (match-string 1 opts
)))
2489 (when (and textareap
(eq org-export-current-backend
'html
))
2490 ;; we cannot use numbering or highlighting.
2491 (setq num nil cont nil lang nil
))
2492 (if keepp
(setq rpllbl
'keep
))
2493 (setq rtn
(if preserve-indentp code
(org-remove-indentation code
)))
2494 (when (string-match "^," rtn
)
2495 (setq rtn
(with-temp-buffer
2497 ;; Free up the protected lines
2498 (goto-char (point-min))
2499 (while (re-search-forward "^," nil t
)
2500 (if (or (equal lang
"org")
2502 (looking-at "\\([*#]\\|[ \t]*#\\+\\)")))
2506 ;; Now backend-specific coding
2509 ((eq org-export-current-backend
'docbook
)
2510 (setq rtn
(org-export-number-lines rtn
0 0 num cont rpllbl fmt
))
2511 (concat "\n#+BEGIN_DOCBOOK\n"
2512 (org-add-props (concat "<programlisting><![CDATA["
2514 "]]></programlisting>\n")
2515 '(org-protected t org-example t
))
2517 ((eq org-export-current-backend
'html
)
2518 ;; We are exporting to HTML
2520 (if (featurep 'xemacs
)
2522 (require 'htmlize nil t
))
2523 (when (not (fboundp 'htmlize-region-for-paste
))
2524 ;; we do not have htmlize.el, or an old version of it
2527 "htmlize.el 1.34 or later is needed for source code formatting")))
2530 (let* ((lang-m (when lang
2531 (or (cdr (assoc lang org-src-lang-modes
))
2533 (mode (and lang-m
(intern
2535 (if (symbolp lang-m
)
2536 (symbol-name lang-m
)
2539 (org-inhibit-startup t
)
2540 (org-startup-folded nil
))
2544 (if (functionp mode
)
2547 (font-lock-fontify-buffer)
2548 ;; markup each line separately
2549 (org-remove-formatting-on-newlines-in-region (point-min) (point-max))
2551 (set-buffer-modified-p nil
)
2552 (org-export-htmlize-region-for-paste
2553 (point-min) (point-max))))
2554 (if (string-match "<pre\\([^>]*\\)>\n*" rtn
)
2559 "<div class=\"org-src-container\">"
2561 "<label class=\"org-src-name\">%s</label>"
2565 (format "<pre class=\"src src-%s\">\n" lang
)
2567 (if caption
"</div>" "")))))
2570 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">"
2572 rtn
"</textarea>\n</p>\n"))
2575 (goto-char (point-min))
2576 (while (re-search-forward "[<>&]" nil t
)
2577 (replace-match (cdr (assq (char-before)
2578 '((?
&.
"&")(?
<.
"<")(?
>.
">"))))
2580 (setq rtn
(buffer-string)))
2581 (setq rtn
(concat "<pre class=\"example\">\n" rtn
"</pre>\n"))))
2583 (setq rtn
(org-export-number-lines rtn
1 1 num cont rpllbl fmt
)))
2584 (if (string-match "\\(\\`<[^>]*>\\)\n" rtn
)
2585 (setq rtn
(replace-match "\\1" t nil rtn
)))
2586 (concat "\n#+BEGIN_HTML\n" (org-add-props rtn
'(org-protected t org-example t
)) "\n#+END_HTML\n\n"))
2587 ((eq org-export-current-backend
'latex
)
2588 (setq rtn
(org-export-number-lines rtn
0 0 num cont rpllbl fmt
))
2593 ((and lang org-export-latex-listings
)
2594 (flet ((make-option-string
2596 (concat (first pair
)
2597 (if (> (length (second pair
)) 0)
2598 (concat "=" (second pair
))))))
2599 (let* ((lang-sym (intern lang
))
2600 (minted-p (eq org-export-latex-listings
'minted
))
2601 (listings-p (not minted-p
))
2607 (minted-p org-export-latex-minted-langs
)
2608 (listings-p org-export-latex-listings-langs
))))
2614 org-export-latex-custom-lang-environments
))))
2616 (when (and listings-p
(not custom-environment
))
2620 #'make-option-string
2621 (append org-export-latex-listings-options
2622 `(("language" ,backend-lang
))) ",")))
2623 (when (and caption org-export-latex-listings-w-names
)
2626 (replace-regexp-in-string "_" "\\\\_" caption
)))
2629 (format "\\begin{%s}\n%s\\end{%s}\n"
2630 custom-environment rtn custom-environment
))
2632 (format "\\begin{%s}\n%s\\end{%s}\n"
2633 "lstlisting" rtn
"lstlisting"))
2636 "\\begin{minted}[%s]{%s}\n%s\\end{minted}\n"
2637 (mapconcat #'make-option-string
2638 org-export-latex-minted-options
",")
2639 backend-lang rtn
)))))))
2640 (t (concat (car org-export-latex-verbatim-wrap
)
2641 rtn
(cdr org-export-latex-verbatim-wrap
))))
2642 '(org-protected t org-example t
))
2644 ((eq org-export-current-backend
'ascii
)
2645 ;; This is not HTML or LaTeX, so just make it an example.
2646 (setq rtn
(org-export-number-lines rtn
0 0 num cont rpllbl fmt
))
2647 (concat caption
"\n"
2652 (lambda (l) (concat " " l
))
2653 (org-split-string rtn
"\n")
2656 '(org-protected t org-example t
))
2658 (org-add-props rtn nil
'original-indentation indent
))))
2660 (defun org-export-number-lines (text &optional skip1 skip2 number cont
2661 replace-labels label-format
)
2662 (setq skip1
(or skip1
0) skip2
(or skip2
0))
2663 (if (not cont
) (setq org-export-last-code-line-counter-value
0))
2666 (goto-char (point-max))
2667 (skip-chars-backward " \t\n\r")
2668 (delete-region (point) (point-max))
2669 (beginning-of-line (- 1 skip2
))
2670 (let* ((last (org-current-line))
2671 (n org-export-last-code-line-counter-value
)
2672 (nmax (+ n
(- last skip1
)))
2673 (fmt (format "%%%dd: " (length (number-to-string nmax
))))
2676 ((eq org-export-current-backend
'html
) (format "<span class=\"linenr\">%s</span>"
2678 ((eq org-export-current-backend
'ascii
) fmt
)
2679 ((eq org-export-current-backend
'latex
) fmt
)
2680 ((eq org-export-current-backend
'docbook
) fmt
)
2682 (label-format (or label-format org-coderef-label-format
))
2683 (label-pre (if (string-match "%s" label-format
)
2684 (substring label-format
0 (match-beginning 0))
2686 (label-post (if (string-match "%s" label-format
)
2687 (substring label-format
(match-end 0))
2691 ".*?\\S-.*?\\([ \t]*\\("
2692 (regexp-quote label-pre
)
2693 "\\([-a-zA-Z0-9_ ]+\\)"
2694 (regexp-quote label-post
)
2698 (org-goto-line (1+ skip1
))
2699 (while (and (re-search-forward "^" nil t
) (not (eobp)) (< n nmax
))
2701 (insert (format fm
(incf n
)))
2703 (when (looking-at lbl-re
)
2704 (setq ref
(match-string 3))
2705 (cond ((numberp replace-labels
)
2706 ;; remove labels; use numbers for references when lines
2707 ;; are numbered, use labels otherwise
2708 (delete-region (match-beginning 1) (match-end 1))
2709 (push (cons ref
(if (> n
0) n ref
)) org-export-code-refs
))
2710 ((eq replace-labels
'keep
)
2711 ;; don't remove labels; use numbers for references when
2712 ;; lines are numbered, use labels otherwise
2713 (goto-char (match-beginning 2))
2714 (delete-region (match-beginning 2) (match-end 2))
2715 (insert "(" ref
")")
2716 (push (cons ref
(if (> n
0) n
(concat "(" ref
")")))
2717 org-export-code-refs
))
2719 ;; don't remove labels and don't use numbers for
2721 (goto-char (match-beginning 2))
2722 (delete-region (match-beginning 2) (match-end 2))
2723 (insert "(" ref
")")
2724 (push (cons ref
(concat "(" ref
")")) org-export-code-refs
)))
2725 (when (eq org-export-current-backend
'html
)
2727 (beginning-of-line 1)
2728 (insert (format "<span id=\"coderef-%s\" class=\"coderef-off\">"
2731 (insert "</span>")))))
2732 (setq org-export-last-code-line-counter-value n
)
2733 (goto-char (point-max))
2737 (defun org-search-todo-below (line lines level
)
2738 "Search the subtree below LINE for any TODO entries."
2739 (let ((rest (cdr (memq line lines
)))
2740 (re org-todo-line-regexp
)
2743 (while (setq line
(pop rest
))
2744 (if (string-match re line
)
2746 (setq lv
(- (match-end 1) (match-beginning 1))
2747 todo
(and (match-beginning 2)
2748 (not (member (match-string 2 line
)
2749 org-done-keywords
))))
2751 (if (<= lv level
) (throw 'exit nil
))
2752 (if todo
(throw 'exit t
))))))))
2755 (defun org-export-visible (type arg
)
2756 "Create a copy of the visible part of the current buffer, and export it.
2757 The copy is created in a temporary buffer and removed after use.
2758 TYPE is the final key (as a string) that also selects the export command in
2759 the \\<org-mode-map>\\[org-export] export dispatcher.
2760 As a special case, if the you type SPC at the prompt, the temporary
2761 org-mode file will not be removed but presented to you so that you can
2762 continue to use it. The prefix arg ARG is passed through to the exporting
2766 (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")
2767 (read-char-exclusive))
2768 current-prefix-arg
))
2769 (if (not (member type
'(?a ?n ?u ?\C-a ?b ?\C-b ?h ?D ?x ?\ ?l ?p ?d ?L ?H ?R
)))
2770 (error "Invalid export key"))
2771 (let* ((binding (cdr (assoc type
2773 (?a . org-export-as-ascii
)
2774 (?A . org-export-as-ascii-to-buffer
)
2775 (?n . org-export-as-latin1
)
2776 (?N . org-export-as-latin1-to-buffer
)
2777 (?u . org-export-as-utf8
)
2778 (?U . org-export-as-utf8-to-buffer
)
2779 (?\C-a . org-export-as-ascii
)
2780 (?b . org-export-as-html-and-open
)
2781 (?\C-b . org-export-as-html-and-open
)
2782 (?h . org-export-as-html
)
2783 (?H . org-export-as-html-to-buffer
)
2784 (?R . org-export-region-as-html
)
2785 (?D . org-export-as-docbook
)
2787 (?l . org-export-as-latex
)
2788 (?p . org-export-as-pdf
)
2789 (?d . org-export-as-pdf-and-open
)
2790 (?L . org-export-as-latex-to-buffer
)
2792 (?x . org-export-as-xoxo
)))))
2793 (keepp (equal type ?\
))
2794 (file buffer-file-name
)
2795 (buffer (get-buffer-create "*Org Export Visible*"))
2797 ;; Need to hack the drawers here.
2799 (goto-char (point-min))
2800 (while (re-search-forward org-drawer-regexp nil t
)
2801 (goto-char (match-beginning 1))
2802 (or (outline-invisible-p) (org-flag-drawer nil
))))
2803 (with-current-buffer buffer
(erase-buffer))
2805 (setq s
(goto-char (point-min)))
2806 (while (not (= (point) (point-max)))
2807 (goto-char (org-find-invisible))
2808 (append-to-buffer buffer s
(point))
2809 (setq s
(goto-char (org-find-visible))))
2810 (org-cycle-hide-drawers 'all
)
2811 (goto-char (point-min))
2813 ;; Copy all comment lines to the end, to make sure #+ settings are
2814 ;; still available for the second export step. Kind of a hack, but
2815 ;; does do the trick.
2816 (if (looking-at "#[^\r\n]*")
2817 (append-to-buffer buffer
(match-beginning 0) (1+ (match-end 0))))
2818 (when (re-search-forward "^\\*+[ \t]+" nil t
)
2819 (while (re-search-backward "[\n\r]#[^\n\r]*" nil t
)
2820 (append-to-buffer buffer
(1+ (match-beginning 0))
2821 (min (point-max) (1+ (match-end 0)))))))
2823 (let ((buffer-file-name file
)
2824 (org-inhibit-startup t
))
2827 (unless keepp
(funcall binding arg
))))
2829 (kill-buffer buffer
)
2830 (switch-to-buffer-other-window buffer
)
2831 (goto-char (point-min)))))
2833 (defun org-find-visible ()
2835 (while (and (not (= (point-max) (setq s
(next-overlay-change s
))))
2836 (get-char-property s
'invisible
)))
2838 (defun org-find-invisible ()
2840 (while (and (not (= (point-max) (setq s
(next-overlay-change s
))))
2841 (not (get-char-property s
'invisible
))))
2844 (defvar org-export-htmlized-org-css-url
) ;; defined in org-html.el
2846 (defun org-export-string (string fmt
&optional dir
)
2847 "Export STRING to FMT using existing export facilities.
2848 During export STRING is saved to a temporary file whose location
2849 could vary. Optional argument DIR can be used to force the
2850 directory in which the temporary file is created during export
2851 which can be useful for resolving relative paths. Dir defaults
2852 to the value of `temporary-file-directory'."
2853 (let ((temporary-file-directory (or dir temporary-file-directory
))
2854 (tmp-file (make-temp-file "org-")))
2858 (write-file tmp-file
)
2859 (org-load-modules-maybe)
2860 (unless org-local-vars
2861 (setq org-local-vars
(org-get-local-variables)))
2862 (eval ;; convert to fmt -- mimicing `org-run-like-in-org-mode'
2863 (list 'let org-local-vars
2864 (list (intern (format "org-export-as-%s" fmt
))
2865 nil nil nil
''string t
))))
2866 (delete-file tmp-file
))))
2869 (defun org-export-as-org (arg &optional hidden ext-plist
2870 to-buffer body-only pub-dir
)
2871 "Make a copy with not-exporting stuff removed.
2872 The purpose of this function is to provide a way to export the source
2873 Org file of a webpage in Org format, but with sensitive and/or irrelevant
2874 stuff removed. This command will remove the following:
2876 - archived trees (if the variable `org-export-with-archived-trees' is nil)
2877 - comment blocks and trees starting with the COMMENT keyword
2878 - only trees that are consistent with `org-export-select-tags'
2879 and `org-export-exclude-tags'.
2881 The only arguments that will be used are EXT-PLIST and PUB-DIR,
2882 all the others will be ignored (but are present so that the general
2883 mechanism to call publishing functions will work).
2885 EXT-PLIST is a property list with external parameters overriding
2886 org-mode's default settings, but still inferior to file-local
2887 settings. When PUB-DIR is set, use this as the publishing
2890 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
2892 (org-infile-export-plist)))
2893 (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
2894 (filename (concat (file-name-as-directory
2896 (org-export-directory :org opt-plist
)))
2897 (file-name-sans-extension
2898 (file-name-nondirectory bfname
))
2900 (filename (and filename
2901 (if (equal (file-truename filename
)
2902 (file-truename bfname
))
2903 (concat (file-name-sans-extension filename
)
2905 (file-name-extension filename
))
2907 (backup-inhibited t
)
2908 (buffer (find-file-noselect filename
))
2909 (region (buffer-string))
2912 (switch-to-buffer buffer
)
2915 (let ((org-inhibit-startup t
)) (org-mode))
2916 (org-install-letbind)
2918 ;; Get rid of archived trees
2919 (org-export-remove-archived-trees (plist-get opt-plist
:archived-trees
))
2921 ;; Remove comment environment and comment subtrees
2922 (org-export-remove-comment-blocks-and-subtrees)
2924 ;; Get rid of excluded trees
2925 (org-export-handle-export-tags (plist-get opt-plist
:select-tags
)
2926 (plist-get opt-plist
:exclude-tags
))
2928 (when (or (plist-get opt-plist
:plain-source
)
2929 (not (or (plist-get opt-plist
:plain-source
)
2930 (plist-get opt-plist
:htmlized-source
))))
2931 ;; Either nothing special is requested (default call)
2932 ;; or the plain source is explicitly requested
2935 (when (plist-get opt-plist
:htmlized-source
)
2936 ;; Make the htmlized version
2939 (font-lock-fontify-buffer)
2940 (let* ((htmlize-output-type 'css
)
2941 (newbuf (htmlize-buffer)))
2942 (with-current-buffer newbuf
2943 (when org-export-htmlized-org-css-url
2944 (goto-char (point-min))
2945 (and (re-search-forward
2946 "<style type=\"text/css\">[^\000]*?\n[ \t]*</style>.*"
2950 "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"
2951 org-export-htmlized-org-css-url
)
2953 (write-file (concat filename
".html")))
2954 (kill-buffer newbuf
)))
2955 (set-buffer-modified-p nil
)
2956 (if (equal to-buffer
'string
)
2957 (progn (setq str-ret
(buffer-string))
2958 (kill-buffer (current-buffer))
2960 (kill-buffer (current-buffer))))))
2962 (defvar org-archive-location
) ;; gets loaded with the org-archive require.
2963 (defun org-get-current-options ()
2964 "Return a string with current options as keyword options.
2965 Does include HTML export options as well as TODO and CATEGORY stuff."
2966 (require 'org-archive
)
2975 #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s <:%s
2976 #+OPTIONS: TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s
2978 #+EXPORT_SELECT_TAGS: %s
2979 #+EXPORT_EXCLUDE_TAGS: %s
2986 #+PRIORITIES: %c %c %c
2988 #+STARTUP: %s %s %s %s %s
2994 (buffer-name) (user-full-name) user-mail-address
2995 (format-time-string (substring (car org-time-stamp-formats
) 1 -
1))
2996 org-export-default-language
2997 org-export-headline-levels
2998 org-export-with-section-numbers
3000 org-export-preserve-breaks
3001 org-export-html-expand
3002 org-export-with-fixed-width
3003 org-export-with-tables
3004 org-export-with-sub-superscripts
3005 org-export-with-special-strings
3006 org-export-with-footnotes
3007 org-export-with-emphasize
3008 org-export-with-timestamps
3009 org-export-with-TeX-macros
3010 org-export-with-LaTeX-fragments
3011 org-export-skip-text-before-1st-heading
3012 org-export-with-drawers
3013 org-export-with-todo-keywords
3014 org-export-with-priority
3015 org-export-with-tags
3016 (if (featurep 'org-jsinfo
) (org-infojs-options-inbuffer-template) "")
3017 (mapconcat 'identity org-export-select-tags
" ")
3018 (mapconcat 'identity org-export-exclude-tags
" ")
3019 org-export-html-link-up
3020 org-export-html-link-home
3022 (file-name-sans-extension
3023 (file-name-nondirectory (buffer-file-name (buffer-base-buffer)))))
3025 "TODO FEEDBACK VERIFY DONE"
3026 "Me Jason Marie DONE"
3027 org-highest-priority org-lowest-priority org-default-priority
3028 (mapconcat 'identity org-drawers
" ")
3029 (cdr (assoc org-startup-folded
3030 '((nil .
"showall") (t .
"overview") (content .
"content"))))
3031 (if org-odd-levels-only
"odd" "oddeven")
3032 (if org-hide-leading-stars
"hidestars" "showstars")
3033 (if org-startup-align-all-tables
"align" "noalign")
3034 (cond ((eq org-log-done t
) "logdone")
3035 ((equal org-log-done
'note
) "lognotedone")
3036 ((not org-log-done
) "nologdone"))
3037 (or (mapconcat (lambda (x)
3039 ((equal :startgroup
(car x
)) "{")
3040 ((equal :endgroup
(car x
)) "}")
3041 ((equal :newline
(car x
)) "")
3042 ((cdr x
) (format "%s(%c)" (car x
) (cdr x
)))
3044 (or org-tag-alist
(org-get-buffer-tags)) " ") "")
3045 (mapconcat 'identity org-file-tags
" ")
3046 org-archive-location
3047 "org file:~/org/%s.org"
3051 (defun org-insert-export-options-template ()
3052 "Insert into the buffer a template with information for exporting."
3054 (if (not (bolp)) (newline))
3055 (let ((s (org-get-current-options)))
3056 (and (string-match "#\\+CATEGORY" s
)
3057 (setq s
(substring s
0 (match-beginning 0))))
3060 (defvar org-table-colgroup-info nil
)
3062 (defun org-table-clean-before-export (lines &optional maybe-quoted
)
3063 "Check if the table has a marking column.
3064 If yes remove the column and the special lines."
3065 (setq org-table-colgroup-info nil
)
3068 (lambda (x) (or (string-match "^[ \t]*|-" x
)
3071 "^[ \t]*| *\\\\?\\([\#!$*_^ /]\\) *|"
3072 "^[ \t]*| *\\([\#!$*_^ /]\\) *|")
3075 ;; No special marking column
3077 (setq org-table-clean-did-remove-column nil
)
3082 ((org-table-colgroup-line-p x
)
3083 ;; This line contains colgroup info, extract it
3084 ;; and then discard the line
3085 (setq org-table-colgroup-info
3087 (cond ((member x
'("<" "<")) :start
)
3088 ((member x
'(">" ">")) :end
)
3089 ((member x
'("<>" "<>")) :startend
)
3091 (org-split-string x
"[ \t]*|[ \t]*")))
3093 ((org-table-cookie-line-p x
)
3094 ;; This line contains formatting cookies, discard it
3098 ;; there is a special marking column
3099 (setq org-table-clean-did-remove-column t
)
3104 ((org-table-colgroup-line-p x
)
3105 ;; This line contains colgroup info, extract it
3106 ;; and then discard the line
3107 (setq org-table-colgroup-info
3109 (cond ((member x
'("<" "<")) :start
)
3110 ((member x
'(">" ">")) :end
)
3111 ((member x
'("<>" "<>")) :startend
)
3113 (cdr (org-split-string x
"[ \t]*|[ \t]*"))))
3115 ((org-table-cookie-line-p x
)
3116 ;; This line contains formatting cookies, discard it
3118 ((string-match "^[ \t]*| *[!_^/] *|" x
)
3121 ((or (string-match "^\\([ \t]*\\)|-+\\+" x
)
3122 (string-match "^\\([ \t]*\\)|[^|]*|" x
))
3123 ;; remove the first column
3124 (replace-match "\\1|" t nil x
))))
3127 (defun org-export-cleanup-toc-line (s)
3128 "Remove tags and timestamps from lines going into the toc."
3129 (when (memq org-export-with-tags
'(not-in-toc nil
))
3130 (if (string-match (org-re " +:[[:alnum:]_@#%:]+: *$") s
)
3131 (setq s
(replace-match "" t t s
))))
3132 (when org-export-remove-timestamps-from-toc
3133 (while (string-match org-maybe-keyword-time-regexp s
)
3134 (setq s
(replace-match "" t t s
))))
3135 (while (string-match org-bracket-link-regexp s
)
3136 (setq s
(replace-match (match-string (if (match-end 3) 3 1) s
)
3138 (while (string-match "\\[\\([0-9]\\|fn:[^]]*\\)\\]" s
)
3139 (setq s
(replace-match "" t t s
)))
3143 (defun org-get-text-property-any (pos prop
&optional object
)
3144 (or (get-text-property pos prop object
)
3145 (and (setq pos
(next-single-property-change pos prop object
))
3146 (get-text-property pos prop object
))))
3148 (defun org-export-get-coderef-format (path desc
)
3150 (if (and desc
(string-match
3151 (regexp-quote (concat "(" path
")"))
3153 (replace-match "%s" t t desc
)
3156 (defun org-export-push-to-kill-ring (format)
3157 "Push buffer content to kill ring.
3158 The depends on the variable `org-export-copy-to-kill'."
3159 (when org-export-copy-to-kill-ring
3160 (org-kill-new (buffer-string))
3161 (when (fboundp 'x-set-selection
)
3162 (ignore-errors (x-set-selection 'PRIMARY
(buffer-string)))
3163 (ignore-errors (x-set-selection 'CLIPBOARD
(buffer-string))))
3164 (message "%s export done, pushed to kill ring and clipboard" format
)))
3168 ;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
3170 ;;; org-exp.el ends here