org-mac: Fix link to org-mac-mail-link from org-mac
[worg.git] / exporters / ox-docstrings.org
blobd357df607b06737da35d8a88b3063c8a00c4d7dd
1 #+TITLE:      Docstrings from 'ox.el' 
2 #+AUTHOR:     Thorsten Jolitz
3 #+EMAIL:      tjolitz[at]gmail[dot]com
4 #+OPTIONS:    H:3 num:nil toc:t \n:nil ::t |:t ^:t -:t f:t *:t tex:t d:(HIDE) tags:not-in-toc
5 #+STARTUP:    align fold nodlcheck hidestars oddeven lognotestate hideblocks
6 #+SEQ_TODO:   TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
7 #+TAGS:       Write(w) Update(u) Fix(f) Check(c) noexport(n)
8 #+LANGUAGE:   en
9 #+STYLE:      <style type="text/css">#outline-container-introduction{ clear:both; }</style>
10 #+HTML_LINK_UP:    ../ox-overview.html
11 #+HTML_LINK_HOME:  https://orgmode.org/worg/
12 #+EXCLUDE_TAGS: noexport
14 # This file is released by its authors and contributors under the GNU
15 # Free Documentation license v1.3 or later, code examples are released
16 # under the GNU General Public License v3 or later.
18 [[file:index.org][{Back to Worg's index}]]
20 * ox.el --- Generic Export Engine for Org Mode
22 Copyright (C) 2012, 2013  Free Software Foundation, Inc.
24 Author: Nicolas Goaziou <n.goaziou at gmail dot com>
25 Keywords: outlines, hypermedia, calendar, wp
27 GNU Emacs is free software: you can redistribute it and/or modify
28 it under the terms of the GNU General Public License as published by
29 the Free Software Foundation, either version 3 of the License, or
30 (at your option) any later version.
32 GNU Emacs is distributed in the hope that it will be useful,
33 but WITHOUT ANY WARRANTY; without even the implied warranty of
34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
35 GNU General Public License for more details.
37 You should have received a copy of the GNU General Public License
38 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
40 * Commentary:
42 This library implements a generic export engine for Org, built on
43 its syntactical parser: Org Elements.
45 Besides that parser, the generic exporter is made of three distinct
46 parts:
48 - The communication channel consists in a property list, which is
49   created and updated during the process.  Its use is to offer
50   every piece of information, would it be about initial environment
51   or contextual data, all in a single place.  The exhaustive list
52   of properties is given in "The Communication Channel" section of
53   this file.
55 - The transcoder walks the parse tree, ignores or treat as plain
56   text elements and objects according to export options, and
57   eventually calls back-end specific functions to do the real
58   transcoding, concatenating their return value along the way.
60 - The filter system is activated at the very beginning and the very
61   end of the export process, and each time an element or an object
62   has been converted.  It is the entry point to fine-tune standard
63   output from back-end transcoders.  See "The Filter System"
64   section for more information.
66 The core function is `org-export-as'.  It returns the transcoded
67 buffer as a string.
69 An export back-end is defined with `org-export-define-backend',
70 which defines one mandatory information: his translation table.
71 Its value is an alist whose keys are elements and objects types and
72 values translator functions.  See function's docstring for more
73 information about translators.
75 Optionally, `org-export-define-backend' can also support specific
76 buffer keywords, OPTION keyword's items and filters.  Also refer to
77 function documentation for more information.
79 If the new back-end shares most properties with another one,
80 `org-export-define-derived-backend' can be used to simplify the
81 process.
83 Any back-end can define its own variables.  Among them, those
84 customizable should belong to the `org-export-BACKEND' group.
86 Tools for common tasks across back-ends are implemented in the
87 following part of the file.
89 Then, a wrapper macro for asynchronous export,
90 `org-export-async-start', along with tools to display results. are
91 given in the penultimate part.
93 Eventually, a dispatcher (`org-export-dispatch') for standard
94 back-ends is provided in the last one.
96 * Code:
98 #+begin_src emacs-lisp
99 (eval-when-compile (require 'cl))
100 (require 'org-element)
101 (require 'org-macro)
102 (require 'ob-exp)
104 (declare-function org-publish "ox-publish" (project &optional force async))
105 (declare-function org-publish-all "ox-publish" (&optional force async))
106 (declare-function
107  org-publish-current-file "ox-publish" (&optional force async))
108 (declare-function org-publish-current-project "ox-publish"
109                   (&optional force async))
111 (defvar org-publish-project-alist)
112 (defvar org-table-number-fraction)
113 (defvar org-table-number-regexp)
116 #+end_src
118 * Internal Variables
120 Among internal variables, the most important is
121 `org-export-options-alist'.  This variable define the global export
122 options, shared between every exporter, and how they are acquired.
124 #+begin_src emacs-lisp
125 (defconst org-export-max-depth 19
126   "Maximum nesting depth for headlines, counting from 0.")
128 (defconst org-export-options-alist
129   '((:author "AUTHOR" nil user-full-name t)
130     (:creator "CREATOR" nil org-export-creator-string)
131     (:date "DATE" nil nil t)
132     (:description "DESCRIPTION" nil nil newline)
133     (:email "EMAIL" nil user-mail-address t)
134     (:exclude-tags "EXCLUDE_TAGS" nil org-export-exclude-tags split)
135     (:headline-levels nil "H" org-export-headline-levels)
136     (:keywords "KEYWORDS" nil nil space)
137     (:language "LANGUAGE" nil org-export-default-language t)
138     (:preserve-breaks nil "\\n" org-export-preserve-breaks)
139     (:section-numbers nil "num" org-export-with-section-numbers)
140     (:select-tags "SELECT_TAGS" nil org-export-select-tags split)
141     (:time-stamp-file nil "timestamp" org-export-time-stamp-file)
142     (:title "TITLE" nil org-export--default-title space)
143     (:with-archived-trees nil "arch" org-export-with-archived-trees)
144     (:with-author nil "author" org-export-with-author)
145     (:with-clocks nil "c" org-export-with-clocks)
146     (:with-creator nil "creator" org-export-with-creator)
147     (:with-date nil "date" org-export-with-date)
148     (:with-drawers nil "d" org-export-with-drawers)
149     (:with-email nil "email" org-export-with-email)
150     (:with-emphasize nil "*" org-export-with-emphasize)
151     (:with-entities nil "e" org-export-with-entities)
152     (:with-fixed-width nil ":" org-export-with-fixed-width)
153     (:with-footnotes nil "f" org-export-with-footnotes)
154     (:with-inlinetasks nil "inline" org-export-with-inlinetasks)
155     (:with-latex nil "tex" org-export-with-latex)
156     (:with-planning nil "p" org-export-with-planning)
157     (:with-priority nil "pri" org-export-with-priority)
158     (:with-smart-quotes nil "'" org-export-with-smart-quotes)
159     (:with-special-strings nil "-" org-export-with-special-strings)
160     (:with-statistics-cookies nil "stat" org-export-with-statistics-cookies)
161     (:with-sub-superscript nil "^" org-export-with-sub-superscripts)
162     (:with-toc nil "toc" org-export-with-toc)
163     (:with-tables nil "|" org-export-with-tables)
164     (:with-tags nil "tags" org-export-with-tags)
165     (:with-tasks nil "tasks" org-export-with-tasks)
166     (:with-timestamps nil "<" org-export-with-timestamps)
167     (:with-todo-keywords nil "todo" org-export-with-todo-keywords))
168   "Alist between export properties and ways to set them.
170 The CAR of the alist is the property name, and the CDR is a list
171 like (KEYWORD OPTION DEFAULT BEHAVIOUR) where:
173 KEYWORD is a string representing a buffer keyword, or nil.  Each
174   property defined this way can also be set, during subtree
175   export, through a headline property named after the keyword
176   with the \"EXPORT_\" prefix (i.e. DATE keyword and EXPORT_DATE
177   property).
178 OPTION is a string that could be found in an #+OPTIONS: line.
179 DEFAULT is the default value for the property.
180 BEHAVIOUR determines how Org should handle multiple keywords for
181   the same property.  It is a symbol among:
182   nil       Keep old value and discard the new one.
183   t         Replace old value with the new one.
184   `space'   Concatenate the values, separating them with a space.
185   `newline' Concatenate the values, separating them with
186             a newline.
187   `split'   Split values at white spaces, and cons them to the
188             previous list.
190 Values set through KEYWORD and OPTION have precedence over
191 DEFAULT.
193 All these properties should be back-end agnostic.  Back-end
194 specific properties are set through `org-export-define-backend'.
195 Properties redefined there have precedence over these.")
197 (defconst org-export-special-keywords '("FILETAGS" "SETUPFILE" "OPTIONS")
198   "List of in-buffer keywords that require special treatment.
199 These keywords are not directly associated to a property.  The
200 way they are handled must be hard-coded into
201 `org-export--get-inbuffer-options' function.")
203 (defconst org-export-filters-alist
204   '((:filter-bold . org-export-filter-bold-functions)
205     (:filter-babel-call . org-export-filter-babel-call-functions)
206     (:filter-center-block . org-export-filter-center-block-functions)
207     (:filter-clock . org-export-filter-clock-functions)
208     (:filter-code . org-export-filter-code-functions)
209     (:filter-comment . org-export-filter-comment-functions)
210     (:filter-comment-block . org-export-filter-comment-block-functions)
211     (:filter-diary-sexp . org-export-filter-diary-sexp-functions)
212     (:filter-drawer . org-export-filter-drawer-functions)
213     (:filter-dynamic-block . org-export-filter-dynamic-block-functions)
214     (:filter-entity . org-export-filter-entity-functions)
215     (:filter-example-block . org-export-filter-example-block-functions)
216     (:filter-export-block . org-export-filter-export-block-functions)
217     (:filter-export-snippet . org-export-filter-export-snippet-functions)
218     (:filter-final-output . org-export-filter-final-output-functions)
219     (:filter-fixed-width . org-export-filter-fixed-width-functions)
220     (:filter-footnote-definition . org-export-filter-footnote-definition-functions)
221     (:filter-footnote-reference . org-export-filter-footnote-reference-functions)
222     (:filter-headline . org-export-filter-headline-functions)
223     (:filter-horizontal-rule . org-export-filter-horizontal-rule-functions)
224     (:filter-inline-babel-call . org-export-filter-inline-babel-call-functions)
225     (:filter-inline-src-block . org-export-filter-inline-src-block-functions)
226     (:filter-inlinetask . org-export-filter-inlinetask-functions)
227     (:filter-italic . org-export-filter-italic-functions)
228     (:filter-item . org-export-filter-item-functions)
229     (:filter-keyword . org-export-filter-keyword-functions)
230     (:filter-latex-environment . org-export-filter-latex-environment-functions)
231     (:filter-latex-fragment . org-export-filter-latex-fragment-functions)
232     (:filter-line-break . org-export-filter-line-break-functions)
233     (:filter-link . org-export-filter-link-functions)
234     (:filter-node-property . org-export-filter-node-property-functions)
235     (:filter-options . org-export-filter-options-functions)
236     (:filter-paragraph . org-export-filter-paragraph-functions)
237     (:filter-parse-tree . org-export-filter-parse-tree-functions)
238     (:filter-plain-list . org-export-filter-plain-list-functions)
239     (:filter-plain-text . org-export-filter-plain-text-functions)
240     (:filter-planning . org-export-filter-planning-functions)
241     (:filter-property-drawer . org-export-filter-property-drawer-functions)
242     (:filter-quote-block . org-export-filter-quote-block-functions)
243     (:filter-quote-section . org-export-filter-quote-section-functions)
244     (:filter-radio-target . org-export-filter-radio-target-functions)
245     (:filter-section . org-export-filter-section-functions)
246     (:filter-special-block . org-export-filter-special-block-functions)
247     (:filter-src-block . org-export-filter-src-block-functions)
248     (:filter-statistics-cookie . org-export-filter-statistics-cookie-functions)
249     (:filter-strike-through . org-export-filter-strike-through-functions)
250     (:filter-subscript . org-export-filter-subscript-functions)
251     (:filter-superscript . org-export-filter-superscript-functions)
252     (:filter-table . org-export-filter-table-functions)
253     (:filter-table-cell . org-export-filter-table-cell-functions)
254     (:filter-table-row . org-export-filter-table-row-functions)
255     (:filter-target . org-export-filter-target-functions)
256     (:filter-timestamp . org-export-filter-timestamp-functions)
257     (:filter-underline . org-export-filter-underline-functions)
258     (:filter-verbatim . org-export-filter-verbatim-functions)
259     (:filter-verse-block . org-export-filter-verse-block-functions))
260   "Alist between filters properties and initial values.
262 The key of each association is a property name accessible through
263 the communication channel.  Its value is a configurable global
264 variable defining initial filters.
266 This list is meant to install user specified filters.  Back-end
267 developers may install their own filters using
268 `org-export-define-backend'.  Filters defined there will always
269 be prepended to the current list, so they always get applied
270 first.")
272 (defconst org-export-default-inline-image-rule
273   `(("file" .
274      ,(format "\\.%s\\'"
275               (regexp-opt
276                '("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
277                  "xpm" "pbm" "pgm" "ppm") t))))
278   "Default rule for link matching an inline image.
279 This rule applies to links with no description.  By default, it
280 will be considered as an inline image if it targets a local file
281 whose extension is either \"png\", \"jpeg\", \"jpg\", \"gif\",
282 \"tiff\", \"tif\", \"xbm\", \"xpm\", \"pbm\", \"pgm\" or \"ppm\".
283 See `org-export-inline-image-p' for more information about
284 rules.")
286 (defvar org-export-async-debug nil
287   "Non-nil means asynchronous export process should leave data behind.
289 This data is found in the appropriate \"*Org Export Process*\"
290 buffer, and in files prefixed with \"org-export-process\" and
291 located in `temporary-file-directory'.
293 When non-nil, it will also set `debug-on-error' to a non-nil
294 value in the external process.")
296 (defvar org-export-stack-contents nil
297   "Record asynchronously generated export results and processes.
298 This is an alist: its CAR is the source of the
299 result (destination file or buffer for a finished process,
300 original buffer for a running one) and its CDR is a list
301 containing the back-end used, as a symbol, and either a process
302 or the time at which it finished.  It is used to build the menu
303 from `org-export-stack'.")
305 (defvar org-export-registered-backends nil
306   "List of backends currently available in the exporter.
308 A backend is stored as a list where CAR is its name, as a symbol,
309 and CDR is a plist with the following properties:
310 `:filters-alist', `:menu-entry', `:options-alist' and
311 `:translate-alist'.
313 This variable is set with `org-export-define-backend' and
314 `org-export-define-derived-backend' functions.")
316 (defvar org-export-dispatch-last-action nil
317   "Last command called from the dispatcher.
318 The value should be a list.  Its CAR is the action, as a symbol,
319 and its CDR is a list of export options.")
321 (defvar org-export-dispatch-last-position (make-marker)
322   "The position where the last export command was created using the dispatcher.
323 This marker will be used with `C-u C-c C-e' to make sure export repetition
324 uses the same subtree if the previous command was restricted to a subtree.")
326 #+end_src
328 * User-configurable Variables
330 Configuration for the masses.
332 They should never be accessed directly, as their value is to be
333 stored in a property list (cf. `org-export-options-alist').
334 Back-ends will read their value from there instead.
336 #+begin_src emacs-lisp
337 (defgroup org-export nil
338   "Options for exporting Org mode files."
339   :tag "Org Export"
340   :group 'org)
342 (defgroup org-export-general nil
343   "General options for export engine."
344   :tag "Org Export General"
345   :group 'org-export)
347 (defcustom org-export-with-archived-trees 'headline
348   "Whether sub-trees with the ARCHIVE tag should be exported.
350 This can have three different values:
351 nil         Do not export, pretend this tree is not present.
352 t           Do export the entire tree.
353 `headline'  Only export the headline, but skip the tree below it.
355 This option can also be set with the OPTIONS keyword,
356 e.g. \"arch:nil\"."
357   :group 'org-export-general
358   :type '(choice
359           (const :tag "Not at all" nil)
360           (const :tag "Headline only" headline)
361           (const :tag "Entirely" t)))
363 (defcustom org-export-with-author t
364   "Non-nil means insert author name into the exported file.
365 This option can also be set with the OPTIONS keyword,
366 e.g. \"author:nil\"."
367   :group 'org-export-general
368   :type 'boolean)
370 (defcustom org-export-with-clocks nil
371   "Non-nil means export CLOCK keywords.
372 This option can also be set with the OPTIONS keyword,
373 e.g. \"c:t\"."
374   :group 'org-export-general
375   :type 'boolean)
377 (defcustom org-export-with-creator 'comment
378   "Non-nil means the postamble should contain a creator sentence.
380 The sentence can be set in `org-export-creator-string' and
381 defaults to \"Generated by Org mode XX in Emacs XXX.\".
383 If the value is `comment' insert it as a comment."
384   :group 'org-export-general
385   :type '(choice
386           (const :tag "No creator sentence" nil)
387           (const :tag "Sentence as a comment" 'comment)
388           (const :tag "Insert the sentence" t)))
390 (defcustom org-export-with-date t
391   "Non-nil means insert date in the exported document.
392 This option can also be set with the OPTIONS keyword,
393 e.g. \"date:nil\"."
394   :group 'org-export-general
395   :type 'boolean)
397 (defcustom org-export-date-timestamp-format nil
398   "Time-stamp format string to use for DATE keyword.
400 The format string, when specified, only applies if date consists
401 in a single time-stamp.  Otherwise its value will be ignored.
403 See `format-time-string' for details on how to build this
404 string."
405   :group 'org-export-general
406   :type '(choice
407           (string :tag "Time-stamp format string")
408           (const :tag "No format string" nil)))
410 (defcustom org-export-creator-string
411   (format "Emacs %s (Org mode %s)"
412           emacs-version
413           (if (fboundp 'org-version) (org-version) "unknown version"))
414   "Information about the creator of the document.
415 This option can also be set on with the CREATOR keyword."
416   :group 'org-export-general
417   :type '(string :tag "Creator string"))
419 (defcustom org-export-with-drawers '(not "LOGBOOK")
420   "Non-nil means export contents of standard drawers.
422 When t, all drawers are exported.  This may also be a list of
423 drawer names to export.  If that list starts with `not', only
424 drawers with such names will be ignored.
426 This variable doesn't apply to properties drawers.
428 This option can also be set with the OPTIONS keyword,
429 e.g. \"d:nil\"."
430   :group 'org-export-general
431   :version "24.4"
432   :package-version '(Org . "8.0")
433   :type '(choice
434           (const :tag "All drawers" t)
435           (const :tag "None" nil)
436           (repeat :tag "Selected drawers"
437                   (string :tag "Drawer name"))
438           (list :tag "Ignored drawers"
439                 (const :format "" not)
440                 (repeat :tag "Specify names of drawers to ignore during export"
441                         :inline t
442                         (string :tag "Drawer name")))))
444 (defcustom org-export-with-email nil
445   "Non-nil means insert author email into the exported file.
446 This option can also be set with the OPTIONS keyword,
447 e.g. \"email:t\"."
448   :group 'org-export-general
449   :type 'boolean)
451 (defcustom org-export-with-emphasize t
452   "Non-nil means interpret *word*, /word/, _word_ and +word+.
454 If the export target supports emphasizing text, the word will be
455 typeset in bold, italic, with an underline or strike-through,
456 respectively.
458 This option can also be set with the OPTIONS keyword,
459 e.g. \"*:nil\"."
460   :group 'org-export-general
461   :type 'boolean)
463 (defcustom org-export-exclude-tags '("noexport")
464   "Tags that exclude a tree from export.
466 All trees carrying any of these tags will be excluded from
467 export.  This is without condition, so even subtrees inside that
468 carry one of the `org-export-select-tags' will be removed.
470 This option can also be set with the EXCLUDE_TAGS keyword."
471   :group 'org-export-general
472   :type '(repeat (string :tag "Tag")))
474 (defcustom org-export-with-fixed-width t
475   "Non-nil means lines starting with \":\" will be in fixed width font.
477 This can be used to have pre-formatted text, fragments of code
478 etc.  For example:
479   : ;; Some Lisp examples
480   : (while (defc cnt)
481   :   (ding))
482 will be looking just like this in also HTML.  See also the QUOTE
483 keyword.  Not all export backends support this.
485 This option can also be set with the OPTIONS keyword,
486 e.g. \"::nil\"."
487   :group 'org-export-general
488   :type 'boolean)
490 (defcustom org-export-with-footnotes t
491   "Non-nil means Org footnotes should be exported.
492 This option can also be set with the OPTIONS keyword,
493 e.g. \"f:nil\"."
494   :group 'org-export-general
495   :type 'boolean)
497 (defcustom org-export-with-latex t
498   "Non-nil means process LaTeX environments and fragments.
500 This option can also be set with the OPTIONS line,
501 e.g. \"tex:verbatim\".  Allowed values are:
503 nil         Ignore math snippets.
504 `verbatim'  Keep everything in verbatim.
505 t           Allow export of math snippets."
506   :group 'org-export-general
507   :version "24.4"
508   :package-version '(Org . "8.0")
509   :type '(choice
510           (const :tag "Do not process math in any way" nil)
511           (const :tag "Interpret math snippets" t)
512           (const :tag "Leave math verbatim" verbatim)))
514 (defcustom org-export-headline-levels 3
515   "The last level which is still exported as a headline.
517 Inferior levels will usually produce itemize or enumerate lists
518 when exported, but back-end behaviour may differ.
520 This option can also be set with the OPTIONS keyword,
521 e.g. \"H:2\"."
522   :group 'org-export-general
523   :type 'integer)
525 (defcustom org-export-default-language "en"
526   "The default language for export and clocktable translations, as a string.
527 This may have an association in
528 `org-clock-clocktable-language-setup'.  This option can also be
529 set with the LANGUAGE keyword."
530   :group 'org-export-general
531   :type '(string :tag "Language"))
533 (defcustom org-export-preserve-breaks nil
534   "Non-nil means preserve all line breaks when exporting.
535 This option can also be set with the OPTIONS keyword,
536 e.g. \"\\n:t\"."
537   :group 'org-export-general
538   :type 'boolean)
540 (defcustom org-export-with-entities t
541   "Non-nil means interpret entities when exporting.
543 For example, HTML export converts \\alpha to &alpha; and \\AA to
544 &Aring;.
546 For a list of supported names, see the constant `org-entities'
547 and the user option `org-entities-user'.
549 This option can also be set with the OPTIONS keyword,
550 e.g. \"e:nil\"."
551   :group 'org-export-general
552   :type 'boolean)
554 (defcustom org-export-with-inlinetasks t
555   "Non-nil means inlinetasks should be exported.
556 This option can also be set with the OPTIONS keyword,
557 e.g. \"inline:nil\"."
558   :group 'org-export-general
559   :version "24.4"
560   :package-version '(Org . "8.0")
561   :type 'boolean)
563 (defcustom org-export-with-planning nil
564   "Non-nil means include planning info in export.
566 Planning info is the line containing either SCHEDULED:,
567 DEADLINE:, CLOSED: time-stamps, or a combination of them.
569 This option can also be set with the OPTIONS keyword,
570 e.g. \"p:t\"."
571   :group 'org-export-general
572   :version "24.4"
573   :package-version '(Org . "8.0")
574   :type 'boolean)
576 (defcustom org-export-with-priority nil
577   "Non-nil means include priority cookies in export.
578 This option can also be set with the OPTIONS keyword,
579 e.g. \"pri:t\"."
580   :group 'org-export-general
581   :type 'boolean)
583 (defcustom org-export-with-section-numbers t
584   "Non-nil means add section numbers to headlines when exporting.
586 When set to an integer n, numbering will only happen for
587 headlines whose relative level is higher or equal to n.
589 This option can also be set with the OPTIONS keyword,
590 e.g. \"num:t\"."
591   :group 'org-export-general
592   :type 'boolean)
594 (defcustom org-export-select-tags '("export")
595   "Tags that select a tree for export.
597 If any such tag is found in a buffer, all trees that do not carry
598 one of these tags will be ignored during export.  Inside trees
599 that are selected like this, you can still deselect a subtree by
600 tagging it with one of the `org-export-exclude-tags'.
602 This option can also be set with the SELECT_TAGS keyword."
603   :group 'org-export-general
604   :type '(repeat (string :tag "Tag")))
606 (defcustom org-export-with-smart-quotes nil
607   "Non-nil means activate smart quotes during export.
608 This option can also be set with the OPTIONS keyword,
609 e.g., \"':t\".
611 When setting this to non-nil, you need to take care of
612 using the correct Babel package when exporting to LaTeX.
613 E.g., you can load Babel for french like this:
615 #+LATEX_HEADER: \\usepackage[french]{babel}"
616   :group 'org-export-general
617   :version "24.4"
618   :package-version '(Org . "8.0")
619   :type 'boolean)
621 (defcustom org-export-with-special-strings t
622   "Non-nil means interpret \"\\-\", \"--\" and \"---\" for export.
624 When this option is turned on, these strings will be exported as:
626    Org     HTML     LaTeX    UTF-8
627   -----+----------+--------+-------
628    \\-    &shy;      \\-
629    --    &ndash;    --         –
630    ---   &mdash;    ---        —
631    ...   &hellip;   \\ldots     …
633 This option can also be set with the OPTIONS keyword,
634 e.g. \"-:nil\"."
635   :group 'org-export-general
636   :type 'boolean)
638 (defcustom org-export-with-statistics-cookies t
639   "Non-nil means include statistics cookies in export.
640 This option can also be set with the OPTIONS keyword,
641 e.g. \"stat:nil\""
642   :group 'org-export-general
643   :version "24.4"
644   :package-version '(Org . "8.0")
645   :type 'boolean)
647 (defcustom org-export-with-sub-superscripts t
648   "Non-nil means interpret \"_\" and \"^\" for export.
650 When this option is turned on, you can use TeX-like syntax for
651 sub- and superscripts.  Several characters after \"_\" or \"^\"
652 will be considered as a single item - so grouping with {} is
653 normally not needed.  For example, the following things will be
654 parsed as single sub- or superscripts.
656  10^24   or   10^tau     several digits will be considered 1 item.
657  10^-12  or   10^-tau    a leading sign with digits or a word
658  x^2-y^3                 will be read as x^2 - y^3, because items are
659                          terminated by almost any nonword/nondigit char.
660  x_{i^2} or   x^(2-i)    braces or parenthesis do grouping.
662 Still, ambiguity is possible - so when in doubt use {} to enclose
663 the sub/superscript.  If you set this variable to the symbol
664 `{}', the braces are *required* in order to trigger
665 interpretations as sub/superscript.  This can be helpful in
666 documents that need \"_\" frequently in plain text.
668 This option can also be set with the OPTIONS keyword,
669 e.g. \"^:nil\"."
670   :group 'org-export-general
671   :type '(choice
672           (const :tag "Interpret them" t)
673           (const :tag "Curly brackets only" {})
674           (const :tag "Do not interpret them" nil)))
676 (defcustom org-export-with-toc t
677   "Non-nil means create a table of contents in exported files.
679 The TOC contains headlines with levels up
680 to`org-export-headline-levels'.  When an integer, include levels
681 up to N in the toc, this may then be different from
682 `org-export-headline-levels', but it will not be allowed to be
683 larger than the number of headline levels.  When nil, no table of
684 contents is made.
686 This option can also be set with the OPTIONS keyword,
687 e.g. \"toc:nil\" or \"toc:3\"."
688   :group 'org-export-general
689   :type '(choice
690           (const :tag "No Table of Contents" nil)
691           (const :tag "Full Table of Contents" t)
692           (integer :tag "TOC to level")))
694 (defcustom org-export-with-tables t
695   "If non-nil, lines starting with \"|\" define a table.
696 For example:
698   | Name        | Address  | Birthday  |
699   |-------------+----------+-----------|
700   | Arthur Dent | England  | 29.2.2100 |
702 This option can also be set with the OPTIONS keyword,
703 e.g. \"|:nil\"."
704   :group 'org-export-general
705   :type 'boolean)
707 (defcustom org-export-with-tags t
708   "If nil, do not export tags, just remove them from headlines.
710 If this is the symbol `not-in-toc', tags will be removed from
711 table of contents entries, but still be shown in the headlines of
712 the document.
714 This option can also be set with the OPTIONS keyword,
715 e.g. \"tags:nil\"."
716   :group 'org-export-general
717   :type '(choice
718           (const :tag "Off" nil)
719           (const :tag "Not in TOC" not-in-toc)
720           (const :tag "On" t)))
722 (defcustom org-export-with-tasks t
723   "Non-nil means include TODO items for export.
725 This may have the following values:
726 t                    include tasks independent of state.
727 `todo'               include only tasks that are not yet done.
728 `done'               include only tasks that are already done.
729 nil                  ignore all tasks.
730 list of keywords     include tasks with these keywords.
732 This option can also be set with the OPTIONS keyword,
733 e.g. \"tasks:nil\"."
734   :group 'org-export-general
735   :type '(choice
736           (const :tag "All tasks" t)
737           (const :tag "No tasks" nil)
738           (const :tag "Not-done tasks" todo)
739           (const :tag "Only done tasks" done)
740           (repeat :tag "Specific TODO keywords"
741                   (string :tag "Keyword"))))
743 (defcustom org-export-time-stamp-file t
744   "Non-nil means insert a time stamp into the exported file.
745 The time stamp shows when the file was created. This option can
746 also be set with the OPTIONS keyword, e.g. \"timestamp:nil\"."
747   :group 'org-export-general
748   :type 'boolean)
750 (defcustom org-export-with-timestamps t
751   "Non nil means allow timestamps in export.
753 It can be set to any of the following values:
754   t          export all timestamps.
755   `active'   export active timestamps only.
756   `inactive' export inactive timestamps only.
757   nil        do not export timestamps
759 This only applies to timestamps isolated in a paragraph
760 containing only timestamps.  Other timestamps are always
761 exported.
763 This option can also be set with the OPTIONS keyword, e.g.
764 \"<:nil\"."
765   :group 'org-export-general
766   :type '(choice
767           (const :tag "All timestamps" t)
768           (const :tag "Only active timestamps" active)
769           (const :tag "Only inactive timestamps" inactive)
770           (const :tag "No timestamp" nil)))
772 (defcustom org-export-with-todo-keywords t
773   "Non-nil means include TODO keywords in export.
774 When nil, remove all these keywords from the export.  This option
775 can also be set with the OPTIONS keyword, e.g.  \"todo:nil\"."
776   :group 'org-export-general
777   :type 'boolean)
779 (defcustom org-export-allow-bind-keywords nil
780   "Non-nil means BIND keywords can define local variable values.
781 This is a potential security risk, which is why the default value
782 is nil.  You can also allow them through local buffer variables."
783   :group 'org-export-general
784   :version "24.4"
785   :package-version '(Org . "8.0")
786   :type 'boolean)
788 (defcustom org-export-snippet-translation-alist nil
789   "Alist between export snippets back-ends and exporter back-ends.
791 This variable allows to provide shortcuts for export snippets.
793 For example, with a value of '\(\(\"h\" . \"html\"\)\), the
794 HTML back-end will recognize the contents of \"@@h:<b>@@\" as
795 HTML code while every other back-end will ignore it."
796   :group 'org-export-general
797   :version "24.4"
798   :package-version '(Org . "8.0")
799   :type '(repeat
800           (cons (string :tag "Shortcut")
801                 (string :tag "Back-end"))))
803 (defcustom org-export-coding-system nil
804   "Coding system for the exported file."
805   :group 'org-export-general
806   :version "24.4"
807   :package-version '(Org . "8.0")
808   :type 'coding-system)
810 (defcustom org-export-copy-to-kill-ring 'if-interactive
811   "Should we push exported content to the kill ring?"
812   :group 'org-export-general
813   :version "24.3"
814   :type '(choice
815           (const :tag "Always" t)
816           (const :tag "When export is done interactively" if-interactive)
817           (const :tag "Never" nil)))
819 (defcustom org-export-initial-scope 'buffer
820   "The initial scope when exporting with `org-export-dispatch'.
821 This variable can be either set to `buffer' or `subtree'."
822   :group 'org-export-general
823   :type '(choice
824           (const :tag "Export current buffer" buffer)
825           (const :tag "Export current subtree" subtree)))
827 (defcustom org-export-show-temporary-export-buffer t
828   "Non-nil means show buffer after exporting to temp buffer.
829 When Org exports to a file, the buffer visiting that file is ever
830 shown, but remains buried.  However, when exporting to
831 a temporary buffer, that buffer is popped up in a second window.
832 When this variable is nil, the buffer remains buried also in
833 these cases."
834   :group 'org-export-general
835   :type 'boolean)
837 (defcustom org-export-in-background nil
838   "Non-nil means export and publishing commands will run in background.
839 Results from an asynchronous export are never displayed
840 automatically.  But you can retrieve them with \\[org-export-stack]."
841   :group 'org-export-general
842   :version "24.4"
843   :package-version '(Org . "8.0")
844   :type 'boolean)
846 (defcustom org-export-async-init-file user-init-file
847   "File used to initialize external export process.
848 Value must be an absolute file name.  It defaults to user's
849 initialization file.  Though, a specific configuration makes the
850 process faster and the export more portable."
851   :group 'org-export-general
852   :version "24.4"
853   :package-version '(Org . "8.0")
854   :type '(file :must-match t))
856 (defcustom org-export-invisible-backends nil
857   "List of back-ends that shouldn't appear in the dispatcher.
859 Any back-end belonging to this list or derived from a back-end
860 belonging to it will not appear in the dispatcher menu.
862 Indeed, Org may require some export back-ends without notice.  If
863 these modules are never to be used interactively, adding them
864 here will avoid cluttering the dispatcher menu."
865   :group 'org-export-general
866   :version "24.4"
867   :package-version '(Org . "8.0")
868   :type '(repeat (symbol :tag "Back-End")))
870 (defcustom org-export-dispatch-use-expert-ui nil
871   "Non-nil means using a non-intrusive `org-export-dispatch'.
872 In that case, no help buffer is displayed.  Though, an indicator
873 for current export scope is added to the prompt (\"b\" when
874 output is restricted to body only, \"s\" when it is restricted to
875 the current subtree, \"v\" when only visible elements are
876 considered for export, \"f\" when publishing functions should be
877 passed the FORCE argument and \"a\" when the export should be
878 asynchronous).  Also, \[?] allows to switch back to standard
879 mode."
880   :group 'org-export-general
881   :version "24.4"
882   :package-version '(Org . "8.0")
883   :type 'boolean)
886 #+end_src
888 * Defining Back-ends
890 `org-export-define-backend' is the standard way to define an export
891 back-end.  It allows to specify translators, filters, buffer
892 options and a menu entry.  If the new back-end shares translators
893 with another back-end, `org-export-define-derived-backend' may be
894 used instead.
896 Internally, a back-end is stored as a list, of which CAR is the
897 name of the back-end, as a symbol, and CDR a plist.  Accessors to
898 properties of a given back-end are: `org-export-backend-filters',
899 `org-export-backend-menu', `org-export-backend-options' and
900 `org-export-backend-translate-table'.
902 Eventually `org-export-barf-if-invalid-backend' returns an error
903 when a given back-end hasn't been registered yet.
905 #+begin_src emacs-lisp
906 (defun org-export-define-backend (backend translators &rest body)
907   "Define a new back-end BACKEND.
909 TRANSLATORS is an alist between object or element types and
910 functions handling them.
912 These functions should return a string without any trailing
913 space, or nil.  They must accept three arguments: the object or
914 element itself, its contents or nil when it isn't recursive and
915 the property list used as a communication channel.
917 Contents, when not nil, are stripped from any global indentation
918 \(although the relative one is preserved).  They also always end
919 with a single newline character.
921 If, for a given type, no function is found, that element or
922 object type will simply be ignored, along with any blank line or
923 white space at its end.  The same will happen if the function
924 returns the nil value.  If that function returns the empty
925 string, the type will be ignored, but the blank lines or white
926 spaces will be kept.
928 In addition to element and object types, one function can be
929 associated to the `template' (or `inner-template') symbol and
930 another one to the `plain-text' symbol.
932 The former returns the final transcoded string, and can be used
933 to add a preamble and a postamble to document's body.  It must
934 accept two arguments: the transcoded string and the property list
935 containing export options.  A function associated to `template'
936 will not be applied if export has option \"body-only\".
937 A function associated to `inner-template' is always applied.
939 The latter, when defined, is to be called on every text not
940 recognized as an element or an object.  It must accept two
941 arguments: the text string and the information channel.  It is an
942 appropriate place to protect special chars relative to the
943 back-end.
945 BODY can start with pre-defined keyword arguments.  The following
946 keywords are understood:
948   :export-block
950     String, or list of strings, representing block names that
951     will not be parsed.  This is used to specify blocks that will
952     contain raw code specific to the back-end.  These blocks
953     still have to be handled by the relative `export-block' type
954     translator.
956   :filters-alist
958     Alist between filters and function, or list of functions,
959     specific to the back-end.  See `org-export-filters-alist' for
960     a list of all allowed filters.  Filters defined here
961     shouldn't make a back-end test, as it may prevent back-ends
962     derived from this one to behave properly.
964   :menu-entry
966     Menu entry for the export dispatcher.  It should be a list
967     like:
969       '(KEY DESCRIPTION-OR-ORDINAL ACTION-OR-MENU)
971     where :
973       KEY is a free character selecting the back-end.
975       DESCRIPTION-OR-ORDINAL is either a string or a number.
977       If it is a string, is will be used to name the back-end in
978       its menu entry.  If it is a number, the following menu will
979       be displayed as a sub-menu of the back-end with the same
980       KEY.  Also, the number will be used to determine in which
981       order such sub-menus will appear (lowest first).
983       ACTION-OR-MENU is either a function or an alist.
985       If it is an action, it will be called with four
986       arguments (booleans): ASYNC, SUBTREEP, VISIBLE-ONLY and
987       BODY-ONLY.  See `org-export-as' for further explanations on
988       some of them.
990       If it is an alist, associations should follow the
991       pattern:
993         '(KEY DESCRIPTION ACTION)
995       where KEY, DESCRIPTION and ACTION are described above.
997     Valid values include:
999       '(?m \"My Special Back-end\" my-special-export-function)
1001       or
1003       '(?l \"Export to LaTeX\"
1004            \(?p \"As PDF file\" org-latex-export-to-pdf)
1005            \(?o \"As PDF file and open\"
1006                \(lambda (a s v b)
1007                  \(if a (org-latex-export-to-pdf t s v b)
1008                    \(org-open-file
1009                     \(org-latex-export-to-pdf nil s v b)))))))
1011       or the following, which will be added to the previous
1012       sub-menu,
1014       '(?l 1
1015           \((?B \"As TEX buffer (Beamer)\" org-beamer-export-as-latex)
1016            \(?P \"As PDF file (Beamer)\" org-beamer-export-to-pdf)))
1018   :options-alist
1020     Alist between back-end specific properties introduced in
1021     communication channel and how their value are acquired.  See
1022     `org-export-options-alist' for more information about
1023     structure of the values.")
1025 (defun org-export-define-derived-backend (child parent &rest body)
1026   "Create a new back-end as a variant of an existing one.
1028 CHILD is the name of the derived back-end.  PARENT is the name of
1029 the parent back-end.
1031 BODY can start with pre-defined keyword arguments.  The following
1032 keywords are understood:
1034   :export-block
1036     String, or list of strings, representing block names that
1037     will not be parsed.  This is used to specify blocks that will
1038     contain raw code specific to the back-end.  These blocks
1039     still have to be handled by the relative `export-block' type
1040     translator.
1042   :filters-alist
1044     Alist of filters that will overwrite or complete filters
1045     defined in PARENT back-end.  See `org-export-filters-alist'
1046     for a list of allowed filters.
1048   :menu-entry
1050     Menu entry for the export dispatcher.  See
1051     `org-export-define-backend' for more information about the
1052     expected value.
1054   :options-alist
1056     Alist of back-end specific properties that will overwrite or
1057     complete those defined in PARENT back-end.  Refer to
1058     `org-export-options-alist' for more information about
1059     structure of the values.
1061   :translate-alist
1063     Alist of element and object types and transcoders that will
1064     overwrite or complete transcode table from PARENT back-end.
1065     Refer to `org-export-define-backend' for detailed information
1066     about transcoders.
1068 As an example, here is how one could define \"my-latex\" back-end
1069 as a variant of `latex' back-end with a custom template function:
1071   \(org-export-define-derived-backend 'my-latex 'latex
1072      :translate-alist '((template . my-latex-template-fun)))
1074 The back-end could then be called with, for example:
1076   \(org-export-to-buffer 'my-latex \"*Test my-latex*\")")
1078 (defun org-export-backend-parent (backend)
1079   "Return back-end from which BACKEND is derived, or nil.")
1081 (defun org-export-backend-filters (backend)
1082   "Return filters for BACKEND.")
1084 (defun org-export-backend-menu (backend)
1085   "Return menu entry for BACKEND.")
1087 (defun org-export-backend-options (backend)
1088   "Return export options for BACKEND.")
1090 (defun org-export-backend-translate-table (backend)
1091   "Return translate table for BACKEND.")
1093 (defun org-export-barf-if-invalid-backend (backend)
1094   "Signal an error if BACKEND isn't defined.")
1096 (defun org-export-derived-backend-p (backend &rest backends)
1097   "Non-nil if BACKEND is derived from one of BACKENDS.")
1100 #+end_src
1102 * The Communication Channel
1104 During export process, every function has access to a number of
1105 properties.  They are of two types:
1107 1. Environment options are collected once at the very beginning of
1108    the process, out of the original buffer and configuration.
1109    Collecting them is handled by `org-export-get-environment'
1110    function.
1112    Most environment options are defined through the
1113    `org-export-options-alist' variable.
1115 2. Tree properties are extracted directly from the parsed tree,
1116    just before export, by `org-export-collect-tree-properties'.
1118 Here is the full list of properties available during transcode
1119 process, with their category and their value type.
1121 + `:author' :: Author's name.
1122   - category :: option
1123   - type :: string
1125 + `:back-end' :: Current back-end used for transcoding.
1126   - category :: tree
1127   - type :: symbol
1129 + `:creator' :: String to write as creation information.
1130   - category :: option
1131   - type :: string
1133 + `:date' :: String to use as date.
1134   - category :: option
1135   - type :: string
1137 + `:description' :: Description text for the current data.
1138   - category :: option
1139   - type :: string
1141 + `:email' :: Author's email.
1142   - category :: option
1143   - type :: string
1145 + `:exclude-tags' :: Tags for exclusion of subtrees from export
1146      process.
1147   - category :: option
1148   - type :: list of strings
1150 + `:export-options' :: List of export options available for current
1151      process.
1152   - category :: none
1153   - type :: list of symbols, among `subtree', `body-only' and
1154      `visible-only'.
1156 + `:exported-data' :: Hash table used for memoizing
1157     `org-export-data'.
1158   - category :: tree
1159   - type :: hash table
1161 + `:filetags' :: List of global tags for buffer.  Used by
1162   `org-export-get-tags' to get tags with inheritance.
1163   - category :: option
1164   - type :: list of strings
1166 + `:footnote-definition-alist' :: Alist between footnote labels and
1167      their definition, as parsed data.  Only non-inlined footnotes
1168      are represented in this alist.  Also, every definition isn't
1169      guaranteed to be referenced in the parse tree.  The purpose of
1170      this property is to preserve definitions from oblivion
1171      (i.e. when the parse tree comes from a part of the original
1172      buffer), it isn't meant for direct use in a back-end.  To
1173      retrieve a definition relative to a reference, use
1174      `org-export-get-footnote-definition' instead.
1175   - category :: option
1176   - type :: alist (STRING . LIST)
1178 + `:headline-levels' :: Maximum level being exported as an
1179      headline.  Comparison is done with the relative level of
1180      headlines in the parse tree, not necessarily with their
1181      actual level.
1182   - category :: option
1183   - type :: integer
1185 + `:headline-offset' :: Difference between relative and real level
1186      of headlines in the parse tree.  For example, a value of -1
1187      means a level 2 headline should be considered as level
1188      1 (cf. `org-export-get-relative-level').
1189   - category :: tree
1190   - type :: integer
1192 + `:headline-numbering' :: Alist between headlines and their
1193      numbering, as a list of numbers
1194      (cf. `org-export-get-headline-number').
1195   - category :: tree
1196   - type :: alist (INTEGER . LIST)
1198 + `:id-alist' :: Alist between ID strings and destination file's
1199      path, relative to current directory.  It is used by
1200      `org-export-resolve-id-link' to resolve ID links targeting an
1201      external file.
1202   - category :: option
1203   - type :: alist (STRING . STRING)
1205 + `:ignore-list' :: List of elements and objects that should be
1206      ignored during export.
1207   - category :: tree
1208   - type :: list of elements and objects
1210 + `:input-file' :: Full path to input file, if any.
1211   - category :: option
1212   - type :: string or nil
1214 + `:keywords' :: List of keywords attached to data.
1215   - category :: option
1216   - type :: string
1218 + `:language' :: Default language used for translations.
1219   - category :: option
1220   - type :: string
1222 + `:parse-tree' :: Whole parse tree, available at any time during
1223      transcoding.
1224   - category :: option
1225   - type :: list (as returned by `org-element-parse-buffer')
1227 + `:preserve-breaks' :: Non-nil means transcoding should preserve
1228      all line breaks.
1229   - category :: option
1230   - type :: symbol (nil, t)
1232 + `:section-numbers' :: Non-nil means transcoding should add
1233      section numbers to headlines.
1234   - category :: option
1235   - type :: symbol (nil, t)
1237 + `:select-tags' :: List of tags enforcing inclusion of sub-trees
1238      in transcoding.  When such a tag is present, subtrees without
1239      it are de facto excluded from the process.  See
1240      `use-select-tags'.
1241   - category :: option
1242   - type :: list of strings
1244 + `:time-stamp-file' :: Non-nil means transcoding should insert
1245      a time stamp in the output.
1246   - category :: option
1247   - type :: symbol (nil, t)
1249 + `:translate-alist' :: Alist between element and object types and
1250      transcoding functions relative to the current back-end.
1251      Special keys `inner-template', `template' and `plain-text' are
1252      also possible.
1253   - category :: option
1254   - type :: alist (SYMBOL . FUNCTION)
1256 + `:with-archived-trees' :: Non-nil when archived subtrees should
1257      also be transcoded.  If it is set to the `headline' symbol,
1258      only the archived headline's name is retained.
1259   - category :: option
1260   - type :: symbol (nil, t, `headline')
1262 + `:with-author' :: Non-nil means author's name should be included
1263      in the output.
1264   - category :: option
1265   - type :: symbol (nil, t)
1267 + `:with-clocks' :: Non-nil means clock keywords should be exported.
1268   - category :: option
1269   - type :: symbol (nil, t)
1271 + `:with-creator' :: Non-nil means a creation sentence should be
1272      inserted at the end of the transcoded string.  If the value
1273      is `comment', it should be commented.
1274   - category :: option
1275   - type :: symbol (`comment', nil, t)
1277 + `:with-date' :: Non-nil means output should contain a date.
1278   - category :: option
1279   - type :. symbol (nil, t)
1281 + `:with-drawers' :: Non-nil means drawers should be exported.  If
1282      its value is a list of names, only drawers with such names
1283      will be transcoded.  If that list starts with `not', drawer
1284      with these names will be skipped.
1285   - category :: option
1286   - type :: symbol (nil, t) or list of strings
1288 + `:with-email' :: Non-nil means output should contain author's
1289                   email.
1290   - category :: option
1291   - type :: symbol (nil, t)
1293 + `:with-emphasize' :: Non-nil means emphasized text should be
1294      interpreted.
1295   - category :: option
1296   - type :: symbol (nil, t)
1298 + `:with-fixed-width' :: Non-nil if transcoder should interpret
1299      strings starting with a colon as a fixed-with (verbatim) area.
1300   - category :: option
1301   - type :: symbol (nil, t)
1303 + `:with-footnotes' :: Non-nil if transcoder should interpret
1304      footnotes.
1305   - category :: option
1306   - type :: symbol (nil, t)
1308 + `:with-latex' :: Non-nil means `latex-environment' elements and
1309    `latex-fragment' objects should appear in export output.  When
1310    this property is set to `verbatim', they will be left as-is.
1311   - category :: option
1312   - type :: symbol (`verbatim', nil, t)
1314 + `:with-planning' :: Non-nil means transcoding should include
1315      planning info.
1316   - category :: option
1317   - type :: symbol (nil, t)
1319 + `:with-priority' :: Non-nil means transcoding should include
1320      priority cookies.
1321   - category :: option
1322   - type :: symbol (nil, t)
1324 + `:with-smart-quotes' :: Non-nil means activate smart quotes in
1325      plain text.
1326   - category :: option
1327   - type :: symbol (nil, t)
1329 + `:with-special-strings' :: Non-nil means transcoding should
1330      interpret special strings in plain text.
1331   - category :: option
1332   - type :: symbol (nil, t)
1334 + `:with-sub-superscript' :: Non-nil means transcoding should
1335      interpret subscript and superscript.  With a value of "{}",
1336      only interpret those using curly brackets.
1337   - category :: option
1338   - type :: symbol (nil, {}, t)
1340 + `:with-tables' :: Non-nil means transcoding should interpret
1341      tables.
1342   - category :: option
1343   - type :: symbol (nil, t)
1345 + `:with-tags' :: Non-nil means transcoding should keep tags in
1346      headlines.  A `not-in-toc' value will remove them from the
1347      table of contents, if any, nonetheless.
1348   - category :: option
1349   - type :: symbol (nil, t, `not-in-toc')
1351 + `:with-tasks' :: Non-nil means transcoding should include
1352      headlines with a TODO keyword.  A `todo' value will only
1353      include headlines with a todo type keyword while a `done'
1354      value will do the contrary.  If a list of strings is provided,
1355      only tasks with keywords belonging to that list will be kept.
1356   - category :: option
1357   - type :: symbol (t, todo, done, nil) or list of strings
1359 + `:with-timestamps' :: Non-nil means transcoding should include
1360      time stamps.  Special value `active' (resp. `inactive') ask to
1361      export only active (resp. inactive) timestamps.  Otherwise,
1362      completely remove them.
1363   - category :: option
1364   - type :: symbol: (`active', `inactive', t, nil)
1366 + `:with-toc' :: Non-nil means that a table of contents has to be
1367      added to the output.  An integer value limits its depth.
1368   - category :: option
1369   - type :: symbol (nil, t or integer)
1371 + `:with-todo-keywords' :: Non-nil means transcoding should
1372      include TODO keywords.
1373   - category :: option
1374   - type :: symbol (nil, t)
1377 ** Environment Options
1379 Environment options encompass all parameters defined outside the
1380 scope of the parsed data.  They come from five sources, in
1381 increasing precedence order:
1383 - Global variables,
1384 - Buffer's attributes,
1385 - Options keyword symbols,
1386 - Buffer keywords,
1387 - Subtree properties.
1389 The central internal function with regards to environment options
1390 is `org-export-get-environment'.  It updates global variables with
1391 "#+BIND:" keywords, then retrieve and prioritize properties from
1392 the different sources.
1394  The internal functions doing the retrieval are:
1395  `org-export--get-global-options',
1396  `org-export--get-buffer-attributes',
1397  `org-export--parse-option-keyword',
1398  `org-export--get-subtree-options' and
1399  `org-export--get-inbuffer-options'
1401 Also, `org-export--install-letbind-maybe' takes care of the part
1402 relative to "#+BIND:" keywords.
1404 #+begin_src emacs-lisp
1405 (defun org-export-get-environment (&optional backend subtreep ext-plist)
1406   "Collect export options from the current buffer.
1408 Optional argument BACKEND is a symbol specifying which back-end
1409 specific options to read, if any.
1411 When optional argument SUBTREEP is non-nil, assume the export is
1412 done against the current sub-tree.
1414 Third optional argument EXT-PLIST is a property list with
1415 external parameters overriding Org default settings, but still
1416 inferior to file-local settings.")
1418 (defun org-export--parse-option-keyword (options &optional backend)
1419   "Parse an OPTIONS line and return values as a plist.
1420 Optional argument BACKEND is a symbol specifying which back-end
1421 specific items to read, if any.")
1423 (defun org-export--get-subtree-options (&optional backend)
1424   "Get export options in subtree at point.
1425 Optional argument BACKEND is a symbol specifying back-end used
1426 for export.  Return options as a plist."
1427   ;; For each buffer keyword, create a headline property setting the
1428   ;; same property in communication channel. The name for the property
1429   ;; is the keyword with "EXPORT_")
1431 (defun org-export--get-inbuffer-options (&optional backend)
1432   "Return current buffer export options, as a plist.
1434 Optional argument BACKEND, when non-nil, is a symbol specifying
1435 which back-end specific options should also be read in the
1436 process.
1438 Assume buffer is in Org mode.  Narrowing, if any, is ignored.")
1440 (defun org-export--get-buffer-attributes ()
1441   "Return properties related to buffer attributes, as a plist.")
1443 (defvar org-export--default-title nil)  ; Dynamically scoped.
1444 (defun org-export-store-default-title ()
1445   "Return default title for current document, as a string.
1446 Title is extracted from associated file name, if any, or buffer's
1447 name.")
1449 (defun org-export--get-global-options (&optional backend)
1450   "Return global export options as a plist.
1451 Optional argument BACKEND, if non-nil, is a symbol specifying
1452 which back-end specific export options should also be read in the
1453 process.")
1455 (defun org-export--list-bound-variables ()
1456   "Return variables bound from BIND keywords in current buffer.
1457 Also look for BIND keywords in setup files.  The return value is
1458 an alist where associations are (VARIABLE-NAME VALUE).")
1460 #+end_src
1462 ** Tree Properties
1464 Tree properties are information extracted from parse tree.  They
1465 are initialized at the beginning of the transcoding process by
1466 `org-export-collect-tree-properties'.
1468 Dedicated functions focus on computing the value of specific tree
1469 properties during initialization.  Thus,
1470 `org-export--populate-ignore-list' lists elements and objects that
1471 should be skipped during export, `org-export--get-min-level' gets
1472 the minimal exportable level, used as a basis to compute relative
1473 level for headlines.  Eventually
1474 `org-export--collect-headline-numbering' builds an alist between
1475 headlines and their numbering.
1477 #+begin_src emacs-lisp
1478 (defun org-export-collect-tree-properties (data info)
1479   "Extract tree properties from parse tree.
1481 DATA is the parse tree from which information is retrieved.  INFO
1482 is a list holding export options.
1484 Following tree properties are set or updated:
1486 `:exported-data' Hash table used to memoize results from
1487                  `org-export-data'.
1489 `:footnote-definition-alist' List of footnotes definitions in
1490                    original buffer and current parse tree.
1492 `:headline-offset' Offset between true level of headlines and
1493                    local level.  An offset of -1 means a headline
1494                    of level 2 should be considered as a level
1495                    1 headline in the context.
1497 `:headline-numbering' Alist of all headlines as key an the
1498                       associated numbering as value.
1500 `:ignore-list'     List of elements that should be ignored during
1501                    export.
1503 Return updated plist.")
1505 (defun org-export--get-min-level (data options)
1506   "Return minimum exportable headline's level in DATA.
1507 DATA is parsed tree as returned by `org-element-parse-buffer'.
1508 OPTIONS is a plist holding export options.")
1510 (defun org-export--collect-headline-numbering (data options)
1511   "Return numbering of all exportable headlines in a parse tree.
1513 DATA is the parse tree.  OPTIONS is the plist holding export
1514 options.
1516 Return an alist whose key is a headline and value is its
1517 associated numbering \(in the shape of a list of numbers\) or nil
1518 for a footnotes section.")
1520 (defun org-export--populate-ignore-list (data options)
1521   "Return list of elements and objects to ignore during export.
1522 DATA is the parse tree to traverse.  OPTIONS is the plist holding
1523 export options.")
1525 (defun org-export--selected-trees (data info)
1526   "Return list of headlines and inlinetasks with a select tag in their tree.
1527 DATA is parsed data as returned by `org-element-parse-buffer'.
1528 INFO is a plist holding export options.")
1530 (defun org-export--skip-p (blob options selected)
1531   "Non-nil when element or object BLOB should be skipped during export.
1532 OPTIONS is the plist holding export options.  SELECTED, when
1533 non-nil, is a list of headlines or inlinetasks belonging to
1534 a tree with a select tag.")
1536 #+end_src
1538 * The Transcoder
1540 `org-export-data' reads a parse tree (obtained with, i.e.
1541 `org-element-parse-buffer') and transcodes it into a specified
1542 back-end output.  It takes care of filtering out elements or
1543 objects according to export options and organizing the output blank
1544 lines and white space are preserved.  The function memoizes its
1545 results, so it is cheap to call it within translators.
1547 It is possible to modify locally the back-end used by
1548 `org-export-data' or even use a temporary back-end by using
1549 `org-export-data-with-translations' and
1550 `org-export-data-with-backend'.
1552 Internally, three functions handle the filtering of objects and
1553 elements during the export.  In particular,
1554 `org-export-ignore-element' marks an element or object so future
1555 parse tree traversals skip it, `org-export--interpret-p' tells which
1556 elements or objects should be seen as real Org syntax and
1557 `org-export-expand' transforms the others back into their original
1558 shape
1560 `org-export-transcoder' is an accessor returning appropriate
1561 translator function for a given element or object.
1563 #+begin_src emacs-lisp
1564 (defun org-export-transcoder (blob info)
1565   "Return appropriate transcoder for BLOB.
1566 INFO is a plist containing export directives.")
1568 (defun org-export-data (data info)
1569   "Convert DATA into current back-end format.
1571 DATA is a parse tree, an element or an object or a secondary
1572 string.  INFO is a plist holding export options.
1574 Return transcoded string.")
1576 (defun org-export-data-with-translations (data translations info)
1577   "Convert DATA into another format using a given translation table.
1578 DATA is an element, an object, a secondary string or a string.
1579 TRANSLATIONS is an alist between element or object types and
1580 a functions handling them.  See `org-export-define-backend' for
1581 more information.  INFO is a plist used as a communication
1582 channel.")
1584 (defun org-export-data-with-backend (data backend info)
1585   "Convert DATA into BACKEND format.
1587 DATA is an element, an object, a secondary string or a string.
1588 BACKEND is a symbol.  INFO is a plist used as a communication
1589 channel.
1591 Unlike to `org-export-with-backend', this function will
1592 recursively convert DATA using BACKEND translation table.")
1594 (defun org-export--interpret-p (blob info)
1595   "Non-nil if element or object BLOB should be interpreted during export.
1596 If nil, BLOB will appear as raw Org syntax.  Check is done
1597 according to export options INFO, stored as a plist.")
1599 (defun org-export-expand (blob contents &optional with-affiliated)
1600   "Expand a parsed element or object to its original state.
1602 BLOB is either an element or an object.  CONTENTS is its
1603 contents, as a string or nil.
1605 When optional argument WITH-AFFILIATED is non-nil, add affiliated
1606 keywords before output.")
1608 (defun org-export-ignore-element (element info)
1609   "Add ELEMENT to `:ignore-list' in INFO.
1611 Any element in `:ignore-list' will be skipped when using
1612 `org-element-map'.  INFO is modified by side effects.")
1615 #+end_src
1617 * The Filter System
1619 Filters allow end-users to tweak easily the transcoded output.
1620 They are the functional counterpart of hooks, as every filter in
1621 a set is applied to the return value of the previous one.
1623 Every set is back-end agnostic.  Although, a filter is always
1624 called, in addition to the string it applies to, with the back-end
1625 used as argument, so it's easy for the end-user to add back-end
1626 specific filters in the set.  The communication channel, as
1627 a plist, is required as the third argument.
1629 From the developer side, filters sets can be installed in the
1630 process with the help of `org-export-define-backend', which
1631 internally stores filters as an alist.  Each association has a key
1632 among the following symbols and a function or a list of functions
1633 as value.
1635 - `:filter-options' applies to the property list containing export
1636   options.  Unlike to other filters, functions in this list accept
1637   two arguments instead of three: the property list containing
1638   export options and the back-end.  Users can set its value through
1639   `org-export-filter-options-functions' variable.
1641 - `:filter-parse-tree' applies directly to the complete parsed
1642   tree.  Users can set it through
1643   `org-export-filter-parse-tree-functions' variable.
1645 - `:filter-final-output' applies to the final transcoded string.
1646   Users can set it with `org-export-filter-final-output-functions'
1647   variable
1649 - `:filter-plain-text' applies to any string not recognized as Org
1650   syntax.  `org-export-filter-plain-text-functions' allows users to
1651   configure it.
1653 - `:filter-TYPE' applies on the string returned after an element or
1654   object of type TYPE has been transcoded.  A user can modify
1655   `org-export-filter-TYPE-functions'
1657 All filters sets are applied with
1658 `org-export-filter-apply-functions' function.  Filters in a set are
1659 applied in a LIFO fashion.  It allows developers to be sure that
1660 their filters will be applied first.
1662 Filters properties are installed in communication channel with
1663 `org-export-install-filters' function.
1665 Eventually, two hooks (`org-export-before-processing-hook' and
1666 `org-export-before-parsing-hook') are run at the beginning of the
1667 export process and just before parsing to allow for heavy structure
1668 modifications.
1671 ** Hooks
1673 #+begin_src emacs-lisp
1674 (defvar org-export-before-processing-hook nil
1675   "Hook run at the beginning of the export process.
1677 This is run before include keywords and macros are expanded and
1678 Babel code blocks executed, on a copy of the original buffer
1679 being exported.  Visibility and narrowing are preserved.  Point
1680 is at the beginning of the buffer.
1682 Every function in this hook will be called with one argument: the
1683 back-end currently used, as a symbol.")
1685 (defvar org-export-before-parsing-hook nil
1686   "Hook run before parsing an export buffer.
1688 This is run after include keywords and macros have been expanded
1689 and Babel code blocks executed, on a copy of the original buffer
1690 being exported.  Visibility and narrowing are preserved.  Point
1691 is at the beginning of the buffer.
1693 Every function in this hook will be called with one argument: the
1694 back-end currently used, as a symbol.")
1696 #+end_src
1698 ** Special Filters
1700 #+begin_src emacs-lisp
1701 (defvar org-export-filter-options-functions nil
1702   "List of functions applied to the export options.
1703 Each filter is called with two arguments: the export options, as
1704 a plist, and the back-end, as a symbol.  It must return
1705 a property list containing export options.")
1707 (defvar org-export-filter-parse-tree-functions nil
1708   "List of functions applied to the parsed tree.
1709 Each filter is called with three arguments: the parse tree, as
1710 returned by `org-element-parse-buffer', the back-end, as
1711 a symbol, and the communication channel, as a plist.  It must
1712 return the modified parse tree to transcode.")
1714 (defvar org-export-filter-plain-text-functions nil
1715   "List of functions applied to plain text.
1716 Each filter is called with three arguments: a string which
1717 contains no Org syntax, the back-end, as a symbol, and the
1718 communication channel, as a plist.  It must return a string or
1719 nil.")
1721 (defvar org-export-filter-final-output-functions nil
1722   "List of functions applied to the transcoded string.
1723 Each filter is called with three arguments: the full transcoded
1724 string, the back-end, as a symbol, and the communication channel,
1725 as a plist.  It must return a string that will be used as the
1726 final export output.")
1728 #+end_src
1730 ** Elements Filters
1732 #+begin_src emacs-lisp
1733 (defvar org-export-filter-babel-call-functions nil
1734   "List of functions applied to a transcoded babel-call.
1735 Each filter is called with three arguments: the transcoded data,
1736 as a string, the back-end, as a symbol, and the communication
1737 channel, as a plist.  It must return a string or nil.")
1739 (defvar org-export-filter-center-block-functions nil
1740   "List of functions applied to a transcoded center block.
1741 Each filter is called with three arguments: the transcoded data,
1742 as a string, the back-end, as a symbol, and the communication
1743 channel, as a plist.  It must return a string or nil.")
1745 (defvar org-export-filter-clock-functions nil
1746   "List of functions applied to a transcoded clock.
1747 Each filter is called with three arguments: the transcoded data,
1748 as a string, the back-end, as a symbol, and the communication
1749 channel, as a plist.  It must return a string or nil.")
1751 (defvar org-export-filter-comment-functions nil
1752   "List of functions applied to a transcoded comment.
1753 Each filter is called with three arguments: the transcoded data,
1754 as a string, the back-end, as a symbol, and the communication
1755 channel, as a plist.  It must return a string or nil.")
1757 (defvar org-export-filter-comment-block-functions nil
1758   "List of functions applied to a transcoded comment-block.
1759 Each filter is called with three arguments: the transcoded data,
1760 as a string, the back-end, as a symbol, and the communication
1761 channel, as a plist.  It must return a string or nil.")
1763 (defvar org-export-filter-diary-sexp-functions nil
1764   "List of functions applied to a transcoded diary-sexp.
1765 Each filter is called with three arguments: the transcoded data,
1766 as a string, the back-end, as a symbol, and the communication
1767 channel, as a plist.  It must return a string or nil.")
1769 (defvar org-export-filter-drawer-functions nil
1770   "List of functions applied to a transcoded drawer.
1771 Each filter is called with three arguments: the transcoded data,
1772 as a string, the back-end, as a symbol, and the communication
1773 channel, as a plist.  It must return a string or nil.")
1775 (defvar org-export-filter-dynamic-block-functions nil
1776   "List of functions applied to a transcoded dynamic-block.
1777 Each filter is called with three arguments: the transcoded data,
1778 as a string, the back-end, as a symbol, and the communication
1779 channel, as a plist.  It must return a string or nil.")
1781 (defvar org-export-filter-example-block-functions nil
1782   "List of functions applied to a transcoded example-block.
1783 Each filter is called with three arguments: the transcoded data,
1784 as a string, the back-end, as a symbol, and the communication
1785 channel, as a plist.  It must return a string or nil.")
1787 (defvar org-export-filter-export-block-functions nil
1788   "List of functions applied to a transcoded export-block.
1789 Each filter is called with three arguments: the transcoded data,
1790 as a string, the back-end, as a symbol, and the communication
1791 channel, as a plist.  It must return a string or nil.")
1793 (defvar org-export-filter-fixed-width-functions nil
1794   "List of functions applied to a transcoded fixed-width.
1795 Each filter is called with three arguments: the transcoded data,
1796 as a string, the back-end, as a symbol, and the communication
1797 channel, as a plist.  It must return a string or nil.")
1799 (defvar org-export-filter-footnote-definition-functions nil
1800   "List of functions applied to a transcoded footnote-definition.
1801 Each filter is called with three arguments: the transcoded data,
1802 as a string, the back-end, as a symbol, and the communication
1803 channel, as a plist.  It must return a string or nil.")
1805 (defvar org-export-filter-headline-functions nil
1806   "List of functions applied to a transcoded headline.
1807 Each filter is called with three arguments: the transcoded data,
1808 as a string, the back-end, as a symbol, and the communication
1809 channel, as a plist.  It must return a string or nil.")
1811 (defvar org-export-filter-horizontal-rule-functions nil
1812   "List of functions applied to a transcoded horizontal-rule.
1813 Each filter is called with three arguments: the transcoded data,
1814 as a string, the back-end, as a symbol, and the communication
1815 channel, as a plist.  It must return a string or nil.")
1817 (defvar org-export-filter-inlinetask-functions nil
1818   "List of functions applied to a transcoded inlinetask.
1819 Each filter is called with three arguments: the transcoded data,
1820 as a string, the back-end, as a symbol, and the communication
1821 channel, as a plist.  It must return a string or nil.")
1823 (defvar org-export-filter-item-functions nil
1824   "List of functions applied to a transcoded item.
1825 Each filter is called with three arguments: the transcoded data,
1826 as a string, the back-end, as a symbol, and the communication
1827 channel, as a plist.  It must return a string or nil.")
1829 (defvar org-export-filter-keyword-functions nil
1830   "List of functions applied to a transcoded keyword.
1831 Each filter is called with three arguments: the transcoded data,
1832 as a string, the back-end, as a symbol, and the communication
1833 channel, as a plist.  It must return a string or nil.")
1835 (defvar org-export-filter-latex-environment-functions nil
1836   "List of functions applied to a transcoded latex-environment.
1837 Each filter is called with three arguments: the transcoded data,
1838 as a string, the back-end, as a symbol, and the communication
1839 channel, as a plist.  It must return a string or nil.")
1841 (defvar org-export-filter-node-property-functions nil
1842   "List of functions applied to a transcoded node-property.
1843 Each filter is called with three arguments: the transcoded data,
1844 as a string, the back-end, as a symbol, and the communication
1845 channel, as a plist.  It must return a string or nil.")
1847 (defvar org-export-filter-paragraph-functions nil
1848   "List of functions applied to a transcoded paragraph.
1849 Each filter is called with three arguments: the transcoded data,
1850 as a string, the back-end, as a symbol, and the communication
1851 channel, as a plist.  It must return a string or nil.")
1853 (defvar org-export-filter-plain-list-functions nil
1854   "List of functions applied to a transcoded plain-list.
1855 Each filter is called with three arguments: the transcoded data,
1856 as a string, the back-end, as a symbol, and the communication
1857 channel, as a plist.  It must return a string or nil.")
1859 (defvar org-export-filter-planning-functions nil
1860   "List of functions applied to a transcoded planning.
1861 Each filter is called with three arguments: the transcoded data,
1862 as a string, the back-end, as a symbol, and the communication
1863 channel, as a plist.  It must return a string or nil.")
1865 (defvar org-export-filter-property-drawer-functions nil
1866   "List of functions applied to a transcoded property-drawer.
1867 Each filter is called with three arguments: the transcoded data,
1868 as a string, the back-end, as a symbol, and the communication
1869 channel, as a plist.  It must return a string or nil.")
1871 (defvar org-export-filter-quote-block-functions nil
1872   "List of functions applied to a transcoded quote block.
1873 Each filter is called with three arguments: the transcoded quote
1874 data, as a string, the back-end, as a symbol, and the
1875 communication channel, as a plist.  It must return a string or
1876 nil.")
1878 (defvar org-export-filter-quote-section-functions nil
1879   "List of functions applied to a transcoded quote-section.
1880 Each filter is called with three arguments: the transcoded data,
1881 as a string, the back-end, as a symbol, and the communication
1882 channel, as a plist.  It must return a string or nil.")
1884 (defvar org-export-filter-section-functions nil
1885   "List of functions applied to a transcoded section.
1886 Each filter is called with three arguments: the transcoded data,
1887 as a string, the back-end, as a symbol, and the communication
1888 channel, as a plist.  It must return a string or nil.")
1890 (defvar org-export-filter-special-block-functions nil
1891   "List of functions applied to a transcoded special block.
1892 Each filter is called with three arguments: the transcoded data,
1893 as a string, the back-end, as a symbol, and the communication
1894 channel, as a plist.  It must return a string or nil.")
1896 (defvar org-export-filter-src-block-functions nil
1897   "List of functions applied to a transcoded src-block.
1898 Each filter is called with three arguments: the transcoded data,
1899 as a string, the back-end, as a symbol, and the communication
1900 channel, as a plist.  It must return a string or nil.")
1902 (defvar org-export-filter-table-functions nil
1903   "List of functions applied to a transcoded table.
1904 Each filter is called with three arguments: the transcoded data,
1905 as a string, the back-end, as a symbol, and the communication
1906 channel, as a plist.  It must return a string or nil.")
1908 (defvar org-export-filter-table-cell-functions nil
1909   "List of functions applied to a transcoded table-cell.
1910 Each filter is called with three arguments: the transcoded data,
1911 as a string, the back-end, as a symbol, and the communication
1912 channel, as a plist.  It must return a string or nil.")
1914 (defvar org-export-filter-table-row-functions nil
1915   "List of functions applied to a transcoded table-row.
1916 Each filter is called with three arguments: the transcoded data,
1917 as a string, the back-end, as a symbol, and the communication
1918 channel, as a plist.  It must return a string or nil.")
1920 (defvar org-export-filter-verse-block-functions nil
1921   "List of functions applied to a transcoded verse block.
1922 Each filter is called with three arguments: the transcoded data,
1923 as a string, the back-end, as a symbol, and the communication
1924 channel, as a plist.  It must return a string or nil.")
1926 #+end_src
1928 ** Objects Filters
1930 #+begin_src emacs-lisp
1931 (defvar org-export-filter-bold-functions nil
1932   "List of functions applied to transcoded bold text.
1933 Each filter is called with three arguments: the transcoded data,
1934 as a string, the back-end, as a symbol, and the communication
1935 channel, as a plist.  It must return a string or nil.")
1937 (defvar org-export-filter-code-functions nil
1938   "List of functions applied to transcoded code text.
1939 Each filter is called with three arguments: the transcoded data,
1940 as a string, the back-end, as a symbol, and the communication
1941 channel, as a plist.  It must return a string or nil.")
1943 (defvar org-export-filter-entity-functions nil
1944   "List of functions applied to a transcoded entity.
1945 Each filter is called with three arguments: the transcoded data,
1946 as a string, the back-end, as a symbol, and the communication
1947 channel, as a plist.  It must return a string or nil.")
1949 (defvar org-export-filter-export-snippet-functions nil
1950   "List of functions applied to a transcoded export-snippet.
1951 Each filter is called with three arguments: the transcoded data,
1952 as a string, the back-end, as a symbol, and the communication
1953 channel, as a plist.  It must return a string or nil.")
1955 (defvar org-export-filter-footnote-reference-functions nil
1956   "List of functions applied to a transcoded footnote-reference.
1957 Each filter is called with three arguments: the transcoded data,
1958 as a string, the back-end, as a symbol, and the communication
1959 channel, as a plist.  It must return a string or nil.")
1961 (defvar org-export-filter-inline-babel-call-functions nil
1962   "List of functions applied to a transcoded inline-babel-call.
1963 Each filter is called with three arguments: the transcoded data,
1964 as a string, the back-end, as a symbol, and the communication
1965 channel, as a plist.  It must return a string or nil.")
1967 (defvar org-export-filter-inline-src-block-functions nil
1968   "List of functions applied to a transcoded inline-src-block.
1969 Each filter is called with three arguments: the transcoded data,
1970 as a string, the back-end, as a symbol, and the communication
1971 channel, as a plist.  It must return a string or nil.")
1973 (defvar org-export-filter-italic-functions nil
1974   "List of functions applied to transcoded italic text.
1975 Each filter is called with three arguments: the transcoded data,
1976 as a string, the back-end, as a symbol, and the communication
1977 channel, as a plist.  It must return a string or nil.")
1979 (defvar org-export-filter-latex-fragment-functions nil
1980   "List of functions applied to a transcoded latex-fragment.
1981 Each filter is called with three arguments: the transcoded data,
1982 as a string, the back-end, as a symbol, and the communication
1983 channel, as a plist.  It must return a string or nil.")
1985 (defvar org-export-filter-line-break-functions nil
1986   "List of functions applied to a transcoded line-break.
1987 Each filter is called with three arguments: the transcoded data,
1988 as a string, the back-end, as a symbol, and the communication
1989 channel, as a plist.  It must return a string or nil.")
1991 (defvar org-export-filter-link-functions nil
1992   "List of functions applied to a transcoded link.
1993 Each filter is called with three arguments: the transcoded data,
1994 as a string, the back-end, as a symbol, and the communication
1995 channel, as a plist.  It must return a string or nil.")
1997 (defvar org-export-filter-radio-target-functions nil
1998   "List of functions applied to a transcoded radio-target.
1999 Each filter is called with three arguments: the transcoded data,
2000 as a string, the back-end, as a symbol, and the communication
2001 channel, as a plist.  It must return a string or nil.")
2003 (defvar org-export-filter-statistics-cookie-functions nil
2004   "List of functions applied to a transcoded statistics-cookie.
2005 Each filter is called with three arguments: the transcoded data,
2006 as a string, the back-end, as a symbol, and the communication
2007 channel, as a plist.  It must return a string or nil.")
2009 (defvar org-export-filter-strike-through-functions nil
2010   "List of functions applied to transcoded strike-through text.
2011 Each filter is called with three arguments: the transcoded data,
2012 as a string, the back-end, as a symbol, and the communication
2013 channel, as a plist.  It must return a string or nil.")
2015 (defvar org-export-filter-subscript-functions nil
2016   "List of functions applied to a transcoded subscript.
2017 Each filter is called with three arguments: the transcoded data,
2018 as a string, the back-end, as a symbol, and the communication
2019 channel, as a plist.  It must return a string or nil.")
2021 (defvar org-export-filter-superscript-functions nil
2022   "List of functions applied to a transcoded superscript.
2023 Each filter is called with three arguments: the transcoded data,
2024 as a string, the back-end, as a symbol, and the communication
2025 channel, as a plist.  It must return a string or nil.")
2027 (defvar org-export-filter-target-functions nil
2028   "List of functions applied to a transcoded target.
2029 Each filter is called with three arguments: the transcoded data,
2030 as a string, the back-end, as a symbol, and the communication
2031 channel, as a plist.  It must return a string or nil.")
2033 (defvar org-export-filter-timestamp-functions nil
2034   "List of functions applied to a transcoded timestamp.
2035 Each filter is called with three arguments: the transcoded data,
2036 as a string, the back-end, as a symbol, and the communication
2037 channel, as a plist.  It must return a string or nil.")
2039 (defvar org-export-filter-underline-functions nil
2040   "List of functions applied to transcoded underline text.
2041 Each filter is called with three arguments: the transcoded data,
2042 as a string, the back-end, as a symbol, and the communication
2043 channel, as a plist.  It must return a string or nil.")
2045 (defvar org-export-filter-verbatim-functions nil
2046   "List of functions applied to transcoded verbatim text.
2047 Each filter is called with three arguments: the transcoded data,
2048 as a string, the back-end, as a symbol, and the communication
2049 channel, as a plist.  It must return a string or nil.")
2051 #+end_src
2053 ** Filters Tools
2055 Internal function `org-export-install-filters' installs filters
2056 hard-coded in back-ends (developer filters) and filters from global
2057 variables (user filters) in the communication channel.
2059 Internal function `org-export-filter-apply-functions' takes care
2060 about applying each filter in order to a given data.  It ignores
2061 filters returning a nil value but stops whenever a filter returns
2062 an empty string.
2064 #+begin_src emacs-lisp
2065 (defun org-export-filter-apply-functions (filters value info)
2066   "Call every function in FILTERS.
2068 Functions are called with arguments VALUE, current export
2069 back-end and INFO.  A function returning a nil value will be
2070 skipped.  If it returns the empty string, the process ends and
2071 VALUE is ignored.
2073 Call is done in a LIFO fashion, to be sure that developer
2074 specified filters, if any, are called first.")
2076 (defun org-export-install-filters (info)
2077   "Install filters properties in communication channel.
2078 INFO is a plist containing the current communication channel.
2079 Return the updated communication channel.")
2082 #+end_src
2084 * Core functions
2086 This is the room for the main function, `org-export-as', along with
2087 its derivatives, `org-export-to-buffer', `org-export-to-file' and
2088 `org-export-string-as'.  They differ either by the way they output
2089 the resulting code (for the first two) or by the input type (for
2090 the latter).  `org-export--copy-to-kill-ring-p' determines if
2091 output of these function should be added to kill ring.
2093 `org-export-output-file-name' is an auxiliary function meant to be
2094 used with `org-export-to-file'.  With a given extension, it tries
2095 to provide a canonical file name to write export output to.
2097 Note that `org-export-as' doesn't really parse the current buffer,
2098 but a copy of it (with the same buffer-local variables and
2099 visibility), where macros and include keywords are expanded and
2100 Babel blocks are executed, if appropriate.
2101 `org-export-with-buffer-copy' macro prepares that copy.
2103 File inclusion is taken care of by
2104 `org-export-expand-include-keyword' and
2105 `org-export--prepare-file-contents'.  Structure wise, including
2106 a whole Org file in a buffer often makes little sense.  For
2107 example, if the file contains a headline and the include keyword
2108 was within an item, the item should contain the headline.  That's
2109 why file inclusion should be done before any structure can be
2110 associated to the file, that is before parsing.
2112 `org-export-insert-default-template' is a command to insert
2113 a default template (or a back-end specific template) at point or in
2114 current subtree.
2116 #+begin_src emacs-lisp
2117 (defun org-export-copy-buffer ()
2118   "Return a copy of the current buffer.
2119 The copy preserves Org buffer-local variables, visibility and
2120 narrowing.")
2122 (defmacro org-export-with-buffer-copy (&rest body)
2123   "Apply BODY in a copy of the current buffer.
2124 The copy preserves local variables, visibility and contents of
2125 the original buffer.  Point is at the beginning of the buffer
2126 when BODY is applied.")
2128 (defun org-export--generate-copy-script (buffer)
2129   "Generate a function duplicating BUFFER.
2131 The copy will preserve local variables, visibility, contents and
2132 narrowing of the original buffer.  If a region was active in
2133 BUFFER, contents will be narrowed to that region instead.
2135 The resulting function can be evaled at a later time, from
2136 another buffer, effectively cloning the original buffer there.
2138 The function assumes BUFFER's major mode is `org-mode'.")
2139 #+end_src
2141 ###autoload
2142 #+begin_src emacs-lisp
2143 (defun org-export-as
2144   (backend &optional subtreep visible-only body-only ext-plist)
2145   "Transcode current Org buffer into BACKEND code.
2147 If narrowing is active in the current buffer, only transcode its
2148 narrowed part.
2150 If a region is active, transcode that region.
2152 When optional argument SUBTREEP is non-nil, transcode the
2153 sub-tree at point, extracting information from the headline
2154 properties first.
2156 When optional argument VISIBLE-ONLY is non-nil, don't export
2157 contents of hidden elements.
2159 When optional argument BODY-ONLY is non-nil, only return body
2160 code, without surrounding template.
2162 Optional argument EXT-PLIST, when provided, is a property list
2163 with external parameters overriding Org default settings, but
2164 still inferior to file-local settings.
2166 Return code as a string.")
2167 #+end_src
2169 ###autoload
2170 #+begin_src emacs-lisp
2171 (defun org-export-to-buffer
2172   (backend buffer &optional subtreep visible-only body-only ext-plist)
2173   "Call `org-export-as' with output to a specified buffer.
2175 BACKEND is the back-end used for transcoding, as a symbol.
2177 BUFFER is the output buffer.  If it already exists, it will be
2178 erased first, otherwise, it will be created.
2180 Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY and
2181 EXT-PLIST are similar to those used in `org-export-as', which
2182 see.
2184 Depending on `org-export-copy-to-kill-ring', add buffer contents
2185 to kill ring.  Return buffer.")
2186 #+end_src
2188 ###autoload
2189 #+begin_src emacs-lisp
2190 (defun org-export-to-file
2191   (backend file &optional subtreep visible-only body-only ext-plist)
2192   "Call `org-export-as' with output to a specified file.
2194 BACKEND is the back-end used for transcoding, as a symbol.  FILE
2195 is the name of the output file, as a string.
2197 Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY and
2198 EXT-PLIST are similar to those used in `org-export-as', which
2199 see.
2201 Depending on `org-export-copy-to-kill-ring', add file contents
2202 to kill ring.  Return output file's name."
2203 #+end_src
2205 ###autoload
2206 #+begin_src emacs-lisp
2207 (defun org-export-string-as (string backend &optional body-only ext-plist)
2208   "Transcode STRING into BACKEND code.
2210 When optional argument BODY-ONLY is non-nil, only return body
2211 code, without preamble nor postamble.
2213 Optional argument EXT-PLIST, when provided, is a property list
2214 with external parameters overriding Org default settings, but
2215 still inferior to file-local settings.
2217 Return code as a string.")
2218 #+end_src
2220 ###autoload
2221 #+begin_src emacs-lisp
2222 (defun org-export-replace-region-by (backend)
2223   "Replace the active region by its export to BACKEND.")
2224 #+end_src
2226 ###autoload
2227 #+begin_src emacs-lisp
2228 (defun org-export-insert-default-template (&optional backend subtreep)
2229   "Insert all export keywords with default values at beginning of line.
2231 BACKEND is a symbol representing the export back-end for which
2232 specific export options should be added to the template, or
2233 `default' for default template.  When it is nil, the user will be
2234 prompted for a category.
2236 If SUBTREEP is non-nil, export configuration will be set up
2237 locally for the subtree through node properties.")
2239 (defun org-export-output-file-name (extension &optional subtreep pub-dir)
2240   "Return output file's name according to buffer specifications.
2242 EXTENSION is a string representing the output file extension,
2243 with the leading dot.
2245 With a non-nil optional argument SUBTREEP, try to determine
2246 output file's name by looking for \"EXPORT_FILE_NAME\" property
2247 of subtree at point.
2249 When optional argument PUB-DIR is set, use it as the publishing
2250 directory.
2252 When optional argument VISIBLE-ONLY is non-nil, don't export
2253 contents of hidden elements.
2255 Return file name as a string.")
2257 (defun org-export-expand-include-keyword (&optional included dir)
2258   "Expand every include keyword in buffer.
2259 Optional argument INCLUDED is a list of included file names along
2260 with their line restriction, when appropriate.  It is used to
2261 avoid infinite recursion.  Optional argument DIR is the current
2262 working directory.  It is used to properly resolve relative
2263 paths.")
2265 (defun org-export--prepare-file-contents (file &optional lines ind minlevel)
2266   "Prepare the contents of FILE for inclusion and return them as a string.
2268 When optional argument LINES is a string specifying a range of
2269 lines, include only those lines.
2271 Optional argument IND, when non-nil, is an integer specifying the
2272 global indentation of returned contents.  Since its purpose is to
2273 allow an included file to stay in the same environment it was
2274 created \(i.e. a list item), it doesn't apply past the first
2275 headline encountered.
2277 Optional argument MINLEVEL, when non-nil, is an integer
2278 specifying the level that any top-level headline in the included
2279 file should have.")
2281 (defun org-export-execute-babel-code ()
2282   "Execute every Babel code in the visible part of current buffer.")
2284 (defun org-export--copy-to-kill-ring-p ()
2285   "Return a non-nil value when output should be added to the kill ring.
2286 See also `org-export-copy-to-kill-ring'.")
2289 #+end_src
2291 * Tools For Back-Ends
2293 A whole set of tools is available to help build new exporters.  Any
2294 function general enough to have its use across many back-ends
2295 should be added here.
2297 ** For Affiliated Keywords
2299 `org-export-read-attribute' reads a property from a given element
2300  as a plist.  It can be used to normalize affiliated keywords'
2301  syntax.
2303 Since captions can span over multiple lines and accept dual values,
2304 their internal representation is a bit tricky.  Therefore,
2305 `org-export-get-caption' transparently returns a given element's
2306 caption as a secondary string.
2308 #+begin_src emacs-lisp
2309 (defun org-export-read-attribute (attribute element &optional property)
2310   "Turn ATTRIBUTE property from ELEMENT into a plist.
2312 When optional argument PROPERTY is non-nil, return the value of
2313 that property within attributes.
2315 This function assumes attributes are defined as \":keyword
2316 value\" pairs.  It is appropriate for `:attr_html' like
2317 properties.
2319 All values will become strings except the empty string and
2320 \"nil\", which will become nil.  Also, values containing only
2321 double quotes will be read as-is, which means that \"\" value
2322 will become the empty string.")
2324 (defun org-export-get-caption (element &optional shortp)
2325   "Return caption from ELEMENT as a secondary string.
2327 When optional argument SHORTP is non-nil, return short caption,
2328 as a secondary string, instead.
2330 Caption lines are separated by a white space.")
2332 #+end_src
2334 ** For Derived Back-ends
2336 `org-export-with-backend' is a function allowing to locally use
2337 another back-end to transcode some object or element.  In a derived
2338 back-end, it may be used as a fall-back function once all specific
2339 cases have been treated.
2341 #+begin_src emacs-lisp
2342 (defun org-export-with-backend (back-end data &optional contents info)
2343   "Call a transcoder from BACK-END on DATA.
2344 CONTENTS, when non-nil, is the transcoded contents of DATA
2345 element, as a string.  INFO, when non-nil, is the communication
2346 channel used for export, as a plist..")
2348 #+end_src
2350 ** For Export Snippets
2352 Every export snippet is transmitted to the back-end.  Though, the
2353 latter will only retain one type of export-snippet, ignoring
2354 others, based on the former's target back-end.  The function
2355 `org-export-snippet-backend' returns that back-end for a given
2356 export-snippet.
2358 #+begin_src emacs-lisp
2359 (defun org-export-snippet-backend (export-snippet)
2360   "Return EXPORT-SNIPPET targeted back-end as a symbol.
2361 Translation, with `org-export-snippet-translation-alist', is
2362 applied.")
2364 #+end_src
2366 ** For Footnotes
2368 `org-export-collect-footnote-definitions' is a tool to list
2369 actually used footnotes definitions in the whole parse tree, or in
2370 a headline, in order to add footnote listings throughout the
2371 transcoded data.
2373 `org-export-footnote-first-reference-p' is a predicate used by some
2374 back-ends, when they need to attach the footnote definition only to
2375 the first occurrence of the corresponding label.
2377 `org-export-get-footnote-definition' and
2378 `org-export-get-footnote-number' provide easier access to
2379 additional information relative to a footnote reference.
2381 #+begin_src emacs-lisp
2382 (defun org-export-collect-footnote-definitions (data info)
2383   "Return an alist between footnote numbers, labels and definitions.
2385 DATA is the parse tree from which definitions are collected.
2386 INFO is the plist used as a communication channel.
2388 Definitions are sorted by order of references.  They either
2389 appear as Org data or as a secondary string for inlined
2390 footnotes.  Unreferenced definitions are ignored.")
2392 (defun org-export-footnote-first-reference-p (footnote-reference info)
2393   "Non-nil when a footnote reference is the first one for its label.
2395 FOOTNOTE-REFERENCE is the footnote reference being considered.
2396 INFO is the plist used as a communication channel.")
2398 (defun org-export-get-footnote-definition (footnote-reference info)
2399   "Return definition of FOOTNOTE-REFERENCE as parsed data.
2400 INFO is the plist used as a communication channel.  If no such
2401 definition can be found, return the \"DEFINITION NOT FOUND\"
2402 string.")
2404 (defun org-export-get-footnote-number (footnote info)
2405   "Return number associated to a footnote.
2407 FOOTNOTE is either a footnote reference or a footnote definition.
2408 INFO is the plist used as a communication channel.")
2410 #+end_src
2412 ** For Headlines
2414 `org-export-get-relative-level' is a shortcut to get headline
2415 level, relatively to the lower headline level in the parsed tree.
2417 `org-export-get-headline-number' returns the section number of an
2418 headline, while `org-export-number-to-roman' allows to convert it
2419 to roman numbers.
2421 `org-export-low-level-p', `org-export-first-sibling-p' and
2422 `org-export-last-sibling-p' are three useful predicates when it
2423 comes to fulfill the `:headline-levels' property.
2425 `org-export-get-tags', `org-export-get-category' and
2426 `org-export-get-node-property' extract useful information from an
2427 headline or a parent headline.  They all handle inheritance.
2429 `org-export-get-alt-title' tries to retrieve an alternative title,
2430 as a secondary string, suitable for table of contents.  It falls
2431 back onto default title.
2433 #+begin_src emacs-lisp
2434 (defun org-export-get-relative-level (headline info)
2435   "Return HEADLINE relative level within current parsed tree.
2436 INFO is a plist holding contextual information.")
2438 (defun org-export-low-level-p (headline info)
2439   "Non-nil when HEADLINE is considered as low level.
2441 INFO is a plist used as a communication channel.
2443 A low level headlines has a relative level greater than
2444 `:headline-levels' property value.
2446 Return value is the difference between HEADLINE relative level
2447 and the last level being considered as high enough, or nil.")
2449 (defun org-export-get-headline-number (headline info)
2450   "Return HEADLINE numbering as a list of numbers.
2451 INFO is a plist holding contextual information.")
2453 (defun org-export-numbered-headline-p (headline info)
2454   "Return a non-nil value if HEADLINE element should be numbered.
2455 INFO is a plist used as a communication channel.")
2457 (defun org-export-number-to-roman (n)
2458   "Convert integer N into a roman numeral.")
2460 (defun org-export-get-tags (element info &optional tags inherited)
2461   "Return list of tags associated to ELEMENT.
2463 ELEMENT has either an `headline' or an `inlinetask' type.  INFO
2464 is a plist used as a communication channel.
2466 Select tags (see `org-export-select-tags') and exclude tags (see
2467 `org-export-exclude-tags') are removed from the list.
2469 When non-nil, optional argument TAGS should be a list of strings.
2470 Any tag belonging to this list will also be removed.
2472 When optional argument INHERITED is non-nil, tags can also be
2473 inherited from parent headlines and FILETAGS keywords.")
2475 (defun org-export-get-node-property (property blob &optional inherited)
2476   "Return node PROPERTY value for BLOB.
2478 PROPERTY is an upcase symbol (i.e. `:COOKIE_DATA').  BLOB is an
2479 element or object.
2481 If optional argument INHERITED is non-nil, the value can be
2482 inherited from a parent headline.
2484 Return value is a string or nil.")
2486 (defun org-export-get-category (blob info)
2487   "Return category for element or object BLOB.
2489 INFO is a plist used as a communication channel.
2491 CATEGORY is automatically inherited from a parent headline, from
2492 #+CATEGORY: keyword or created out of original file name.  If all
2493 fail, the fall-back value is \"???\".")
2495 (defun org-export-get-alt-title (headline info)
2496   "Return alternative title for HEADLINE, as a secondary string.
2497 INFO is a plist used as a communication channel.  If no optional
2498 title is defined, fall-back to the regular title.")
2500 (defun org-export-first-sibling-p (headline info)
2501   "Non-nil when HEADLINE is the first sibling in its sub-tree.
2502 INFO is a plist used as a communication channel.")
2504 (defun org-export-last-sibling-p (headline info)
2505   "Non-nil when HEADLINE is the last sibling in its sub-tree.
2506 INFO is a plist used as a communication channel.")
2508 #+end_src
2510 ** For Keywords
2512 `org-export-get-date' returns a date appropriate for the document
2513  to about to be exported.  In particular, it takes care of
2514  `org-export-date-timestamp-format'.
2516 #+begin_src emacs-lisp
2517 (defun org-export-get-date (info &optional fmt)
2518   "Return date value for the current document.
2520 INFO is a plist used as a communication channel.  FMT, when
2521 non-nil, is a time format string that will be applied on the date
2522 if it consists in a single timestamp object.  It defaults to
2523 `org-export-date-timestamp-format' when nil.
2525 A proper date can be a secondary string, a string or nil.  It is
2526 meant to be translated with `org-export-data' or alike.")
2528 #+end_src
2530 ** For Links
2532 `org-export-solidify-link-text' turns a string into a safer version
2533 for links, replacing most non-standard characters with hyphens.
2535 `org-export-get-coderef-format' returns an appropriate format
2536 string for coderefs.
2538 `org-export-inline-image-p' returns a non-nil value when the link
2539 provided should be considered as an inline image.
2541 `org-export-resolve-fuzzy-link' searches destination of fuzzy links
2542 (i.e. links with "fuzzy" as type) within the parsed tree, and
2543 returns an appropriate unique identifier when found, or nil.
2545 `org-export-resolve-id-link' returns the first headline with
2546 specified id or custom-id in parse tree, the path to the external
2547 file with the id or nil when neither was found.
2549 `org-export-resolve-coderef' associates a reference to a line
2550 number in the element it belongs, or returns the reference itself
2551 when the element isn't numbered.
2553 #+begin_src emacs-lisp
2554 (defun org-export-solidify-link-text (s)
2555   "Take link text S and make a safe target out of it.")
2557 (defun org-export-get-coderef-format (path desc)
2558   "Return format string for code reference link.
2559 PATH is the link path.  DESC is its description.")
2561 (defun org-export-inline-image-p (link &optional rules)
2562   "Non-nil if LINK object points to an inline image.
2564 Optional argument is a set of RULES defining inline images.  It
2565 is an alist where associations have the following shape:
2567   \(TYPE . REGEXP)
2569 Applying a rule means apply REGEXP against LINK's path when its
2570 type is TYPE.  The function will return a non-nil value if any of
2571 the provided rules is non-nil.  The default rule is
2572 `org-export-default-inline-image-rule'.
2574 This only applies to links without a description.")
2576 (defun org-export-resolve-coderef (ref info)
2577   "Resolve a code reference REF.
2579 INFO is a plist used as a communication channel.
2581 Return associated line number in source code, or REF itself,
2582 depending on src-block or example element's switches.")
2584 (defun org-export-resolve-fuzzy-link (link info)
2585   "Return LINK destination.
2587 INFO is a plist holding contextual information.
2589 Return value can be an object, an element, or nil:
2591 - If LINK path matches a target object (i.e. <<path>>) return it.
2593 - If LINK path exactly matches the name affiliated keyword
2594   \(i.e. #+NAME: path) of an element, return that element.
2596 - If LINK path exactly matches any headline name, return that
2597   element.  If more than one headline share that name, priority
2598   will be given to the one with the closest common ancestor, if
2599   any, or the first one in the parse tree otherwise.
2601 - Otherwise, return nil.
2603 Assume LINK type is \"fuzzy\".  White spaces are not
2604 significant.")
2606 (defun org-export-resolve-id-link (link info)
2607   "Return headline referenced as LINK destination.
2609 INFO is a plist used as a communication channel.
2611 Return value can be the headline element matched in current parse
2612 tree, a file name or nil.  Assume LINK type is either \"id\" or
2613 \"custom-id\".")
2615 (defun org-export-resolve-radio-link (link info)
2616   "Return radio-target object referenced as LINK destination.
2618 INFO is a plist used as a communication channel.
2620 Return value can be a radio-target object or nil.  Assume LINK
2621 has type \"radio\".")
2623 #+end_src
2625 ** For References
2627 `org-export-get-ordinal' associates a sequence number to any object
2628 or element.
2630 #+begin_src emacs-lisp
2631 (defun org-export-get-ordinal (element info &optional types predicate)
2632   "Return ordinal number of an element or object.
2634 ELEMENT is the element or object considered.  INFO is the plist
2635 used as a communication channel.
2637 Optional argument TYPES, when non-nil, is a list of element or
2638 object types, as symbols, that should also be counted in.
2639 Otherwise, only provided element's type is considered.
2641 Optional argument PREDICATE is a function returning a non-nil
2642 value if the current element or object should be counted in.  It
2643 accepts two arguments: the element or object being considered and
2644 the plist used as a communication channel.  This allows to count
2645 only a certain type of objects (i.e. inline images).
2647 Return value is a list of numbers if ELEMENT is a headline or an
2648 item.  It is nil for keywords.  It represents the footnote number
2649 for footnote definitions and footnote references.  If ELEMENT is
2650 a target, return the same value as if ELEMENT was the closest
2651 table, item or headline containing the target.  In any other
2652 case, return the sequence number of ELEMENT among elements or
2653 objects of the same type.")
2655 #+end_src
2657 ** For Src-Blocks
2659 `org-export-get-loc' counts number of code lines accumulated in
2660 src-block or example-block elements with a "+n" switch until
2661 a given element, excluded.  Note: "-n" switches reset that count.
2663 `org-export-unravel-code' extracts source code (along with a code
2664 references alist) from an `element-block' or `src-block' type
2665 element.
2667 `org-export-format-code' applies a formatting function to each line
2668 of code, providing relative line number and code reference when
2669 appropriate.  Since it doesn't access the original element from
2670 which the source code is coming, it expects from the code calling
2671 it to know if lines should be numbered and if code references
2672 should appear.
2674 Eventually, `org-export-format-code-default' is a higher-level
2675 function (it makes use of the two previous functions) which handles
2676 line numbering and code references inclusion, and returns source
2677 code in a format suitable for plain text or verbatim output.
2679 #+begin_src emacs-lisp
2680 (defun org-export-get-loc (element info)
2681   "Return accumulated lines of code up to ELEMENT.
2683 INFO is the plist used as a communication channel.
2685 ELEMENT is excluded from count.")
2687 (defun org-export-unravel-code (element)
2688   "Clean source code and extract references out of it.
2690 ELEMENT has either a `src-block' an `example-block' type.
2692 Return a cons cell whose CAR is the source code, cleaned from any
2693 reference and protective comma and CDR is an alist between
2694 relative line number (integer) and name of code reference on that
2695 line (string).")
2697 (defun org-export-format-code (code fun &optional num-lines ref-alist)
2698   "Format CODE by applying FUN line-wise and return it.
2700 CODE is a string representing the code to format.  FUN is
2701 a function.  It must accept three arguments: a line of
2702 code (string), the current line number (integer) or nil and the
2703 reference associated to the current line (string) or nil.
2705 Optional argument NUM-LINES can be an integer representing the
2706 number of code lines accumulated until the current code.  Line
2707 numbers passed to FUN will take it into account.  If it is nil,
2708 FUN's second argument will always be nil.  This number can be
2709 obtained with `org-export-get-loc' function.
2711 Optional argument REF-ALIST can be an alist between relative line
2712 number (i.e. ignoring NUM-LINES) and the name of the code
2713 reference on it.  If it is nil, FUN's third argument will always
2714 be nil.  It can be obtained through the use of
2715 `org-export-unravel-code' function.")
2717 (defun org-export-format-code-default (element info)
2718   "Return source code from ELEMENT, formatted in a standard way.
2720 ELEMENT is either a `src-block' or `example-block' element.  INFO
2721 is a plist used as a communication channel.
2723 This function takes care of line numbering and code references
2724 inclusion.  Line numbers, when applicable, appear at the
2725 beginning of the line, separated from the code by two white
2726 spaces.  Code references, on the other hand, appear flushed to
2727 the right, separated by six white spaces from the widest line of
2728 code.")
2730 #+end_src
2732 ** For Tables
2734 `org-export-table-has-special-column-p' and and
2735 `org-export-table-row-is-special-p' are predicates used to look for
2736 meta-information about the table structure.
2738 `org-table-has-header-p' tells when the rows before the first rule
2739  should be considered as table's header.
2741 `org-export-table-cell-width', `org-export-table-cell-alignment'
2742 and `org-export-table-cell-borders' extract information from
2743 a table-cell element.
2745 `org-export-table-dimensions' gives the number on rows and columns
2746 in the table, ignoring horizontal rules and special columns.
2747 `org-export-table-cell-address', given a table-cell object, returns
2748 the absolute address of a cell. On the other hand,
2749 `org-export-get-table-cell-at' does the contrary.
2751 `org-export-table-cell-starts-colgroup-p',
2752 `org-export-table-cell-ends-colgroup-p',
2753 `org-export-table-row-starts-rowgroup-p',
2754 `org-export-table-row-ends-rowgroup-p',
2755 `org-export-table-row-starts-header-p' and
2756 `org-export-table-row-ends-header-p' indicate position of current
2757 row or cell within the table.
2759 #+begin_src emacs-lisp
2760 (defun org-export-table-has-special-column-p (table)
2761   "Non-nil when TABLE has a special column.
2762 All special columns will be ignored during export."
2763   ;; The table has a special column when every first cell of every row
2764   ;; has an empty value or contains a symbol among "/", "#", "!", "$",
2765   ;; "*" "_" and "^")
2767 (defun org-export-table-has-header-p (table info)
2768   "Non-nil when TABLE has a header.
2770 INFO is a plist used as a communication channel.
2772 A table has a header when it contains at least two row groups.")
2774 (defun org-export-table-row-is-special-p (table-row info)
2775   "Non-nil if TABLE-ROW is considered special.
2777 INFO is a plist used as the communication channel.
2779 All special rows will be ignored during export.")
2781 (defun org-export-table-row-group (table-row info)
2782   "Return TABLE-ROW's group number, as an integer.
2784 INFO is a plist used as the communication channel.
2786 Return value is the group number, as an integer, or nil for
2787 special rows and rows separators.  First group is also table's
2788 header.")
2790 (defun org-export-table-cell-width (table-cell info)
2791   "Return TABLE-CELL contents width.
2793 INFO is a plist used as the communication channel.
2795 Return value is the width given by the last width cookie in the
2796 same column as TABLE-CELL, or nil.")
2798 (defun org-export-table-cell-alignment (table-cell info)
2799   "Return TABLE-CELL contents alignment.
2801 INFO is a plist used as the communication channel.
2803 Return alignment as specified by the last alignment cookie in the
2804 same column as TABLE-CELL.  If no such cookie is found, a default
2805 alignment value will be deduced from fraction of numbers in the
2806 column (see `org-table-number-fraction' for more information).
2807 Possible values are `left', `right' and `center'.")
2809 (defun org-export-table-cell-borders (table-cell info)
2810   "Return TABLE-CELL borders.
2812 INFO is a plist used as a communication channel.
2814 Return value is a list of symbols, or nil.  Possible values are:
2815 `top', `bottom', `above', `below', `left' and `right'.  Note:
2816 `top' (resp. `bottom') only happen for a cell in the first
2817 row (resp. last row) of the table, ignoring table rules, if any.
2819 Returned borders ignore special rows.")
2821 (defun org-export-table-cell-starts-colgroup-p (table-cell info)
2822   "Non-nil when TABLE-CELL is at the beginning of a row group.
2823 INFO is a plist used as a communication channel.")
2825 (defun org-export-table-cell-ends-colgroup-p (table-cell info)
2826   "Non-nil when TABLE-CELL is at the end of a row group.
2827 INFO is a plist used as a communication channel.")
2829 (defun org-export-table-row-starts-rowgroup-p (table-row info)
2830   "Non-nil when TABLE-ROW is at the beginning of a column group.
2831 INFO is a plist used as a communication channel.")
2833 (defun org-export-table-row-ends-rowgroup-p (table-row info)
2834   "Non-nil when TABLE-ROW is at the end of a column group.
2835 INFO is a plist used as a communication channel.")
2837 (defun org-export-table-row-starts-header-p (table-row info)
2838   "Non-nil when TABLE-ROW is the first table header's row.
2839 INFO is a plist used as a communication channel.")
2841 (defun org-export-table-row-ends-header-p (table-row info)
2842   "Non-nil when TABLE-ROW is the last table header's row.
2843 INFO is a plist used as a communication channel.")
2845 (defun org-export-table-row-number (table-row info)
2846   "Return TABLE-ROW number.
2847 INFO is a plist used as a communication channel.  Return value is
2848 zero-based and ignores separators.  The function returns nil for
2849 special colums and separators.")
2851 (defun org-export-table-dimensions (table info)
2852   "Return TABLE dimensions.
2854 INFO is a plist used as a communication channel.
2856 Return value is a CONS like (ROWS . COLUMNS) where
2857 ROWS (resp. COLUMNS) is the number of exportable
2858 rows (resp. columns).")
2860 (defun org-export-table-cell-address (table-cell info)
2861   "Return address of a regular TABLE-CELL object.
2863 TABLE-CELL is the cell considered.  INFO is a plist used as
2864 a communication channel.
2866 Address is a CONS cell (ROW . COLUMN), where ROW and COLUMN are
2867 zero-based index.  Only exportable cells are considered.  The
2868 function returns nil for other cells.")
2870 (defun org-export-get-table-cell-at (address table info)
2871   "Return regular table-cell object at ADDRESS in TABLE.
2873 Address is a CONS cell (ROW . COLUMN), where ROW and COLUMN are
2874 zero-based index.  TABLE is a table type element.  INFO is
2875 a plist used as a communication channel.
2877 If no table-cell, among exportable cells, is found at ADDRESS,
2878 return nil.")
2880 #+end_src
2882 ** For Tables Of Contents
2884 `org-export-collect-headlines' builds a list of all exportable
2885 headline elements, maybe limited to a certain depth.  One can then
2886 easily parse it and transcode it.
2888 Building lists of tables, figures or listings is quite similar.
2889 Once the generic function `org-export-collect-elements' is defined,
2890 `org-export-collect-tables', `org-export-collect-figures' and
2891 `org-export-collect-listings' can be derived from it.
2893 #+begin_src emacs-lisp
2894 (defun org-export-collect-headlines (info &optional n)
2895   "Collect headlines in order to build a table of contents.
2897 INFO is a plist used as a communication channel.
2899 When optional argument N is an integer, it specifies the depth of
2900 the table of contents.  Otherwise, it is set to the value of the
2901 last headline level.  See `org-export-headline-levels' for more
2902 information.
2904 Return a list of all exportable headlines as parsed elements.
2905 Footnote sections, if any, will be ignored.")
2907 (defun org-export-collect-elements (type info &optional predicate)
2908   "Collect referenceable elements of a determined type.
2910 TYPE can be a symbol or a list of symbols specifying element
2911 types to search.  Only elements with a caption are collected.
2913 INFO is a plist used as a communication channel.
2915 When non-nil, optional argument PREDICATE is a function accepting
2916 one argument, an element of type TYPE.  It returns a non-nil
2917 value when that element should be collected.
2919 Return a list of all elements found, in order of appearance.")
2921 (defun org-export-collect-tables (info)
2922   "Build a list of tables.
2923 INFO is a plist used as a communication channel.
2925 Return a list of table elements with a caption.")
2927 (defun org-export-collect-figures (info predicate)
2928   "Build a list of figures.
2930 INFO is a plist used as a communication channel.  PREDICATE is
2931 a function which accepts one argument: a paragraph element and
2932 whose return value is non-nil when that element should be
2933 collected.
2935 A figure is a paragraph type element, with a caption, verifying
2936 PREDICATE.  The latter has to be provided since a \"figure\" is
2937 a vague concept that may depend on back-end.
2939 Return a list of elements recognized as figures.")
2941 (defun org-export-collect-listings (info)
2942   "Build a list of src blocks.
2944 INFO is a plist used as a communication channel.
2946 Return a list of src-block elements with a caption.")
2948 #+end_src
2950 ** Smart Quotes
2952 The main function for the smart quotes sub-system is
2953 `org-export-activate-smart-quotes', which replaces every quote in
2954 a given string from the parse tree with its "smart" counterpart.
2956 Dictionary for smart quotes is stored in
2957 `org-export-smart-quotes-alist'.
2959 Internally, regexps matching potential smart quotes (checks at
2960 string boundaries are also necessary) are defined in
2961 `org-export-smart-quotes-regexps'.
2963 #+begin_src emacs-lisp
2964 (defconst org-export-smart-quotes-alist
2965   '(("de"
2966      (opening-double-quote :utf-8 "„" :html "&bdquo;" :latex "\"`"
2967                            :texinfo "@quotedblbase{}")
2968      (closing-double-quote :utf-8 "“" :html "&ldquo;" :latex "\"'"
2969                            :texinfo "@quotedblleft{}")
2970      (opening-single-quote :utf-8 "‚" :html "&sbquo;" :latex "\\glq{}"
2971                            :texinfo "@quotesinglbase{}")
2972      (closing-single-quote :utf-8 "‘" :html "&lsquo;" :latex "\\grq{}"
2973                            :texinfo "@quoteleft{}")
2974      (apostrophe :utf-8 "’" :html "&rsquo;"))
2975     ("en"
2976      (opening-double-quote :utf-8 "“" :html "&ldquo;" :latex "``" :texinfo "``")
2977      (closing-double-quote :utf-8 "”" :html "&rdquo;" :latex "''" :texinfo "''")
2978      (opening-single-quote :utf-8 "‘" :html "&lsquo;" :latex "`" :texinfo "`")
2979      (closing-single-quote :utf-8 "’" :html "&rsquo;" :latex "'" :texinfo "'")
2980      (apostrophe :utf-8 "’" :html "&rsquo;"))
2981     ("es"
2982      (opening-double-quote :utf-8 "«" :html "&laquo;" :latex "\\guillemotleft{}"
2983                            :texinfo "@guillemetleft{}")
2984      (closing-double-quote :utf-8 "»" :html "&raquo;" :latex "\\guillemotright{}"
2985                            :texinfo "@guillemetright{}")
2986      (opening-single-quote :utf-8 "“" :html "&ldquo;" :latex "``" :texinfo "``")
2987      (closing-single-quote :utf-8 "”" :html "&rdquo;" :latex "''" :texinfo "''")
2988      (apostrophe :utf-8 "’" :html "&rsquo;"))
2989     ("fr"
2990      (opening-double-quote :utf-8 "« " :html "&laquo;&nbsp;" :latex "\\og "
2991                            :texinfo "@guillemetleft{}@tie{}")
2992      (closing-double-quote :utf-8 " »" :html "&nbsp;&raquo;" :latex "\\fg{}"
2993                            :texinfo "@tie{}@guillemetright{}")
2994      (opening-single-quote :utf-8 "« " :html "&laquo;&nbsp;" :latex "\\og "
2995                            :texinfo "@guillemetleft{}@tie{}")
2996      (closing-single-quote :utf-8 " »" :html "&nbsp;&raquo;" :latex "\\fg{}"
2997                            :texinfo "@tie{}@guillemetright{}")
2998      (apostrophe :utf-8 "’" :html "&rsquo;")))
2999   "Smart quotes translations.
3001 Alist whose CAR is a language string and CDR is an alist with
3002 quote type as key and a plist associating various encodings to
3003 their translation as value.
3005 A quote type can be any symbol among `opening-double-quote',
3006 `closing-double-quote', `opening-single-quote',
3007 `closing-single-quote' and `apostrophe'.
3009 Valid encodings include `:utf-8', `:html', `:latex' and
3010 `:texinfo'.
3012 If no translation is found, the quote character is left as-is.")
3014 (defconst org-export-smart-quotes-regexps
3015   (list
3016    ;; Possible opening quote at beginning of string.
3017    "\\`\\([\"']\\)\\(\\w\\|\\s.\\|\\s_\\)"
3018    ;; Possible closing quote at beginning of string.
3019    "\\`\\([\"']\\)\\(\\s-\\|\\s)\\|\\s.\\)"
3020    ;; Possible apostrophe at beginning of string.
3021    "\\`\\('\\)\\S-"
3022    ;; Opening single and double quotes.
3023    "\\(?:\\s-\\|\\s(\\)\\([\"']\\)\\(?:\\w\\|\\s.\\|\\s_\\)"
3024    ;; Closing single and double quotes.
3025    "\\(?:\\w\\|\\s.\\|\\s_\\)\\([\"']\\)\\(?:\\s-\\|\\s)\\|\\s.\\)"
3026    ;; Apostrophe.
3027    "\\S-\\('\\)\\S-"
3028    ;; Possible opening quote at end of string.
3029    "\\(?:\\s-\\|\\s(\\)\\([\"']\\)\\'"
3030    ;; Possible closing quote at end of string.
3031    "\\(?:\\w\\|\\s.\\|\\s_\\)\\([\"']\\)\\'"
3032    ;; Possible apostrophe at end of string.
3033    "\\S-\\('\\)\\'")
3034   "List of regexps matching a quote or an apostrophe.
3035 In every regexp, quote or apostrophe matched is put in group 1.")
3037 (defun org-export-activate-smart-quotes (s encoding info &optional original)
3038   "Replace regular quotes with \"smart\" quotes in string S.
3040 ENCODING is a symbol among `:html', `:latex', `:texinfo' and
3041 `:utf-8'.  INFO is a plist used as a communication channel.
3043 The function has to retrieve information about string
3044 surroundings in parse tree.  It can only happen with an
3045 unmodified string.  Thus, if S has already been through another
3046 process, a non-nil ORIGINAL optional argument will provide that
3047 original string.
3049 Return the new string.")
3050 #+end_src
3052 ** Topology
3054 Here are various functions to retrieve information about the
3055 neighbourhood of a given element or object.  Neighbours of interest
3056 are direct parent (`org-export-get-parent'), parent headline
3057 (`org-export-get-parent-headline'), first element containing an
3058 object, (`org-export-get-parent-element'), parent table
3059 (`org-export-get-parent-table'), previous element or object
3060 (`org-export-get-previous-element') and next element or object
3061 (`org-export-get-next-element').
3063 `org-export-get-genealogy' returns the full genealogy of a given
3064 element or object, from closest parent to full parse tree.
3066 #+begin_src emacs-lisp
3067 (defsubst org-export-get-parent (blob)
3068   "Return BLOB parent or nil.
3069 BLOB is the element or object considered.")
3071 (defun org-export-get-genealogy (blob)
3072   "Return full genealogy relative to a given element or object.
3074 BLOB is the element or object being considered.
3076 Ancestors are returned from closest to farthest, the last one
3077 being the full parse tree.")
3079 (defun org-export-get-parent-headline (blob)
3080   "Return BLOB parent headline or nil.
3081 BLOB is the element or object being considered.")
3083 (defun org-export-get-parent-element (object)
3084   "Return first element containing OBJECT or nil.
3085 OBJECT is the object to consider.")
3087 (defun org-export-get-parent-table (object)
3088   "Return OBJECT parent table or nil.
3089 OBJECT is either a `table-cell' or `table-element' type object.")
3091 (defun org-export-get-previous-element (blob info &optional n)
3092   "Return previous element or object.
3094 BLOB is an element or object.  INFO is a plist used as
3095 a communication channel.  Return previous exportable element or
3096 object, a string, or nil.
3098 When optional argument N is a positive integer, return a list
3099 containing up to N siblings before BLOB, from farthest to
3100 closest.  With any other non-nil value, return a list containing
3101 all of them.")
3103 (defun org-export-get-next-element (blob info &optional n)
3104   "Return next element or object.
3106 BLOB is an element or object.  INFO is a plist used as
3107 a communication channel.  Return next exportable element or
3108 object, a string, or nil.
3110 When optional argument N is a positive integer, return a list
3111 containing up to N siblings after BLOB, from closest to farthest.
3112 With any other non-nil value, return a list containing all of
3113 them.")
3115 #+end_src
3117 ** Translation
3119 `org-export-translate' translates a string according to language
3120 specified by LANGUAGE keyword or `org-export-language-setup'
3121 variable and a specified charset.  `org-export-dictionary' contains
3122 the dictionary used for the translation.
3124 #+begin_src emacs-lisp
3125 (defconst org-export-dictionary
3126   '(("Author"
3127      ("ca" :default "Autor")
3128      ("cs" :default "Autor")
3129      ("da" :default "Ophavsmand")
3130      ("de" :default "Autor")
3131      ("eo" :html "A&#365;toro")
3132      ("es" :default "Autor")
3133      ("fi" :html "Tekij&auml;")
3134      ("fr" :default "Auteur")
3135      ("hu" :default "Szerz&otilde;")
3136      ("is" :html "H&ouml;fundur")
3137      ("it" :default "Autore")
3138      ("ja" :html "&#33879;&#32773;" :utf-8 "著者")
3139      ("nl" :default "Auteur")
3140      ("no" :default "Forfatter")
3141      ("nb" :default "Forfatter")
3142      ("nn" :default "Forfattar")
3143      ("pl" :default "Autor")
3144      ("ru" :html "&#1040;&#1074;&#1090;&#1086;&#1088;" :utf-8 "Автор")
3145      ("sv" :html "F&ouml;rfattare")
3146      ("uk" :html "&#1040;&#1074;&#1090;&#1086;&#1088;" :utf-8 "Автор")
3147      ("zh-CN" :html "&#20316;&#32773;" :utf-8 "作者")
3148      ("zh-TW" :html "&#20316;&#32773;" :utf-8 "作者"))
3149     ("Date"
3150      ("ca" :default "Data")
3151      ("cs" :default "Datum")
3152      ("da" :default "Dato")
3153      ("de" :default "Datum")
3154      ("eo" :default "Dato")
3155      ("es" :default "Fecha")
3156      ("fi" :html "P&auml;iv&auml;m&auml;&auml;r&auml;")
3157      ("hu" :html "D&aacute;tum")
3158      ("is" :default "Dagsetning")
3159      ("it" :default "Data")
3160      ("ja" :html "&#26085;&#20184;" :utf-8 "日付")
3161      ("nl" :default "Datum")
3162      ("no" :default "Dato")
3163      ("nb" :default "Dato")
3164      ("nn" :default "Dato")
3165      ("pl" :default "Data")
3166      ("ru" :html "&#1044;&#1072;&#1090;&#1072;" :utf-8 "Дата")
3167      ("sv" :default "Datum")
3168      ("uk" :html "&#1044;&#1072;&#1090;&#1072;" :utf-8 "Дата")
3169      ("zh-CN" :html "&#26085;&#26399;" :utf-8 "日期")
3170      ("zh-TW" :html "&#26085;&#26399;" :utf-8 "日期"))
3171     ("Equation"
3172      ("fr" :ascii "Equation" :default "Équation"))
3173     ("Figure")
3174     ("Footnotes"
3175      ("ca" :html "Peus de p&agrave;gina")
3176      ("cs" :default "Pozn\xe1mky pod carou")
3177      ("da" :default "Fodnoter")
3178      ("de" :html "Fu&szlig;noten")
3179      ("eo" :default "Piednotoj")
3180      ("es" :html "Pies de p&aacute;gina")
3181      ("fi" :default "Alaviitteet")
3182      ("fr" :default "Notes de bas de page")
3183      ("hu" :html "L&aacute;bjegyzet")
3184      ("is" :html "Aftanm&aacute;lsgreinar")
3185      ("it" :html "Note a pi&egrave; di pagina")
3186      ("ja" :html "&#33050;&#27880;" :utf-8 "脚注")
3187      ("nl" :default "Voetnoten")
3188      ("no" :default "Fotnoter")
3189      ("nb" :default "Fotnoter")
3190      ("nn" :default "Fotnotar")
3191      ("pl" :default "Przypis")
3192      ("ru" :html "&#1057;&#1085;&#1086;&#1089;&#1082;&#1080;" :utf-8 "Сноски")
3193      ("sv" :default "Fotnoter")
3194      ("uk" :html "&#1055;&#1088;&#1080;&#1084;&#1110;&#1090;&#1082;&#1080;"
3195       :utf-8 "Примітки")
3196      ("zh-CN" :html "&#33050;&#27880;" :utf-8 "脚注")
3197      ("zh-TW" :html "&#33139;&#35387;" :utf-8 "腳註"))
3198     ("List of Listings"
3199      ("fr" :default "Liste des programmes"))
3200     ("List of Tables"
3201      ("fr" :default "Liste des tableaux"))
3202     ("Listing %d:"
3203      ("fr"
3204       :ascii "Programme %d :" :default "Programme nº %d :"
3205       :latin1 "Programme %d :"))
3206     ("Listing %d: %s"
3207      ("fr"
3208       :ascii "Programme %d : %s" :default "Programme nº %d : %s"
3209       :latin1 "Programme %d : %s"))
3210     ("See section %s"
3211      ("fr" :default "cf. section %s"))
3212     ("Table %d:"
3213      ("fr"
3214       :ascii "Tableau %d :" :default "Tableau nº %d :" :latin1 "Tableau %d :"))
3215     ("Table %d: %s"
3216      ("fr"
3217       :ascii "Tableau %d : %s" :default "Tableau nº %d : %s"
3218       :latin1 "Tableau %d : %s"))
3219     ("Table of Contents"
3220      ("ca" :html "&Iacute;ndex")
3221      ("cs" :default "Obsah")
3222      ("da" :default "Indhold")
3223      ("de" :default "Inhaltsverzeichnis")
3224      ("eo" :default "Enhavo")
3225      ("es" :html "&Iacute;ndice")
3226      ("fi" :html "Sis&auml;llysluettelo")
3227      ("fr" :ascii "Sommaire" :default "Table des matières")
3228      ("hu" :html "Tartalomjegyz&eacute;k")
3229      ("is" :default "Efnisyfirlit")
3230      ("it" :default "Indice")
3231      ("ja" :html "&#30446;&#27425;" :utf-8 "目次")
3232      ("nl" :default "Inhoudsopgave")
3233      ("no" :default "Innhold")
3234      ("nb" :default "Innhold")
3235      ("nn" :default "Innhald")
3236      ("pl" :html "Spis tre&#x015b;ci")
3237      ("ru" :html "&#1057;&#1086;&#1076;&#1077;&#1088;&#1078;&#1072;&#1085;&#1080;&#1077;"
3238       :utf-8 "Содержание")
3239      ("sv" :html "Inneh&aring;ll")
3240      ("uk" :html "&#1047;&#1084;&#1110;&#1089;&#1090;" :utf-8 "Зміст")
3241      ("zh-CN" :html "&#30446;&#24405;" :utf-8 "目录")
3242      ("zh-TW" :html "&#30446;&#37636;" :utf-8 "目錄"))
3243     ("Unknown reference"
3244      ("fr" :ascii "Destination inconnue" :default "Référence inconnue")))
3245   "Dictionary for export engine.
3247 Alist whose CAR is the string to translate and CDR is an alist
3248 whose CAR is the language string and CDR is a plist whose
3249 properties are possible charsets and values translated terms.
3251 It is used as a database for `org-export-translate'. Since this
3252 function returns the string as-is if no translation was found,
3253 the variable only needs to record values different from the
3254 entry.")
3256 (defun org-export-translate (s encoding info)
3257   "Translate string S according to language specification.
3259 ENCODING is a symbol among `:ascii', `:html', `:latex', `:latin1'
3260 and `:utf-8'.  INFO is a plist used as a communication channel.
3262 Translation depends on `:language' property. Return the
3263 translated string. If no translation is found, try to fall back
3264 to `:default' encoding. If it fails, return S.")
3267 #+end_src
3269 * Asynchronous Export
3271 `org-export-async-start' is the entry point for asynchronous
3272 export.  It recreates current buffer (including visibility,
3273 narrowing and visited file) in an external Emacs process, and
3274 evaluates a command there.  It then applies a function on the
3275 returned results in the current process.
3277 Asynchronously generated results are never displayed directly.
3278 Instead, they are stored in `org-export-stack-contents'.  They can
3279 then be retrieved by calling `org-export-stack'.
3281 Export Stack is viewed through a dedicated major mode
3282 `org-export-stack-mode' and tools: `org-export-stack-refresh',
3283 `org-export-stack-delete', `org-export-stack-view' and
3284 `org-export-stack-clear'.
3286 For back-ends, `org-export-add-to-stack' add a new source to stack.
3287 It should used whenever `org-export-async-start' is called.
3289 #+begin_src emacs-lisp
3290 (defmacro org-export-async-start  (fun &rest body)
3291   "Call function FUN on the results returned by BODY evaluation.
3293 BODY evaluation happens in an asynchronous process, from a buffer
3294 which is an exact copy of the current one.
3296 Use `org-export-add-to-stack' in FUN in order to register results
3297 in the stack.  Examples for, respectively a temporary buffer and
3298 a file are:
3300   \(org-export-async-start
3301       \(lambda (output)
3302         \(with-current-buffer (get-buffer-create \"*Org BACKEND Export*\")
3303         \(erase-buffer)
3304         \(insert output)
3305         \(goto-char (point-min))
3306         \(org-export-add-to-stack (current-buffer) 'backend)))
3307     `(org-export-as 'backend ,subtreep ,visible-only ,body-only ',ext-plist))
3311   \(org-export-async-start
3312       \(lambda (f) (org-export-add-to-stack f 'backend))
3313     `(expand-file-name
3314       \(org-export-to-file
3315        'backend ,outfile ,subtreep ,visible-only ,body-only ',ext-plist)))")
3317 (defun org-export-add-to-stack (source backend &optional process)
3318   "Add a new result to export stack if not present already.
3320 SOURCE is a buffer or a file name containing export results.
3321 BACKEND is a symbol representing export back-end used to generate
3324 Entries already pointing to SOURCE and unavailable entries are
3325 removed beforehand.  Return the new stack.")
3327 (defun org-export-stack ()
3328   "Menu for asynchronous export results and running processes.")
3330 (defun org-export--stack-source-at-point ()
3331   "Return source from export results at point in stack.")
3333 (defun org-export-stack-clear ()
3334   "Remove all entries from export stack.")
3336 (defun org-export-stack-refresh (&rest dummy)
3337   "Refresh the asynchronous export stack.
3338 DUMMY is ignored.  Unavailable sources are removed from the list.
3339 Return the new stack.")
3341 (defun org-export-stack-remove (&optional source)
3342   "Remove export results at point from stack.
3343 If optional argument SOURCE is non-nil, remove it instead.")
3345 (defun org-export-stack-view (&optional in-emacs)
3346   "View export results at point in stack.
3347 With an optional prefix argument IN-EMACS, force viewing files
3348 within Emacs.")
3350 (defconst org-export-stack-mode-map
3351   (let ((km (make-sparse-keymap)))
3352     (define-key km " " 'next-line)
3353     (define-key km "n" 'next-line)
3354     (define-key km "\C-n" 'next-line)
3355     (define-key km [down] 'next-line)
3356     (define-key km "p" 'previous-line)
3357     (define-key km "\C-p" 'previous-line)
3358     (define-key km "\C-?" 'previous-line)
3359     (define-key km [up] 'previous-line)
3360     (define-key km "C" 'org-export-stack-clear)
3361     (define-key km "v" 'org-export-stack-view)
3362     (define-key km (kbd "RET") 'org-export-stack-view)
3363     (define-key km "d" 'org-export-stack-remove)
3364     km)
3365   "Keymap for Org Export Stack.")
3367 (define-derived-mode org-export-stack-mode special-mode "Org-Stack"
3368   "Mode for displaying asynchronous export stack.
3370 Type \\[org-export-stack] to visualize the asynchronous export
3371 stack.
3373 In an Org Export Stack buffer, use \\<org-export-stack-mode-map>\\[org-export-stack-view] to view export output
3374 on current line, \\[org-export-stack-remove] to remove it from the stack and \\[org-export-stack-clear] to clear
3375 stack completely.
3377 Removing entries in an Org Export Stack buffer doesn't affect
3378 files or buffers, only the display.
3380 \\{org-export-stack-mode-map}"
3381   (abbrev-mode 0)
3382   (auto-fill-mode 0)
3383   (setq buffer-read-only t
3384         buffer-undo-list t
3385         truncate-lines t
3386         header-line-format
3387         '(:eval
3388           (format "  %-12s | %6s | %s" "Back-End" "Age" "Source")))
3389   (org-add-hook 'post-command-hook 'org-export-stack-refresh nil t)
3390   (set (make-local-variable 'revert-buffer-function)
3391        'org-export-stack-refresh))
3394 #+end_src
3396 * The Dispatcher
3398 `org-export-dispatch' is the standard interactive way to start an
3399 export process.  It uses `org-export--dispatch-ui' as a subroutine
3400 for its interface, which, in turn, delegates response to key
3401 pressed to `org-export--dispatch-action'.
3403 ###autoload
3404 #+begin_src emacs-lisp
3405   (defun org-export-dispatch (&optional arg)
3406     "Export dispatcher for Org mode.
3408   It provides an access to common export related tasks in a buffer.
3409   Its interface comes in two flavours: standard and expert.
3411   While both share the same set of bindings, only the former
3412   displays the valid keys associations in a dedicated buffer.
3413   Scrolling (resp. line-wise motion) in this buffer is done with
3414   SPC and DEL (resp. C-n and C-p) keys.
3416   Set variable `org-export-dispatch-use-expert-ui' to switch to one
3417   flavour or the other.
3419   When ARG is \\[universal-argument], repeat the last export action, with the same set
3420   of options used back then, on the current buffer.
3422   When ARG is \\[universal-argument] \\[universal-argument],
3423   display the asynchronous export stack.")
3425   (defun org-export--dispatch-ui (options first-key expertp)
3426     "Handle interface for `org-export-dispatch'.
3428   OPTIONS is a list containing current interactive options set for
3429   export.  It can contain any of the following symbols:
3430   `body'    toggles a body-only export
3431   `subtree' restricts export to current subtree
3432   `visible' restricts export to visible part of buffer.
3433   `force'   force publishing files.
3434   `async'   use asynchronous export process
3436   FIRST-KEY is the key pressed to select the first level menu.  It
3437   is nil when this menu hasn't been selected yet.
3439   EXPERTP, when non-nil, triggers expert UI.  In that case, no help
3440   buffer is provided, but indications about currently active
3441   options are given in the prompt.  Moreover, \[?] allows to switch
3442   back to standard interface.")
3444   (defun org-export--dispatch-action
3445     (prompt allowed-keys backends options first-key expertp)
3446     "Read a character from command input and act accordingly.
3448   PROMPT is the displayed prompt, as a string.  ALLOWED-KEYS is
3449   a list of characters available at a given step in the process.
3450   BACKENDS is a list of menu entries.  OPTIONS, FIRST-KEY and
3451   EXPERTP are the same as defined in `org-export--dispatch-ui',
3452   which see.
3454   Toggle export options when required.  Otherwise, return value is
3455   a list with action as CAR and a list of interactive export
3456   options as CDR.")
3458   (provide 'ox)
3459 #+end_src
3461 Local variables:
3462 generated-autoload-file: "org-loaddefs.el"
3463 End:
3465 * ox.el ends here