\enableregime[utf]
\usetypescript[modern][ec]
\setupbodyfont[10pt,rm]
\setupexternalfigures[location={local,global,default}]

% Load the Markdown module.
\usemodule[t][markdown]

% Set options of the Markdown module.
\setupmarkdown
  [
    contentBlocks = yes,
    debugExtensions = yes,
    definitionLists = yes,
    fancy_lists = yes,
    fencedCode = yes,
    hashEnumerators = yes,
    inlineNotes = yes,
    lineBlocks = yes,
    notes = yes,
    pipeTables = yes,
    rawAttribute = yes,
    smartEllipses = yes,
    strikethrough = yes,
    subscripts = yes,
    superscripts = yes,
    tableCaptions = yes,
    taskLists = yes,
  ]

% Set renderers of the Markdown module.
\definehighlight
  [markdownRendererEmphasis]
  [style=\em]

\definehighlight
  [markdownRendererStrongEmphasis]
  [style=bold]

\definehighlight
  [markdownRendererCodeSpan]
  [style=mono]

\definetyping
  [latex]

\setuptyping
  [latex]
  [option=TEX]

\starttext

% Typeset the document `example.md` by letting the Markdown package handle
% the conversion internally.
\inputmarkdown{./example.md}

% Typeset the document `example.tex` that we prepared separately using the
% Lua command-line interface and that contains a plain TeX representation
% of the document `example.md`.
\catcode`\%=12\relax
\catcode`\#=12\relax
\doiffileelse{./example.tex}{\input example}{}
\catcode`\%=14\relax
\catcode`\#=6\relax

% Typeset inline markdown text.
\startmarkdown

Here are some non-ASCII characters: *ěščřžýáíé*
and ConTeXt special characters: *|*.

Here is a hard line break that we inserted directly from the TeX source
by typing two spaces at the end of a line.  
This is stretching TeX's abilities and is only supported in ConTeXt MkIV
and later.

\stopmarkdown

\stoptext
