orgize/docs/SYNTAX.md

943 lines
27 KiB
Markdown
Raw Normal View History

2020-05-16 11:35:27 +01:00
# Table of Contents
1. [Headlines and Sections](#Headlines_and_Sections)
2. [Affiliated Keywords](#Affiliated_keywords)
3. [Greater Elements](#Greater_Elements)
1. [Greater Blocks](#Greater_Blocks)
2. [Drawers and Property Drawers](#Drawers)
3. [Dynamic Blocks](#Dynamic_Blocks)
4. [Footnote Definitions](#Footnote_Definitions)
5. [Inlinetasks](#Inlinetasks)
6. [Plain Lists and Items](#Plain_Lists_and_Items)
7. [Property Drawers](#Property_Drawers)
8. [Tables](#Tables)
4. [Elements](#Elements)
1. [Babel Call](#Babel_Call)
2. [Blocks](#Blocks)
3. [Clock, Diary Sexp and Planning](#Clock,_Diary_Sexp_and_Planning)
4. [Comments](#Comments)
5. [Fixed Width Areas](#Fixed_Width_Areas)
6. [Horizontal Rules](#Horizontal_Rules)
7. [Keywords](#Keywords)
8. [LaTeX Environments](#LaTeX_Environments)
9. [Node Properties](#Node_Properties)
10. [Paragraphs](#Paragraphs)
11. [Table Rows](#Table_Rows)
5. [Objects](#Objects)
1. [Entities and LaTeX Fragments](#Entities_and_LaTeX_Fragments)
2. [Export Snippets](#Export_Snippets)
3. [Footnote References](#Footnote_References)
2020-05-16 12:01:33 +01:00
4. [Inline Babel Calls and Source
Blocks](#Inline_Babel_Calls_and_Source_Blocks)
2020-05-16 11:35:27 +01:00
5. [Line Breaks](#Line_Breaks)
6. [Links](#Links)
7. [Macros](#Macros)
8. [Targets and Radio Targets](#Targets_and_Radio_Targets)
9. [Statistics Cookies](#Statistics_Cookies)
10. [Subscript and Superscript](#Subscript_and_Superscript)
11. [Table Cells](#Table_Cells)
12. [Timestamps](#Timestamp)
13. [Text Markup](#Emphasis_Markers)
2020-05-16 12:01:33 +01:00
This document describes and comments Org syntax as it is currently read by its
parser (Org Elements) and, therefore, by the export framework. It also includes
a few comments on that syntax.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
A core concept in this syntax is that only headlines, sections, planning lines
and property drawers are context-free<sup><a id="fnr.1" class="footref"
href="#fn.1">1</a></sup><sup>, </sup><sup><a id="fnr.2" class="footref"
href="#fn.2">2</a></sup>. Every other syntactical part only exists within
specific environments.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
Three categories are used to classify these environments: **Greater elements**,
**elements**, and **objects**, from the broadest scope to the narrowest. The
word **element** is used for both Greater and non-Greater elements, the context
should make that clear.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
The paragraph is the unit of measurement. An element defines syntactical parts
that are at the same level as a paragraph, i.e. which cannot contain or be
included in a paragraph. An object is a part that could be included in an
element. Greater elements are all parts that can contain an element.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
Empty lines belong to the largest element ending before them. For example, in a
list, empty lines between items belong are part of the item before them, but
empty lines at the end of a list belong to the plain list element.
2020-05-16 11:35:27 +01:00
Unless specified otherwise, case is not significant.
<a id="Headlines_and_Sections"></a>
# Headlines and Sections
A headline is defined as:
STARS KEYWORD PRIORITY TITLE TAGS
2020-05-16 12:01:33 +01:00
STARS is a string starting at column 0, containing at least one asterisk (and up
to `org-inlinetask-min-level` if `org-inlinetask` library is loaded) and ended
by a space character. The number of asterisks is used to define the level of the
headline. It's the sole compulsory part of a headline.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
KEYWORD is a TODO keyword, which has to belong to the list defined in
`org-todo-keywords-1`. Case is significant.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
PRIORITY is a priority cookie, i.e. a single letter preceded by a hash sign #
and enclosed within square brackets.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
TITLE can be made of any character but a new line. Though, it will match after
every other part have been matched.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
TAGS is made of words containing any alpha-numeric character, underscore, at
sign, hash sign or percent sign, and separated with colons.
2020-05-16 11:35:27 +01:00
Examples of valid headlines include:
*
** DONE
*** Some e-mail
**** TODO [#A] COMMENT Title :tag:a2%:
2020-05-16 12:01:33 +01:00
If the first word appearing in the title is `COMMENT`, the headline will be
considered as **commented**. Case is significant.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
If its title is `org-footnote-section`, it will be considered as a **footnote
section**. Case is significant.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
If `ARCHIVE` is one of its tags, it will be considered as **archived**. Case is
significant.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
A headline contains directly one section (optionally), followed by any number of
deeper level headlines.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
A section contains directly any greater element or element. Only a headline can
contain a section. As an exception, text before the first headline in the
document also belongs to a section.
2020-05-16 11:35:27 +01:00
As an example, consider the following document:
An introduction.
* A Headline
Some text.
** Sub-Topic 1
** Sub-Topic 2
*** Additional entry
Its internal structure could be summarized as:
(document
(section)
(headline
(section)
(headline)
(headline
(headline))))
<a id="Affiliated_keywords"></a>
# Affiliated Keywords
2020-05-16 12:01:33 +01:00
With the exception of [inlinetasks](#Inlinetasks),
[items](#Plain_Lists_and_Items), [planning](#Clock,_Diary_Sexp_and_Planning),
[clocks](#Clock,_Diary_Sexp_and_Planning), [node properties](#Node_Properties)
and [table rows](#Table_Rows), every other element type can be assigned
2020-05-16 11:35:27 +01:00
attributes.
2020-05-16 12:01:33 +01:00
This is done by adding specific keywords, named **affiliated keywords**, just
above the element considered, no blank line allowed.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
Affiliated keywords are built upon one of the following patterns: `#+KEY: VALUE`,
`#+KEY[OPTIONAL]: VALUE` or `#+ATTR_BACKEND: VALUE`.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
KEY is either `CAPTION`, `HEADER`, `NAME`, `PLOT` or `RESULTS` string.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
BACKEND is a string constituted of alpha-numeric characters, hyphens or
underscores.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
OPTIONAL and VALUE can contain any character but a new line. Only `CAPTION` and
`RESULTS` keywords can have an optional value.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
An affiliated keyword can appear more than once if KEY is either `CAPTION` or
`HEADER` or if its pattern is `#+ATTR_BACKEND: VALUE`.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
`CAPTION`, `AUTHOR`, `DATE` and `TITLE` keywords can contain objects in their
value and their optional value, if applicable.
2020-05-16 11:35:27 +01:00
<a id="Greater_Elements"></a>
# Greater Elements
2020-05-16 12:01:33 +01:00
Unless specified otherwise, greater elements can contain directly any other
element or greater element excepted:
2020-05-16 11:35:27 +01:00
- elements of their own type,
2020-05-16 12:01:33 +01:00
- [node properties](#Node_Properties), which can only be found in [property
drawers](#Property_Drawers),
- [items](#Plain_Lists_and_Items), which can only be found in [plain
lists](#Plain_Lists_and_Items).
2020-05-16 11:35:27 +01:00
<a id="Greater_Blocks"></a>
## Greater Blocks
Greater blocks consist in the following pattern:
#+BEGIN_NAME PARAMETERS
CONTENTS
#+END_NAME
NAME can contain any non-whitespace character.
2020-05-16 12:01:33 +01:00
PARAMETERS can contain any character other than new line, and can be omitted.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
If NAME is `CENTER`, it will be a **center block**. If it is `QUOTE`, it will be
a **quote block**.
2020-05-16 11:35:27 +01:00
If the block is neither a center block, a quote block or a [block
2020-05-16 12:01:33 +01:00
element](#Blocks), it will be a **special block**.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
CONTENTS can contain any element, except : a line `#+END_NAME` on its own. Also
lines beginning with STARS must be quoted by a comma.
2020-05-16 11:35:27 +01:00
<a id="Drawers"></a>
## Drawers and Property Drawers
Pattern for drawers is:
:NAME:
CONTENTS
:END:
2020-05-16 12:01:33 +01:00
NAME can contain word-constituent characters, hyphens and underscores.
2020-05-16 11:35:27 +01:00
CONTENTS can contain any element but another drawer.
<a id="Dynamic_Blocks"></a>
## Dynamic Blocks
Pattern for dynamic blocks is:
#+BEGIN: NAME PARAMETERS
CONTENTS
#+END:
NAME cannot contain any whitespace character.
PARAMETERS can contain any character and can be omitted.
<a id="Footnote_Definitions"></a>
## Footnote Definitions
Pattern for footnote definitions is:
[fn:LABEL] CONTENTS
It must start at column 0.
2020-05-16 12:01:33 +01:00
LABEL is either a number or follows the pattern `fn:WORD`, where word can
contain any word-constituent character, hyphens and underscore characters.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
CONTENTS can contain any element excepted another footnote definition. It ends
at the next footnote definition, the next headline, two consecutive empty lines
or the end of buffer.
2020-05-16 11:35:27 +01:00
<a id="Inlinetasks"></a>
## Inlinetasks
2020-05-16 12:01:33 +01:00
Inlinetasks are defined by `org-inlinetask-min-level` contiguous asterisk
characters starting at column 0, followed by a whitespace character.
2020-05-16 11:35:27 +01:00
Optionally, inlinetasks can be ended with a string constituted of
2020-05-16 12:01:33 +01:00
`org-inlinetask-min-level` contiguous asterisk characters starting at column 0,
followed by a space and the `END` string.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
Inlinetasks are recognized only after `org-inlinetask` library is loaded.
2020-05-16 11:35:27 +01:00
<a id="Plain_Lists_and_Items"></a>
## Plain Lists and Items
Items are defined by a line starting with the following pattern:
2020-05-16 12:01:33 +01:00
`BULLET COUNTER-SET CHECK-BOX TAG`, in which only BULLET is mandatory.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
BULLET is either an asterisk, a hyphen, a plus sign character or follows either
the pattern `COUNTER.` or `COUNTER)`. In any case, BULLET is follwed by a
whitespace character or line ending.
2020-05-16 11:35:27 +01:00
COUNTER can be a number or a single letter.
COUNTER-SET follows the pattern [@COUNTER].
2020-05-16 12:01:33 +01:00
CHECK-BOX is either a single whitespace character, a `X` character or a hyphen,
enclosed within square brackets.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
TAG follows `TAG-TEXT ::` pattern, where TAG-TEXT can contain any character but
a new line.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
An item ends before the next item, the first line less or equally indented than
its starting line, or two consecutive empty lines. Indentation of lines within
other greater elements do not count, neither do inlinetasks boundaries.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
A plain list is a set of consecutive items of the same indentation. It can only
directly contain items.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
If first item in a plain list has a counter in its bullet, the plain list will
be an **ordered plain-list**. If it contains a tag, it will be a **descriptive
list**. Otherwise, it will be an **unordered list**. List types are mutually
exclusive.
2020-05-16 11:35:27 +01:00
For example, consider the following excerpt of an Org document:
1. item 1
2. [X] item 2
- some tag :: item 2.1
Its internal structure is as follows:
(ordered-plain-list
(item)
(item
(descriptive-plain-list
(item))))
<a id="Property_Drawers"></a>
## Property Drawers
2020-05-16 12:01:33 +01:00
Property drawers are a special type of drawer containing properties attached to
a headline. They are located right after a [headline](#Headlines_and_Sections)
2020-05-16 11:35:27 +01:00
and its [planning](#Clock,_Diary_Sexp_and_Planning) information.
HEADLINE
PROPERTYDRAWER
HEADLINE
PLANNING
PROPERTYDRAWER
PROPERTYDRAWER follows the pattern
:PROPERTIES:
CONTENTS
:END:
where CONTENTS consists of zero or more [node properties](#Node_Properties).
<a id="Tables"></a>
## Tables
2020-05-16 12:01:33 +01:00
Tables start at lines beginning with either a vertical bar or the `+-` string
followed by plus or minus signs only, assuming they are not preceded with lines
of the same type. These lines can be indented.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
A table starting with a vertical bar has `org` type. Otherwise it has `table.el`
type.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
Org tables end at the first line not starting with a vertical bar. Table.el
tables end at the first line not starting with either a vertical line or a plus
sign. Such lines can be indented.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
An org table can only contain table rows. A table.el table does not contain
anything.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
One or more `#+TBLFM: FORMULAS` lines, where `FORMULAS` can contain any
character, can follow an org table.
2020-05-16 11:35:27 +01:00
<a id="Elements"></a>
# Elements
Elements cannot contain any other element.
Only [keywords](#Keywords) whose name belongs to
2020-05-16 12:01:33 +01:00
`org-element-document-properties`, [verse blocks](#Blocks) ,
[paragraphs](#Paragraphs) and [table rows](#Table_Rows) can contain objects.
2020-05-16 11:35:27 +01:00
<a id="Babel_Call"></a>
## Babel Call
Pattern for babel calls is:
#+CALL: VALUE
VALUE is optional. It can contain any character but a new line.
<a id="Blocks"></a>
## Blocks
Like [greater blocks](#Greater_Blocks), pattern for blocks is:
#+BEGIN_NAME DATA
CONTENTS
#+END_NAME
NAME cannot contain any whitespace character.
2020-05-16 12:01:33 +01:00
1. If NAME is `COMMENT`, it will be a **comment block**.
2. If it is `EXAMPLE`, it will be an **example block**.
3. If it is `EXPORT`, it will be an **export block**.
4. If it is `SRC`, it will be a **source block**.
5. If it is `VERSE`, it will be a **verse block**.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
DATA can contain any character but a new line. It can be ommitted, unless the
block is either a **source block** or an **export block**.
2020-05-16 11:35:27 +01:00
In the latter case, it should be constituted of a single word.
2020-05-16 12:01:33 +01:00
In the former case, it must follow the pattern `LANGUAGE SWITCHES ARGUMENTS`,
where SWITCHES and ARGUMENTS are optional.
2020-05-16 11:35:27 +01:00
LANGUAGE cannot contain any whitespace character.
2020-05-16 12:01:33 +01:00
SWITCHES is made of any number of `SWITCH` patterns, separated by blank lines.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
A SWITCH pattern is either `-l FORMAT`, where FORMAT can contain any character
but a double quote and a new line, `-S` or `+S`, where S stands for a single
letter.
2020-05-16 11:35:27 +01:00
ARGUMENTS can contain any character but a new line.
2020-05-16 12:01:33 +01:00
CONTENTS can contain any character, including new lines. Though it will only
contain Org objects if the block is a verse block. Otherwise, CONTENTS will not
be parsed.
2020-05-16 11:35:27 +01:00
<a id="Clock,_Diary_Sexp_and_Planning"></a>
## Clock, Diary Sexp and Planning
A clock follows either of the patterns below:
CLOCK: INACTIVE-TIMESTAMP
CLOCK: INACTIVE-TIMESTAMP-RANGE DURATION
2020-05-16 12:01:33 +01:00
INACTIVE-TIMESTAMP, resp. INACTIVE-TIMESTAMP-RANGE, is an inactive, resp.
inactive range, [timestamp](#Timestamp) object.
2020-05-16 11:35:27 +01:00
DURATION follows the pattern:
=> HH:MM
2020-05-16 12:01:33 +01:00
HH is a number containing any number of digits. MM is a two digit numbers.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
A diary sexp is a line starting at column 0 with `%%(` string. It can then
contain any character besides a new line.
2020-05-16 11:35:27 +01:00
A planning is an element with the following pattern:
HEADLINE
PLANNING
2020-05-16 12:01:33 +01:00
where HEADLINE is a [headline](#Headlines_and_Sections) element and PLANNING is
a line filled with INFO parts, where each of them follows the pattern:
2020-05-16 11:35:27 +01:00
KEYWORD: TIMESTAMP
2020-05-16 12:01:33 +01:00
KEYWORD is either `DEADLINE`, `SCHEDULED` or `CLOSED`. TIMESTAMP is a
[timestamp](#Timestamp) object.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
In particular, no blank line is allowed between PLANNING and HEADLINE.
2020-05-16 11:35:27 +01:00
<a id="Comments"></a>
## Comments
2020-05-16 12:01:33 +01:00
A **comment line** starts with a hash signe and a whitespace character or an end
of line.
2020-05-16 11:35:27 +01:00
Comments can contain any number of consecutive comment lines.
<a id="Fixed_Width_Areas"></a>
## Fixed Width Areas
2020-05-16 12:01:33 +01:00
A **fixed-width line** start with a colon character and a whitespace or an end
of line.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
Fixed width areas can contain any number of consecutive fixed-width lines.
2020-05-16 11:35:27 +01:00
<a id="Horizontal_Rules"></a>
## Horizontal Rules
2020-05-16 12:01:33 +01:00
A horizontal rule is a line made of at least 5 consecutive hyphens. It can be
indented.
2020-05-16 11:35:27 +01:00
<a id="Keywords"></a>
## Keywords
Keywords follow the syntax:
#+KEY: VALUE
2020-05-16 12:01:33 +01:00
KEY can contain any non-whitespace character, but it cannot be equal to `CALL`
or any affiliated keyword.
2020-05-16 11:35:27 +01:00
VALUE can contain any character excepted a new line.
2020-05-16 12:01:33 +01:00
If KEY belongs to `org-element-document-properties`, VALUE can contain objects.
2020-05-16 11:35:27 +01:00
<a id="LaTeX_Environments"></a>
## LaTeX Environments
Pattern for LaTeX environments is:
\begin{NAME} CONTENTS \end{NAME}
NAME is constituted of alpha-numeric or asterisk characters.
2020-05-16 12:01:33 +01:00
CONTENTS can contain anything but the `\end{NAME}` string.
2020-05-16 11:35:27 +01:00
<a id="Node_Properties"></a>
## Node Properties
2020-05-16 12:01:33 +01:00
Node properties can only exist in [property drawers](#Property_Drawers). Their
pattern is any of the following
2020-05-16 11:35:27 +01:00
:NAME: VALUE
:NAME+: VALUE
:NAME:
:NAME+:
2020-05-16 12:01:33 +01:00
NAME can contain any non-whitespace character but cannot end with a plus sign.
It cannot be the empty string.
2020-05-16 11:35:27 +01:00
VALUE can contain anything but a newline character.
<a id="Paragraphs"></a>
## Paragraphs
2020-05-16 12:01:33 +01:00
Paragraphs are the default element, which means that any unrecognized context is
a paragraph.
2020-05-16 11:35:27 +01:00
Empty lines and other elements end paragraphs.
Paragraphs can contain every type of object.
<a id="Table_Rows"></a>
## Table Rows
2020-05-16 12:01:33 +01:00
A table rows is either constituted of a vertical bar and any number of [table
cells](#Table_Cells) or a vertical bar followed by a hyphen.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
In the first case the table row has the **standard** type. In the second case,
it has the **rule** type.
2020-05-16 11:35:27 +01:00
Table rows can only exist in [tables](#Tables).
<a id="Objects"></a>
# Objects
Objects can only be found in the following locations:
2020-05-16 12:01:33 +01:00
- [affiliated keywords](#Affiliated_keywords) defined in
`org-element-parsed-keywords`,
2020-05-16 11:35:27 +01:00
- [document properties](#Keywords),
- [headline](#Headlines_and_Sections) titles,
- [inlinetask](#Inlinetasks) titles,
- [item](#Plain_Lists_and_Items) tags,
- [paragraphs](#Paragraphs),
- [table cells](#Table_Cells),
2020-05-16 12:01:33 +01:00
- [table rows](#Table_Rows), which can only contain table cell objects,
2020-05-16 11:35:27 +01:00
- [verse blocks](#Blocks).
2020-05-16 12:01:33 +01:00
Most objects cannot contain objects. Those which can will be specified.
2020-05-16 11:35:27 +01:00
<a id="Entities_and_LaTeX_Fragments"></a>
## Entities and LaTeX Fragments
An entity follows the pattern:
\NAME POST
where NAME has a valid association in either `org-entities` or
`org-entities-user`.
2020-05-16 12:01:33 +01:00
POST is the end of line, `{}` string, or a non-alphabetical character. It isn't
separated from NAME by a whitespace character.
2020-05-16 11:35:27 +01:00
A LaTeX fragment can follow multiple patterns:
\NAME BRACKETS
\(CONTENTS\)
\[CONTENTS\]
$$CONTENTS$$
PRE$CHAR$POST
PRE$BORDER1 BODY BORDER2$POST
2020-05-16 12:01:33 +01:00
NAME contains alphabetical characters only and must not have an association in
either **org-entities** or **org-entities-user**.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
BRACKETS is optional, and is not separated from NAME with white spaces. It may
contain any number of the following patterns:
2020-05-16 11:35:27 +01:00
[CONTENTS1]
{CONTENTS2}
2020-05-16 12:01:33 +01:00
where CONTENTS1 can contain any characters excepted `{` `}`, `[` `]` and newline
and CONTENTS2 can contain any character excepted `{`, `}` and newline.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
CONTENTS can contain any character but cannot contain `\\)` in the second
template or `\\]` in the third one.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
PRE is either the beginning of line or a character different from `$`.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
CHAR is a non-whitespace character different from `.`, `,`, `?`, `;`, `'` or a
double quote.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
POST is any punctuation (including parentheses and quotes) or space character,
or the end of line.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
BORDER1 is a non-whitespace character different from `.`, `,`, `;` and `$`.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
BODY can contain any character excepted `$`, and may not span over more than 3
lines.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
BORDER2 is any non-whitespace character different from `,`, `.` and `$`.
2020-05-16 11:35:27 +01:00
---
2020-05-16 12:01:33 +01:00
> It would introduce incompatibilities with previous Org versions, but support
> for `$...$` (and for symmetry, `$$...$$`) constructs ought to be removed.
2020-05-16 11:35:27 +01:00
>
2020-05-16 12:01:33 +01:00
> They are slow to parse, fragile, redundant and imply false positives. &#x2014;
> ngz
2020-05-16 11:35:27 +01:00
<a id="Export_Snippets"></a>
## Export Snippets
Patter for export snippets is:
@@NAME:VALUE@@
NAME can contain any alpha-numeric character and hyphens.
2020-05-16 12:01:33 +01:00
VALUE can contain anything but `@@` string.
2020-05-16 11:35:27 +01:00
<a id="Footnote_References"></a>
## Footnote References
There are four patterns for footnote references:
[fn:LABEL]
[fn:LABEL:DEFINITION]
[fn::DEFINITION]
2020-05-16 12:01:33 +01:00
LABEL can contain any word constituent character, hyphens and underscores.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
DEFINITION can contain any character. Though opening and closing square brackets
must be balanced in it. It can contain any object encountered in a paragraph,
even other footnote references.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
If the reference follows the second pattern, it is called an **inline
footnote**. If it follows the third one, i.e. if LABEL is omitted, it is an
**anonymous footnote**.
2020-05-16 11:35:27 +01:00
<a id="Inline_Babel_Calls_and_Source_Blocks"></a>
## Inline Babel Calls and Source Blocks
Inline Babel calls follow any of the following patterns:
call_NAME(ARGUMENTS)
call_NAME[HEADER](ARGUMENTS)[HEADER]
2020-05-16 12:01:33 +01:00
NAME can contain any character besides `(`, `)` and `\n`.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
HEADER can contain any character besides `]` and `\n`.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
ARGUMENTS can contain any character besides `)` and `\n`.
2020-05-16 11:35:27 +01:00
Inline source blocks follow any of the following patterns:
src_LANG{BODY}
src_LANG[OPTIONS]{BODY}
LANG can contain any non-whitespace character.
2020-05-16 12:01:33 +01:00
OPTIONS and BODY can contain any character but `\n`.
2020-05-16 11:35:27 +01:00
<a id="Line_Breaks"></a>
## Line Breaks
2020-05-16 12:01:33 +01:00
A line break consists in `\\\SPACE` pattern at the end of an otherwise non-empty
line.
2020-05-16 11:35:27 +01:00
SPACE can contain any number of tabs and spaces, including 0.
<a id="Links"></a>
## Links
There are 4 major types of links:
PRE1 RADIO POST1 ("radio" link)
<PROTOCOL:PATH> ("angle" link)
PRE2 PROTOCOL:PATH2 POST2 ("plain" link)
[[PATH3]DESCRIPTION] ("regular" link)
PRE1 and POST1, when they exist, are non alphanumeric characters.
2020-05-16 12:01:33 +01:00
RADIO is a string matched by some [radio target](#Targets_and_Radio_Targets). It
may contain [entities](#Entities_and_LaTeX_Fragments), [latex
fragments](#Entities_and_LaTeX_Fragments),
[subscript](#Subscript_and_Superscript) and
[superscript](#Subscript_and_Superscript).
2020-05-16 11:35:27 +01:00
PROTOCOL is a string among `org-link-types`.
PATH can contain any character but `]`, `<`, `>` and `\n`.
2020-05-16 12:01:33 +01:00
PRE2 and POST2, when they exist, are non word constituent characters.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
PATH2 can contain any non-whitespace character excepted `(`, `)`, `<` and `>`.
It must end with a word-constituent character, or any non-whitespace
non-punctuation character followed by `/`.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
DESCRIPTION must be enclosed within square brackets. It can contain any
character but square brackets. It can contain any object found in a paragraph
excepted a [footnote reference](#Footnote_References), a [radio
target](#Targets_and_Radio_Targets) and a [line break](#Line_Breaks). It cannot
contain another link either, unless it is a plain or angular link.
2020-05-16 11:35:27 +01:00
DESCRIPTION is optional.
PATH3 is built according to the following patterns:
FILENAME ("file" type)
PROTOCOL:PATH4 ("PROTOCOL" type)
PROTOCOL://PATH4 ("PROTOCOL" type)
id:ID ("id" type)
#CUSTOM-ID ("custom-id" type)
(CODEREF) ("coderef" type)
FUZZY ("fuzzy" type)
FILENAME is a file name, either absolute or relative.
PATH4 can contain any character besides square brackets.
ID is constituted of hexadecimal numbers separated with hyphens.
2020-05-16 12:01:33 +01:00
PATH4, CUSTOM-ID, CODEREF and FUZZY can contain any character besides square
brackets.
2020-05-16 11:35:27 +01:00
<a id="Macros"></a>
## Macros
Macros follow the pattern:
{{{NAME(ARGUMENTS)}}}
2020-05-16 12:01:33 +01:00
NAME must start with a letter and can be followed by any number of alpha-numeric
characters, hyphens and underscores.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
ARGUMENTS can contain anything but `}}}` string. Values within ARGUMENTS are
separated by commas. Non-separating commas have to be escaped with a backslash
character.
2020-05-16 11:35:27 +01:00
<a id="Targets_and_Radio_Targets"></a>
## Targets and Radio Targets
Radio targets follow the pattern:
<<<CONTENTS>>>
2020-05-16 12:01:33 +01:00
CONTENTS can be any character besides `<`, `>` and `\n`. It cannot start or end
with a whitespace character. As far as objects go, it can contain [text
markup](#Emphasis_Markers), [entities](#Entities_and_LaTeX_Fragments), [latex
fragments](#Entities_and_LaTeX_Fragments),
[subscript](#Subscript_and_Superscript) and
2020-05-16 11:35:27 +01:00
[superscript](#Subscript_and_Superscript) only.
Targets follow the pattern:
<<TARGET>>
2020-05-16 12:01:33 +01:00
TARGET can contain any character besides `<`, `>` and `\n`. It cannot start or
end with a whitespace character. It cannot contain any object.
2020-05-16 11:35:27 +01:00
<a id="Statistics_Cookies"></a>
## Statistics Cookies
Statistics cookies follow either pattern:
[PERCENT%]
[NUM1/NUM2]
PERCENT, NUM1 and NUM2 are numbers or the empty string.
<a id="Subscript_and_Superscript"></a>
## Subscript and Superscript
Pattern for subscript is:
CHAR_SCRIPT
Pattern for superscript is:
CHAR^SCRIPT
CHAR is any non-whitespace character.
2020-05-16 12:01:33 +01:00
SCRIPT can be `*` or an expression enclosed in parenthesis (respectively curly
brackets), possibly containing balanced parenthesis (respectively curly
brackets).
2020-05-16 11:35:27 +01:00
SCRIPT can also follow the pattern:
SIGN CHARS FINAL
SIGN is either a plus sign, a minus sign, or an empty string.
2020-05-16 12:01:33 +01:00
CHARS is any number of alpha-numeric characters, commas, backslashes and dots,
or an empty string.
2020-05-16 11:35:27 +01:00
FINAL is an alpha-numeric character.
There is no white space between SIGN, CHARS and FINAL.
<a id="Table_Cells"></a>
## Table Cells
Table cells follow the pattern:
CONTENTS SPACES|
CONTENTS can contain any character excepted a vertical bar.
2020-05-16 12:01:33 +01:00
SPACES contains any number of space characters, including zero. It can be used
to align properly the table.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
The final bar may be replaced with a newline character for the last cell in row.
2020-05-16 11:35:27 +01:00
<a id="Timestamp"></a>
## Timestamps
There are seven possible patterns for timestamps:
<%%(SEXP)> (diary)
<DATE TIME REPEATER-OR-DELAY> (active)
[DATE TIME REPEATER-OR-DELAY] (inactive)
<DATE TIME REPEATER-OR-DELAY>--<DATE TIME REPEATER-OR-DELAY> (active range)
<DATE TIME-TIME REPEATER-OR-DELAY> (active range)
[DATE TIME REPEATER-OR-DELAY]--[DATE TIME REPEATER-OR-DELAY] (inactive range)
[DATE TIME-TIME REPEATER-OR-DELAY] (inactive range)
SEXP can contain any character excepted `>` and `\n`.
DATE follows the pattern:
YYYY-MM-DD DAYNAME
2020-05-16 12:01:33 +01:00
`Y`, `M` and `D` are digits. DAYNAME can contain any non whitespace-character
besides `+`, `-`, `]`, `>`, a digit or `\n`.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
TIME follows the pattern `H:MM`. `H` can be one or two digit long and can start
with 0.
2020-05-16 11:35:27 +01:00
REPEATER-OR-DELAY follows the pattern:
MARK VALUE UNIT
2020-05-16 12:01:33 +01:00
MARK is `+` (cumulate type), `++` (catch-up type) or `.+` (restart type) for a
repeater, and `-` (all type) or `--` (first type) for warning delays.
2020-05-16 11:35:27 +01:00
VALUE is a number.
2020-05-16 12:01:33 +01:00
UNIT is a character among `h` (hour), `d` (day), `w` (week), `m` (month), `y`
(year).
2020-05-16 11:35:27 +01:00
MARK, VALUE and UNIT are not separated by whitespace characters.
2020-05-16 12:01:33 +01:00
There can be two REPEATER-OR-DELAY in the timestamp: one as a repeater and one
as a warning delay.
2020-05-16 11:35:27 +01:00
<a id="Emphasis_Markers"></a>
## Text Markup
Text markup follows the pattern:
PRE MARKER CONTENTS MARKER POST
2020-05-16 12:01:33 +01:00
PRE is a whitespace character, `(`, `{` `'` or a double quote. It can also be a
beginning of line.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
MARKER is a character among `*` (bold), `=` (verbatim), `/` (italic), `+`
(strike-through), `_` (underline), `~` (code).
2020-05-16 11:35:27 +01:00
CONTENTS is a string following the pattern:
BORDER BODY BORDER
2020-05-16 12:01:33 +01:00
BORDER can be any non-whitespace character excepted `,`, `'` or a double quote.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
BODY can contain contain any character but may not span over more than 3 lines.
2020-05-16 11:35:27 +01:00
BORDER and BODY are not separated by whitespaces.
2020-05-16 12:01:33 +01:00
CONTENTS can contain any object encountered in a paragraph when markup is
**bold**, **italic**, **strike-through** or **underline**.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
POST is a whitespace character, `-`, `.`, `,`, `:`, `!`, `?`, `'`, `)`, `}` or a
double quote. It can also be an end of line.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
PRE, MARKER, CONTENTS, MARKER and POST are not separated by whitespace
characters.
2020-05-16 11:35:27 +01:00
---
> All of this is wrong if `org-emphasis-regexp-components` or
> `org-emphasis-alist` are modified.
>
> This should really be simplified.
>
2020-05-16 12:01:33 +01:00
> Also, CONTENTS should be anything within code and verbatim emphasis, by
> definition. &#x2014; ngz
2020-05-16 11:35:27 +01:00
# Footnotes
2020-05-16 12:01:33 +01:00
<sup><a id="fn.1" href="#fnr.1">1</a></sup> In particular, the parser requires
stars at column 0 to be quoted by a comma when they do not define a headline.
2020-05-16 11:35:27 +01:00
2020-05-16 12:01:33 +01:00
<sup><a id="fn.2" href="#fnr.2">2</a></sup> It also means that only headlines
and sections can be recognized just by looking at the beginning of the line.
Planning lines and property drawers can be recognized by looking at one or two
2020-05-16 11:35:27 +01:00
lines above.
2020-05-16 12:01:33 +01:00
As a consequence, using `org-element-at-point` or `org-element-context` will
move up to the parent headline, and parse top-down from there until context
around original location is found.