From b7bf9474dd20221297fb47bf90c1ab6c6a2d9306 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 6 Jun 2014 23:52:00 +0200 Subject: beta 2014.06.06 23:52 --- tex/context/base/anch-pgr.lua | 11 +- tex/context/base/back-ini.lua | 7 + tex/context/base/back-pdf.lua | 2 +- tex/context/base/back-pdf.mkiv | 12 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4323 -> 4323 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/lpdf-ini.lua | 33 +- tex/context/base/lpdf-mis.lua | 11 +- tex/context/base/meta-fnt.lua | 32 +- tex/context/base/mlib-pdf.lua | 2 +- tex/context/base/status-files.pdf | Bin 24871 -> 24884 bytes tex/context/base/status-lua.pdf | Bin 246697 -> 246770 bytes tex/context/base/x-asciimath.lua | 355 +++++++++++++++------ tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 15 files changed, 331 insertions(+), 140 deletions(-) diff --git a/tex/context/base/anch-pgr.lua b/tex/context/base/anch-pgr.lua index c7f56a92b..7c8c4545f 100644 --- a/tex/context/base/anch-pgr.lua +++ b/tex/context/base/anch-pgr.lua @@ -59,7 +59,7 @@ local function add(t,x,y,last,direction) if x == lx and y == ly then -- quick skip elseif n == 1 then --- if abs(lx-x) <= eps or abs(ly-y) <= eps then + -- if abs(lx-x) <= eps or abs(ly-y) <= eps then if abs(lx-x) > eps or abs(ly-y) > eps then t[n+1] = { x, y } end @@ -67,10 +67,9 @@ local function add(t,x,y,last,direction) local tm = t[n-1] local px = tm[1] local py = tm[2] -if (direction == "down" and y > ly) or (direction == "up" and y < ly) then - -- move back from too much hang -else - if abs(lx-px) <= eps and abs(lx-x) <= eps then + if (direction == "down" and y > ly) or (direction == "up" and y < ly) then + -- move back from too much hang + elseif abs(lx-px) <= eps and abs(lx-x) <= eps then if abs(ly-y) > eps then tn[2] = y end @@ -81,7 +80,6 @@ else elseif not last then t[n+1] = { x, y } end -end end end end @@ -430,7 +428,6 @@ local function calculatemultipar(tag,obeyhang) end -- Obeying intermediate changes of left/rightskip makes no sense as it will -- look bad, so we only look at the begin situation. - -- local bn = b.n if bn then local bp = collected[f_p_tag(bn)] diff --git a/tex/context/base/back-ini.lua b/tex/context/base/back-ini.lua index c1f973a0c..129e7b75c 100644 --- a/tex/context/base/back-ini.lua +++ b/tex/context/base/back-ini.lua @@ -6,6 +6,13 @@ if not modules then modules = { } end modules ['back-ini'] = { license = "see context related readme files" } +-- -- how to create a shortcut: +-- +-- local function something(...) +-- something = backends.codeinjections.something +-- return something(...) +-- end + local next, type = next, type local format = string.format diff --git a/tex/context/base/back-pdf.lua b/tex/context/base/back-pdf.lua index 34a28e3f7..9eb4a9b73 100644 --- a/tex/context/base/back-pdf.lua +++ b/tex/context/base/back-pdf.lua @@ -24,7 +24,7 @@ local context = context local sind, cosd = math.sind, math.cosd local insert, remove = table.insert, table.remove -local f_matrix = string.formatters["%0.8F %0.8F %0.8F %0.8F"] +local f_matrix = string.formatters["%F %F %F %F"] -- 0.8 is default function commands.pdfrotation(a) -- todo: check for 1 and 0 and flush sparse diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index df9594507..3fbad1350 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -527,7 +527,7 @@ \xmin \space \ymin \space \xmin \space \yymin\space y \or % 28 \fi - \ifnum\mode>8\space + \ifnum\mode>\pluseight\space S \else \ifnum\dostroke=\plusone S \fi @@ -541,13 +541,15 @@ \box\scratchbox \egroup} -\unexpanded\def\pdfactualtext#1#2% not interfaced - {\pdfliteral direct{/Span <> BDC}% +\unexpanded\def\pdfbackendactualtext#1#2% not interfaced + {\ctxcommand{startactualtext(\!!bs#2\!!es)}% #1% - \pdfliteral direct{EMC}} + \ctxcommand{stopactualtext()}} + +\let\pdfactualtext\pdfbackendactualtext % \starttext -% text \pdfactualtext{Meier}{Müller} text +% text \pdfbackendactualtext{Meier}{Müller} text % \stoptext \protect \endinput diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 3e480088e..512dbb282 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{2014.06.05 23:04} +\newcontextversion{2014.06.06 23:52} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index ac3f0eaf9..6bf00b133 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 254d37394..1290a7d92 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -28,7 +28,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2014.06.05 23:04} +\edef\contextversion{2014.06.06 23:52} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua index 025f62c4f..eee5e2280 100644 --- a/tex/context/base/lpdf-ini.lua +++ b/tex/context/base/lpdf-ini.lua @@ -532,7 +532,7 @@ end -- lpdf.object = pdfdeferredobject -- lpdf.referenceobject = pdfreferenceobject -local pagereference = pdf.pageref or tex.pdfpageref +local pagereference = pdf.pageref -- tex.pdfpageref is obsolete local nofpages = 0 function lpdf.pagereference(n) @@ -1002,3 +1002,34 @@ end -- end -- end, -- }) + + +-- The next variant of ActualText is what Taco and I could come up with +-- eventually. As of September 2013 Acrobat copies okay, Sumatra copies a +-- question mark, pdftotext injects an extra space and Okular adds a +-- newline plus space. + +-- return formatters["BT /Span << /ActualText (CONTEXT) >> BDC [] TJ % t EMC ET"](code) + +local f_actual_text_one = formatters["BT /Span << /ActualText >> BDC [] TJ %s EMC ET"] +local f_actual_text_two = formatters["BT /Span << /ActualText >> BDC [] TJ %s EMC ET"] +local f_actual_text = formatters["/Span <> BDC"] + +local context = context +local pdfdirect = nodes.pool.pdfdirect + +function codeinjections.unicodetoactualtext(unicode,pdfcode) + if unicode < 0x10000 then + return f_actual_text_one(unicode,pdfcode) + else + return f_actual_text_two(unicode/1024+0xD800,unicode%1024+0xDC00,pdfcode) + end +end + +function commands.startactualtext(str) + context(pdfdirect(f_actual_text(tosixteen(str)))) +end + +function commands.stopactualtext() + context(pdfdirect("EMC")) +end diff --git a/tex/context/base/lpdf-mis.lua b/tex/context/base/lpdf-mis.lua index 6efbd3882..748567125 100644 --- a/tex/context/base/lpdf-mis.lua +++ b/tex/context/base/lpdf-mis.lua @@ -253,21 +253,26 @@ local pagespecs = { local pagespec, topoffset, leftoffset, height, width, doublesided = "default", 0, 0, 0, 0, false +local pdfpaperheight = tex.pdfpageheight +local pdfpaperwidth = tex.pdfpagewidth + function codeinjections.setupcanvas(specification) local paperheight = specification.paperheight local paperwidth = specification.paperwidth local paperdouble = specification.doublesided if paperheight then texset('global','pdfpageheight',paperheight) + pdfpaperheight = paperheight end if paperwidth then texset('global','pdfpagewidth',paperwidth) + pdfpaperwidth = paperwidth end pagespec = specification.mode or pagespec topoffset = specification.topoffset or 0 leftoffset = specification.leftoffset or 0 - height = specification.height or tex.pdfpageheight - width = specification.width or tex.pdfpagewidth + height = specification.height or pdfpaperheight + width = specification.width or pdfpaperwidth if paperdouble ~= nil then doublesided = paperdouble end @@ -313,7 +318,7 @@ local function boxvalue(n) -- we could share them end local function pagespecification() - local pageheight = tex.pdfpageheight + local pageheight = pdfpaperheight local box = pdfarray { -- can be cached boxvalue(leftoffset), boxvalue(pageheight+topoffset-height), diff --git a/tex/context/base/meta-fnt.lua b/tex/context/base/meta-fnt.lua index 596d0f456..02bf5d6b2 100644 --- a/tex/context/base/meta-fnt.lua +++ b/tex/context/base/meta-fnt.lua @@ -21,32 +21,18 @@ mpfonts.version = mpfonts.version or 1.20 mpfonts.inline = true mpfonts.cache = containers.define("fonts", "mp", mpfonts.version, true) -metapost.fonts = metapost.fonts or { } +metapost.fonts = metapost.fonts or { } + +local function unicodetoactualtext(...) + unicodetoactualtext = backends.codeinjections.unicodetoactualtext + return unicodetoactualtext(...) +end -- a few glocals local characters, descriptions = { }, { } local factor, code, slot, width, height, depth, total, variants, bbox, llx, lly, urx, ury = 100, { }, 0, 0, 0, 0, 0, 0, true, 0, 0, 0, 0 --- The next variant of ActualText is what Taco and I could come up with --- eventually. As of September 2013 Acrobat copies okay, Sumatra copies a --- question mark, pdftotext injects an extra space and Okular adds a --- newline plus space. - --- return formatters["BT /Span << /ActualText (CONTEXT) >> BDC [] TJ % t EMC ET"](code) - -local function topdf(n,code) - if n < 0x10000 then - return formatters["BT /Span << /ActualText >> BDC [] TJ % t EMC ET"](n,code) - else - return formatters["BT /Span << /ActualText >> BDC [] TJ % t EMC ET"](n/1024+0xD800,n%1024+0xDC00,code) - end -end - --- local function topdf(n,code) --- return formatters["/Span << /ActualText (CTX) >> BDC % t EMC"](code) --- end - local flusher = { startfigure = function(_chr_,_llx_,_lly_,_urx_,_ury_) code = { } @@ -68,6 +54,7 @@ local flusher = { end, stopfigure = function() local cd = chardata[n] + local code = unicodetoactualtext(slot,concat(code," ")) or "" descriptions[slot] = { -- unicode = slot, name = cd and cd.adobename, @@ -79,7 +66,7 @@ local flusher = { if inline then characters[slot] = { commands = { - { "special", "pdf:" .. topdf(slot,code) }, + { "special", "pdf:" .. code }, } } else @@ -88,13 +75,14 @@ local flusher = { { "image", { - stream = topdf(slot,code), + stream = code, bbox = { 0, -depth * 65536, width * 65536, height * 65536 } }, }, } } end + code = nil -- no need to keep that end } diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua index 7dfab3580..82db18fec 100644 --- a/tex/context/base/mlib-pdf.lua +++ b/tex/context/base/mlib-pdf.lua @@ -459,7 +459,7 @@ function metapost.flush(result,flusher,askedfig) end elseif objecttype == "start_clip" then result[#result+1] = "q" - flushnormalpath(object.path,t,false) + flushnormalpath(object.path,result,false) result[#result+1] = "W n" elseif objecttype == "stop_clip" then result[#result+1] = "Q" diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index cb680861e..2801e2b05 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 f2b5292e3..dba0dc0b7 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/x-asciimath.lua b/tex/context/base/x-asciimath.lua index da46b9b31..a6883f66c 100644 --- a/tex/context/base/x-asciimath.lua +++ b/tex/context/base/x-asciimath.lua @@ -39,7 +39,7 @@ local report_asciimath = logs.reporter("mathematics","asciimath") local type, rawget = type, rawget local lpegmatch, patterns = lpeg.match, lpeg.patterns local S, P, R, C, V, Cc, Ct, Cs = lpeg.S, lpeg.P, lpeg.R, lpeg.C, lpeg.V, lpeg.Cc, lpeg.Ct, lpeg.Cs -local concat, sortedhash, sortedkeys = table.concat, table.sortedhash, table.sortedkeys +local concat, remove, sortedhash, sortedkeys, keys = table.concat, table.remove, table.sortedhash, table.sortedkeys, table.keys local rep, gmatch, gsub, find = string.rep, string.gmatch, string.gsub, string.find local formatters = string.formatters @@ -116,7 +116,7 @@ local reserved = { -- ["-"] = "-", ["*"] = "⋅", ["**"] = "⋆", - ["//"] = "/", + ["//"] = "\\slash", ["\\"] = "\\", ["xx"] = "×", ["times"] = "×", @@ -657,24 +657,27 @@ local isunary = { ["\\dot"] = true, -- ["\\ddot"] = true, -- - ["^"] = true, - ["_"] = true, +-- ["^"] = true, +-- ["_"] = true, } --- local isinfix = { --- ["\\slash"] = true --- } +local isinfix = { + ["^"] = true, + ["_"] = true, +} local isleft = { ["\\left\\lparent"] = true, ["\\left\\lbrace"] = true, ["\\left\\lbracket"] = true, + ["\\left."] = true, } local isright = { ["\\right\\rparent"] = true, ["\\right\\rbrace"] = true, ["\\right\\rbracket"] = true, + ["\\right."] = true, } local issimplified = { @@ -696,9 +699,6 @@ local float = real * (P("E") * integer)^-1 -- local number = C(float + integer) local p_number = C(float) -local p_open = S("{[") * P(":") -local p_close = P(":") * S("]}") - local p_utf_base = patterns.utf8character local p_utf = @@ -764,27 +764,74 @@ local p_text = -- either map to \left or map to \left\name -local p_left = - P("(:") / "\\left\\langle" - + P("(") / "\\left\\lparent" - + P("[") / "\\left\\lbracket" - + P("{") / "\\left\\lbrace" - + P("<<") / "\\left\\langle" -- why not <: - + P("|_") / "\\left\\lfloor" - + P("|~") / "\\left\\lceil" - - + P("⟨") / "\\left\\langle" +-- local p_open = S("{[") * P(":") +-- local p_close = P(":") * S("]}") + +-- local p_open_left = (S("{[") * P(":")) / "\\left." +-- local p_close_right = (P(":") * S("]}")) / "\\right." + +-- local p_left = +-- P("(:") / "\\left\\langle" +-- + P("{:") / "\\left." +-- + P("[:") / "\\left." +-- + P("(") / "\\left\\lparent" +-- + P("[") / "\\left\\lbracket" +-- + P("{") / "\\left\\lbrace" +-- + P("<<") / "\\left\\langle" -- why not <: +-- + P("|_") / "\\left\\lfloor" +-- + P("|~") / "\\left\\lceil" +-- + P("⟨") / "\\left\\langle" +-- + P("〈") / "\\left\\langle" +-- + P("〈") / "\\left\\langle" + +-- local p_right = +-- P(")") / "\\right\\rparent" +-- + P(":)") / "\\right\\rangle" +-- + P(":}") / "\\right." +-- + P(":]") / "\\right." +-- + P("]") / "\\right\\rbracket" +-- + P("}") / "\\right\\rbrace" +-- + P(">>") / "\\right\\rangle" -- why not :> +-- + P("~|") / "\\right\\rceil" +-- + P("_|") / "\\right\\rfloor" +-- + P("⟩") / "\\right\\rangle" +-- + P("〉") / "\\right\\rangle" +-- + P("〉") / "\\right\\rangle" + +local m_left = { + ["(:"] = "\\left\\langle", + ["{:"] = "\\left.", + ["[:"] = "\\left.", + ["("] = "\\left\\lparent", + ["["] = "\\left\\lbracket", + ["{"] = "\\left\\lbrace", + ["<<"] = "\\left\\langle", -- why not <: + ["|_"] = "\\left\\lfloor", + ["|~"] = "\\left\\lceil", + ["⟨"] = "\\left\\langle", + ["〈"] = "\\left\\langle", + ["〈"] = "\\left\\langle", +} -local p_right = - P(")") / "\\right\\rparent" - + P(":)") / "\\right\\rangle" - + P("]") / "\\right\\rbracket" - + P("}") / "\\right\\rbrace" - + P(">>") / "\\right\\rangle" -- why not :> - + P("~|") / "\\right\\rceil" - + P("_|") / "\\right\\rfloor" +local m_right = { + [")"] = "\\right\\rparent", + [":)"] = "\\right\\rangle", + [":}"] = "\\right.", + [":]"] = "\\right.", + ["]"] = "\\right\\rbracket", + ["}"] = "\\right\\rbrace", + [">>"] = "\\right\\rangle", -- why not :> + ["~|"] = "\\right\\rceil", + ["_|"] = "\\right\\rfloor", + ["⟩"] = "\\right\\rangle", + ["〉"] = "\\right\\rangle", + ["〉"] = "\\right\\rangle", +} - + P("⟩") / "\\right\\rangle" +local p_left = + lpeg.utfchartabletopattern(keys(m_left)) / m_left +local p_right = + lpeg.utfchartabletopattern(keys(m_right)) / m_right -- special cases @@ -799,9 +846,11 @@ local p_right = -- faster bug also uglier: local p_special = - C("/") - + P("|") * Cc("\\|") -- "\\middle\\|" -- maybe always add left / right as in mml ? - + P("\\") * ( +-- C("/") +-- + + P("|") * Cc("\\|") -- "\\middle\\|" -- maybe always add left / right as in mml ? + + + P("\\") * ( ( P(" ") * ( Cc("{}") * p_spaces^0 * C(S("^_")) @@ -812,17 +861,23 @@ local p_special = + (R("az","AZ")^1/entities) ) +-- open | close :: {: | :} + + local parser = Ct { "tokenizer", tokenizer = ( p_spaces + p_number + p_text - + Ct(p_open * V("tokenizer") * p_close) - + Ct(p_left * V("tokenizer") * p_right) +-- + Ct(p_open * V("tokenizer") * p_close) -- {: (a+b,=,1),(a+b,=,7) :} +-- + Ct(p_open * V("tokenizer") * p_close_right) -- { (a+b,=,1),(a+b,=,7) :} +-- + Ct(p_open_left * V("tokenizer") * p_right) -- {: (a+b,=,1),(a+b,=,7) } + + Ct(p_left * V("tokenizer") * p_right) -- { (a+b,=,1),(a+b,=,7) } + p_special + p_reserved + p_entity - + p_utf - p_close - p_right +-- + p_utf - p_close - p_right + + p_utf - p_right )^1, } @@ -880,7 +935,12 @@ local function collapse(t,level) end end if valid then - t[1] = l1 .. "\\startmatrix" + local omit = l1 == "\\left." and r1 == "\\right." + if omit then + t[1] = "\\startmatrix" + else + t[1] = l1 .. "\\startmatrix" + end for i=2,n-1 do if t[i] == "," then t[i] = "\\NR" @@ -895,7 +955,11 @@ local function collapse(t,level) ti[#ti] = nil end end - t[n] = "\\NR\\stopmatrix" .. r1 + if omit then + t[n] = "\\NR\\stopmatrix" + else + t[n] = "\\NR\\stopmatrix" .. r1 + end end end end @@ -906,8 +970,7 @@ local function collapse(t,level) state = show_state(state,level,t) end -- - local n = #t - local i = 1 + local n, i = #t, 1 while i < n do local current = t[i] if current == "/" and i > 1 then @@ -938,16 +1001,17 @@ local function collapse(t,level) state = show_state(state,level,t) end -- - local n = #t - local i = 1 + local n, i = #t, 1 if n > 2 then while i < n do local current = t[i] if type(current) == "table" and isleft[t[i-1]] and isright[t[i+1]] then local c = #current if c > 2 and isleft[current[1]] and isright[current[c]] then - current[1] = "" - current[c] = nil +-- current[c] = nil +-- current[1] = "" + remove(current,c) + remove(current,1) end i = i + 3 else @@ -960,9 +1024,54 @@ local function collapse(t,level) state = show_state(state,level,t) end -- - local n = #t - local i = 1 - local m = 0 + local n, m, i = #t, 0, 1 + while i <= n do + m = m + 1 + local current = t[i] + if isunary[current] then + local one = t[i+1] + if not one then + m = m + 1 + t[m] = current .. "{}" -- error + break + end + if type(one) == "table" then + if isleft[one[1]] and isright[one[#one]] then +-- one[1] = "" +-- one[#one] = nil + remove(one,#one) + remove(one,1) + end + one = collapse(one,level) + elseif one == "-" and i + 2 <= n then -- or another sign ? or unary ? + local t2 = t[i+2] + if type(t2) == "string" then + one = one .. t2 + i = i + 1 + end + end + t[m] = current .. "{" .. one .. "}" + i = i + 2 + else + t[m] = current + i = i + 1 + end + end + if i == n then -- yes? + m = m + 1 + t[m] = t[n] + end + if m < n then + for i=n,m+1,-1 do + t[i] = nil + end + end + -- + if trace_detail then + state = show_state(state,level,t) + end + -- + local n, m, i = #t, 0, 1 while i <= n do m = m + 1 local current = t[i] @@ -975,8 +1084,10 @@ local function collapse(t,level) end if type(one) == "table" then if isleft[one[1]] and isright[one[#one]] then - one[1] = "" - one[#one] = nil +-- one[1] = "" +-- one[#one] = nil + remove(one,#one) + remove(one,1) end one = collapse(one,level) end @@ -986,36 +1097,39 @@ local function collapse(t,level) end if type(two) == "table" then if isleft[two[1]] and isright[two[#two]] then - two[1] = "" - two[#two] = nil +-- two[1] = "" +-- two[#two] = nil + remove(two,#two) + remove(two,1) end two = collapse(two,level) end t[m] = current .. "{" .. one .. "}{" .. two .. "}" i = i + 3 - elseif isunary[current] then - local one = t[i+1] - if not one then - m = m + 1 - t[m] = current .. "{}" -- error - break - end - if type(one) == "table" then - if isleft[one[1]] and isright[one[#one]] then - one[1] = "" - one[#one] = nil - end - one = collapse(one,level) - elseif one == "-" and i + 2 <= n then -- or another sign ? or unary ? - local t2 = t[i+2] - if type(t2) == "string" then - one = one .. t2 - i = i + 1 - end - end - t[m] = current .. "{" .. one .. "}" - i = i + 2 - elseif type(current) == "table" then + else + t[m] = current + i = i + 1 + end + end + if i == n then -- yes? + m = m + 1 + t[m] = t[n] + end + if m < n then + for i=n,m+1,-1 do + t[i] = nil + end + end + -- + if trace_detail then + state = show_state(state,level,t) + end + -- + local n, m, i = #t, 0, 1 + while i <= n do + m = m + 1 + local current = t[i] + if type(current) == "table" then if current[1] == "\\NC" then t[m] = collapse(current,level) else @@ -1041,9 +1155,35 @@ local function collapse(t,level) state = show_state(state,level,t) end -- - local n = #t - local m = 0 - local i = 1 + local n, m, i = #t, 0, 1 + while i < n do + local current = t[i] + if isinfix[current] and i > 1 then + local tl = t[i-1] + local tr = t[i+1] + t[m] = tl .. current .. "{" .. tr .. "}" + i = i + 2 + else + m = m + 1 + t[m] = current + i = i + 1 + end + end + if i == n then + m = m + 1 + t[m] = t[n] + end + if m < n then + for i=n,m+1,-1 do + t[i] = nil + end + end + -- + if trace_detail then + state = show_state(state,level,t) + end + -- + local n, m, i = #t, 0, 1 while i < n do local current = t[i] if current == "/" and i > 1 then @@ -1083,13 +1223,12 @@ local function collapse(t,level) state = show_state(state,level,t) end -- - local n = #t - local m = 0 - local i = 1 + local n, m, i = #t, 0, 1 while i < n do local current = t[i] if current == "\\slash" and i > 1 then - t[m] = "{\\left(" .. t[i-1] .. "\\middle/" .. t[i+1] .. "\\right)}" +-- t[m] = "{\\left(" .. t[i-1] .. "\\middle/" .. t[i+1] .. "\\right)}" + t[m] = "{\\left." .. t[i-1] .. "\\middle/" .. t[i+1] .. "\\right.}" i = i + 2 else m = m + 1 @@ -1111,9 +1250,12 @@ local function collapse(t,level) state = show_state(state,level,t) end -- - local result = concat(t," ") - -- - return result + local n = #t + if t[1] == "\\left." and t[n] == "\\right." then + return concat(t," ",2,n-1) + else + return concat(t," ") + end end -- todo: cache simple ones, say #str < 10, maybe weak @@ -1183,15 +1325,17 @@ function collect(fpattern,element,collected,indexed) local element = element or "am" local mpattern = formatters["<%s>(.-)"](element,element) local filenames = dir.glob(fpattern) - local wildcard = string.split(fpattern,"*")[1] + local cfpattern = gsub(fpattern,"^%./",lfs.currentdir()) + local cfpattern = gsub(cfpattern,"\\","/") + local wildcard = string.split(cfpattern,"*")[1] if not collected then collected = { } indexed = { } end for i=1,#filenames do - filename = filenames[i] - local splitname = string.split(filename,wildcard) - local shortname = temp and temp[2] or file.basename(filename) + filename = gsub(filenames[i],"\\","/") + local splitname = (wildcard and wildcard ~= "" and string.split(filename,wildcard)[2]) or filename + local shortname = gsub(splitname or file.basename(filename),"^%./","") for s in gmatch(io.loaddata(filename),mpattern) do local c = cleanedup(s) local f = collected[c] @@ -1265,16 +1409,33 @@ if not context then -- trace_mapping = true -- trace_detail = true - report_asciimath(cleanedup([[ac+sinx+xsqrtx+sinsqrtx+sinsqrt(x)]])) - report_asciimath(cleanedup([[a "αsinsqrtx" b]])) - report_asciimath(cleanedup([[a "α" b]])) - - convert([[ac+sinx+xsqrtx]]) - convert([[ac+\alpha x+xsqrtx-cc b*pi**psi-3alephx / bb X]]) - convert([[ac+\ ^ x+xsqrtx]]) - convert([[d/dx(x^2+1)]]) - convert([[a "αsinsqrtx" b]]) - convert([[a "α" b]]) +-- report_asciimath(cleanedup([[ac+sinx+xsqrtx+sinsqrtx+sinsqrt(x)]])) +-- report_asciimath(cleanedup([[a "αsinsqrtx" b]])) +-- report_asciimath(cleanedup([[a "α" b]])) +-- report_asciimath(cleanedup([[//4]])) + +-- convert([[D_f=[0 ,→〉]]) +-- convert([[ac+sinx+xsqrtx]]) +-- convert([[ac+\alpha x+xsqrtx-cc b*pi**psi-3alephx / bb X]]) +-- convert([[ac+\ ^ x+xsqrtx]]) +-- convert([[d/dx(x^2+1)]]) +-- convert([[a "αsinsqrtx" b]]) +-- convert([[a "α" b]]) +-- convert([[//4]]) +-- convert([[ {(a+b,=,1),(a+b,=,7)) ]]) + +-- convert([[ 2/a // 5/b = (2 b) / ( a b) // ( 5 a ) / ( a b ) = (2 b ) / ( 5 a ) ]]) +-- convert([[ (2+x)/a // 5/b ]]) + +-- convert([[ ( 2/a ) // ( 5/b ) = ( (2 b) / ( a b) ) // ( ( 5 a ) / ( a b ) ) = (2 b ) / ( 5 a ) ]]) + +-- convert([[ (x/y)^3 = x^3/y^3 ]]) + +-- convert([[ {: (1,2) :} ]]) +-- convert([[ {: (a+b,=,1),(a+b,=,7) :} ]]) +-- convert([[ { (a+b,=,1),(a+b,=,7) :} ]]) +-- convert([[ {: (a+b,=,1),(a+b,=,7) } ]]) +-- convert([[ { (a+b,=,1),(a+b,=,7) } ]]) -- convert([[(1,5 ±sqrt(1,25 ),0 )]]) -- convert([[1//2]]) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 53364197f..0f4cdc112 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 06/05/14 23:04:38 +-- merge date : 06/06/14 23:52:32 do -- begin closure to overcome local limits and interference -- cgit v1.2.3