Input and compilation/Other markup languages sources

From Wiki
Jump to navigation Jump to search

Pandoc

Pandoc can convert many markup languages to ConTeXt

Converting to ConTeXt

Use the following options

  • -t context+ntb for natural table format or -t context (extreme table format is default)
  • -s for a standalone file (setup are added in the setup area). Without the output will miss some setups to be ready for ConTeXt compilation.

pandoc -s -t context+ntb input.md -o input.tex

pandoc --standalone --to=context+ntb input.md --output input.tex

Creating a PDF

By default, pandoc will use LaTeX to create the PDF, which requires that a LaTeX engine be installed (see --pdf-engine below). Alternatively, pandoc can use ConTeXt, roff ms, or HTML as an intermediate format. To do this, specify an output file with a .pdf extension, as before, but -t context to the command line (the tool used to generate the PDF from the intermediate format may be specified using --pdf-engine).

pandoc -t context+ntb input.org -o input.pdf

ConTeXt always produces tagged PDFs, but the quality depends on the input. The default ConTeXt markup generated by pandoc is optimized for readability and reuse, not tagging. Enable the tagging format extension to force markup that is optimized for tagging. This can be combined with the pdfa variable to generate standard-compliant PDFs. E.g.:

pandoc -s -t context+ntb+tagging -V pdfa=3a input.org --output input.pdf

Customizing


TODO: demo how to use your own environment files, and to use the pandoc variables (See: To-Do List)


Org Mode and ox-context

Use of pandoc via the filter module

This demo, with Markdown Org Mode and reStructuredText, can not be rendered on this wiki nor on context-on-web.eu server because pandoc is required.

But try on your computer:

\usemodule[filter]

\defineexternalfilter
  [markdown]
  [filtercommand={pandoc -t context -f markdown -o \externalfilteroutputfile\space \externalfilterinputfile}]

\defineexternalfilter
  [orgmode]
  [filtercommand={pandoc -t context -f org -o \externalfilteroutputfile\space \externalfilterinputfile}]

\defineexternalfilter
  [rst]
  [filtercommand={pandoc -t context -f rst -o \externalfilteroutputfile\space \externalfilterinputfile}]

\starttext

%==============================================================================
\startmarkdown
# Heading level 1 with Markdown

Text with **bold text**.

## Heading level 2.1

* item 1
* item 2

![the GNU mascot](https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/Official_gnu.svg/768px-Official_gnu.svg.png)
\stopmarkdown

\page

%==============================================================================
\startorgmode
* Heading level 1 with Org-mode

Text with *bold text*.

** Heading level 2.1

- item 1
- item 2

#+CAPTION: the GNU mascot
[[https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/Official_gnu.svg/768px-Official_gnu.svg.png]]
\stoporgmode

\page

%==============================================================================
\startrst
Heading level 1 with reStructuredText
=====================================

Text with **bold text**.

Heading level 2.1
-----------------

-  item 1
-  item 2

.. figure::
   https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/Official_gnu.svg/768px-Official_gnu.svg.png

   the GNU mascot
\stoprst

\stoptext