diff options
Diffstat (limited to 'tex')
29 files changed, 553 insertions, 120 deletions
diff --git a/tex/context/base/attr-ini.lua b/tex/context/base/attr-ini.lua index 100743c91..35c514ffe 100644 --- a/tex/context/base/attr-ini.lua +++ b/tex/context/base/attr-ini.lua @@ -16,7 +16,8 @@ local texsprint = tex.sprint local ctxcatcodes = tex.ctxcatcodes --- todo: document this +-- todo: document this but first reimplement this as it reflects the early +-- days of luatex / mkiv and we have better ways now -- nb: attributes: color etc is much slower than normal (marks + literals) but ... -- nb. too many "0 g"s diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index 68edfcd79..93aff94ce 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -61,7 +61,7 @@ %D An example of usage is: -\appendtoks % will change ... +\appendtoks % will change ... not here the () \pdfbackendsetinfo{ConTeXt.Version}{(\contextversion)}% \pdfbackendsetinfo{ConTeXt.Time} {(\number\normalyear.\twodigits\normalmonth.\twodigits\normalday\space \twodigits\currenthour:\twodigits\currentminute)}% \pdfbackendsetinfo{ConTeXt.Jobname}{(\jobname)}% diff --git a/tex/context/base/bibl-tra.mkii b/tex/context/base/bibl-tra.mkii index 9653f057e..59783e139 100644 --- a/tex/context/base/bibl-tra.mkii +++ b/tex/context/base/bibl-tra.mkii @@ -822,7 +822,7 @@ \def\typesetpubslist {\dobeginoflist - \the\initializebibdefinitions +% \the\initializebibdefinitions \edef\askedlevel{\csname \??li pubs\c!criterium\endcsname}% \ifx\askedlevel\v!all \def\bibrefprefix{}% @@ -987,19 +987,21 @@ %D \subsubject{What's in a publication} \unexpanded\def\typesetapublication#1% - {\doifsomething{#1}{\doglobal\increment\bibcounter - \bgroup - \makepbkvalue{#1}% - \ifgridsnapping - \snaptogrid\vbox{\dodolistelement{pubs}{}{\bibcounter}% - {\expanded{\reference[\bibrefprefix#1]{\bibcounter}}% - \strut \dotypesetapublication{#1}\strut }{}{}}% - \else - \dodolistelement{pubs}{}{\bibcounter}% - {\expanded{\reference[\bibrefprefix#1]{\bibcounter}}% + {\doifsomething{#1} + {\doglobal\increment\bibcounter + \bgroup + \the\initializebibdefinitions + \makepbkvalue{#1}% + \ifgridsnapping + \snaptogrid\vbox{\dodolistelement{pubs}{}{\bibcounter}% + {\expanded{\reference[\bibrefprefix#1]{\bibcounter}}% + \strut \dotypesetapublication{#1}\strut }{}{}}% + \else + \dodolistelement{pubs}{}{\bibcounter}% + {\expanded{\reference[\bibrefprefix#1]{\bibcounter}}% \strut \dotypesetapublication{#1}\strut }{}{}% - \fi - \egroup }} + \fi + \egroup}} \def\dotypesetapublication#1% {\bgroup diff --git a/tex/context/base/bibl-tra.mkiv b/tex/context/base/bibl-tra.mkiv index 5ad1422f3..936f310be 100644 --- a/tex/context/base/bibl-tra.mkiv +++ b/tex/context/base/bibl-tra.mkiv @@ -785,11 +785,13 @@ \def\typesetpubslist {\dobeginoflist - \the\initializebibdefinitions + % \the\initializebibdefinitions % COMMENTED \edef\currentlist{pubs}% - \doif{\listparameter\c!criterium}\v!cite{\setuplist[pubs][\c!criterium=\v!here]}% + \doif{\listparameter\c!criterium}\v!cite + {\setuplist[pubs][\c!criterium=\v!here]}% \ctxlua{bibtex.hacks.reset(\number\bibtexoncemode)}% - \placestructurelist{pubs}{\listparameter\c!criterium}{\listparameter\c!number}% only collects + \placestructurelist{pubs}% + {\listparameter\c!criterium}{\listparameter\c!number}% \ctxlua{bibtex.hacks.flush("\@@pbsorttype")}% \doendoflist} @@ -904,6 +906,7 @@ \def\dotypesetapublication#1% {\bgroup + \the\initializebibdefinitions % NEW \def\@@currentalternative{:l:}% \presetbibvariables \let\biblanguage\empty diff --git a/tex/context/base/colo-ext.mkiv b/tex/context/base/colo-ext.mkiv index 074a0130e..f973af73a 100644 --- a/tex/context/base/colo-ext.mkiv +++ b/tex/context/base/colo-ext.mkiv @@ -75,4 +75,26 @@ \setupcolors[\c!intent=\v!none] +% A goodie that replaces the startMPcolor hackery +% +% \definecolor[red-t] [r=1,t=0.5,a=1] +% \definecolor[green-t][g=1,t=0.5,a=1] +% \defineintermediatecolor[mycolora][0.5,red,green] +% \defineintermediatecolor[mycolorb][0.5,red-t,green-t] +% \starttext +% test {\mycolora OEPS} test +% test {\mycolorb OEPS} test +% \stoptext + +\def\defineintermediatecolor + {\dodoubleempty\dodefineintermediatecolor} + +\def\dodefineintermediatecolor[#1][#2,#3,#4]% -- no checking + {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi + \ctxlua{colors.defineintermediate("#1",0#2, + \thecolorattribute{#3},\thecolorattribute{#4}, + \thetransparencyattribute{#3},\thetransparencyattribute{#4}, + \iffreezecolors true\else false\fi)}% + \dodefinecolorcommand\setvalue{#1}} + \protect \endinput diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua index fc63d6b3a..8797b85f5 100644 --- a/tex/context/base/colo-ini.lua +++ b/tex/context/base/colo-ini.lua @@ -407,3 +407,39 @@ function colors.spotcolorvalue(ca,default) end return tostring(v) end + +-- experiment (a bit of a hack, as we need to get the attribute number) + +local min = math.min + +local function f(one,two,i,fraction) + return min(fraction*(one[i]+two[i]),1) +end + +function colors.defineintermediate(name,fraction,c_one,c_two,a_one,a_two,global,freeze) + local one, two = colors.value(c_one), colors.value(c_two) + if one and two then + local csone, cstwo = one[1], two[1] + if csone == cstwo then + local ca + if csone == 2 then + ca = colors.register(name,'gray',f(one,two,2,fraction)) + elseif csone == 3 then + ca = colors.register(name,'rgb',f(one,two,3,fraction),f(one,two,4,fraction),f(one,two,5,fraction)) + elseif csone == 4 then + ca = colors.register(name,'rgb',f(one,two,6,fraction),f(one,two,7,fraction),f(one,two,8,fraction),f(one,two,9,fraction)) + else + ca = colors.register(name,'gray',f(one,two,2,fraction)) + end + definecolor(name,ca,global,freeze) + end + end + local one, two = transparencies.value(a_one), transparencies.value(a_two) + if one and two then + local tsone, tstwo = one[1], two[1] + if tsone == tstwo then + local ta = transparencies.register(name,tsone,f(one,two,2,fraction)) + definetransparent(name,ta,global) + end + end +end diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 8a2b1faf8..b355e5713 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2009.10.29 21:26} +\newcontextversion{2009.11.01 21:24} %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.tex b/tex/context/base/context.tex index 82e0e9451..7339ec263 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2009.10.29 21:26} +\edef\contextversion{2009.11.01 21:24} %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 f9920d4c4..db85eaf7d 100644 --- a/tex/context/base/core-ctx.lua +++ b/tex/context/base/core-ctx.lua @@ -26,7 +26,7 @@ function commands.loadctxpreplist() end --~ end for e in xml.collected(x,"ctx:prepfile") do - local name = xml.content(e) + local name = xml.text(e) if islocal then name = file.basename(name) end diff --git a/tex/context/base/core-job.lua b/tex/context/base/core-job.lua index 8f5517df3..2815aecf3 100644 --- a/tex/context/base/core-job.lua +++ b/tex/context/base/core-job.lua @@ -92,7 +92,7 @@ local function convertexamodes(str) for e in xml.collected(x,"exa:variable") do local label = e.at and e.at.label if label and label ~= "" then - local data = xml.content(e) or "" + local data = xml.text(e) local mode = label:match("^mode:(.+)$") if mode then texsprint(ctxcatcodes,format("\\enablemode[%s:%s]",mode,data)) diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index 43b830e55..0fc40b38b 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -268,9 +268,9 @@ do local figuredata = figures.new() if request then local iv = interfaces.variables - -- request.width/height are strings and are only used when no natural dimensions - -- can be determined; at some point the handlers might set them to numbers instead ---~ local w, h = tonumber(request.width), tonumber(request.height) + -- request.width/height are strings and are only used when no natural dimensions + -- can be determined; at some point the handlers might set them to numbers instead + -- local w, h = tonumber(request.width), tonumber(request.height) request.page = math.max(tonumber(request.page) or 1,1) request.size = img.check_size(request.size) request.object = iv[request.object] == variables.yes @@ -279,8 +279,8 @@ do request.cache = request.cache ~= "" and request.cache request.prefix = request.prefix ~= "" and request.prefix request.format = request.format ~= "" and request.format ---~ request.width = (w and w > 0) or false ---~ request.height = (h and h > 0) or false + -- request.width = (w and w > 0) or false + -- request.height = (h and h > 0) or false table.merge(figuredata.request,request) end callstack[#callstack+1] = figuredata @@ -293,6 +293,7 @@ do end -- maybe move texsprint to tex function figures.get(category,tag,default) +--~ print(table.serialize(figuredata)) local value = figuredata[category] value = value and value[tag] if not value or value == "" or value == true then @@ -857,7 +858,7 @@ function bases.find(basename,askedlabel) if base[2] and base[3] then -- rlx:library for e in xml.collected(base[3],"/(*:library|figurelibrary)/*:figure/*:label") do page = page + 1 - if xml.content(e) == askedlabel then + if xml.text(e) == askedlabel then t = { base = file.replacesuffix(base[2],"pdf"), format = "pdf", diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv index c8c0e36b7..c2a0f2b49 100644 --- a/tex/context/base/grph-inc.mkiv +++ b/tex/context/base/grph-inc.mkiv @@ -93,7 +93,6 @@ \def\figurefilename {\ctxlua{tex.sprint(tex.ctxcatcodes,file.nameonly(figures.get("used","fullname")))}} \def\figurefiletype {\ctxlua{tex.sprint(tex.ctxcatcodes,file.extname (figures.get("used","fullname")))}} \def\figurefullname {\ctxlua{figures.tprint("used","fullname")}} - \def\noffigurepages {\ctxlua{figures.tprint("used","pages",0)}} \let\naturalfigurewidth \figurenaturalwidth @@ -244,6 +243,10 @@ } }% \ctxlua{figures.identify()}% \ifconditional\testexternalfigureonly + \ifcase\figurestatus \else + \ctxlua{figures.check()}% + \ctxlua{figures.scale()}% + \fi \signalexternalfigure \else \ifcase\figurestatus diff --git a/tex/context/base/l-os.lua b/tex/context/base/l-os.lua index 6806ec5ae..63c5f214d 100644 --- a/tex/context/base/l-os.lua +++ b/tex/context/base/l-os.lua @@ -6,7 +6,8 @@ if not modules then modules = { } end modules ['l-os'] = { license = "see context related readme files" } -local find = string.find +local find, format = string.find, string.format +local random, ceil = math.random, math.ceil function os.resultof(command) return io.popen(command,"r"):read("*all") @@ -103,6 +104,8 @@ function os.currentplatform(name,default) elseif name == "macosx" then if find(architecture,"i386") then platform = "osx-intel" + elseif find(architecture,"x86_64") then + platform = "osx-64" else platform = "osx-ppc" end @@ -128,3 +131,26 @@ function os.currentplatform(name,default) end return platform end + +-- beware, we set the randomseed +-- + +-- from wikipedia: Version 4 UUIDs use a scheme relying only on random numbers. This algorithm sets the +-- version number as well as two reserved bits. All other bits are set using a random or pseudorandom +-- data source. Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx with hexadecimal +-- digits x and hexadecimal digits 8, 9, A, or B for y. e.g. f47ac10b-58cc-4372-a567-0e02b2c3d479. +-- +-- as we don't call this function too often there is not so much risk on repetition + + +local t = { 8, 9, "a", "b" } + +function os.uuid() + return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", + random(0xFFFF),random(0xFFFF), + random(0x0FFF), + t[ceil(random(4))] or 8,random(0x0FFF), + random(0xFFFF), + random(0xFFFF),random(0xFFFF),random(0xFFFF) + ) +end diff --git a/tex/context/base/lpdf-ini.mkiv b/tex/context/base/lpdf-ini.mkiv index 771ed3c58..cfc416216 100644 --- a/tex/context/base/lpdf-ini.mkiv +++ b/tex/context/base/lpdf-ini.mkiv @@ -14,6 +14,7 @@ \writestatus{loading}{ConTeXt Backend Macros / PDF} \registerctxluafile{lpdf-ini}{1.001} +\registerctxluafile{lpdf-xmp}{1.001} \registerctxluafile{lpdf-nod}{1.001} %registerctxluafile{lpdf-col}{1.001} % will be loaded later \registerctxluafile{lpdf-mis}{1.001} diff --git a/tex/context/base/lpdf-mis.lua b/tex/context/base/lpdf-mis.lua index 3a0422bad..142b1281f 100644 --- a/tex/context/base/lpdf-mis.lua +++ b/tex/context/base/lpdf-mis.lua @@ -44,7 +44,7 @@ local tobasepoints = number.tobasepoints local variables = interfaces.variables -lpdf.addtoinfo ("Trapped", pdfboolean(false)) +lpdf.addtoinfo ("Trapped", pdfboolean(false), "False") lpdf.addtocatalog("Version", pdfconstant(format("1.%s",tex.pdfminorversion))) -- @@ -149,25 +149,26 @@ lpdf.registerdocumentfinalizer(flushdocumentactions) function codeinjections.setupidentity(specification) local title = specification.title or "" if title ~= "" then - lpdf.addtoinfo("Title", pdfunicode(title)) + lpdf.addtoinfo("Title", pdfunicode(title), title) end local subject = specification.subject or "" if subject ~= "" then - lpdf.addtoinfo("Subject", pdfunicode(subject)) + lpdf.addtoinfo("Subject", pdfunicode(subject), subject) end local author = specification.author or "" if author ~= "" then - lpdf.addtoinfo("Author", pdfunicode(author)) + lpdf.addtoinfo("Author", pdfunicode(author), author) end local creator = specification.creator or "" if creator ~= "" then - lpdf.addtoinfo("Creator", pdfunicode(creator)) + lpdf.addtoinfo("Creator", pdfunicode(creator), creator) end local date = specification.date or "" if date ~= "" then - lpdf.addtoinfo("ModDate", pdfstring(date)) + lpdf.addtoinfo("ModDate", pdfstring(date), date) end local keywords = specification.keywords or "" if keywords ~= "" then keywords = string.gsub(keywords, "[%s,]+", " ") - lpdf.addtoinfo("Keywords",pdfunicode(keywords)) + lpdf.addtoinfo("Keywords",pdfunicode(keywords), keywords) end - lpdf.addtoinfo("ID", pdfstring(format("%s.%s",tex.jobname,os.date("%Y%m%d.%H%M")))) -- needed for pdf/x + local id = format("%s.%s",tex.jobname,os.date("%Y%m%d.%H%M")) + lpdf.addtoinfo("ID", pdfstring(id), id) -- needed for pdf/x end local function flushjavascripts() diff --git a/tex/context/base/lpdf-xmp.lua b/tex/context/base/lpdf-xmp.lua new file mode 100644 index 000000000..03f7c0dd4 --- /dev/null +++ b/tex/context/base/lpdf-xmp.lua @@ -0,0 +1,158 @@ +if not modules then modules = { } end modules ['lpdf-xmp'] = { + version = 1.001, + comment = "companion to lpdf-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local format, random, char, gsub = string.format, math.random, string.char, string.gsub +local xmlfillin = xml.fillin + +local trace_xmp = false trackers.register("backend.xmp", function(v) trace_xmp = v end) + +local xmpmetadata = [[ +<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:08:04"> + <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"> + <dc:format>application/pdf</dc:format> + <dc:creator> + <rdf:Seq> + <rdf:li/> + </rdf:Seq> + </dc:creator> + <dc:title> + <rdf:Alt> + <rdf:li xml:lang="x-default"/> + </rdf:Alt> + </dc:title> + </rdf:Description> + <rdf:Description rdf:about="" xmlns:pdfx="http://ns.adobe.com/pdfx/1.3/"> + <pdfx:ConTeXt.Jobname/> + <pdfx:ConTeXt.Time/> + <pdfx:ConTeXt.Url/> + <pdfx:ConTeXt.Version/> + <pdfx:ID/> + <pdfx:PTEX.Fullbanner/> + </rdf:Description> + <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/"> + <xmp:CreateDate/> + <xmp:CreatorTool/> + <xmp:ModifyDate/> + <xmp:MetadataDate/> + </rdf:Description> + <rdf:Description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/"> + <pdf:Producer/> + <pdf:Trapped/> + </rdf:Description> + <rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"> + <xmpMM:DocumentID/> + <xmpMM:InstanceID/> + </rdf:Description> + </rdf:RDF> +</x:xmpmeta> +]] + +-- i wonder why this begin end is empty / w (no time now to look into it) + +local xpacket = [[ +<?xpacket begin="" id="%s"?> + +%s + +<?xpacket end="w"?>]] + +local mapping = { + ["Creator"] = "rdf:Description/dc:creator/rdf:Seq/rdf:li", + ["Title"] = "rdf:Description/dc:title/rdf:Alt/rdf:li", + ["ConTeXt.Jobname"] = "rdf:Description/pdfx:ConTeXt.Jobname", + ["ConTeXt.Time"] = "rdf:Description/pdfx:ConTeXt.Time", + ["ConTeXt.Url"] = "rdf:Description/pdfx:ConTeXt.Url", + ["ConTeXt.Version"] = "rdf:Description/pdfx:ConTeXt.Version", + ["ID"] = "rdf:Description/pdfx:ID", + ["PTEX.Fullbanner"] = "rdf:Description/pdfx:PTEX.Fullbanner", + ["CreateDate"] = "rdf:Description/xmp:CreateDate", + ["CreatorTool"] = "rdf:Description/xmp:CreatorTool", + ["ModifyDate"] = "rdf:Description/xmp:ModifyDate", + ["MetadataDate"] = "rdf:Description/xmp:MetadataDate", + ["Producer"] = "rdf:Description/pdf:Producer", + ["Trapped"] = "rdf:Description/pdf:Trapped", + ["DocumentID"] = "rdf:Description/xmpMM:DocumentID", + ["InstanceID"] = "rdf:Description/xmpMM:InstanceID", +} + +local xmp = xml.convert(xmpmetadata) + +local addtoinfo = lpdf.addtoinfo + +local function addxmpinfo(tag,value,check) + local pattern = mapping[tag] + if pattern then + xmlfillin(xmp,pattern,value,check) + end +end + +function lpdf.addtoinfo(tag,pdfvalue,strvalue) + addtoinfo(tag,pdfvalue) + addxmpinfo(tag,strvalue or gsub(tostring(pdfvalue),"^%((.*)%)$","%1")) -- hack +end + +lpdf.addxmpinfo = addxmpinfo + +local t = { } for i=1,24 do t[i] = random() end + +local function flushxmpinfo() + + commands.freezerandomseed(os.clock()) -- hack + + local t = { } for i=1,24 do t[i] = char(96 + random(26)) end + local packetid = table.concat(t) + local time = os.date("!%Y-%m-%dT%X") -- ! -> universaltime + addxmpinfo("Producer",format("LuaTeX-%0.2f.%s",tex.luatexversion/100,tex.luatexrevision)) + addxmpinfo("DocumentID",format("uuid:%s",os.uuid())) + addxmpinfo("InstanceID",format("uuid:%s",os.uuid())) + addxmpinfo("CreatorTool","LuaTeX + ConTeXt MkIV") + addxmpinfo("CreateDate",time) + addxmpinfo("ModifyDate",time) + addxmpinfo("MetadataDate",time) + local blob = xml.tostring(xmp) + local md = lpdf.dictionary { + Subtype = lpdf.constant("XML"), + Type = lpdf.constant("Metadata"), + } + if trace_xmp then + commands.writestatus("system","xmp data flushed (see log file)") + texio.write_nl("log","") + texio.write("log","\n% ",(gsub(blob,"[\r\n]","\n%% ")),"\n") + end + if true then + commands.writestatus("system","xmp data not flushed (needs luatex upgrade)") + else + lpdf.addtocatalog("Metadata",lpdf.reference(pdf.immediateobj("stream",format(xpacket,packetid,blob),md()))) + end + commands.defrostrandomseed() -- hack + +end + +-- his will be enabled when we can inhibit compression for a stream at the lua end + +lpdf.registerdocumentfinalizer(flushxmpinfo,3) + +--~ lpdf.addxmpinfo("creator", "PRAGMA ADE: Hans Hagen and/or Ton Otten") +--~ lpdf.addxmpinfo("title", "oeps") +--~ lpdf.addxmpinfo("ConTeXt.Jobname", "oeps") +--~ lpdf.addxmpinfo("ConTeXt.Time", "2009.10.30 17:53") +--~ lpdf.addxmpinfo("ConTeXt.Url", "www.pragma-ade.com") +--~ lpdf.addxmpinfo("ConTeXt.Version", "2009.10.30 16:59") +--~ lpdf.addxmpinfo("ID", "oeps.20091030.1753") +--~ lpdf.addxmpinfo("PTEX.Fullbanner", "This is LuaTeX, Version beta-0.44.0-2009103014 (Web2C 2009) kpathsea version 5.0.0") +--~ lpdf.addxmpinfo("CreateDate", "2009-10-30T17:53:39+01:00") +--~ lpdf.addxmpinfo("CreatorTool", "ConTeXt - 2009.10.30 16:59") +--~ lpdf.addxmpinfo("ModifyDate", "2009-10-30T19:38:18+01:00") +--~ lpdf.addxmpinfo("MetadataDate", "2009-10-30T19:38:18+01:00") +--~ lpdf.addxmpinfo("Producer", "LuaTeX-0.44.0") +--~ lpdf.addxmpinfo("Trapped", "False") +--~ lpdf.addxmpinfo("DocumentID", "uuid:d9f1383c-e069-4619-bee0-c978d9495d7d") +--~ lpdf.addxmpinfo("InstanceID", "uuid:67eda265-8146-4cce-a1a2-1ec91819ad73") + +--~ print(lpdf.flushxmpinfo()) diff --git a/tex/context/base/lxml-mis.lua b/tex/context/base/lxml-mis.lua index eff012013..74c264d0c 100644 --- a/tex/context/base/lxml-mis.lua +++ b/tex/context/base/lxml-mis.lua @@ -85,3 +85,15 @@ xml.cleansed_pattern = cleansed function xml.escaped (str) return escaped :match(str) end function xml.unescaped(str) return unescaped:match(str) end function xml.cleansed (str) return cleansed :match(str) end + +-- this might move + +function xml.fillin(root,pattern,str,check) + local e = xml.first(root,pattern) + if e then + local n = #e.dt + if not check or n == 0 or (n == 1 and e.dt[1] == "") then + e.dt = { str } + end + end +end diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua index ca22a7eec..8bd64890d 100644 --- a/tex/context/base/lxml-tab.lua +++ b/tex/context/base/lxml-tab.lua @@ -148,8 +148,8 @@ local dcache, hcache, acache = { }, { }, { } local mt = { } -function initialize_mt(root) -- we will make a xml.new that then sets the mt as field - mt = { __tostring = xml.text, __index = root } +function initialize_mt(root) + mt = { __index = root } -- will be redefined later end function xml.setproperty(root,k,v) @@ -963,7 +963,6 @@ xml.defaulthandlers = handlers xml.newhandlers = newhandlers xml.serialize = serialize xml.tostring = xmltostring -xml.text = xmltext --[[ldx-- <p>The next function operated on the content only and needs a handle function @@ -999,14 +998,6 @@ function xml.body(root) return (root.ri and root.dt[root.ri]) or root end -function xml.text(root) - return (root and xml.tostring(root)) or "" -end - -function xml.content(root) -- bugged - return (root and root.dt and xml.tostring(root.dt)) or "" -end - function xml.name(root) if not root then return "" diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua index 56bb0ab15..4809942a8 100644 --- a/tex/context/base/lxml-tex.lua +++ b/tex/context/base/lxml-tex.lua @@ -30,8 +30,7 @@ local texcatcodes, ctxcatcodes, vrbcatcodes = tex.texcatcodes, tex.ctxcatcodes, local xmlelements, xmlcollected, xmlsetproperty = xml.elements, xml.collected, xml.setproperty local xmlparseapply, xmlwithelements = xml.parse_apply, xml.withelements -local xmlserialize, xmlcollect, xmlcontent = xml.serialize, xml.collect, xml.content -local xmltostring = xml.tostring +local xmlserialize, xmlcollect, xmltext, xmltostring = xml.serialize, xml.collect, xml.text, xml.tostring local variables = (interfaces and interfaces.variables) or { } @@ -1125,20 +1124,22 @@ function lxml.attribute(id,pattern,a,default) end end -function lxml.text(id,pattern) - local collected = lxmlparseapply(id,pattern) +function lxml.raw(id,pattern) -- the content, untouched by commands + local collected = (pattern and lxmlparseapply(id,pattern)) or get_id(id) if collected then - text(collected) + texsprint(xmltostring(collected[1].dt)) end end -function lxml.raw(id,pattern) -- the content, untouched by commands - local collected = lxmlparseapply(id,pattern) +function lxml.text(id,pattern) + local collected = (pattern and lxmlparseapply(id,pattern)) or get_id(id) if collected then - texsprint(xmltostring(collected[1].dt)) + text(collected) end end +lxml.content = text + function lxml.position(id,pattern,n) local collected = lxmlparseapply(id,pattern) if collected then @@ -1165,17 +1166,7 @@ function lxml.element(id,n) position(lxmlparseapply(id,"/*"),n) end -lxml.index = lxml.position - --- fast direct ones - -function lxml.content(root) -- bugged, does not print - local root = get_id(id) - local content = root and root.dt and xmltostring(root.dt) - if content then - texsprint(content) - end -end +lxml.index = lxml.position function lxml.pos(id) local root = get_id(id) @@ -1336,7 +1327,7 @@ function lxml.strip(id,pattern,nolines) end function lxml.stripped(id,pattern,nolines) - local str = xmlcontent(get_id(id),pattern) or "" + local str = xmltext(get_id(id),pattern) or "" str = gsub(str,"^%s*(.-)%s*$","%1") if nolines then str = gsub(str,"%s+"," ") diff --git a/tex/context/base/lxml-xml.lua b/tex/context/base/lxml-xml.lua index 2aaed94fc..bbde4bd42 100644 --- a/tex/context/base/lxml-xml.lua +++ b/tex/context/base/lxml-xml.lua @@ -94,6 +94,14 @@ local function chainattribute(collected,arguments) -- todo: optional levels return "" end +local function raw(collected) + if collected then + return xmlserialize(collected[1]) -- only first as we cannot concat function + else + return "" + end +end + local function text(collected) if collected then return xmltostring(collected[1].dt) -- only first as we cannot concat function @@ -229,14 +237,24 @@ function xml.attribute(id,pattern,a,default) return attribute(xmlfilter(id,pattern),a,default) end -function xml.text(id,pattern) - return text(xmlfilter(id,pattern)) +function xml.raw(id,pattern) + if pattern then + return raw(xmlfilter(id,pattern)) + else + return raw(id) + end end -function xml.raw(id,pattern) - return xmlserialize(xmlfilter(id,pattern)) +function xml.text(id,pattern) + if pattern then + return text(xmlfilter(id,pattern)) + else + return text(id) + end end +xml.content = text + function xml.position(id,pattern,n) return position(xmlfilter(id,pattern),n) end diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index 706c3ceb0..9603680c5 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -1057,37 +1057,11 @@ %D \macros %D {startMPcolor} -%D -%D The following time consuming method uses \METAPOST\ to -%D calculate a color. This enables a match between colors -%D resulting from a complex calculation (e.g. for a title -%D page) and those in the text. - -% \startuseMPgraphic{somecolors} -% color c[] ; c[1] := .7[red,green] ; c[2] := .7[blue,yellow] ; -% \stopuseMPgraphic - -% \startMPcolor[shade-1][t=.2,a=1] -% \includeMPgraphic{somecolors} ; fill fullcircle withcolor c[1] ; -% \stopMPcolor - -% \startMPcolor[shade-2][t=.2,a=1] -% \includeMPgraphic{somecolors} ; fill fullcircle withcolor c[2] ; -% \stopMPcolor - -% \blackrule[width=\hsize,height=4cm,color=shade-1] -% \blackrule[width=\hsize,height=4cm,color=shade-2] - -\def\startMPcolor - {\dodoubleempty\dostartMPcolor} - -\long\def\dostartMPcolor[#1][#2]#3\stopMPcolor % slow but sometimes handy - {\startnointerference - \def\handleMPgraycolor{\normalexpanded{\noexpand\defineglobalcolor[#1][s=\!MPgMPa1,#2]}}% - \def\handleMPrgbcolor {\normalexpanded{\noexpand\defineglobalcolor[#1][r=\!MPgMPa1,g=\!MPgMPa2,b=\!MPgMPa3,#2]}}% - \def\handleMPcmykcolor{\normalexpanded{\noexpand\defineglobalcolor[#1][c=\!MPgMPa1,m=\!MPgMPa2,y=\!MPgMPa3,k=\!MPgMPa4,#2]}}% - \processMPgraphic{#3}% - \stopnointerference} + +\long\def\startMPcolor#1\stopMPcolor + {\writestatus \m!metapost % eventually this placeholder will go away + {\string\startMPcolor...\stopMPcolor\space is obsolete,\space + use \string\defineintermediatecolor\space instead}} %D New: diff --git a/tex/context/base/mult-cld.lua b/tex/context/base/mult-cld.lua index 8898ffc49..02c57fe5f 100644 --- a/tex/context/base/mult-cld.lua +++ b/tex/context/base/mult-cld.lua @@ -46,8 +46,8 @@ function context.trace(intercept) context.trace = function() end end -local trace_context = false trackers.register("context.flush", function(v) if v then context.trace() end end) -local trace_context = false trackers.register("context.intercept", function(v) if v then context.trace(true) end end) +trackers.register("context.flush", function(v) if v then context.trace() end end) +trackers.register("context.intercept", function(v) if v then context.trace(true) end end) local function writer(k,...) flush(ctxcatcodes,k) diff --git a/tex/context/base/mult-cld.mkiv b/tex/context/base/mult-cld.mkiv index 050928658..d387516f1 100644 --- a/tex/context/base/mult-cld.mkiv +++ b/tex/context/base/mult-cld.mkiv @@ -16,5 +16,12 @@ \writestatus{loading}{ConTeXt Multilingual Macros / Lua} \registerctxluafile{mult-cld}{1.001} +\registerctxluafile{mult-clm}{1.001} -\endinput +\unprotect + +\def\defmkivstart#1{\normalprotected\expandafter\def\csname\e!start#1\endcsname} +\def\defmkivstop #1{\normalprotected\expandafter\def\csname\e!stop #1\endcsname} +\def\defmkiv #1{\normalprotected\expandafter\def\csname #1\endcsname} + +\protect \endinput diff --git a/tex/context/base/mult-clm.lua b/tex/context/base/mult-clm.lua new file mode 100644 index 000000000..6e6597e2a --- /dev/null +++ b/tex/context/base/mult-clm.lua @@ -0,0 +1,183 @@ +if not modules then modules = { } end modules ['mult-clm'] = { + version = 1.001, + comment = "companion to mult-clm.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- another experiment +-- todo: multilingual + +local texsprint, ctxcatcodes, vrbcatcodes = tex.sprint, tex.ctxcatcodes, tex.vrbcatcodes +local format, insert, remove, concat = string.format, table.insert, table.remove, table.concat + +local trace_define = false trackers.register("context.define", function(v) trace_define = v end) + +mkiv = mkiv or { } + +mkiv.h, mkiv.a = aux.settings_to_hash, aux.settings_to_array + +local starters, stoppers, macros, stack = { }, { }, { }, { } + +local checkers = { + "\\dosingleempty", + "\\dodoubleempty", + "\\dotripleempty", + "\\doquadrupleempty", + "\\doquintupleempty", + "\\dosixtupleempty", +} + +function mkiv.m(name,...) + macros[name](...) +end + +function mkiv.b(name,...) + local sn = stack[name] + insert(sn,{...}) + starters[name](...) +end + +function mkiv.e(name) + local sn = stack[name] + local sv = remove(sn) + if sv then + stoppers[name](unpack(sv)) + else + -- nesting error + end +end + +mkiv.n = tonumber + +function mkiv.define(name,specification) -- name is optional + if type(name) == "table" then + specification = name + name = specification.name + end + if name and specification then + local arguments = specification.arguments + local na = (arguments and #arguments) or 0 + local environment = specification.environment + if na == 0 then + if environment then + texsprint(ctxcatcodes,"\\defmkstart{",name,"}{\\ctxlua{mkiv.b('",name,"')}}") + texsprint(ctxcatcodes,"\\defmkstop{", name,"}{\\ctxlua{mkiv.b('",name,"')}}") + else + texsprint(ctxcatcodes,"\\defmkiv{", name,"}{\\ctxlua{mkiv.m('",name,"')}}") + end + else + stack[name] = { } + local opt, done = 0, false + local mkivdo = "\\mkivdo" .. name + texsprint(ctxcatcodes,"\\def",mkivdo) + for i=1,na do + local a = arguments[i] + local kind = a[1] + if kind == "option" then + texsprint(ctxcatcodes,"[#",i,"]") + if not done then + opt = opt + 1 + end + else + done = true -- no more optional checking after this + texsprint(ctxcatcodes,"#",i) + end + end + if environment then + texsprint(ctxcatcodes,"{\\ctxlua{mkiv.b('",name,"'") + else + texsprint(ctxcatcodes,"{\\ctxlua{mkiv.m('",name,"'") + end + for i=1,na do + local a = arguments[i] + local kind = a[2] + if kind == "list" then + texsprint(ctxcatcodes,",mkiv.a([[#",i,"]])") + elseif kind == "hash" then + texsprint(ctxcatcodes,",mkiv.h([[#",i,"]])") + elseif kind == "number" then + texsprint(ctxcatcodes,",mkiv.n([[#",i,"]])") + else + texsprint(ctxcatcodes,",[[#",i,"]]") + end + end + texsprint(ctxcatcodes,")}}") + if environment then + texsprint(ctxcatcodes,"\\defmkivstop{" ,name,"}{\\ctxlua{mkiv.e('",name,"')}}") + texsprint(ctxcatcodes,"\\defmkivstart{",name,"}{",checkers[opt],mkivdo,"}") + else + texsprint(ctxcatcodes,"\\defmkiv{", name,"}{",checkers[opt],mkivdo,"}") + end + end + if environment then + starters[name] = specification.starter + stoppers[name] = specification.stopper + else + macros[name] = specification.macro + end + end +end + +function mkiv.tolist(t) + local r = { } + for i=1,#t do + r[i] = t[i] + end + for k,v in table.sortedpairs(t) do + if type(k) ~= "number" then + r[#r+1] = k .. "=" .. v + end + end + return concat(r,", ") +end + +--~ \startluacode +--~ function test(opt_1, opt_2, arg_1) +--~ context.startnarrower() +--~ context("options 1: %s",mkiv.tolist(opt_1)) +--~ context.par() +--~ context("options 2: %s",mkiv.tolist(opt_2)) +--~ context.par() +--~ context("argument 1: %s",arg_1) +--~ context.stopnarrower() +--~ end + +--~ mkiv.define { +--~ name = "test", +--~ arguments = { +--~ { "option", "list" }, +--~ { "option", "hash" }, +--~ { "content", "string" }, +--~ }, +--~ macro = test, +--~ } +--~ \stopluacode + +--~ test: \test[1][a=3]{whatever} + +--~ \startluacode +--~ local function startmore(opt_1) +--~ context.startnarrower() +--~ context("start more, options: %s",mkiv.tolist(opt_1)) +--~ context.startnarrower() +--~ end + +--~ local function stopmore(opt_1) +--~ context.stopnarrower() +--~ context("stop more, options: %s",mkiv.tolist(opt_1)) +--~ context.stopnarrower() +--~ end + +--~ mkiv.define ( "more", { +--~ environment = true, +--~ arguments = { +--~ { "option", "list" }, +--~ }, +--~ starter = startmore, +--~ stopper = stopmore, +--~ } ) +--~ \stopluacode + +--~ more: \startmore[1] one \startmore[2] two \stopmore one \stopmore diff --git a/tex/context/base/node-bck.lua b/tex/context/base/node-bck.lua index 94fbac85f..477ca3f21 100644 --- a/tex/context/base/node-bck.lua +++ b/tex/context/base/node-bck.lua @@ -67,6 +67,7 @@ local function add_backgrounds(head) -- boxes, inline will be done too if mode then local glue = new_glue(-current.width) local rule = new_rule(current.width,current.height,current.depth) +--~ local rule = new_rule(current.width,-current.depth/2,current.depth) -- test local color = has_attribute(found,a_color) local transparency = has_attribute(found,a_transparency) set_attribute(rule,a_colorspace, mode) diff --git a/tex/context/base/supp-ran.lua b/tex/context/base/supp-ran.lua index a0e3d1cf6..b28b57e9a 100644 --- a/tex/context/base/supp-ran.lua +++ b/tex/context/base/supp-ran.lua @@ -39,10 +39,13 @@ function commands.getrandomseed(n) texwrite(last) end -function commands.freezerandomseed() +function commands.freezerandomseed(n) if seed == false then seed = last end + if n then + randomseed(n) + end end function commands.defrostrandomseed() diff --git a/tex/context/base/x-ct.lua b/tex/context/base/x-ct.lua index 06566a464..7fe1795a8 100644 --- a/tex/context/base/x-ct.lua +++ b/tex/context/base/x-ct.lua @@ -97,7 +97,7 @@ function lxml.context.tabulate(root,namespace) --~ for e in xmlcollected(root,bodyrowspec) do --~ texsprint(ctxcatcodes, "\\NC ") --~ for e in xmlcollected(e,cellspec) do ---~ texsprint(xml.content(e)) -- use some xmlprint +--~ texsprint(xml.text(e)) -- use some xmlprint --~ texsprint(ctxcatcodes, "\\NC") --~ end --~ texsprint(ctxcatcodes, "\\NR") @@ -115,7 +115,7 @@ function lxml.context.tabulate(root,namespace) for e in xmlcollected(root,bodyrowspec) do NC() for e in xmlcollected(e,cellspec) do - texsprint(xml.content(e)) -- test: xmlcprint(e) + texsprint(xml.text(e)) -- test: xmlcprint(e) NC() end NR() diff --git a/tex/context/base/x-mathml.lua b/tex/context/base/x-mathml.lua index d1ac4f62d..166db30b6 100644 --- a/tex/context/base/x-mathml.lua +++ b/tex/context/base/x-mathml.lua @@ -11,13 +11,12 @@ local utf = unicode.utf8 local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes local format, lower = string.format, string.lower local utfchar, utffind, utfgmatch = utf.char, utf.find, utf.gmatch -local xmlsprint, xmlcprint = xml.sprint, xml.cprint +local xmlsprint, xmlcprint, xmltext = xml.sprint, xml.cprint, xml.text +local lxmltext, get_id = lxml.text, lxml.get_id local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues lxml.mml = lxml.mml or { } -local get_id = lxml.get_id - -- an alternative is to remap to private codes, where we can have -- different properties .. to be done; this will move and become -- generic @@ -453,7 +452,7 @@ end function lxml.mml.mn(id,pattern) -- maybe at some point we need to interpret the number, but -- currently we assume an upright font - local str = xml.content(get_id(id),pattern) or "" + local str = xmltext(get_id(id),pattern) or "" str = str:gsub("(%s+)",utfchar(0x205F)) -- medspace e.g.: twenty one (nbsp is not seen) texsprint(ctxcatcodes,(str:gsub(".",n_replacements))) end @@ -463,12 +462,12 @@ function characters.remapentity(chr,slot) end function lxml.mml.mo(id,pattern) - local str = xml.content(get_id(id),pattern) or "" + local str = xmltext(get_id(id),pattern) or "" texsprint(ctxcatcodes,(utf.gsub(str,".",o_replacements))) end function lxml.mml.mi(id,pattern) - local str = xml.content(get_id(id),pattern) or "" + local str = xmltext(get_id(id),pattern) or "" -- str = str:gsub("^%s*(.-)%s*$","%1") local rep = i_replacements[str] if rep then @@ -609,12 +608,12 @@ local frametypes = { -- crazy element ... should be a proper structure instead of such a mess function lxml.mml.mcolumn(root) - root = lxml.id(root) + root = get_id(root) local matrix, numbers = { }, 0 local function collect(m,e) local tag = e.tg if tag == "mi" or tag == "mn" or tag == "mo" or tag == "mtext" then - local str = xml.content(e) + local str = xmltext(e) for s in utfcharacters(str) do -- utf.gmatch(str,".") btw, the gmatch was bugged m[#m+1] = { tag, s } end @@ -769,7 +768,7 @@ function lxml.mml.csymbol(root) local hash = url.hashed(lower(at.definitionUrl or "")) local full = hash.original or "" local base = hash.path or "" - local text = string.strip(lxml.content(root)) + local text = string.strip(lxmltext(root)) --~ texsprint(ctxcatcodes,format("\\mmlapplycsymbol{%s}{%s}{%s}{%s}",full,base,encoding,text)) texsprint(ctxcatcodes,"\\mmlapplycsymbol{",full,"}{",base,"}{",encoding,"}{",text,"}") end diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index f3a2ea70c..0b823a206 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua --- merge date : 10/29/09 21:30:47 +-- merge date : 11/01/09 21:29:22 do -- begin closure to overcome local limits and interference |