"Fossies" - the Fresh Open Source Software Archive

Member "pandoc-2.18/doc/org.md" (4 Apr 2022, 10550 Bytes) of package /linux/www/pandoc-2.18.tar.gz:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field. See also the latest Fossies "Diffs" side-by-side code changes report for "org.md":

Pandoc's handling of org files is similar to that of Emacs org-mode. This document aims to highlight the cases where this is not possible or just not the case yet.

Export options

The following export keywords are supported:

::: {.alert .alert-info} Pandoc tries to be compatible with org-mode when exporting an org document. If you find some behavior confusing, please do refer to org-mode Export-Settings documentation. For example, a common confusion (#3214, #5169, #6145, #7236) is treatment of headers with level > 3 differently because org-mode sets org-export-headline-levels (configurable with #+OPTIONS: H:3) to 3 by default. :::

Format-specific options

Emacs Org-mode supports additional export options which work for specific export formats. Some of these options' behavior differs in Org-mode depending on the output format, while pandoc is format-agnostic when parsing; differences are noted where they occur.

Pandoc-specific options

Pandoc recognizes some export options not used by Emacs Org.

Other options

Any export option or directive not listed above has no effect when parsing with pandoc. However, the information is retained as a raw block. It can be accessed through a filter and will be included in org output.

Directives as metadata

As an example, we will restore an old behavior of pandoc versions prior to 2.10. Unknown keywords were treated as variable definitions, and were added the document's metadata. Typing #+key: value in the org-file used to have the same effect as running pandoc with the --metadata key=value option.

Since pandoc 2.10, each unhandled line starting with #+ is kept internally as a raw block with format org. This block can be inspected and processed by a filter. Below is a Lua filter which converts these unhandled lines into metadata key-value pairs.

-- intermediate store for variables and their values
local variables = {}

--- Function called for each raw block element.
function RawBlock (raw)
  -- Don't do anything unless the block contains *org* markup.
  if raw.format ~= 'org' then return nil end

  -- extract variable name and value
  local name, value = raw.text:match '#%+(%w+):%s*(.+)$'
  if name and value then
    variables[name] = value

-- Add the extracted variables to the document's metadata.
function Meta (meta)
  for name, value in pairs(variables) do
    meta[name] = value
  return meta


Pandoc supports normal org tables (sometimes called "pipe tables") and grid tables (tables created by table.el).

Column widths

Org mode tables don't allow line-breaks within cells, and lines which contain text can get very long. This often leads to tables which run off the page when exporting, especially when exporting to PDF via LaTeX. Overlong lines in the source text are this is usually hidden by setting a column width, but the default Emacs exporters ignore that setting. Pandoc deviates from Emacs's behavior and uses this information to resize the table columns when exporting.


There is no support yet for cells spanning multiple columns or rows. The table.el grid tables allows rowspans and colspans and so does pandoc's internal structure since 2.10, but the parser has not been updated yet.

Emphasis rules

Org-mode uses complex rules to decide whether a string represents emphasized text. In Emacs, this can be customized via the variable org-emphasis-regexp-components. A variable like this doesn't fit well with pandoc's model. Instead, it is possible to use special lines to change these values:

#+pandoc-emphasis-pre: "-\t ('\"{"
#+pandoc-emphasis-post: "-\t\n .,:!?;'\")}["

The above describes the default values of these variables. The arguments must be valid (Haskell) strings. If interpretation of the argument as string fails, the default is restored.

Changing emphasis rules only affect the part of the document following the special lines. They must be some of the first lines to alter parsing behavior for the whole document. It is also possible to change the values temporarily for selected sections only. The string test in the following snippet will be read as emphasized text, while the rest of the document will be parsed using default emphasis rules:

#+pandoc-emphasis-pre: "["
#+pandoc-emphasis-post: "]"

smart extension

Org-mode allows to insert certain characters via special character sequences. For example, instead of typing the Unicode /HORIZONTAL ELLISPIS/ character by hand, one can instead type tree dots .... En dashes and em dashes can be written as -- and --- respectively. Furthermore, quotation marks (") and apostrophe-quotes (') can be treated in a "smart" way, potentially replacing them with proper, language specific unicode quotation characters.

Like in Markdown, these behaviors can be turned on all-at-once by enabling the smart extension. However, disabling smart (the default) will not necessarily disable smart quotes and special strings. Instead, it will just result in the default Org mode behavior.

The special string feature can be turned off via the #+OPTIONS: -:nil export setting. There are currently no command line flags which control these features. As a workaround, one can use process substitution, a feature supported by most shells. It allows to provide the options line on the command line:

pandoc -f org <(printf "#+OPTIONS: -:nil\n") …

fancy_lists extension

Org-mode has a variable org-list-allow-alphabetical that when set to t, allows ordered lists with single-character alphabetical markers. Since this variable is nil by default, alphabetical markers can be optionally enabled in Pandoc by enabling the fancy_lists extension.

When fancy_lists is enabled, Pandoc will also parse list markers starting with one lowercase or uppercase alphabetical character, like a. and D). Countrary to the use of this extension in markdown, roman numerals or the # placeholder can't be used as markers as they are not allowed in Org-mode.

One additional behavior that is enabled by the fancy_lists extension is that the . and ) delimiters for list markers will be distinguished by Pandoc. In essence, this means that when converting Org into formats like LaTeX, Pandoc will respect the type of delimiter that you used in your Org file, instead of always using the default delimiter for the exported format.

Currently unsupported features

Library of babel

The library of babel translates between various programming languages. This is out-of-scope for pandoc. Use Emacs to run code, then feed the resulting org file to pandoc.