From eb24ffd0c9851ab316455bca04fd9b23afe226e9 Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 16 Oct 2012 00:00:15 +0300 Subject: beta 2012.10.15 22:38 --- tex/context/base/chem-str.lua | 27 ++++++---- tex/context/base/chem-str.mkiv | 57 +++++++++++++++++---- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4143 -> 4144 bytes tex/context/base/context-version.png | Bin 105861 -> 106760 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/file-job.lua | 21 ++++++++ tex/context/base/grph-inc.lua | 16 +++--- tex/context/base/m-graph.mkiv | 22 ++++++-- tex/context/base/mult-def.mkiv | 2 + tex/context/base/status-files.pdf | Bin 24580 -> 24573 bytes tex/context/base/status-lua.pdf | Bin 195370 -> 195374 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 15 files changed, 118 insertions(+), 37 deletions(-) (limited to 'tex') diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua index a794f5fe7..3c1b88123 100644 --- a/tex/context/base/chem-str.lua +++ b/tex/context/base/chem-str.lua @@ -55,6 +55,7 @@ local common_keys = { mid = "fixed", mids = "fixed", midz = "text", z = "text", rz = "text", mrz = "text", prz = "text", crz = "text", rt = "text", rtt = "text", rbt = "text", zt = "text", zn = "number", + zbt = "text", zbn = "number", ztt = "text", ztn = "number", mov = "transform", rot = "transform", adj = "transform", sub = "transform", off = "transform", } @@ -64,6 +65,7 @@ local front_keys = { sb = "line", msb = "line", psb = "line", r = "line", pr = "line", mr = "line", z = "text", mrz = "text", prz = "text", + zt = "text", zn = "number", } local one_keys = { @@ -86,15 +88,16 @@ local syntax = { one = { n = 1, max = 8, keys = one_keys, align = { --- z = { { "r", "r_b", "b", "l_b", "l", "l_t", "t", "r_t" } }, ---~ z = { { "r", "r", "b", "l", "l", "l", "t", "r" } }, + -- z = { { "r", "r_b", "b", "l_b", "l", "l_t", "t", "r_t" } }, + -- z = { { "r", "r", "b", "l", "l", "l", "t", "r" } }, } }, three = { n = 3, max = 3, keys = common_keys, align = { mrz = { { "r","b","l" }, { "b","l","t" }, { "l","t","r" }, { "t","r","b" } }, - rz = { { "r_t","r_b","l" }, { "r_b","l_b","t" }, { "l_b","l_t","r" }, { "l_t","r_t","b" } }, + rz = { { "auto","auto","auto" }, { "auto","auto","auto" }, { "auto","auto","auto" }, { "auto","auto","auto" } }, + -- rz = { { "r_t","r_b","l" }, { "r_b","l_b","t" }, { "l_b","l_t","r" }, { "l_t","r_t","b" } }, prz = { { "r","l","t" }, { "b","t","r" }, { "l","r","b" }, { "t","b","l" } }, } }, @@ -102,7 +105,8 @@ local syntax = { n = 4, max = 4, keys = common_keys, align = { mrz = { { "t","r","b","l" }, { "r","b","l","t" }, { "b","l","t","r" }, { "l","t","r","b" } }, - rz = { { "r_t","r_b","l_b","l_t" }, { "r_b","l_b","l_t","r_t" }, { "l_b","l_t","r_t","r_b" }, { "l_t","r_t","r_b","l_b" } }, + rz = { { "auto","auto","auto","auto" }, { "auto","auto","auto","auto" }, { "auto","auto","auto","auto" }, { "auto","auto","auto","auto" } }, + -- rz = { { "r_t","r_b","l_b","l_t" }, { "r_b","l_b","l_t","r_t" }, { "l_b","l_t","r_t","r_b" }, { "l_t","r_t","r_b","l_b" } }, prz = { { "r","b","l","t" }, { "b","l","t","r" }, { "l","t","r","b" }, { "t","r","b","l" } }, } }, @@ -110,7 +114,8 @@ local syntax = { n = 5, max = 5, keys = common_keys, align = { mrz = { { "t","r","b","b","l" }, { "r","b","l","l","t" }, { "b","l","t","r","r" }, { "l","t","r","r","b" } }, - rz = { { "r","r","b","l","t" }, { "b","b","l","t","r" }, { "l","l","t","r","b" }, { "t","t","r","b","l" } }, + rz = { { "auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto" } }, + -- rz = { { "r","r","b","l","t" }, { "b","b","l","t","r" }, { "l","l","t","r","b" }, { "t","t","r","b","l" } }, prz = { { "r","b","l","t","t" }, { "b","l","t","r","r" }, { "l","t","r","b","b" }, { "t","r","b","l","l" } }, } }, @@ -118,7 +123,8 @@ local syntax = { n = 6, max = 6, keys = common_keys, align = { mrz = { { "t","t","r","b","b","l" }, { "r","b","b","l","t","t" }, { "b","b","l","t","t","r" }, { "l","t","t","r","b","b" } }, - rz = { { "r","r","b","l","l","t" }, { "b","b","l","t","t","r" }, { "l","l","t","r","r","b" }, { "t","t","r","b","b","l" } }, + rz = { { "auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto" } }, + -- rz = { { "r","r","b","l","l","t" }, { "b","b","l","t","t","r" }, { "l","l","t","r","r","b" }, { "t","t","r","b","b","l" } }, prz = { { "r","b","l","l","t","r" }, { "b","l","t","t","r","b" }, { "l","t","r","r","b","l" }, { "t","r","b","b","l","t" } }, } }, @@ -126,7 +132,8 @@ local syntax = { n = 8, max = 8, keys = common_keys, align = { -- todo mrz = { { "t","r","r","b","b","l","l","t" }, { "r","b","b","l","l","t","t","r" }, { "b","l","l","t","t","r","r","b" }, { "l","t","t","r","r","b","b","l" } }, - rz = { { "r","r","b","b","l","l","t","t" }, { "b","b","l","l","t","t","r","r" }, { "l","l","t","t","r","r","b","b" }, { "t","t","r","r","b","b","l","l" } }, + rz = { { "auto","auto","auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto","auto","auto" } }, + -- rz = { { "r","r","b","b","l","l","t","t" }, { "b","b","l","l","t","t","r","r" }, { "l","l","t","t","r","r","b","b" }, { "t","t","r","r","b","b","l","l" } }, prz = { { "r","b","b","l","l","t","t","r" }, { "b","l","l","t","t","r","r","b" }, { "l","t","t","r","r","b","b","l" }, { "t","r","r","b","b","l","l","t" } }, } }, @@ -344,7 +351,8 @@ local function process(spec,text,n,rulethickness,rulecolor,offset) if not t then txt, t = fetch(txt) end if t then t = molecule(processor_tostring(t)) - m = m + 1 ; metacode[m] = format('chem_%s_zero("\\chemicaltext{%s}");',operation,t) + m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\chemicaltext{%s}");',operation,bonds,index,t) + -- m = m + 1 ; metacode[m] = format('chem_%s_zero("\\chemicaltext{%s}");',operation,t) end elseif index then local t = text @@ -455,7 +463,8 @@ function chemistry.start(settings) tostring(settings.axis == variables.on), tostring(width), tostring(height), tostring(offset) ) -- - variant, keys, bonds, stack, rot, pstack = "six", { }, 6, { }, 1, { } + -- variant, keys, bonds, stack, rot, pstack = "six", { }, 6, { }, 1, { } + variant, keys, bonds, stack, rot, pstack = "one", { }, 1, { }, 1, { } end function chemistry.stop() diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv index 121adf6fd..64e2679dc 100644 --- a/tex/context/base/chem-str.mkiv +++ b/tex/context/base/chem-str.mkiv @@ -28,24 +28,24 @@ % Here we use chemicalformula instead, so no longer a mix: % % \startchemicalformula -% \chemical{H_2}{top}{bottom} +% \chemical{2H_2}{top}{bottom} % \chemical{PLUS}{top}{bottom} -% \chemical{O}{top}{bottom} +% \chemical{O_2}{top}{bottom} % \chemical{GIVES}{top}{bottom} -% \chemical{H_2O}{top}{bottom} +% \chemical{2H_2O}{top}{bottom} % \stopchemicalformula % % \startchemicalformula -% \chemical{H_2} +% \chemical{2H_2} % \chemical{PLUS} -% \chemical{O} +% \chemical{O_2} % \chemical{GIVES} -% \chemical{H_2O} +% \chemical{2H_2O} % \stopchemicalformula % % The inline variant has only one argument: % -% \chemical{H_2,PLUS,O,GIVES,H_2O} +% \chemical{2H_2,PLUS,O_2,GIVES,2H_2O} % todo: seven | eight | frontsix | fontfive | carbon | newmans | chair @@ -456,12 +456,12 @@ \definechemicalsymbol[i:equilibrium] [\enspace\mathematics{\xrightpverleftarrow{}{}}\enspace] \definechemicalsymbol[i:mesomeric] [\enspace\mathematics{\xleftrightarrow{}{}}\enspace] \definechemicalsymbol[i:single] [\chemicalbondrule] -\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}] +\definechemicalsymbol[i:double] [\hbox{\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] +\definechemicalsymbol[i:triple] [\hbox{\chemicalbondrule\hskip-1em\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] \unexpanded\def\chemicalsinglebond {\chemicalsymbol[i:single]} -\unexpanded\def\chemicaldoublebond {\chemicalsymbol[i:tripple]} -\unexpanded\def\chemicaltriplebond {\chemicalsymbol[i:double]} +\unexpanded\def\chemicaldoublebond {\chemicalsymbol[i:double]} +\unexpanded\def\chemicaltriplebond {\chemicalsymbol[i:triple]} \unexpanded\def\chemicalgives {\chemicalsymbol[i:gives]} \unexpanded\def\chemicalmesomeric {\chemicalsymbol[i:mesomeric]} \unexpanded\def\chemicalequilibrium{\chemicalsymbol[i:equilibrium]} @@ -580,6 +580,41 @@ \def\chem_formula_top_indeed#1{\strut#1} \def\chem_formula_bot_indeed#1{\strut#1} +% Experimental: defaults might change. + +\definefloat + [\v!chemical] + [\v!chemicals] + +\setuplabeltext + [\v!chemical=] + +\setupfloat + [\v!chemical] + [\c!location=\v!here, + \c!inner=\hsize.8\textwidth\dontleavehmode, % brr + \c!align={\v!flushleft,\v!lohi}] + +\setupcaption + [\v!chemical] + [\c!location=\v!right, + \c!distance=\zeropoint, + \c!width=.2\textwidth, + \c!align=\v!flushright] + +% Can be used as for displayed math: \startplaceformula... to display a chemical formula +% or a chemical structure: +% +% \startplacechemical +% \startchemicalformula +% \chemical{2H_2} +% \chemical{PLUS} +% \chemical{O_2} +% \chemical{GIVES} +% \chemical{2H_2O} +% \stopchemicalformula +% \stopplacechemical + % gone: state option resolution offset (now frame offset) alternative \setupchemicalframed diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index de3436ac3..902ea5681 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.10.15 19:10} +\newcontextversion{2012.10.15 22:38} %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 c2651e60c..015cdcffc 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.10.15 19:10} +\newcontextversion{2012.10.15 22:38} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index 1468d8749..80f16daa8 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index 7c4fb75a0..10e66ac9c 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 6a61fca48..42ccf76d5 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.10.15 19:10} +\edef\contextversion{2012.10.15 22:38} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index d49877e41..bf7794936 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.10.15 19:10} +\edef\contextversion{2012.10.15 22:38} %D For those who want to use this: diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua index b62944abc..bced0b4d2 100644 --- a/tex/context/base/file-job.lua +++ b/tex/context/base/file-job.lua @@ -36,8 +36,10 @@ local basename = file.basename local addsuffix = file.addsuffix local removesuffix = file.removesuffix local dirname = file.dirname +local joinpath = file.join local is_qualified_path = file.is_qualified_path +local cleanpath = resolvers.cleanpath local inputstack = resolvers.inputstack local v_outer = variables.outer @@ -551,9 +553,28 @@ function resolvers.jobs.currentenvironment() return topofstack(v_environment) en local done = { } local tolerant = false -- too messy, mkii user with the wrong sructure should adapt +local function toppath() + local pathname = dirname(inputstack[#inputstack] or "") + if pathname == "" then + return "." + else + return pathname + end +end + +resolvers.toppath = topath + +resolvers.prefixes.toppath = function(str) + local fullname = cleanpath(joinpath(toppath(),str)) + return fullname +end + local function process(what,name) local depth = #typestack local process + -- + name = resolvers.resolve(name) + -- -- if not tolerant then -- okay, would be best but not compatible with mkii process = processors[currenttype][what] diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index 8ec319247..f8c9a5134 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -216,14 +216,16 @@ function figures.guess(filename) 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) + if str then + 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 - return format end end end diff --git a/tex/context/base/m-graph.mkiv b/tex/context/base/m-graph.mkiv index 45903e532..35f487775 100644 --- a/tex/context/base/m-graph.mkiv +++ b/tex/context/base/m-graph.mkiv @@ -18,9 +18,21 @@ \startluacode local format, gsub, find, match = string.format, string.gsub, string.find, string.match - local function strip(s) - s = gsub(s,"^([+-]*)0+(%d)","%1%2") - return format("\\times10^{%s}",s) + local simplify = true + + local function strip(n,e) + -- get rid of e(0) + e = gsub(e,"^[+-]*0+$","") + -- get rid of e(+*) + e = gsub(e,"^+","") + -- remove leading zeros + e = gsub(e,"^([+-]*)0+(%d)","%1%2") + if not simplify then + -- take it as it is + elseif n == "1" then + return format("10^{%s}",e) + end + return format("%s\\times10^{%s}",n,e) end function metapost.format_n(fmt,str) @@ -28,11 +40,11 @@ local initial, hasformat, final = match(fmt,"^(.-)(%%.-[%a])(.-)$") if hasformat then str = format(fmt,str) - str = gsub(str,"e(.-)$",strip) + str = gsub(str,"(.-)e(.-)$",strip) str = format("%s\\mathematics{%s}%s",initial,str,final) elseif not find(fmt,"%%") then str = format("%"..fmt,str) - str = gsub(str,"e(.-)$",strip) + str = gsub(str,"(.-)e(.-)$",strip) str = format("\\mathematics{%s}",str) end context(str) diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv index 4c145590d..0ee59d8c3 100644 --- a/tex/context/base/mult-def.mkiv +++ b/tex/context/base/mult-def.mkiv @@ -63,6 +63,8 @@ \def\v!shiftdown {shiftdown} \def\v!construction {construction} \def\v!unframed {unframed} +\def\v!chemical {chemical} +\def\v!chemicals {chemicals} \def\s!lcgreek {lcgreek} \def\s!ucgreek {ucgreek} diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 5b6dd8af6..8e80dfbbc 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 46a19e3b1..4e4cf0d81 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index d87f182f7..f9b122f85 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 : 10/15/12 19:10:22 +-- merge date : 10/15/12 22:38:49 do -- begin closure to overcome local limits and interference -- cgit v1.2.3