%D \module
%D   [       file=core-itm,
%D        version=2023.21.007,
%D          title=\CONTEXT\ Table Macros,
%D       subtitle=Itemize,
%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.

\writestatus{loading}{ConTeXt Table Macros / Itemize}

%D This is a bit weird module but also kind of fun. It permits mixing tables with
%D numbered items.
%D
%D \starttyping
%D \startitemize[n,loose]
%D     \startitem \samplefile{ward}  \stopitem
%D     \starttabulate[|pl|i3pl|]
%D         \NC \startitem \samplefile{ward}  \stopitem
%D         \NC \startitem \samplefile{tufte} \stopitem
%D         \NC \NR
%D         \NC \startitem \samplefile{ward}  \stopitem
%D         \NC \startitem \samplefile{tufte} \stopitem
%D         \NC \NR
%D     \stoptabulate
%D     \startitem \samplefile{tufte}  \stopitem
%D \stopitemize
%D
%D \page
%D
%D \starttabulate[|l|i3pl|]
%D     \NC one \NC
%D         \startitemize[n]
%D             \startitem \samplefile{ward}  \stopitem
%D             \startitem \samplefile{tufte} \stopitem
%D         \stopitemize
%D     \NC \NR
%D \stoptabulate
%D
%D \page
%D
%D \startitemize[n,loose,packed]
%D     \startitem \samplefile{ward}  \stopitem
%D     \startlinecorrection
%D         \bTABLE[distance=2em]
%D             \bTR
%D                 \bTD \startitem \samplefile{ward}  \stopitem \eTD
%D                 \bTD \startitem \samplefile{tufte} \stopitem \eTD
%D             \eTR
%D         \eTABLE
%D     \stoplinecorrection
%D     \startitem \samplefile{tufte}  \stopitem
%D \stopitemize
%D
%D \page
%D
%D \bTABLE
%D     \bTR
%D         \bTD
%D             \startitemize[n]
%D                 \startitem \samplefile{ward}  \stopitem
%D                 \startitem \samplefile{tufte} \stopitem
%D             \stopitemize
%D         \eTD
%D     \eTR
%D \eTABLE
%D \stoptyping
%D
%D We don't (yet) deal with spacing but at some point it might happen as it depends
%D on usage.

\unprotect

\appendtoks
    \ifcase\c_strc_itemgroups_nesting\else
        \strc_counters_save\v_strc_itemgroups_counter
    \fi
\to \t_tabl_tabulate_initializers_first

\appendtoks
    \ifcase\c_strc_itemgroups_nesting\else
        \strc_counters_restore\v_strc_itemgroups_counter
    \fi
\to \t_tabl_tabulate_initializers_second

\appendtoks
    \ifcase\c_strc_itemgroups_nesting\else
        \strc_counters_save\v_strc_itemgroups_counter
    \fi
\to \t_tabl_ntb_initializers_first

\appendtoks
    \ifcase\c_strc_itemgroups_nesting\else
        \strc_counters_restore\v_strc_itemgroups_counter
    \fi
\to \t_tabl_ntb_initializers_second

\protect \endinput
