From fc4466b32ed330a956ac603b00fd145524cff49a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 22 Apr 2016 22:14:39 +0000 Subject: context (22apr16) git-svn-id: svn://tug.org/texlive/trunk@40691 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/context/base/mkiv/strc-sbe.mkiv | 148 +++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 Master/texmf-dist/tex/context/base/mkiv/strc-sbe.mkiv (limited to 'Master/texmf-dist/tex/context/base/mkiv/strc-sbe.mkiv') diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-sbe.mkiv b/Master/texmf-dist/tex/context/base/mkiv/strc-sbe.mkiv new file mode 100644 index 00000000000..9f1d214cfda --- /dev/null +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-sbe.mkiv @@ -0,0 +1,148 @@ +%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 + +\installcorenamespace{sectionblock} + +\installcommandhandler \??sectionblock {sectionblock} \??sectionblock + +\setupsectionblock + [\c!number=\v!yes, + \c!page=\v!right] % otherwise marks are reset too soon + +\newtoks\everybeforesectionblock +\newtoks\everyaftersectionblock + +\let\strc_sectionblock_define_normal\definesectionblock + +\unexpanded\def\definesectionblock + {\dotripleargument\strc_sectionblock_define} + +\def\strc_sectionblock_define[#1][#2][#3]% singular plural settings + {\strc_sectionblock_define_normal[#1][#3]% + \expandafter\newif\csname if#2\endcsname % obsolete + \strc_sectionblock_set_environment{#1}\empty + \setuvalue{\e!start#2}{\startsectionblock[#1]}% + \setuvalue{\e!stop #2}{\stopsectionblock}} + +\ifdefined \resetallstructuremarks \else + \let\resetallstructuremarks\relax +\fi + +\def\strc_sectionblock_handle_page + {\edef\p_strc_sectionblock_page{\sectionblockparameter\c!page}% + \ifx\p_strc_sectionblock_page\empty \else + \page[\p_strc_sectionblock_page]% + \fi} + +\appendtoks + \strc_sectionblock_handle_page + \resetallstructuremarks + \strc_sectionblock_get_environment\currentsectionblock + \sectionblockparameter\c!before % don't move + \dostarttagged\t!division\currentsectionblock % no parents +\to \everybeforesectionblock + +\appendtoks + \sectionblockparameter\c!after % don't move + \strc_sectionblock_handle_page + \dostoptagged + \resetallstructuremarks +\to \everyaftersectionblock + +\unexpanded\def\setsectionblock + {\dodoubleempty\strc_sectionblock_set} + +\def\strc_sectionblock_set[#1][#2]% used to set the default + {\edef\currentsectionblock{#1}% from now on we assume a value + \setupcurrentsectionblock[#2]% + \clf_setsectionblock{#1} + bookmark {\sectionblockparameter\c!bookmark}% + \relax} + +\let\currentsectionblock\empty % was \s!unknown + +\unexpanded\def\startsectionblock + {\dodoubleempty\strc_sectionblock_start} + +\unexpanded\def\strc_sectionblock_start[#1][#2]% + {%\ctxlua{structures.counters.check(0)}% we assume sane usage of \page, as this is the only workable place (in push) + \begingroup + \edef\currentsectionblock{#1}% from now on we assume a value + \setupcurrentsectionblock[#2]% + \clf_pushsectionblock{#1} + bookmark {\sectionblockparameter\c!bookmark}% + \relax + \csname #1true\endcsname % obsolete + \setsystemmode\currentsectionblock + \the\everybeforesectionblock\relax + \showmessage\m!structures1\currentsectionblock} + +\unexpanded\def\stopsectionblock + {\showmessage\m!structures2\currentsectionblock + \the\everyaftersectionblock\relax + \clf_popsectionblock + \endgroup} + +%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 + +\installcorenamespace{sectionblockenvironment} + +\unexpanded\def\strc_sectionblock_set_environment#1#2% + {\setvalue{\??sectionblockenvironment#1}{#2}} + +\unexpanded\def\strc_sectionblock_get_environment#1% + {\csname\??sectionblockenvironment#1\endcsname} + +\unexpanded\setvalue{\e!start\v!sectionblockenvironment}% + {\dosingleargument\strc_sectionblock_environment_start} + +\letvalue{\e!stop\v!sectionblockenvironment}\relax + +\def\strc_sectionblock_environment_start[#1]% evt \pushendofline \popendofline + {\grabuntil{\e!stop\v!sectionblockenvironment}{\strc_sectionblock_set_environment{#1}}} + +\protect \endinput -- cgit v1.2.3