diff options
author | Marius <mariausol@gmail.com> | 2012-06-11 01:40:15 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2012-06-11 01:40:15 +0300 |
commit | ddf4906882f4bea473964e5b0d209cc3a33bddef (patch) | |
tree | 6d7045186772c2186d2541fb3625b16bbf7246af | |
parent | a8d90ec17f9ba850721305edcf360407c3aae5b3 (diff) | |
download | context-ddf4906882f4bea473964e5b0d209cc3a33bddef.tar.gz |
beta 2012.06.11 00:21
-rw-r--r-- | scripts/context/lua/mtx-context.lua | 1 | ||||
-rw-r--r-- | scripts/context/lua/mtx-epub.lua | 53 | ||||
-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/cont-yes.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4139 -> 4141 bytes | |||
-rw-r--r-- | tex/context/base/context-version.png | bin | 104713 -> 106045 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/core-ctx.lua | 53 | ||||
-rw-r--r-- | tex/context/base/m-spreadsheet.lua | 7 | ||||
-rw-r--r-- | tex/context/base/s-mod.ctx | 1 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24389 -> 24388 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 181135 -> 181164 bytes | |||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
15 files changed, 99 insertions, 28 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 3aff2bee2..890c7455c 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -258,6 +258,7 @@ function ctxrunner.checkfile(ctxdata,ctxname,defaultname) local flags = ctxdata.flags for e in xml.collected(xmldata,"/ctx:job/ctx:flags/ctx:flag") do + local flag = xml.text(e) or "" local key, value = match(flag,"^(.-)=(.+)$") if key and value then flags[key] = value diff --git a/scripts/context/lua/mtx-epub.lua b/scripts/context/lua/mtx-epub.lua index 6b7f7e718..52a144c20 100644 --- a/scripts/context/lua/mtx-epub.lua +++ b/scripts/context/lua/mtx-epub.lua @@ -63,6 +63,7 @@ local package = [[ <dc:identifier id="%s" opf:scheme="UUID">urn:uuid:%s</dc:identifier> <dc:creator>%s</dc:creator> <dc:date>%s</dc:date> + <meta name="cover" content="%s" /> </metadata> <manifest> @@ -70,6 +71,7 @@ local package = [[ </manifest> <spine toc="ncx"> + <itemref idref="cover-xhtml" /> <itemref idref="%s" /> </spine> @@ -108,6 +110,23 @@ local toc = [[ </ncx> ]] +local coverxhtml = [[ +<?xml version="1.0" encoding="UTF-8"?> + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>cover.xhtml</title> + </head> + <body> + <div> + <img src="%s" alt="The cover image" style="max-width: 100%%;" /> + </div> + </body> +</html> +]] + -- We need to figure out what is permitted. Numbers only seem to give -- problems is some applications as do names with dashes. Also the -- optional toc is supposed to be there and although id's are by @@ -128,6 +147,7 @@ local mimetypes = { png = "image/png", jpg = "image/jpeg", ncx = "application/x-dtbncx+xml", + gif = "image/gif", -- default = "text/plain", } @@ -202,10 +222,10 @@ function scripts.epub.make() -- identifier = gsub(identifier,"[^a-zA-z0-9]","") - if firstpage == "" then + if firstpage ~= "" then images[firstpage] = firstpage end - if lastpage == "" then + if lastpage ~= "" then images[lastpage] = lastpage end @@ -216,6 +236,7 @@ function scripts.epub.make() local epubfile = file.replacesuffix(name,"epub") local epubroot = file.replacesuffix(name,"opf") local epubtoc = "toc.ncx" + local epubcover = "cover.xhtml" application.report("creating paths in tree %s",epubpath) lfs.mkdir(epubpath) @@ -236,6 +257,7 @@ function scripts.epub.make() end end + copyone("cover.xhtml") copyone("toc.ncx") local function copythem(files) @@ -264,14 +286,35 @@ function scripts.epub.make() local idmaker = idmakers[file.extname(root)] or idmakers.default - container = format(container,epubroot) - 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) + container = format(container, + epubroot + ) + package = format(package, + identifier, + title, + language, + identifier, + os.uuid(), + creator, + os.date("!%Y-%m-%dT%H:%M:%SZ"), + idmaker(firstpage), + concat(used,"\n"), + idmaker(root) + ) + toc = format(toc, + identifier, + title, + root + ) + coverxhtml = format(coverxhtml, + firstpage + ) io.savedata(file.join(epubpath,"mimetype"),mimetype) io.savedata(file.join(epubpath,"META-INF","container.xml"),container) io.savedata(file.join(epubpath,"OEBPS",epubroot),package) io.savedata(file.join(epubpath,"OEBPS",epubtoc),toc) + io.savedata(file.join(epubpath,"OEBPS",epubcover),coverxhtml) application.report("creating archive\n\n") diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index b07d590ba..2aabcc1b2 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.09 01:22} +\newcontextversion{2012.06.11 00:21} %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 4d313564c..7e3dd671f 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.09 01:22} +\newcontextversion{2012.06.11 00:21} %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-yes.mkiv b/tex/context/base/cont-yes.mkiv index 51be3a569..01ba88d49 100644 --- a/tex/context/base/cont-yes.mkiv +++ b/tex/context/base/cont-yes.mkiv @@ -24,6 +24,8 @@ local filename = arguments.input or tex.jobname local suffix = file.suffix(filename) + local filename = ctxrunner.resolve(filename) -- in case we're prepped + if suffix == "xml" or arguments.forcexml then -- Maybe we should move the preamble parsing here as it diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 160d6435b..0e42029c0 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 56ad3270f..5352a41ab 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 a88a133f3..f2c39eef0 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.09 01:22} +\edef\contextversion{2012.06.11 00:21} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index b6d0f54eb..32ea1b198 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.09 01:22} +\edef\contextversion{2012.06.11 00:21} %D For those who want to use this: diff --git a/tex/context/base/core-ctx.lua b/tex/context/base/core-ctx.lua index 616f82a58..1f673d17e 100644 --- a/tex/context/base/core-ctx.lua +++ b/tex/context/base/core-ctx.lua @@ -33,7 +33,9 @@ millisecond it's not that much of a burden. local trace_prepfiles = false trackers.register("system.prepfiles", function(v) trace_prepfiles = v end) -local gsub, find = string.gsub, string.find +local gsub, find, match, validstring = string.gsub, string.find, string.match, string.valid +local concat = table.concat +local xmltext = xml.text local report_prepfiles = logs.reporter("system","prepfiles") @@ -106,6 +108,7 @@ function ctxrunner.load(ctxname) xml.include(xmldata,'ctx:include','name', {'.', file.dirname(ctxname), "..", "../.." }) for e in xml.collected(xmldata,"/ctx:job/ctx:flags/ctx:flag") do + local flag = xmltext(e) local key, value = match(flag,"^(.-)=(.+)$") if key and value then environment.setargument(key,value) @@ -123,22 +126,22 @@ function ctxrunner.load(ctxname) local environments = ctxfile.environments for e in xml.collected(xmldata,"/ctx:job/ctx:process/ctx:resources/ctx:mode") do - modes[#modes+1] = xml.text(e) - -- context.enablemode { xml.text(e) } + modes[#modes+1] = xmltext(e) + -- context.enablemode { xmltext(e) } end for e in xml.collected(xmldata,"/ctx:job/ctx:process/ctx:resources/ctx:module") do - modules[#modules+1] = xml.text(e) - -- context.module { xml.text(e) } + modules[#modules+1] = xmltext(e) + -- context.module { xmltext(e) } end for e in xml.collected(xmldata,"/ctx:job/ctx:process/ctx:resources/ctx:environment") do - environments[#environments+1] = xml.text(e) - -- context.environment { xml.text(e) } + environments[#environments+1] = xmltext(e) + -- context.environment { xmltext(e) } end for e in xml.collected(xmldata,"ctx:message") do - report_prepfiles("ctx comment: %s", xml.text(e)) + report_prepfiles("ctx comment: %s", xmltext(e)) end for r, d, k in xml.elements(xmldata,"ctx:value[@name='job']") do @@ -156,20 +159,33 @@ function ctxrunner.load(ctxname) -- todo: only collect, then plug into file handler + local inputfile = validstring(environment.arguments.input) or jobname + + variables.old = inputfile + for files in xml.collected(xmldata,"/ctx:job/ctx:preprocess/ctx:files") do for pattern in xml.collected(files,"ctx:file") do local preprocessor = pattern.at['processor'] or "" - if preprocessor ~= "" then - treatments[#treatments+1] = { - pattern = string.topattern(justtext(xml.tostring(pattern))), - preprocessors = utilities.parsers.settings_to_array(preprocessor), + for r, d, k in xml.elements(pattern,"/ctx:old") do + d[k] = jobname + end + for r, d, k in xml.elements(pattern,"/ctx:value[@name='old'") do + d[k] = jobname + end + pattern =justtext(xml.tostring(pattern)) + if preprocessor and preprocessor ~= "" and pattern and pattern ~= "" then + local noftreatments = #treatments + 1 + local findpattern = string.topattern(pattern) + local preprocessors = utilities.parsers.settings_to_array(preprocessor) + treatments[noftreatments] = { + pattern = findpattern, + preprocessors = preprocessors, } + report_prepfiles("step: %s, pattern: %q, preprocessor: %q",noftreatments,findpattern,concat(preprocessors," ")) end end end - variables.old = jobname - local function needstreatment(oldfile) for i=1,#treatments do local treatment = treatments[i] @@ -185,7 +201,8 @@ function ctxrunner.load(ctxname) local treatment = needstreatment(filename) if treatment then local oldfile = filename - newfile = oldfile .. "." .. suffix + -- newfile = oldfile .. "." .. suffix + newfile = oldfile .. ".prep" if runlocal then newfile = file.basename(newfile) end @@ -265,6 +282,8 @@ function ctxrunner.load(ctxname) table.setmetatableindex(ctxrunner.prepfiles,preparefile or dontpreparefile) + -- we need to deal with the input filename as it has already be resolved + end local function resolve(name) -- used a few times later on @@ -301,6 +320,10 @@ function commands.getctxfile() end end +function ctxrunner.resolve(name) -- used a few times later on + return ctxrunner.prepfiles[file.collapsepath(name)] or name +end + -- ctxrunner.load("t:/sources/core-ctx.ctx") -- -- context(ctxrunner.prepfiles["one-a.xml"]) context.par() diff --git a/tex/context/base/m-spreadsheet.lua b/tex/context/base/m-spreadsheet.lua index 25bf6be87..34bbdf433 100644 --- a/tex/context/base/m-spreadsheet.lua +++ b/tex/context/base/m-spreadsheet.lua @@ -9,9 +9,12 @@ if not modules then modules = { } end modules ['m-spreadsheet'] = { local byte, format, gsub = string.byte, string.format, string.gsub local R, P, C, V, Cs, Cc, Carg, lpegmatch = lpeg.R, lpeg.P, lpeg.C, lpeg.V, lpeg.Cs, lpeg.Cc, lpeg.Carg, lpeg.match +local context = context + local splitthousands = utilities.parsers.splitthousands +local variables = interfaces.variables -local context = context +local v_yes = variables.yes moduledata = moduledata or { } @@ -180,7 +183,7 @@ function spreadsheets.get(name,r,c,str) local split = settings.split local period = settings.period local comma = settings.comma - if split then + if split == v_yes then result = splitthousands(result) end if period == "" then period = nil end diff --git a/tex/context/base/s-mod.ctx b/tex/context/base/s-mod.ctx index 5059c77d4..09ecf714c 100644 --- a/tex/context/base/s-mod.ctx +++ b/tex/context/base/s-mod.ctx @@ -11,7 +11,6 @@ </ctx:files> </ctx:preprocess> <ctx:flags> - <!-- ctx:flag>purge</ctx:flag --> <ctx:flag>global</ctx:flag> <ctx:flag>prep</ctx:flag> <ctx:flag>purge</ctx:flag> diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex b04ca9be3..6210d8e2f 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 12862163c..90f84ece6 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 390612836..b8fb4d912 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/09/12 01:22:26 +-- merge date : 06/11/12 00:21:25 do -- begin closure to overcome local limits and interference |