diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/lua/luatools.lua | 254 | ||||
-rw-r--r-- | scripts/context/lua/mtx-context.lua | 4 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 311 | ||||
-rw-r--r-- | scripts/context/ruby/base/system.rb | 2 | ||||
-rw-r--r-- | scripts/context/ruby/base/tex.rb | 10 | ||||
-rw-r--r-- | scripts/context/ruby/base/texutil.rb | 7 | ||||
-rw-r--r-- | scripts/context/ruby/graphics/inkscape.rb | 41 | ||||
-rw-r--r-- | scripts/context/ruby/texexec.rb | 11 |
8 files changed, 378 insertions, 262 deletions
diff --git a/scripts/context/lua/luatools.lua b/scripts/context/lua/luatools.lua index 660d69ef8..d6af50fb6 100644 --- a/scripts/context/lua/luatools.lua +++ b/scripts/context/lua/luatools.lua @@ -1362,6 +1362,78 @@ end +-- filename : l-set.lua +-- author : Hans Hagen, PRAGMA-ADE, Hasselt NL +-- copyright: PRAGMA ADE / ConTeXt Development Team +-- license : see context related readme files + +if not versions then versions = { } end versions['l-set'] = 1.001 + +if not set then set = { } end + +do + + local nums = { } + local tabs = { } + local concat = table.concat + + set.create = table.tohash + + function set.tonumber(t) + if next(t) then + local s = "" + -- we could save mem by sorting, but it slows down + for k, v in pairs(t) do + if v then + -- why bother about the leading space + s = s .. " " .. k + end + end + if not nums[s] then + tabs[#tabs+1] = t + nums[s] = #tabs + end + return nums[s] + else + return 0 + end + end + + function set.totable(n) + if n == 0 then + return { } + else + return tabs[n] or { } + end + end + + function set.contains(n,s) + if type(n) == "table" then + return n[s] + elseif n == 0 then + return false + else + local t = tabs[n] + return t and t[s] + end + end + +end + +--~ local c = set.create{'aap','noot','mies'} +--~ local s = set.tonumber(c) +--~ local t = set.totable(s) +--~ print(t['aap']) +--~ local c = set.create{'zus','wim','jet'} +--~ local s = set.tonumber(c) +--~ local t = set.totable(s) +--~ print(t['aap']) +--~ print(t['jet']) +--~ print(set.contains(t,'jet')) +--~ print(set.contains(t,'aap')) + + + -- filename : l-os.lua -- comment : split off from luat-lib -- author : Hans Hagen, PRAGMA-ADE, Hasselt NL @@ -2472,7 +2544,7 @@ do end function input.elapsedtime(instance) - return string.format("%0.3f",instance.loadtime or 0) + return string.format("%0.3f",(instance and instance.loadtime) or 0) end function input.report_loadtime(instance) @@ -2481,9 +2553,7 @@ function input.report_loadtime(instance) end end -function input.loadtime(instance) - tex.print(input.elapsedtime(instance)) -end +input.loadtime = input.elapsedtime function input.env(instance,key) return instance.environment[key] or input.osenv(instance,key) @@ -5078,6 +5148,78 @@ end -- callback into the file io and related things; disabling kpse + +if texconfig and not texlua then do + + -- this is not the right place, because we refer to quite some not yet defined tables, but who cares ... + + ctx = ctx or { } + + local ss = { } + + function ctx.writestatus(a,b) + local s = ss[a] + if not ss[a] then + s = a:rpadd(15) .. ": " + ss[a] = s + end + texio.write_nl(s .. b .. "\n") + end + + function ctx.show_statistics() + local function ws(...) + ctx.writestatus("mkiv lua stats",string.format(...)) + end + if caches then + ws("used config path - %s", caches.configpath(texmf.instance)) + ws("used cache path - %s", caches.path) + end + if status.luabytecodes > 0 and input.storage and input.storage.done then + ws("modules/dumps/instances - %s/%s/%s", status.luabytecodes-500, input.storage.done, status.luastates) + end + if texmf.instance then + ws("input load time - %s seconds", input.loadtime(texmf.instance)) + end + if fonts then + ws("fonts load time - %s seconds", input.loadtime(fonts)) + end + if xml then + ws("xml load time - %s seconds", input.loadtime(lxml)) + end + if mptopdf then + ws("mps conversion time - %s seconds", input.loadtime(mptopdf)) + end + if nodes then + ws("node processing time - %s seconds (including kernel)", input.loadtime(nodes)) + end + if kernel then + ws("kernel processing time - %s seconds", input.loadtime(kernel)) + end + if attributes then + ws("attribute processing time - %s seconds", input.loadtime(attributes)) + end + if languages then + ws("language load time - %s seconds (n=%s)", input.loadtime(languages), languages.hyphenation.n()) + end + if status.luastate_bytes then + ws("current memory usage - %s bytes", status.luastate_bytes) + end + if nodes then + ws("cleaned up reserved nodes - %s nodes, %s lists (of %s)", nodes.cleanup_reserved(tex.count[24])) -- \topofboxstack + end + if languages then + ws("loaded patterns - %s", languages.logger.report()) + end + if status.node_mem_usage then + ws("node memory usage - %s", status.node_mem_usage) + end + if fonts then + ws("loaded fonts - %s", fonts.logger.report()) -- last because it is often a long list + end + end + +end end + if texconfig and not texlua then texconfig.kpse_init = false @@ -5172,54 +5314,56 @@ if texconfig and not texlua then end - if callback and (input.logmode() == 'xml') then - - function input.start_page_number() - texio.write_nl("<p real='" .. tex.count[0] .. "' page='"..tex.count[1].."' sub='"..tex.count[2].."'") - end - function input.stop_page_number() - texio.write("/>") - texio.write_nl("") - end + if callback then - callback.register('start_page_number' , input.start_page_number) - callback.register('stop_page_number' , input.stop_page_number ) + if input.logmode() == 'xml' then - function input.report_output_pages(p,b) - texio.write_nl("<v k='pages'>"..p.."</v>") - texio.write_nl("<v k='bytes'>"..b.."</v>") - texio.write_nl("") - end - function input.report_output_log() - end + function input.start_page_number() + texio.write_nl("<p real='" .. tex.count[0] .. "' page='"..tex.count[1].."' sub='"..tex.count[2].."'") + end + function input.stop_page_number() + texio.write("/>") + texio.write_nl("") + end - callback.register('report_output_pages', input.report_output_pages) - callback.register('report_output_log' , input.report_output_log ) + callback.register('start_page_number' , input.start_page_number) + callback.register('stop_page_number' , input.stop_page_number ) - function input.start_run() - texio.write_nl("<?xml version='1.0' standalone='yes'?>") - texio.write_nl("<job xmlns='www.tug.org/luatex/schemas/context-job.rng'>") - texio.write_nl("") - end - function input.stop_run() - texio.write_nl("</job>") - end - function input.show_statistics() - for k,v in pairs(status.list()) do - texio.write_nl("log","<v k='"..k.."'>"..tostring(v).."</v>") + function input.report_output_pages(p,b) + texio.write_nl("<v k='pages'>"..p.."</v>") + texio.write_nl("<v k='bytes'>"..b.."</v>") + texio.write_nl("") + end + function input.report_output_log() end - end - table.insert(input.start_actions, input.start_run) + callback.register('report_output_pages', input.report_output_pages) + callback.register('report_output_log' , input.report_output_log ) + + function input.start_run() + texio.write_nl("<?xml version='1.0' standalone='yes'?>") + texio.write_nl("<job xmlns='www.tug.org/luatex/schemas/context-job.rng'>") + texio.write_nl("") + end + function input.stop_run() + texio.write_nl("</job>") + end + function input.show_statistics() + for k,v in pairs(status.list()) do + texio.write_nl("log","<v k='"..k.."'>"..tostring(v).."</v>") + end + end - table.insert(input.stop_actions, input.show_statistics) - table.insert(input.stop_actions, input.stop_run) + table.insert(input.start_actions, input.start_run) + table.insert(input.stop_actions , input.show_statistics) + table.insert(input.stop_actions , input.stop_run) - function input.start_run() for _, a in pairs(input.start_actions) do a() end end - function input.stop_run () for _, a in pairs(input.stop_actions ) do a() end end + else + table.insert(input.stop_actions , input.show_statistics) + end - callback.register('start_run', input.start_run) - callback.register('stop_run' , input.stop_run ) + callback.register('start_run', function() for _, a in pairs(input.start_actions) do a() end end) + callback.register('stop_run' , function() for _, a in pairs(input.stop_actions ) do a() end ctx.show_statistics() end) end @@ -5248,7 +5392,7 @@ end if texconfig and not texlua then - if not luatex then luatex = { } end + luatex = luatex or { } luatex.variablenames = { 'main_memory', 'extra_mem_bot', 'extra_mem_top', @@ -5338,7 +5482,7 @@ if node then for i=1,nofboxes do local l = tb[i] if l then - flush(l) + -- flush(l) tb[i] = nil nl = nl + 1 end @@ -5348,9 +5492,6 @@ if node then return nr, nl, nofboxes end - -- nodes.register = function() end - -- nodes.cleanup_reserved = function() end - end do @@ -5408,6 +5549,20 @@ if node then end +if tex then + + function tex.node_mem_status() + -- todo: lpeg + local s = status.node_mem_usage + local t = { } + for n, tag in s:gmatch("(%d+) ([a-z_]+)") do + t[tag] = n + end + return t + end + +end + if not modules then modules = { } end modules ['luat-kps'] = { version = 1.001, @@ -5528,6 +5683,7 @@ own.libs = { -- todo: check which ones are really needed 'l-table.lua', 'l-io.lua', 'l-number.lua', + 'l-set.lua', 'l-os.lua', 'l-md5.lua', 'l-file.lua', @@ -5596,7 +5752,7 @@ input.banner = 'LuaTools | ' utils.report = input.report input.defaultlibs = { -- not all are needed - 'l-string.lua', 'l-lpeg.lua', 'l-table.lua', 'l-boolean.lua', 'l-number.lua', 'l-unicode.lua', + 'l-string.lua', 'l-lpeg.lua', 'l-table.lua', 'l-boolean.lua', 'l-number.lua', 'l-set.lua', 'l-unicode.lua', 'l-md5.lua', 'l-os.lua', 'l-io.lua', 'l-file.lua', 'l-dir.lua', 'l-utils.lua', 'l-tex.lua', 'luat-lib.lua', 'luat-inp.lua', 'luat-tmp.lua', 'luat-zip.lua', 'luat-tex.lua' } diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 2e7855847..2a4e25071 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -591,7 +591,7 @@ messages.help = [[ ]] input.verbose = true -input.start_timing(scripts.context) +input.starttiming(scripts.context) if environment.argument("run") then scripts.context.run() @@ -603,5 +603,5 @@ else input.help(banner,messages.help) end -input.stop_timing(scripts.context) +input.stoptiming(scripts.context) input.report("total runtime: " .. input.elapsedtime(scripts.context)) diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 011ee8bb2..5a19d7960 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -1397,6 +1397,78 @@ end +-- filename : l-set.lua +-- author : Hans Hagen, PRAGMA-ADE, Hasselt NL +-- copyright: PRAGMA ADE / ConTeXt Development Team +-- license : see context related readme files + +if not versions then versions = { } end versions['l-set'] = 1.001 + +if not set then set = { } end + +do + + local nums = { } + local tabs = { } + local concat = table.concat + + set.create = table.tohash + + function set.tonumber(t) + if next(t) then + local s = "" + -- we could save mem by sorting, but it slows down + for k, v in pairs(t) do + if v then + -- why bother about the leading space + s = s .. " " .. k + end + end + if not nums[s] then + tabs[#tabs+1] = t + nums[s] = #tabs + end + return nums[s] + else + return 0 + end + end + + function set.totable(n) + if n == 0 then + return { } + else + return tabs[n] or { } + end + end + + function set.contains(n,s) + if type(n) == "table" then + return n[s] + elseif n == 0 then + return false + else + local t = tabs[n] + return t and t[s] + end + end + +end + +--~ local c = set.create{'aap','noot','mies'} +--~ local s = set.tonumber(c) +--~ local t = set.totable(s) +--~ print(t['aap']) +--~ local c = set.create{'zus','wim','jet'} +--~ local s = set.tonumber(c) +--~ local t = set.totable(s) +--~ print(t['aap']) +--~ print(t['jet']) +--~ print(set.contains(t,'jet')) +--~ print(set.contains(t,'aap')) + + + -- filename : l-os.lua -- comment : split off from luat-lib -- author : Hans Hagen, PRAGMA-ADE, Hasselt NL @@ -4236,7 +4308,7 @@ do end function input.elapsedtime(instance) - return string.format("%0.3f",instance.loadtime or 0) + return string.format("%0.3f",(instance and instance.loadtime) or 0) end function input.report_loadtime(instance) @@ -4245,9 +4317,7 @@ function input.report_loadtime(instance) end end -function input.loadtime(instance) - tex.print(input.elapsedtime(instance)) -end +input.loadtime = input.elapsedtime function input.env(instance,key) return instance.environment[key] or input.osenv(instance,key) @@ -4275,6 +4345,7 @@ end function input.identify_cnf(instance) if #instance.cnffiles == 0 then if instance.treepath ~= "" then + -- this is a special purpose branch, not really used if instance.rootpath ~= "" then local t = instance.treepath:splitchr(',') for k,v in ipairs(t) do @@ -4287,6 +4358,7 @@ function input.identify_cnf(instance) instance.environment['TEXMFCNF'] = file.join(t[1] or '.','texmf/web2c') end if instance.rootpath ~= "" then + -- this assumes a single path, maybe do an expanded split here too instance.environment['TEXMFCNF'] = file.join(instance.rootpath,'texmf/web2c') instance.environment['SELFAUTOPARENT'] = instance.rootpath end @@ -4314,9 +4386,9 @@ function input.load_cnf(instance) else instance.rootpath = instance.cnffiles[1] for k,fname in ipairs(instance.cnffiles) do - instance.cnffiles[k] = fname:gsub("\\",'/') + instance.cnffiles[k] = fname:gsub("\\",'/') -- needed? end - for i = 1, 3 do + for i=1,3 do instance.rootpath = file.dirname(instance.rootpath) end if instance.lsrmode then @@ -4494,22 +4566,33 @@ function input.locatedatabase(instance,specification) return input.methodhandler('locators', instance, specification) end +--~ poor mans solution, from before we had lfs.isdir +--~ +--~ function input.locators.tex(instance,specification) +--~ if specification and specification ~= '' then +--~ local files = { +--~ file.join(specification,'files'..input.lucsuffix), +--~ file.join(specification,'files'..input.luasuffix), +--~ file.join(specification,input.lsrname) +--~ } +--~ for _, filename in pairs(files) do +--~ local f = io.open(filename) +--~ if f then +--~ input.logger('! tex locator', specification..' found') +--~ input.aux.append_hash(instance,'file',specification,filename) +--~ f:close() +--~ return +--~ end +--~ end +--~ input.logger('? tex locator', specification..' not found') +--~ end +--~ end + function input.locators.tex(instance,specification) - if specification and specification ~= '' then - local files = { - file.join(specification,'files'..input.lucsuffix), - file.join(specification,'files'..input.luasuffix), - file.join(specification,input.lsrname) - } - for _, filename in pairs(files) do - local f = io.open(filename) - if f then - input.logger('! tex locator', specification..' found') - input.aux.append_hash(instance,'file',specification,filename) - f:close() - return - end - end + if specification and specification ~= '' and lfs.isdir(specification) then + input.logger('! tex locator', specification..' found') + input.aux.append_hash(instance,'file',specification,filename) + else input.logger('? tex locator', specification..' not found') end end @@ -4696,14 +4779,14 @@ function input.join_path(str) return str end end -function input.splitexpansions(instance) - for k,v in pairs(instance.expansions) do - local t = file.split_path(v) - if #t > 1 then - instance.expansions[k] = t - end - end -end +--~ function input.splitexpansions(instance) +--~ for k,v in pairs(instance.expansions) do +--~ local t = file.split_path(v) +--~ if #t > 1 then +--~ instance.expansions[k] = t +--~ end +--~ end +--~ end function input.splitexpansions(instance) for k,v in pairs(instance.expansions) do local t, h = { }, { } @@ -4863,7 +4946,8 @@ function input.expand_variables(instance) for k,v in pairs(instance.expansions) do instance.expansions[k] = v:gsub("\\", '/') end - input.splitexpansions(instance) + -- ########## + --~ input.splitexpansions(instance) -- better not, fuzzy end function input.aux.expand_vars(instance,lst) -- simple vars @@ -5083,80 +5167,6 @@ end -- work that well; the parsing is ok, but dealing with the resulting -- table is a pain because we need to work inside-out recursively ---~ function input.aux.splitpathexpr(str, t, validate) ---~ -- no need for optimization, only called a few times, we can use lpeg for the sub ---~ t = t or { } ---~ while true do ---~ local done = false ---~ while true do ---~ ok = false ---~ str = str:gsub("([^{},]+){([^{}]-)}", function(a,b) ---~ local t = { } ---~ for s in b:gmatch("([^,]+)") do ---~ t[#t+1] = a .. s ---~ end ---~ ok, done = true, true ---~ return "{" .. table.concat(t,",") .. "}" ---~ end) ---~ if not ok then break end ---~ end ---~ while true do ---~ ok = false ---~ str = str:gsub("{([^{}]-)}([^{},]+)", function(a,b) ---~ local t = { } ---~ for s in a:gmatch("([^,]+)") do ---~ t[#t+1] = s .. b ---~ end ---~ ok, done = true, true ---~ return "{" .. table.concat(t,",") .. "}" ---~ end) ---~ if not ok then break end ---~ end ---~ while true do ---~ ok = false ---~ str = str:gsub("([,{]){([^{}]+)}([,}])", function(a,b,c) ---~ ok, done = true, true ---~ return a .. b .. c ---~ end) ---~ if not ok then break end ---~ end ---~ if not done then break end ---~ end ---~ while true do ---~ ok = false ---~ str = str:gsub("{([^{}]-)}{([^{}]-)}", function(a,b) ---~ local t = { } ---~ for sa in a:gmatch("([^,]+)") do ---~ for sb in b:gmatch("([^,]+)") do ---~ t[#t+1] = sa .. sb ---~ end ---~ end ---~ ok = true ---~ return "{" .. table.concat(t,",") .. "}" ---~ end) ---~ if not ok then break end ---~ end ---~ while true do ---~ ok = false ---~ str = str:gsub("{([^{}]-)}", function(a) ---~ ok = true ---~ return a ---~ end) ---~ if not ok then break end ---~ end ---~ if validate then ---~ for s in str:gmatch("([^,]+)") do ---~ s = validate(s) ---~ if s then t[#t+1] = s end ---~ end ---~ else ---~ for s in str:gmatch("([^,]+)") do ---~ t[#t+1] = s ---~ end ---~ end ---~ return t ---~ end - function input.aux.splitpathexpr(str, t, validate) -- no need for optimization, only called a few times, we can use lpeg for the sub t = t or { } @@ -5228,7 +5238,7 @@ function input.aux.splitpathexpr(str, t, validate) return t end -function input.aux.expanded_path(instance,pathlist) +function input.aux.expanded_path(instance,pathlist) -- maybe not a list, just a path -- a previous version fed back into pathlist local newlist, ok = { }, false for _,v in ipairs(pathlist) do @@ -5255,87 +5265,6 @@ function input.aux.expanded_path(instance,pathlist) return newlist end ---~ old one, imperfect and not that efficient ---~ ---~ function input.aux.expanded_path(instance,pathlist) ---~ -- a previous version fed back into pathlist ---~ local i, n, oldlist, newlist, ok = 0, 0, { }, { }, false ---~ for _,v in ipairs(pathlist) do ---~ if v:find("[{}]") then ---~ ok = true ---~ break ---~ end ---~ end ---~ if ok then ---~ for _,v in ipairs(pathlist) do ---~ oldlist[#oldlist+1] = (v:gsub("([\{\}])", function(p) ---~ if p == "{" then ---~ i = i + 1 ---~ if i > n then n = i end ---~ return "<" .. (i-1) .. ">" ---~ else ---~ i = i - 1 ---~ return "</" .. i .. ">" ---~ end ---~ end)) ---~ end ---~ for i=1,n do ---~ while true do ---~ local more = false ---~ local pattern = "^(.-)<"..(n-i)..">(.-)</"..(n-i)..">(.-)$" ---~ local t = { } ---~ for _,v in ipairs(oldlist) do ---~ local pre, mid, post = v:match(pattern) ---~ if pre and mid and post then ---~ more = true ---~ for vv in string.gmatch(mid..',',"(.-),") do -- (mid, "([^,]+)") ---~ if vv == '.' then ---~ t[#t+1] = pre..post ---~ else ---~ t[#t+1] = pre..vv..post ---~ end ---~ end ---~ else ---~ t[#t+1] = v ---~ end ---~ end ---~ oldlist = t ---~ if not more then break end ---~ end ---~ end ---~ if true then ---~ -- many dups are possible due to messy resolve / order can be messed up too, brr ! ---~ local ok = { } ---~ for _,o in ipairs(oldlist) do ---~ for v in o:gmatch("([^,]+)") do ---~ if not ok[v] then ---~ ok[v] = true ---~ v = file.collapse_path(v) ---~ if v ~= "" and not v:find(instance.dummy_path_expr) then newlist[#newlist+1] = v end ---~ end ---~ end ---~ end ---~ else ---~ for _,v in ipairs(oldlist) do ---~ v = file.collapse_path(v) ---~ if v ~= "" and not v:find(instance.dummy_path_expr) then newlist[#newlist+1] = v end ---~ end ---~ end ---~ else ---~ for _,v in ipairs(pathlist) do ---~ for vv in string.gmatch(v..',',"(.-),") do ---~ vv = file.collapse_path(v) ---~ if vv ~= "" then newlist[#newlist+1] = vv end ---~ end ---~ end ---~ end ---~ return newlist ---~ end - ---~ function input.is_readable(name) -- brrr, get rid of this ---~ return name:find("^zip##") or file.is_readable(name) ---~ end - input.is_readable = { } function input.aux.is_readable(readable, name) @@ -6115,6 +6044,10 @@ function input.update_script(instance,oldname,newname) -- oldname -> own.name, n end +--~ print(table.serialize(input.aux.splitpathexpr("/usr/share/texmf-{texlive,tetex}", {}))) + + + if not modules then modules = { } end modules ['luat-tmp'] = { version = 1.001, comment = "companion to luat-lib.tex", @@ -6169,7 +6102,8 @@ elseif lfs.attributes(caches.temp,"mode") ~= "directory" then end function caches.configpath(instance) - return input.expand_var(instance,"TEXMFCNF") + return table.concat(instance.cnffiles,";") +--~ return input.expand_var(instance,"TEXMFCNF") end function caches.treehash(instance) @@ -6184,7 +6118,7 @@ end function caches.setpath(instance,...) if not caches.path then if lfs and instance then - for _,v in pairs(caches.paths) do + for _,v in pairs(caches.paths) do for _,vv in pairs(input.expanded_path_list(instance,v)) do if lfs.isdir(vv) then caches.path = vv @@ -6725,6 +6659,7 @@ own.libs = { -- todo: check which ones are really needed 'l-io.lua', 'l-md5.lua', 'l-number.lua', + 'l-set.lua', 'l-os.lua', 'l-file.lua', 'l-dir.lua', diff --git a/scripts/context/ruby/base/system.rb b/scripts/context/ruby/base/system.rb index 267a22cb9..c3fb08645 100644 --- a/scripts/context/ruby/base/system.rb +++ b/scripts/context/ruby/base/system.rb @@ -30,7 +30,7 @@ module System def System.null - if @@mswindows then 'nul' else '/dev/null/' end + if @@mswindows then 'nul' else '/dev/null' end end def System.unix? diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb index 54d5bc730..02683bd60 100644 --- a/scripts/context/ruby/base/tex.rb +++ b/scripts/context/ruby/base/tex.rb @@ -95,6 +95,7 @@ class TEX ['tex','etex','pdftex','pdfetex','standard'] .each do |e| @@texengines[e] = 'pdftex' end ['aleph','omega'] .each do |e| @@texengines[e] = 'aleph' end ['xetex'] .each do |e| @@texengines[e] = 'xetex' end + ['petex'] .each do |e| @@texengines[e] = 'petex' end ['luatex'] .each do |e| @@texengines[e] = 'luatex' end ['metapost','mpost', 'standard'] .each do |e| @@mpsengines[e] = 'mpost' end @@ -102,6 +103,7 @@ class TEX ['pdfetex','pdftex','pdf','pdftex','standard'] .each do |b| @@backends[b] = 'pdftex' end ['dvipdfmx','dvipdfm','dpx','dpm'] .each do |b| @@backends[b] = 'dvipdfmx' end ['xetex','xtx'] .each do |b| @@backends[b] = 'xetex' end + ['petex'] .each do |b| @@backends[b] = 'dvipdfmx' end ['aleph'] .each do |b| @@backends[b] = 'dvipdfmx' end ['dvips','ps','dvi'] .each do |b| @@backends[b] = 'dvips' end ['dvipsone'] .each do |b| @@backends[b] = 'dvipsone' end @@ -110,7 +112,7 @@ class TEX ['tex','standard'] .each do |b| @@mappaths[b] = 'dvips' end ['pdftex','pdfetex'] .each do |b| @@mappaths[b] = 'pdftex' end - ['aleph','omega','xetex'] .each do |b| @@mappaths[b] = 'dvipdfm' end + ['aleph','omega','xetex','petex'] .each do |b| @@mappaths[b] = 'dvipdfm' end ['dvipdfm', 'dvipdfmx', 'xdvipdfmx'] .each do |b| @@mappaths[b] = 'dvipdfm' end ['xdv','xdv2pdf'] .each do |b| @@mappaths[b] = 'dvips' end @@ -132,9 +134,7 @@ class TEX ['plain','mpost'] .each do |f| @@mpsformats[f] = 'plain' end ['metafun','context','standard'] .each do |f| @@mpsformats[f] = 'metafun' end - # no 'standard' progname ! / beware, when using texexec we always use the context/metafun values - - ['pdftex','pdfetex','aleph','omega', + ['pdftex','pdfetex','aleph','omega','petex', 'xetex','luatex'] .each do |p| @@prognames[p] = 'context' end ['mpost'] .each do |p| @@prognames[p] = 'metafun' end ['latex','pdflatex'] .each do |p| @@prognames[p] = 'latex' end @@ -158,6 +158,7 @@ class TEX @@runoptions['mpost'] = ['--8bit'] @@runoptions['pdfetex'] = ['--8bit'] # obsolete @@runoptions['pdftex'] = ['--8bit'] # pdftex is now pdfetex + # @@runoptions['petex'] = [] @@runoptions['xetex'] = ['--8bit','-output-driver="xdvipdfmx -E -d 4 -V 5"'] @@tcxflag['aleph'] = true @@ -165,6 +166,7 @@ class TEX @@tcxflag['mpost'] = true @@tcxflag['pdfetex'] = true @@tcxflag['pdftex'] = true + @@tcxflag['petex'] = false @@tcxflag['xetex'] = false @@draftoptions['pdftex'] = ['--draftmode'] diff --git a/scripts/context/ruby/base/texutil.rb b/scripts/context/ruby/base/texutil.rb index 4882404d5..063f67f2d 100644 --- a/scripts/context/ruby/base/texutil.rb +++ b/scripts/context/ruby/base/texutil.rb @@ -187,7 +187,14 @@ class TeXUtil # shortcut("\\\"e", 'ediaeresis') # shortcut("\\\'o", 'oacute') + def hextoutf(str) + str.gsub(/^(0x[A-F\d]+)$/) do + [$1.hex()].pack("U") + end + end + def shortcut(from,to) + from = hextoutf(from) replacer(from,to) expander(to) end diff --git a/scripts/context/ruby/graphics/inkscape.rb b/scripts/context/ruby/graphics/inkscape.rb index 4495c3070..8d3b26468 100644 --- a/scripts/context/ruby/graphics/inkscape.rb +++ b/scripts/context/ruby/graphics/inkscape.rb @@ -43,6 +43,10 @@ class InkScape def convert(logfile=System.null) + directpdf = false + + logfile = logfile.gsub(/\/+$/,"") + inpfilename = getvariable('inputfile').dup outfilename = getvariable('outputfile').dup outfilename = inpfilename.dup if outfilename.empty? @@ -62,11 +66,15 @@ class InkScape return false end - report("converting #{inpfilename} to #{tmpfilename}") - # we need to redirect the error info else we get a pop up console - resultpipe = "--without-gui --print=\">#{tmpfilename}\" 2>#{logfile}" + if directpdf then + report("converting #{inpfilename} to #{outfilename}") + resultpipe = "--without-gui --export-pdf=\"#{outfilename}\" 2>#{logfile}" + else + report("converting #{inpfilename} to #{tmpfilename}") + resultpipe = "--without-gui --print=\">#{tmpfilename}\" 2>#{logfile}" + end arguments = [resultpipe,inpfilename].join(' ').gsub(/\s+/,' ') @@ -76,8 +84,11 @@ class InkScape # should work # ok = System.run('inkscape',arguments) # does not work here # but 0.40 only works with this: - ok = system("inkscape #{arguments}") + command = "inkscape #{arguments}" + report(command) + ok = system(command) # and 0.41 fails with everything + # and 0.45 is better rescue report("aborted due to error") return false @@ -85,18 +96,16 @@ class InkScape return false unless ok end - ghostscript = GhostScript.new(@logger) - - ghostscript.setvariable('inputfile',tmpfilename) - ghostscript.setvariable('outputfile',outfilename) - - report("converting #{tmpfilename} to #{outfilename}") - - ghostscript.convert - - begin - File.delete(tmpfilename) - rescue + if not directpdf then + ghostscript = GhostScript.new(@logger) + ghostscript.setvariable('inputfile',tmpfilename) + ghostscript.setvariable('outputfile',outfilename) + report("converting #{tmpfilename} to #{outfilename}") + ghostscript.convert + begin + File.delete(tmpfilename) + rescue + end end end diff --git a/scripts/context/ruby/texexec.rb b/scripts/context/ruby/texexec.rb index d2c722438..a09572c6c 100644 --- a/scripts/context/ruby/texexec.rb +++ b/scripts/context/ruby/texexec.rb @@ -575,14 +575,16 @@ job.setvariable('given.backend',job.getvariable('backend')) if (str = @commandline.option('engine')) && ! str.standard? && ! str.empty? then job.setvariable('texengine',str) + elsif @commandline.oneof('luatex') then + job.setvariable('texengine','luatex') elsif @commandline.oneof('pdfetex','pdftex','pdf') then job.setvariable('texengine','pdftex') elsif @commandline.oneof('xetex','xtx') then job.setvariable('texengine','xetex') elsif @commandline.oneof('aleph') then job.setvariable('texengine','aleph') - elsif @commandline.oneof('luatex') then - job.setvariable('texengine','luatex') + elsif @commandline.oneof('petex') then + job.setvariable('texengine','petex') else job.setvariable('texengine','standard') end @@ -597,6 +599,8 @@ job.setvariable('given.backend',job.getvariable('backend')) job.setvariable('backend','xetex') elsif @commandline.oneof('aleph') then job.setvariable('backend','dvipdfmx') + elsif @commandline.oneof('petex') then + job.setvariable('backend','dvipdfmx') elsif @commandline.oneof('dvips','ps') then job.setvariable('backend','dvips') elsif @commandline.oneof('xdv') then @@ -607,6 +611,7 @@ job.setvariable('given.backend',job.getvariable('backend')) when 'pdftex' then job.setvariable('backend','pdftex') when 'luatex' then job.setvariable('backend','pdftex') when 'xetex' then job.setvariable('backend','xetex') + when 'petex' then job.setvariable('backend','dvipdfmx') when 'aleph' then job.setvariable('backend','dvipdfmx') else job.setvariable('backend','standard') @@ -760,6 +765,8 @@ commandline.registerflag('xdv') commandline.registerflag('aleph') +commandline.registerflag('petex') + commandline.registerflag('all') commandline.registerflag('fast') commandline.registerflag('sort') |