test.mkiv

    % ConTeXt test file for Kate's syntax highlighting and code folding

    %% Comments
    %   This is a comment
    \%  Not a comment
    \\% This is a comment

    % Titles should be bold
    \subject{Subject}
    \subsubject{Sub-subject}
    \subsubsubject{Sub-sub-subject}
    \subsubsubsubject{Sub-sub-sub-subject}
    \subsubsubsubsubject{Sub-sub-sub-sub-subject}
    \section{Section}
    \subsection{Sub-section}
    \subsubsection{Sub-sub-section}
    \subsubsubsection{Sub-sub-sub-section}
    \subsubsubsubsection{Sub-sub-sub-sub-section}

    %% Start/stop blocks
    \startsection
    Can be nested
    \startitemize
    \item normal
    \stopitemize
    normal
    \stopsection
    % \startblock \stopblock should be comments

    %% Commands
    \def\startstuff{Custom environment start}
    \def\stopstuff{Custom environment stop}
    \startstuff should not be normal command colour (it is an error to miss \stopstuff)

    \def\sayHello{Héllò Wø®łÐ}
    % This prints Héllò Wø®łÐ@@@ , If it were \sayHelloAAA it would be
    % an error, so the @ is not in the macro
    \sayHello@@@

    \def\testUnderscores{Text_With_Underscores}
    % This prints Text_With_Underscores_ note the final underscore and no error
    \testUnderscores_

    \def\€{Macro with sign}
    % This is a single macro
    \€ % This prints Macro with sign
    \€A % This prints Macro with signA   (not an error)

    \setupindenting[yes, big]

    %% Inline math
    $equations are green, \commands somewhat darker
    it can also run over multiple lines
    % Comment
    $
    normal
    \mathematics{equations are green, \commands somewhat darker
    it can also run over multiple lines
    \mathematics{nested math should be green} this should still be green
    % Comment
    }
    normal
    \math{equations are green, \commands somewhat darker
    it can also run over multiple lines
    \math{nested math should be green} this should still be green
    % Comment
    }
    normal
    \m{equations are green, \commands somewhat darker
    it can also run over multiple lines
    \m{nested math should be green} this should still be green
    % Comment
    }
    normal
    \mathematics the first character should be green {}
    \math        the first character should be green {}
    \m           the first character should be green {}
    \formula     the first character should be green {}
    normal
    % $should$ \mathematics{still} \math{be} \m{commented}

    % The underscore after sum should be blue, not macro color
    Math macro with underscores \m { v = \sum_0^1{ \sqrt{2} }! }

    %% Display math
    $$
    equations are green, \commands somewhat darker
    it can also run over multiple lines
    % Comment
    $$
    normal
    \startformula
    equations are green, \commands somewhat darker
    it can also run over multiple lines
    % Comment

    Nested formulae should not work
    The following should be red:
    \startformula
    Should still be math colour
    \stopformula
    normal

    % This is a regular macro, not math macro
    \def\mathematicsMacroShouldNotMatchThis{Not Math}

    %% Verbatim
    \starttyping
    All text in here should be verbatim colour
    % This should not be a comment
    &@@#^%&^#$

    Nested typing should be displayed in verbatim colour
    \starttyping
    \stoptyping
    should still be verbatim colour
    % This should not be a comment
    \stoptyping

    normal

    %% Tables
    \starttabulate[|c|c|c|]
    \FL
    \NC header1 \NC header2 \NC header3 \NR
    \ML
    \NC value1 \NC value2 \NC value3 \NR
    \NC value4 \NC value5 \NC value6 \NR
    \BL
    \stoptabulate

    Commands for TABLE environment (\bTABLE and \eTABLE, \bTD and \eTD, etc.) should emulate start/stop blocks
    \bTABLE[split=yes]
      \bTR \bTD value1 \eTD \bTD value2 \eTD \bTD value3 \eTD \eTR
      \bTR \bTD value4 \eTD \bTD value5 \eTD \bTD value6 \eTD \eTR
    \eTABLE

    \startxtable
      \startxrow
        \startxcell value1 \stopxcell
        \startxcell value2 \stopxcell
      \stopxrow
      \startxrow
        \startxcell value3 \stopxcell
        \startxcell value5 \stopxcell
      \stopxrow
    \stopxtable

    \subject{ Languajes directly usable in \CONTEXT }

    % These three sould have their own separate syntax highlighting

    \startluacode
        context.chapter({first}, "Some title")
        context.startcolumns({n = 3, rule = "on"})
            context("Hello one")
        context.column()
            context("Hello two")
        context.column()
            context("Hello three")
        context.stopcolumns()
    \stopluacode

    \startMPcode
        transform pagecoords;
        pagecoords := identity scaled 10mm shifted (100mm,150mm);
        fill ( (0,0) -- (2,0) -- (2,1) -- (1,1) -- (1,2) -- cycle )
            transformed pagecoords withcolor green;
        draw ( (2,0) .. (2,1) .. (1,1) .. (1,2) .. (0,2) )
            transformed pagecoords;
        drawarrow ( (0,0) -- (2,2) ) transformed pagecoords;
    \stopMPcode

    \startXML
    <context name="MathModeMacroFind" attribute="Math" lineEndContext="#stay">
        <DetectChar char="{"              attribute="Brace" context="#pop!MathModeMacro"/>
        <RegExpr    String="&macro_math;" attribute="Macro" context="#pop"/> <!-- 1 token -->
        <RegExpr    String="[[:graph:]]"  attribute="Math"  context="#pop"/> <!-- 1 token -->
    </context>
    \stopXML