%D \module %D [ file=strc-sbe, %D version=2008.10.20, %D title=\CONTEXT\ Structure Macros, %D subtitle=Section Block Environments, %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 Structure Macros / Section Block Environments} \unprotect % \def\ChapterEntry#1#2#3% % {chapter : \hbox to \hsize{\strut\bf#2\hss#3}\endgraf\placelist[section]} % % \startfrontmatter % optional % \placelist[chapter][alternative=command,command=\ChapterEntry,criterium=text] \page % \stopfrontmatter % optional % % \startbodymatter % optional % \chapter{first} \section{one} test \section{two} test \page % \chapter{second} \section{alpha} test \section{beta} test \page % \stopbodymatter % optional \unexpanded\def\definesectionblock{\dotripleargument\dodefinesectionblock} \unexpanded\def\setupsectionblock {\dodoubleargument\dosetupsectionblock} \def\setsectionblock {\dosingleargument\dosetsectionblock} \def\sectionblockparameter#1% {\csname \ifcsname\??sb\currentsectionblock#1\endcsname\??sb\currentsectionblock#1\else\s!empty\fi \endcsname} \newtoks \everybeforesectionblock \newtoks \everyaftersectionblock \def\dodefinesectionblock[#1][#2][#3]% singular plural settings {\getparameters [\??sb#1] [\c!number=\v!yes, \c!page=\v!right, % anders worden marks te vroeg gereset ! #3]% \expandafter\newif\csname if#2\endcsname % better a mode \setsectionblockenvironment{#1}\empty \setvalue {\e!start#2}{\startsectionblock[#1]}% \setvalue {\e!stop #2}{\stopsectionblock}} \ifdefined \resetallstructuremarks \else \let\resetallstructuremarks\relax \fi \appendtoks \doifsomething{\sectionblockparameter\c!page}{\page[\sectionblockparameter\c!page]}% \resetallstructuremarks \getsectionblockenvironment\currentsectionblock \sectionblockparameter\c!before % don't move \dostarttagged\t!division\currentsectionblock \to \everybeforesectionblock \appendtoks \sectionblockparameter\c!after % don't move \doifsomething{\sectionblockparameter\c!page}{\page[\sectionblockparameter\c!page]}% \dostoptagged \resetallstructuremarks \to \everyaftersectionblock \def\dosetupsectionblock[#1]% {\getparameters[\??sb#1]}% [#2] \def\dosetsectionblock[#1]% used to set the default {\edef\currentsectionblock{\ctxlua{structures.sections.setblock("#1")}}} \let\currentsectionblock\empty % was \s!unknown \unexpanded\def\startsectionblock[#1]% {%\ctxlua{structures.counters.check(0)}% we assume sane usage of \page, as this is the only workable place (in push) \begingroup \edef\currentsectionblock{\ctxlua{structures.sections.pushblock("#1")}}% \csname #1true\endcsname % for old times sake \setsystemmode\currentsectionblock \the\everybeforesectionblock\relax \showmessage\m!structures1\currentsectionblock} \unexpanded\def\stopsectionblock {\showmessage\m!structures2\currentsectionblock \the\everyaftersectionblock\relax \edef\currentsectionblock{\ctxlua{structures.sections.popblock()}}% \endgroup} \long\def\setsectionblockenvironment#1#2% {\long\setvalue{\??sb\s!do#1}{\do{#2}}} \def\getsectionblockenvironment#1% {\let\do\firstofoneargument %\sectionblockparameter{\s!do#1}} \csname\??sb\s!do#1\endcsname} %D \starttyping %D \startsectionblockenvironment[frontpart] %D \setupnumber[userpage][numberconversion=romannumerals,start=1] %D \stopsectionblockenvironment %D %D \startsectionblockenvironment[bodypart] %D \setupnumber[userpage][numberconversion=numbers,start=1] %D \stopsectionblockenvironment %D %D \startsectionblockenvironment[backpart] %D \setupnumber[userpage][numberconversion=numbers,start=1] %D \stopsectionblockenvironment %D %D \starttext %D \startfrontmatter \chapter{test} \stopfrontmatter %D \startbodymatter \chapter{test} \stopbodymatter %D \startappendices \chapter{test} \stopappendices %D \stoptext %D \stoptyping \setvalue{\e!start\v!sectionblockenvironment}% {\dosingleargument\dostartsectionblockenvironment} \def\dostartsectionblockenvironment[#1]% evt \pushendofline \popendofline {\grabuntil{\e!stop\v!sectionblockenvironment}{\setsectionblockenvironment{#1}}} \protect \endinput