diff options
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/chem-str.mkiv | 360 | ||||
-rw-r--r-- | tex/context/base/cont-new.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4128 -> 4134 bytes | |||
-rw-r--r-- | tex/context/base/context-version.png | bin | 106161 -> 106127 bytes | |||
-rw-r--r-- | tex/context/base/context.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/file-res.lua | 67 | ||||
-rw-r--r-- | tex/context/base/grph-inc.lua | 102 | ||||
-rw-r--r-- | tex/context/base/mult-sys.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/pack-bck.mkvi | 18 | ||||
-rw-r--r-- | tex/context/base/pack-rul.mkiv | 18 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24406 -> 24432 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 180035 -> 180073 bytes | |||
-rw-r--r-- | tex/context/base/status-mkiv.lua | 2 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
16 files changed, 333 insertions, 246 deletions
diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv index 197c13bc6..e74c268da 100644 --- a/tex/context/base/chem-str.mkiv +++ b/tex/context/base/chem-str.mkiv @@ -49,13 +49,12 @@ \unprotect +\installcorenamespace{chemical} \installcorenamespace{chemicalsymbol} +\installcorenamespace{chemicalframed} +\installcorenamespace{chemicalsize} -\unexpanded\def\setupchemical - {\dosingleempty\dosetupchemical} - -\def\dosetupchemical - {\getparameters[\??cm]} +\installsimplecommandhandler \??chemical {chemical} \??chemical % no \define... \let\setupchemicals\setupchemical @@ -63,72 +62,91 @@ {\dosingleempty\dosetupchemicalframed} \def\dosetupchemicalframed - {\getparameters[\??cm:\c!frame]} - -\def\chemicalparameter#1{\csname\??cm#1\endcsname} + {\getparameters[\??chemicalframed]} -\unexpanded\def\definechemical - {\dosingleargument\dodefinechemical} % global +\unexpanded\def\definechemical % is global (so we don't use the commandhandler) + {\dosingleargument\chem_define} -\def\dodefinechemical[#1]#2% +\def\chem_define[#1]#2% {\startnointerference + \edef\currentdefinedchemical{#1}% + \let\chemical\chem_chemical_nested \ctxlua{chemicals.undefine("#1")}% - \def\chemical{\dodoubleempty\dostructurechemical}% - \def\dostructurechemical[##1][##2]{\ctxlua{chemicals.define("#1",\!!bs##1\!!es,\!!bs\detokenize{##2}\!!es)}}% #2% flush \stopnointerference} +\unexpanded\def\chem_chemical_nested + {\dodoubleempty\chem_chemical_nested_indeed} + +\def\chem_chemical_nested_indeed[#1][#2]% + {\ctxlua{chemicals.define("\currentdefinedchemical",\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)}} + +% chemical symbols + \unexpanded\def\definechemicalsymbol - {\dodoubleempty\dodefinechemicalsymbol} + {\dodoubleempty\chem_symbol_define} -\def\dodefinechemicalsymbol[#1][#2]% +\def\chem_symbol_define[#1][#2]% {\setvalue{\??chemicalsymbol#1}{#2}} \unexpanded\def\chemicalsymbol[#1]% - {\getvalue{\??chemicalsymbol#1}} + {\csname\??chemicalsymbol\ifcsname\??chemicalsymbol#1\endcsname\s!unknown\else#1\fi\endcsname} -% size (small medium big) +\definechemicalsymbol[\s!unknown][] % empty -\unexpanded\def\dosetchemicaltext - {\dousestyleparameter\@@cmstyle - \dousecolorparameter\@@cmcolor} +% size (small medium big) \edef\chemicaltoplocation{t} \edef\chemicalbotlocation{b} -\def\dochemicaltext#1% in ppchtex we had a more clever alignment - {\dosetchemicaltext\strut#1} % maybe also \setstrut +\def\chem_text#1% in ppchtex we had a more clever alignment + {\usechemicalstyleandcolor\c!style\c!color + \strut + #1} % maybe also \setstrut + +\def\chem_text#1% + {\mathematics + {\usechemicalstyleandcolor\c!style\c!color + \strut + \ifcase\currentxfontsize\or\scriptstyle\or\scriptscriptstyle\fi + #1}} -\def\dochemicaltext#1% - {\mathematics{\dosetchemicaltext\strut\ifcase\currentxfontsize\or\scriptstyle\or\scriptscriptstyle\fi#1}} +\setvalue{\??chemicalsize\v!small }{\txx} +\setvalue{\??chemicalsize\v!medium}{\tx} +\setvalue{\??chemicalsize\v!big }{} +\newtoks \everychemical +\newtoks \everystructurechemical \newconditional\indisplaychemical -\unexpanded\def\startchemical - {\dosingleempty\dostartchemical} +\newtoks \t_chem_every_box +\newbox \b_chem_result +\newconditional\c_chem_some_text +\newdimen \d_chem_width +\newdimen \d_chem_height +\newdimen \d_chem_depth -\setvalue{\??cm:\c!size:\v!small }{\txx} -\setvalue{\??cm:\c!size:\v!medium}{\tx} -\setvalue{\??cm:\c!size:\v!big }{} +\unexpanded\def\startchemical + {\dodoubleempty\chem_start} -\newtoks \everychemical -\newtoks \everystructurechemical -\newtoks \withchemicalbox -\newbox \chemicalbox -\newconditional\somechemicaltext -\newdimen \chemicalwidth -\newdimen \chemicalheight -\newdimen \chemicaldepth - -\def\dostartchemical[#1]% +\def\chem_start[#1][#2]% {\ifmmode\vcenter\else\vbox\fi \bgroup \dontcomplain \settrue\indisplaychemical \forgetall - \getparameters[\??cm][#1]% + \ifsecondargument + \doifassignmentelse{#1} + {\setupcurrentchemical[#1]}% same as \currentchemical + {\edef\currentchemical{#1}% + \setupcurrentchemical[#2]}% + \else\iffirstargument + \doifassignmentelse{#1} + {\setupcurrentchemical[#1]}% same as \currentchemical + {\edef\currentchemical{#1}}% + \fi\fi \the\everystructurechemical - \setbox\chemicalbox\hbox\bgroup + \setbox\b_chem_result\hbox\bgroup \ctxlua{chemicals.start { width = "\chemicalparameter\c!width", height = "\chemicalparameter\c!height", @@ -146,41 +164,41 @@ {\stopnointerference \ctxlua{chemicals.stop()}% \egroup - \chemicalwidth \wd\chemicalbox - \chemicalheight\ht\chemicalbox - \chemicaldepth \dp\chemicalbox - \the\withchemicalbox - \doifelsenothing{\chemicalparameter\c!frame}\handlechemicalframednop\handlechemicalframedyes + \d_chem_width \wd\b_chem_result + \d_chem_height\ht\b_chem_result + \d_chem_depth \dp\b_chem_result + \the\t_chem_every_box + \doifelsenothing{\chemicalparameter\c!frame}\chem_framed_nop\chem_framed_yes \egroup} -\def\handlechemicalframedyes +\def\chem_framed_yes {\localframed% - [\??cm:\c!frame]% - [\c!frame=\chemicalparameter\c!frame,\c!align=\v!normal,\c!strut=\v!no]{\vbox{\box\chemicalbox\vss}}} % remove depth + [\??chemicalframed]% + [\c!frame=\chemicalparameter\c!frame,\c!align=\v!normal,\c!strut=\v!no]{\vbox{\box\b_chem_result\vss}}} % remove depth -\def\handlechemicalframednop +\def\chem_framed_nop {\localframed% - [\??cm:\c!frame]% - [\c!align=\v!normal,\c!strut=\v!no]{\vbox{\box\chemicalbox\vss}}} % remove depth + [\??chemicalframed]% + [\c!align=\v!normal,\c!strut=\v!no]{\vbox{\box\b_chem_result\vss}}} % remove depth \let\startstructurechemical\startchemical \let\stopstructurechemical \stopchemical \unexpanded\def\structurechemical - {\dotripleempty\dostructurechemical} + {\dotripleempty\strc_chem_indeed} \appendtoks \let\chemical\structurechemical \to\everystructurechemical -\def\dostructurechemical +\def\strc_chem_indeed {\ifthirdargument - \expandafter\dostructurechemicalthree + \expandafter\strc_chem_indeed_three \else - \expandafter\dostructurechemicaltwo + \expandafter\strc_chem_indeed_two \fi} -\def\dostructurechemicalthree[#1][#2][#3]% +\def\strc_chem_indeed_three[#1][#2][#3]% {\writestatus\m!chemicals{hyperlinked chemicals not yet supported}% todo reference, for the moment ignored \ctxlua{chemicals.component(\!!bs#2\!!es, \!!bs\detokenize{#3}\!!es, { % maybe also pass first two args this way rulethickness = "\the\dimexpr\chemicalparameter\c!rulethickness\relax", % todo: scaled points @@ -188,7 +206,7 @@ } ) }% \ignorespaces} -\def\dostructurechemicaltwo[#1][#2]% +\def\strc_chem_indeed_two[#1][#2]% {\ctxlua{chemicals.component(\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es, { % maybe also pass first two args this way rulethickness = "\the\dimexpr\chemicalparameter\c!rulethickness\relax", % todo: scaled points rulecolor = "\MPcolor{\chemicalparameter\c!rulecolor}" % we can precalculate this for speedup @@ -196,66 +214,66 @@ \ignorespaces} \appendtoks - \setbox\chemicalbox\hbox{\raise\MPlly\box\chemicalbox}% - \chemicalwidth \wd\chemicalbox - \chemicalheight\ht\chemicalbox - \chemicaldepth \dp\chemicalbox -\to \withchemicalbox + \setbox\b_chem_result\hbox{\raise\MPlly\box\b_chem_result}% + \d_chem_width \wd\b_chem_result + \d_chem_height\ht\b_chem_result + \d_chem_depth \dp\b_chem_result +\to \t_chem_every_box % kind of compatible, but text sizes instead of math sizes (i.e. tx is larger than scriptsize) \appendtoks - \edef\chemicalbodyfont{\chemicalparameter\c!bodyfont}% + \edef\chemicalbodyfont{\chemicalparameter\c!bodyfont}% public? \ifx\chemicalbodyfont\empty \switchtobodyfont[\chemicalbodyfont]% \fi - \getvalue{\??cm:\c!size:\chemicalparameter\c!size}% + \getvalue{\??chemicalsize\chemicalparameter\c!size}% % \to \everystructurechemical \to \everychemical -\def\chemicaltoptext#1{\global\settrue\somechemicaltext\gdef\thetoptext{#1}\ignorespaces} -\def\chemicalbottext#1{\global\settrue\somechemicaltext\gdef\thebottext{#1}\ignorespaces} -\def\chemicalmidtext#1{\global\settrue\somechemicaltext\gdef\themidtext{#1}\ignorespaces} +\def\chemicaltoptext#1{\global\settrue\c_chem_some_text\gdef\m_chem_top_text{#1}\ignorespaces} +\def\chemicalbottext#1{\global\settrue\c_chem_some_text\gdef\m_chem_bot_text{#1}\ignorespaces} +\def\chemicalmidtext#1{\global\settrue\c_chem_some_text\gdef\m_chem_mid_text{#1}\ignorespaces} \appendtoks - \let\toptext\chemicaltoptext \glet\thetoptext\empty - \let\bottext\chemicalbottext \glet\thebottext\empty - \let\midtext\chemicalmidtext \glet\themidtext\empty - \global\setfalse\somechemicaltext + \let\toptext\chemicaltoptext \glet\m_chem_top_text\empty + \let\bottext\chemicalbottext \glet\m_chem_bot_text\empty + \let\midtext\chemicalmidtext \glet\m_chem_mid_text\empty + \global\setfalse\c_chem_some_text \to \everystructurechemical \def\doaddchemicaltexts - {\setbox2\hbox to \chemicalwidth{\strut\hss\hbox{\strut\themidtext}\hss}% - \setbox4\hbox to \chemicalwidth{\strut\hss\hbox{\strut\thetoptext}\hss}% - \setbox6\hbox to \chemicalwidth{\strut\hss\hbox{\strut\thebottext}\hss}% - \setbox\chemicalbox\hbox \bgroup - \box\chemicalbox - \hskip-\chemicalwidth - \raise\chemicalheight\hbox{\lower\ht4\box4}% - \hskip-\chemicalwidth + {\setbox2\hbox to \d_chem_width{\strut\hss\hbox{\strut\m_chem_mid_text}\hss}% + \setbox4\hbox to \d_chem_width{\strut\hss\hbox{\strut\m_chem_top_text}\hss}% + \setbox6\hbox to \d_chem_width{\strut\hss\hbox{\strut\m_chem_bot_text}\hss}% + \setbox\b_chem_result\hbox \bgroup + \box\b_chem_result + \hskip-\d_chem_width + \raise\d_chem_height\hbox{\lower\ht4\box4}% + \hskip-\d_chem_width \lower.5\dimexpr\ht2-\dp2\relax\box2% - \hskip-\chemicalwidth - \lower\chemicaldepth \hbox{\raise\dp6\box6}% + \hskip-\d_chem_width + \lower\d_chem_depth \hbox{\raise\dp6\box6}% \hss \egroup} % text on top of chemicals \appendtoks - \ifconditional\somechemicaltext + \ifconditional\c_chem_some_text \doaddchemicaltexts - \chemicalwidth \wd\chemicalbox - \chemicalheight\ht\chemicalbox - \chemicaldepth \dp\chemicalbox + \d_chem_width \wd\b_chem_result + \d_chem_height\ht\b_chem_result + \d_chem_depth \dp\b_chem_result \fi -\to \withchemicalbox +\to \t_chem_every_box % todo: enspace or emspace \definechemicalsymbol[space] [\enspace\quad\enspace] \definechemicalsymbol[plus] [\enspace+\enspace] \definechemicalsymbol[minus] [\enspace-\enspace] -\definechemicalsymbol[gives] [\dochemicalarrow\xrightarrow] -\definechemicalsymbol[equilibrium] [\dochemicalarrow\xrightoverleftarrow] -\definechemicalsymbol[mesomeric] [\dochemicalarrow\xleftrightarrow] +\definechemicalsymbol[gives] [\chem_arrow_construct\xrightarrow] +\definechemicalsymbol[equilibrium] [\chem_arrow_construct\xrightoverleftarrow] +\definechemicalsymbol[mesomeric] [\chem_arrow_construct\xleftrightarrow] \definechemicalsymbol[opencomplex] [\mathematics{\Bigg[}] % not yet ok \definechemicalsymbol[closecomplex][\mathematics{\Bigg]}] % not yet ok @@ -268,32 +286,30 @@ \definechemicalsymbol[OPENCOMPLEX] [{\chemicalsymbol[opencomplex]}] \definechemicalsymbol[CLOSECOMPLEX][{\chemicalsymbol[closecomplex]}] -\def\dochemicalarrow#1#2#3% +\def\chem_arrow_construct#1#2#3% {\enspace \mathematics{#1% - {\strut\hbox \!!spread 2em{\hss\ctxlua{chemicals.inline(\!!bs#2\!!es)}\hss}}% - {\strut\hbox \!!spread 2em{\hss\ctxlua{chemicals.inline(\!!bs#3\!!es)}\hss}}}% -% {\strut\hbox \!!spread 2em{\hss#2\hss}}% -% {\strut\hbox \!!spread 2em{\hss#3\hss}}}% + {\strut\hbox \!!spread 2\emwidth{\hss\ctxlua{chemicals.inline(\!!bs#2\!!es)}\hss}}% {\strut\hbox \!!spread 2em{\hss#2\hss}}% + {\strut\hbox \!!spread 2\emwidth{\hss\ctxlua{chemicals.inline(\!!bs#3\!!es)}\hss}}}% {\strut\hbox \!!spread 2em{\hss#3\hss}}}% \enspace} % special macros (probably needs some more work) -\def\dochemicaltop#1#2#3#4% +\def\chem_top_construct#1#2#3#4% {\begingroup \setbox0\hbox{\tx\setstrut\strut#3}% \setbox2\hbox{\setstrut\strut\molecule{#4}}% \setbox0\hbox{\raise\dimexpr\dp0+\ht2\relax\hbox to \wd2{#1\box0#2}}% -% no: \smashbox0 + % no: \smashbox0 \hbox{\box0\box2}% \endgroup}% -\def\dochemicalbottom#1#2#3#4% +\def\chem_bottom_construct#1#2#3#4% {\begingroup \setbox0\hbox{\tx\setstrut\strut#3}% \setbox2\hbox{\setstrut\strut#4}% \setbox0\hbox{\lower\dimexpr\dp2+\ht0\relax\hbox to \wd2{#1\box0#2}}% -% no: \smashbox0 + % no: \smashbox0 \hbox{\box0\box2}% \endgroup}% @@ -307,12 +323,12 @@ \hbox{\setstrut\strut#2\rlap{\tx\setstrut\strut#1}}% \endgroup}% -\unexpanded\def\chemicaltop {\dochemicaltop \hss \hss } -\unexpanded\def\chemicallefttop {\dochemicaltop \relax \hss } -\unexpanded\def\chemicalrighttop {\dochemicaltop \hss \relax} -\unexpanded\def\chemicalbottom {\dochemicalbottom \hss \hss } -\unexpanded\def\chemicalleftbottom {\dochemicalbottom \relax \hss } -\unexpanded\def\chemicalrightbottom {\dochemicalbottom \hss \relax} +\unexpanded\def\chemicaltop {\chem_top_construct \hss \hss } +\unexpanded\def\chemicallefttop {\chem_top_construct \relax \hss } +\unexpanded\def\chemicalrighttop {\chem_top_construct \hss \relax} +\unexpanded\def\chemicalbottom {\chem_bottom_construct \hss \hss } +\unexpanded\def\chemicalleftbottom {\chem_bottom_construct \relax \hss } +\unexpanded\def\chemicalrightbottom {\chem_bottom_construct \hss \relax} \unexpanded\def\chemicaltopleft #1{\chemicalleft {\chemicalrighttop {#1}{}}} \unexpanded\def\chemicalbottomleft #1{\chemicalleft {\chemicalrightbottom{#1}{}}} @@ -330,7 +346,7 @@ \unexpanded\def\chemicalalignedtext#1#2#3% {\dontleavehmode \begingroup - \dosetchemicaltext + \usechemicalstyleandcolor\c!style\c!color \hbox to \fontcharwd\font`C{\setstrut\strut#1\molecule{#3}#2}% \endgroup} @@ -347,8 +363,8 @@ \unexpanded\def\chemicaloxidationplus {\dotriplegroupempty\chemicaloxidation{\textplus }} % {} needed! \unexpanded\def\chemicaloxidationminus{\dotriplegroupempty\chemicaloxidation{\textminus}} % {} needed! -\unexpanded\def\chemicalforeveropen {\dotriplegroupempty\chemicalleft {$\big[$}} % {} needed! -\unexpanded\def\chemicalforeverclose {\dotriplegroupempty\chemicalright {$\big]$}} % {} needed! +\unexpanded\def\chemicalforeveropen {\dotriplegroupempty\chemicalleft {$\big[$}} % {} needed! +\unexpanded\def\chemicalforeverclose {\dotriplegroupempty\chemicalright {$\big]$}} % {} needed! \unexpanded\def\chemicaloxidationone {\chemicaloxidation\relax1} \unexpanded\def\chemicaloxidationtwo {\chemicaloxidation\relax2} \unexpanded\def\chemicaloxidationthree{\chemicaloxidation\relax3} @@ -402,14 +418,14 @@ \expandafter\inlinechemical \fi} -\def\displaychemical - {\dotriplegroupempty\dodisplaychemical} +\unexpanded\def\displaychemical + {\dotriplegroupempty\chem_display} -\def\dodisplaychemical#1#2#3% todo: +\def\chem_display#1#2#3% todo: {\the\everychemical \everychemical\emptytoks \quad \vcenter\bgroup - \dosetchemicaltext + \usechemicalstyleandcolor\c!style\c!color \ifthirdargument \ifsecondargument \halign{&\hss##\hss\cr#2\cr\molecule{#1}\cr#3\cr}% @@ -422,10 +438,12 @@ \egroup \quad} -\def\inlinechemical#1% - {\dontleavehmode\hbox{\dosetchemicaltext\ctxlua{chemicals.inline(\!!bs#1\!!es)}}} +\unexpanded\def\inlinechemical#1% + {\dontleavehmode + \hbox{\usechemicalstyleandcolor\c!style\c!color\ctxlua{chemicals.inline(\!!bs#1\!!es)}}} -\def\chemicalbondrule{\hbox{\vrule\!!height.75ex\!!depth-\dimexpr.75ex-\linewidth\relax\!!width1em\relax}} +\unexpanded\def\chemicalbondrule + {\hbox{\vrule\!!height.75ex\!!depth-\dimexpr.75ex-\linewidth\relax\!!width1em\relax}} \definechemicalsymbol[i:space] [\enspace\quad\enspace] \definechemicalsymbol[i:plus] [\enspace\mathematics{+}\enspace] @@ -437,25 +455,25 @@ \definechemicalsymbol[i:tripple] [\hbox{\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] \definechemicalsymbol[i:double] [\hbox{\chemicalbondrule\hskip-1em\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] -\def\chemicalsinglebond {\chemicalsymbol[i:single]} -\def\chemicaldoublebond {\chemicalsymbol[i:tripple]} -\def\chemicaltriplebond {\chemicalsymbol[i:double]} -\def\chemicalgives {\chemicalsymbol[i:gives]} -\def\chemicalmesomeric {\chemicalsymbol[i:mesomeric]} -\def\chemicalequilibrium{\chemicalsymbol[i:equilibrium]} -\def\chemicalsplus {\chemicalsymbol[i:plus]} -\def\chemicalsminus {\chemicalsymbol[i:minus]} -\def\chemicalsspace {\chemicalsymbol[i:space]} -\def\chemicalinline #1{#1} +\unexpanded\def\chemicalsinglebond {\chemicalsymbol[i:single]} +\unexpanded\def\chemicaldoublebond {\chemicalsymbol[i:tripple]} +\unexpanded\def\chemicaltriplebond {\chemicalsymbol[i:double]} +\unexpanded\def\chemicalgives {\chemicalsymbol[i:gives]} +\unexpanded\def\chemicalmesomeric {\chemicalsymbol[i:mesomeric]} +\unexpanded\def\chemicalequilibrium{\chemicalsymbol[i:equilibrium]} +\unexpanded\def\chemicalsplus {\chemicalsymbol[i:plus]} +\unexpanded\def\chemicalsminus {\chemicalsymbol[i:minus]} +\unexpanded\def\chemicalsspace {\chemicalsymbol[i:space]} +\unexpanded\def\chemicalinline #1{#1} % display -\newconditional\formulachemicalhastop -\newconditional\formulachemicalhasbot +\newconditional\c_chem_has_top +\newconditional\c_chem_has_bot -\newtoks\formulachemicaltop -\newtoks\formulachemicalmid -\newtoks\formulachemicalbot +\newtoks\t_chem_top +\newtoks\t_chem_mid +\newtoks\t_chem_bot \newif\ifinchemicalformula @@ -465,81 +483,61 @@ \inchemicalformulatrue \the\everychemical \everychemical\emptytoks - \formulachemicaltop\emptytoks % not needed - \formulachemicalmid\emptytoks % not needed - \formulachemicalbot\emptytoks % not needed + \t_chem_top\emptytoks % not needed + \t_chem_mid\emptytoks % not needed + \t_chem_bot\emptytoks % not needed \let\chemical\formulachemical - \setfalse\formulachemicalhastop - \setfalse\formulachemicalhasbot } + \setfalse\c_chem_has_top + \setfalse\c_chem_has_bot} \unexpanded\def\stopchemicalformula {\tabskip1em\relax \nointerlineskip - \ifconditional\formulachemicalhastop - \ifconditional\formulachemicalhasbot - \halign{&\hss\dosetchemicaltext##\hss\cr\the\formulachemicaltop\cr\the\formulachemicalmid\cr\the\formulachemicalbot\cr}% + \ifconditional\c_chem_has_top + \ifconditional\c_chem_has_bot + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% \else - \halign{&\hss\dosetchemicaltext##\hss\cr\the\formulachemicaltop\cr\the\formulachemicalmid\cr}% + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr}% \fi \else - \ifconditional\formulachemicalhasbot - \halign{&\hss\dosetchemicaltext##\hss\cr\the\formulachemicalmid\cr\the\formulachemicalbot\cr}% + \ifconditional\c_chem_has_bot + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% \else - \halign{&\hss\dosetchemicaltext##\hss\cr\the\formulachemicalmid\cr}% + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_mid\cr}% \fi \fi \egroup} \unexpanded\def\formulachemical - {\relax\dotriplegroupempty\doformulachemical} - -% \def\doformulachemical#1#2#3% we could do hboxes and measure -% {\ifthirdargument -% \doifelsenothing{#2}\noformulachemicaltop{\doformulachemicaltop{#2}}% -% \doifelsenothing{#3}\noformulachemicalbot{\doformulachemicalbot{#3}}% -% \else\ifsecondargument -% \noformulachemicaltop -% \doifelsenothing{#2}\noformulachemicalbot{\doformulachemicalbot{#2}}% -% \else -% \noformulachemicaltop -% \noformulachemicalbot -% \fi\fi -% \formulachemicalmid\expandafter{\the\formulachemicalmid\dodochemicalformulamid{#1}&}} -% -% \def\dodochemicalformulamid#1% -% {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname -% \csname\??chemicalsymbol\detokenize{#1}\expandafter\endcsname{}{}% -% \else -% \molecule{#1}{}{}% -% \fi} - -\def\domidformulachemical#1% - {\csname\??chemicalsymbol\detokenize{#1}\endcsname} + {\relax\dotriplegroupempty\chem_formula} -\def\doformulachemical#1#2#3% we could do hboxes and measure +\def\chem_formula#1#2#3% we could do hboxes and measure {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname - \formulachemicalmid\expandafter{\the\formulachemicalmid\domidformulachemical{#1}{#2}{#3}}% + \t_chem_mid\expandafter{\the\t_chem_mid\chem_formula_mid{#1}{#2}{#3}}% \else \ifthirdargument - \doifelsenothing{#2}\noformulachemicaltop{\doformulachemicaltop{#2}}% - \doifelsenothing{#3}\noformulachemicalbot{\doformulachemicalbot{#3}}% + \doifelsenothing{#2}\chem_formula_top_nop{\chem_formula_top_yes{#2}}% + \doifelsenothing{#3}\chem_formula_bot_nop{\chem_formula_bot_yes{#3}}% \else\ifsecondargument - \noformulachemicaltop - \doifelsenothing{#2}\noformulachemicalbot{\doformulachemicalbot{#2}}% + \chem_formula_top_nop + \doifelsenothing{#2}\chem_formula_bot_nop{\chem_formula_bot_yes{#2}}% \else - \noformulachemicaltop - \noformulachemicalbot + \chem_formula_top_nop + \chem_formula_bot_nop \fi\fi - \formulachemicalmid\expandafter{\the\formulachemicalmid\molecule{#1}&}% + \t_chem_mid\expandafter{\the\t_chem_mid\molecule{#1}&}% \fi} -\def\noformulachemicaltop {\formulachemicaltop\expandafter{\the\formulachemicaltop&}} -\def\noformulachemicalbot {\formulachemicalbot\expandafter{\the\formulachemicalbot&}} -\def\doformulachemicaltop#1{\formulachemicaltop\expandafter{\the\formulachemicaltop\dodochemicalformulatop{#1}&}\settrue\formulachemicalhastop} -\def\doformulachemicalbot#1{\formulachemicalbot\expandafter{\the\formulachemicalbot\dodochemicalformulabot{#1}&}\settrue\formulachemicalhasbot} +\def\chem_formula_mid#1% + {\csname\??chemicalsymbol\detokenize{#1}\endcsname} + +\def\chem_formula_top_nop {\t_chem_top\expandafter{\the\t_chem_top&}} +\def\chem_formula_bot_nop {\t_chem_bot\expandafter{\the\t_chem_bot&}} +\def\chem_formula_top_yes#1{\t_chem_top\expandafter{\the\t_chem_top\chem_formula_top_indeed{#1}&}\settrue\c_chem_has_top} +\def\chem_formula_bot_yes#1{\t_chem_bot\expandafter{\the\t_chem_bot\chem_formula_bot_indeed{#1}&}\settrue\c_chem_has_bot} -\def\dodochemicalformulatop#1{\strut#1} -\def\dodochemicalformulabot#1{\strut#1} +\def\chem_formula_top_indeed#1{\strut#1} +\def\chem_formula_bot_indeed#1{\strut#1} % gone: state option resolution offset (now frame offset) alternative diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 0fbfda73e..ad5bf64cd 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.05.25 18:21} +\newcontextversion{2012.05.26 16:40} %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 a521479b5..ecb1e2210 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.05.25 18:21} +\newcontextversion{2012.05.26 16:40} %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 078cdfb31..bf6d22796 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 2ee0c710d..04cf48f56 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 55b4110f1..3a8e0ad0a 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.05.25 18:21} +\edef\contextversion{2012.05.26 16:40} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index ccbc64c21..ddad74ad6 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.05.25 18:21} +\edef\contextversion{2012.05.26 16:40} %D For those who want to use this: diff --git a/tex/context/base/file-res.lua b/tex/context/base/file-res.lua index 24b0f1cfc..4687e140e 100644 --- a/tex/context/base/file-res.lua +++ b/tex/context/base/file-res.lua @@ -24,24 +24,67 @@ local function readfilename(specification,backtrack,treetoo) local name = specification.filename local fnd = name and found[name] if not fnd then - if isfile(name) then + local names + local suffix = file.suffix(name) + if suffix ~= "" then + names = { name } + else + local defaultsuffixes = resolvers.defaultsuffixes + names = { } + for i=1,#defaultsuffixes do + names[i] = name .. "." .. defaultsuffixes[i] + end if trace_files then - report_files("found local: %s",name) + report_files("locating: %s, using default suffixes: %s",name,table.concat(defaultsuffixes," ")) + end + end + for i=1,#names do + local fname = names[i] + if isfile(fname) then + if trace_files then + report_files("found local: %s",name) + end + fnd = fname + break end - fnd = name end if not fnd and backtrack then - local fname = name - for i=1,backtrack,1 do - fname = "../" .. fname - if isfile(fname) then - if trace_files then - report_files("found by backtracking: %s",fname) + for i=1,#names do + local fname = names[i] + for i=1,backtrack,1 do + fname = "../" .. fname + if isfile(fname) then + if trace_files then + report_files("found by backtracking: %s",fname) + end + fnd = fname + break + elseif trace_files then + report_files("not found by backtracking: %s",fname) end - fnd = fname + end + if fnd then break - elseif trace_files then - report_files("not found by backtracking: %s",fname) + end + end + end + if not fnd then + local paths = resolvers.instance.extra_paths + if paths then + for i=1,#paths do + for i=1,#names do + local fname = paths[i] .. "/" .. names[i] + if isfile(fname) then + if trace_files then + report_files("found on extra path: %s",name) + end + fnd = name + break + end + end + if fnd then + break + end end end end diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index 8a9fd6b47..13c9985fa 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -47,6 +47,8 @@ local contains = table.contains local concat, insert, remove = table.concat, table.insert, table.remove local todimen = string.todimen +local P = lpeg.P + local settings_to_array = utilities.parsers.settings_to_array local settings_to_hash = utilities.parsers.settings_to_hash local allocate = utilities.storage.allocate @@ -133,12 +135,12 @@ figures.defaultdepth = 0 figures.nofprocessed = 0 figures.preferquality = true -- quality over location -figures.existers = allocate() local existers = figures.existers -figures.checkers = allocate() local checkers = figures.checkers -figures.includers = allocate() local includers = figures.includers -figures.converters = allocate() local converters = figures.converters -figures.identifiers = allocate() local identifiers = figures.identifiers -figures.programs = allocate() local programs = figures.programs +local existers = allocate() figures.existers = existers +local checkers = allocate() figures.checkers = checkers +local includers = allocate() figures.includers = includers +local converters = allocate() figures.converters = converters +local identifiers = allocate() figures.identifiers = identifiers +local programs = allocate() figures.programs = programs figures.localpaths = allocate { ".", "..", "../.." @@ -150,13 +152,13 @@ figures.cachepaths = allocate { subpath = ".", } -figures.paths = allocate(table.copy(figures.localpaths)) +figures.paths = allocate(table.copy(figures.localpaths)) figures.order = allocate{ - "pdf", "mps", "jpg", "png", "jp2", "jbig", "svg", "eps", "tif", "gif", "mov", "buffer", "tex", "cld", + "pdf", "mps", "jpg", "png", "jp2", "jbig", "svg", "eps", "tif", "gif", "mov", "buffer", "tex", "cld", "auto", } -figures.formats = allocate{ +local formats = allocate { ["pdf"] = { list = { "pdf" } }, ["mps"] = { patterns = { "mps", "%d+" } }, ["jpg"] = { list = { "jpg", "jpeg" } }, @@ -171,13 +173,43 @@ figures.formats = allocate{ ["buffer"] = { list = { "tmp", "buffer", "buf" } }, ["tex"] = { list = { "tex" } }, ["cld"] = { list = { "cld" } }, + ["auto"] = { list = { "auto" } }, +} + +local magics = allocate { + { format = "png", pattern = P("\137PNG\013\010\026\010") }, -- 89 50 4E 47 0D 0A 1A 0A, + { format = "jpg", pattern = P("\255\216\255") }, -- FF D8 FF + { format = "jp2", pattern = P("\000\000\000\012\106\080\032\032\013\010"), }, -- 00 00 00 0C 6A 50 20 20 0D 0A }, + { format = "gif", pattern = P("GIF") }, + { format = "pdf", pattern = (1 - P("%PDF"))^0 * P("%PDF") }, } -function figures.setlookups() +figures.formats = formats -- frozen +figures.magics = magics -- frozen + +function figures.guess(filename) + local f = io.open(filename,'rb') + if f then + local str = f:read(100) + f:close() + for i=1,#magics do + local pattern = magics[i] + if pattern.pattern:match(str) then + local format = pattern.format + if trace_figures then + report_inclusion("file %q has format %s",filename,format) + end + return format + end + end + end +end + +function figures.setlookups() -- tobe redone .. just set locals local fs, fp = allocate(), allocate() figures.suffixes, figures.patterns = fs, fp for _, format in next, figures.order do - local data = figures.formats[format] + local data = formats[format] local list = data.list if list then for i=1,#list do @@ -204,10 +236,10 @@ function figures.registerresource(t) end local function register(tag,target,what) - local data = figures.formats[target] -- resolver etc + local data = formats[target] -- resolver etc if not data then data = { } - figures.formats[target] = data + formats[target] = data end local d = data[tag] -- list or pattern if d and not contains(d,what) then @@ -578,14 +610,14 @@ local function locate(request) -- name, format, cache end end if format then - local foundname, quitscanning = figures.exists(askedname,format,resolve_too) -- not askedformat + local foundname, quitscanning, forcedformat = figures.exists(askedname,format,resolve_too) -- not askedformat if foundname then return register(askedname, { askedname = askedname, fullname = foundname, -- askedname, - format = format, + format = forcedformat or format, cache = askedcache, ---~ foundname = foundname, + -- foundname = foundname, -- no conversion = askedconversion, resolution = askedresolution, }) @@ -597,12 +629,12 @@ local function locate(request) -- name, format, cache end if askedpath then -- path and type given, todo: strip pieces of path - local foundname = figures.exists(askedname,askedformat,resolve_too) + local foundname, quitscanning, forcedformat = figures.exists(askedname,askedformat,resolve_too) if foundname then return register(askedname, { askedname = askedname, fullname = foundname, -- askedname, - format = askedformat, + format = forcedformat or askedformat, cache = askedcache, conversion = askedconversion, resolution = askedresolution, @@ -616,7 +648,8 @@ local function locate(request) -- name, format, cache local check = path .. "/" .. askedname -- we pass 'true' as it can be an url as well, as the type -- is given we don't waste much time - if figures.exists(check,askedformat,resolve_too) then + local foundname, quitscanning, forcedformat = figures.exists(check,askedformat,resolve_too) + if foundname then return register(check, { askedname = askedname, fullname = check, @@ -648,16 +681,16 @@ local function locate(request) -- name, format, cache local figureorder = figures.order for i=1,#figureorder do local format = figureorder[i] - local list = figures.formats[format].list or { format } + local list = formats[format].list or { format } for j=1,#list do local suffix = list[j] local check = file.addsuffix(askedname,suffix) - local foundname = figures.exists(check,format,resolve_too) + local foundname, quitscanning, forcedformat = figures.exists(check,format,resolve_too) if foundname then return register(askedname, { askedname = askedname, fullname = foundname, -- check, - format = format, + format = forcedformat or format, cache = askedcache, conversion = askedconversion, resolution = askedresolution, @@ -674,7 +707,7 @@ local function locate(request) -- name, format, cache local figureorder = figures.order for j=1,#figureorder do local format = figureorder[j] - local list = figures.formats[format].list or { format } + local list = formats[format].list or { format } for k=1,#list do local suffix = list[k] -- local name = file.replacesuffix(askedbase,suffix) @@ -688,12 +721,12 @@ local function locate(request) -- name, format, cache report_inclusion("warning: skipping path %s",path) end else - local foundname = figures.exists(check,format,true) + local foundname, quitscanning, forcedformat = figures.exists(check,format,true) if foundname then return register(askedname, { askedname = askedname, fullname = foundname, -- check - format = format, + format = forcedformat or format, cache = askedcache, conversion = askedconversion, resolution = askedresolution, @@ -713,16 +746,16 @@ local function locate(request) -- name, format, cache local path = figurepaths[i] for j=1,#figureorder do local format = figureorder[j] - local list = figures.formats[format].list or { format } + local list = formats[format].list or { format } for k=1,#list do local suffix = list[k] local check = path .. "/" .. file.replacesuffix(askedbase,suffix) - local foundname = figures.exists(check,format,resolve_too) + local foundname, quitscanning, forcedformat = figures.exists(check,format,resolve_too) if foundname then return register(askedname, { askedname = askedname, fullname = foudname, -- check, - format = format, + format = forcedformat or format, cache = askedcache, conversion = askedconversion, resolution = askedresolution, @@ -739,7 +772,7 @@ local function locate(request) -- name, format, cache local figureorder = figures.order for j=1,#figureorder do local format = figureorder[j] - local list = figures.formats[format].list or { format } + local list = formats[format].list or { format } for k=1,#list do local suffix = list[k] local check = resolvers.findfile(file.replacesuffix(askedname,suffix)) @@ -1064,6 +1097,17 @@ end includers.buffers = includers.nongeneric +-- -- -- auto -- -- -- + +function existers.auto(askedname) + local name = file.nameonly(askedname) + local format = figures.guess(name) + return format and name, true, format +end + +checkers.auto = checkers.generic +includers.auto = includers.generic + -- -- -- cld -- -- -- existers.cld = existers.tex diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv index cdf73b612..6f9545ec0 100644 --- a/tex/context/base/mult-sys.mkiv +++ b/tex/context/base/mult-sys.mkiv @@ -381,7 +381,6 @@ \definesystemconstant {bp} \definesystemconstant {in} \definesystemconstant {pc} -\definesystemconstant {cm} \definesystemconstant {dd} \definesystemconstant {cc} \definesystemconstant {nd} @@ -464,7 +463,6 @@ \definesystemvariable {bp} % BreakPoint \definesystemvariable {bx} % BackendExport \definesystemvariable {cb} % CollectBox -\definesystemvariable {cm} % CheMical \definesystemvariable {cp} % CliP \definesystemvariable {da} % DAte \definesystemvariable {db} % Labels diff --git a/tex/context/base/pack-bck.mkvi b/tex/context/base/pack-bck.mkvi index 38750f590..fbe704fab 100644 --- a/tex/context/base/pack-bck.mkvi +++ b/tex/context/base/pack-bck.mkvi @@ -97,7 +97,7 @@ \let\pack_backgrounds_stop\relax -\unexpanded\def\pack_backgrounds_stop_indeed +\unexpanded\def\pack_backgrounds_stop_indeed % we shoul duse the fast background variant of framed {\endgraf \removelastskip \egroup @@ -199,17 +199,21 @@ \setupbackground [\c!leftoffset=.5\bodyfontsize, \c!rightoffset=\backgroundparameter\c!leftoffset, - \c!topoffset=\!!zeropoint, + \c!topoffset=\zeropoint, \c!bottomoffset=\backgroundparameter\c!topoffset, \c!state=\v!start, \c!radius=.5\bodyfontsize, \c!corner=\v!rectangular, \c!frame=\v!off, - \c!color=, - \c!depth=\!!zeropoint, - \c!background=\v!screen, - \c!backgroundcolor=\backgroundparameter\c!color, - \c!screen=\@@rsscreen, + \c!depth=\zeropoint, +% \c!color=, +% \c!background=\v!screen, +% \c!backgroundcolor=\backgroundparameter\c!color, +% \c!screen=\@@rsscreen, +% + \c!background=\v!color, + \c!backgroundcolor=lightgray, +% \c!before=, \c!after=] diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv index d7e41dd70..1f4ddbfc9 100644 --- a/tex/context/base/pack-rul.mkiv +++ b/tex/context/base/pack-rul.mkiv @@ -523,12 +523,12 @@ \newtoks\everybackgroundbox -\let\currentbackground\empty +\let\m_framed_background\empty % we might need a public name \def\pack_framed_process_background - {\ifcsname\??overlaybuiltin\currentbackground\endcsname + {\ifcsname\??overlaybuiltin\m_framed_background\endcsname \pack_framed_process_background_indeed_internal - \else\ifcsname\??overlay\currentbackground\endcsname + \else\ifcsname\??overlay\m_framed_background\endcsname \pack_framed_process_background_indeed_external \fi\fi} @@ -536,10 +536,10 @@ {\bgroup \setbox\b_framed_extra\hbox{%\bgroup \ifzeropt\framedbackgroundoffset - \csname\??overlaybuiltin\currentbackground\endcsname + \csname\??overlaybuiltin\m_framed_background\endcsname \else \kern-\framedbackgroundoffset - \hbox{\csname\??overlaybuiltin\currentbackground\endcsname}% + \hbox{\csname\??overlaybuiltin\m_framed_background\endcsname}% \fi }%\egroup \wd\b_framed_extra\zeropoint @@ -553,10 +553,10 @@ \bgroup \setbox\b_framed_extra\hbox{%\bgroup \ifzeropt\framedbackgroundoffset - \csname\??overlay\currentbackground\endcsname + \csname\??overlay\m_framed_background\endcsname \else \kern-\framedbackgroundoffset - \hbox{\csname\??overlay\currentbackground\endcsname}% + \hbox{\csname\??overlay\m_framed_background\endcsname}% \fi }%\egroup \wd\b_framed_extra\zeropoint @@ -566,8 +566,8 @@ \egroup} \def\pack_framed_process_backgrounds#1,#2% #2 gobbles spaces (we could avoid one catch if we have nextbackground) - {\edef\currentbackground{#1}% - \ifx\currentbackground\s!unknown\else + {\edef\m_framed_background{#1}% + \ifx\m_framed_background\s!unknown\else \pack_framed_process_background \expandafter\pack_framed_process_backgrounds \fi#2} diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 1bb5ecfc7..6fd8cf78d 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 ca099cd41..b6509bee6 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 a94080378..5887667ee 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -1323,7 +1323,7 @@ return { { filename = "chem-str", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "typo-scr", diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index ad962eb88..5389102fe 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 : 05/25/12 18:21:28 +-- merge date : 05/26/12 16:40:14 do -- begin closure to overcome local limits and interference |