From faaa984b45c82f7345e0a8daf457685feae54dcc Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 14 Jun 2011 00:20:14 +0300 Subject: beta 2011.06.13 23:08 --- scripts/context/lua/mtx-context.lua | 5 +- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 4 +- tex/context/base/m-dimensions.lua | 398 ---------------------------- tex/context/base/m-dimensions.mkiv | 194 -------------- tex/context/base/phys-dim.lua | 383 ++++++++++++++++++++++++++ tex/context/base/phys-dim.mkiv | 277 +++++++++++++++++++ tex/context/base/status-files.pdf | Bin 23463 -> 23623 bytes tex/context/base/status-lua.pdf | Bin 155139 -> 155784 bytes tex/context/base/strc-sec.mkiv | 4 +- tex/context/base/supp-num.mkiv | 85 ------ tex/generic/context/luatex-fonts-merged.lua | 2 +- 14 files changed, 672 insertions(+), 686 deletions(-) delete mode 100644 tex/context/base/m-dimensions.lua delete mode 100644 tex/context/base/m-dimensions.mkiv create mode 100644 tex/context/base/phys-dim.lua create mode 100644 tex/context/base/phys-dim.mkiv diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 5645e4760..36c71e463 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -1219,7 +1219,8 @@ local persistent_runfiles = { } local special_runfiles = { - "-mpgraph*", "-mprun*", "-temp-*" +--~ "-mpgraph*", "-mprun*", "-temp-*" -- hm, wasn't this escaped? + "-mpgraph", "-mprun", "-temp-" } local function purge_file(dfile,cfile) @@ -1675,7 +1676,7 @@ elseif environment.argument("purge") then scripts.context.purge() elseif environment.argument("purgeall") then -- only when no filename given, supports --pattern - scripts.context.purge(true) + scripts.context.purge(true,nil,true) else application.help("basic") end diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 991bd8225..845dd7d30 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{2011.06.11 16:45} +\newcontextversion{2011.06.13 23:08} %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 62e80131f..ffe6a39f9 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{2011.06.11 16:45} +\newcontextversion{2011.06.13 23:08} %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.mkii b/tex/context/base/context.mkii index baef733f4..a04470313 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{2011.06.11 16:45} +\edef\contextversion{2011.06.13 23:08} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 5d39430ed..653ee6c64 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.06.11 16:45} +\edef\contextversion{2011.06.13 23:08} %D For those who want to use this: @@ -357,6 +357,8 @@ \loadmarkfile{math-dis} %loadmarkfile{math-lan} +\loadmarkfile{phys-dim} + \loadmarkfile{strc-mat} \loadmarkfile{chem-ini} diff --git a/tex/context/base/m-dimensions.lua b/tex/context/base/m-dimensions.lua deleted file mode 100644 index 19a3e9702..000000000 --- a/tex/context/base/m-dimensions.lua +++ /dev/null @@ -1,398 +0,0 @@ -if not modules then modules = { } end modules ['m-dimensions'] = { - version = 1.001, - comment = "companion to m-dimensions.mkiv", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", - copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files" -} - --- This is pretty old code that I found back, but let's give it a try --- in practice. It started out as m-units.lua but as we want to keep that --- module around we moved the code to the dimensions module. - -local P, C, Cc, Cs, matchlpeg = lpeg.P, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.match -local format = string.format -local appendlpeg = lpeg.append - -local mergetable, mergedtable, keys, loweredkeys = table.merge, table.merged, table.keys, table.loweredkeys - -local long_prefixes = { - Yocto = [[y]], -- 10^{-24} - Zepto = [[z]], -- 10^{-21} - Atto = [[a]], -- 10^{-18} - Femto = [[f]], -- 10^{-15} - Pico = [[p]], -- 10^{-12} - Nano = [[n]], -- 10^{-9} - Micro = [[\mu]],-- 10^{-6} - Milli = [[m]], -- 10^{-3} - Centi = [[c]], -- 10^{-2} - Deci = [[d]], -- 10^{-1} - - Deca = [[da]], -- 10^{1} - Hecto = [[h]], -- 10^{2} - Kilo = [[k]], -- 10^{3} - Mega = [[M]], -- 10^{6} - Giga = [[G]], -- 10^{9} - Tera = [[T]], -- 10^{12} - Peta = [[P]], -- 10^{15} - Exa = [[E]], -- 10^{18} - Zetta = [[Z]], -- 10^{21} - Yotta = [[Y]], -- 10^{24} - - Kibi = [[ki]], -- 2^{10} - Mebi = [[Mi]], -- 2^{20} - Gibi = [[Gi]], -- 2^{30} - Tebi = [[Ti]], -- 2^{40} - Pebi = [[Pi]], -- 2^{50} - - Kibi = [[Ki]], -- binary - Mebi = [[Mi]], -- binary - Gibi = [[Gi]], -- binary - Tebi = [[Ti]], -- binary - Pebi = [[Pi]], -- binary - Exbi = [[Ei]], -- binary - Zebi = [[Zi]], -- binary - Yobi = [[Yi]], -- binary -} - -local long_units = { - Meter = [[m]], - Hertz = [[hz]], - Second = [[s]], - Hour = [[h]], - Liter = [[l]], - Litre = [[l]], - Gram = [[g]], - Newton = [[N]], - Pascal = [[Pa]], - Atom = [[u]], - Joule = [[W]], - Watt = [[J]], - Celsius = [[C]], -- no SI - Kelvin = [[K]], - Fahrenheit = [[F]], -- no SI - Mol = [[mol]], - Mole = [[mol]], - Equivalent = [[eql]], - Farad = [[F]], - Ohm = [[\Omega]], - Siemens = [[S]], - Ampere = [[A]], - Coulomb = [[C]], - Volt = [[V]], - eVolt = [[eV]], - Tesla = [[T]], - VoltAC = [[V\scientificunitbackspace\scientificunitlower{ac}]], - VoltDC = [[V\scientificunitbackspace\scientificunitlower{dc}]], - AC = [[V\scientificunitbackspace\scientificunitlower{ac}]], - DC = [[V\scientificunitbackspace\scientificunitlower{dc}]], - Bit = [[bit]], - Baud = [[Bd]], - Byte = [[B]], - Erlang = [[E]], - Bequerel = [[Bq]], - Sievert = [[Sv]], - Candela = [[cd]], - Bell = [[B]], - At = [[at]], - Atm = [[atm]], - Bar = [[bar]], - Foot = [[ft]], - Inch = [[inch]], - Cal = [[cal]], - Force = [[f]], - Lux = [[lux]], - Gray = [[Gr]], - Weber = [[Wb]], - Henry = [[H]], - Sterant = [[sr]], - Angstrom = [[Å]], - Gauss = [[G]], - Rad = [[rad]], - Deg = [[°]], - RPS = [[RPS]], - RPM = [[RPM]], - RevPerSec = [[RPS]], - RevPerMin = [[RPM]], - Percent = [[\percent]], - Promille = [[\promille]], -} - -local long_operators = { - Times = [[\scientificunitTIMES]], -- cdot - Solidus = [[\scientificunitSOLIDUS]], - Per = [[\scientificunitSOLIDUS]], - OutOf = [[\scientificunitOUTOF]], -} - -local long_suffixes = { - Linear = [[1]], - Square = [[2]], - Cubic = [[3]], - Inverse = [[-1]], - ILinear = [[-1]], - ISquare = [[-2]], - ICubic = [[-3]], -} - -mergetable(long_prefixes, loweredkeys(long_prefixes)) -mergetable(long_units, loweredkeys(long_units)) -mergetable(long_operators, loweredkeys(long_operators)) -mergetable(long_suffixes, loweredkeys(long_suffixes)) - -local short_prefixes = { - y = long_prefixes.Yocto, - z = long_prefixes.Zetto, - a = long_prefixes.Atto, - f = long_prefixes.Femto, - p = long_prefixes.Pico, - n = long_prefixes.Nano, - u = long_prefixes.Micro, - m = long_prefixes.Milli, - c = long_prefixes.Centi, - d = long_prefixes.Deci, - da = long_prefixes.Deca, - h = long_prefixes.Hecto, - k = long_prefixes.Kilo, - M = long_prefixes.Mega, - G = long_prefixes.Giga, - T = long_prefixes.Tera, - P = long_prefixes.Peta, - E = long_prefixes.Exa, - Z = long_prefixes.Zetta, - Y = long_prefixes.Yotta, -} - -local short_units = { - m = long_units.Meter, - hz = long_units.Hertz, - u = long_units.Hour, - h = long_units.Hour, - s = long_units.Second, -} - -local short_operators = { - ["."] = long_operators.Times, - ["*"] = long_operators.Times, - ["/"] = long_operators.Solidus, - [":"] = long_operators.OutOf, -} - -local short_suffixes = { -- maybe just raw digit match - ["1"] = long_suffixes.Linear, - ["2"] = long_suffixes.Square, - ["3"] = long_suffixes.Cubic, - ["+1"] = long_suffixes.Linear, - ["+2"] = long_suffixes.Square, - ["+3"] = long_suffixes.Cubic, - ["-1"] = long_suffixes.Inverse, - ["-1"] = long_suffixes.ILinear, - ["-2"] = long_suffixes.ISquare, - ["-3"] = long_suffixes.ICubic, - ["^1"] = long_suffixes.Linear, - ["^2"] = long_suffixes.Square, - ["^3"] = long_suffixes.Cubic, - ["^+1"] = long_suffixes.Linear, - ["^+2"] = long_suffixes.Square, - ["^+3"] = long_suffixes.Cubic, - ["^-1"] = long_suffixes.Inverse, - ["^-1"] = long_suffixes.ILinear, - ["^-2"] = long_suffixes.ISquare, - ["^-3"] = long_suffixes.ICubic, -} - -local prefixes = mergedtable(long_prefixes,short_prefixes) -local units = mergedtable(long_units,short_units) -local operators = mergedtable(long_operators,short_operators) -local suffixes = mergedtable(long_suffixes,short_suffixes) - -local space = P(" ")^0/"" - -local l_prefix = appendlpeg(keys(long_prefixes)) -local l_unit = appendlpeg(keys(long_units)) -local l_operator = appendlpeg(keys(long_operators)) -local l_suffix = appendlpeg(keys(long_suffixes)) - -local s_prefix = appendlpeg(keys(short_prefixes)) -local s_unit = appendlpeg(keys(short_units)) -local s_operator = appendlpeg(keys(short_operators)) -local s_suffix = appendlpeg(keys(short_suffixes)) - --- space inside Cs else funny captures and args to function - --- square centi meter per square kilo seconds - -local l_suffix = Cs(space * l_suffix) -local s_suffix = Cs(space * s_suffix) + Cc("") -local l_operator = Cs(space * l_operator) -local l_combination = (Cs(space * l_prefix) + Cc("")) * Cs(space * l_unit) -local s_combination = Cs(space * s_prefix) * Cs(space * s_unit) + Cc("") * Cs(space * s_unit) - -local combination = l_combination + s_combination - --- square kilo meter --- square km - -local function dimpus(p,u,s) - p = prefixes[p] or p - u = units[u] or u - s = suffixes[s] or s - if p ~= "" then - if u ~= "" then - if s ~= "" then - return format(" p=%s u=%s s=%s ",p,u,s) - else - return format(" p=%s u=%s ",p,u) - end - elseif s ~= "" then - return format(" p=%s s=%s ",p,s) - else - return format(" p=%s ",p) - end - else - if u ~= "" then - if s ~= "" then - return format(" u=%s s=%s ",u,s) - else - return format(" u=%s ",u) - end - elseif s ~= "" then - return format(" s=%s ",s) - else - return format(" p=%s ",p) - end - end -end - -local function dimop(o) - o = operators[o] or o - if o then - return format(" o=%s ",o) - end -end - -local function dimnum(n) - if n ~= "" then - return format(" n=%s ",n) - end -end - -local function dimerror(s) - return s ~= "" and s or "error" -end - -local dimension = - (l_suffix * combination) / function (s,p,u) - return dimpus(p,u,s) - end - + (combination * s_suffix) / function (p,u,s) - return dimpus(p,u,s) - end - -local operator = (l_operator + s_operator) / function(o) - return dimop(o) -end - -local number = (lpeg.patterns.number / function(n) - return dimnum(n) -end)^-1 - -dimension = space * dimension * space -number = space * number * space -operator = space * operator * space - -local expression = lpeg.Cs ( - number * dimension * dimension^0 * (operator * dimension^1)^-1 * P(-1) - + (P(1)^0) / function(s) return dimerror(s) end -) - -if commands and context then - - local scientificunitPUS = context.scientificunitPUS - local scientificunitPU = context.scientificunitPU - local scientificunitPS = context.scientificunitPS - local scientificunitP = context.scientificunitP - local scientificunitUS = context.scientificunitUS - local scientificunitU = context.scientificunitU - local scientificunitS = context.scientificunitS - local scientificunitO = context.scientificunitO - local scientificunitN = context.scientificunitN - - dimpus = function(p,u,s) - p = prefixes[p] or p - u = units[u] or u - s = suffixes[s] or s - if p ~= "" then - if u ~= "" then - if s ~= "" then - scientificunitPUS(p,u,s) - else - scientificunitPU(p,u) - end - elseif s ~= "" then - scientificunitPS(p,s) - else - scientificunitP(p) - end - else - if u ~= "" then - if s ~= "" then - scientificunitUS(u,s) - else - scientificunitU(u) - end - elseif s ~= "" then - scientificunitS(s) - else - scientificunitP(p) - end - end - end - - dimop = function(o) - o = operators[o] or o - if o then - scientificunitO(o) - end - end - - dimnum = function(n) - if n ~= "" then - scientificunitN(n) - end - end - - dimerror = function(s) - scientificunitU(s) - end - - function commands.scientificunit(str) - matchlpeg(expression,str) - end - -else - - local tests = { ---~ "m/u", ---~ "km/u", ---~ "km", ---~ "km/s2", ---~ "km/ms2", ---~ "km/ms-2", ---~ "km/h", ---~ " meter ", ---~ " meter per meter", ---~ "cubic meter per square meter", ---~ "cubic kilo meter per square meter", ---~ "KiloMeter/Hour", ---~ "10.5 kilo pascal", ---~ "kilo pascal meter liter per second", ---~ "100 crap", - } - - for i=1,#tests do - local test = tests[i] - print(test,matchlpeg(expression,test) or test) - end - -end diff --git a/tex/context/base/m-dimensions.mkiv b/tex/context/base/m-dimensions.mkiv deleted file mode 100644 index 2e4495e82..000000000 --- a/tex/context/base/m-dimensions.mkiv +++ /dev/null @@ -1,194 +0,0 @@ -%D \module -%D [ file=m-dimensions, -%D version=1997.03.19, -%D title=\CONTEXT\ Extra Modules, -%D subtitle=Scientific Units, -%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. - -\unprotect - -\registerctxluafile{m-dimensions}{} - -\startmodule[dimensions] - -%D \macros -%D {su} -%D -%D We have been using the units module (and its predecessor) for over a decade -%D now but when we moved on to \LUATEX\ a variant was prototyped that permits a -%D less texie coding. I finally picked up that thread and cleaned up the code a -%D bit so users can now play with it. (The main reason was that I wanted to -%D test exporting.) -%D -%D \startbuffer -%D \su{10 km/h} -%D 10\su{km/h} -%D 10 \su{km/h} -%D $10\su{km/h}$ -%D $10 \su{km/h}$ -%D 10 \su{KiloMeter/Hour} -%D 10 \su{kilometer/hour} -%D 10 \su{km/h} -%D 10 \su{kilometer per hour} -%D 10 \su{km / h} -%D 10 \su{ km / h } -%D 10 \su{km/ms2} -%D 10 \su{meter per second} -%D 10 \su{cubic meter} -%D 10 \su{cubic meter per second} -%D 10 \su{cubic meter / second} -%D $10 \su{cubic meter / second}$ -%D 30 \su{kilo pascal } -%D 30 \su{kilo pascal square meter / second} -%D 30 \su{kilo pascal square meter / second kelvin} -%D 30 \su{crap} -%D $ \frac{10 \su{m/s}}{20 \su{m/s}} $ -%D \stopbuffer -%D -%D \typebuffer -%D -%D Result: \getbuffer - -\newconstant \c_scientificunit_mode % 0=text 1=math -\newconstant \c_scientificunit_state % 0=start 1=suffix 2=operator 3=unit 4=prefix 5=number -\newconditional\c_scientificunit_number - -% tags and export -% smash == snapper -% hbox ook in mmode - -\def\scientificunithalfspace{\thinspace} -\def\scientificunitbackspace{\negthinspace} - -\newtoks \everyscientificunit % we keep the old \units command so we need a longer one - -\unexpanded\def\scientificunit#1% - {\begingroup - \the\everyscientificunit - \removeunwantedspaces - \ifmmode - \c_scientificunit_mode\plusone - \rm\tf - \mathtf - \fi - \scientificunit_indeed{#1}% - \scientificunit_finish - \endgroup} - -\appendtoks - \let\scientificunit\scientificunit_indeed -\to \everyscientificunit - -\let\su\scientificunit - -\appendtoks - \let\su\scientificunit_indeed -\to \everyscientificunit - -\unexpanded\def\scientificunit_indeed#1{\ctxcommand{scientificunit(\!!bs#1\!!es)}} - -\unexpanded\def\scientificunitPUS#1#2#3{\scientificunit_next#1#2\scientificunitraise{#3}\c_scientificunit_state\plusone} % suffix -\unexpanded\def\scientificunitPU #1#2{\scientificunit_next#1#2\c_scientificunit_state \plusthree} % unit -\unexpanded\def\scientificunitPS #1#2{\scientificunit_next#1\scientificunitraise{#2}\c_scientificunit_state \plusone} % suffix -\unexpanded\def\scientificunitUS #1#2{\scientificunit_next#1\scientificunitraise{#2}\c_scientificunit_state \plusone} % suffix -\unexpanded\def\scientificunitP #1{\scientificunit_next#1\c_scientificunit_state \plusfour} % prefix -\unexpanded\def\scientificunitU #1{\scientificunit_next#1\c_scientificunit_state \plusthree} % unit -\unexpanded\def\scientificunitS #1{\scientificunit_start{}\scientificunitraise{#1}\c_scientificunit_state \plusone} % suffix -\unexpanded\def\scientificunitO #1{\scientificunit_start#1\c_scientificunit_state \plustwo} % operator -\unexpanded\def\scientificunitN #1{\scientificunit_start#1\c_scientificunit_state \plusfive} % number - -\setelementnature[unit] [mixed] -\setelementnature[quantity][mixed] - -\unexpanded\def\scientificunitN#1% - {\ifmmode - #1% - \else - \dostarttagged{quantity}\empty - \dostarttagged{number}\empty - #1% - \dostoptagged - \settrue\c_scientificunit_number - \fi - %\scientificunit_start - \c_scientificunit_state\plusfive} - -\def\scientificunit_start - {\ifmmode - \dostarttagged\t!mathaction{unit}% - \bgroup % make an mrow - \else - \dostarttagged{unit}\empty - \fi - \let\scientificunit_finish\scientificunit_stop - \let\scientificunit_start\relax} - -\def\scientificunit_stop - {\ifmmode - \egroup - \fi - \ifconditional\c_scientificunit_number - \dostoptagged - \fi - \dostoptagged} - -\def\scientificunitraise - {\ifnum\c_scientificunit_mode=\plusone - \expandafter\normalsuperscript - \else - \expandafter\high - \fi} - -\def\scientificunitlower - {\ifnum\c_scientificunit_mode=\plusone - \expandafter\normalsubscript - \else - \expandafter\low - \fi} - -\unexpanded\def\scientificunit_next - {\ifcase\c_scientificunit_state % start - \scientificunithalfspace - \scientificunithalfspace - \or % suffix - {\cdot}% \scientificunithalfspace - \or % operator - \or % unit - {\cdot}% \scientificunithalfspace - \or % prefix - \or % number - \scientificunithalfspace - \scientificunithalfspace - \fi - \scientificunit_start} - -\unexpanded\def\scientificunitTIMES - {\ifnum\c_scientificunit_state=\plusone % suffix - \else - \scientificunithalfspace - \fi - \cdot} % or \times - -\unexpanded\def\scientificunitOUTOF - {\ifnum\c_scientificunit_state=\plusone % suffix - \else - \scientificunithalfspace - \fi - :} - -\unexpanded\def\scientificunitSOLIDUS - {\ifnum\c_scientificunit_state=\plusone % suffix - \scientificunitbackspace - \fi - {/}% - }%\scientificunitbackspace} - -\stopmodule - -\protect \endinput diff --git a/tex/context/base/phys-dim.lua b/tex/context/base/phys-dim.lua new file mode 100644 index 000000000..e27d48ffa --- /dev/null +++ b/tex/context/base/phys-dim.lua @@ -0,0 +1,383 @@ +if not modules then modules = { } end modules ['phys-dim'] = { + version = 1.001, + comment = "companion to phys-dim.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- This is pretty old code that I found back, but let's give it a try +-- in practice. It started out as m-units.lua but as we want to keep that +-- module around we moved the code to the dimensions module. +-- +-- todo: maybe also an sciunit command that converts to si units (1 inch -> 0.0254 m) +-- etc .. typical something to do when listening to a news whow or b-movie + +local P, S, R, C, Cc, Cs, matchlpeg = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.match +local format = string.format +local appendlpeg = lpeg.append + +local mergetable, mergedtable, keys, loweredkeys = table.merge, table.merged, table.keys, table.loweredkeys + +physics = physics or { } +physics.patterns = physics.patterns or { } + +-- digits parser (todo : use patterns) + +local done = false +local swap = false + +local digit = R("09") +local sign = S("+-") +local power = S("^e") +local digitspace = S("~@_") +local digitspacex = digitspace + P(" ") +local comma = P(",") +local period = P(".") +local signspace = P("/") +local positive = S("p") +local negative = S("n") +local highspace = P("s") +local padding = P("=") +local plus = P("+") +local minus = P("-") + +-- rename context.digitsspace -> digitsS +-- also have digitsN + + +-- move done to tex end + +local digits = (digit^1) + +local ddigitspacex = digitspacex / "" / context.digitsspace +local ddigitspace = digitspace / "" / context.digitsspace +local ddigit = digits / function(s) done = true context(s) end +local dseparator = comma / "" / function() if not done then context.digitsseparatorspace() elseif swap then context(".") else context(",") end end + + period / "" / function() if not done then context.digitsseparatorspace() elseif swap then context(",") else context(".") end end +local dsignspace = signspace / "" / context.digitssignspace +local dpositive = positive / "" / context.digitspositive +local dnegative = negative / "" / context.digitsnegative +local dhighspace = highspace / "" / context.digitshighspace +local dsomesign = plus / "" / context.digitsplus + + minus / "" / context.digitsminus +local dpower = power / "" * ( + plus * C(digits) / context.digitspowerplus + + minus * C(digits) / context.digitspowerminus + + C(digits) / context.digitspower + ) +local dpadding = padding / "" / context.digitszeropadding -- todo + +local digitparsernospace = + (dsomesign + dsignspace + dpositive + dnegative + dhighspace)^0 + * (dseparator^0 * (ddigitspacex + ddigit)^1)^1 + * dpower^0 + +local digitparser = + (dsomesign + dsignspace + dpositive + dnegative + dhighspace)^0 + * (dseparator^0 * (ddigitspace + ddigit)^1)^1 + * dpower^0 + +physics.patterns.digitparserspace = digitparserspace +physics.patterns.digitparser = digitparser + +function commands.digits(str) + done = false + -- swap = true + matchlpeg(digitparserspace,str) -- also space +end + +-- units parser + +local long_prefixes = { + Yocto = [[y]], -- 10^{-24} + Zepto = [[z]], -- 10^{-21} + Atto = [[a]], -- 10^{-18} + Femto = [[f]], -- 10^{-15} + Pico = [[p]], -- 10^{-12} + Nano = [[n]], -- 10^{-9} + Micro = [[\mu]],-- 10^{-6} + Milli = [[m]], -- 10^{-3} + Centi = [[c]], -- 10^{-2} + Deci = [[d]], -- 10^{-1} + + Deca = [[da]], -- 10^{1} + Hecto = [[h]], -- 10^{2} + Kilo = [[k]], -- 10^{3} + Mega = [[M]], -- 10^{6} + Giga = [[G]], -- 10^{9} + Tera = [[T]], -- 10^{12} + Peta = [[P]], -- 10^{15} + Exa = [[E]], -- 10^{18} + Zetta = [[Z]], -- 10^{21} + Yotta = [[Y]], -- 10^{24} + + Kibi = [[ki]], -- 2^{10} + Mebi = [[Mi]], -- 2^{20} + Gibi = [[Gi]], -- 2^{30} + Tebi = [[Ti]], -- 2^{40} + Pebi = [[Pi]], -- 2^{50} + + Kibi = [[Ki]], -- binary + Mebi = [[Mi]], -- binary + Gibi = [[Gi]], -- binary + Tebi = [[Ti]], -- binary + Pebi = [[Pi]], -- binary + Exbi = [[Ei]], -- binary + Zebi = [[Zi]], -- binary + Yobi = [[Yi]], -- binary +} + +local long_units = { + Meter = [[m]], + Hertz = [[hz]], + Second = [[s]], + Hour = [[h]], + Liter = [[l]], + Litre = [[l]], + Gram = [[g]], + Newton = [[N]], + Pascal = [[Pa]], + Atom = [[u]], + Joule = [[W]], + Watt = [[J]], + Celsius = [[C]], -- no SI + Kelvin = [[K]], + Fahrenheit = [[F]], -- no SI + Mol = [[mol]], + Mole = [[mol]], + Equivalent = [[eql]], + Farad = [[F]], + Ohm = [[\Omega]], + Siemens = [[S]], + Ampere = [[A]], + Coulomb = [[C]], + Volt = [[V]], + eVolt = [[eV]], + Tesla = [[T]], + VoltAC = [[V\unitsbackspace\unitslower{ac}]], + VoltDC = [[V\unitsbackspace\unitslower{dc}]], + AC = [[V\unitsbackspace\unitslower{ac}]], + DC = [[V\unitsbackspace\unitslower{dc}]], + Bit = [[bit]], + Baud = [[Bd]], + Byte = [[B]], + Erlang = [[E]], + Bequerel = [[Bq]], + Sievert = [[Sv]], + Candela = [[cd]], + Bell = [[B]], + At = [[at]], + Atm = [[atm]], + Bar = [[bar]], + Foot = [[ft]], + Inch = [[inch]], + Cal = [[cal]], + Force = [[f]], + Lux = [[lux]], + Gray = [[Gr]], + Weber = [[Wb]], + Henry = [[H]], + Sterant = [[sr]], + Angstrom = [[Å]], + Gauss = [[G]], + Rad = [[rad]], + Deg = [[°]], + RPS = [[RPS]], + RPM = [[RPM]], + RevPerSec = [[RPS]], + RevPerMin = [[RPM]], + Percent = [[\percent]], + Promille = [[\promille]], +} + +local long_operators = { + Times = [[\unitsTIMES]], -- cdot + Solidus = [[\unitsSOLIDUS]], + Per = [[\unitsSOLIDUS]], + OutOf = [[\unitsOUTOF]], +} + +local long_suffixes = { + Linear = [[1]], + Square = [[2]], + Cubic = [[3]], + Inverse = [[-1]], + ILinear = [[-1]], + ISquare = [[-2]], + ICubic = [[-3]], +} + +mergetable(long_prefixes, loweredkeys(long_prefixes)) +mergetable(long_units, loweredkeys(long_units)) +mergetable(long_operators, loweredkeys(long_operators)) +mergetable(long_suffixes, loweredkeys(long_suffixes)) + +local short_prefixes = { + y = long_prefixes.Yocto, + z = long_prefixes.Zetto, + a = long_prefixes.Atto, + f = long_prefixes.Femto, + p = long_prefixes.Pico, + n = long_prefixes.Nano, + u = long_prefixes.Micro, + m = long_prefixes.Milli, + c = long_prefixes.Centi, + d = long_prefixes.Deci, + da = long_prefixes.Deca, + h = long_prefixes.Hecto, + k = long_prefixes.Kilo, + M = long_prefixes.Mega, + G = long_prefixes.Giga, + T = long_prefixes.Tera, + P = long_prefixes.Peta, + E = long_prefixes.Exa, + Z = long_prefixes.Zetta, + Y = long_prefixes.Yotta, +} + +local short_units = { + m = long_units.Meter, + hz = long_units.Hertz, + u = long_units.Hour, + h = long_units.Hour, + s = long_units.Second, +} + +local short_operators = { + ["."] = long_operators.Times, + ["*"] = long_operators.Times, + ["/"] = long_operators.Solidus, + [":"] = long_operators.OutOf, +} + +local short_suffixes = { -- maybe just raw digit match + ["1"] = long_suffixes.Linear, + ["2"] = long_suffixes.Square, + ["3"] = long_suffixes.Cubic, + ["+1"] = long_suffixes.Linear, + ["+2"] = long_suffixes.Square, + ["+3"] = long_suffixes.Cubic, + ["-1"] = long_suffixes.Inverse, + ["-1"] = long_suffixes.ILinear, + ["-2"] = long_suffixes.ISquare, + ["-3"] = long_suffixes.ICubic, + ["^1"] = long_suffixes.Linear, + ["^2"] = long_suffixes.Square, + ["^3"] = long_suffixes.Cubic, + ["^+1"] = long_suffixes.Linear, + ["^+2"] = long_suffixes.Square, + ["^+3"] = long_suffixes.Cubic, + ["^-1"] = long_suffixes.Inverse, + ["^-1"] = long_suffixes.ILinear, + ["^-2"] = long_suffixes.ISquare, + ["^-3"] = long_suffixes.ICubic, +} + +local prefixes = mergedtable(long_prefixes,short_prefixes) +local units = mergedtable(long_units,short_units) +local operators = mergedtable(long_operators,short_operators) +local suffixes = mergedtable(long_suffixes,short_suffixes) + +local somespace = P(" ")^0/"" + +local l_prefix = appendlpeg(keys(long_prefixes)) +local l_unit = appendlpeg(keys(long_units)) +local l_operator = appendlpeg(keys(long_operators)) +local l_suffix = appendlpeg(keys(long_suffixes)) + +local s_prefix = appendlpeg(keys(short_prefixes)) +local s_unit = appendlpeg(keys(short_units)) +local s_operator = appendlpeg(keys(short_operators)) +local s_suffix = appendlpeg(keys(short_suffixes)) + +-- space inside Cs else funny captures and args to function + +-- square centi meter per square kilo seconds + +local l_suffix = Cs(somespace * l_suffix) +local s_suffix = Cs(somespace * s_suffix) + Cc("") +local l_operator = Cs(somespace * l_operator) +local l_combination = (Cs(somespace * l_prefix) + Cc("")) * Cs(somespace * l_unit) +local s_combination = Cs(somespace * s_prefix) * Cs(somespace * s_unit) + Cc("") * Cs(somespace * s_unit) + +local combination = l_combination + s_combination + +-- square kilo meter +-- square km + +local unitsPUS = context.unitsPUS +local unitsPU = context.unitsPU +local unitsPS = context.unitsPS +local unitsP = context.unitsP +local unitsUS = context.unitsUS +local unitsU = context.unitsU +local unitsS = context.unitsS +local unitsO = context.unitsO +local unitsN = context.unitsN +local unitsNstart = context.unitsNstart +local unitsNstop = context.unitsNstop + +local function dimpus(p,u,s) + p = prefixes[p] or p + u = units[u] or u + s = suffixes[s] or s + if p ~= "" then + if u ~= "" then + if s ~= "" then + unitsPUS(p,u,s) + else + unitsPU(p,u) + end + elseif s ~= "" then + unitsPS(p,s) + else + unitsP(p) + end + else + if u ~= "" then + if s ~= "" then + unitsUS(u,s) + else + unitsU(u) + end + elseif s ~= "" then + unitsS(s) + else + unitsP(p) + end + end +end + +local function dimspu(s,p,u) + return dimpus(p,u,s) +end + +local function dimop(o) + o = operators[o] or o + if o then + unitsO(o) + end +end + +local dimension = (l_suffix * combination) / dimspu + (combination * s_suffix) / dimpus +local number = lpeg.patterns.number / unitsN +local operator = (l_operator + s_operator) / dimop +local whatever = (P(1)^0) / unitsU + +dimension = somespace * dimension * somespace +number = somespace * number * somespace +operator = somespace * operator * somespace + +----- unitparser = dimension * dimension^0 * (operator * dimension^1)^-1 + whatever +local unitparser = dimension^1 * (operator * dimension^1)^-1 + whatever + +local unitdigitparser = (P(true)/unitsNstart) * digitparser * (P(true)/unitsNstop) +local combinedparser = (unitdigitparser + number)^-1 * unitparser + +physics.patterns.unitparser = unitparser +physics.patterns.combinedparser = combinedparser + +function commands.unit(str) + matchlpeg(combinedparser,str) +end diff --git a/tex/context/base/phys-dim.mkiv b/tex/context/base/phys-dim.mkiv new file mode 100644 index 000000000..5a44be53d --- /dev/null +++ b/tex/context/base/phys-dim.mkiv @@ -0,0 +1,277 @@ +%D \module +%D [ file=phys-dim, +%D version=2011-06-13, % was digits and units 1997.03.19, +%D title=\CONTEXT\ Physics, +%D subtitle=Digits and Units, +%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. + +\registerctxluafile{phys-dim}{} + +\unprotect + +% We will have +% +% \setupunits +% [alternative=text, % maybe no longer +% grid=yes, % snapper +% style=..., % +% space=...] % small medium big + +% digits code: + +%D \startbuffer +%D \digits{12} +%D \digits{~~~.~~~.~~~.68.712,34} +%D \digits{~~~.~~~.~~~.68.712,34} +%D \digits{___.___.111.68.712,34} +%D \digits{111.111.111.68.712,34} +%D \digits{12.345,90} +%D \digits{12.345.000} +%D \digits{12,34} +%D \digits{392.857.230.68.712,34} +%D \digits{1234} +%D \digits{123.222,00} +%D \digits{123.222,==} +%D \digits{123.222,00^10} +%D \digits{123.222,00e10} +%D \digits{-123.222,00e-12} +%D \digits{/123.222,00e-12} +%D \digits{+123.222,00e-12} +%D \digits{n123.222,00e-12} +%D \digits{s123.222,00e-12} +%D \digits{p123.222,00e/12} +%D %D \stopbuffer +%D +%D \typebuffer +%D +%D Result: \getbuffer + +% todo: ifmmode + +\def\digitsnormalized#1#2{{\setbox\scratchbox\hbox{#1}\hbox to \wd\scratchbox{\hss#2\hss}}} + +\def\digitsraised {\ifmmode\expandafter\normalsuperscript\else\expandafter\high\fi} + +\def\digitszeropadding {\zeroamount} +\def\digitsnegative {\digitsnormalized\zeroamount{\digitsraised{\textminus}}} % \mathematics \negative +\def\digitspositive {\digitsnormalized\zeroamount{\digitsraised{\textplus }}} % \mathematics \positive +\def\digitsnegative {\mathematics\negative} +\def\digitspositive {\mathematics\positive} +\def\digitsspace {\hphantom{0}} +\def\digitsseparatorspace{\hphantom{.}} +\def\digitssignspace {\hphantom{\digitsminus}} +\def\digitshighspace {\hphantom{\digitspositive}} +\def\digitspower {\digitsraised} +\def\digitspowerplus #1{\digitsraised{\digitsplus #1}} +\def\digitspowerminus #1{\digitsraised{\digitsminus#1}} +\def\digitsminus {\mathematics-} +\def\digitsplus {\mathematics+} + +% First I need to check the old supp-num code for compatibility. + +\unexpanded\def\tempdigits#1% for testing + {\dontleavehmode + \ctxcommand{digits(\!!bs\detokenize{#1}\!!es)}} + +%D \macros +%D {su} +%D +%D We have been using the units module (and its predecessor) for over a decade +%D now but when we moved on to \LUATEX\ a variant was prototyped that permits a +%D less texie coding. I finally picked up that thread and cleaned up the code a +%D bit so users can now play with it. (The main reason was that I wanted to +%D test exporting.) +%D +%D \startbuffer +%D 01: $10\su{km/h}$ +%D 02: $\su{10 km/h}$ +%D 03: \su{km/h} +%D 04: \su{10 km/h} +%D 05: \su{10 km/h} +%D 06: \su{~1 km/h} +%D 07: 10\su{km/h} +%D 08: 10 \su{km/h} +%D 09: $10 \su{km/h}$ +%D 10: 10 \su{KiloMeter/Hour} +%D 11: 10 \su{kilometer/hour} +%D 12: 10 \su{km/h} +%D 13: 10 \su{kilometer per hour} +%D 14: 10 \su{km / h} +%D 15: 10 \su{ km / h } +%D 16: 10 \su{km/ms2} +%D 17: 10 \su{meter per second} +%D 18: 10 \su{cubic meter} +%D 19: 10 \su{cubic meter per second} +%D 21: 10 \su{cubic meter / second} +%D 22: $10 \su{cubic meter / second}$ +%D 23: 30 \su{kilo pascal } +%D 24: 30 \su{kilo pascal square meter / second} +%D 25: 30 \su{kilo pascal square meter / kelvin second} +%D 26: \su{30 kilo pascal square meter / kelvin second} +%D 27: $30 \su{kilo pascal square meter / kelvin second }$ +%D 28: 30 \su{crap} +%D 29: 30 \su{AC} +%D 30: $\frac{10 \su{m/s}}{20 \su{m/s}} $ +%D 31: {\ss 30 \su{kilo pascal square meter / second kelvin}} +%D 32: \su{123.22^-3 km/s} +%D 33: \su{123.22e-3 km/s} +%D \stopbuffer +%D +%D \typebuffer +%D +%D Result: \getbuffer + +\newconstant \c_units_mode % 0=text 1=math +\newconstant \c_units_state % 0=start 1=suffix 2=operator 3=unit 4=prefix 5=number +\newconditional\c_units_number + +% tags and export +% smash == snapper +% hbox ook in mmode + +\def\unitshalfspace{\thinspace} +\def\unitsbackspace{\negthinspace} + +\newtoks \everyunits % we keep the old \units command so we need a longer one + +\unexpanded\def\unit#1% + {\begingroup + \the\everyunits + %\removeunwantedspaces % now ok yet + \ifmmode + \c_units_mode\plusone + \rm\tf + \mathtf + \fi + \units_indeed{#1}% + \units_finish + \endgroup} + +\appendtoks + \let\unit\units_indeed +\to \everyunits + +% bonus ... we might go for \un instead or maybe du (digit+unit) + +% \let\su\unit +% +% \appendtoks +% \let\su\units_indeed +% \to \everyunits + +\unexpanded\def\units_indeed#1{\ctxcommand{unit(\!!bs\detokenize{#1}\!!es)}} + +\unexpanded\def\unitsPUS#1#2#3{\units_next#1#2\unitsraise{#3}\c_units_state\plusone} % suffix +\unexpanded\def\unitsPU #1#2{\units_next#1#2\c_units_state \plusthree} % unit +\unexpanded\def\unitsPS #1#2{\units_next#1\unitsraise{#2}\c_units_state \plusone} % suffix +\unexpanded\def\unitsUS #1#2{\units_next#1\unitsraise{#2}\c_units_state \plusone} % suffix +\unexpanded\def\unitsP #1{\units_next#1\c_units_state \plusfour} % prefix +\unexpanded\def\unitsU #1{\units_next#1\c_units_state \plusthree} % unit +\unexpanded\def\unitsS #1{\units_start{}\unitsraise{#1}\c_units_state \plusone} % suffix +\unexpanded\def\unitsO #1{\units_start#1\c_units_state \plustwo} % operator +\unexpanded\def\unitsN #1{\units_start#1\c_units_state \plusfive} % number + +\setelementnature[unit] [mixed] +\setelementnature[quantity][mixed] + +\let\units_finish\relax + +\unexpanded\def\unitsNstart + {\ifmmode + \else + \dostarttagged{quantity}\empty + \dostarttagged{number}\empty + \fi} + +\unexpanded\def\unitsNstop + {\ifmmode + \else + \dostoptagged + \fi + %\units_start + \c_units_state\plusfive} + +\unexpanded\def\unitsN#1% + {\unitsNstart#1\unitsNstop} + +\def\units_start + {\ifmmode + \dostarttagged\t!mathaction{unit}% + \bgroup % make an mrow + \else + \dostarttagged{unit}\empty + \fi + \let\units_finish\units_stop + \let\units_start\relax} + +\def\units_stop + {\ifmmode + \egroup + \fi + \ifconditional\c_units_number + \dostoptagged + \fi + \dostoptagged} + +\def\unitsraise + {\ifnum\c_units_mode=\plusone + \expandafter\normalsuperscript + \else + \expandafter\high + \fi} + +\def\unitslower + {\ifnum\c_units_mode=\plusone + \expandafter\normalsubscript + \else + \expandafter\low + \fi} + +\unexpanded\def\units_next + {\ifcase\c_units_state % start + \ifdim\lastskip=\zeropoint + \unitshalfspace + \unitshalfspace + \else + % too tricky ... we could remove and add + \fi + \or % suffix + {\cdot}% \unitshalfspace + \or % operator + \or % unit + {\cdot}% \unitshalfspace + \or % prefix + \or % number + \unitshalfspace + \unitshalfspace + \fi + \units_start} + +\unexpanded\def\unitsTIMES + {\ifnum\c_units_state=\plusone % suffix + \else + \unitshalfspace + \fi + \cdot} % or \times + +\unexpanded\def\unitsOUTOF + {\ifnum\c_units_state=\plusone % suffix + \else + \unitshalfspace + \fi + :} + +\unexpanded\def\unitsSOLIDUS + {\ifnum\c_units_state=\plusone % suffix + \unitsbackspace + \fi + {/}% + }%\unitsbackspace} + +\protect \endinput diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 0f70d464e..732fb6c7c 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index eb731ba05..6cd2ece6f 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index c64d379ea..a36f549b1 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -702,12 +702,12 @@ \settrue\autoheadbreak % todo: \vspacing[category:8] == keep_together \def\dopreventbreakafterheadauto % used after \c!before - {\ifconditonal\autoheadbreak + {\ifconditional\autoheadbreak \vspacing[\v!samepage-\currentheadlevel]% \fi} \def\dopreventbreakafterheadspec#1% see enumerations etc - {\ifconditonal\autoheadbreak + {\ifconditional\autoheadbreak \vspacing[\v!samepage-\the\numexpr\currentheadlevel+1\relax]% todo #1 \fi} diff --git a/tex/context/base/supp-num.mkiv b/tex/context/base/supp-num.mkiv index 271e2588a..43b7fce9b 100644 --- a/tex/context/base/supp-num.mkiv +++ b/tex/context/base/supp-num.mkiv @@ -417,88 +417,3 @@ \fi\fi} \protect \endinput - - -\endinput - -\def\digitszeropadding {\zeroamount} -\def\digitsnegative {\mathematics\negative} -\def\digitspositive {\mathematics\positive} -\def\digitsspace {\hphantom{0}} -\def\digitsseparatorspace{\hphantom{.}} -\def\digitssignspace {\hphantom{+}} -\def\digitshighspace {\hphantom{\mathematics\positive}} -\def\digitspower {\high} - -\starttext - -% print(table.serialize(table.keys(jobs))) - -local P, S, R, Cs = lpeg.P, lpeg.S, lpeg.R, lpeg.Cs - -local done = false -local swap = false -local digit = R("09") -local sign = S("+-") -local power = S("^e") -local space = S(" ~@_") -local comma = P(",") -local period = P(".") -local signspace = P("/") -local positive = P("p") -local negative = P("n") -local highspace = P("s") -local padding = P("=") - -local space = space / "\\digitsspace" -local digit = digit / function(s) done = true return s end -local separator = comma / function(s) if not done then return "\\digitsseparatorspace" elseif swap then return "." else return "," end end - + period / function(s) if not done then return "\\digitsseparatorspace" elseif swap then return "," else return "." end end -local signspace = signspace / "\\digitssignspace" -local positive = positive / "\\digitspositive" -local negative = negative / "\\digitsnegative" -local highspace = highspace / "\\digitshighspace" -local power = power/"" * (Cs((sign + signspace)^0 * digit^1) / function(s) return "\\digitspower{" .. s .. "}" end) -local padding = padding / "\\digitszeropadding" - -local replace = lpeg.Cs ( - (sign + signspace + positive + negative + highspace)^0 - * (separator^0 * (space + digit)^1)^1 - * power^0 -) - -local function digits(str) - done = false ---~ swap = true - local str = lpeg.match(replace,str) --- print(str) - tex.sprint(tex.ctxcatcodes,"\\dontleavehmode",str,"\\par") -end --- namespaces.register("digits") - -digits("12") -digits("~~~.~~~.~~~.68.712,34") -digits("~~~.~~~.~~~.68.712,34") -digits("___.___.111.68.712,34") -digits("111.111.111.68.712,34") -digits("12.345,90") -digits("12.345.000") -digits("12,34") -digits("392.857.230.68.712,34") -digits("1234") -digits("123.222,00") -digits("123.222,==") -digits("123.222,00^10") -digits("123.222,00e10") -digits("/123.222,00e-12") -digits("-123.222,00e-12") --- digits("+123.222,00e-12") -digits("n123.222,00e-12") -digits("s123.222,00e-12") -digits("p123.222,00e/12") - -\stopluacode -[[\digitsseparatorspace]] -\stoptext - - diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 0cfbf2a0c..02177a09a 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 06/11/11 16:45:35 +-- merge date : 06/13/11 23:08:53 do -- begin closure to overcome local limits and interference -- cgit v1.2.3