This is a [[https://wiki.contextgarden.net][ConTeXt]] [[https://orgmode.org/manual/Exporting.html][exporter]] for [[https://orgmode.org/][Org Mode]].
git clone https://github.com/Jason-S-Ross/ox-context
Then, in your customization file, add
(add-to-list 'load-path "~/path-to-repo/ox-context/")
Examples See [[https://github.com/Jason-S-Ross/ox-context-examples][the example repo]] for examples.
Document Customization
Each element type in the Org document is associated with a custom ConTeXt command whose name and definition is set by a customization variable. When you export a document, the command definition associated with each type of org element is exported into the ConTeXt document preamble. The element itself is formatted by the associated command. This allows documents to be customized by either changing the customization variable associated with each element type, or by inserting new command definitions into the document preamble after the original definitions in order to override them. There are several ways to insert command definitions into the preamble:
~#+context_header~ :: This keyword adds literal ConTeXt code at the beginning of the document preamble.
Note that these entries will be overriden by presets and other default definitions, so usually you want to use the ~_extra~ variant (unlike in ~ox-latex~).
~#+context_header_extra~ :: This keyword inserts literal ConTeXt code directly into the document preamble after the default command definitions.
Here's how to use it to set the paper size:
Here's the procedure to change description items:
This could also be used to insert an environment file to customize multiple commands:
~#+context_snippet~ :: This keyword allows a named "snippet" to be inserted into the document preamble after the default command definitions. Snippets are stored in the ~org-context-snippets-alist~ customization variable. A new snippet can be added to this list like this:
(add-to-list 'org-context-snippets-alist '("paper-a4" . "\setuppapersize[A4]") t)
Then the snippet can be used in the document as follows:
As with ~#+context_header_extra~, snippets can override existing command definitions.
~#+context_preset~ :: This keyword selects the document /Preset/. A /Preset/ is a collection of ConTeXt instructions to insert into the preamble, a list of snippets, and an "inner template" that specifies overall document structure.
The following code adds the "paper-a4" snippet that we previously defined to the article template:
(let ((article-preset (cdr (assoc "article" org-context-presets-alist)))) (plist-put article-preset :snippets (cons "paper-a4" (plist-get article-preset :snippets))))
Alternatively, one could modify the literal code of the article template directly and skip declaring the snippet:
(let ((article-preset (cdr (assoc "article" org-context-presets-alist)))) (plist-put article-preset :literal (concat (plist-get article-preset :literal) "\n\setuppapersize[A4]")))
Features and Configuration
NOTE :: In this section, any customization variables are prefixed with ~org-context-~ if not stated otherwise.
NOTE :: Additional documentation on customization variables can be viewed with ~customize-group~.
** Tables
The entire table gets styled by whatever global ~xtable~ options are set in the document preamble by a command like ~\setupxtable[option=value]~. Additionally, each part of the table has associated named styles applied to it. The styles depend on the position of the part in the table structure. Styles are applied in a cascading manner, with table styles getting overridden by section styles, which are overridden by row styles, which are finally overridden by cell styles.
*** Table Section Element Styling
| Name | Elisp Customization Variable | Default ConTeXt name | Key | |--------+------------------------------+----------------------+------| | Header | ~header-style~ | ~OrgTableHeader~ | ~:h~ | | Body | ~body-style~ | ~OrgTableBody~ | ~:b~ | | Footer | ~footer-style~ | ~OrgTableFooter~ | ~:f~ |
Specific rows get named styles as well:
| Name | Elisp Customization Variable | Default ConTeXt Name | Key | |-------------------------+------------------------------+-------------------------+--------| | Top Row[fn:1] | ~toprow-style~ | ~OrgTableTopRow~ | ~:n~ | | Bottom Row[fn:2] | ~bottomrow-style~ | ~OrgTableBottomRow~ | ~:s~ | | Header Top Row[fn:3] | ~header-top-style~ | ~OrgTableHeaderTop~ | ~:ht~ | | Header Bottom Row[fn:3] | ~header-bottom-style~ | ~OrgTableHeaderBottom~ | ~:hb~ | | Header Mid Row[fn:3] | ~header-mid-style~ | ~OrgTableHeaderMid~ | ~:hm~ | | Footer Top Row[fn:4] | ~footer-top-style~ | ~OrgTableFooterTop~ | ~:ft~ | | Footer Bottom Row[fn:4] | ~footer-bottom-style~ | ~OrgTableFooterBottom~ | ~:fb~ | | Footer Mid Row[fn:4] | ~header-mid-style~ | ~OrgTableFooterMid~ | ~:fm~ | | Row Group Top Row | ~rowgroup-start-style~ | ~OrgTableRowGroupStart~ | ~:rgs~ | | Row Group Bottom Row | ~rowgroup-end-style~ | ~OrgTableRowGroupEnd~ | ~:rge~ |
Likewise, cells in special columns get a named style depending on their position. The following special columns are defined:
| Name | Elisp Customization Variable | Default ConTeXt Name | Key | |--------------------+------------------------------+-------------------------+--------| | Left Column | ~leftcol-style~ | ~OrgTableLeftCol~ | ~:w~ | | Right Column | ~rightcol-style~ | ~OrgTableRightCol~ | ~:e~ | | Column Group Right | ~colgroup-start-style~ | ~OrgTableColGroupStart~ | ~:cgs~ | | Column Group Left | ~colgroup-end-style~ | ~OrgTableColGroupEnd~ | ~:cge~ |
Finally, cells at special positions are defined:
| Name | Elisp Customization Variable | Default ConTeXt Name | Key | |--------------+------------------------------+---------------------------+-------| | Top Left | ~topleft-style~ | ~OrgTableTopLeftCell~ | ~:nw~ | | Top Right | ~topright-style~ | ~OrgTableTopRightCell~ | ~:ne~ | | Bottom Left | ~bottomleft-style~ | ~OrgTableBottomLeftCell~ | ~:sw~ | | Bottom Right | ~bottomright-style~ | ~OrgTableBottomRightCell~ | ~:se~ |
Each of these styles can be configured like any other command. Additionally, there is a key that can be passed to ~#+attr_context~ to customize the styling of each element defined above.
Here's an example table with the start of each row group set to have a blue background:
| H1 | H2 | H3 | |----+----+----| | 1 | 2 | 3 | | 4 | 5 | 6 | |----+----+----| | 7 | 8 | 9 | | 4 | 5 | 6 | |----+----+----| | 7 | 8 | 9 | | 4 | 5 | 6 | |----+----+----| | 7 | 8 | 9 |
| H1 | H2 | H3 | |----+----+----| | 1 | 2 | 3 | | 4 | 5 | 6 | |----+----+----| | 7 | 8 | 9 | | 4 | 5 | 6 | |----+----+----| | 7 | 8 | 9 | | 4 | 5 | 6 | |----+----+----| | 7 | 8 | 9 |
*** Additional configuration for tables
The following additional configuration options are available for tables.
| Name | Elisp Customization Variable | Document-level Keyword | Table-level Keyword | |-------------+------------------------------+------------------------+---------------------| | Location | ~table-location~ | ~#+table_location~ | ~:location~ | | Header | ~table-header~ | ~#+table_head~ | ~:header~ | | Footer | ~table-footer~ | ~#+table_foot~ | ~:footer~ | | Option | ~table-option~ | ~#+table_option~ | ~:option~ | | Table Style | ~table-style~ | ~#+table_style~ | ~:table-style~ | | Float Style | ~table-float-style~ | ~#+table_float~ | ~:float-style~ | | Split | ~table-split~ | ~#+table_split~ | ~:split~ |
| Name | Elisp Customization Variable | Image-level Keyword | |-----------+------------------------------+---------------------| | Float | | ~:float~ | | Scale | ~image-default-scale~ | ~:scale~ | | Width | ~image-default-width~ | ~:width~ | | Height | ~image-default-height~ | ~:height~ | | Placement | ~image-default-placement~ | ~:placement~ | | Options | ~image-default-options~ | ~:options~ |
** Syntax Highlighting
*** Standard Syntax Highlighting (default)
ConTeXt does not support many languages by default. Vim syntax highlighting is recommended.
**** Configuration
Language aliases are defined in the ~highlighted-langs-alist~ customization variable. Language aliases are used in order to avoid invalid characters in the ConTeXt code and to alias from the Emacs language name to the ConTeXt name.
*** Vim Syntax Highlighting
The ConTeXt Vim highlighting module provides support for a large range of languages. Vim syntax highlighting is disabled by default. **** Configuration
Language aliases are defined in the ~vim-langs-alist~ customization variable. Language aliases are used to rename a language in order to avoid invalid characters in the ConTeXt code and to alias from the Emacs language name to the Vim name.
**** Enabling Vim Syntax Highlighting Vim syntax highlighting is enabled globally by setting ~syntax-engine~ customization variable to ~'vim~. Vim syntax highlighting can set on a per-document basis with ~#+options: syntax:vim~.
The snippet ~syntax-pigmints~ is provided to give syntax highlighting that may superficially resemble the default setting of a popular syntax highlighting package written in python... ** Custom Indices The customization variable ~texinfo-indices-alist~ allows custom index keywords to be used in documents. The motivating example for this is the ~texinfo~ exporter which supports ~#+CINDEX~, ~#+FINDEX~, ~#+KINDEX~, ~#+PINDEX~, ~#+TINDEX~, and ~#+VINDEX~ keywords for concepts, functions, keystrokes, programs, datatypes, and variables respectively.
An indexing keyword can be placed in the document to define where a term is used. The corresponding list of indices can be placed with the ~#+TOC:~ command.
Indexing is presented by example.
New indices may be defined as follows:
(add-to-list 'org-context-texinfo-indices-alist '("myindex" . (:keyword "MYINDEX" :command "MySpecialIndex")) t)
They can then be used throughout documents as follows:
Indexing is presented by example.
Additionally, indices defined this way can be used with headline properties just like with the texinfo exporter:
,* My Custom Index :PROPERTIES: :INDEX: myindex :END:
** Tables of Contents In addition to any custom indices, the ~#+TOC~ keyword can be used with the following values:
In-Text Keywords Document Structure and Section Placement The overall sectioning structure of the document is defined by the "inner template". This is a format spec string that locates each part of the document. Inner templates are listed in ~inner-templates-alist~.
Here's an example inner template:
\startfrontmatter \startOrgTitlePage \OrgMakeTitle %t \stopOrgTitlePage %f \stopfrontmatter
\startbodymatter %c \stopbodymatter
\startappendices %a %i \stopappendices
\startbackmatter %b %o \stopbackmatter
The format string keys are as follows:
The inner template exists primarily to allow separation to be inserted between different parts of a document, but it also allows the different parts to be reordered in the exported document if desired.