From 13f840f6ff972c4065f4ddf98f5f299f1fe566de Mon Sep 17 00:00:00 2001 From: Marius Date: Fri, 8 Jun 2012 12:20:13 +0300 Subject: beta 2012.06.08 10:07 --- tex/context/base/back-exp.lua | 5 + tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4147 -> 4141 bytes tex/context/base/context-version.png | Bin 106124 -> 105215 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/font-ott.lua | 61 ++++---- tex/context/base/m-spreadsheet.lua | 161 +++++++++++++++++++++ tex/context/base/m-spreadsheet.mkiv | 142 +----------------- tex/context/base/status-files.pdf | Bin 24431 -> 24391 bytes tex/context/base/status-lua.pdf | Bin 181186 -> 181114 bytes tex/context/base/tabl-tbl.mkiv | 4 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 14 files changed, 211 insertions(+), 172 deletions(-) create mode 100644 tex/context/base/m-spreadsheet.lua (limited to 'tex') diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 3ce40a6c5..818f89e45 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -20,6 +20,7 @@ if not modules then modules = { } end modules ['back-exp'] = { local next, type = next, type local format, match, concat, rep, sub, gsub, gmatch, find = string.format, string.match, table.concat, string.rep, string.sub, string.gsub, string.gmatch, string.find +local validstring = string.valid local lpegmatch = lpeg.match local utfchar, utfbyte, utfsub, utfgsub = utf.char, utf.byte, utf.sub, utf.gsub local insert, remove = table.insert, table.remove @@ -2362,12 +2363,16 @@ local function stopexport(v) report_export("saving xhtml variant in '%s",xhtmlfile) local xmltree = cleanxhtmltree(xml.convert(results)) xml.save(xmltree,xhtmlfile) + local identity = interactions.general.getidentity() local specification = { name = file.removesuffix(v), identifier = os.uuid(), images = uniqueusedimages(), root = xhtmlfile, files = files, + language = languagenames[tex.count.mainlanguagenumber], + title = validstring(identity.title), + author = validstring(identity.author), } report_export("saving specification in '%s' (mtxrun --script epub --make %s)",specificationfilename,specificationfilename) io.savedata(specificationfilename,table.serialize(specification,true)) diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index a3e06dc9c..6fde41a34 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.06.07 18:39} +\newcontextversion{2012.06.08 10:07} %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 877476dfa..fe8415046 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.06.07 18:39} +\newcontextversion{2012.06.08 10:07} %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 index 435109161..2e807d6bc 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 edd9c1c6d..655ba8d0a 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 e99a9b930..29574a248 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.06.07 18:39} +\edef\contextversion{2012.06.08 10:07} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index d0f5084e7..5b8c6d55d 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.06.07 18:39} +\edef\contextversion{2012.06.08 10:07} %D For those who want to use this: diff --git a/tex/context/base/font-ott.lua b/tex/context/base/font-ott.lua index 6c671d76f..1e4bd69af 100644 --- a/tex/context/base/font-ott.lua +++ b/tex/context/base/font-ott.lua @@ -577,26 +577,26 @@ local features = allocate { ['size'] = 'optical size', ['smcp'] = 'small capitals', ['smpl'] = 'simplified forms', - ['ss01'] = 'stylistic set 1', - ['ss02'] = 'stylistic set 2', - ['ss03'] = 'stylistic set 3', - ['ss04'] = 'stylistic set 4', - ['ss05'] = 'stylistic set 5', - ['ss06'] = 'stylistic set 6', - ['ss07'] = 'stylistic set 7', - ['ss08'] = 'stylistic set 8', - ['ss09'] = 'stylistic set 9', - ['ss10'] = 'stylistic set 10', - ['ss11'] = 'stylistic set 11', - ['ss12'] = 'stylistic set 12', - ['ss13'] = 'stylistic set 13', - ['ss14'] = 'stylistic set 14', - ['ss15'] = 'stylistic set 15', - ['ss16'] = 'stylistic set 16', - ['ss17'] = 'stylistic set 17', - ['ss18'] = 'stylistic set 18', - ['ss19'] = 'stylistic set 19', - ['ss20'] = 'stylistic set 20', + -- ['ss01'] = 'stylistic set 1', + -- ['ss02'] = 'stylistic set 2', + -- ['ss03'] = 'stylistic set 3', + -- ['ss04'] = 'stylistic set 4', + -- ['ss05'] = 'stylistic set 5', + -- ['ss06'] = 'stylistic set 6', + -- ['ss07'] = 'stylistic set 7', + -- ['ss08'] = 'stylistic set 8', + -- ['ss09'] = 'stylistic set 9', + -- ['ss10'] = 'stylistic set 10', + -- ['ss11'] = 'stylistic set 11', + -- ['ss12'] = 'stylistic set 12', + -- ['ss13'] = 'stylistic set 13', + -- ['ss14'] = 'stylistic set 14', + -- ['ss15'] = 'stylistic set 15', + -- ['ss16'] = 'stylistic set 16', + -- ['ss17'] = 'stylistic set 17', + -- ['ss18'] = 'stylistic set 18', + -- ['ss19'] = 'stylistic set 19', + -- ['ss20'] = 'stylistic set 20', ['ssty'] = 'script style', -- math ['subs'] = 'subscript', ['sups'] = 'superscript', @@ -622,7 +622,13 @@ local features = allocate { ['trep'] = 'traditional tex replacements', ['tlig'] = 'traditional tex ligatures', - ['ss'] = 'stylistic set %s', + -- ['ss'] = 'stylistic set %s', + -- ['cv'] = 'character variant %s', + -- ['js'] = 'justification %s', + + ['ss..'] = 'stylistic set ..', + ['cv..'] = 'character variant ..', + ['js..'] = 'justification ..', } local baselines = allocate { @@ -750,7 +756,12 @@ local function resolve(t,k) if tag and dd then local v = rawget(t,tag) if v then - return format(v,tonumber(dd)) + return format(v,tonumber(dd)) -- old way + else + local v = rawget(t,tag.."..") -- nicer in overview + if v then + return (gsub(v,"%.%.",tonumber(dd))) -- new way + end end end end @@ -760,10 +771,10 @@ end setmetatableindex(features, resolve) local function assign(t,k,v) - if k then + if k and v then v = lower(v) - rawset(t,k,v) - rawset(features,gsub(v,"[^a-z0-9]",""),k) + rawset(t,k,v) -- rawset ? + -- rawset(features,gsub(v,"[^a-z0-9]",""),k) -- why ? old code end end diff --git a/tex/context/base/m-spreadsheet.lua b/tex/context/base/m-spreadsheet.lua new file mode 100644 index 000000000..7a74b594b --- /dev/null +++ b/tex/context/base/m-spreadsheet.lua @@ -0,0 +1,161 @@ +if not modules then modules = { } end modules ['m-spreadsheet'] = { + version = 1.001, + comment = "companion to m-spreadsheet.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local byte, format, gsub, validstring = string.byte, string.format, string.gsub, string.valid +local R, P, C, Cs, Cc, Carg, lpegmatch = lpeg.R, lpeg.P, lpeg.C, lpeg.Cs, lpeg.Cc, lpeg.Carg, lpeg.match + +local context = context + +moduledata = moduledata or { } + +local spreadsheets = { } +moduledata.spreadsheets = spreadsheets + +local data = { + -- nothing yet +} + +local settings = { + numberseparator = ".", +} + +spreadsheets.data = data +spreadsheets.settings = settings + +local stack, current = { }, "default" + +local mt ; mt = { + __index = function(t,k) + local v = { } + setmetatable(v,mt) + t[k] = v + return v + end, +} + +function spreadsheets.reset(name) + if not name or name == "" then name = "default" end + local d = { } + setmetatable(d,mt) + data[name] = d +end + +function spreadsheets.start(name) + if not name or name == "" then name = "default" end + table.insert(stack,current) + current = name + if not data[current] then + local d = { } + setmetatable(d,mt) + data[current] = d + end +end + +function spreadsheets.stop() + current = table.remove(stack) +end + +spreadsheets.reset() + +local offset = byte("A") - 1 + +local function assign(s,n) + return format("moduledata.spreadsheets.data['%s'][%s]",n,byte(s)-offset) +end + +-------- datacell(name,a,b,...) +function datacell(a,b,...) + local n = 0 + if b then + local t = { a, b, ... } + for i=1,#t do + n = n * (i-1) * 26 + byte(t[i]) - offset + end + else + n = byte(a) - offset + end + -- return format("dat['%s'][%s]",name,n) + return format("dat[%s]",n) +end + +----- cell = (Carg(1) * C(R("AZ"))^1) / datacell * (Cc("[") * (R("09")^1) * Cc("]") + #P(1)) +local cell = C(R("AZ"))^1 / datacell * (Cc("[") * (R("09")^1) * Cc("]") + #P(1)) +local pattern = Cs(Cc("return ") * (cell + P(1))^0) + +local functions = { } +spreadsheets.functions = functions + +function functions.sum(c,f,t) + if f and t then + local r = 0 + for i=f,t do + r = r + c[i] + end + return r + else + return 0 + end +end + +function functions.fmt(pattern,n) + return format("%"..pattern,n) +end + +local template = [[ + local spr = moduledata.spreadsheets.functions + local dat = moduledata.spreadsheets.data['%s'] + local sum = spr.sum + local fmt = spr.fmt + %s +]] + +local function execute(name,r,c,str) + if name == "" then name = current if name == "" then name = "default" end end + str = lpegmatch(pattern,str,1,name) + str = format(template,name,str) + -- print(str) + local result = loadstring(str) + result = result and result() or 0 + data[name][c][r] = result + return result +end + +function spreadsheets.set(name,r,c,str) + if name == "" then name = current if name == "" then name = "default" end end + execute(name,r,c,str) +end + +function spreadsheets.get(name,r,c,str) + if name == "" then name = current if name == "" then name = "default" end end + if not str or str == "" then + context(data[name][c][r] or 0) + else + local result = execute(name,r,c,str) + if result then + if type(result) == "number" then + data[name][c][r] = result + end + local numberseparator = validstring(settings.numberseparator,".") + if numberseparator ~= "." then + result = gsub(tostring(result),"%.",numberseparator) + end + context(result) + end + end +end + +function spreadsheets.doifelsecell(name,r,c) + if name == "" then name = current if name == "" then name = "default" end end + local d = data[name] + commands.testcase(d and d[c][r]) +end + +function spreadsheets.show(name) + if name == "" then name = current if name == "" then name = "default" end end + table.print(data[name],name) +end diff --git a/tex/context/base/m-spreadsheet.mkiv b/tex/context/base/m-spreadsheet.mkiv index 839214096..45e14ef39 100644 --- a/tex/context/base/m-spreadsheet.mkiv +++ b/tex/context/base/m-spreadsheet.mkiv @@ -13,145 +13,7 @@ %D This is an experimental follow up on discussion on the mailing list. -\startluacode -local byte, format = string.byte, string.format -local R, P, C, Cs, Cc, Carg, lpegmatch = lpeg.R, lpeg.P, lpeg.C, lpeg.Cs, lpeg.Cc, lpeg.Carg, lpeg.match - -local spreadsheets = { } -moduledata.spreadsheets = spreadsheets - -local data = { } -spreadsheets.data = data - -local stack, current = { }, "default" - -local mt ; mt = { - __index = function(t,k) - local v = { } - setmetatable(v,mt) - t[k] = v - return v - end, -} - -function spreadsheets.reset(name) - if not name or name == "" then name = "default" end - local d = { } - setmetatable(d,mt) - data[name] = d -end - -function spreadsheets.start(name) - if not name or name == "" then name = "default" end - table.insert(stack,current) - current = name - if not data[current] then - local d = { } - setmetatable(d,mt) - data[current] = d - end -end - -function spreadsheets.stop() - current = table.remove(stack) -end - -spreadsheets.reset() - -local offset = byte("A") - 1 - -local function assign(s,n) - return format("moduledata.spreadsheets.data['%s'][%s]",n,byte(s)-offset) -end - --------- datacell(name,a,b,...) -function datacell(a,b,...) - local n = 0 - if b then - local t = { a, b, ... } - for i=1,#t do - n = n * (i-1) * 26 + byte(t[i]) - offset - end - else - n = byte(a) - offset - end - -- return format("dat['%s'][%s]",name,n) - return format("dat[%s]",n) -end - ------ cell = (Carg(1) * C(R("AZ"))^1) / datacell * (Cc("[") * (R("09")^1) * Cc("]") + #P(1)) -local cell = C(R("AZ"))^1 / datacell * (Cc("[") * (R("09")^1) * Cc("]") + #P(1)) -local pattern = Cs(Cc("return ") * (cell + P(1))^0) - -local functions = { } -spreadsheets.functions = functions - -function functions.sum(c,f,t) - if f and t then - local r = 0 - for i=f,t do - r = r + c[i] - end - return r - else - return 0 - end -end - -function functions.fmt(pattern,n) - return format("%"..pattern,n) -end - -local template = [[ - local spr = moduledata.spreadsheets.functions - local dat = moduledata.spreadsheets.data['%s'] - local sum = spr.sum - local fmt = spr.fmt - %s -]] - -local function execute(name,r,c,str) - if name == "" then name = current if name == "" then name = "default" end end - str = lpegmatch(pattern,str,1,name) - str = format(template,name,str) - -- print(str) - local result = loadstring(str) - result = result and result() or 0 - data[name][c][r] = result - return result -end - -function spreadsheets.set(name,r,c,str) - if name == "" then name = current if name == "" then name = "default" end end - execute(name,r,c,str) -end - -function spreadsheets.get(name,r,c,str) - if name == "" then name = current if name == "" then name = "default" end end - if not str or str == "" then - context(data[name][c][r] or 0) - else - local result = execute(name,r,c,str) - if result then - if type(result) == "number" then - data[name][c][r] = result - end - context(result) - end - end -end - -function spreadsheets.doifelsecell(name,r,c) - if name == "" then name = current if name == "" then name = "default" end end - local d = data[name] - commands.testcase(d and d[c][r]) -end - -function spreadsheets.show(name) - if name == "" then name = current if name == "" then name = "default" end end - table.print(data[name],name) -end -\stopluacode +\registerctxluafile{m-spreadsheet}{1.001} \unprotect @@ -198,7 +60,7 @@ end \protect -\doifnotmode{demo}{\endinput} +\continueifinputfile{m-spreadsheet.mkiv} \starttext diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 9155dbeef..f41c2c98d 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 466493324..5ed908d42 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/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index 20ddac461..489287727 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -1904,10 +1904,10 @@ {\c_tabl_tabulate_pass\plusone \tabl_tabulate_check_full_content \edef\v_tabl_tabulate_align{\executeifdefined{\??tabulatealigning\p_align}0}% - \s_tabl_tabulate_post\zeropoint - \s_tabl_tabulate_pre\zeropoint \s_tabl_tabulate_first.5\d_tabl_tabulate_unit \s_tabl_tabulate_last\s_tabl_tabulate_first + \s_tabl_tabulate_pre\zeropoint + \s_tabl_tabulate_post\s_tabl_tabulate_first % was: \zeropoint \global\c_tabl_tabulate_columns\zerocount \global\c_tabl_tabulate_nofauto\zerocount \global\c_tabl_tabulate_noflines\zerocount diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index a51f460ae..ce772abe7 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 : 06/07/12 18:39:35 +-- merge date : 06/08/12 10:07:44 do -- begin closure to overcome local limits and interference -- cgit v1.2.3