diff options
Diffstat (limited to 'tex')
35 files changed, 1375 insertions, 1221 deletions
diff --git a/tex/context/base/buff-ini.mkiv b/tex/context/base/buff-ini.mkiv index 0d240e1a9..0512910ce 100644 --- a/tex/context/base/buff-ini.mkiv +++ b/tex/context/base/buff-ini.mkiv @@ -34,7 +34,7 @@ {\ctxcommand{erasebuffer("#1")}} \setuvalue{\e!start\v!buffer}% - {\bgroup + {\begingroup % (1) \obeylines \dosingleempty\buff_start} @@ -45,7 +45,7 @@ {\normalexpanded{\buff_pickup{#2}{#3}{#4}{}{\buff_stop{#4}}}} \unexpanded\def\grabbufferdata % was: \dostartbuffer - {\bgroup + {\begingroup % (1) \obeylines \doquadrupleempty\buff_grab_direct_indeed} @@ -64,12 +64,13 @@ \unexpanded\def\buff_pickup#1#2#3#4#5% name, startsequence, stopsequence, before, after {#4% - \bgroup + \begingroup % (2) \edef\catcodetableofbuffer{\number\catcodetable}% \ctxcommand{erasebuffer("#1")}% \setcatcodetable\vrbcatcodes \def\buff_finish - {\egroup + {\endgroup % (1) + \endgroup % (2) #5}% \def\buff_gobble##1#3% is detokenize needed? TEST %{\ctxcommand{grabbuffer("#1","#2","#3",\!!bs\detokenize{##1}\!!es)} % space ? diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 86e6a0374..43da43bd6 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.01.11 14:58} +\newcontextversion{2012.01.12 11:03} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 89a754665..dd3bf86dd 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.01.11 14:58} +\newcontextversion{2012.01.12 11:03} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex edaaa063f..6c7fccec0 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 4a65db342..44fc1db1b 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index cefbf66b7..944066f75 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.01.11 14:58} +\edef\contextversion{2012.01.12 11:03} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 65423c066..5f6719619 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -23,7 +23,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.01.11 14:58} +\edef\contextversion{2012.01.12 11:03} %D For those who want to use this: @@ -406,6 +406,8 @@ \loadmarkfile{strc-lnt} \loadmarkfile{core-mis} +\loadmarkfile{pack-com} +\loadmarkfile{typo-del} \loadmarkfile{grph-trf} \loadmarkfile{grph-inc} diff --git a/tex/context/base/core-ini.mkiv b/tex/context/base/core-ini.mkiv index cdaa02a21..0c369ff3a 100644 --- a/tex/context/base/core-ini.mkiv +++ b/tex/context/base/core-ini.mkiv @@ -36,7 +36,7 @@ \appendtoks \registerparoptions \to \everypar \appendtoks \flushsyncpositions \to \everypar \appendtoks \flushpostponednodedata \to \everypar -\appendtoks \dohandlerepeatdelimitedtext \to \everypar +\appendtoks \typo_delimited_repeat \to \everypar \appendtoks \insertparagraphintro \to \everypar \appendtoks \flushpostponedbookmark \to \neverypar diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv index 1e21fc60c..299a01fa2 100644 --- a/tex/context/base/core-mis.mkiv +++ b/tex/context/base/core-mis.mkiv @@ -1,4 +1,3 @@ - %D \module %D [ file=core-mis, %D version=1998.01.29, @@ -16,21 +15,6 @@ % needs to be redone -% %D You would not expect the next macro in \CONTEXT, -% %D wouldn't you? It's there to warn \LATEX\ users that -% %D something is wrong. -% %D -% %D Obsolete now: -% % -% % \def\documentstyle{\showmessage\m!system3\empty\stoptekst} -% % -% % \let\documentclass=\documentstyle -% %D \macros -% %D {simplifiedcommands, simplifycommands} -% %D -% %D I first needed this simplification in bookmarks. Users can -% %D add their own if needed. - \unprotect %D Sometimes (for instance in bookmarks) we need to simplify macro @@ -60,15 +44,6 @@ % THIS WAS MAIN-002.TEX -%\def\checkinterlineskip -% {\ifvmode -% \ifdim\lastskip>\zeropoint -% \nointerlineskip -% \else\ifdim\lastkern>\zeropoint -% \nointerlineskip -% \fi\fi -% \fi} - \def\horitems#1#2% #1=breedte #2=commandos {\scratchdimen#1% \divide\scratchdimen \nofitems @@ -197,11 +172,6 @@ \c!inbetween={\blank[\v!medium]}, \c!after=\blank] -% Te zijner tijd [plaats=boven,onder,midden] implementeren, -% in dat geval moet eerst de maximale hoogte worden bepaald. -% -% Overigens kan een en ander mooier met \halign. - % there is quite some historic balast in this mechanism, the next variant % is a first cleanup @@ -419,6 +389,8 @@ \paragraphparameter\c!after \egroup} +% Is this used at all? + \def\dosetuptab[#1]% {\getparameters[\??ta] [\c!headstyle=\v!normal, @@ -445,663 +417,6 @@ \setuptab [\c!location=\v!left] -\unexpanded\def\celsius #1{#1\mathematics{^\circ}C} -\unexpanded\def\inch {\mathematics{\prime\prime}} % was: \hbox{\rm\char125\relax} -\unexpanded\def\fraction#1#2{\mathematics{#1\over#2}} - -% very dutch - -\unexpanded\def\graden {\mathematics{^\circ}} - -\def\bedragprefix {\euro\normalfixedspace} -\def\bedragsuffix {} -\def\bedragempty {\euro} - -\unexpanded\def\bedrag#1% - {\strut\hbox\bgroup - \let\normalfixedspace\nonbreakablespace - \doifelsenothing{#1} - {\bedragempty} - {\bedragprefix\digits{#1}\bedragsuffix}% - \egroup} - -% \definieeralineas[test][n=3] -% -% \stelalineasin[test][3][breedte=4cm,uitlijnen=links] -% -% \startopelkaar -% \test hans \\ ton \\ \bedrag{1.000,--} \\ -% \test hans \\ ton \\ \bedrag{~.~~1,--} \\ -% \test hans \\ ton \\ \bedrag{~.~~1,~~} \\ -% \test hans \\ ton \\ \bedrag{~.100,--} \\ -% \test hans \\ ton \\ \subtot{1.000,--} \\ -% \test hans \\ ton \\ \bedrag{1.000,--} \\ -% \test hans \\ ton \\ \bedrag{1.000,--} \\ -% \test hans \\ ton \\ \totaal{1.000,--} \\ -% \test hans \\ ton \\ \bedrag{nihil,--} \\ -% \test hans \\ ton \\ \totaal{nihil,--} \\ -% \test hans \\ ton \\ \subtot{nihil,--} \\ -% \stopopelkaar - -\def\periodswidth {.5em} -\def\periodsdefault{3} % was 5, but now it's like \unknown - -\unexpanded\def\periods - {\dosingleempty\doperiods} - -% \def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 -% {\dontleavehmode -% \begingroup -% \scratchdimen\periodswidth -% \hbox to \iffirstargument#1\else\periodsdefault\fi \scratchdimen -% {\leaders\hbox to \scratchdimen{\hss.\hss}\hss}% -% \endgroup} -% -% better for export: - -\def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 - {\dontleavehmode - \hbox\bgroup - \setbox\scratchbox\hbox to \periodswidth{\hss.\hss}% - \dorecurse{\iffirstargument#1\else\periodsdefault\fi}{\copy\scratchbox}% - \egroup} - -\unexpanded\def\unknown - {\periods\relax} % relax prevents lookahead for [] - -% Example by Wolfgang Schuster on the context list: -% -% \unexpanded\def\fourdots{{\def\periodswidth{.3em}\periods[4]}} -% -% Hello\fourdots\ World\fourdots \par Hello\fourdots\ World. - -\setnewconstant\boundarycharactermode\plusone - -\def\midboundarycharacter#1#2% - {\ifcase\boundarycharactermode - \or - %\nobreak - \hskip\hspaceamount\currentlanguage{#2}% - \languageparameter#1% - %\nobreak - \hskip\hspaceamount\currentlanguage{#2}% - \or - \languageparameter#1% - \fi - \boundarycharactermode\plusone} - -\def\leftboundarycharacter#1#2% - {\ifcase\boundarycharactermode - \or - \languageparameter#1% - \nobreak - \hskip\hspaceamount\currentlanguage{#2}% - \or - \languageparameter#1% - \fi - \boundarycharactermode\plusone} - -\def\rightboundarycharacter#1#2% - {\ifcase\boundarycharactermode - \or - \prewordbreak %\nobreak - \hskip\hspaceamount\currentlanguage{#2}% - \languageparameter#1% - \or - \languageparameter#1% - \fi - \boundarycharactermode\plusone} - -% actually this is pretty old, but temporary moved here -% -% obsolete: - -\unexpanded\def\setuphyphenmark - {\dodoubleargument\getparameters[\??kp]} - -\unexpanded\def\setuphyphenmark[#1]% sign=normal|wide - {\dodoubleargument\getparameters[\??kp][#1]% - \doifelse\@@kpsign {\v!normal}% was inset? - {\let\textmodehyphen\normalhyphen \let\textmodehyphendiscretionary\normalhyphendiscretionary} - {\let\textmodehyphen\composedhyphen\let\textmodehyphendiscretionary\composedhyphendiscretionary}} - -\setuphyphenmark[\c!sign=\v!wide] -% % \setuphyphenmark[\c!sign=\v!normal] - -\definesymbol[\c!lefthyphen] [\languageparameter\c!lefthyphen] -\definesymbol[\c!righthyphen] [\languageparameter\c!righthyphen] -\definesymbol[\c!hyphen] [\languageparameter\c!hyphen] - -\def\normalhyphen - {\hbox{\directsymbol\empty\c!hyphen}} - -\def\composedhyphen - {\hbox{\directsymbol\empty\c!compoundhyphen}} - -\def\normalhyphendiscretionary - {\discretionary - {\hbox{\directsymbol\empty\c!righthyphen}} - {\hbox{\directsymbol\empty\c!lefthyphen}} - {\hbox{\directsymbol\empty\c!hyphen}}} - -\def\composedhyphendiscretionary - {\discretionary - {\hbox{\directsymbol\empty\c!rightcompoundhyphen}} - {\hbox{\directsymbol\empty\c!leftcompoundhyphen}} - {\hbox{\directsymbol\empty\c!compoundhyphen}}} - -\let\textmodehyphen \composedhyphen -\let\textmodehyphendiscretionary\composedhyphendiscretionary - -\definesymbol[\c!leftcompoundhyphen] [\languageparameter\c!leftcompoundhyphen] -\definesymbol[\c!rightcompoundhyphen] [\languageparameter\c!rightcompoundhyphen] -\definesymbol[\c!compoundhyphen] [\languageparameter\c!compoundhyphen] - -\definehspace [sentence] [\zeropoint] -\definehspace [intersentence] [.250em] - -\definesymbol - [\c!midsentence] - [\midboundarycharacter\c!midsentence{sentence}] - -\definesymbol - [\c!leftsentence] - [\leftboundarycharacter\c!leftsentence{sentence}] - -\definesymbol - [\c!rightsentence] - [\rightboundarycharacter\c!rightsentence{sentence}] - -\definesymbol - [\c!leftsubsentence] - [\leftboundarycharacter\c!leftsubsentence{sentence}] - -\definesymbol - [\c!rightsubsentence] - [\rightboundarycharacter\c!rightsubsentence{sentence}] - -\newsignal \subsentencesignal -\newcount \subsentencelevel - -\let\beforesubsentence\donothing -\let\aftersubsentence \donothing - -% todo: make this language option -% -% \def\beforesubsentence{\removeunwantedspaces} -% \def\aftersubsentence {\ignorespaces} - -\def\midsentence - {\symbol[\c!midsentence]} - -\def\beginofsubsentence - {\beforesubsentence - \ifdim\lastkern=\subsentencesignal - \unskip - \kern\hspaceamount\currentlanguage{intersentence}% - \fi - \global\advance\subsentencelevel\plusone - \ifnum\subsentencelevel=\plusone - \dontleavehmode % was \leaveoutervmode - \fi - \dostarttagged\t!subsentence\empty - \symbol[\ifodd\subsentencelevel\c!leftsentence\else\c!leftsubsentence\fi]% - }% \ignorespaces} - -\def\endofsubsentence % relax prevents space gobbling - {\symbol[\ifodd\subsentencelevel\c!rightsentence\else\c!rightsubsentence\fi]% - \dostoptagged - \global\advance\subsentencelevel\minusone - \unskip - \kern\subsentencesignal\relax - \aftersubsentence} - -\def\beginofsubsentencespacing % relax prevents space gobbling - {\kern\subsentencesignal\relax}% \ignorespaces} - -\def\endofsubsentencespacing - {\ifdim\lastkern=\subsentencesignal - \unskip - \hskip\hspaceamount\currentlanguage{intersentence}% - % no good, actually language dependent: -% \ignorespaces - \else - \unskip - \fi} - -%D \startbuffer -%D test |<|test |<|test|>| test|>| test \par -%D test|<|test|<|test|>|test|>|test \par -%D test |<||<|test|>||>| test \par -%D test \directdiscretionary{<}test\directdiscretionary{>} test \par -%D \stopbuffer -%D -%D \typebuffer -%D \getbuffer - -\unexpanded\def\startsubsentence{\beginofsubsentence \prewordbreak\beginofsubsentencespacing} -\unexpanded\def\stopsubsentence {\endofsubsentencespacing\prewordbreak\endofsubsentence} -\unexpanded\def\subsentence {\groupedcommand\startsubsentence\stopsubsentence} - -\definehspace [quotation] [\zeropoint] -\definehspace [interquotation] [.125em] - -%definehspace [quote] [\zeropoint] -%definehspace [speech] [\zeropoint] - -\definehspace [quote] [\hspaceamount\currentlanguage{quotation}] -\definehspace [speech] [\hspaceamount\currentlanguage{quotation}] - -\definesymbol - [\c!leftquotation] - [\leftboundarycharacter\c!leftquotation{quotation}] - -\definesymbol - [\c!rightquotation] - [\rightboundarycharacter\c!rightquotation{quotation}] - -\definesymbol - [\c!leftquote] - [\leftboundarycharacter\c!leftquote{quote}] - -\definesymbol - [\c!rightquote] - [\rightboundarycharacter\c!rightquote{quote}] - -\definesymbol - [\c!leftspeech] - [\leftboundarycharacter\c!leftspeech{speech}] - -\definesymbol - [\c!rightspeech] - [\rightboundarycharacter\c!rightspeech{speech}] - -\definesymbol - [\c!middlespeech] - [\leftboundarycharacter\c!middlespeech{speech}] - -\appendtoks\def\quotation#1{"#1"}\to\simplifiedcommands -\appendtoks\def\quote #1{'#1'}\to\simplifiedcommands - -%D The next features was so desperately needed by Giuseppe -%D Bilotta that he made a module for it. Since this is a -%D typical example of core functionality, I decided to extend -%D the low level quotation macros in such a way that a speech -%D feature could be build on top of it. The speech opening and -%D closing symbols are defined per language. Italian is an -%D example of a language that has them set. - -% this will replace the quotation and speed definitions - -% todo: \typo_ namespace - -\newsignal\delimitedtextsignal - -\let\currentdelimitedtext\s!unknown - -\def\delimitedtextlevel{\csname\??ci:\currentdelimitedtext:\c!level\endcsname} - -\def\doinitializetextlevel#1% - {\ifcsname\??ci:#1:\c!level\endcsname - \csname\??ci:#1:\c!level\endcsname\zerocount - \else - \expandafter\newcount\csname\??ci:#1:\c!level\endcsname - \fi} - -\def\delimitedtextparameter#1% will be sped up - {\executeifdefined{\??ci\currentdelimitedtext:\number\delimitedtextlevel#1}% - {\executeifdefined{\??ci\currentdelimitedtext#1}% - {\executeifdefined{\??ci#1}\empty}}} - -\unexpanded\def\definedelimitedtext - {\dodoubleempty\dodefinedelimitedtext} - -\def\dodefinedelimitedtext[#1][#2]% - {\doinitializetextlevel{#1}% - \doifassignmentelse{#2} - {\getparameters - [\??ci#1] - [\c!location=\v!margin, % \v!text \v!paragraph - \c!spacebefore=, - \c!spaceafter=\delimitedtextparameter\c!spacebefore, - \c!style=\v!normal, - \c!color=, - \c!leftmargin=\zeropoint, - \c!rightmargin=\delimitedtextparameter\c!leftmargin, - \c!indentnext=\v!yes, - \c!before=, - \c!after=, - \c!left=, - \c!right=, - %\c!level=0, - \c!repeat=\v!no, - \c!method=, - #2]}% - {\doifdefined{#2} - {\copyparameters[\??ci#1][\??ci#2] - [\c!location,\c!spacebefore,\c!spaceafter,\c!style,\c!color, - \c!leftmargin,\c!rightmargin,\c!indentnext, - \c!before,\c!after,\c!left,\c!right]}}% - \doifsomething{#1} - {\setuvalue{#1}{\delimitedtext[#1]}% - \setuvalue{\e!start#1}{\startdelimitedtext[#1]}% u added - \setuvalue{\e!stop #1}{\stopdelimitedtext}}} % u added - -\unexpanded\def\setupdelimitedtext - {\dotripleargument\dosetupdelimitedtext} - -\def\dosetupdelimitedtext[#1][#2][#3]% #2 = optional level - {\ifthirdargument - \getparameters[\??ci#1:#2][#3]% - \else\ifsecondargument - \getparameters[\??ci#1][#2]% - \else - \getparameters[\??ci][#1]% - \fi\fi} - -\def\dorepeatdelimitedtext - {\relax\ifcase\delimitedtextlevel\else - \dohandledelimitedtext\c!middle % maybe better \dohandleleftdelimitedtext - \fi} - -\let\dohandlerepeatdelimitedtext\relax - -\unexpanded\def\startdelimitedtext[#1]% - {\begingroup - \pushdelimitedtext{#1}% - \dostarttagged\t!delimitedblock\currentdelimitedtext - \doifelse{\delimitedtextparameter\c!method}\s!font - {\let\dostopdelimitedtext\typo_delimitedtexts_finish_font - \ignoredelimitedtext\c!left\ignorespaces} - {\doifelse{\delimitedtextparameter\c!repeat}\v!yes - {\let\dohandlerepeatdelimitedtext\dorepeatdelimitedtext}% - {\let\dohandlerepeatdelimitedtext\relax}% - \doifinsetelse{\delimitedtextparameter\c!location}{\v!paragraph,\v!margin}% - {\dosingleempty\dostartdelimitedtextpar}\dostartdelimitedtexttxt}} - -\def\typo_delimitedtexts_finish_font - {\removeunwantedspaces\ignoredelimitedtext\c!right} - -\def\dostartdelimitedtextpar[#1]% - {\let\dostopdelimitedtext\dostopdelimitedtextpar - \doifsomething{\delimitedtextparameter\c!spacebefore} - {\blank[\delimitedtextparameter\c!spacebefore]}% - \delimitedtextparameter\c!before - % nicer: - % \doadaptleftskip {\delimitedtextparameter\c!leftmargin}% - % \doadaptrightskip{\delimitedtextparameter\c!rightmargin}% - % backward compatible: - \doifelsenothing{#1} - {\endgraf - \doadaptleftskip {\delimitedtextparameter\c!leftmargin}% - \doadaptrightskip{\delimitedtextparameter\c!rightmargin}% - \let\dodostopdelimitedtextpar\endgraf} - {\startnarrower[#1]\let\dodostopdelimitedtextpar\stopnarrower}% - % so far - \pushmacro\checkindentation - \doifsomething{\delimitedtextparameter\c!indenting} % WS - {\setupindenting[\delimitedtextparameter\c!indenting]}% - \begingroup - \dousestylehashparameter{\??ci\currentdelimitedtext}\c!style - \dousecolorhashparameter{\??ci\currentdelimitedtext}\c!color - \leftdelimitedtextmark - \ignorespaces} - -\def\dostopdelimitedtextpar - {\removeunwantedspaces - \removelastskip - \rightdelimitedtextmark - \endgroup - \popmacro\checkindentation - \dodostopdelimitedtextpar - \delimitedtextparameter\c!after - \doifsomething{\delimitedtextparameter\c!spaceafter} - {\blank[\delimitedtextparameter\c!spaceafter]}% - \useindentnextparameter\delimitedtextparameter - \dorechecknextindentation}% AM: This was missing! - -\def\dostartdelimitedtexttxt - {\let\dostopdelimitedtext\dostopdelimitedtexttxt - \begingroup - \dousestylehashparameter{\??ci\currentdelimitedtext}\c!style - \dousecolorhashparameter{\??ci\currentdelimitedtext}\c!color - \dohandleleftdelimitedtext\c!left - \ignorespaces} - -\def\dostopdelimitedtexttxt - {\removeunwantedspaces - \dohandlerightdelimitedtext\c!right - \endgroup} - -\unexpanded\def\stopdelimitedtext - {\dostopdelimitedtext - \dostoptagged - \popdelimitedtext - \endgroup} - -\def\pushdelimitedtext#1% - {\globalpushmacro\currentdelimitedtext - \def\currentdelimitedtext{#1}% - \global\advance\delimitedtextlevel\plusone} - -\def\popdelimitedtext - {\global\advance\delimitedtextlevel\minusone - \globalpopmacro\currentdelimitedtext} - -\unexpanded\def\delimitedtext[#1]% - {\dontleavehmode % following ones can be omited - \pushdelimitedtext{#1}% - \doifelse{\delimitedtextparameter\c!method}\s!font - {\dofontdrivendelimited} - {\doifinsetelse{\delimitedtextparameter\c!location}{\v!paragraph,\v!margin}% - \dodelimitedtextpar\dodelimitedtexttxt}} - -% shortcuts - -\unexpanded\def\startdelimited{\startdelimitedtext} -\unexpanded\def\stopdelimited {\stopdelimitedtext} % no let, dynamically assigned - \def\delimited {\delimitedtext} - -\def\leftdelimitedtextmark - {\doifsomething{\delimitedtextparameter\c!left} - {\setbox\scratchbox\hbox{\delimitedtextparameter\c!left}% - \dontleavehmode - \doif{\delimitedtextparameter\c!location}\v!margin{\hskip-\wd\scratchbox}% - \box\scratchbox}} - -\def\rightdelimitedtextmark - {\doifsomething{\delimitedtextparameter\c!right} - {\hsmash{\delimitedtextparameter\c!right}}} - -% \starttext -% \hyphenatedword{groepsvrijstellingsverordeningen}\par -% \hyphenatedword{\quote{groepsvrijstellingsverordeningen}}\par -% \dorecurse{100}{\hskip300pt\hskip\recurselevel pt test \quote{xxx xxxx}.\par} -% \page \setuppapersize[A5][A4] -% \quotation {overly beautiful pusillanimous sesquipedalian -% longwinded} test test test test test test test test test test test -% test test test test test test test test test test test test test -% test test test test test test test test test test test test test -% test test test test test test test test test test test test test -% test test test -% \stoptext - -\def\dohandledelimitedtext#1#2% - {\begingroup - \setbox\scratchbox\hbox{\delimitedtextparameter#1}% - \ifdim\wd\scratchbox>\zeropoint - \ifdim\lastkern=\delimitedtextsignal - \unkern - \hskip\hspaceamount\currentlanguage{interquotation}% - \else - #2% - \fi - \ifhmode % else funny pagebeaks - \penalty\plustenthousand - \hskip\zeropoint % == \prewordbreak - \fi - \strut % new, needed below - \delimitedtextparameter#1% unhbox\scratchbox - % \penalty\plustenthousand % else overfull boxes, but that's better than dangling periods - \kern\delimitedtextsignal % +- \prewordbreak - \fi - \endgroup} - -\def\dohandleleftdelimitedtext#1#2% - {\begingroup - \setbox\scratchbox\hbox{\delimitedtextparameter#1}% - \ifdim\wd\scratchbox>\zeropoint - \ifdim\lastkern=\delimitedtextsignal - \unkern - \hskip\hspaceamount\currentlanguage{interquotation}% - \else\ifdim\lastskip=\delimitedtextsignal - \unskip - \hskip\hspaceamount\currentlanguage{interquotation}% - \else - #2% - \fi\fi - \strut % new, needed below - \ifhmode % else funny pagebeaks - \penalty\plustenthousand - \hskip\zeropoint % == \prewordbreak - \fi - \strut % new, needed below - \delimitedtextparameter#1% unhbox\scratchbox - \hskip\delimitedtextsignal % +- \prewordbreak - \fi - \endgroup} - -\def\dohandlerightdelimitedtext#1#2% - {\begingroup - \setbox\scratchbox\hbox{\delimitedtextparameter#1}% - \ifdim\wd\scratchbox>\zeropoint - \ifdim\lastkern=\delimitedtextsignal - \unkern - \penalty\plustenthousand - \hskip\hspaceamount\currentlanguage{interquotation}% - \else\ifdim\lastskip=\delimitedtextsignal - \unskip - \penalty\plustenthousand - \hskip\hspaceamount\currentlanguage{interquotation}% - \else - #2% - \fi\fi - \ifhmode % else funny pagebeaks - \penalty\plustenthousand - \hskip\zeropoint % == \prewordbreak - \fi - \strut % new, needed below - \delimitedtextparameter#1% unhbox\scratchbox - \kern\delimitedtextsignal % +- \prewordbreak - \fi - \endgroup} - - -\def\ignoredelimitedtext#1% - {\delimitedtextparameter#1} - -\def\handledelimitedtext#1% - {\dohandledelimitedtext{#1}\relax} - -\def\handleleftdelimitedtext#1% - {\dohandleleftdelimitedtext{#1}\relax} - -\def\handlerightdelimitedtext#1% - {\dohandlerightdelimitedtext{#1}\relax} - -\unexpanded\def\dodelimitedtextpar - {\groupedcommand - {\dostarttagged\t!delimited\currentdelimitedtext % block? - \dohandleleftdelimitedtext\c!left\relax} - {\dohandlerightdelimitedtext\c!right\removelastskip - \dostoptagged - \popdelimitedtext}} - -\unexpanded\def\dodelimitedtexttxt - {\doifelse{\delimitedtextparameter\c!style}\v!normal - \doquoteddelimited\doattributeddelimited} - -\def\doquoteddelimited - {\groupedcommand - {\dostarttagged\t!delimited\currentdelimitedtext - \dohandleleftdelimitedtext\c!left\relax} - {\dohandlerightdelimitedtext\c!right - \removelastskip - \dostoptagged - \popdelimitedtext}} - -\def\doattributeddelimited - {\groupedcommand - {\dostarttagged\t!delimited\currentdelimitedtext - \dousestylehashparameter{\??ci\currentdelimitedtext}\c!style - \dousecolorhashparameter{\??ci\currentdelimitedtext}\c!color} - {\dostoptagged - \popdelimitedtext}} - -\def\dofontdrivendelimited - {\simplegroupedcommand - {\dostarttagged\t!delimited\currentdelimitedtext - \languageparameter{\c!left\currentdelimitedtext}} - {\languageparameter{\c!right\currentdelimitedtext}% - \dostoptagged - \popdelimitedtext}} - -% testcase for nesting: -% -% \quotation{... \quotation{...} ...} -% \startquotation ... \startquotation... \quotation{...} \stopquotation\space ...\stopquotation -% \setupdelimitedtext[quotation][1][left=(,right=)] -% \setupdelimitedtext[quotation][2][left={[},right={]}] -% \setupdelimitedtext[quotation][3][left=\{,right=\}] -% \quotation{... \quotation{...} ...} -% \startquotation ... \startquotation... \quotation{...} \stopquotation\space ...\stopquotation - -\definedelimitedtext - [\v!quotation] - [\c!left={\symbol[\c!leftquotation]}, - \c!right={\symbol[\c!rightquotation]}, - \c!leftmargin=\v!standard] - -\definedelimitedtext - [\v!quote][\v!quotation] - -\setupdelimitedtext - [\v!quote] - [\c!location=\v!text, - \c!left={\symbol[\c!leftquote]}, - \c!right={\symbol[\c!rightquote]}] - -\definedelimitedtext - [\v!blockquote][\v!quotation] - -\setupdelimitedtext - [\v!blockquote] - [\c!left=, - \c!right=] - -\definedelimitedtext - [\v!speech][\v!quotation] - -\setupdelimitedtext - [\v!speech] - [\c!repeat=\v!yes, - \c!left={\symbol[\c!leftspeech]}, - \c!middle={\symbol[\c!middlespeech]}, - \c!right={\symbol[\c!rightspeech]}] - -% how do we call an tight quote -% -% \definedelimitedtext -% [\v!quotation][\v!quotation] -% -% \setupdelimitedtext -% [\v!quotation] -% [\c!indentnext=\v!no, -% \c!spacebefore=\v!nowhite] - -\unexpanded\def\setupquotation{\setupdelimitedtext[\v!quotation]} -\unexpanded\def\setupquote {\setupdelimitedtext[\v!quote]} - % seldom used, move from kernel to run time module \ifx\tfx\undefined \let\tfx\relax \fi @@ -1219,41 +534,6 @@ \let\grid\basegrid -% only used at pragma, move from kernel to run time module - -\def\referraldate - {\currentdate[\v!referral]} - -\def\doreferral[#1]% - {\noheaderandfooterlines - \bgroup - \getparameters - [\??km] - [\c!bet=\unknown,\c!dat=\unknown,\c!ken=\unknown, - \c!from=,\c!to=,\c!ref=,#1]% - % moet anders, hoort niet in 01b - \assigntranslation[\s!nl=referentie,\s!en=reference,\s!de=Referenz,\s!hr=referenca,\s!sp=referencia]\to\@@@kmref - \assigntranslation[\s!nl=van,\s!en=from,\s!de=Von,\s!hr=od,\s!sp=de]\to\@@@kmvan - \assigntranslation[\s!nl=aan,\s!en=to,\s!de=An,\s!hr=za,\s!sp=a]\to\@@@kmaan - \assigntranslation[\s!nl=betreft,\s!en=concerns,\s!de=Betreff,\s!hr=predmet,\s!sp=]\to\@@@kmbet - \assigntranslation[\s!nl=datum,\s!en=date,\s!de=Datum,\s!hr=datum,\s!sp=fecha]\to\@@@kmdat - \assigntranslation[\s!nl=kenmerk,\s!en=mark,\s!de=Kennzeichen,\s!hr=oznaka,\s!sp=]\to\@@@kmken - % - \definetabulate[\s!dummy][|l|p|] - \startdummy - \NC\@@@kmbet\EQ\@@kmbet\NC\NR - \NC\@@@kmdat\EQ\@@kmdat\NC\NR - \NC\@@@kmken\EQ\expanded{\smallcapped{\@@kmken}}\NC\NR - \doifsomething{\@@kmfrom\@@kmto}{\NC\NC\NC\NR}% - \doifsomething \@@kmfrom {\NC\@@@kmvan\EQ\@@kmfrom\NC\NR}% - \doifsomething \@@kmto {\NC\@@@kmaan\EQ\@@kmto\NC\NR}% - \doifsomething \@@kmref {\NC\NC\NC\NR\NC\@@@kmref\EQ\@@kmref\NC\NR}% - \stopdummy - \egroup} - -\def\referral - {\dosingleargument\doreferral} - \definetabulate [\v!legend] [|emj1|i1|mR|] @@ -1433,6 +713,12 @@ %D \stopitemize}} %D \stoptyping +\newsystemmode{pairedbox} + +\appendtoks + \global\resetsystemmode{pairedbox}% +\to \everyinsidefloat + \newbox\firstpairedbox \newbox\secondpairedbox @@ -1610,294 +896,6 @@ \definepairedbox[\v!legend] -%D Goody (to be reconsidered): - -\newsystemmode{combination} -\newsystemmode{pairedbox} - -\appendtoks - \global\resetsystemmode{combination}% - \global\resetsystemmode{pairedbox}% -\to \everyinsidefloat - -% todo: \startcombination \startcomb \stopcomb ... - -% needs to be mkiv'd (we could map this onto bTABLE) - -\newcount\horcombination % counter -\newcount\totcombination - -\unexpanded\def\definecombination - {\dodoubleempty\dodefinecombination} - -\def\dodefinecombination[#1][#2]% - {\copyparameters - [\??co#1][\??co] - [\c!width,\c!height,\c!distance,\c!location,% - \c!before,\c!inbetween,\c!after,\c!align,% - \c!style,\c!color]% - \getparameters - [\??co#1][#2]} - -\unexpanded\def\setupcombinations - {\dodoubleempty\dosetupcombinations} - -\def\dosetupcombinations[#1][#2]% - {\ifsecondargument - \getparameters[\??co#1][#2]% - \else - \getparameters[\??co][#1]% - \fi} - -\def\combinationparameter#1% - {\csname\??co\currentcombination#1\endcsname}% - -\unexpanded\def\startcombination - {\bgroup % so we can grab a group - \dodoubleempty\dostartcombination} - -% \startcombination {alpha} {a} {beta} {b} \stopcombination -% \startcombination[2*1] {alpha} {a} {beta} {b} \stopcombination -% \startcombination[1*2] {alpha} {a} {beta} {b} \stopcombination -% \startcombination[2] {alpha} {a} {beta} {b} \stopcombination - -\def\dostartcombination[#1][#2]% needs a cleanup, also nx ny (pretty old, this one) - {\global\setsystemmode{combination}% - \doifnothing{#1}\firstargumentfalse % to be sure (when called in macros) - \doifnothing{#2}\secondargumentfalse % to be sure (when called in macros) - \ifsecondargument % todo: nx ny - \def\currentcombination{#1}% - \edef\currentcombinationspec{#2*1*}% - \else % better : \doifcombinationelse ... \??co#1\c!location - \doifinstringelse{*}{#1} - {\let\currentcombination\empty - \edef\currentcombinationspec{#1*1*}} - {\doifnumberelse{#1} - {\let\currentcombination\empty - \edef\currentcombinationspec{#1*1*}} - {\def\currentcombination{#1}% - \edef\currentcombinationspec{2*1*}}}% - \fi - \forgetall - \dostarttagged\t!combination\currentcombination - \doifelse{\combinationparameter\c!height}\v!fit - \vbox {\vbox to \combinationparameter\c!height}% - \bgroup - \let\combination\empty % permits \combination{}{} handy for cld - \setuphorizontaldivision - [\c!n=\v!fit,\c!distance=\combinationparameter\c!distance]% - \expanded{\dodostartcombination[\currentcombinationspec]}} - -\ifdefined\dotagcombination \else \let\dotagcombination\relax \fi - -\long\def\dodostartcombination[#1*#2*#3]% - {\global\horcombination#1% - \global\totcombination#2% - \dotagcombination - \global\setbox\combinationstack\emptybox - \xdef\maxhorcombination{\the\horcombination}% - \multiply\totcombination\horcombination - \tabskip\zeropoint - \doifelse{\combinationparameter\c!width}\v!fit - {\halign}{\halign to \combinationparameter\c!width}% - \bgroup - &% - %\hfil##\hfil% now : location={left,top} - \expanded{\doifnotinset{\v!left}{\combinationparameter\c!location}}\hfil - ##% - \expanded{\doifnotinset{\v!right}{\combinationparameter\c!location}}\hfil - &% - \tabskip\zeropoint \!!plus 1fill - ##% - \cr - \docombination} - -\def\docombination % we want to add struts but still ignore an empty box - {\dostarttagged\t!combinationpair\empty - \dostarttagged\t!combinationcontent\empty - \dowithnextboxcs\docombinationfinish\hbox} - -\def\docombinationfinish % we want to add struts but still ignore an empty box - {\dostoptagged - \setbox0\flushnextbox - \dostarttagged\t!combinationcaption\empty - \dowithnextbox - {\dostoptagged - \dostoptagged - \setbox2\flushnextbox - \dodocombination}% - \vtop\bgroup - \afterassignment\donextcombination\let\nexttoken=} - -\def\donextcombination - {\futurelet\nexttoken\donextnextcombination} - -\def\donextnextcombination - {\ifx\nexttoken\egroup \else % the next box is empty - \hsize\wd0 - \setupalign[\combinationparameter\c!align]% - \dousestylehashparameter{\??co\currentcombination}\c!style - \dousecolorhashparameter{\??co\currentcombination}\c!color - \bgroup - \aftergroup\endstrut - \aftergroup\egroup - \begstrut - \fi} - -\def\depthonlybox - {\dowithnextbox{\vtop{\hsize\wd\nextbox\kern\zeropoint\box\nextbox}}\vbox} - -\def\dodocombination - {\vbox - {\forgetall % \setupwhitespace[\v!none]% - \let\next\vbox - \expanded{\processallactionsinset[\combinationparameter\c!location]} - [ \v!top=>\let\next\depthonlybox, % \tbox, - \v!middle=>\let\next\halfwaybox]% - \next{\copy0}% - % we need to save the caption for a next alignment line - \saveoncombinationstack2}% - \ifnum\totcombination>\plusone - \global\advance\totcombination\minusone - \global\advance\horcombination\minusone - \ifnum\horcombination=\zerocount - \doubleexpandafter\docombinationa - \else - \doubleexpandafter\docombinationb - \fi - \else - \expandafter\docombinationc - \fi} - -\def\docombinationa - {\cr - \flushcombinationstack - \noalign - {\forgetall % \setupwhitespace[\v!none]% no - \global\setbox\combinationstack\emptybox - \nointerlineskip - \combinationparameter\c!after - \combinationparameter\c!before - \vss - \nointerlineskip}% - \global\horcombination\maxhorcombination\relax - \docombination} - -\def\docombinationb - {&&&\hskip\combinationparameter\c!distance&\docombination} - -\def\docombinationc - {\cr - \flushcombinationstack - \egroup} - -% formally ok: -% -% \unexpanded\def\stopcombination -% {\egroup -% \egroup} -% -% more robust: -% -% \unexpanded\def\stopcombination -% {{}{}{}{}{}{}{}{}% catches (at most 4) missing entries -% \egroup -% \egroup} -% -% even better: - -\unexpanded\def\stopcombination - {{\scratchtoks{{}{}{}}\dorecurse\totcombination{\appendtoks{}{}{}{}\to\scratchtoks}\expandafter}\the\scratchtoks - \egroup - \dostoptagged - \egroup} - -\newbox\combinationstack - -\def\saveoncombinationstack#1% - {\global\setbox\combinationstack\hbox - {\hbox{\box#1}\unhbox\combinationstack}} - -\def\flushcombinationstack - {\noalign - {\ifdim\ht\combinationstack>\zeropoint - \nointerlineskip % nieuw - \combinationparameter\c!inbetween - \global\horcombination\maxhorcombination - \globallet\doflushcombinationstack\dodoflushcombinationstack - \else - \global\setbox\combinationstack\emptybox - \globallet\doflushcombinationstack\donothing - \fi}% - \doflushcombinationstack\crcr} - -\gdef\dodoflushcombinationstack - {\global\setbox\combinationstack\hbox - {\unhbox\combinationstack - \global\setbox1\lastbox}% - \box1% \ruledhbox{\box1}% - \global\advance\horcombination\minusone\relax - \ifnum\horcombination>\zerocount - \expandafter\dodoflushcombinationstacknext - \else - \global\setbox\combinationstack\emptybox - \fi} - -\def\dodoflushcombinationstacknext - {&&&&\doflushcombinationstack} - -\setupcombinations - [\c!width=\v!fit, - \c!height=\v!fit, - \c!distance=1em, - \c!location=\v!bottom, % can be something {top,left} - \c!before=\blank, - \c!inbetween={\blank[\v!medium]}, - \c!style=, - \c!color=, - \c!after=, - \c!align=\v!middle] - -%D \macros -%D {startfloatcombination} -%D -%D \setupexternalfigures[directory={../sample}] -%D \startbuffer -%D \placefigure -%D [left,none] -%D {} -%D {\startfloatcombination[2*2] -%D \placefigure{alpha}{\externalfigure[cow.pdf][width=1cm]} -%D \placefigure{beta} {\externalfigure[cow.pdf][width=2cm]} -%D \placefigure{gamma}{\externalfigure[cow.pdf][width=3cm]} -%D \placefigure{delta}{\externalfigure[cow.pdf][width=4cm]} -%D \stopfloatcombination} -%D -%D \input tufte -%D \stopbuffer -%D -%D \typebuffer \getbuffer - -\unexpanded\def\startfloatcombination - {\dodoubleempty\dostartfloatcombination} - -\let\startfloatcombination\relax - -\def\dostartfloatcombination[#1][#2]% - {\vbox\bgroup - %\insidecolumnstrue % trick, forces no centering, todo: proper switch/feature - \postcenterfloatmethod\zerocount - \forcelocalfloats - \unexpanded\def\stopfloatcombination{\dostopfloatcombination{#1}}} - -\unexpanded\def\dostopfloatcombination#1% - {\scratchtoks\emptytoks - \dorecurse\noflocalfloats - {\appendetoks{\noexpand\getlocalfloat{\recurselevel}}{}\to\scratchtoks}% brrr - \expanded{\startcombination[#1]\the\scratchtoks}\stopcombination - \resetlocalfloats - \egroup} - \unexpanded\def\placerelativetoeachother#1#2% {\bgroup \dowithnextbox @@ -1957,9 +955,8 @@ [\c!distance=\emwidth, \c!n=\v!fit] -%D This one is for Daniel Pittman, who wanted tight -%D fractions. We show three versions. First the simple -%D one using \type {\low} and \type {high}: +%D This one is for Daniel Pittman, who wanted tight fractions. We show +%D three versions. First the simple one using \type {\low} and \type {high}: %D %D \startbuffer %D \def\vfrac#1#2% @@ -2017,7 +1014,7 @@ \lower\dp0\hbox{\raise\dp2\hbox{\txx#2}}% \fi}} -\ifx\vfrac\undefined \let\vfrac\vulgarfraction \fi +\ifdefined\vfrac \else \let\vfrac\vulgarfraction \fi %D \starttabulate %D \HL @@ -2029,7 +1026,7 @@ %D \NC 3 \NC \vulgarfractionmethod3 \vulgarfraction{1}{2} \NC\NR %D \HL %D \stoptabulate - + %D Under construction: %D %D \starttyping @@ -2041,6 +1038,8 @@ %D \commalistsentence[a,b,c][+,-] %D \stoptyping +% obsolete .. use lua instead + \let\handlecommalistsentence\firstofoneargument \def\commalistsentenceone{and-1} diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv index a5dc60f93..d225f07af 100644 --- a/tex/context/base/enco-ini.mkiv +++ b/tex/context/base/enco-ini.mkiv @@ -339,4 +339,42 @@ \unexpanded\def\textplus {\char"002B } % plus +%D Moved from core-mis: + +\unexpanded\def\celsius #1{#1\mathematics{^\circ}C} +\unexpanded\def\inch {\mathematics{\prime\prime}} % was: \hbox{\rm\char125\relax} +\unexpanded\def\fraction#1#2{\mathematics{#1\over#2}} + +\def\periodswidth {.5em} +\def\periodsdefault{3} % was 5, but now it's like \unknown + +\unexpanded\def\periods + {\dosingleempty\doperiods} + +% \def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 +% {\dontleavehmode +% \begingroup +% \scratchdimen\periodswidth +% \hbox to \iffirstargument#1\else\periodsdefault\fi \scratchdimen +% {\leaders\hbox to \scratchdimen{\hss.\hss}\hss}% +% \endgroup} +% +% better for export: + +\unexpanded\def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 + {\dontleavehmode + \hbox\bgroup + \setbox\scratchbox\hbox to \periodswidth{\hss.\hss}% + \dorecurse{\iffirstargument#1\else\periodsdefault\fi}{\copy\scratchbox}% + \egroup} + +\unexpanded\def\unknown + {\periods\relax} % relax prevents lookahead for [] + +% Example by Wolfgang Schuster on the context list: +% +% \unexpanded\def\fourdots{{\def\periodswidth{.3em}\periods[4]}} +% +% Hello\fourdots\ World\fourdots \par Hello\fourdots\ World. + \protect \endinput diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index bc5c4f12d..db94c62e4 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -8,6 +8,8 @@ if not modules then modules = { } end modules ['grph-inc'] = { -- figures -> managers.figures +-- todo: empty filename or only suffix always false (not found) + -- lowercase types -- mps tex tmp svg -- partly qualified diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv index 58d1e2b62..633130ea9 100644 --- a/tex/context/base/grph-inc.mkiv +++ b/tex/context/base/grph-inc.mkiv @@ -290,6 +290,7 @@ height = "\@@efheight", % can be crap } }% \ctxlua{figures.identify()}% + % also mode: checkpresense only \ifconditional\testexternalfigureonly \ifcase\figurestatus \else \ctxlua{figures.check()}% @@ -325,7 +326,7 @@ \newsystemmode\v!figure -\def\signalexternalfigure % global +\def\signalexternalfigure % global (dup call to status) {\ifcase\figurestatus \global\resetsystemmode\v!figure % todo, also: \v!resource \else @@ -406,9 +407,21 @@ \let\getfiguredimensionsonly\getfiguredimensions -\def\doiffigureelse#1% +% \unexpanded\def\doiffigureelse#1% +% {\getfiguredimensions[#1]% so data is available ! +% \ifdim\figurewidth=\zeropoint % todo: \figurestatus +% \expandafter\secondoftwoarguments +% \else +% \expandafter\firstoftwoarguments +% \fi} + +% \unexpanded\def\doiffigureelse#1% just low level call +% {\getfiguredimensions[#1]% so data is available ! ... grouped so status is local +% \doifmodeelse{*\v!figure}\firstoftwoarguments\secondoftwoarguments} % mode is set global + +\unexpanded\def\doiffigureelse#1% {\getfiguredimensions[#1]% so data is available ! - \ifdim\figurewidth=\zeropoint % todo: \figurestatus + \ifcase\figurestatus \expandafter\secondoftwoarguments \else \expandafter\firstoftwoarguments diff --git a/tex/context/base/grph-trf.mkiv b/tex/context/base/grph-trf.mkiv index b3392a9b7..a33e5606d 100644 --- a/tex/context/base/grph-trf.mkiv +++ b/tex/context/base/grph-trf.mkiv @@ -823,7 +823,7 @@ \settrue \c_grph_rotate_obey_depth \grph_rotate_framed} -\def\dorotatebox#1% {angle} \hbox/\vbox/\vtop % a fast low level one +\unexpanded\def\dorotatebox#1% {angle} \hbox/\vbox/\vtop % a fast low level one {\ifcase#1\relax \expandafter\gobbleoneargument \else @@ -837,7 +837,9 @@ \dowithnextboxcs\grph_rotate_finish_box} \def\grph_rotate_finish_box - {\getvalue{\??rotatelocation\v!broad}% + {\setfalse\c_grph_rotate_not_fit % this is the same as broad but + \setfalse\c_grph_rotate_center % without the following grab as + \setfalse\c_grph_rotate_obey_depth % we call finish directly \grph_rotate_finish_indeed \egroup \egroup} diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index e50a7470c..d9ac110c9 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -11,6 +11,9 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +% todo: setupxxx and setupxxxs (so a plural for the root setup and +% we can consider blocking the root) + %D A generalization of \MKIV-like inheritance. Just something to play %D with (interface might change). The code here evolved in an email %D exchange between me and Wolgang Schuster. diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv index 816a32d4f..205e67009 100644 --- a/tex/context/base/mult-sys.mkiv +++ b/tex/context/base/mult-sys.mkiv @@ -439,9 +439,8 @@ \definesystemvariable {br} % sideBaR \definesystemvariable {bx} % BackendExport \definesystemvariable {cb} % CollectBox -\definesystemvariable {ci} % CItaat +% \definesystemvariable {ci} % CItaat \definesystemvariable {cm} % CheMical -\definesystemvariable {co} % COmbinaties \definesystemvariable {cp} % CliP \definesystemvariable {da} % DAte \definesystemvariable {db} % Labels @@ -478,7 +477,6 @@ \definesystemvariable {it} % stelInTerliniein \definesystemvariable {iv} % stelInvulLijnenin \definesystemvariable {ka} % KAntlijn -\definesystemvariable {kk} % Kapitalen \definesystemvariable {kl} % KoLommen \definesystemvariable {km} % KenMerk \definesystemvariable {kp} % KopPelteken @@ -559,6 +557,7 @@ \definesystemvariable{cs} % CharacterSpacing \definesystemvariable{ts} % TypeScript +\definesystemvariable{kk} % Kapitalen %D Next we define some language independant one letter %D variables and keywords. We can actually make these diff --git a/tex/context/base/pack-com.mkiv b/tex/context/base/pack-com.mkiv new file mode 100644 index 000000000..be06b2e86 --- /dev/null +++ b/tex/context/base/pack-com.mkiv @@ -0,0 +1,350 @@ +%D \module +%D [ file=pack-com, % used to be in core-mis, +%D version=20120111, +%D title=\CONTEXT\ Packing Macros, +%D subtitle=Combinations, +%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 Packaging Macros / Combinations} + +\unprotect + +%D We could of course map combinations onto one of the table +%D mechanisms but as it has served us well for ages we keep +%D this one. The code has been cleaned up a bit and mkiv'd. +%D +%D Okay ... I might luafy this one eventually. + +% \startcombination {alpha} {a} {beta} {b} \stopcombination +% \startcombination[2*1] {alpha} {a} {beta} {b} \stopcombination +% \startcombination[1*2] {alpha} {a} {beta} {b} \stopcombination +% \startcombination[2] {alpha} {a} {beta} {b} \stopcombination + +% todo: \startcombination \startcomb \stopcomb ... + +\ifdefined\dotagcombination \else \let\dotagcombination\relax \fi + +\newsystemmode{combination} + +\appendtoks + \global\resetsystemmode{combination}% +\to \everyinsidefloat + +\newcount\c_pack_combinations_x +\newcount\c_pack_combinations_n +\newcount\c_pack_combinations_max +\newbox \b_pack_combinations_captions +\newbox \b_pack_combinations_content +\newbox \b_pack_combinations_caption +\newbox \b_pack_combinations_temp % global + +\installcorenamespace{combination} + +\installcommandhandler \??combination {combination} \??combination + +\setupcombination + [\c!width=\v!fit, + \c!height=\v!fit, + \c!distance=\emwidth, + \c!location=\v!bottom, % can be something {top,left} + \c!before=\blank, + \c!inbetween={\blank[\v!medium]}, + %\c!style=, + %\c!color=, + %\c!after=, + \c!align=\v!middle] + +\let\setupcombinations\setupcombination % for the moment (we might distinguish) + +\installcorenamespace{combinationlocation} + +\let\m_pack_combinations_rightfiller\hfil +\let\m_pack_combinations_leftfiller \hfil +\let\m_pack_combinations_valigner \firstofoneargument + +\setvalue{\??combinationlocation\v!left }{\let\m_pack_combinations_leftfiller\relax} +\setvalue{\??combinationlocation\v!right }{\let\m_pack_combinations_rightfiller\relax} +\setvalue{\??combinationlocation\v!top }{\let\m_pack_combinations_valigner\depthonlybox} +\setvalue{\??combinationlocation\v!middle}{\let\m_pack_combinations_valigner\halfwaybox} + +\def\pack_combinations_location_step#1% + {\csname\??combinationlocation#1\endcsname} + +\unexpanded\def\startcombination + {\bgroup % so we can grab a group + \dodoubleempty\pack_combinations_start} + +% formally ok: +% +% \unexpanded\def\stopcombination +% {\egroup +% \egroup} +% +% more robust: +% +% \unexpanded\def\stopcombination +% {{}{}{}{}{}{}{}{}% catches (at most 4) missing entries +% \egroup +% \egroup} +% +% even better: +% +% \unexpanded\def\stopcombination +% {\bgroup +% \scratchtoks{{}}% +% \dorecurse\c_pack_combinations_n +% {\scratchtoks\expandafter{\the\scratchtoks{}{}}}% +% \expandafter\egroup\the\scratchtoks +% \egroup +% \dostoptagged +% \egroup} +% +% faster + +\unexpanded\def\stopcombination + {\bgroup\normalexpanded{\egroup{}\ctxcommand{ntimes("{}{}",\number\c_pack_combinations_n)}}% + \dostoptagged + \egroup + \egroup} + +\def\pack_combinations_start[#1][#2]% needs a cleanup, also nx ny (pretty old, this one) + {\global\setsystemmode{combination}% + % +% \doifnothing{#1}\firstargumentfalse % to be sure (when called in macros) +% \doifnothing{#2}\secondargumentfalse % to be sure (when called in macros) +% \ifsecondargument % todo: nx ny +% \edef\currentcombination{#1}% +% \edef\currentcombinationspec{#2*\plusone*}% +% \else % better : \doifcombinationelse ... \??co#1\c!location +% \doifinstringelse{*}{#1} +% {\let\currentcombination\empty +% \edef\currentcombinationspec{#1*\plusone*}} +% {\doifnumberelse{#1} +% {\let\currentcombination\empty +% \edef\currentcombinationspec{#1*\plusone*}} +% {\edef\currentcombination{#1}% +% \edef\currentcombinationspec{\plustwo*\plusone*}}}% +% \fi + % + % todo : move split to here + % + \edef\currentcombination{#1}% + \edef\currentcombinationspec{#2}% + \ifx\currentcombinationspec\empty + \doifinstringelse{*}\currentcombination + {\edef\currentcombinationspec{\currentcombination*\plusone*}% + \let\currentcombination\empty} + {\doifnumberelse\currentcombination + {\edef\currentcombinationspec{\currentcombination*\plusone*}% + \let\currentcombination\empty} + {\edef\currentcombinationspec{\plustwo*\plusone*}}}% + \else + \edef\currentcombinationspec{\currentcombinationspec*\plusone*}% + \fi + % + \forgetall + % + \edef\p_height {\combinationparameter\c!height}% + \edef\p_width {\combinationparameter\c!width}% + \edef\p_location{\combinationparameter\c!location}% + \edef\p_align {\combinationparameter\c!align}% + \edef\p_distance{\combinationparameter\c!distance}% + % + \let\m_pack_combinations_rightfiller\relax + \let\m_pack_combinations_leftfiller \relax + \let\m_pack_combinations_valigner \vbox + \processcommacommand[\p_location]\pack_combinations_location_step + % + \dostarttagged\t!combination\currentcombination + \vbox \ifx\p_height\v!fit\else to \p_height \fi \bgroup + \let\combination\empty % permits \combination{}{} handy for cld + \setuphorizontaldivision[\c!n=\v!fit,\c!distance=\p_distance]% + \normalexpanded{\pack_combinations_start_indeed[\currentcombinationspec]}} + +\unexpanded\def\pack_combinations_start_indeed[#1*#2*#3]% + {\global\c_pack_combinations_x#1\relax + \global\c_pack_combinations_n#2\relax + \dotagcombination + \global\setbox\b_pack_combinations_captions\emptybox + \global\c_pack_combinations_max\c_pack_combinations_x + \multiply\c_pack_combinations_n\c_pack_combinations_x + \tabskip\zeropoint + \halign \ifx\p_width\v!fit\else to \p_width \fi \bgroup + \aligntab + \m_pack_combinations_leftfiller + \alignmark\alignmark + \m_pack_combinations_rightfiller + \aligntab + \tabskip\zeropoint \!!plus 1fill + \alignmark\alignmark + \cr + \pack_combinations_pickup} + +\def\pack_combinations_pickup % we want to add struts but still ignore an empty box + {\dostarttagged\t!combinationpair\empty + \dostarttagged\t!combinationcontent\empty + \dowithnextboxcs\pack_combinations_pickup_content\hbox} + +\def\pack_combinations_pickup_content % we want to add struts but still ignore an empty box + {\dostoptagged + \setbox\b_pack_combinations_content\box\nextbox + \dostarttagged\t!combinationcaption\empty + \dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup + \afterassignment\pack_combinations_caption_first + \let\nexttoken=} + +\def\pack_combinations_pickup_caption + {\dostoptagged + \dostoptagged + \setbox\b_pack_combinations_caption\box\nextbox + \pack_combinations_pickup_package_pair} + +\def\pack_combinations_caption_first + {\futurelet\nexttoken\pack_combinations_caption_second} + +\def\pack_combinations_caption_second + {\ifx\nexttoken\egroup + % the caption is empty + \else + \hsize\wd\b_pack_combinations_content + \ifx\p_align\empty\else\setupalign[\p_align]\fi + \usecombinationstyleandcolor\c!style\c!color + \bgroup + \aftergroup\endstrut + \aftergroup\egroup + \begstrut + \fi} + +\def\pack_combinations_pickup_package_pair % we need to store the caption row + {\vbox + {\forgetall + \m_pack_combinations_valigner{\copy\b_pack_combinations_content}% + % we need to save the caption for a next alignment line + \pack_combinations_save_caption}% + \ifnum\c_pack_combinations_n>\plusone + \global\advance\c_pack_combinations_n\minusone + \global\advance\c_pack_combinations_x\minusone + \ifcase\c_pack_combinations_x + \doubleexpandafter\pack_combinations_pickup_package_pair_a + \else + \doubleexpandafter\pack_combinations_pickup_package_pair_b + \fi + \else + \singleexpandafter\pack_combinations_pickup_package_pair_c + \fi} + +\def\pack_combinations_pickup_package_pair_a + {\cr + \pack_combinations_flush_captions + \noalign + {\forgetall + \global\setbox\b_pack_combinations_captions\emptybox + \nointerlineskip + \combinationparameter\c!after + \combinationparameter\c!before + \vss + \nointerlineskip}% + \global\c_pack_combinations_x\c_pack_combinations_max + \pack_combinations_pickup} + +\def\pack_combinations_pickup_package_pair_b + {\aligntab + \aligntab + \aligntab + \hskip\p_distance + \aligntab + \pack_combinations_pickup} + +\def\pack_combinations_pickup_package_pair_c + {\cr + \pack_combinations_flush_captions + \egroup} + +\def\pack_combinations_save_caption + {\global\setbox\b_pack_combinations_captions\hbox + {\hbox{\box\b_pack_combinations_caption}% + \unhbox\b_pack_combinations_captions}} + +\def\pack_combinations_flush_captions + {\noalign + {\ifdim\ht\b_pack_combinations_captions>\zeropoint + \nointerlineskip % indeed + \combinationparameter\c!inbetween + \global\c_pack_combinations_x\c_pack_combinations_max + \globallet\pack_combinations_flush_captions_indeed\pack_combinations_flush_captions_yes + \else + \global\setbox\b_pack_combinations_captions\emptybox + \globallet\pack_combinations_flush_captions_indeed\pack_combinations_flush_captions_nop + \fi}% + \pack_combinations_flush_captions_indeed + \crcr} + +\def\pack_combinations_flush_captions_yes + {\global\setbox\b_pack_combinations_captions\hbox + {\unhbox\b_pack_combinations_captions + \global\setbox\b_pack_combinations_temp\lastbox}% + \box\b_pack_combinations_temp + \global\advance\c_pack_combinations_x\minusone\relax + \ifnum\c_pack_combinations_x>\zerocount + \expandafter\pack_combinations_flush_captions_yes_followup + \else + \global\setbox\b_pack_combinations_captions\emptybox + \fi} + +\let\pack_combinations_flush_captions_nop\donothing + +\def\pack_combinations_flush_captions_yes_followup + {\aligntab + \aligntab + \aligntab + \aligntab + \pack_combinations_flush_captions_indeed} + +%D \macros +%D {startfloatcombination} +%D +%D \setupexternalfigures[directory={../sample}] +%D \startbuffer +%D \placefigure +%D [left,none] +%D {} +%D {\startfloatcombination[2*2] +%D \placefigure{alpha}{\externalfigure[cow.pdf][width=1cm]} +%D \placefigure{beta} {\externalfigure[cow.pdf][width=2cm]} +%D \placefigure{gamma}{\externalfigure[cow.pdf][width=3cm]} +%D \placefigure{delta}{\externalfigure[cow.pdf][width=4cm]} +%D \stopfloatcombination} +%D +%D \input tufte +%D \stopbuffer +%D +%D \typebuffer \getbuffer + +\unexpanded\def\startfloatcombination + {\dodoubleempty\pack_combinations_start_float} + +\let\stopfloatcombination\relax + +\def\pack_combinations_start_float[#1][#2]% + {\vbox\bgroup + %\insidecolumnstrue % trick, forces no centering, todo: proper switch/feature + \postcenterfloatmethod\zerocount + \forcelocalfloats + \unexpanded\def\stopfloatcombination{\pack_combinations_stop_float{#1}}} + +\def\pack_combinations_stop_float#1% + {\scratchtoks\emptytoks + \dorecurse\noflocalfloats + {\appendetoks{\noexpand\getlocalfloat{\recurselevel}}{}\to\scratchtoks}% brrr + \expanded{\startcombination[#1]\the\scratchtoks}\stopcombination + \resetlocalfloats + \egroup} + + +\protect \endinput diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv index 525017954..d00de2c31 100644 --- a/tex/context/base/page-lay.mkiv +++ b/tex/context/base/page-lay.mkiv @@ -814,20 +814,24 @@ \newconditional\c_page_layouts_location_is_set -\def\page_layouts_location_reset +\def\page_layouts_location_reset % we start in the left top and mirror right pages {\setfalse\c_page_layouts_location_is_set \let\v_page_target_left_fill \relax - \let\v_page_target_right_fill \relax + \let\v_page_target_right_fill \hss % ? \relax \let\v_page_target_top_fill \relax - \let\v_page_target_bottom_fill\relax} + \let\v_page_target_bottom_fill\vss} % \relax} \setvalue{\??layoutlocation\v!right }{\settrue\c_page_layouts_location_is_set - \let\v_page_target_left_fill \hss} + \let\v_page_target_left_fill \hss + \let\v_page_target_right_fill \relax} \setvalue{\??layoutlocation\v!left }{\settrue\c_page_layouts_location_is_set + \let\v_page_target_left_fill \relax \let\v_page_target_right_fill \hss} \setvalue{\??layoutlocation\v!bottom }{\settrue\c_page_layouts_location_is_set - \let\v_page_target_top_fill \vss} + \let\v_page_target_top_fill \vss + \let\v_page_target_bottom_fill\relax} \setvalue{\??layoutlocation\v!top }{\settrue\c_page_layouts_location_is_set + \let\v_page_target_top_fill \relax \let\v_page_target_bottom_fill\vss} \setvalue{\??layoutlocation\v!middle }{\settrue\c_page_layouts_location_is_set \let\v_page_target_left_fill \hss diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv index 01bd565c0..6cc04b203 100644 --- a/tex/context/base/spac-ali.mkiv +++ b/tex/context/base/spac-ali.mkiv @@ -236,6 +236,10 @@ \newconditional\raggedonelinerstate % public \fi +% \appendtoks +% \setfalse\raggedonelinerstate +% \to \everyforgetall + \newconstant\raggedstatus % public \newconstant\c_spac_align_state_horizontal @@ -262,6 +266,7 @@ \spaceskip \zeropoint \xspaceskip \zeropoint \parfillskip\s_zero_plus_one_fil % new + \setfalse\raggedonelinerstate % now here \let\updateraggedskips\relax} % no need for adaption \unexpanded\def\spac_align_set_horizontal_left diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex cf02f71fc..e8412cf30 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex da0b60f3f..af0fbaf85 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index 8968cd993..320bcd414 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -783,12 +783,12 @@ return { { filename = "typo-pag", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "typo-mar", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "buff-ini", @@ -1031,22 +1031,22 @@ return { { filename = "typo-brk", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "typo-cap", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "typo-dig", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "typo-rep", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "typo-txt", @@ -1057,7 +1057,8 @@ return { { filename = "typo-par", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "might get extended", }, { filename = "type-ini", @@ -1267,6 +1268,16 @@ return { status = "unknown", }, { + filename = "pack-com", + marktype = "mkiv", + status = "okay", + }, + { + filename = "typo-del", + marktype = "mkiv", + status = "unknown", + }, + { filename = "grph-trf", marktype = "mkiv", status = "okay", diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv index 0c78994ea..5981b97f0 100644 --- a/tex/context/base/supp-box.mkiv +++ b/tex/context/base/supp-box.mkiv @@ -2454,6 +2454,15 @@ \lower.5\ht\nextbox\box\nextbox \egroup} +\unexpanded\def\depthonlybox + {\vtop\bgroup + \dowithnextboxcs\syst_boxes_depthonlybox_finish\vbox} + +\def\syst_boxes_depthonlybox_finish + {\hsize\wd\nextbox + \kern\zeropoint\box\nextbox + \egroup} + %D New: \def\setdimentoatleast#1#2{\ifdim#1>\zeropoint\else#1=#2\fi} diff --git a/tex/context/base/syst-lua.lua b/tex/context/base/syst-lua.lua index 000b16963..e5c6c8242 100644 --- a/tex/context/base/syst-lua.lua +++ b/tex/context/base/syst-lua.lua @@ -6,10 +6,12 @@ if not modules then modules = { } end modules ['syst-lua'] = { license = "see context related readme files" } -local format, find, match = string.format, string.find, string.match +local format, find, match, rep = string.format, string.find, string.match, string.rep local tonumber = tonumber local S, lpegmatch, lpegtsplitat = lpeg.S, lpeg.match, lpeg.tsplitat +local context = context + commands = commands or { } function commands.writestatus(...) logs.status(...) end -- overloaded later @@ -95,3 +97,7 @@ function commands.firstinlist(str) local first = match(str,"^([^,]+),") context(first or str) end + +function commands.ntimes(str,n) + context(rep(str,n or 1)) +end diff --git a/tex/context/base/typo-brk.lua b/tex/context/base/typo-brk.lua index fe0258bcc..14f0b8b47 100644 --- a/tex/context/base/typo-brk.lua +++ b/tex/context/base/typo-brk.lua @@ -32,10 +32,13 @@ local remove_node = nodes.remove -- ! nodes local link_nodes = nodes.link local texattribute = tex.attribute +local unsetvalue = attributes.unsetvalue local nodepool = nodes.pool local tasks = nodes.tasks +local v_reset = interfaces.variables.reset + local new_penalty = nodepool.penalty local new_glue = nodepool.glue local new_disc = nodepool.disc @@ -54,7 +57,7 @@ typesetters.breakpoints = typesetters.breakpoints or {} local breakpoints = typesetters.breakpoints breakpoints.mapping = breakpoints.mapping or { } -local mapping = breakpoints.mapping +breakpoints.numbers = breakpoints.numbers or { } breakpoints.methods = breakpoints.methods or { } local methods = breakpoints.methods @@ -64,27 +67,12 @@ breakpoints.attribute = a_breakpoints storage.register("typesetters/breakpoints/mapping", breakpoints.mapping, "typesetters.breakpoints.mapping") -function breakpoints.setreplacement(id,char,language,settings) - char = utfbyte(char) - local map = mapping[id] - if not map then - map = { } - mapping[id] = map - end - local cmap = map[char] - if not cmap then - cmap = { } - map[char] = cmap - end - local left, right, middle = settings.left, settings.right, settings.middle - cmap[language or ""] = { - type = tonumber(settings.type) or 1, - nleft = tonumber(settings.nleft) or 1, - nright = tonumber(settings.nright) or 1, - left = left ~= "" and left or nil, - right = right ~= "" and right or nil, - middle = middle ~= "" and middle or nil, - } -- was { type or 1, before or 1, after or 1 } +local mapping = breakpoints.mapping +local numbers = breakpoints.mapping + +for i=1,#mapping do + local m = mapping[i] + numbers[m.name] = m end local function insert_break(head,start,before,after) @@ -167,12 +155,13 @@ local function process(namespace,attribute,head) while start do local id = start.id if id == glyph_code then - local attr = has_attribute(start,attribute) + local attr = has_attribute(start,a_breakpoints) if attr and attr > 0 then - unset_attribute(start,attribute) -- maybe test for subtype > 256 (faster) + unset_attribute(start,a_breakpoints) -- maybe test for subtype > 256 (faster) -- look ahead and back n chars - local map = mapping[attr] - if map then + local data = mapping[attr] + if data then + local map = data.characters local cmap = map[start.char] if cmap then local lang = start.lang @@ -230,15 +219,64 @@ local function process(namespace,attribute,head) return head, done end -function breakpoints.set(n) - if trace_breakpoints then - report_breakpoints("enabling breakpoints handler") +local enabled = false + +function breakpoints.define(name) + local data = numbers[name] + if data then + -- error + else + local number = #mapping + 1 + local data = { + name = name, + number = number, + characters = { }, + } + mapping[number] = data + numbers[name] = data + end +end + +function breakpoints.setreplacement(name,char,language,settings) + char = utfbyte(char) + local data = numbers[name] + if data then + local characters = data.characters + local cmap = characters[char] + if not cmap then + cmap = { } + characters[char] = cmap + end + local left, right, middle = settings.left, settings.right, settings.middle + cmap[language or ""] = { + type = tonumber(settings.type) or 1, + nleft = tonumber(settings.nleft) or 1, + nright = tonumber(settings.nright) or 1, + left = left ~= "" and left or nil, + right = right ~= "" and right or nil, + middle = middle ~= "" and middle or nil, + } -- was { type or 1, before or 1, after or 1 } end - tasks.enableaction("processors","typesetters.breakpoints.handler") - function breakpoints.set(n) - texattribute[a_breakpoints] = n +end + +function breakpoints.set(n) + if n == v_reset then + n = unsetvalue + else + n = mapping[n] + if not n then + n = unsetvalue + else + if not enabled then + if trace_breakpoints then + report_breakpoints("enabling breakpoints handler") + end + tasks.enableaction("processors","typesetters.breakpoints.handler") + end + n = n.number + end end - breakpoints.set(n) + texattribute[a_breakpoints] = n end breakpoints.handler = nodes.installattributehandler { @@ -247,6 +285,12 @@ breakpoints.handler = nodes.installattributehandler { processor = process, } -function breakpoints.enable() - tasks.enableaction("processors","typesetters.breakpoints.handler") -end +-- function breakpoints.enable() +-- tasks.enableaction("processors","typesetters.breakpoints.handler") +-- end + +-- interface + +commands.definebreakpoints = breakpoints.define +commands.definebreakpoint = breakpoints.setreplacement +commands.setbreakpoints = breakpoints.set diff --git a/tex/context/base/typo-brk.mkiv b/tex/context/base/typo-brk.mkiv index cd2db6212..23253240c 100644 --- a/tex/context/base/typo-brk.mkiv +++ b/tex/context/base/typo-brk.mkiv @@ -15,73 +15,65 @@ \unprotect +% hm, we cannot prebuild lists, font dependent +% +% -- type nleft nright language left right middle +% +% -- we might eventually stick to only method 5 + \registerctxluafile{typo-brk}{1.001} \definesystemattribute[breakpoint][public] -% compound stuff (under construction) - -\newbox\breakpointbox - \exhyphenchar\minusone % we use a different order then base tex, so we really need this -\newcount \maxbreakpointsid - \unexpanded\def\definebreakpoints - {\dosingleargument\dodefinebreakpoints} - -\def\dodefinebreakpoints[#1]% - {\ifcsname\??bp:#1\endcsname \else - \global\advance\maxbreakpointsid\plusone - \setxvalue{\??bp:#1}{\number\maxbreakpointsid}% - \fi} - -\def\installbreakpoint - {\dotripleempty\doinstallbreakpoint} - -% hm, we cannot prebuild lists, font dependent -% -% -- type nleft nright language left right middle -% -% -- we might eventually stick to only method 5 - -\def\doinstallbreakpoint[#1][#2][#3]% - {\ifcsname\??bp:#1\endcsname - \begingroup - \getparameters[\??bp][\c!type=1,\c!nleft=3,\c!nright=3,\s!language=,\c!left=,\c!right=,\c!middle=,#3]% - \ctxlua{typesetters.breakpoints.setreplacement(\csname\??bp:#1\endcsname, "#2", "\reallanguagetag\@@bplanguage", { - type = \@@bptype, - nleft = "\@@bpnleft", - nright = "\@@bpnright", - right = "\@@bpright", - left = "\@@bpleft", - middle = "\@@bpmiddle" - } )}% todo: table - \endgroup - \fi} + {\dosingleargument\typo_breakpoints_define} + +\def\typo_breakpoints_define[#1]% + {\ctxcommand{definebreakpoints("#1")}} + +\def\definebreakpoint + {\dotripleempty\typo_breakpoints_define_character} + +\def\typo_breakpoints_define_character[#1][#2][#3]% name char settings + {\begingroup + \getparameters[\??bp][\c!type=1,\c!nleft=3,\c!nright=3,\s!language=,\c!left=,\c!right=,\c!middle=,#3]% + \ctxcommand{definebreakpoint("#1", "#2", "\reallanguagetag\@@bplanguage", { + type = \@@bptype, + nleft = "\@@bpnleft", + nright = "\@@bpnright", + right = "\@@bpright", + left = "\@@bpleft", + middle = "\@@bpmiddle" + } )}% + \endgroup} \unexpanded\def\setbreakpoints[#1]% - {\ctxlua{typesetters.breakpoints.set(\number\csname\??bp:#1\endcsname)}} + {\ctxcommand{setbreakpoints("#1")}} -\letvalue{\??bp:\s!reset}\attributeunsetvalue +\unexpanded\def\resetbreakpoints + {\attribute\breakpointattribute\attributeunsetvalue} \definebreakpoints[compound] -\installbreakpoint [compound] [+] [\c!nleft=3,\c!nright=3,\c!type=1] % middle=+,left=,right= -\installbreakpoint [compound] [-] [\c!nleft=3,\c!nright=3,\c!type=1] % middle=+,left=,right= -\installbreakpoint [compound] [/] [\c!nleft=3,\c!nright=3,\c!type=1] % middle=+,left=,right= -\installbreakpoint [compound] [(] [\c!nleft=3,\c!nright=3,\c!type=2] % type=5,middle=(,left=(-,right= -\installbreakpoint [compound] [)] [\c!nleft=3,\c!nright=3,\c!type=3] % type=5,middle=),left=,right=-) +\definebreakpoint [compound] [+] [\c!nleft=3,\c!nright=3,\c!type=1] % middle=+,left=,right= +\definebreakpoint [compound] [-] [\c!nleft=3,\c!nright=3,\c!type=1] % middle=+,left=,right= +\definebreakpoint [compound] [/] [\c!nleft=3,\c!nright=3,\c!type=1] % middle=+,left=,right= +\definebreakpoint [compound] [(] [\c!nleft=3,\c!nright=3,\c!type=2] % type=5,middle=(,left=(-,right= +\definebreakpoint [compound] [)] [\c!nleft=3,\c!nright=3,\c!type=3] % type=5,middle=),left=,right=-) + +\let\installbreakpoint\definebreakpoint % for a while % \start \hsize 1.5cm \setbreakpoints[compound] -% \installbreakpoint [compound] [-] [nleft=3,nright=3,type=5,left=,right={-},middle={-}] -% \installbreakpoint [compound] [(] [nleft=3,nright=3,type=5,left=,right={(-},middle={(}] -% \installbreakpoint [compound] [)] [nleft=3,nright=3,type=5,left={-)},right=,middle={)}] +% \definebreakpoint [compound] [-] [nleft=3,nright=3,type=5,left=,right={-},middle={-}] +% \definebreakpoint [compound] [(] [nleft=3,nright=3,type=5,left=,right={(-},middle={(}] +% \definebreakpoint [compound] [)] [nleft=3,nright=3,type=5,left={-)},right=,middle={)}] % composed-word\par composed(word)\par % \stop % \mainlanguage[czech] -% \installbreakpoint [compound] [\number`-] [language=cs,nleft=3,nright=3,type=4] +% \definebreakpoint [compound] [\number`-] [language=cs,nleft=3,nright=3,type=4] % \setbreakpoints[compound] % \start \hsize 1mm test-test \par \stop diff --git a/tex/context/base/typo-cap.lua b/tex/context/base/typo-cap.lua index 2e20a95e7..3d70ffbfd 100644 --- a/tex/context/base/typo-cap.lua +++ b/tex/context/base/typo-cap.lua @@ -4,7 +4,7 @@ if not modules then modules = { } end modules ['typo-cap'] = { author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" -} + } local next, type = next, type local format, insert = string.format, table.insert @@ -23,6 +23,7 @@ local traverse_id = node.traverse_id local copy_node = node.copy local texattribute = tex.attribute +local unsetvalue = attributes.unsetvalue local nodecodes = nodes.nodecodes local skipcodes = nodes.skipcodes @@ -40,6 +41,8 @@ local fonthashes = fonts.hashes local fontdata = fonthashes.identifiers local fontchar = fonthashes.characters +local v_reset = interfaces.variables.reset + local chardata = characters.data typesetters = typesetters or { } @@ -257,19 +260,29 @@ end local m, enabled = 0, false -- a trick to make neighbouring ranges work function cases.set(n) - if not enabled then - tasks.enableaction("processors","typesetters.cases.handler") - if trace_casing then - report_casing("enabling case handler") - end - enabled = true - end - if m == 100 then - m = 1 + if n == v_reset then + n = unsetvalue else - m = m + 1 + n = tonumber(n) + if n then + if not enabled then + tasks.enableaction("processors","typesetters.cases.handler") + if trace_casing then + report_casing("enabling case handler") + end + enabled = true + end + if m == 100 then + m = 1 + else + m = m + 1 + end + n = m * 100 + n + else + n = unsetvalue + end end - texattribute[a_cases] = m * 100 + n + texattribute[a_cases] = n end cases.handler = nodes.installattributehandler { @@ -277,3 +290,7 @@ cases.handler = nodes.installattributehandler { namespace = cases, processor = process, } + +-- interface + +commands.setcharactercasing = cases.set diff --git a/tex/context/base/typo-cap.mkiv b/tex/context/base/typo-cap.mkiv index 2ed50ce20..713beaa31 100644 --- a/tex/context/base/typo-cap.mkiv +++ b/tex/context/base/typo-cap.mkiv @@ -49,22 +49,22 @@ % test \word{test TEST \TeX} test % test \Word{test TEST \TeX} test -\unexpanded\def\setcharactercasing[#1]% - {\ctxlua{typesetters.cases.set(\number#1)}} +\unexpanded\def\setcharactercasing[#1]% mayb eat some point we will introduce names alongside numbers + {\ctxcommand{setcharactercasing("#1")}} % todo: names casings -\unexpanded\def\WORD {\groupedcommand{\setcharactercasing[\plusone ]}{}} -\unexpanded\def\word {\groupedcommand{\setcharactercasing[\plustwo ]}{}} -\unexpanded\def\Word {\groupedcommand{\setcharactercasing[\plusthree]}{}} -\unexpanded\def\Words{\groupedcommand{\setcharactercasing[\plusfour ]}{}} +\unexpanded\def\WORD {\groupedcommand{\setcharactercasing[1]}{}} +\unexpanded\def\word {\groupedcommand{\setcharactercasing[2]}{}} +\unexpanded\def\Word {\groupedcommand{\setcharactercasing[3]}{}} +\unexpanded\def\Words{\groupedcommand{\setcharactercasing[4]}{}} -% this will become: +% This might become: % -% \unexpanded\def\WORD {\bgroup\def\g_word{\setcharactercasing[\plusone ]}\afterassignment\g_word\let\nexttoken} -% \unexpanded\def\word {\bgroup\def\g_word{\setcharactercasing[\plustwo ]}\afterassignment\g_word\let\nexttoken} -% \unexpanded\def\Word {\bgroup\def\g_word{\setcharactercasing[\plusthree]}\afterassignment\g_word\let\nexttoken} -% \unexpanded\def\Words{\bgroup\def\g_word{\setcharactercasing[\plusfour ]}\afterassignment\g_word\let\nexttoken} +% \unexpanded\def\WORD {\bgroup\def\g_word{\setcharactercasing[1]}\afterassignment\g_word\let\nexttoken} +% \unexpanded\def\word {\bgroup\def\g_word{\setcharactercasing[2]}\afterassignment\g_word\let\nexttoken} +% \unexpanded\def\Word {\bgroup\def\g_word{\setcharactercasing[3]}\afterassignment\g_word\let\nexttoken} +% \unexpanded\def\Words{\bgroup\def\g_word{\setcharactercasing[4]}\afterassignment\g_word\let\nexttoken} % % so no longer {\Word test} and { } mandate (also later \groupedcommands will go) @@ -127,33 +127,33 @@ \let\disablepseudocaps\relax % maybe used elsewhere -\newconditional\pseudocapsenabled +\newconditional\c_typo_capitals_pseudo -\def\usepseudocaps{\settrue \pseudocapsenabled} -\def\userealcaps {\setfalse\pseudocapsenabled} +\unexpanded\def\usepseudocaps{\settrue \c_typo_capitals_pseudo} +\unexpanded\def\userealcaps {\setfalse\c_typo_capitals_pseudo} \usepseudocaps % we use char0 as placeholder for the larger font -\unexpanded\def\pseudosmallcapped{\groupedcommand{\setcharactercasing[\plusone ]\signalcharacter\tx}{}} % all upper -\unexpanded\def\pseudoSmallcapped{\groupedcommand{\setcharactercasing[\plusfive]\signalcharacter\tx}{}} % one upper + font -\unexpanded\def\pseudoSmallCapped{\groupedcommand{\setcharactercasing[\plussix ]\signalcharacter\tx}{}} % some upper + font +\unexpanded\def\pseudosmallcapped{\groupedcommand{\setcharactercasing[1]\signalcharacter\tx}{}} % all upper +\unexpanded\def\pseudoSmallcapped{\groupedcommand{\setcharactercasing[5]\signalcharacter\tx}{}} % one upper + font +\unexpanded\def\pseudoSmallCapped{\groupedcommand{\setcharactercasing[6]\signalcharacter\tx}{}} % some upper + font -\unexpanded\def\realsmallcapped {\groupedcommand{\sc\setcharactercasing[\plusone ]}{}} % all lower -\unexpanded\def\realSmallcapped {\groupedcommand{\sc\setcharactercasing[\plusthree]}{}} % one upper + font -\unexpanded\def\realSmallCapped {\groupedcommand{\sc\setcharactercasing[\plusfour ]}{}} % some upper +\unexpanded\def\realsmallcapped {\groupedcommand{\sc\setcharactercasing[1]}{}} % all lower +\unexpanded\def\realSmallcapped {\groupedcommand{\sc\setcharactercasing[3]}{}} % one upper + font +\unexpanded\def\realSmallCapped {\groupedcommand{\sc\setcharactercasing[4]}{}} % some upper -\unexpanded\def\dohandlesmallcaps - {\ifconditional\pseudocapsenabled +\unexpanded\def\typo_capitals_smallcaps + {\ifconditional\c_typo_capitals_pseudo \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} -\unexpanded\def\smallcapped{\dohandlesmallcaps\pseudosmallcapped\realsmallcapped} -\unexpanded\def\Smallcapped{\dohandlesmallcaps\pseudoSmallcapped\realSmallcapped} -\unexpanded\def\SmallCapped{\dohandlesmallcaps\pseudoSmallCapped\realSmallCapped} +\unexpanded\def\smallcapped{\typo_capitals_smallcaps\pseudosmallcapped\realsmallcapped} +\unexpanded\def\Smallcapped{\typo_capitals_smallcaps\pseudoSmallcapped\realSmallcapped} +\unexpanded\def\SmallCapped{\typo_capitals_smallcaps\pseudoSmallCapped\realSmallCapped} \unexpanded\def\autocap{\ifmmode\expandafter\normalcap\else\expandafter\smallcapped\fi} @@ -171,7 +171,7 @@ %D As suggested by WS: -\unexpanded\def\notsmallcapped{\groupedcommand{\setcharactercasing[\plustwo]\signalcharacter}{}} +\unexpanded\def\notsmallcapped{\groupedcommand{\setcharactercasing[2]\signalcharacter}{}} %D \macros %D {setupcapitals} @@ -183,16 +183,18 @@ \let\normalsmallcapped\smallcapped +\definesystemvariable{kk} + \unexpanded\def\setupcapitals - {\dosingleempty\dosetupcapitals} + {\dosingleempty\typo_capitals_setup} -\def\dosetupcapitals[#1]% todo: don't use grouping just a switch +\def\typo_capitals_setup[#1]% todo: don't use grouping just a switch {\getparameters[\??kk][#1]% \doifelse\@@kktitle\v!yes - {\definealternativestyle[\v!capital][\normalsmallcapped][\normalsmallcapped]% - \definealternativestyle[\v!smallcaps][\sc][\sc]} - {\definealternativestyle[\v!capital][\normalsmallcapped][\normalWORD]% - \definealternativestyle[\v!smallcaps][\sc][\normalWORD]}% + {\definealternativestyle[\v!capital ][\normalsmallcapped][\normalsmallcapped]% + \definealternativestyle[\v!smallcaps][\sc ][\sc ]} + {\definealternativestyle[\v!capital ][\normalsmallcapped][\normalWORD ]% + \definealternativestyle[\v!smallcaps][\sc ][\normalWORD ]}% \doifelse\@@kksc\v!yes\userealcaps\usepseudocaps} \let\uppercased\normalWORD @@ -200,7 +202,7 @@ \setupcapitals [\c!title=\v!yes, - sc=\v!no] % no \c!sc any longer + \s!sc=\v!no] % no \c!sc any longer % \definestartstop is not yet in available at core-spa time % @@ -208,7 +210,7 @@ % % \definestartstop[randomized][\c!before=\dosetattribute{case}{8},\c!after=] -\def\randomizetext{\groupedcommand{\attribute\caseattribute\pluseight}{}} +\unexpanded\def\randomizetext{\groupedcommand{\attribute\caseattribute\pluseight}{}} \definestartstop[randomized][\c!before=\dosetattribute{case}{8},\c!after=] diff --git a/tex/context/base/typo-del.mkiv b/tex/context/base/typo-del.mkiv new file mode 100644 index 000000000..b2213db65 --- /dev/null +++ b/tex/context/base/typo-del.mkiv @@ -0,0 +1,607 @@ +%D \module +%D [ file=typo-del, % moved from core-mis, +%D version=20110112, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Delimited Content, +%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 Typesetting Macros / Delimited Content} + +\unprotect + +% THIS IS OBSOLETE: + +\unexpanded\def\setuphyphenmark + {\dodoubleargument\getparameters[\??kp]} + +\unexpanded\def\setuphyphenmark[#1]% sign=normal|wide + {\dodoubleargument\getparameters[\??kp][#1]% + \doifelse\@@kpsign {\v!normal}% was inset? + {\let\textmodehyphen\normalhyphen \let\textmodehyphendiscretionary\normalhyphendiscretionary} + {\let\textmodehyphen\composedhyphen\let\textmodehyphendiscretionary\composedhyphendiscretionary}} + +\setuphyphenmark[\c!sign=\v!wide] + +\definesymbol[\c!lefthyphen] [\languageparameter\c!lefthyphen] +\definesymbol[\c!righthyphen] [\languageparameter\c!righthyphen] +\definesymbol[\c!hyphen] [\languageparameter\c!hyphen] + +\def\normalhyphen + {\hbox{\directsymbol\empty\c!hyphen}} + +\def\composedhyphen + {\hbox{\directsymbol\empty\c!compoundhyphen}} + +\def\normalhyphendiscretionary + {\discretionary + {\hbox{\directsymbol\empty\c!righthyphen}} + {\hbox{\directsymbol\empty\c!lefthyphen}} + {\hbox{\directsymbol\empty\c!hyphen}}} + +\def\composedhyphendiscretionary + {\discretionary + {\hbox{\directsymbol\empty\c!rightcompoundhyphen}} + {\hbox{\directsymbol\empty\c!leftcompoundhyphen}} + {\hbox{\directsymbol\empty\c!compoundhyphen}}} + +\let\textmodehyphen \composedhyphen +\let\textmodehyphendiscretionary\composedhyphendiscretionary + +\definesymbol[\c!leftcompoundhyphen] [\languageparameter\c!leftcompoundhyphen] +\definesymbol[\c!rightcompoundhyphen] [\languageparameter\c!rightcompoundhyphen] +\definesymbol[\c!compoundhyphen] [\languageparameter\c!compoundhyphen] + +% TILL HERE + +\setnewconstant\boundarycharactermode\plusone + +\unexpanded\def\midboundarycharacter#1#2% + {\ifcase\boundarycharactermode + \or + %\nobreak + \hskip\hspaceamount\currentlanguage{#2}% + \languageparameter#1% + %\nobreak + \hskip\hspaceamount\currentlanguage{#2}% + \or + \languageparameter#1% + \fi + \boundarycharactermode\plusone} + +\unexpanded\def\leftboundarycharacter#1#2% + {\ifcase\boundarycharactermode + \or + \languageparameter#1% + \nobreak + \hskip\hspaceamount\currentlanguage{#2}% + \or + \languageparameter#1% + \fi + \boundarycharactermode\plusone} + +\unexpanded\def\rightboundarycharacter#1#2% + {\ifcase\boundarycharactermode + \or + \prewordbreak %\nobreak + \hskip\hspaceamount\currentlanguage{#2}% + \languageparameter#1% + \or + \languageparameter#1% + \fi + \boundarycharactermode\plusone} + +\definehspace [sentence] [\zeropoint] +\definehspace [intersentence] [.250\emwidth] + +\definesymbol + [\c!midsentence] + [\midboundarycharacter\c!midsentence{sentence}] + +\definesymbol + [\c!leftsentence] + [\leftboundarycharacter\c!leftsentence{sentence}] + +\definesymbol + [\c!rightsentence] + [\rightboundarycharacter\c!rightsentence{sentence}] + +\definesymbol + [\c!leftsubsentence] + [\leftboundarycharacter\c!leftsubsentence{sentence}] + +\definesymbol + [\c!rightsubsentence] + [\rightboundarycharacter\c!rightsubsentence{sentence}] + +\newsignal \d_typo_subsentence_signal +\newcount \c_typo_subsentence_nesting + +\let\beforesubsentence\donothing +\let\aftersubsentence \donothing + +% todo: make this language option +% +% \def\beforesubsentence{\removeunwantedspaces} +% \def\aftersubsentence {\ignorespaces} + +\unexpanded\def\midsentence + {\symbol[\c!midsentence]} + +\unexpanded\def\beginofsubsentence + {\beforesubsentence + \ifdim\lastkern=\d_typo_subsentence_signal + \unskip + \kern\hspaceamount\currentlanguage{intersentence}% + \fi + \global\advance\c_typo_subsentence_nesting\plusone + \ifnum\c_typo_subsentence_nesting=\plusone + \dontleavehmode % was \leaveoutervmode + \fi + \dostarttagged\t!subsentence\empty + \symbol[\ifodd\c_typo_subsentence_nesting\c!leftsentence\else\c!leftsubsentence\fi]% + }% \ignorespaces} + +\unexpanded\def\endofsubsentence % relax prevents space gobbling + {\symbol[\ifodd\c_typo_subsentence_nesting\c!rightsentence\else\c!rightsubsentence\fi]% + \dostoptagged + \global\advance\c_typo_subsentence_nesting\minusone + \unskip + \kern\d_typo_subsentence_signal\relax + \aftersubsentence} + +\unexpanded\def\beginofsubsentencespacing % relax prevents space gobbling + {\kern\d_typo_subsentence_signal\relax}% \ignorespaces} + +\unexpanded\def\endofsubsentencespacing + {\ifdim\lastkern=\d_typo_subsentence_signal + \unskip + \hskip\hspaceamount\currentlanguage{intersentence}% + % no good, actually language dependent: +% \ignorespaces + \else + \unskip + \fi} + +%D \startbuffer +%D test |<|test |<|test|>| test|>| test \par +%D test|<|test|<|test|>|test|>|test \par +%D test |<||<|test|>||>| test \par +%D test \directdiscretionary{<}test\directdiscretionary{>} test \par +%D \stopbuffer +%D +%D \typebuffer +%D \getbuffer + +\unexpanded\def\startsubsentence{\beginofsubsentence \prewordbreak\beginofsubsentencespacing} +\unexpanded\def\stopsubsentence {\endofsubsentencespacing\prewordbreak\endofsubsentence} +\unexpanded\def\subsentence {\groupedcommand\startsubsentence\stopsubsentence} + +\definehspace [quotation] [\zeropoint] +\definehspace [interquotation] [.125em] + +%definehspace [quote] [\zeropoint] +%definehspace [speech] [\zeropoint] + +\definehspace [quote] [\hspaceamount\currentlanguage{quotation}] +\definehspace [speech] [\hspaceamount\currentlanguage{quotation}] + +\definesymbol + [\c!leftquotation] + [\leftboundarycharacter\c!leftquotation{quotation}] + +\definesymbol + [\c!rightquotation] + [\rightboundarycharacter\c!rightquotation{quotation}] + +\definesymbol + [\c!leftquote] + [\leftboundarycharacter\c!leftquote{quote}] + +\definesymbol + [\c!rightquote] + [\rightboundarycharacter\c!rightquote{quote}] + +\definesymbol + [\c!leftspeech] + [\leftboundarycharacter\c!leftspeech{speech}] + +\definesymbol + [\c!rightspeech] + [\rightboundarycharacter\c!rightspeech{speech}] + +\definesymbol + [\c!middlespeech] + [\leftboundarycharacter\c!middlespeech{speech}] + +\appendtoks\def\quotation#1{"#1"}\to\simplifiedcommands +\appendtoks\def\quote #1{'#1'}\to\simplifiedcommands + +%D The next features was so desperately needed by Giuseppe +%D Bilotta that he made a module for it. Since this is a +%D typical example of core functionality, I decided to extend +%D the low level quotation macros in such a way that a speech +%D feature could be build on top of it. The speech opening and +%D closing symbols are defined per language. Italian is an +%D example of a language that has them set. + +\newsignal\d_typo_delimited_signal + +\let\currentdelimitedtext\s!unknown + +\let\delimitedtextlevel\!!zerocount + +\def\c_typo_delimited_nesting{\csname\??delimitedtextlevel\currentparentdelimitedtext\endcsname} + +\def\typo_delimited_push#1% + {\globalpushmacro\currentdelimitedtext + \def\currentdelimitedtext{#1}% + \let\currentparentdelimitedtext\currentdelimitedtext + \global\advance\c_typo_delimited_nesting\plusone + \edef\delimitedtextlevel{\number\c_typo_delimited_nesting}% + \normalexpanded{\chaintocurrentdelimitedtext{\currentparentdelimitedtext:\delimitedtextlevel}}% + \edef\currentdelimitedtext{\currentparentdelimitedtext:\delimitedtextlevel}} + +\def\typo_delimited_pop + {\global\advance\c_typo_delimited_nesting\minusone + \globalpopmacro\currentdelimitedtext} + +\installcorenamespace{delimitedtext} +\installcorenamespace{delimitedtextlevel} + +\installcommandhandler \??delimitedtext {delimitedtext} \??delimitedtext + +\appendtoks + \expandafter\newcount\csname\??delimitedtextlevel\currentdelimitedtext\endcsname + \setuevalue{\currentdelimitedtext }{\delimitedtext[\currentdelimitedtext]}% + \setuevalue{\e!start\currentdelimitedtext}{\startdelimitedtext[\currentdelimitedtext]}% + \setuevalue{\e!stop \currentdelimitedtext}{\stopdelimitedtext}% +\to \everydefinedelimitedtext + +\setupdelimitedtext + [\c!location=\v!margin, % \v!text \v!paragraph + \c!spacebefore=, + \c!spaceafter=\delimitedtextparameter\c!spacebefore, + \c!style=\v!normal, + \c!color=, + \c!leftmargin=\zeropoint, + \c!rightmargin=\delimitedtextparameter\c!leftmargin, + \c!indentnext=\v!yes, + \c!before=, + \c!after=, + \c!left=, + \c!right=, + %\c!level=0, + \c!method=, + \c!repeat=\v!no] + +\def\typo_delimited_repeat_ideed + {\relax\ifcase\delimitedtextlevel\else + \typo_delimited_handle_middle\c!middle + \fi} + +\let\typo_delimited_repeat\relax + +\unexpanded\def\startdelimitedtext[#1]% + {\begingroup + \typo_delimited_push{#1}% + \dostarttagged\t!delimitedblock\currentdelimitedtext + \edef\p_method{\delimitedtextparameter\c!method}% + \ifx\p_method\s!font + \expandafter\typo_delimited_start_font + \else + \expandafter\typo_delimited_start_other + \fi} + +\let\typo_delimited_stop\relax % hooks into \everypar + +\def\typo_delimited_start_font + {\let\typo_delimited_stop\typo_delimitedtexts_finish_font + \delimitedtextparameter\c!left + \ignorespaces} + +\def\typo_delimited_start_other + {\edef\p_repeat{\delimitedtextparameter\c!repeat}% + \ifx\p_repeat\v!yes + \let\typo_delimited_repeat\typo_delimited_repeat_ideed + \else + \let\typo_delimited_repeat\relax + \fi + \edef\p_location{\delimitedtextparameter\c!location}% + \ifx\p_location\v!paragraph + \singleexpandafter\typo_delimited_start_par + \else\ifx\p_location\v!margin + \doubleexpandafter\typo_delimited_start_par + \else + \doubleexpandafter\typo_delimited_start_txt + \fi\fi} + +\def\typo_delimitedtexts_finish_font + {\removeunwantedspaces\delimitedtextparameter\c!right} + +\def\typo_delimited_start_par + {\dosingleempty\typo_delimited_start_par_indeed} + +\def\typo_delimited_start_par_indeed[#1]% + {\let\typo_delimited_stop\typo_delimited_stop_par + \doifsomething{\delimitedtextparameter\c!spacebefore} + {\blank[\delimitedtextparameter\c!spacebefore]}% + \delimitedtextparameter\c!before + \edef\m_typo_delimited_narrower{#1}% + \ifx\m_typo_delimited_narrower\empty + \endgraf + \doadaptleftskip {\delimitedtextparameter\c!leftmargin}% + \doadaptrightskip{\delimitedtextparameter\c!rightmargin}% + \let\typo_delimited_stop_par_indeed\endgraf + \else % backward compatible direct directive + \startnarrower[#1]% + \let\typo_delimited_stop_par_indeed\stopnarrower + \fi + % so far + \pushmacro\checkindentation + \doifsomething{\delimitedtextparameter\c!indenting} % WS + {\setupindenting[\delimitedtextparameter\c!indenting]}% + \begingroup + \usedelimitedtextstyleandcolor\c!style\c!color + \leftdelimitedtextmark + \ignorespaces} + +\def\typo_delimited_stop_par + {\removeunwantedspaces + \removelastskip + \rightdelimitedtextmark + \endgroup + \popmacro\checkindentation + \typo_delimited_stop_par_indeed + \delimitedtextparameter\c!after + \doifsomething{\delimitedtextparameter\c!spaceafter} + {\blank[\delimitedtextparameter\c!spaceafter]}% + \useindentnextparameter\delimitedtextparameter + \dorechecknextindentation}% AM: This was missing! + +\def\typo_delimited_start_txt + {\let\typo_delimited_stop\typo_delimited_stop_txt + \begingroup + \usedelimitedtextstyleandcolor\c!style\c!color + \typo_delimited_handle_left\c!left + \ignorespaces} + +\def\typo_delimited_stop_txt + {\removeunwantedspaces + \typo_delimited_handle_right\c!right + \endgroup} + +\unexpanded\def\stopdelimitedtext + {\typo_delimited_stop + \dostoptagged + \typo_delimited_pop + \endgroup} + +\unexpanded\def\delimitedtext[#1]% + {\dontleavehmode % following ones can be omited + \typo_delimited_push{#1}% + \edef\p_method{\delimitedtextparameter\c!method}% + \ifx\p_method\s!font + \expandafter\typo_delimited_fontdriven + \else + \expandafter\typo_delimited_other + \fi} + +\def\typo_delimited_other + {\edef\p_location{\delimitedtextparameter\c!location}% + \ifx\p_location\v!paragraph + \singleexpandafter\typo_delimited_par + \else\ifx\p_location\v!margin + \doubleexpandafter\typo_delimited_par + \else + \doubleexpandafter\typo_delimited_txt + \fi\fi} + +% shortcuts + +\unexpanded\def\startdelimited{\startdelimitedtext} +\unexpanded\def\stopdelimited {\stopdelimitedtext} % no let, dynamically assigned + \def\delimited {\delimitedtext} + +\unexpanded\def\leftdelimitedtextmark + {\doifsomething{\delimitedtextparameter\c!left} + {\setbox\scratchbox\hbox{\delimitedtextparameter\c!left}% + \dontleavehmode + \doif{\delimitedtextparameter\c!location}\v!margin{\hskip-\wd\scratchbox}% + \box\scratchbox}} + +\unexpanded\def\rightdelimitedtextmark + {\doifsomething{\delimitedtextparameter\c!right} + {\hsmash{\delimitedtextparameter\c!right}}} + +% \starttext +% \hyphenatedword{groepsvrijstellingsverordeningen}\par +% \hyphenatedword{\quote{groepsvrijstellingsverordeningen}}\par +% \dorecurse{100}{\hskip300pt\hskip\recurselevel pt test \quote{xxx xxxx}.\par} +% \page \setuppapersize[A5][A4] +% \quotation {overly beautiful pusillanimous sesquipedalian +% longwinded} test test test test test test test test test test test +% test test test test test test test test test test test test test +% test test test test test test test test test test test test test +% test test test test test test test test test test test test test +% test test test +% \stoptext + +\def\typo_delimited_handle_middle#1% + {\begingroup + \setbox\scratchbox\hbox{\delimitedtextparameter#1}% + \ifdim\wd\scratchbox>\zeropoint + \ifdim\lastkern=\d_typo_delimited_signal + \unkern + \hskip\hspaceamount\currentlanguage{interquotation}% + \fi + \ifhmode % else funny pagebeaks + \penalty\plustenthousand + \hskip\zeropoint % == \prewordbreak + \fi + \strut % new, needed below + \delimitedtextparameter#1% unhbox\scratchbox + % \penalty\plustenthousand % else overfull boxes, but that's better than dangling periods + \kern\d_typo_delimited_signal % +- \prewordbreak + \fi + \endgroup} + +\def\typo_delimited_handle_left#1% + {\begingroup + \setbox\scratchbox\hbox{\delimitedtextparameter#1}% + \ifdim\wd\scratchbox>\zeropoint + \ifdim\lastkern=\d_typo_delimited_signal + \unkern + \hskip\hspaceamount\currentlanguage{interquotation}% + \else\ifdim\lastskip=\d_typo_delimited_signal + \unskip + \hskip\hspaceamount\currentlanguage{interquotation}% + \fi\fi + \strut % new, needed below + \ifhmode % else funny pagebeaks + \penalty\plustenthousand + \hskip\zeropoint % == \prewordbreak + \fi + \strut % new, needed below + \delimitedtextparameter#1% unhbox\scratchbox + \hskip\d_typo_delimited_signal % +- \prewordbreak + \fi + \endgroup} + +\def\typo_delimited_handle_right#1% + {\begingroup + \setbox\scratchbox\hbox{\delimitedtextparameter#1}% + \ifdim\wd\scratchbox>\zeropoint + \ifdim\lastkern=\d_typo_delimited_signal + \unkern + \penalty\plustenthousand + \hskip\hspaceamount\currentlanguage{interquotation}% + \else\ifdim\lastskip=\d_typo_delimited_signal + \unskip + \penalty\plustenthousand + \hskip\hspaceamount\currentlanguage{interquotation}% + \fi\fi + \ifhmode % else funny pagebeaks + \penalty\plustenthousand + \hskip\zeropoint % == \prewordbreak + \fi + \strut % new, needed below + \delimitedtextparameter#1% unhbox\scratchbox + \kern\d_typo_delimited_signal % +- \prewordbreak + \fi + \endgroup} + +\unexpanded\def\typo_delimited_par + {\groupedcommand + {\dostarttagged\t!delimited\currentdelimitedtext % block? + \typo_delimited_handle_left\c!left} + {\typo_delimited_handle_right\c!right + \removelastskip + \dostoptagged + \typo_delimited_pop}} + +\unexpanded\def\typo_delimited_txt + {\doifelse{\delimitedtextparameter\c!style}\v!normal + \typo_delimited_quoted + \typo_delimited_attributed} + +\def\typo_delimited_quoted_b + {\dostarttagged\t!delimited\currentdelimitedtext + \typo_delimited_handle_left\c!left} + +\def\typo_delimited_quoted_e + {\typo_delimited_handle_right\c!right + \removelastskip + \dostoptagged + \typo_delimited_pop} + +\def\typo_delimited_attributed_b + {\dostarttagged\t!delimited\currentdelimitedtext + \usedelimitedtextstyleandcolor\c!style\c!color} + +\def\typo_delimited_attributed_e + {\dostoptagged + \typo_delimited_pop} + +\def\typo_delimited_fontdriven_b + {\dostarttagged\t!delimited\currentdelimitedtext + \languageparameter{\c!left\currentdelimitedtext}} + +\def\typo_delimited_fontdriven_e + {\languageparameter{\c!right\currentdelimitedtext}% + \dostoptagged + \typo_delimited_pop} + +% We now assume proper argument usage (so no longer grouped +% command). + +% \def\typo_delimited_quoted {\groupedcommand \typo_delimited_quoted_b \typo_delimited_quoted_e } +% \def\typo_delimited_attributed{\groupedcommand \typo_delimited_attributed_b\typo_delimited_attributed_e} +% \def\typo_delimited_fontdriven{\simplegroupedcommand\typo_delimited_fontdriven_b\typo_delimited_fontdriven_e} + +\def\typo_delimited_quoted {\bgroup\typo_delimited_quoted_b \aftergroup\typo_delimited_quoted_e \let\next=} +\def\typo_delimited_attributed{\bgroup\typo_delimited_attributed_b\aftergroup\typo_delimited_attributed_e\let\next=} +\def\typo_delimited_fontdriven{\bgroup\typo_delimited_fontdriven_b\aftergroup\typo_delimited_fontdriven_e\let\next=} + +% testcase for nesting: +% +% \quotation{... \quotation{...} ...} +% \startquotation ... \startquotation... \quotation{...} \stopquotation\space ...\stopquotation +% \setupdelimitedtext[quotation][1][left=(,right=)] +% \setupdelimitedtext[quotation][2][left={[},right={]}] +% \setupdelimitedtext[quotation][3][left=\{,right=\}] +% \quotation{... \quotation{...} ...} +% \startquotation ... \startquotation... \quotation{...} \stopquotation\space ...\stopquotation + +\definedelimitedtext + [\v!quotation] + [\c!left={\symbol[\c!leftquotation]}, + \c!right={\symbol[\c!rightquotation]}, + \c!leftmargin=\v!standard] + +\definedelimitedtext + [\v!quote][\v!quotation] + +\setupdelimitedtext + [\v!quote] + [\c!location=\v!text, + \c!left={\symbol[\c!leftquote]}, + \c!right={\symbol[\c!rightquote]}] + +\definedelimitedtext + [\v!blockquote][\v!quotation] + +\setupdelimitedtext + [\v!blockquote] + [\c!left=, + \c!right=] + +\definedelimitedtext + [\v!speech][\v!quotation] + +\setupdelimitedtext + [\v!speech] + [\c!repeat=\v!yes, + \c!left={\symbol[\c!leftspeech]}, + \c!middle={\symbol[\c!middlespeech]}, + \c!right={\symbol[\c!rightspeech]}] + +% how do we call an tight quote +% +% \definedelimitedtext +% [\v!quotation][\v!quotation] +% +% \setupdelimitedtext +% [\v!quotation] +% [\c!indentnext=\v!no, +% \c!spacebefore=\v!nowhite] + +\unexpanded\def\setupquotation{\setupdelimitedtext[\v!quotation]} +\unexpanded\def\setupquote {\setupdelimitedtext[\v!quote]} + +\protect \endinput diff --git a/tex/context/base/typo-dig.lua b/tex/context/base/typo-dig.lua index 1e4a02fc6..f11b3b0e3 100644 --- a/tex/context/base/typo-dig.lua +++ b/tex/context/base/typo-dig.lua @@ -28,6 +28,7 @@ local insert_before = node.insert_before local insert_after = node.insert_after local texattribute = tex.attribute +local unsetvalue = attributes.unsetvalue local nodecodes = nodes.nodecodes local glyph_code = nodecodes.glyph @@ -42,6 +43,8 @@ local fontdata = fonthashes.identifiers local chardata = fonthashes.characters local quaddata = fonthashes.quads +local v_reset = interfaces.variables.reset + local charbase = characters.data local getdigitwidth = fonts.helpers.getdigitwidth @@ -125,20 +128,30 @@ end local m, enabled = 0, false -- a trick to make neighbouring ranges work -function digits.set(n) - if not enabled then - tasks.enableaction("processors","typesetters.digits.handler") - if trace_digits then - report_digits("enabling digit handler") - end - enabled = true - end - if m == 100 then - m = 1 +function digits.set(n) -- number or 'reset' + if n == v_reset then + n = unsetvalue else - m = m + 1 + n = tonumber(n) + if n then + if not enabled then + tasks.enableaction("processors","typesetters.digits.handler") + if trace_digits then + report_digits("enabling digit handler") + end + enabled = true + end + if m == 100 then + m = 1 + else + m = m + 1 + end + n = m * 100 + n + else + n = unsetvalue + end end - texattribute[a_digits] = m * 100 + n + texattribute[a_digits] = n end digits.handler = nodes.installattributehandler { @@ -146,3 +159,7 @@ digits.handler = nodes.installattributehandler { namespace = digits, processor = process, } + +-- interface + +commands.setdigitsmanipulation = digits.set diff --git a/tex/context/base/typo-dig.mkiv b/tex/context/base/typo-dig.mkiv index 03be1bffc..832ebbec4 100644 --- a/tex/context/base/typo-dig.mkiv +++ b/tex/context/base/typo-dig.mkiv @@ -39,7 +39,7 @@ %D \stoplines \unexpanded\def\setdigitsmanipulation[#1]% - {\ctxlua{typesetters.digits.set(\number#1)}} + {\ctxcommand{setdigitsmanipulation("#1")}} \unexpanded\def\resetdigitsmanipulation {\attribute\digitsattribute\attributeunsetvalue} @@ -48,8 +48,8 @@ \resetdigitsmanipulation \to \everyresettypesetting -\unexpanded\def\equaldigits{\groupedcommand{\setdigitsmanipulation[\plusone]}{}} -\unexpanded\def\dummydigit {\hphantom{\setdigitsmanipulation[\plusone]0}} +\unexpanded\def\equaldigits{\groupedcommand{\setdigitsmanipulation[\number\plusone]}{}} +\unexpanded\def\dummydigit {\hphantom {\setdigitsmanipulation[\number\plusone]0}} \appendtoks \resetcharacterspacing diff --git a/tex/context/base/typo-mar.mkiv b/tex/context/base/typo-mar.mkiv index 0d5c5a5b9..987ce9a12 100644 --- a/tex/context/base/typo-mar.mkiv +++ b/tex/context/base/typo-mar.mkiv @@ -155,26 +155,26 @@ \unexpanded\def\margindata {\iftrialtypesetting - \expandafter\nomargindata + \expandafter\typo_margins_data_nop \else - \expandafter\domargindata + \expandafter\typo_margins_data_yes \fi} -\def\nomargindata[#name]% - {\dodoubleempty\donomargindata} +\def\typo_margins_data_nop[#name]% + {\dodoubleempty\typo_margins_data_nop_indeed} -\def\domargindata[#name]% +\def\typo_margins_data_yes[#name]% {\setfalse\inhibitmargindata % flushing afterwards \begingroup %\settrue\inhibitmargindata % no flushing in here \def\currentmargindata{#name}% \let\currentmarginframed\currentmargindata - \dodoubleempty\dodomargindata} + \dodoubleempty\typo_margins_data_yes_indeed} -\unexpanded\def\donomargindata[#dataparameters][#textparameters]#content% +\unexpanded\def\typo_margins_data_nop_indeed[#dataparameters][#textparameters]#content% {} -\unexpanded\def\dodomargindata[#dataparameters][#textparameters]#content% +\unexpanded\def\typo_margins_data_yes_indeed[#dataparameters][#textparameters]#content% {\iffirstargument \setupcurrentmargindata[#dataparameters]% \fi @@ -365,9 +365,9 @@ \let\definemarginline\definemargindata \unexpanded\def\defineinmargin - {\doquadrupleempty\dodefineinmargin} + {\doquadrupleempty\typo_inmargin_define} -\def\dodefineinmargin[#name][#location][#align][#settings]% not completely compatible +\def\typo_inmargin_define[#name][#location][#align][#settings]% not completely compatible {\definemargindata[#name][\c!location=#location,\c!align=#align,#settings]% \definemarginframed[#name][#location][\c!align=#align,#settings]} diff --git a/tex/context/base/typo-rep.lua b/tex/context/base/typo-rep.lua index 5ecff5586..0d9bf8cc1 100644 --- a/tex/context/base/typo-rep.lua +++ b/tex/context/base/typo-rep.lua @@ -24,12 +24,17 @@ local has_attribute = node.has_attribute local chardata = characters.data local collected = false -local attribute = attributes.private("stripping") +local a_stripping = attributes.private("stripping") local fontdata = fonts.hashes.identifiers local tasks = nodes.tasks -local nodecodes = nodes.nodecodes -local glyph_code = nodecodes.glyph +local texattribute = tex.attribute +local unsetvalue = attributes.unsetvalue + +local v_reset = interfaces.variables.reset + +local nodecodes = nodes.nodecodes +local glyph_code = nodecodes.glyph -- todo: other namespace -> typesetters @@ -74,7 +79,7 @@ function nodes.handlers.stripping(head) while current do if current.id == glyph_code then -- it's more efficient to keep track of what needs to be kept - local todo = has_attribute(current,attribute) + local todo = has_attribute(current,a_stripping) if todo == 1 then local char = current.char local what = glyphs[char] @@ -94,11 +99,31 @@ function nodes.handlers.stripping(head) return head, done end +local enabled = false + +function stripping.set(n) -- number or 'reset' + if n == v_reset then + n = unsetvalue + else + n = tonumber(n) + if n then + if not enabled then + if initialize then initialize() end + tasks.enableaction("processors","nodes.handlers.stripping") + enabled = true + end + else + n = unsetvalue + end + end + texattribute[a_stripping] = n +end + +-- why not in task-ini? + tasks.appendaction("processors","fonts","nodes.handlers.stripping",nil,"nodes.handlers.characters") tasks.disableaction("processors","nodes.handlers.stripping") -function nodes.stripping.enable() - if initialize then initialize() end - tasks.enableaction("processors","nodes.handlers.stripping") - function nodes.stripping.enable() end -end +-- interface + +commands.setcharacterstripping = stripping.set diff --git a/tex/context/base/typo-rep.mkiv b/tex/context/base/typo-rep.mkiv index c13d7eeb7..46b439491 100644 --- a/tex/context/base/typo-rep.mkiv +++ b/tex/context/base/typo-rep.mkiv @@ -37,17 +37,15 @@ \definesystemattribute[stripping][public] -\def\setcharacterstripping - {\ctxlua{nodes.stripping.enable()}% - \gdef\setcharacterstripping[##1]{\attribute\strippingattribute##1\relax}% - \setcharacterstripping} +\unexpanded\def\setcharacterstripping[#1]% + {\ctxcommand{setcharacterstripping("#1")}} -\def\resetcharacterstripping +\unexpanded\def\resetcharacterstripping {\attribute\strippingattribute\attributeunsetvalue} % maybe .. this might disappear, but is handy for testing -\def\forcecharacterstripping % secret command +\unexpanded\def\forcecharacterstripping % secret command {\ctxlua{fonts.handlers.otf.features.register("formatters",true)}} \protect \endinput diff --git a/tex/context/base/typo-spa.lua b/tex/context/base/typo-spa.lua index 5b80c7178..9e653ad55 100644 --- a/tex/context/base/typo-spa.lua +++ b/tex/context/base/typo-spa.lua @@ -30,6 +30,8 @@ local quaddata = fonthashes.quads local texattribute = tex.attribute local unsetvalue = attributes.unsetvalue +local v_reset = interfaces.variables.reset + local nodecodes = nodes.nodecodes local glyph_code = nodecodes.glyph @@ -192,12 +194,18 @@ function spacings.setup(name,char,settings) end function spacings.set(name) - if not enabled then - tasks.enableaction("processors","typesetters.spacings.handler") - enabled = true + local n = unsetvalue + if name ~= v_reset then + local data = numbers[name] + if data then + if not enabled then + tasks.enableaction("processors","typesetters.spacings.handler") + enabled = true + end + n = data.number or unsetvalue + end end - local data = numbers[name] - texattribute[a_spacings] = data and data.number or unsetvalue + texattribute[a_spacings] = n end function spacings.reset() diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 50eb86f93..c5a3e3028 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 01/11/12 14:58:36 +-- merge date : 01/12/12 11:03:39 do -- begin closure to overcome local limits and interference |