diff options
Diffstat (limited to 'tex/context/base/xtag-ini.tex')
-rw-r--r-- | tex/context/base/xtag-ini.tex | 412 |
1 files changed, 308 insertions, 104 deletions
diff --git a/tex/context/base/xtag-ini.tex b/tex/context/base/xtag-ini.tex index 7be11a1db..fed3e7c2b 100644 --- a/tex/context/base/xtag-ini.tex +++ b/tex/context/base/xtag-ini.tex @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +% etex optimized + \unprotect \def\unspaced#1% @@ -28,6 +30,9 @@ {\convertargument#1\to#2% \@EA\edef\@EA#2\@EA{\@EA\unspaced\@EA{#2}}} +\def\unspaceafter#1#2% + {\edef\ascii{\dounspaced#2\end}\@EA#1\@EA{\ascii}} + \protect \beginTEX @@ -114,6 +119,8 @@ \def\@@XMLdata {\@@XML dat} \def\@@XMLcode {\@@XML cod} \def\@@XMLinstruction {\@@XML ins} +\def\@@XMLmap {\@@XML map} +\def\@@XMLlist {\@@XML lst} \newtoks\XMLtoks \newtoks\XMLresetlist @@ -265,13 +272,15 @@ %D to determine if we're dealing with a comment or processing %D instruction. We need a bit of grouping because we have to %D mess up with catcodes. We probably have to treat a few -%D more catcode and first character cases. +%D more catcode and first character cases. We need to use +%D \type {\begingroup} here, otherwise we get funny spaces in +%D math. \protect \long\def\doXMLelement#1% - {\bgroup % maybe tab and space needs some treatment too: \catcode`\ =10 % \@@space - \catcode`\^^M= 10 + {\begingroup % maybe tab and space needs some treatment too: \catcode`\ =10 % \@@space + \catcode`\^^M=10 \if#1!\let\next \xdoXMLelement \else \if#1?\let\next \ydoXMLelement \else \let\next \zdoXMLelement \fi\fi @@ -280,11 +289,11 @@ %D By using a few {\expandafter}'s we can us a \type {\next} %D construction. We could speed the first char test up a bit %D by using an installer and something \typ {\getvalue -%D {#1doXMLelement}} (todo). +%D {#1doXMLelement}} (todo). \long\def\doXMLelement#1% - {\bgroup % maybe tab and space needs some treatment too: \catcode`\ =10 % \@@space - \catcode`\^^M= 10 + {\begingroup % maybe tab and space needs some treatment too: \catcode`\ =10 % \@@space + \catcode`\^^M=10\relax \if#1!\expandafter \xdoXMLelement \else \if#1?\expandafter\expandafter\expandafter \ydoXMLelement \else \expandafter\expandafter\expandafter \zdoXMLelement \fi\fi @@ -294,7 +303,7 @@ %D on top of the verbatim environment. \long\def\xdoXMLelement !#1 % !-- --> or !xyz > - {\egroup + {\endgroup \doifelse{#1}{--} {\long\def\nextelement{\gobbleuntil{-->}}} {\doifelse{#1}{[CDATA[} @@ -310,12 +319,12 @@ %D later. \long\def\ydoXMLelement#1 #2?>% ?target ?> - {\egroup\dodoXMLprocessor{#1}{#2}} + {\endgroup\dodoXMLprocessor{#1}{#2}} %D The normal elements are handled by \type {\dodoXMLelement}. \long\def\zdoXMLelement#1>% - {\egroup\dodoXMLelement#1 >} + {\endgroup\dodoXMLelement#1 >} %D Now we switch to unprotected mode again. @@ -382,19 +391,23 @@ \let\currentXMLarguments\empty \let\currentXMLelement \empty +\newtoks\everyXMLelement + \long\def\dodoXMLelement#1 #2>% - {\getvalue{\@@XMLpars:#1}% parameter list - \def\!!stringa{#2}% + {\def\!!stringa{#2}% \def\!!stringb{/ }% \ifx\!!stringa\empty \let\currentXMLarguments\empty \def\currentXMLelement{#1}% + \the\everyXMLelement \else\ifx\!!stringa\!!stringb \let\currentXMLarguments\empty \def\currentXMLelement{#1/}% + \the\everyXMLelement \else \def\currentXMLelement{#1}% \def\currentXMLarguments{#2}% + \the\everyXMLelement %\getXMLarguments\currentXMLelement{#2}% \dogetXMLarguments\currentXMLelement#2>% \fi \fi @@ -431,8 +444,24 @@ {\unspaceargument#1\to\ascii \long\setvalue{\@@XMLentity:\@EA\firstofoneargument\ascii}{#2}} +% we need to be able to do: +% +% \defineXMLentity[amp] {\FunnyAmp} \def\FunnyAmp#1;{\getXMLentity{#1}} +% +% \defineXMLentity [pound] {(why not use euro's?)} +% +% \startXMLdata +% test &pound; test +% \stopXMLdata +% +% so we need an ifless implementation of: + \gdef\doXMLentity#1;% - {\ifXMLrawentities#1\else\executeXMLentity{#1}\fi} + {\ifXMLrawentities + \expandafter\firstofoneargument + \else + \expandafter\executeXMLentity + \fi{#1}} \def\executeXMLentity#1% internal ! ! ! {\getXMLentity{#1}} @@ -446,21 +475,75 @@ \gdef\doifXMLentityelse#1#2#3% {\ifundefined{\@@XMLentity:#1}#3\else#2\fi} +% \long\def\getXMLarguments#1#2% +% {\dogetXMLarguments{#1}#2>} +% +% \long\def\dogetXMLarguments#1% +% {\XMLtoks\emptytoks +% \def\@@XMLclass{#1}% +% \let\dodoparseXMLarguments\doparseXMLarguments +% \doparseXMLarguments} +% +% \def\dosetXMLargument#1% +% {\setvalue{\@@XMLvariable:\@@XMLclass:\@@XMLname}{#1}% +% %\message{[\@@XMLname=#1]}% +% \let\dodoparseXMLarguments\doparseXMLarguments +% \dodoparseXMLarguments} + +% see \defineXML... commands: +% +% [key=val] => \presetXMLarguments{element} => default key/vals +% [blabla] => \theXMLarguments{blabla} => user key/vals +% [blabla] [key=val] => \presetXMLarguments{element} => default key/vals +% \theXMLarguments{blabla} => user key/vals +% +% <element key="val"> stored in case of [blabla] else set as \XMLpar +% +% see m-steps for an example of usage + \long\def\getXMLarguments#1#2% {\dogetXMLarguments{#1}#2>} \long\def\dogetXMLarguments#1% {\XMLtoks\emptytoks - \def\@@XMLclass{#1}% + \ifcsname\@@XMLmap:#1\endcsname + \let\dosetXMLargument\dosetXMLargumentB + \else + \def\@@XMLclass{#1}% + \let\dosetXMLargument\dosetXMLargumentA + \fi \let\dodoparseXMLarguments\doparseXMLarguments \doparseXMLarguments} -\def\dosetXMLargument#1% +\def\dosetXMLargumentA#1% {\setvalue{\@@XMLvariable:\@@XMLclass:\@@XMLname}{#1}% - %\message{[\@@XMLname=#1]}% \let\dodoparseXMLarguments\doparseXMLarguments + %\message{[\@@XMLclass][\@@XMLname=#1]}\wait \dodoparseXMLarguments} +\def\dosetXMLargumentB#1% + {\setevalue{\@@XMLmap:\@@XMLmapmap}% + {\@EA\ifx\csname\@@XMLmap:\@@XMLmapmap\endcsname\empty\else + \csname\@@XMLmap:\@@XMLmapmap\endcsname,% + \fi + \@@XMLname=#1}% + \let\dodoparseXMLarguments\doparseXMLarguments + %\message{[\@@XMLprefix][\@@XMLname=#1]}\wait + \dodoparseXMLarguments} + +\appendtoks + \resetXMLarguments\currentXMLelement +\to \everyXMLelement + +\def\resetXMLarguments#1% + {\ifcsname\@@XMLmap:#1\endcsname + \@EA\let\@EA\@@XMLmapmap\csname\@@XMLmap:#1\endcsname + \@EA\let\csname\@@XMLmap:\@@XMLmapmap\endcsname\empty + \fi} + +\def\theXMLarguments#1% + {\ifcsname\@@XMLmap:#1\endcsname\csname\@@XMLmap:#1\endcsname\fi} + \long\def\doparseXMLarguments#1% space goes ok {\if#1>% \let\dodoparseXMLarguments\empty @@ -485,8 +568,6 @@ %D is left to the imagination of the reader. These macros %D will be improved. -%D - \bgroup \catcode`<=\@@active @@ -523,78 +604,114 @@ {\long\setvalue{\@@XMLelement:#1/}{\long\setvalue{\@@XMLdata:#1}{}}% \long\setvalue{\@@XMLelement:#1}##1</#1>{\long\setvalue{\@@XMLdata:#1}{##1}}} +\long\gdef\dododefineXMLenvironmentpush#1#2#3% + {\long\setvalue{\@@XMLelement:#1/}{#2\long\setvalue{\@@XMLdata:#1}{}#3}% + \long\setvalue{\@@XMLelement:#1}##1</#1>{#2\long\setvalue{\@@XMLdata:#1}{##1}#3}} + \long\gdef\dododefineXMLprocess#1% {\long\setvalue{\@@XMLelement:#1/}{}% \long\setvalue{\@@XMLelement:#1}{}% \long\setvalue{\@@XMLelement:/#1}{}} -\long\gdef\dododefineXMLnested#1#2#3% - {\long\setvalue{\@@XMLelement:#1}{\getXMLgrouped{#1}{#2}{#3}}} +\long\gdef\dododefineXMLnestedenvironment#1#2#3% + {\long\setvalue{\@@XMLelement:#1}{\getXMLgroupedenvironment{#1}{#2}{#3}}} + +\long\gdef\dododefineXMLnestedargument#1#2% + {\long\setvalue{\@@XMLelement:#1}{\getXMLgroupedargument{#1}{#2}}} \egroup %D The high level definition macros. -\def\defineXMLsingular {\dodoubleempty\dodefineXMLsingular} -\def\defineXMLcommand {\dodoubleempty\dodefineXMLcommand} -\def\defineXMLgrouped {\dodoubleempty\dodefineXMLgrouped} -\def\defineXMLargument {\dodoubleempty\dodefineXMLargument} -\def\defineXMLignore {\dodoubleempty\dodefineXMLignore} -\def\defineXMLpickup {\dodoubleempty\dodefineXMLpickup} -\def\defineXMLenvironment{\dodoubleempty\dodefineXMLenvironment} -\def\defineXMLpush {\dodoubleempty\dodefineXMLpush} -\def\defineXMLprocess {\dodoubleempty\dodefineXMLprocess} -\def\defineXMLnested {\dodoubleempty\dodefineXMLnested} +\def\defineXMLsingular {\dotripleempty\dodefineXMLsingular} +\def\defineXMLcommand {\dotripleempty\dodefineXMLcommand} +\def\defineXMLgrouped {\dotripleempty\dodefineXMLgrouped} +\def\defineXMLargument {\dotripleempty\dodefineXMLargument} +\def\defineXMLignore {\dotripleempty\dodefineXMLignore} +\def\defineXMLpickup {\dotripleempty\dodefineXMLpickup} +\def\defineXMLenvironment {\dotripleempty\dodefineXMLenvironment} +\def\defineXMLpush {\dotripleempty\dodefineXMLpush} +\def\defineXMLenvironmentpush{\dotripleempty\dodefineXMLenvironmentpush} +\def\defineXMLprocess {\dotripleempty\dodefineXMLprocess} + +% goes for all types + +\def\defineXMLnested {\dotripleempty\dodefineXMLnestedenvironment} +\def\defineXMLnestedenvironment{\dotripleempty\dodefineXMLnestedenvironment} +\def\defineXMLnestedargument {\dotripleempty\dodefineXMLnestedargument} + +\long\def\dodefineXMLsingular[#1][#2][#3]#4% + {\defineXMLmethod\dododefineXMLsingular{#1}{#2}{#3}{#4}{}} + +\long\def\dodefineXMLcommand[#1][#2][#3]#4% + {\defineXMLmethod\dododefineXMLcommand{#1}{#2}{#3}{#4}{}} + +\long\def\dodefineXMLgrouped[#1][#2][#3]#4% + {\defineXMLmethod\dododefineXMLgrouped{#1}{#2}{#3}{#4}{}} -\long\def\dodefineXMLsingular[#1][#2]#3% - {\defineXMLmethod\dododefineXMLsingular{#1}{#2}{#3}{}} +\long\def\dodefineXMLargument[#1][#2][#3]#4% + {\defineXMLmethod\dododefineXMLargument{#1}{#2}{#3}{#4}{}} -\long\def\dodefineXMLcommand[#1][#2]#3% - {\defineXMLmethod\dododefineXMLcommand{#1}{#2}{#3}{}} +\long\def\dodefineXMLignore[#1][#2][#3]% + {\defineXMLmethod\dododefineXMLignore{#1}{#2}{#3}{}{}} -\long\def\dodefineXMLgrouped[#1][#2]#3% - {\defineXMLmethod\dododefineXMLgrouped{#1}{#2}{#3}{}} +\long\def\dodefineXMLpickup[#1][#2][#3]#4#5% + {\defineXMLmethod\dododefineXMLpickup{#1}{#2}{#3}{#4}{#5}} -\long\def\dodefineXMLargument[#1][#2]#3% - {\defineXMLmethod\dododefineXMLargument{#1}{#2}{#3}{}} +\long\def\dodefineXMLenvironment[#1][#2][#3]#4#5% + {\defineXMLmethod\dododefineXMLenvironment{#1}{#2}{#3}{#4}{#5}} -\long\def\dodefineXMLignore[#1][#2]% - {\defineXMLmethod\dododefineXMLignore{#1}{#2}{}{}} +\long\def\dodefineXMLpush[#1][#2][#3]% + {\defineXMLmethod\dododefineXMLpush{#1}{#2}{#3}{}{}} -\long\def\dodefineXMLpickup[#1][#2]#3#4% - {\defineXMLmethod\dododefineXMLpickup{#1}{#2}{#3}{#4}} +\long\def\dodefineXMLenvironmentpush[#1][#2][#3]#4#5% + {\defineXMLmethod\dododefineXMLenvironmentpush{#1}{#2}{#3}{#4}{#5}} -\long\def\dodefineXMLenvironment[#1][#2]#3#4% - {\defineXMLmethod\dododefineXMLenvironment{#1}{#2}{#3}{#4}} +\long\def\dodefineXMLprocess[#1][#2][#3]% + {\defineXMLmethod\dododefineXMLprocess{#1}{#2}{#3}{}{}} -\long\def\dodefineXMLpush[#1][#2]% - {\defineXMLmethod\dododefineXMLpush{#1}{#2}{}{}} +\long\def\dodefineXMLnestedenvironment[#1][#2][#3]#4#5% + {\defineXMLmethod\dododefineXMLnestedenvironment{#1}{#2}{#3}{#4}{#5}} -\long\def\dodefineXMLprocess[#1][#2]% - {\defineXMLmethod\dododefineXMLprocess{#1}{#2}{}{}} +\long\def\dodefineXMLnestedargument[#1][#2][#3]#4% + {\defineXMLmethod\dododefineXMLnestedargument{#1}{#2}{#3}{#4}{}} -\long\def\dodefineXMLnested[#1][#2]#3#4% - {\defineXMLmethod\dododefineXMLnested{#1}{#2}{#3}{#4}} +% [key=val] => \presetXMLarguments{element} => default key/vals +% [blabla] => \theXMLarguments{blabla} => user key/vals +% [blabla] [key=val] => \presetXMLarguments{element} => default key/vals +% \theXMLarguments{blabla} => user key/vals -\long\def\defineXMLmethod#1#2#3#4#5% command element pars begin end +\long\def\defineXMLmethod#1#2#3#4#5#6% command element [map] [parlst] begin end {\ifsecondargument - \doifassignmentelse{#3} - {\setvalue{\@@XMLpars:#2}{\getrawparameters[\@@XMLvariable:#2:][#3]}} - {}% ? ? ? - % \def\docommando##1% can be made faster - % {\expanded{\XMLtoks{\the\XMLtoks\def\csname\@@XMLvariable:##1\endcsname{}}}}% - % \XMLtoks\emptytoks\processcommalist[#3]\docommando}% + \setXMLarguments{#2}{#3}{#4}% \fi \ifignoreXMLcase - \lowercasestring#2\to\ascii \@EA#1\@EA{\ascii}{#4}{#5}% - \uppercasestring#2\to\ascii \@EA#1\@EA{\ascii}{#4}{#5}% + \lowercasestring#2\to\ascii \@EA#1\@EA{\ascii}{#5}{#6}% + \uppercasestring#2\to\ascii \@EA#1\@EA{\ascii}{#5}{#6}% \else - #1{#2}{#4}{#5}% + #1{#2}{#5}{#6}% \fi} +\def\setXMLarguments#1#2#3% element [tag] settings + {\doifassignmentelse{#2} + {\setvalue{\@@XMLpars:#1}{\getrawparameters[\@@XMLvariable:#1:][#2]}} + {\setvalue{\@@XMLmap :#1}{#2}% later we can init vars by this name + \doifsomething{#3}{\setvalue{\@@XMLpars:#1}{\getrawparameters[#2][#3]}}}} + +\def\presetXMLarguments#1% + {\getvalue{\@@XMLpars:#1}} + +\prependtoks + \presetXMLarguments\currentXMLelement +\to \everyXMLelement + \def\doifXMLdataelse#1#2#3% % \relax too, so no etex -% {\expandafter\ifx\csname\@@XMLdata:#1\endcsname\relax - {\ifundefined{\@@XMLdata:#1}% +% wrong +% {\expandafter\ifx\csname\@@XMLdata:#1\endcsname\relax +% slow +% {\ifundefined{\@@XMLdata:#1}% +% etex + {\unless\ifcsname\@@XMLdata:#1\endcsname #3% \else\expandafter\ifx\csname\@@XMLdata:#1\endcsname\empty #3% @@ -604,11 +721,23 @@ #2% \fi\fi\fi} -\def\XMLpop#1% -% {\expandafter\ifx\csname\@@XMLdata:#1\endcsname\relax\else -% \csname\@@XMLdata:#1\endcsname -% \fi} - {\ifundefined{\@@XMLdata:#1}\else\getvalue{\@@XMLdata:#1}\fi} +\def\XMLpop#1% one level +% wrong +% {\expandafter\ifx\csname\@@XMLdata:#1\endcsname\relax\else +% \csname\@@XMLdata:#1\endcsname +% \fi} +% slow, hm was not commented +% {\ifundefined{\@@XMLdata:#1}\else\getvalue{\@@XMLdata:#1}\fi} +% etex + {\ifcsname\@@XMLdata:#1\endcsname\csname\@@XMLdata:#1\endcsname\fi} + +\def\XMLpopdata#1% see m-steps for usage + {\unless\ifcsname\@@XMLdata:#1\endcsname + \else\expandafter\ifx\csname\@@XMLdata:#1\endcsname\empty + \else\expandafter\ifx\csname\@@XMLdata:#1\endcsname\relax + \else + \@EA\@EA\@EA\XMLdata\@EA\@EA\@EA{\csname\@@XMLdata:#1\endcsname}% + \fi\fi\fi} \def\XMLappend#1#2% {\edef\!!stringa{\@@XMLdata:#1}% @@ -641,6 +770,12 @@ \def\XMLshow#1% {\showvalue{\@@XMLdata:#1\endcsname}} +\def\XMLunspace#1% + {\ifcsname\@@XMLdata:#1\endcsname + \setevalue{\@@XMLdata:#1}% + {\@EA\@EA\@EA\dounspaced\csname\@@XMLdata:#1\endcsname\end}% + \fi} + \def\defXMLlowerclean#1% lowercase ! evt tzt upper too {\bgroup \lccode`\#=32\lccode`\$=32\lccode`\%=32\lccode`\\=32\lccode`\^=32 @@ -659,38 +794,77 @@ \def\mapXMLvalue#1#2#3% td align center -> middle {\setvalue{\@@XMLvalue:#1:#2:#3}} +% \def\XMLvar#1#2#3% td align center +% {\ifundefined{\@@XMLvariable:#1:#2}% +% \XMLval{#1}{#2}{#3}% +% \else +% \XMLval{#1}{#2}{\getvalue{\@@XMLvariable:#1:#2}}% +% \fi} +% +% \def\XMLval#1#2#3% +% {\ifundefined{\@@XMLvalue:#1:#2}% +% #3% +% \else +% \getvalue{\@@XMLvalue:#1:#2}% +% \fi} +% +% \def\XMLpar#1#2#3% +% {\ifundefined{\@@XMLvariable:#1:#2}% +% #3% +% \else +% \getvalue{\@@XMLvariable:#1:#2}% +% \fi} +% +% speedup + \def\XMLvar#1#2#3% td align center - {\ifundefined{\@@XMLvariable:#1:#2}% - \XMLval{#1}{#2}{#3}% + {\ifcsname\@@XMLvariable:#1:#2\endcsname + \XMLval{#1}{#2}{\csname\@@XMLvariable:#1:#2\endcsname}% \else - \XMLval{#1}{#2}{\getvalue{\@@XMLvariable:#1:#2}}% + \XMLval{#1}{#2}{#3}% evt inline code \fi} \def\XMLval#1#2#3% - {\ifundefined{\@@XMLvalue:#1:#2}% - #3% + {\ifcsname\@@XMLvalue:#1:#2\endcsname + \csname\@@XMLvalue:#1:#2\endcsname \else - \getvalue{\@@XMLvalue:#1:#2}% + #3% \fi} \def\XMLpar#1#2#3% - {\ifundefined{\@@XMLvariable:#1:#2}% - #3% + {\ifcsname\@@XMLvariable:#1:#2\endcsname + \csname\@@XMLvariable:#1:#2\endcsname \else - \getvalue{\@@XMLvariable:#1:#2}% + #3% \fi} +% so far for speedup + +\defineXMLsingular [begingroup] {\begingroup} +\defineXMLsingular [endgroup] {\endgroup} + \def\XMLstr#1% {{\enableXML\scantokens{#1}\unskip}} -\def\XMLstrpar#1#2#3% - {{\enableXML - \ifundefined{\@@XMLvariable:#1:#2}% - \scantokens{#3}% - \else - \scantokens\@EA\@EA\@EA - {\csname\@@XMLvariable:#1:#2\endcsname}\unskip - \fi}} +\def\XMLstr#1% test + {\scantokens{\begingroup\enableXML#1<endgroup/>}} + +%\def\XMLstrpar#1#2#3% +% {{\enableXML +% \ifundefined{\@@XMLvariable:#1:#2}% +% \scantokens{#3}% +% \else +% \scantokens\@EA\@EA\@EA +% {\csname\@@XMLvariable:#1:#2\endcsname}\unskip +% \fi}} + +\def\XMLstrpar#1#2#3% test + {\ifundefined{\@@XMLvariable:#1:#2}% + \scantokens{\begingroup\enableXML#3<endgroup/>}% + \else + \scantokens\@EA\@EA\@EA{\@EA\begingroup\@EA\enableXML + \csname\@@XMLvariable:#1:#2\endcsname<endgroup/>}% + \fi} \def\doifXMLvarelse#1#2#3#4% geen etex, \relax too {\expandafter\ifx\csname\@@XMLvariable:#1:#2\endcsname\relax#4\else @@ -712,9 +886,17 @@ \def\gotoXML% {\afterassignment\dogotoXML\let\nexttoken=} -%D +%D Saves tokens and typing. + +\def\XMLownvar {\XMLvar \currentXMLelement} +\def\XMLownval {\XMLval \currentXMLelement} +\def\XMLownpar {\XMLpar \currentXMLelement} +\def\XMLownstrpar {\XMLstrpar \currentXMLelement} +\def\doifXMLownvarelse{\doifXMLvarelse\currentXMLelement} +\def\doifXMLownvalelse{\doifXMLvalelse\currentXMLelement} +\def\doifXMLownparelse{\doifXMLparelse\currentXMLelement} -\beginETEX \scantokens +%D \long\def\startXMLcode[#1] #2 \stopXMLcode {\setgvalue{\@@XMLcode:#1}{\startXMLdata#2\stopXMLdata}} @@ -723,7 +905,7 @@ {\getvalue{\@@XMLcode:#1}} % \long\def\startXMLdata#1\stopXMLdata% -% {\bgroup\enableXML\scantokens{#1}\egroup} +% {\begingroup\enableXML\scantokens{#1}\endgroup} % % \defineXMLentity[tex-backslash] {\catchXMLpar} % @@ -732,30 +914,26 @@ % \else\texescape\fi\else\texescape\fi\else\texescape\fi} \long\def\startXMLdata - {\bgroup + {\begingroup \catcode`\^^I=\@@space \catcode`\^^M=\@@space \catcode`\^^L=\@@space \dostartXMLdata} -\long\def\dostartXMLdata#1\stopXMLdata - {\enableXML\scantokens{#1}\egroup} +% \long\def\dostartXMLdata#1\stopXMLdata +% {\enableXML\scantokens{#1}\endgroup} \long\def\dostartXMLdata#1\stopXMLdata - {\enableXML\scantokens{#1}\ifhmode\unskip\unskip\fi\egroup} + {\enableXML\scantokens{#1}\ifhmode\unskip\unskip\fi\endgroup} -\def\XMLdata#1% - {{\enableXML\scantokens{#1}\ifhmode\unskip\unskip\fi}} - -\endETEX - -\beginTEX - -\long\def\startXMLcode[#1] #2 \stopXMLcode% - {{\infofont[embedded XML code only works in ETEX]}\par} - -\endTEX +\unexpanded\def\XMLdata#1% % \unexpanded added 22/5/2001 + {\begingroup + \enableXML\scantokens{#1}\ifhmode\unskip\unskip\fi + \endgroup} +\unexpanded\def\XMLdata#1% % grouping changed 20/5/2001 + {\scantokens{\begingroup\enableXML#1<endgroup/>}} + %D \def\bXMLs{\ifignoreXMLspaces\ignorespaces\fi} @@ -819,11 +997,11 @@ \def\doprocessXMLbuffer[#1]% {\doifelsenothing{#1} {\doprocessXMLbuffer[\jobname]} - {\bgroup + {\begingroup \def\dodoprocessXMLbuffer##1% {\enableXML\processXMLfile{\TEXbufferfile{##1}}}% \processcommalist[#1]\dodoprocessXMLbuffer - \egroup}} + \endgroup}} %D Loading specific modules takes place with \type %D {\useXMLfilters}. @@ -880,7 +1058,7 @@ \dogetgrouped}% \dogetgrouped} -% cleaner but hardly faster unless big strings are passed +%D Cleaner but hardly faster unless big strings are passed. \long\gdef\docountXMLgrouped#1\end#2\end {\long\def\dosplitstring##1#2##2@@##3\end% @@ -907,6 +1085,32 @@ \dogetgrouped}% \dogetgrouped} +%D More versatile. + +\long\unexpanded\gdef\getXMLgroupedenvironment#1#2#3% + {\def\dodogetgrouped{\@EA#2\the\groupedtoks#3}% + \getXMLgrouped{#1}} + +\long\unexpanded\gdef\getXMLgroupedargument#1#2% + {\def\dodogetgrouped{\@EA#2\@EA{\the\groupedtoks}}% + \getXMLgrouped{#1}} + +\long\unexpanded\gdef\getXMLgrouped#1% + {\groupedtoks\emptytoks + \scratchcounter=0 + \long\def\dogetgrouped##1</#1>% + {\appendtoks##1\to\groupedtoks + \docountXMLgrouped##1\end<#1>\end + \docountXMLgrouped##1\end<#1 \end + \ifcase\scratchcounter + \let\dogetgrouped\dodogetgrouped + \else + \advance\scratchcounter -1 + \appendtoks</#1>\to\groupedtoks + \fi + \dogetgrouped}% + \dogetgrouped} + \egroup % {pre}{pos}{before}{after} |