From 06465c8428905be5c083c70f4e7de6a59d129139 Mon Sep 17 00:00:00 2001 From: Marius Date: Mon, 20 Jun 2011 16:50:10 +0300 Subject: beta 2011.06.19 14:17 --- tex/context/base/back-exp.lua | 908 +++++++++++++--------------- tex/context/base/back-exp.mkiv | 51 +- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 4 +- tex/context/base/core-mis.mkiv | 37 +- tex/context/base/core-sys.mkiv | 105 ++-- tex/context/base/export-example.css | 32 + tex/context/base/export-example.rng | 23 + tex/context/base/export-example.tex | 36 +- tex/context/base/font-ctx.lua | 7 +- tex/context/base/font-ini.mkiv | 2 +- tex/context/base/grph-fig.mkiv | 3 + tex/context/base/grph-inc.lua | 13 + tex/context/base/l-table.lua | 19 +- tex/context/base/lang-def.lua | 9 + tex/context/base/lang-def.mkiv | 7 + tex/context/base/lang-ini.mkiv | 2 + tex/context/base/lxml-css.lua | 111 ++++ tex/context/base/lxml-css.mkiv | 39 ++ tex/context/base/mult-sys.mkiv | 1 + tex/context/base/node-aux.lua | 18 + tex/context/base/status-files.pdf | Bin 23626 -> 23636 bytes tex/context/base/status-lua.pdf | Bin 155960 -> 156367 bytes tex/context/base/strc-des.mkiv | 4 +- tex/context/base/strc-flt.mkiv | 8 +- tex/context/base/strc-itm.mkiv | 6 +- tex/context/base/strc-not.mkiv | 2 +- tex/context/base/strc-ren.mkiv | 21 +- tex/context/base/strc-sec.mkiv | 2 +- tex/context/base/strc-syn.mkiv | 8 +- tex/context/base/strc-tag.lua | 25 + tex/context/base/strc-tag.mkiv | 6 + tex/context/base/tabl-ntb.mkiv | 21 +- tex/context/base/tabl-tbl.mkiv | 52 +- tex/context/base/x-css.lua | 94 --- tex/context/base/x-css.mkiv | 39 -- tex/context/base/x-udhr.mkiv | 98 +++ tex/generic/context/luatex-fonts-enc.lua | 2 +- tex/generic/context/luatex-fonts-merged.lua | 23 +- 41 files changed, 1059 insertions(+), 785 deletions(-) create mode 100644 tex/context/base/lxml-css.lua create mode 100644 tex/context/base/lxml-css.mkiv delete mode 100644 tex/context/base/x-css.lua delete mode 100644 tex/context/base/x-css.mkiv create mode 100644 tex/context/base/x-udhr.mkiv (limited to 'tex') diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 2aaa0cf39..2f1377e98 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -6,49 +6,18 @@ if not modules then modules = { } end modules ['back-exp'] = { license = "see context related readme files" } --- depth can go away (autodepth nu) - - -- language -> only mainlanguage, local languages should happen through start/stoplanguage -- tocs/registers -> maybe add a stripper (i.e. just don't flush entries in final tree) +-- footnotes -> css 3 +-- bodyfont -> in styles.css +-- delimited -> left/right string (needs marking) +-- depth -> can go away (autodepth now and not used) -- Because we need to look ahead we now always build a tree (this was optional in -- the beginning). The extra overhead in the frontend is neglectable. - --- We can consider replacing attributes by the hash entry ... slower --- in resolving but it's still quite okay. - --- todo: less attributes e.g. internal only first node --- todo: build xml tree in mem (handy for cleaning) - --- delimited: left/right string (needs marking) - --- we can optimize the code ... currently the overhead is some 10% for xml + html - --- option: pack strings each page so that we save memory - -local nodecodes = nodes.nodecodes -local traverse_nodes = node.traverse -local hlist_code = nodecodes.hlist -local vlist_code = nodecodes.vlist - -local function locate(start,wantedid,wantedsubtype) - for n in traverse_nodes(start) do - local id = n.id - if id == wantedid then - if not wantedsubtype or n.subtype == wantedsubtype then - return n - end - elseif id == hlist_code or id == vlist_code then - local found = locate(n.list,wantedid,wantedsubtype) - if found then - return found - end - end - end -end - -nodes.locate = locate +-- +-- We can optimize the code ... currently the overhead is some 10% for xml + html so +-- there is no hurry. 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 @@ -104,19 +73,8 @@ local a_characters = attributes.private('characters') local a_exportstatus = attributes.private('exportstatus') local a_tagged = attributes.private('tagged') -local a_image = attributes.private('image') - -local a_taggedalign = attributes.private("taggedalign") -local a_taggedcolumns = attributes.private("taggedcolumns") -local a_taggedrows = attributes.private("taggedrows") local a_taggedpar = attributes.private("taggedpar") -local a_taggedpacked = attributes.private("taggedpacked") -local a_taggedsymbol = attributes.private("taggedsymbol") -local a_taggedinsert = attributes.private("taggedinsert") -local a_taggedtag = attributes.private("taggedtag") -local a_mathcategory = attributes.private("mathcategory") -local a_mathmode = attributes.private("mathmode") - +local a_image = attributes.private('image') local a_reference = attributes.private('reference') local a_textblock = attributes.private("textblock") @@ -137,13 +95,14 @@ local properties = structurestags.properties local userdata = structurestags.userdata -- might be combines with taglist local tagdata = structurestags.data local tagmetadata = structurestags.metadata +local detailedtag = structurestags.detailedtag local starttiming = statistics.starttiming local stoptiming = statistics.stoptiming -- todo: more locals (and optimize) -local exportversion = "0.22" +local exportversion = "0.30" local nofcurrentcontent = 0 -- so we don't free (less garbage collection) local currentcontent = { } @@ -170,6 +129,7 @@ local treeroot = tree local treehash = { } local extras = { } local checks = { } +local finalizers = { } local nofbreaks = 0 local used = { } local exporting = false @@ -271,7 +231,7 @@ setmetatableindex(spaces, function(t,k) return s end) -function structurestags.setattributehash(fulltag,key,value) +function structurestags.setattributehash(fulltag,key,value) -- public hash if type(fulltag) == "number" then fulltag = taglist[fulltag] if fulltag then @@ -288,6 +248,75 @@ function structurestags.setattributehash(fulltag,key,value) end end + +-- experiment: styles and images + +local usedstyles = { } + +local styletemplate = [[ +%s[detail='%s'] { + font-style : %s ; + font-variant : %s ; + font-weight : %s ; + color : %s ; +}]] + +local function allusedstyles(xmlfile) + local result = { format("/* styles for file %s */",xmlfile) } + for element, details in table.sortedpairs(usedstyles) do + for detail, data in table.sortedpairs(details) do + local s = xml.css.fontspecification(data.style) + local c = xml.css.colorspecification(data.color) + result[#result+1] = format(styletemplate,element,detail, + s.style or "inherit",s.variant or "inherit",s.weight or "inherit",c or "inherit") + end + end + return concat(result,"\n\n") +end + +local usedimages = { } + +local imagetemplate = [[ +%s[id="%s"] { + display : block ; + background-image : url(%s) ; + background-size : 100%% auto ; + width : %s ; + height : %s ; +}]] + +local function allusedimages(xmlfile) + local result = { format("/* images for file %s */",xmlfile) } + for element, details in table.sortedpairs(usedimages) do + for detail, data in table.sortedpairs(details) do + local name = data.name + if file.extname(name) == "pdf" then + -- temp hack .. we will have a remapper + name = file.replacesuffix(name,"svg") + end + result[#result+1] = format(imagetemplate,element,detail,name,data.width,data.height) + end + end + return concat(result,"\n\n") +end + +local function uniqueusedimages() + local unique = { } + for element, details in next, usedimages do + for detail, data in next, details do + local name = data.name + if file.extname(name) == "pdf" then + unique[file.replacesuffix(name,"svg")] = name + else + unique[name] = name + end + end + end + return unique +end + +-- + properties.vspace = { export = "break", nature = "display" } ----------------- = { export = "pagebreak", nature = "display" } @@ -361,144 +390,142 @@ function extras.document(result,element,detail,n,fulltag,di) checkdocument(di) end -local snames, snumbers = { }, { } +local itemgroups = { } -function structurestags.setitemgroup(packed,symbol,di) - local s = snumbers[symbol] - if not s then - s = #snames + 1 - snames[s], snumbers[symbol] = symbol, s +function structurestags.setitemgroup(current,packed,symbol) + itemgroups[detailedtag("itemgroup",current)] = { + packed = packed, + symbol = symbol, + } +end + +function extras.itemgroup(result,element,detail,n,fulltag,di) + local hash = itemgroups[fulltag] + if hash then + local v = hash.packed + if v then + result[#result+1] = " packed='yes'" + end + local v = hash.symbol + if v then + result[#result+1] = format(" symbol='%s'",v) + end end - texattribute[a_taggedpacked] = packed and 1 or unsetvalue - texattribute[a_taggedsymbol] = s end --- todo: per class +local synonyms = { } -local synonymnames, synonymnumbers = { }, { } -- can be one hash +function structurestags.setsynonym(current,tag) + synonyms[detailedtag("synonym",current)] = tag +end -function structurestags.setsynonym(class,tag) - local s = synonymnumbers[tag] - if not s then - s = #synonymnames + 1 - synonymnames[s], synonymnumbers[tag] = tag, s +function extras.synonym(result,element,detail,n,fulltag,di) + local tag = synonyms[fulltag] + if tag then + result[#result+1] = format(" tag='%s'",tag) end - texattribute[a_taggedtag] = s end -local sortingnames, sortingnumbers = { }, { } -- can be one hash +local sortings = { } + +function structurestags.setsorting(current,tag) + sortings[detailedtag("sorting",current)] = tag +end -function structurestags.setsorting(class,tag) - local s = sortingnumbers[tag] - if not s then - s = #sortingnames + 1 - sortingnames[s], sortingnumbers[tag] = tag, s +function extras.sorting(result,element,detail,n,fulltag,di) + local tag = sortings[fulltag] + if tag then + result[#result+1] = format(" tag='%s'",tag) end - texattribute[a_taggedtag] = s end -local insertids = { } +usedstyles.highlight = { } + +function structurestags.sethighlight(current,style,color) -- we assume global styles + usedstyles.highlight[current] = { + style = style, -- xml.css.fontspecification(style), + color = color, -- xml.css.colorspec(color), + } +end + +local descriptions = { } +local symbols = { } +local linked = { } -function structurestags.setdescriptionid(tag,n) +function structurestags.setdescription(tag,n) local nd = structures.notes.get(tag,n) -- todo: use listdata instead if nd then - local r = nd.references - texattribute[a_taggedinsert] = r.internal or unsetvalue - else - texattribute[a_taggedinsert] = unsetvalue + local references = nd.references + descriptions[references and references.internal] = detailedtag("description",tag) end end -function extras.descriptiontag(result,element,detail,n,fulltag,di) - local hash = attributehash[fulltag] - if hash then - local v = hash.insert - v = v and insertids[v] - if v then - result[#result+1] = format(" insert='%s'",v) - end +function structurestags.setdescriptionsymbol(tag,n) + local nd = structures.notes.get(tag,n) -- todo: use listdata instead + if nd then + local references = nd.references + symbols[references and references.internal] = detailedtag("descriptionsymbol",tag) end end -function extras.descriptionsymbol(result,element,detail,n,fulltag,di) - local hash = attributehash[fulltag] - if hash then - local v = hash.insert - v = v and insertids[v] - if v then - result[#result+1] = format(" insert='%s'",v) +function finalizers.descriptions(tree) + local n = 0 + for id, tag in next, descriptions do + local sym = symbols[id] + if sym then + n = n + 1 + linked[tag] = n + linked[sym] = n end end end -function extras.synonym(result,element,detail,n,fulltag,di) - local hash = attributehash[fulltag] - if hash then - local v = hash.tag - v = v and synonymnames[v] - if v then - result[#result+1] = format(" tag='%s'",v) - end +function extras.description(result,element,detail,n,fulltag,di) + local id = linked[fulltag] + if id then + result[#result+1] = format(" insert='%s'",id) -- maybe just fulltag end end -function extras.sorting(result,element,detail,n,fulltag,di) - local hash = attributehash[fulltag] - if hash then - local v = hash.tag - v = v and sortingnames[v] - if v then - result[#result+1] = format(" tag='%s'",v) - end +function extras.descriptionsymbol(result,element,detail,n,fulltag,di) + local id = linked[fulltag] + if id then + result[#result+1] = format(" insert='%s'",id) end end -local usedimages = { } +usedimages.image = { } + +function structurestags.setfigure(name,page,width,height) + usedimages.image[detailedtag("image")] = { + name = name, + page = page, + width = number.todimen(width,"cm","%0.3fcm"), + height = number.todimen(height,"cm","%0.3fcm"), + } +end function extras.image(result,element,detail,n,fulltag,di) - local hash = attributehash[fulltag] - if hash then - local v = hash.imageindex - if v then - local figure = img.ofindex(v) - if figure then - local fullname = figure.filepath - local name = file.basename(fullname) - local path = file.dirname(fullname) - local page = figure.page or 1 - local width = figure.width or 0 - local height = figure.height or 0 - local currentimage = { } - if name ~= "" then - result[#result+1] = format(" name='%s'",name) - currentimage.name = name - if file.extname(name) == "pdf" then - -- temp hack .. we will have a remapper - name = file.replacesuffix(name,"svg") - end - currentimage.filename = name - end - if path ~= "" then - result[#result+1] = format(" path='%s'",path) - currentimage.path = path - end - if page > 1 then - result[#result+1] = format(" page='%s'",page) - currentimage.page = page - end - if width > 0 then - width = number.todimen(width,"cm","%0.3fcm") - result[#result+1] = format(" width='%s'",width) - currentimage.width = width - end - if height > 0 then - height = number.todimen(height,"cm","%0.3fcm") - result[#result+1] = format(" ysize='%s'",height) - currentimage.height = height - end - usedimages[#usedimages+1] = currentimage - end - end + local data = usedimages.image[fulltag] + if data then + result[#result+1] = format(" id='%s' name='%s' page='%s' width='%s' height='%s'", + fulltag,data.name,data.page,data.width,data.height) + end +end + +local combinations = { } + +function structurestags.setcombination(nx,ny) + combinations[detailedtag("combination")] = { + nx = nx, + ny = ny, + } +end + +function extras.combination(result,element,detail,n,fulltag,di) + local data = combinations[fulltag] + if data then + result[#result+1] = format(" nx='%s' ny='%s'",data.nx,data.ny) end end @@ -575,6 +602,8 @@ function specials.internal(result,var) end end +local referencehash = { } + local function adddestination(result,references) -- todo: specials -> exporters and then concat if references then local reference = references.reference @@ -614,12 +643,9 @@ end function extras.link(result,element,detail,n,fulltag,di) -- for instance in lists a link has nested elements and no own text - local hash = attributehash[fulltag] - if hash then - local references = hash.reference - if references then - adddestination(result,structures.references.get(references)) - end + local reference = referencehash[fulltag] + if reference then + adddestination(result,structures.references.get(reference)) return true else local data = di.data @@ -1006,41 +1032,29 @@ function extras.float(result,element,detail,n,fulltag,di) end end -function extras.itemgroup(result,element,detail,n,fulltag,di) - local data = di.data - if data then - for i=1,#data do - local di = data[i] - if type(di) == "table" and di.tg == "item" then - local ddata = di.data - for i=1,#ddata do - local ddi = ddata[i] - if type(ddi) == "table" then - local tg = ddi.tg - if tg == "itemtag" or tg == "itemcontent" then - local hash = attributehash[ddi.fulltag] - if hash then - local v = hash.packed - if v and v == 1 then - result[#result+1] = " packed='yes'" - end - local v = hash.symbol - if v then - result[#result+1] = format(" symbol='%s'",snames[v]) - end - return - end - end - end - end - end - end +local tabledata = { } + +function structurestags.settablecell(rows,columns,align) + if align > 0 or rows > 1 or columns > 1 then + tabledata[detailedtag("tablecell")] = { + rows = rows, + columns = columns, + align = align, + } end end function extras.tablecell(result,element,detail,n,fulltag,di) - local hash = attributehash[fulltag] + local hash = tabledata[fulltag] if hash then + local v = hash.columns + if v and v > 1 then + result[#result+1] = format(" columns='%s'",v) + end + local v = hash.rows + if v and v > 1 then + result[#result+1] = format(" rows='%s'",v) + end local v = hash.align if not v or v == 0 then -- normal @@ -1051,29 +1065,52 @@ function extras.tablecell(result,element,detail,n,fulltag,di) elseif v == 3 then result[#result+1] = " align='flushleft'" end - local v = hash.columns - if v and v > 1 then - result[#result+1] = format(" columns='%s'",v) - end - local v = hash.rows - if v and v > 1 then - result[#result+1] = format(" rows='%s'",v) + end +end + +local tabulatedata = { } + +function structurestags.settabulatecell(align) + if align > 0 then + tabulatedata[detailedtag("tabulatecell")] = { + align = align, + } + end +end + +function extras.tabulate(result,element,detail,n,fulltag,di) + local data = di.data + for i=1,#data do + local di = data[i] + if di.tg == "tabulaterow" then + local did = di.data + local content = false + for i=1,#did do + local d = did[i].data + if d and #d > 0 then + content = true + break + end + end + if not content then + di.element = "" -- or simply remove + end end end end function extras.tabulatecell(result,element,detail,n,fulltag,di) - local hash = attributehash[fulltag] + local hash = tabulatedata[fulltag] if hash then local v = hash.align if not v or v == 0 then -- normal elseif v == 1 then - result[#result+1] = " align='flushright'" + result[#result+1] = " align='flushleft'" elseif v == 2 then - result[#result+1] = " align='middle'" + result[#result+1] = " align='flushright'" elseif v == 3 then - result[#result+1] = " align='flushleft'" + result[#result+1] = " align='middle'" end end end @@ -1112,7 +1149,6 @@ end local function begintag(result,element,nature,depth,di,skip) -- if needed we can use a local result with xresult ---~ local result = { } local detail = di.detail local n = di.n local fulltag = di.fulltag @@ -1196,17 +1232,9 @@ local function begintag(result,element,nature,depth,di,skip) result[#result+1] = "\n" linedone = true end ---~ xresult[#xresult+1] = concat(result) used[element][detail or ""] = nature -- for template css local metadata = tagmetadata[fulltag] if metadata then - -- metadata = table.toxml(metadata,"metadata",true,depth*2,2) -- nobanner - -- if not linedone then - -- result[#result+1] = format("\n%s\n",metadata) - -- linedone = true - -- else - -- result[#result+1] = format("%s\n",metadata) - -- end if not linedone then result[#result+1] = "\n" linedone = true @@ -1346,122 +1374,8 @@ local function breaktree(tree,parent,parentelement) -- also removes double break end end --- finalizers - -local function checkinserts(data) - local nofinserts = 0 - for i=1,#data do - local di = data[i] - if type(di) == "table" then -- id ~= false - if di.element == "descriptionsymbol" then - local hash = attributehash[di.fulltag] - if hash then - local i = hash.insert - if i then - nofinserts = nofinserts + 1 - insertids[i] = nofinserts - end - else - -- something is wrong - end - end - local d = di.data - if d then - checkinserts(d) - end - end - end -end - -- tabulaterow reconstruction .. can better be a checker (TO BE CHECKED) ---~ local function xcollapsetree() -- unwanted space injection ---~ for tag, trees in next, treehash do ---~ local d = trees[1].data ---~ if d then ---~ local nd = #d ---~ if nd > 0 then ---~ for i=2,#trees do ---~ local currenttree = trees[i] ---~ local currentdata = currenttree.data ---~ local previouspar = trees[i-1].parnumber ---~ currenttree.collapsed = true ---~ if previouspar == 0 or type(currentdata[1]) ~= "string" then ---~ previouspar = nil -- no need anyway so no further testing needed ---~ end ---~ local done = false ---~ local breakdone = false ---~ local spacedone = false ---~ for j=1,#currentdata do ---~ local cd = currentdata[j] ---~ if not cd then ---~ -- skip ---~ elseif type(cd) == "string" then ---~ if cd == "" then ---~ -- skip ---~ elseif cd == " " then ---~ -- done check ? ---~ if not spacedone and not breakdone then ---~ nd = nd + 1 ---~ d[nd] = cd ---~ spacedone = true ---~ end ---~ elseif done then ---~ if not spacedone and not breakdone then ---~ nd = nd + 1 ---~ d[nd] = " " ---~ spacedone = true ---~ end ---~ nd = nd + 1 ---~ d[nd] = cd ---~ else ---~ done = true ---~ local currentpar = d.parnumber ---~ if not currentpar then ---~ if not spacedone and not breakdone then ---~ nd = nd + 1 ---~ d[nd] = " " -- brr adds space in unwanted places (like math) ---~ spacedone = true ---~ end ---~ previouspar = nil ---~ elseif not previouspar then ---~ if not spacedone and not breakdone then ---~ nd = nd + 1 ---~ d[nd] = " " ---~ spacedone = true ---~ end ---~ previouspar = currentpar ---~ elseif currentpar ~= previouspar then ---~ if not breakdone then ---~ if not spacedone then ---~ nd = nd + 1 ---~ end ---~ d[nd] = makebreaknode(currenttree) ---~ breakdone = true ---~ end ---~ previouspar = currentpar ---~ else ---~ spacedone = false ---~ breakdone = false ---~ end ---~ nd = nd + 1 ---~ d[nd] = cd ---~ end ---~ else ---~ if cd.tg == "break" then ---~ breakdone = true ---~ end ---~ nd = nd + 1 ---~ d[nd] = cd ---~ end ---~ currentdata[j] = false ---~ end ---~ end ---~ end ---~ end ---~ end ---~ end - local function collapsetree() for tag, trees in next, treehash do local d = trees[1].data @@ -1506,17 +1420,32 @@ local function collapsetree() end end +local function finalizetree(tree) + for _, finalizer in next, finalizers do + finalizer(tree) + end +end + local function indextree(tree) local data = tree.data if data then + local n, new = 0, { } for i=1,#data do local d = data[i] - if type(d) == "table" then - d.__i__ = i + if not d then + -- skip + elseif type(d) == "string" then + n = n + 1 + new[n] = d + elseif not d.collapsed then + n = n + 1 + d.__i__ = n d.__p__ = tree indextree(d) + new[n] = d end end + tree.data = new end end @@ -1737,7 +1666,7 @@ end -- whatsit_code localpar_code -local function collectresults(head,list) +local function collectresults(head,list) -- is last used (we also have currentattribute) local p for n in traverse_nodes(head) do local id = n.id -- 14: image, 8: literal (mp) @@ -1763,21 +1692,15 @@ local function collectresults(head,list) currentparagraph = has_attribute(n,a_taggedpar) currentnesting = tl currentattribute = at - local ah = { -- this includes detail ! -- we can move some to te tex end - align = has_attribute(n,a_taggedalign ), - columns = has_attribute(n,a_taggedcolumns), - rows = has_attribute(n,a_taggedrows ), - packed = has_attribute(n,a_taggedpacked ), - symbol = has_attribute(n,a_taggedsymbol ), - insert = has_attribute(n,a_taggedinsert ), - reference = has_attribute(n,a_reference ), - tag = has_attribute(n,a_taggedtag ), -- used for synonyms - } - if next(ah) then - attributehash[tl[#tl]] = ah - end last = at pushentry(currentnesting) + -- We need to intercept this here; maybe I will also move this + -- to a regular setter at the tex end. + local r = has_attribute(n,a_reference) + if r then + referencehash[tl[#tl]] = r -- fulltag + end + -- elseif last then local at = has_attribute(n,a_taggedpar) if at ~= currentparagraph then @@ -1848,12 +1771,7 @@ local function collectresults(head,list) pushcontent() pushentry(currentnesting) -- ?? end - local tl = taglist[at] - local i = locate_node(n,whatsit_code,refximage_code) - if i then - attributehash[tl[#tl]] = { imageindex = i.index } - end - pushentry(tl) -- has an index, todo: flag empty element + pushentry(taglist[at]) -- has an index, todo: flag empty element if trace_export then report_export("%s + ]] -local csspreamble = [[ +local function wholepreamble() + return format(xmlpreamble,tex.jobname,os.date(),environment.version,exportversion) +end +local csspreamble = [[ ]] +local function allusedstylesheets(xmlfile,cssfiles,files) + local result = { } + for i=1,#cssfiles do + local cssfile = cssfiles[i] + if type(cssfile) ~= "string" or cssfile == variables.yes or cssfile == "" or cssfile == xmlfile then + cssfile = file.replacesuffix(xmlfile,"css") + else + cssfile = file.addsuffix(cssfile,"css") + end + files[#files+1] = cssfile + report_export("adding css reference '%s",cssfile) + result[#result+1] = format(csspreamble,cssfile) + end + return concat(result) +end + +local e_template = [[ +%s { + display: %s ; +}]] + +local d_template = [[ +%s[detail=%s] { + display: %s ; +}]] + +local displaymapping = { + inline = "inline", + display = "block", + mixed = "inline", +} + +local function allusedelements(xmlfile) + local result = { format("/* template for file %s */",xmlfile) } + for element, details in table.sortedhash(used) do + result[#result+1] = format("/* category: %s */",element) + for detail, nature in table.sortedhash(details) do + local d = displaymapping[nature or "display"] or "block" + if detail == "" then + result[#result+1] = format(e_template,element,d) + else + result[#result+1] = format(d_template,element,detail,d) + end + end + end + return concat(result,"\n\n") +end + +local function allcontent(tree) + local result = { } + flushtree(result,tree.data,"display",0) -- we need to collect images + result = concat(result) + result = gsub(result,"\n *\n","\n") + result = gsub(result,"\n +([^< ])","\n%1") + return result +end + -- local xhtmlpreamble = [[ -- -- ]] -local imagetemplate = [[ -image[name="%s"] { - display : block ; - background-image : url(%s) ; - background-size : 100%% auto ; - width : %s ; - height : %s ; -}]] +local function cleanxhtmltree(xmltree) + if xmltree then + local xmlwrap = xml.wrap + for e in xml.collected(xmltree,"/document") do + e.at["xmlns:xhtml"] = "http://www.w3.org/1999/xhtml" + break + end + -- todo: inject xhtmlpreamble (xmlns should have be enough) + local wrapper = { tg = "a", ns = "xhtml", at = { href = "unknown" } } + for e in xml.collected(xmltree,"link") do + local location = e.at.location + if location then + wrapper.at.href = "#" .. gsub(location,":","_") + xmlwrap(e,wrapper) + end + end + local wrapper = { tg = "a", ns = "xhtml", at = { name = "unknown" } } + for e in xml.collected(xmltree,"!link[@location]") do + local location = e.at.location + if location then + wrapper.at.name = gsub(location,":","_") + xmlwrap(e,wrapper) + end + end + return xmltree + else + return xml.convert("\ninvalid xhtml tree") + end +end local cssfile, xhtmlfile = nil, nil @@ -2075,136 +2057,81 @@ directives.register("backend.export.xhtml",function(v) xhtmlfile = v end) local function stopexport(v) starttiming(treehash) + -- finishexport() + -- collapsetree(tree) indextree(tree) checktree(tree) breaktree(tree) - checkinserts(tree.data) + finalizetree(tree) + -- hashlistdata() + -- if type(v) ~= "string" or v == variables.yes or v == "" then v = tex.jobname end - local xmlfile = file.addsuffix(v,"export") - if type(cssfile) ~= "string" or cssfile == "" then - cssfile = nil + local basename = file.basename(v) + local xmlfile = file.addsuffix(basename,"export") + -- + local imagefilename = file.addsuffix(file.removesuffix(xmlfile) .. "-images","css") + local stylefilename = file.addsuffix(file.removesuffix(xmlfile) .. "-styles","css") + local templatefilename = file.replacesuffix(xmlfile,"template") + local specificationfilename = file.replacesuffix(xmlfile,"specification") + -- + local cssfiles = { } + if type(cssfile) == "string" and cssfile ~= "" then + cssfiles = settings_to_array(cssfile) + insert(cssfiles,1,imagefilename) + insert(cssfiles,1,stylefilename) end - local files = { } - local specification = { - name = file.removesuffix(v), - identifier = os.uuid(), - files = files, + cssfiles = table.unique(cssfiles) + -- + local result = allcontent(tree) -- also does some housekeeping and data collecting + -- + local files = { + xhtmlfile, + -- stylefilename, + -- imagefilename, + } + local results = concat { + wholepreamble(), + allusedstylesheets(xmlfile,cssfiles,files), -- ads to files + result, } + -- + files = table.unique(files) + -- report_export("saving xml data in '%s",xmlfile) + io.savedata(xmlfile,results) -- - local results = { } - -- collect tree - local result = { } - flushtree(result,tree.data,"display",0) -- we need to collect images - result = concat(result) - result = gsub(result,"\n *\n","\n") - result = gsub(result,"\n +([^< ])","\n%1") + report_export("saving css image definitions in '%s",imagefilename) + io.savedata(imagefilename,allusedimages(xmlfile)) -- - local imgfile = file.addsuffix(file.removesuffix(xmlfile) .. "-images","css") - results[#results+1] = format(xmlpreamble,tex.jobname,os.date(),environment.version,exportversion) - if cssfile then - local cssfiles = settings_to_array(cssfile) - for i=1,#cssfiles do - local cssfile = cssfiles[i] - files[#files+1] = cssfile - if type(cssfile) ~= "string" or cssfile == variables.yes or cssfile == "" or cssfile == xmlfile then - cssfile = file.replacesuffix(xmlfile,"css") - else - cssfile = file.addsuffix(cssfile,"css") - end - report_export("adding css reference '%s",cssfile) - results[#results+1] = format(csspreamble,cssfile) - end - if #usedimages > 0 then - results[#results+1] = format(csspreamble,imgfile) - end - end + report_export("saving css style definitions in '%s",cssfile) + io.savedata(stylefilename,allusedstyles(xmlfile)) -- - results[#results+1] = result + report_export("saving css template in '%s",templatefilename) + io.savedata(templatefilename,allusedelements(xmlfile)) -- - results = concat(results) - -- if needed we can do a cleanup of the tree (no need to load for xhtml then) - -- write to file - io.savedata(xmlfile,results) - -- css template file - if cssfile then - if #usedimages > 0 then - report_export("saving css image definitions in '%s",imgfile) - local result = { format("/* images for file %s */",xmlfile) } - for i=1,#usedimages do - local im = usedimages[i] - -- todo: path - result[#result+1] = format(imagetemplate,im.name,im.filename,im.width,im.height) - end - io.savedata(imgfile,concat(result,"\n\n")) - else - os.remove(imgfile) - end - -- - local cssfile = file.replacesuffix(xmlfile,"template") - report_export("saving css template in '%s",cssfile) - local templates = { format("/* template for file %s */",xmlfile) } - for element, details in table.sortedhash(used) do - templates[#templates+1] = format("/* category: %s */",element) - for detail, nature in table.sortedhash(details) do - local d = displaymapping[nature or "display"] or "block" - if detail == "" then - templates[#templates+1] = format(e_template,element,d) - else - templates[#templates+1] = format(d_template,element,detail,d) - end - end - end - io.savedata(cssfile,concat(templates,"\n\n")) - else - os.remove(imgfile) - end - -- xhtml references if xhtmlfile then - -- messy if type(v) ~= "string" or xhtmlfile == true or xhtmlfile == variables.yes or xhtmlfile == "" or xhtmlfile == xmlfile then xhtmlfile = file.replacesuffix(xmlfile,"xhtml") else xhtmlfile = file.addsuffix(xhtmlfile,"xhtml") end report_export("saving xhtml variant in '%s",xhtmlfile) - -- local xmltree = xml.load(xmlfile) - local xmltree = xml.convert(results) - if xmltree then - local xmlwrap = xml.wrap - for e in xml.collected(xmltree,"/document") do - e.at["xmlns:xhtml"] = "http://www.w3.org/1999/xhtml" - break - end - -- todo: inject xhtmlpreamble (xmlns should have be enough) - local wrapper = { tg = "a", ns = "xhtml", at = { href = "unknown" } } - for e in xml.collected(xmltree,"link") do - local location = e.at.location - if location then - wrapper.at.href = "#" .. gsub(location,":","_") - xmlwrap(e,wrapper) - end - end - local wrapper = { tg = "a", ns = "xhtml", at = { name = "unknown" } } - for e in xml.collected(xmltree,"!link[@location]") do - local location = e.at.location - if location then - wrapper.at.name = gsub(location,":","_") - xmlwrap(e,wrapper) - end - end - xml.save(xmltree,xhtmlfile) - end - files[#files+1] = xhtmlfile - specification.root = xhtmlfile - local specfile = file.replacesuffix(xmlfile,"specification") - report_export("saving specification in '%s' (mtxrun --script epub --make %s)",specfile,specfile) - io.savedata(specfile,table.serialize(specification,true)) + local xmltree = cleanxhtmltree(xml.convert(results)) + xml.save(xmltree,xhtmlfile) + local specification = { + name = file.removesuffix(v), + identifier = os.uuid(), + images = uniqueusedimages(), + root = xhtmlfile, + files = files, + } + report_export("saving specification in '%s' (mtxrun --script epub --make %s)",specificationfilename,specificationfilename) + io.savedata(specificationfilename,table.serialize(specification,true)) end stoptiming(treehash) end @@ -2218,7 +2145,6 @@ local function startexport(v) -- not yet known in task-ini appendaction("shipouts", "normalizers", "nodes.handlers.export") -- enableaction("shipouts","nodes.handlers.export") --- enableaction("shipouts","nodes.handlers.accessibility") enableaction("math", "noads.handlers.tags") --~ appendaction("finalizers","lists","builders.paragraphs.tag") @@ -2236,7 +2162,15 @@ statistics.register("xml exporting time", function() end end) -commands.settagitemgroup = structurestags.setitemgroup -commands.settagsynonym = structurestags.setsynonym -commands.settagsorting = structurestags.setsorting -commands.settagdescriptionid = structurestags.setdescriptionid +-- These are called at the tex end: + +commands.settagitemgroup = structurestags.setitemgroup +commands.settagsynonym = structurestags.setsynonym +commands.settagsorting = structurestags.setsorting +commands.settagdescription = structurestags.setdescription +commands.settagdescriptionsymbol = structurestags.setdescriptionsymbol +commands.settaghighlight = structurestags.sethighlight +commands.settagfigure = structurestags.setfigure +commands.settagcombination = structurestags.setcombination +commands.settagtablecell = structurestags.settablecell +commands.settagtabulatecell = structurestags.settabulatecell diff --git a/tex/context/base/back-exp.mkiv b/tex/context/base/back-exp.mkiv index d6fb74a97..715ccfd5c 100644 --- a/tex/context/base/back-exp.mkiv +++ b/tex/context/base/back-exp.mkiv @@ -26,14 +26,7 @@ % we can replace this by a more generic attributeset mechanism where we bind % to any element (needed anyway, see userdata thingies) -\definesystemattribute[taggedrows] [public] -\definesystemattribute[taggedcolumns][public] -\definesystemattribute[taggedalign] [public] -\definesystemattribute[taggedpar] [public] -\definesystemattribute[taggedpacked] [public] -\definesystemattribute[taggedsymbol] [public] -\definesystemattribute[taggedinsert] [public] -\definesystemattribute[taggedtag] [public] +\definesystemattribute[taggedpar][public] \def\setelementexporttag {\dotripleargument\dosetelementexporttag} @@ -45,8 +38,17 @@ \expandafter\expandafter\expandafter\dosetelementexporttagb \fi\fi} -\def\dosetelementexporttaga[#1][#2][#3]{\ctxcommand{settagproperty("#1","#2","#3")}} -\def\dosetelementexporttagb[#1][#2][#3]{\ctxcommand{settagproperty("#1","export","#2")}} +\def\dosetelementexporttaga[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","#2","#3")}} +\def\dosetelementexporttagb[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","export","#2")}} + +% todo: no need for calls when trialtypesetting + +\def\taggedctxcommand + {\iftrialtypesetting + \expandafter\gobbleoneargument + \else + \expandafter\ctxcommand + \fi} \newcount\tagparcounter @@ -65,29 +67,34 @@ \to \everytabulatepar % tricky, maybe this should be neverypar \appendtoks - \def\dotagnofTABLEcolumns{\attribute\taggedcolumnsattribute\!!counta}% - \def\dotagnofTABLErows {\attribute\taggedrowsattribute \!!countb}% + \def\dotagTABLEcell {\taggedctxcommand{settagtablecell(\number\tablecellrows,\number\tablecellcolumns,\number\raggedstatus)}}% + \def\dotagTABLEsignal{\char\zerocount}% brrr, we need to tag empty cells (unless we start numbering) \to \everyenableelements \appendtoks - \def\dotagTABLEalign{\attribute\taggedalignattribute\raggedstatus}% - \def\dotagTABLEcell {\char\zerocount}% brrr, we need to tag empty cells (unless we start numbering) + \def\dotagtabulatecell {\taggedctxcommand{settagtabulatecell(\number\tabulatealign)}}% + \def\dotagtabulatesignal{\dontleavehmode\char\zerocount\ignorespaces}% \to \everyenableelements \appendtoks - \def\dotagtabulatesignal{\dontleavehmode\char\zerocount\ignorespaces}% + \def\dotagsynonym{\taggedctxcommand{settagsynonym("\currentsynonym","\currentsynonymtag")}}% \to \everyenableelements -\appendtoks - \def\dotagtabulatealign{\attribute\taggedalignattribute\ifcase\tabulatealign\attributeunsetvalue\or\plusthree\or\plusone\or\plustwo\or\attributeunsetvalue\fi}% +\appendtoks % frozen and assumed global per highlight class + \def\dotaghighlight{\taggedctxcommand{settaghighlight("\currenthighlight","\highlightparameter\c!style",\number\attribute\colorattribute)}}% +\to \everyenableelements + +\appendtoks % we can have differently scaled images + \def\dotagfigure{\taggedctxcommand{settagfigure("\figurefileoriginal","\figurefilepage",\number\dimexpr\figurewidth,\number\dimexpr\figureheight)}}% \to \everyenableelements \appendtoks - \def\dotagsynonym{\ctxcommand{settagsynonym("\currentsynonym","\currentsynonymtag")}}% + %\def\dotagcombination{\taggedctxcommand{settagcombination(\combinationparameter\c!nx,\combinationparameter\c!ny)}}% + \def\dotagcombination{\taggedctxcommand{settagcombination(\number\horcombination,\number\totcombination)}}% \to \everyenableelements \appendtoks - \def\dotagsorting{\ctxcommand{settagsorting("\currentsorting","\currentsortingtag")}}% + \def\dotagsorting{\taggedctxcommand{settagsorting("\currentsorting","\currentsortingtag")}}% \to \everyenableelements \appendtoks @@ -95,15 +102,15 @@ \to \everyenableelements \appendtoks - \def\dotagsetitemize{\ctxcommand{settagitemgroup(\ifconditional\packlistitem true\else false\fi,"\currentitemsymbol")}}% + \def\dotagsetitemgroup{\taggedctxcommand{settagitemgroup("\currentitemgroup",\ifconditional\packlistitem true\else false\fi,"\currentitemsymbol")}}% \to \everyenableelements \appendtoks - \def\dotagsetdescriptiontag{\ctxcommand{settagdescriptionid("\currentdescription",\currentdescriptionnumberentry)}}% + \def\dotagsetdescription{\taggedctxcommand{settagdescription("\currentdescription",\currentdescriptionnumberentry)}}% \to \everyenableelements \appendtoks - \def\dotagsetnotesymbol{\ctxcommand{settagdescriptionid("\currentnote",\currentnotenumber)}}% + \def\dotagsetnotesymbol{\taggedctxcommand{settagdescriptionsymbol("\currentnote",\currentnotenumber)}}% \to \everyenableelements \appendtoks diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index f4eab4345..b53881d0a 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{2011.06.16 18:20} +\newcontextversion{2011.06.19 14:17} %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 da94d83c5..623c23eb6 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{2011.06.16 18:20} +\newcontextversion{2011.06.19 14:17} %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.mkii b/tex/context/base/context.mkii index b7d45a1cc..32d875b1c 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{2011.06.16 18:20} +\edef\contextversion{2011.06.19 14:17} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 03e362fd0..e7598d892 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.06.16 18:20} +\edef\contextversion{2011.06.19 14:17} %D For those who want to use this: @@ -303,6 +303,8 @@ \loadmarkfile{font-col} \loadmarkfile{font-gds} +\loadmarkfile{lxml-css} + \loadmarkfile{spac-chr} % depends on fonts \loadmarkfile{blob-ini} % not to be used, we only use a helper diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv index 19e904e41..8a8203b9b 100644 --- a/tex/context/base/core-mis.mkiv +++ b/tex/context/base/core-mis.mkiv @@ -1686,7 +1686,7 @@ % todo: \startcombination \startcomb \stopcomb ... -% needs to be mkiv'd +% needs to be mkiv'd (we could map this onto bTABLE) \newcount\horcombination % counter \newcount\totcombination @@ -1725,11 +1725,11 @@ % \startcombination[1*2] {alpha} {a} {beta} {b} \stopcombination % \startcombination[2] {alpha} {a} {beta} {b} \stopcombination -\def\dostartcombination[#1][#2]% +\def\dostartcombination[#1][#2]% needs a cleanup, also nx ny (pretty old, this one) {\global\setsystemmode{combination}% \doifnothing{#1}\firstargumentfalse % to be sure (when called in macros) \doifnothing{#2}\secondargumentfalse % to be sure (when called in macros) - \ifsecondargument + \ifsecondargument % todo: nx ny \def\currentcombination{#1}% \edef\currentcombinationspec{#2*1*}% \else % better : \doifcombinationelse ... \??co#1\c!location @@ -1743,36 +1743,50 @@ \edef\currentcombinationspec{2*1*}}}% \fi \forgetall +\dostarttagged\t!combination\currentcombination \doifelse{\combinationparameter\c!height}\v!fit \vbox {\vbox to \combinationparameter\c!height}% \bgroup \let\combination\empty % permits \combination{}{} handy for cld + \setuphorizontaldivision + [\c!n=\v!fit,\c!distance=\combinationparameter\c!distance]% \expanded{\dodostartcombination[\currentcombinationspec]}} +\ifdefined\dotagcombination \else \let\dotagcombination\relax \fi + \long\def\dodostartcombination[#1*#2*#3]% - {\setuphorizontaldivision - [\c!n=\v!fit,\c!distance=\combinationparameter\c!distance]% - \global\horcombination#1% + {\global\horcombination#1% \global\totcombination#2% +\dotagcombination \global\setbox\combinationstack\emptybox \xdef\maxhorcombination{\the\horcombination}% \multiply\totcombination\horcombination \tabskip\zeropoint \doifelse{\combinationparameter\c!width}\v!fit {\halign}{\halign to \combinationparameter\c!width}% - \bgroup&% + \bgroup + &% %\hfil##\hfil% now : location={left,top} \expanded{\doifnotinset{\v!left}{\combinationparameter\c!location}}\hfil ##% \expanded{\doifnotinset{\v!right}{\combinationparameter\c!location}}\hfil - &\tabskip\zeropoint \!!plus 1fill##\cr + &% + \tabskip\zeropoint \!!plus 1fill + ##% + \cr \docombination} \def\docombination % we want to add struts but still ignore an empty box - {\dowithnextbox - {\setbox0\flushnextbox + {\dostarttagged\t!combinationpair\empty + \dostarttagged\t!combinationcontent\empty + \dowithnextbox + {\dostoptagged + \setbox0\flushnextbox + \dostarttagged\t!combinationcaption\empty \dowithnextbox - {\setbox2\flushnextbox + {\dostoptagged + \dostoptagged + \setbox2\flushnextbox \dodocombination}% \vtop\bgroup \def\next @@ -1851,6 +1865,7 @@ \unexpanded\def\stopcombination {{\scratchtoks{{}{}{}}\dorecurse\totcombination{\appendtoks{}{}{}{}\to\scratchtoks}\expandafter}\the\scratchtoks \egroup + \dostoptagged \egroup} \newbox\combinationstack diff --git a/tex/context/base/core-sys.mkiv b/tex/context/base/core-sys.mkiv index 253ea6ece..cf3c7f7db 100644 --- a/tex/context/base/core-sys.mkiv +++ b/tex/context/base/core-sys.mkiv @@ -186,79 +186,54 @@ \definecomplexorsimple\start \definecomplexorsimple\stop -% \def\dododefinestartstop[#1][#2]% todo: use indirect commands -% {\getparameters -% [\??be#1] -% [\c!before=, -% \c!after=, -% \c!inbetween=, -% \c!commands=, -% \c!style=, -% #2]% -% \setuvalue{#1}% -% {\groupedcommand -% {\getvalue{\??be#1\c!commands}% -% \dostarttagged\t!construct{#1}% -% \dostartattributes{\??be#1}\c!style\c!color} -% {\dostopattributes -% \dostoptagged -% \getvalue{\??be#1\c!inbetween}}}% -% \setuvalue{\e!start#1}% -% {\getvalue{\??be#1\c!before}% -% \bgroup -% \getvalue{\??be#1\c!commands}% -% \dostarttagged\t!construct{#1}% -% \dostartattributes{\??be#1}\c!style\c!color\empty}% -% \setuvalue{\e!stop#1}% -% {\dostopattributes -% \dostoptagged -% \egroup -% \getvalue{\??be#1\c!after}}} -% -% \def\dodefinestartstop[#1][#2]% -% {\def\docommand##1{\dododefinestartstop[##1][#2]}% -% \processcommalist[#1]\docommand} -% -% \unexpanded\def\definestartstop -% {\dodoubleargument\dodefinestartstop} -% -% \def\dosetupstartstop[#1][#2]% -% {\def\docommand##1{\getparameters[\??be##1][#2]}% -% \processcommalist[#1]\docommand} -% -% \unexpanded\def\setupstartstop -% {\dodoubleargument\dosetupstartstop} - - % \c!before \c!after \c!inbetween \c!commands \c!style \c!color \installcommandhandler{\??be}{startstop}{\??be} \appendtoks - \normalexpanded{\dodefinestartstop{\currentstartstop}}% + \setuevalue{\e!start\currentstartstop}{\dostartstop_start {\currentstartstop}}% + \setuevalue{\e!stop \currentstartstop}{\dostartstop_stop {\currentstartstop}}% + \setuevalue {\currentstartstop}{\dostartstop_indeed{\currentstartstop}}% \to \everydefinestartstop -\unexpanded\def\dodefinestartstop#1% - {\setuvalue{#1}% - {\groupedcommand - {\def\currentstartstop{#1}% - \startstopparameter\c!commands - \dostarttagged\t!construct\currentstartstop - \dosetstartstopattributes\c!style\c!color} - {\def\currentstartstop{#1}% - \dostoptagged - \startstopparameter\c!inbetween}}% - \setuvalue{\e!start#1}% - {\namedstartstopparameter{#1}\c!before - \bgroup - \def\currentstartstop{#1}% - \startstopparameter\c!commands +\unexpanded\def\dostartstop_start#1% + {\namedstartstopparameter{#1}\c!before + \bgroup + \def\currentstartstop{#1}% + \startstopparameter\c!commands + \dostarttagged\t!construct\currentstartstop + \dosetstartstopattributes\c!style\c!color} + +\unexpanded\def\dostartstop_stop#1% + {\dostoptagged + \egroup + \namedstartstopparameter{#1}\c!after} + +\unexpanded\def\dostartstop_indeed#1% + {\groupedcommand + {\def\currentstartstop{#1}% + \startstopparameter\c!commands % will become setups \dostarttagged\t!construct\currentstartstop - \dosetstartstopattributes\c!style\c!color}% - \setuvalue{\e!stop#1}% - {\dostoptagged - \egroup - \namedstartstopparameter{#1}\c!after}} + \dosetstartstopattributes\c!style\c!color} + {\def\currentstartstop{#1}% + \dostoptagged + \startstopparameter\c!inbetween}} + +\installcommandhandler{\??hl}{highlight}{\??hl} % we could do with less + +\appendtoks + \setuevalue{\currenthighlight}{\dohighlight_indeed{\currenthighlight}}% +\to \everydefinehighlight + +\ifdefined\dotaghighlight \else \let\dotaghighlight\relax \fi + +\unexpanded\def\dohighlight_indeed#1% inline style/color switch + {\groupedcommand + {\def\currenthighlight{#1}% + \dostarttagged\t!highlight\currenthighlight + \dosethighlightattributes\c!style\c!color + \dotaghighlight} + {\dostoptagged}} % \docommand kan niet worden gebruikt omdat deze macro % soms lokaal wordt gebruikt diff --git a/tex/context/base/export-example.css b/tex/context/base/export-example.css index 75a74994a..503d4279c 100644 --- a/tex/context/base/export-example.css +++ b/tex/context/base/export-example.css @@ -76,6 +76,7 @@ break { } /* construct : inline */ +/* highlight : inline */ construct { } @@ -84,6 +85,9 @@ construct[detail="important"] { font-weight : bold ; } +highlight { /* todo: style and color */ +} + /* section : display */ /* sectiontitle : mixed */ /* sectionnumber : mixed */ @@ -401,6 +405,34 @@ tabulatecell { padding-right : 1em ; } +/* combination : display */ +/* combinationpair : display */ +/* combinationcontent : mixed */ +/* combinationcaption : mixed */ + +combination { + display : table ; + margin-top : 0em ; + margin-bottom : 0em ; +} + +combinationpair { + display : table-cell ; + padding-right : 1em ; +} + +combinationcontent { + display : table-row ; + text-align : center ; +} + +combinationcaption { + display : table-row ; + padding-top : 1ex ; + text-align : center ; +} + + /* list : display */ /* listitem : display */ /* listtag : mixed */ diff --git a/tex/context/base/export-example.rng b/tex/context/base/export-example.rng index 6e6c03c29..93b21ba50 100644 --- a/tex/context/base/export-example.rng +++ b/tex/context/base/export-example.rng @@ -5,6 +5,7 @@ # todo: check all content (not yet ok but a bit boring job) # todo: add attributes +# todo: we need more | and less , # # validate with "rnv -c export-example.rng" @@ -28,14 +29,17 @@ c_everything = | e_section | e_float | e_formula + | e_combination c_inline = text | e_ignore | e_metadata | e_construct + | e_highlight | e_verbatim | e_description + | e_descriptionsymbol | e_sorting | e_synonym | e_image @@ -103,6 +107,10 @@ e_construct = element construct { c_everything* } +e_highlight = element highlight { + c_inline* +} + e_itemgroup = element itemgroup { element item { element itemtag { @@ -114,6 +122,17 @@ e_itemgroup = element itemgroup { } } +e_combination = element combination { + element combinationpair { + element combinationcontent { + inline* + } , + element combinationcaption { + inline* + } + } +} + e_description = element description { element descriptiontag { c_inline* @@ -126,6 +145,10 @@ e_description = element description { } } +e_descriptionsymbol = element descriptionsymbol { + c_inline* +} + e_verbatimblock = element verbatimblock { element verbatimlines { element verbatimline { diff --git a/tex/context/base/export-example.tex b/tex/context/base/export-example.tex index 6181c9125..6885cfe37 100644 --- a/tex/context/base/export-example.tex +++ b/tex/context/base/export-example.tex @@ -1,5 +1,8 @@ +\usemodule[abr-01] + \setupbackend [export=export-example.xml, + xhtml=export-example.xhtml, css=export-example.css] \definedescription @@ -13,15 +16,32 @@ \setupbodyfont [dejavu] +\setupinteraction + [state=start] + +\setupwhitespace + [big] + +\definehighlight[interesting][style=bold,color=red] + \starttext \startchapter[title=Example] \startparagraph \input zapf (Zapf) \stopparagraph +\startparagraph + Watching a \interesting {movie} after reading a review on \goto{my favourite movie + reviews site}[url(http://outlawvern.com/)] is much more fun. \footnote {Just a note.} +\stopparagraph + \placefigure {} - {\externalfigure[hacker.jpg]} + {\startcombination[3*1] + {\externalfigure[hacker.jpg][width=3cm]} {first} + {\externalfigure[hacker.jpg][width=4cm]} {second} + {\externalfigure[hacker.jpg][width=2cm]} {third} + \stopcombination} \startparagraph \input zapf (Zapf) \stopparagraph @@ -42,7 +62,7 @@ \startitem \input knuth (Knuth) \stopitem \stopitemize -\startitemize[2] +\startitemize[2,packed] \startitem \input zapf (Zapf) \stopitem \startitem \input tufte (Tufte) \stopitem \stopitemize @@ -64,6 +84,18 @@ Okay, it's somewhat boring to always use the same formula, so how about $\sqrt{4} = 2$ or traveling at \unit{120 km/h} instead of $\unit{110 km/h}$. \stopparagraph +\bTABLE +\bTR \bTD test \eTD \bTD test \eTD \eTR +\bTR \bTD[nx=2] test \eTD \eTR +\eTABLE + +\starttabulate[|l|r|p|] +\NC left \NC right \NC \input ward \NC \NR +\NC l \NC r \NC \input ward \NC \NR +\stoptabulate + +It looks like we're using \CONTEXT\ to produce some kind of \XML\ output. + \typefile{export-example.tex} \stopchapter diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index 9f2e4f255..5b8a4e8ec 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -114,6 +114,7 @@ hashes.characters = chardata hashes.parameters = parameters hashes.quads = quaddata hashes.xheights = xheightdata +hashes.csnames = csnames setmetatableindex(chardata, function(t,k) local characters = fontdata[k].characters @@ -714,10 +715,6 @@ function definers.stage_two(global,cs,str,size,inheritancemode,classfeatures,fon end end local tfmdata = definers.read(specification,size) -- id not yet known - local cs = specification.cs - if cs then - csnames[cs] = tfmdata -- new (beware: locals can be forgotten) - end if not tfmdata then report_defining("unable to define %s as \\%s",name,cs) texsetcount("global","lastfontid",-1) @@ -727,6 +724,7 @@ function definers.stage_two(global,cs,str,size,inheritancemode,classfeatures,fon report_defining("reusing %s with id %s as \\%s (features: %s/%s, fallbacks: %s/%s, goodies: %s/%s)", name,tfmdata,cs,classfeatures,fontfeatures,classfallbacks,fontfallbacks,classgoodies,goodies) end + csnames[tfmdata] = specification.cs tex.definefont(global,cs,tfmdata) -- resolved (when designsize is used): setsomefontsize(fontdata[tfmdata].parameters.size .. "sp") @@ -743,6 +741,7 @@ function definers.stage_two(global,cs,str,size,inheritancemode,classfeatures,fon -- characters[0x2008] = { width = characters[0x002E] and characters[0x002E].width or parameters.space } -- period -- local id = font.define(tfmdata) + csnames[id] = specification.cs tfmdata.properties.id = id definers.register(tfmdata,id) -- to be sure, normally already done tex.definefont(global,cs,id) diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv index 62ac058d7..af3d5ba78 100644 --- a/tex/context/base/font-ini.mkiv +++ b/tex/context/base/font-ini.mkiv @@ -4244,7 +4244,7 @@ % \unexpanded\def\stopstyle % {\endgroup} -% definitions +% definitions .. no tagging here \def\definestyle {\dotripleargument\dodefinestyle} diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv index 603604fd1..b3a66eb1c 100644 --- a/tex/context/base/grph-fig.mkiv +++ b/tex/context/base/grph-fig.mkiv @@ -41,11 +41,14 @@ {\dodoplaceexternalfigure[#1][#2][#3][#4][#5]} {\getvalue{\??ef\??ef#2}[#5]}}}} +\ifdefined\dotagfigure \else \let\dotagfigure\relax \fi + \def\dodoplaceexternalfigure[#1][#2][#3][#4][#5]% {\bgroup \dostarttagged\t!image\empty \let\textunderscore\letterunderscore % {\string _} % space needed as _ is now letter in unprotected mode \calculateexternalfigure[][#1][#2][#3][#4][#5]% [] is dummy dwcomp + \dotagfigure \naturalvbox attr \imageattribute 2 {\box\foundexternalfigure}% \dostoptagged \egroup} diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index 5c2207749..4d3ba713d 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -120,6 +120,8 @@ figures.used = allocate() figures.found = allocate() figures.suffixes = allocate() figures.patterns = allocate() +figures.resources = allocate() + figures.boxnumber = figures.boxnumber or 0 figures.defaultsearch = true @@ -191,6 +193,12 @@ end figures.setlookups() +function figures.registerresource(t) + local n = #figures.resources + 1 + figures.resources[n] = t + return n +end + local function register(tag,target,what) local data = figures.formats[target] -- resolver etc if not data then @@ -889,6 +897,11 @@ function includers.generic(data) dr.height = du.height local hash = figures.hash(data) local figure = figures.used[hash] +--~ figures.registerresource { +--~ filename = du.fullname, +--~ width = dr.width, +--~ height = dr.height, +--~ } if figure == nil then figure = ds.private if figure then diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua index eeb3f47f6..d651608ae 100644 --- a/tex/context/base/l-table.lua +++ b/tex/context/base/l-table.lua @@ -15,7 +15,7 @@ local getinfo = debug.getinfo -- Starting with version 5.2 Lua no longer provide ipairs, which makes -- sense. As we already used the for loop and # in most places the -- impact on ConTeXt was not that large; the remaining ipairs already --- have been replaced. In a similar fashio we also hardly used pairs. +-- have been replaced. In a similar fashion we also hardly used pairs. -- -- Just in case, we provide the fallbacks as discussed in Programming -- in Lua (http://www.lua.org/pil/7.3.html): @@ -939,3 +939,20 @@ function table.loweredkeys(t) -- maybe utf end return l end + +-- new, might move (maybe duplicate) + +function table.unique(old) + local hash = { } + local new = { } + local n = 0 + for i=1,#old do + local oi = old[i] + if not hash[oi] then + n = n + 1 + new[n] = oi + hash[oi] = true + end + end + return new +end diff --git a/tex/context/base/lang-def.lua b/tex/context/base/lang-def.lua index 78c8eecbd..80ff13beb 100644 --- a/tex/context/base/lang-def.lua +++ b/tex/context/base/lang-def.lua @@ -64,6 +64,15 @@ local setmetatableindex = table.setmetatableindex -- todo: add default features local specifications = allocate { + { + ["description"] = "Dutch", + ["script"] = "latn", + -- ["bibliographical"] = "nld", + -- ["terminological"] = "nld", + ["context"] = "nl", + ["opentype"] = "nld", + ["variant"] = "nl", + }, { ["description"] = "Basque", ["script"] = "latn", diff --git a/tex/context/base/lang-def.mkiv b/tex/context/base/lang-def.mkiv index b720a1813..874eb2c45 100644 --- a/tex/context/base/lang-def.mkiv +++ b/tex/context/base/lang-def.mkiv @@ -686,4 +686,11 @@ \installlanguage [vietnamese] [\s!vi] +%D Todo: generate this one from languages.data + +\installlanguage[nld][\s!nl] +\installlanguage[deu][\s!de] +\installlanguage[eng][\s!en] +\installlanguage[fra][\s!fr] + \protect \endinput diff --git a/tex/context/base/lang-ini.mkiv b/tex/context/base/lang-ini.mkiv index 6504b82b8..2959028bf 100644 --- a/tex/context/base/lang-ini.mkiv +++ b/tex/context/base/lang-ini.mkiv @@ -377,6 +377,8 @@ % The following may be a solution for the fact that one cannot % change catcodes of characters like : and ; inside an environment. +% we will also permit access by the other names + \def\complexlanguage[#1]% {\edef\askedlanguage{#1}% \ifx\askedlanguage\empty \else diff --git a/tex/context/base/lxml-css.lua b/tex/context/base/lxml-css.lua new file mode 100644 index 000000000..e88c3a4a1 --- /dev/null +++ b/tex/context/base/lxml-css.lua @@ -0,0 +1,111 @@ +if not modules then modules = { } end modules ['lxml-css'] = { + version = 1.001, + comment = "companion to lxml-css.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local tonumber, rawset = tonumber, rawset +local lower, format = string.lower, string.format +local P, S, C, R, Cb, Cg, Carg, Ct, Cc, Cf = lpeg.P, lpeg.S, lpeg.C, lpeg.R, lpeg.Cb, lpeg.Cg, lpeg.Carg, lpeg.Ct, lpeg.Cc, lpeg.Cf +local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns + +xml.css = xml.css or { } +local css = xml.css + +local dimenfactors = number.dimenfactors +local bpf = 1/dimenfactors.bp +local cmf = 1/dimenfactors.cm +local mmf = 1/dimenfactors.mm +local inf = 1/dimenfactors["in"] + +local validdimen = Cg(lpegpatterns.number,'a') * ( + Cb('a') * P("pt") / function(s) return tonumber(s) * bpf end + + Cb('a') * P("cm") / function(s) return tonumber(s) * cmf end + + Cb('a') * P("mm") / function(s) return tonumber(s) * mmf end + + Cb('a') * P("in") / function(s) return tonumber(s) * inf end + + Cb('a') * P("px") * Carg(1) / function(s,pxf) return tonumber(s) * pxf end + + Cb('a') * P("%") * Carg(2) / function(s,pcf) return tonumber(s) * pcf end + + Cb('a') * P("ex") * Carg(3) / function(s,exf) return tonumber(s) * exf end + + Cb('a') * P("em") * Carg(4) / function(s,emf) return tonumber(s) * emf end + + Cb('a') * Carg(1) / function(s,pxf) return tonumber(s) * pxf end + ) + +local pattern = (validdimen * lpegpatterns.whitespace^0)^1 + +-- todo: default if "" + +local function padding(str,pixel,percent,exheight,emwidth) + local top, bottom, left, right = lpegmatch(pattern,str,1,pixel,percent,exheight,emwidth) + if not bottom then + bottom, left, right = top, top, top + elseif not left then + bottom, left, right = top, bottom, bottom + elseif not right then + bottom, left, right = left, bottom, bottom + end + return top, bottom, left, right +end + +css.padding = padding + +-- local hsize = 655360*100 +-- local exheight = 65536*4 +-- local emwidth = 65536*10 +-- local pixel = emwidth/100 +-- +-- print(padding("10px",pixel,hsize,exheight,emwidth)) +-- print(padding("10px 20px",pixel,hsize,exheight,emwidth)) +-- print(padding("10px 20px 30px",pixel,hsize,exheight,emwidth)) +-- print(padding("10px 20px 30px 40px",pixel,hsize,exheight,emwidth)) +-- +-- print(padding("10%",pixel,hsize,exheight,emwidth)) +-- print(padding("10% 20%",pixel,hsize,exheight,emwidth)) +-- print(padding("10% 20% 30%",pixel,hsize,exheight,emwidth)) +-- print(padding("10% 20% 30% 40%",pixel,hsize,exheight,emwidth)) +-- +-- print(padding("10",pixel,hsize,exheight,emwidth)) +-- print(padding("10 20",pixel,hsize,exheight,emwidth)) +-- print(padding("10 20 30",pixel,hsize,exheight,emwidth)) +-- print(padding("10 20 30 40",pixel,hsize,exheight,emwidth)) +-- +-- print(padding("10pt",pixel,hsize,exheight,emwidth)) +-- print(padding("10pt 20pt",pixel,hsize,exheight,emwidth)) +-- print(padding("10pt 20pt 30pt",pixel,hsize,exheight,emwidth)) +-- print(padding("10pt 20pt 30pt 40pt",pixel,hsize,exheight,emwidth)) + +-- local currentfont = font.current +-- local texdimen = tex.dimen +-- local hashes = fonts.hashes +-- local quads = hashes.quads +-- local xheights = hashes.xheights +-- +-- local function padding(str) +-- local font = currentfont() +-- local exheight = xheights[font] +-- local emwidth = quads[font] +-- local hsize = texdimen.hsize/100 +-- local pixel = emwidth/100 +-- return padding(str,pixel,hsize,exheight,emwidth) +-- end +-- +-- function css.simplepadding(str) +-- context("%ssp",padding(str,pixel,hsize,exheight,emwidth)) +-- end + +local pattern = Cf( Ct("") * Cg( + Cc("style") * (C("italic") + C("oblique")) + + Cc("variant") * C("smallcaps") + + Cc("weight") * C("bold") + + P(1) +)^0 , rawset) + +function css.fontspecification(str) + return str and lpegmatch(pattern,lower(str)) +end + +function css.colorspecification(str) + local c = str and attributes.colors.values[tonumber(str)] + return c and format("rgb(%s%%,%s%%,%s%%)",c[3]*100,c[4]*100,c[5]*100) +end diff --git a/tex/context/base/lxml-css.mkiv b/tex/context/base/lxml-css.mkiv new file mode 100644 index 000000000..012db826c --- /dev/null +++ b/tex/context/base/lxml-css.mkiv @@ -0,0 +1,39 @@ +%D \module +%D [ file=lxml-css, +%D version=2010.01.28, +%D title=\CONTEXT\ Modules, +%D subtitle=Css Helpers, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\registerctxluafile{lxml-css}{} + +\def\ctxmodulecss#1{\directlua\zerocount{moduledata.css.#1}} + +% No stable interface yet. + +% \edef\CellPadding{\xmlatt{#1}{cellpadding}} +% \ifx\CellPadding\empty +% \edef\CellPadding{.25ex} +% \else +% \edef\CellPadding{\cssgetsinglepadding{\xmlatt{#1}{cellpadding}}} +% \fi + +% \starttexdefinition cssgetsinglepadding #1 +% \ctxlua { +% context((moduledata.css.padding( +% "#1", +% \number\dimexpr0.1ex, +% \number\dimexpr0.01\hsize, +% \number\dimexpr1ex, +% \number\dimexpr1em +% ))) % returns 4 values therefore () +% }sp +% \stoptexdefinition + +\endinput diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv index 9d037368a..b65d15b45 100644 --- a/tex/context/base/mult-sys.mkiv +++ b/tex/context/base/mult-sys.mkiv @@ -538,6 +538,7 @@ \definesystemvariable {fx} % FoXet \definesystemvariable {gr} % GRid \definesystemvariable {ha} % HAng +\definesystemvariable {hl} % HighLight \definesystemvariable {hs} % HSpace \definesystemvariable {ht} % HiddenText \definesystemvariable {ia} % Interactie diff --git a/tex/context/base/node-aux.lua b/tex/context/base/node-aux.lua index 0b44f7724..38f1561fd 100644 --- a/tex/context/base/node-aux.lua +++ b/tex/context/base/node-aux.lua @@ -317,3 +317,21 @@ function nodes.link(...) local currentfont = font.current return link(nil,nil,{...},currentfont,currentattr) end + +local function locate(start,wantedid,wantedsubtype) + for n in traverse_nodes(start) do + local id = n.id + if id == wantedid then + if not wantedsubtype or n.subtype == wantedsubtype then + return n + end + elseif id == hlist_code or id == vlist_code then + local found = locate(n.list,wantedid,wantedsubtype) + if found then + return found + end + end + end +end + +nodes.locate = locate diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index c5b13be19..b9e7254c3 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 e430fe95f..608937f8e 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/strc-des.mkiv b/tex/context/base/strc-des.mkiv index f081e884a..d67525ae8 100644 --- a/tex/context/base/strc-des.mkiv +++ b/tex/context/base/strc-des.mkiv @@ -419,7 +419,7 @@ \BeforePar{\@@makedescription[#1]{#2}}% \GotoPar} -\let\dotagsetdescriptiontag\relax +\ifdefined\dotagsetdescription \else \let\dotagsetdescription\relax \fi \def\@@dostartdescriptionindeed {\edef\currentdescriptionlocation{\descriptionparameter\c!location}% @@ -430,8 +430,8 @@ \let\currentdescriptionlocation\v!left \fi \dostarttagged\t!description\currentdescription + \dotagsetdescription \dostarttagged\t!descriptiontag\empty - \dotagsetdescriptiontag \@@dostartdescription \csname @@description\currentdescriptionlocation\endcsname \dostoptagged diff --git a/tex/context/base/strc-flt.mkiv b/tex/context/base/strc-flt.mkiv index 4d3689b3c..ee6228afd 100644 --- a/tex/context/base/strc-flt.mkiv +++ b/tex/context/base/strc-flt.mkiv @@ -633,13 +633,15 @@ \the\everyinsidefloat \let\@@extrafloat\empty \presetmorefloatvariables{#2}% +\dostarttagged\t!floatcontent\empty \dowithnextboxcontent % better a \the\everyfloattoks {\setlocalfloathsize \floatparameter\c!inner - \dostarttagged\t!floatcontent\empty - \aftergroup\dostoptagged % tricky, never change \dowithnextboxcontent +% \dostarttagged\t!floatcontent\empty +% \aftergroup\dostoptagged % tricky, never change \dowithnextboxcontent \postponenotes} % new - {\doifsomething{\floatparameter\c!criterium} + {\dostoptagged + \doifsomething{\floatparameter\c!criterium} {\ifdim\wd\nextbox>\floatparameter\c!criterium\relax \edef\forcedfloatmethod{\floatparameter\c!fallback}% \ifx\forcedfloatmethod\empty\let\forcedfloatmethod\v!here\fi diff --git a/tex/context/base/strc-itm.mkiv b/tex/context/base/strc-itm.mkiv index d582dafae..c8044fbc2 100644 --- a/tex/context/base/strc-itm.mkiv +++ b/tex/context/base/strc-itm.mkiv @@ -304,6 +304,8 @@ % test \startitemize[joinedup,nowhite,after] \item test \item test \stopitemize test \par % \stoptext +\ifdefined\dotagsetitemgroup \else \let\dotagsetitemgroup\relax \fi + \def\itembeforecommand {\ifconditional\nowhitelistitem \ifconditional\beforelistitem @@ -317,7 +319,7 @@ \getitemparameter\currentitemlevel\c!before \fi\fi \dostarttagged\t!itemgroup\currentitemgroup - \dotagsetitemize} + \dotagsetitemgroup} \def\itemaftercommand {\dostoptagged @@ -614,8 +616,6 @@ \let\currentitemindenting\empty -\let\dotagsetitemize\relax - \def\redostartitemgroup[#1][#2]% {\setfalse\inlinelistitem % new, no indent (leftskip) \setfalse\concatnextitem % new, concat diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv index d178c840c..09a834c46 100644 --- a/tex/context/base/strc-not.mkiv +++ b/tex/context/base/strc-not.mkiv @@ -688,7 +688,7 @@ \def\dolastnotesymbol {\typesetsomenotesymbol\currentnote\currentnotenumber\currentdescriptionnumberentry} -\let\dotagsetnotesymbol\relax +\ifdefined\dotagsetnotesymbol \else \let\dotagsetnotesymbol\relax \fi \def\dotypesetsomenotesymbol#1#2#3% running text (messy: #1 and current mixed) {\dodonotesymbol diff --git a/tex/context/base/strc-ren.mkiv b/tex/context/base/strc-ren.mkiv index f2f056033..3a160ee9e 100644 --- a/tex/context/base/strc-ren.mkiv +++ b/tex/context/base/strc-ren.mkiv @@ -368,10 +368,29 @@ \unexpanded\def\defineheadplacement {\dodoubleargument\dodefineheadplacement} -\def\dodefineheadplacement[#1][#2]% #3#4 +% \def\dodefineheadplacement[#1][#2]% #3#4 +% {\setvalue{\??ns:#1}{#2}% +% \setvalue{\??ns::#1}} + +% \dodefineheadplacement[sectiona][vertical]{#1->#2} +% \dodefineheadplacement[sectionb][vertical]#1#2{#1->#2} +% +% \setuphead[section][alternative=sectiona] +% \setuphead[subsection][alternative=sectionb] + +\def\dodefineheadplacementyes[#1][#2]%#3#4% + {\setvalue{\??ns:#1}{#2}% + \setvalue{\??ns::#1}##1##2} + +\def\dodefineheadplacementnop[#1][#2]% {\setvalue{\??ns:#1}{#2}% \setvalue{\??ns::#1}} +\def\dodefineheadplacement[#1][#2]% + {\doifnextbgroupelse + {\dodefineheadplacementyes[#1][#2]}% + {\dodefineheadplacementnop[#1][#2]}} + \def\presetnumberheadalternative {\doifelsevalue{\??ns:\numberheadalternative}\v!horizontal\setfalse\settrue\headisdisplay} diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index a36f549b1..94f21a12b 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -450,7 +450,7 @@ \endgraf \endgroup} -\ifdefined \else \let\presetnumberheadalternative\relax \fi +\ifdefined\presetnumberheadalternative \else \let\presetnumberheadalternative\relax \fi \def\dohandlehead#1#2#3% name data userdata (we can move #1 to the caller) {\xdef\currenthead {#1}% diff --git a/tex/context/base/strc-syn.mkiv b/tex/context/base/strc-syn.mkiv index 1cf0f7a04..5efa48f7c 100644 --- a/tex/context/base/strc-syn.mkiv +++ b/tex/context/base/strc-syn.mkiv @@ -20,8 +20,8 @@ \unprotect -\let\dotagsynonym\relax -\let\dotagsorting\relax +\ifdefined\dotagsynonym \else \let\dotagsynonym\relax \fi +\ifdefined\dotagsorting \else \let\dotagsorting\relax \fi % general help, can be shared @@ -175,8 +175,8 @@ {\begingroup \def\currentsynonym{#1}% \def\currentsynonymtag{#2}% - \dotagsynonym \dostarttagged\t!synonym\currentsynonym + \dotagsynonym \dosetsynonymattributes\c!synonymstyle\c!synonymcolor \synonymparameter\c!synonymcommand{\ctxlua{structures.synonyms.synonym("#1","#2")}}% \dostoptagged @@ -336,8 +336,8 @@ % no kap currently, of .. we need to map cap onto WORD \edef\currentsorting{#1}% \def\currentsortingtag{#2}% - \dotagsorting \dostarttagged\t!sorting\currentsorting + \dotagsorting \dosetsortingattributes\c!style\c!color \ctxlua{structures.synonyms.synonym("#1","#2")}% \dostoptagged diff --git a/tex/context/base/strc-tag.lua b/tex/context/base/strc-tag.lua index be8e3f5c8..886f00d36 100644 --- a/tex/context/base/strc-tag.lua +++ b/tex/context/base/strc-tag.lua @@ -50,6 +50,7 @@ local properties = allocate { paragraph = { pdf = "P", nature = "mixed" }, p = { pdf = "P", nature = "mixed" }, construct = { pdf = "Span", nature = "inline" }, + highlight = { pdf = "Span", nature = "inline" }, section = { pdf = "Sect", nature = "display" }, sectiontitle = { pdf = "H", nature = "mixed" }, @@ -164,8 +165,32 @@ local properties = allocate { sup = { pdf = "Span", nature = "inline" }, subsup = { pdf = "Span", nature = "inline" }, + combination = { pdf = "Span", nature = "display" }, + combinationpair = { pdf = "Span", nature = "display" }, + combinationcontent = { pdf = "Span", nature = "mixed" }, + combinationcaption = { pdf = "Span", nature = "mixed" }, } +function tags.detailedtag(tag,detail,attribute) + if not attribute then + attribute = texattribute[a_tagged] + end + local tl = taglist[attribute] + local pattern + if detail and detail ~= "" then + pattern = "^" .. tag .. ":".. detail .. "%-" + else + pattern = "^" .. tag .. "%-" + end + for i=#tl,1,-1 do + local tli = tl[i] + if find(tli,pattern) then + return tli + end + end + return false -- handy as bogus index +end + tags.properties = properties local lasttags = { } diff --git a/tex/context/base/strc-tag.mkiv b/tex/context/base/strc-tag.mkiv index e57a12b6b..335065c8b 100644 --- a/tex/context/base/strc-tag.mkiv +++ b/tex/context/base/strc-tag.mkiv @@ -27,6 +27,7 @@ \def\t!paragraph {paragraph} % P \def\t!p {p} % P \def\t!construct {construct} % Span +\def\t!highlight {highlight} % Span \def\t!section {section} % Sect \def\t!sectiontitle {sectiontitle} % H @@ -127,6 +128,11 @@ \def\t!quantity {quantity} % Span \def\t!number {number} % Span +\def\t!combination {combination} % Span +\def\t!combinationpair {combinationpair} % Span +\def\t!combinationcontent{combinationcontent} % Span +\def\t!combinationcaption{combinationcaption} % Span + % \setuptaglabeltext % [en] % [\t!document=document] diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv index 35ed45b63..4cddb50c7 100644 --- a/tex/context/base/tabl-ntb.mkiv +++ b/tex/context/base/tabl-ntb.mkiv @@ -116,11 +116,11 @@ %D %D \typebuffer \getbuffer -\let\dotagTABLEalign\relax +\ifdefined\dotagTABLEcell \else \let\dotagTABLEcell\relax \fi \def\bTBLCELL % why not \doinhibitblank {\inhibitblank - \dotagTABLEalign + \dotagTABLEcell \doconvertfont\tbltblstyle\empty \everypar{\tbltblleft\delayedbegstrut}} @@ -923,8 +923,6 @@ \fi \egroup}} -\let\dotagTABLEcell\relax - \def\begintbl {\global\tblspn\zerocount \global\tblcol\zerocount @@ -941,7 +939,8 @@ \ignorespaces##\unskip&&\ignorespaces##\unskip\cr} % one too many \def\endtbl - {\dostoptagged\egroup + {\dostoptagged + \egroup \dostoptagged} \setvalue{\tblnone TBL}#1#2% @@ -997,17 +996,17 @@ \settblhei{#1}{\the\ht\scratchbox}% \fi}% -\let\dotagnofTABLEcolumns\relax -\let\dotagnofTABLErows \relax +\newcount\tablecellrows +\newcount\tablecellcolumns \def\domakeTBLthree#1 #2 % {% height -\dostarttagged\t!tablecell\empty + \dostarttagged\t!tablecell\empty \!!counta \gettblcol{#1}{#2}\relax \!!countb \gettblrow{#1}{#2}\relax \!!heighta\gettblht {#1}{#2}\relax -\dotagnofTABLEcolumns -\dotagnofTABLErows + \tablecellcolumns\!!counta % used later so don't adapt these + \tablecellrows \!!countb % used later so don't adapt these \scratchdimen\zeropoint \ifnum\!!counta=\maximumcol\relax % case: nc=maxcolumns @@ -1031,7 +1030,7 @@ \edef\widthTBL{\the\dimexpr\scratchdimen-\tbltblcolumndistance\relax}% % cell \setbox\scratchbox\hbox attr \taggedattribute \attribute\taggedattribute \bgroup -% \dotagTABLEcell + % \dotagTABLEsignal \gettbltxt{#1}{#2}% \egroup \ifnum\!!counta=\maximumcol\relax diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index 5949460aa..c7b5e7b1b 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -324,7 +324,8 @@ \let\endreshapedtabulatepar\egroup -\let\dotagtabulatealign\relax +\ifdefined\dotagtabulatecell \else \let\dotagtabulatecell \relax \fi +\ifdefined\dotagtabulatesignal \else \let\dotagtabulatesignal\relax \fi \unexpanded\def\dochecklocaltabulatecolor#1#2% {\relax @@ -378,9 +379,7 @@ \fi \fi\fi} -\let\dotagtabulatesignal\relax - -\def\dodosettabulatepreamble#1#2% only makes sense for many tabulates +\def\dodosettabulatepreamble#1#2#3% only makes sense for many tabulates {\normalexpanded{\tabulatepreamble{\the\tabulatepreamble \dochecklocaltabulatevrulecolor{\currenttabulatevrulecolor}{\the\tabulatevrulethickness}% \dochecklocaltabulatecolor{\currenttabulatecolor}{\number\tabulatecolorspan}% @@ -411,9 +410,10 @@ \bgroup \noexpand\bbskip \bgroup % we cannot combine the if because a cell may have only one ## + \tabulatealign\number#1\relax % needed in tag passing \noexpand\dostarttagged\noexpand\t!tabulatecell\noexpand\empty - \dotagtabulatealign - \noexpand#1% + \noexpand\dotagtabulatecell + \noexpand#2% \ifcase\tabulatereshape\else \beginreshapedtabulatepar \fi @@ -438,7 +438,7 @@ \ifcase\tabulatereshape\else \endreshapedtabulatepar \fi - \noexpand#2% + \noexpand#3% % \noexpand\dostoptagged \egroup \egroup @@ -457,10 +457,12 @@ %\let\gettabulateexit\dogettabulateexit % still needed ? \tabulatewidth\zeropoint} -\setvalue{\??tt>\meaning x}{\let\tabulatealign\zerocount\settabulatepreamble} % internal -\setvalue{\??tt>\meaning l}{\let\tabulatealign\plusone\settabulatepreamble} -\setvalue{\??tt>\meaning r}{\let\tabulatealign\plustwo\settabulatepreamble} -\setvalue{\??tt>\meaning c}{\let\tabulatealign\plusthree\settabulatepreamble} +\newcount\tabulatealign + +\setvalue{\??tt>\meaning x}{\tabulatealign\zerocount\settabulatepreamble} % internal +\setvalue{\??tt>\meaning l}{\tabulatealign\plusone\settabulatepreamble} +\setvalue{\??tt>\meaning r}{\tabulatealign\plustwo\settabulatepreamble} +\setvalue{\??tt>\meaning c}{\tabulatealign\plusthree\settabulatepreamble} \setvalue{\??tt>\meaning p}{\gettabulateparagraph} \setvalue{\??tt>\meaning s}{\gettabulatesetups} \setvalue{\??tt>\meaning w}{\gettabulatewidth} @@ -586,28 +588,28 @@ \def\tabulatesetpreamblewidthnormal {\ifcase\tabulatealign\relax - \dodosettabulatepreamble\empty \tabulatehss \or - \dodosettabulatepreamble\empty \tabulatehss \or - \dodosettabulatepreamble\tabulatehss\empty \or - \dodosettabulatepreamble\tabulatehss\tabulatehss \fi} + \dodosettabulatepreamble\tabulatealign\empty \tabulatehss \or + \dodosettabulatepreamble\tabulatealign\empty \tabulatehss \or + \dodosettabulatepreamble\tabulatealign\tabulatehss\empty \or + \dodosettabulatepreamble\tabulatealign\tabulatehss\tabulatehss \fi} \def\tabulatesetpreamblewidthfixed {\ifcase\tabulatealign\relax - \dodosettabulatepreamble\bskip \eskip \or - \dodosettabulatepreamble\tabulatebskipraggedright \eskip \or - \dodosettabulatepreamble\tabulatebskipraggedleft \eskip \or - \dodosettabulatepreamble\tabulatebskipraggedcenter\eskip \fi} + \dodosettabulatepreamble\tabulatealign\bskip \eskip \or + \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedright \eskip \or + \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedleft \eskip \or + \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedcenter\eskip \fi} \def\tabulatesetpreamblewidthauto {\global\advance\nofautotabulate\plusone \ifcase\tabulatealign\relax - \dodosettabulatepreamble\bskip \eskip \or - \dodosettabulatepreamble\tabulatebskipraggedright \eskip \or - \dodosettabulatepreamble\tabulatebskipraggedleft \eskip \or - \dodosettabulatepreamble\tabulatebskipraggedcenter\eskip \fi} + \dodosettabulatepreamble\tabulatealign\bskip \eskip \or + \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedright \eskip \or + \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedleft \eskip \or + \dodosettabulatepreamble\tabulatealign\tabulatebskipraggedcenter\eskip \fi} \def\tabulatesetpreamblewidthsimple - {\dodosettabulatepreamble\xbskip\xeskip} + {\dodosettabulatepreamble\tabulatealign\xbskip\xeskip} \def\doparsecolortabulate#1#2% {\gdef\currenttabulatecolor{#2}% @@ -620,7 +622,7 @@ {\xdef\currenttabulatevrulecolor{#1}}} \def\settabulateentry#1#2% rulespec template - {\let\tabulatealign\@@tabulatealign + {\tabulatealign\@@tabulatealign \let\tabulatemodus\zerocount \let\tabulatedimen\zerocount \let\tabulatereshape\zerocount diff --git a/tex/context/base/x-css.lua b/tex/context/base/x-css.lua deleted file mode 100644 index 1bf559d66..000000000 --- a/tex/context/base/x-css.lua +++ /dev/null @@ -1,94 +0,0 @@ -if not modules then modules = { } end modules ['lxml-css'] = { - version = 1.001, - comment = "companion to lxml-css.mkiv", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", - copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files" -} - -local tonumber = tonumber -local P, S, C, R, Cb, Cg, Carg = lpeg.P, lpeg.S, lpeg.C, lpeg.R, lpeg.Cb, lpeg.Cg, lpeg.Carg -local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns - -local css = { } -local moduledata = moduledata or { } -moduledata.css = css - -local dimenfactors = number.dimenfactors - -local bpf, cmf, mmf, inf = 1/dimenfactors.bp, 1/dimenfactors.cm, 1/dimenfactors.mm, 1/dimenfactors["in"] - -local validdimen = Cg(lpegpatterns.number,'a') * ( - Cb('a') * P("pt") / function(s) return tonumber(s) * bpf end - + Cb('a') * P("cm") / function(s) return tonumber(s) * cmf end - + Cb('a') * P("mm") / function(s) return tonumber(s) * mmf end - + Cb('a') * P("in") / function(s) return tonumber(s) * inf end - + Cb('a') * P("px") * Carg(1) / function(s,pxf) return tonumber(s) * pxf end - + Cb('a') * P("%") * Carg(2) / function(s,pcf) return tonumber(s) * pcf end - + Cb('a') * P("ex") * Carg(3) / function(s,exf) return tonumber(s) * exf end - + Cb('a') * P("em") * Carg(4) / function(s,emf) return tonumber(s) * emf end - + Cb('a') * Carg(1) / function(s,pxf) return tonumber(s) * pxf end - ) - -local pattern = (validdimen * lpegpatterns.whitespace^0)^1 - --- todo: default if "" - -local function padding(str,pixel,percent,exheight,emwidth) - local top, bottom, left, right = lpegmatch(pattern,str,1,pixel,percent,exheight,emwidth) - if not bottom then - bottom, left, right = top, top, top - elseif not left then - bottom, left, right = top, bottom, bottom - elseif not right then - bottom, left, right = left, bottom, bottom - end - return top, bottom, left, right -end - -css.padding = padding - --- local hsize = 655360*100 --- local exheight = 65536*4 --- local emwidth = 65536*10 --- local pixel = emwidth/100 --- --- print(padding("10px",pixel,hsize,exheight,emwidth)) --- print(padding("10px 20px",pixel,hsize,exheight,emwidth)) --- print(padding("10px 20px 30px",pixel,hsize,exheight,emwidth)) --- print(padding("10px 20px 30px 40px",pixel,hsize,exheight,emwidth)) --- --- print(padding("10%",pixel,hsize,exheight,emwidth)) --- print(padding("10% 20%",pixel,hsize,exheight,emwidth)) --- print(padding("10% 20% 30%",pixel,hsize,exheight,emwidth)) --- print(padding("10% 20% 30% 40%",pixel,hsize,exheight,emwidth)) --- --- print(padding("10",pixel,hsize,exheight,emwidth)) --- print(padding("10 20",pixel,hsize,exheight,emwidth)) --- print(padding("10 20 30",pixel,hsize,exheight,emwidth)) --- print(padding("10 20 30 40",pixel,hsize,exheight,emwidth)) --- --- print(padding("10pt",pixel,hsize,exheight,emwidth)) --- print(padding("10pt 20pt",pixel,hsize,exheight,emwidth)) --- print(padding("10pt 20pt 30pt",pixel,hsize,exheight,emwidth)) --- print(padding("10pt 20pt 30pt 40pt",pixel,hsize,exheight,emwidth)) - -local currentfont = font.current -local texdimen = tex.dimen -local hashes = fonts.hashes -local quads = hashes.quads -local xheights = hashes.xheights - -local function padding(str) - local font = currentfont() - local exheight = xheights[font] - local emwidth = quads[font] - local hsize = texdimen.hsize/100 - local pixel = emwidth/100 - return padding(str,pixel,hsize,exheight,emwidth) -end - ---~ function css.simplepadding(str) ---~ context("%ssp",padding(str,pixel,hsize,exheight,emwidth)) ---~ end - diff --git a/tex/context/base/x-css.mkiv b/tex/context/base/x-css.mkiv deleted file mode 100644 index 4ea252f9d..000000000 --- a/tex/context/base/x-css.mkiv +++ /dev/null @@ -1,39 +0,0 @@ -%D \module -%D [ file=x-css, -%D version=2010.01.28, -%D title=\CONTEXT\ Modules, -%D subtitle=Css Helpers, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\registerctxluafile{x-css}{} - -\def\ctxmodulecss#1{\directlua\zerocount{moduledata.css.#1}} - -% No stable interface yet. - -% \edef\CellPadding{\xmlatt{#1}{cellpadding}} -% \ifx\CellPadding\empty -% \edef\CellPadding{.25ex} -% \else -% \edef\CellPadding{\cssgetsinglepadding{\xmlatt{#1}{cellpadding}}} -% \fi - -% \starttexdefinition cssgetsinglepadding #1 -% \ctxlua { -% context((moduledata.css.padding( -% "#1", -% \number\dimexpr0.1ex, -% \number\dimexpr0.01\hsize, -% \number\dimexpr1ex, -% \number\dimexpr1em -% ))) % returns 4 values therefore () -% }sp -% \stoptexdefinition - -\endinput diff --git a/tex/context/base/x-udhr.mkiv b/tex/context/base/x-udhr.mkiv new file mode 100644 index 000000000..164b74d83 --- /dev/null +++ b/tex/context/base/x-udhr.mkiv @@ -0,0 +1,98 @@ +%D \module +%D [ file=x-udhr, +%D version=2011.06.11, +%D title=\CONTEXT\ Modules, +%D subtitle=Unicode Language Test Files, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D The XML files can be fetched from: \url {http://unicode.org/udhr/}. + +\startmodule[udhr] + +\startxmlsetups udhr:basics + \xmlsetsetup {#1} {*} {udhr:*} +\stopxmlsetups + +\xmlregistersetup{udhr:basics} + +\startxmlsetups udhr:udhr + + \mainlanguage[\xmlatt{#1}{language}] + + \starttitle[title=\xmltext{#1}{/title}] + \xmlfirst{#1}{/preamble} + \xmlall{#1}{/article} + \stoptitle + +\stopxmlsetups + +\startxmlsetups udhr:preamble + \startsubject[title=\xmltext{#1}{/title}] + \xmlall{#1}{/*)} + \stopsubject +\stopxmlsetups + +\startxmlsetups udhr:article + \startsubject[title=\xmltext{#1}{/title}] + \xmlall{#1}{/*)} + \stopsubject +\stopxmlsetups + +\startxmlsetups udhr:orderedlist + \startitemize[n] + \xmlflush{#1} + \stopitemize +\stopxmlsetups + +\startxmlsetups udhr:listitem + \startitem + \xmlflush{#1} + \stopitem +\stopxmlsetups + +\startxmlsetups udhr:para + \xmlflush{#1} + \par +\stopxmlsetups + +\setupbodyfont + [dejavu,10pt] + +\setuplayout + [width-=middle, + height=middle, + footer=0cm, + header=1.5cm] + +\setupwhitespace + [big] + +\setuphead + [chapter] + [header=high, + style=\bfb, + align=middle] + +\setuphead + [section] + [style=\bfa, + align=middle] + +\setuptolerance + [verytolerant] + +\doifnotmode{demo}{\endinput} + +% todo: when argument given then process it + +\starttext + \xmlprocessfile{main}{udhr_nld.xml}{} +\stoptext + +\stopmodule diff --git a/tex/generic/context/luatex-fonts-enc.lua b/tex/generic/context/luatex-fonts-enc.lua index ac736f2a6..e20c3a03b 100644 --- a/tex/generic/context/luatex-fonts-enc.lua +++ b/tex/generic/context/luatex-fonts-enc.lua @@ -18,7 +18,7 @@ fonts.encodings.agl = { } setmetatable(fonts.encodings.agl, { __index = function(t,k) if k == "unicodes" then texio.write(" ") - local unicodes = dofile(resolvers.findfile("font-agl.lua")) + local unicodes = dofile(resolvers.findfile("font-age.lua")) fonts.encodings.agl = { unicodes = unicodes } return unicodes else diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 54ef6442e..f9234d8fd 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 06/16/11 18:20:55 +-- merge date : 06/19/11 14:17:51 do -- begin closure to overcome local limits and interference @@ -144,7 +144,7 @@ local getinfo = debug.getinfo -- Starting with version 5.2 Lua no longer provide ipairs, which makes -- sense. As we already used the for loop and # in most places the -- impact on ConTeXt was not that large; the remaining ipairs already --- have been replaced. In a similar fashio we also hardly used pairs. +-- have been replaced. In a similar fashion we also hardly used pairs. -- -- Just in case, we provide the fallbacks as discussed in Programming -- in Lua (http://www.lua.org/pil/7.3.html): @@ -1069,6 +1069,23 @@ function table.loweredkeys(t) -- maybe utf return l end +-- new, might move (maybe duplicate) + +function table.unique(old) + local hash = { } + local new = { } + local n = 0 + for i=1,#old do + local oi = old[i] + if not hash[oi] then + n = n + 1 + new[n] = oi + hash[oi] = true + end + end + return new +end + end -- closure do -- begin closure to overcome local limits and interference @@ -4173,7 +4190,7 @@ fonts.encodings.agl = { } setmetatable(fonts.encodings.agl, { __index = function(t,k) if k == "unicodes" then texio.write(" ") - local unicodes = dofile(resolvers.findfile("font-agl.lua")) + local unicodes = dofile(resolvers.findfile("font-age.lua")) fonts.encodings.agl = { unicodes = unicodes } return unicodes else -- cgit v1.2.3