Next: , Previous: Editing source code, Up: Working With Source Code

14.3 Exporting code blocks

It is possible to export the code of code blocks, the results of code block evaluation, both the code and the results of code block evaluation, or none. For most languages, the default exports code. However, for some languages (e.g., ditaa) the default exports the results of code block evaluation. For information on exporting code block bodies, see Literal examples.

The :exports header argument can be used to specify export behavior:

Header arguments:
:exports code
The default in most languages. The body of the code block is exported, as described in Literal examples.
:exports results
The code block will be evaluated and the results will be placed in the Org mode buffer for export, either updating previous results of the code block located anywhere in the buffer or, if no previous results exist, placing the results immediately after the code block. The body of the code block will not be exported.
:exports both
Both the code block and its results will be exported.
:exports none
Neither the code block nor its results will be exported.

It is possible to inhibit the evaluation of code blocks during export. Setting the org-export-babel-evaluate variable to nil will ensure that no code blocks are evaluated as part of the export process. This can be useful in situations where potentially untrusted Org mode files are exported in an automated fashion, for example when Org mode is used as the markup language for a wiki. It is also possible to set this variable to 'inline-only. In that case, only inline code blocks will be evaluated, in order to insert their results. Non-inline code blocks are assumed to have their results already inserted in the buffer by manual evaluation. This setting is useful to avoid expensive recalculations during export, not to provide security.