%D \module
%D   [       file=m-pandoc,
%D        version=2019.05.30,
%D          title=\CONTEXT\ Extra Modules,
%D       subtitle=Pandoc Docbook Rendering,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% just a test

\startxmlsetups xml:docbook:article
    \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:docbook:section
    \startsectionlevel[title={\xmltext{#1}{/title}},reference={\xmlatt{#1}{xml:id}}]
        \xmlall{#1}{./!title}
    \stopsectionlevel
\stopxmlsetups

\startxmlsetups xml:docbook:para
    \dontleavehmode\ignorespaces
        \xmlflush{#1}
    \removeunwantedspaces\par
\stopxmlsetups

\startxmlsetups xml:docbook:emphasis
    \dontleavehmode\begingroup
        \em \xmlflush{#1}
    \endgroup
\stopxmlsetups

\startxmlsetups xml:docbook:literal
    \doifelse {\xmlatt{#1}{class}} {math} {
        % what kind of math? inline or display?
        \starttexcode
            \startimath
                \xmlflush{#1}
            \stopimath
        \stoptexcode
    } {
        \dontleavehmode\begingroup
            \tttf \xmlflush{#1}
           % \xmlinlineverbatim{#1}
        \endgroup
    }
\stopxmlsetups

\startxmlsetups xml:docbook:programlisting
    \xmldisplayverbatim{#1}
\stopxmlsetups

\startxmlsetups xml:docbook:link
    \doifsomethingelse {\xmlatt{#1}{xlink:href}} {
        \goto{\xmlflush{#1}}[url(\xmllastatt)]
    } {
        \doifsomethingelse {\xmlatt{#1}{linkend}} {
            \in{\xmlflush{#1}}[\xmllastatt]
        } {
            \xmlflush{#1}
        }
    }
\stopxmlsetups

\startxmlsetups xml:docbook:anchor
    \pagereference[\xmlatt{id}]
\stopxmlsetups

\startxmlsetups xml:docbook:itemizedlist
    \doifelse {\xmlatt{#1}{spacing}} {compact} {
        \startitemize[packed]
            \xmlflush{#1}
        \stopitemize
    } {
        \startitemize
            \xmlflush{#1}
        \stopitemize
    }
\stopxmlsetups

\startxmlsetups xml:docbook:orderedlist
    \doifelse {\xmlatt{#1}{spacing}} {compact} {
        \startitemize[n,packed]
            \xmlflush{#1}
        \stopitemize
    } {
        \startitemize[n]
            \xmlflush{#1}
        \stopitemize
    }
\stopxmlsetups

\startxmlsetups xml:docbook:listitem
    \startitem
        \xmlflush{#1}
    \stopitem
\stopxmlsetups

\startxmlsetups xml:docbook:variablelist
    \startitemize
        \xmlflush{#1}
    \stopitemize
\stopxmlsetups

\startxmlsetups xml:docbook:varlistentry
    \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:docbook:term
    \xmlflush{#1}
\stopxmlsetups

\usemodule[cals]

\startxmlsetups cals:table:before
    \startlinecorrection
\stopxmlsetups

\startxmlsetups cals:table:after
    \stoplinecorrection
\stopxmlsetups

\startxmlsetups xml:docbook
    \xmlsetsetup {#1} {*} {xml:docbook:*}
    \xmlsetfunction {#1} {informaltable} {moduledata.cals.table}
\stopxmlsetups

\continueifinputfile{x-pandoc.mkiv}

\usemodule[article-basic]

\setupinteraction
  [state=start]

\setupalign
  [flushleft,tolerant]

\starttext

    % running:
    %
    % pandoc -s -t docbook5  pandoc.txt

    \xmlregisterdocumentsetup{main}{xml:docbook}
    \xmlprocessfile{main}{d:/pandoc/pandoc.xml}{}

\stoptext

