diff options
author | Marius <mariausol@gmail.com> | 2012-06-08 12:20:13 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2012-06-08 12:20:13 +0300 |
commit | 13f840f6ff972c4065f4ddf98f5f299f1fe566de (patch) | |
tree | d53451e983950d55313c2ec079fa2ef29a38202e | |
parent | 901949f2e0eddb33046bc7628f831560cc380001 (diff) | |
download | context-13f840f6ff972c4065f4ddf98f5f299f1fe566de.tar.gz |
beta 2012.06.08 10:07
-rw-r--r-- | scripts/context/lua/mtx-epub.lua | 37 | ||||
-rw-r--r-- | tex/context/base/back-exp.lua | 5 | ||||
-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 | 4147 -> 4141 bytes | |||
-rw-r--r-- | tex/context/base/context-version.png | bin | 106124 -> 105215 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/font-ott.lua | 61 | ||||
-rw-r--r-- | tex/context/base/m-spreadsheet.lua | 161 | ||||
-rw-r--r-- | tex/context/base/m-spreadsheet.mkiv | 142 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24431 -> 24391 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 181186 -> 181114 bytes | |||
-rw-r--r-- | tex/context/base/tabl-tbl.mkiv | 4 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
15 files changed, 231 insertions, 189 deletions
diff --git a/scripts/context/lua/mtx-epub.lua b/scripts/context/lua/mtx-epub.lua index 000ac0670..88e31ceee 100644 --- a/scripts/context/lua/mtx-epub.lua +++ b/scripts/context/lua/mtx-epub.lua @@ -11,8 +11,8 @@ if not modules then modules = { } end modules ['mtx-epub'] = { -- really an id but has some special property). Then there is this ncx suffix -- thing. Somehow it give the impression of a reversed engineered application -- format so it will probably take a few cycles to let it become a real --- clean standard. Thanks to Adam Reviczky for helping to figure out all these --- puzzling details. +-- clean standard. Thanks to Adam Reviczky, Luigi Scarso and Andy Thomas for +-- helping to figure out all the puzzling details. -- This is preliminary code. At some point we will deal with images as well but -- first we need a decent strategy to export them. More information will be @@ -43,25 +43,25 @@ scripts.epub = scripts.epub or { } local mimetype = "application/epub+zip" local container = [[ -<?xml version="1.0" encoding="UTF-8" ?> +<?xml version="1.0" encoding="UTF-8"?> <container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> <rootfiles> - <rootfile full-path="OPS/%s" media-type="application/oebps-package+xml"/> + <rootfile full-path="OEBPS/%s" media-type="application/oebps-package+xml"/> </rootfiles> </container> ]] local package = [[ -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> <package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="%s"> <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> - <dc:title>My Title</dc:title> - <dc:language>en</dc:language> - <dc:identifier id="%s" >urn:uuid:%s</dc:identifier> - <dc:creator opf:file-as="Self, My" opf:role="aut">MySelf</dc:creator> + <dc:title>%s</dc:title> + <dc:language>%s</dc:language> + <dc:identifier id="%s" opf:scheme="UUID">urn:uuid:%s</dc:identifier> + <dc:creator>%s</dc:creator> <dc:date>%s</dc:date> </metadata> @@ -76,7 +76,7 @@ local package = [[ </package> ]] -local item = [[ <item id='%s' href='%s' media-type='%s'/>]] +local item = [[ <item id="%s" href="%s" media-type="%s"/>]] local toc = [[ <?xml version="1.0"?> @@ -194,6 +194,9 @@ function scripts.epub.make() local files = specification.files or { file.addsuffix(filename,"xhtml") } local images = specification.images or { } local root = specification.root or files[1] + local language = specification.language or "en" + local creator = specification.author or "My Self" + local title = specification.title or "My Title" -- identifier = gsub(identifier,"[^a-zA-z0-9]","") @@ -208,7 +211,7 @@ function scripts.epub.make() application.report("creating paths in tree %s",epubpath) lfs.mkdir(epubpath) lfs.mkdir(file.join(epubpath,"META-INF")) - lfs.mkdir(file.join(epubpath,"OPS")) + lfs.mkdir(file.join(epubpath,"OEBPS")) local used = { } @@ -217,7 +220,7 @@ function scripts.epub.make() local mime = mimetypes[suffix] if mime then local idmaker = idmakers[suffix] or idmakers.default - local target = file.join(epubpath,"OPS",filename) + local target = file.join(epubpath,"OEBPS",filename) file.copy(filename,target) application.report("copying %s to %s",filename,target) used[#used+1] = format(item,idmaker(filename),filename,mime) @@ -253,13 +256,13 @@ function scripts.epub.make() local idmaker = idmakers[file.extname(root)] or idmakers.default container = format(container,epubroot) - package = format(package,identifier,identifier,os.uuid(),os.date("!%Y-%m-%dT%H:%M:%SZ"),concat(used,"\n"),idmaker(root)) - toc = format(toc,identifier,"title",root) + package = format(package,identifier,title,language,identifier,os.uuid(),creator,os.date("!%Y-%m-%dT%H:%M:%SZ"),concat(used,"\n"),idmaker(root)) + toc = format(toc,identifier,title,root) io.savedata(file.join(epubpath,"mimetype"),mimetype) io.savedata(file.join(epubpath,"META-INF","container.xml"),container) - io.savedata(file.join(epubpath,"OPS",epubroot),package) - io.savedata(file.join(epubpath,"OPS",epubtoc),toc) + io.savedata(file.join(epubpath,"OEBPS",epubroot),package) + io.savedata(file.join(epubpath,"OEBPS",epubtoc),toc) application.report("creating archive\n\n") @@ -272,7 +275,7 @@ function scripts.epub.make() local zipper = zippers[i] if os.execute(format(zipper.uncompressed,epubfile,"mimetype")) then os.execute(format(zipper.compressed,epubfile,"META-INF")) - os.execute(format(zipper.compressed,epubfile,"OPS")) + os.execute(format(zipper.compressed,epubfile,"OEBPS")) done = zipper.name break end 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 Binary files differindex 435109161..2e807d6bc 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 edd9c1c6d..655ba8d0a 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 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 Binary files differindex 9155dbeef..f41c2c98d 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 466493324..5ed908d42 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf 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 |