diff options
author | Hans Hagen <pragma@wxs.nl> | 2011-01-14 14:32:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2011-01-14 14:32:00 +0100 |
commit | 237091b7a4e3a7e2e6601cfe246dac4b4b1ff988 (patch) | |
tree | c4135682b1fd54c266d318ed406ef4bc9e0d629f | |
parent | 8980a62e6a345d2f2746bdca2d207d6cf78aab5f (diff) | |
download | context-237091b7a4e3a7e2e6601cfe246dac4b4b1ff988.tar.gz |
beta 2011.01.14 14:32
-rw-r--r-- | scripts/context/lua/mtx-metapost.lua | 171 | ||||
-rw-r--r-- | scripts/context/lua/mtx-mptopdf.lua | 127 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 12 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 12 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/mtxrun | 12 | ||||
-rw-r--r-- | tex/context/base/buff-ver.lua | 55 | ||||
-rw-r--r-- | tex/context/base/cont-new.tex | 2 | ||||
-rw-r--r-- | tex/context/base/context.tex | 2 | ||||
-rw-r--r-- | tex/context/base/font-ini.mkiv | 11 | ||||
-rw-r--r-- | tex/context/base/l-lpeg.lua | 6 | ||||
-rw-r--r-- | tex/context/base/math-ini.mkiv | 5 | ||||
-rw-r--r-- | tex/context/base/meta-pdf.lua | 18 | ||||
-rw-r--r-- | tex/context/base/v-default.lua | 4 | ||||
-rw-r--r-- | tex/context/base/v-lua.lua | 34 | ||||
-rw-r--r-- | tex/generic/context/luatex-fonts-merged.lua | 8 |
15 files changed, 269 insertions, 210 deletions
diff --git a/scripts/context/lua/mtx-metapost.lua b/scripts/context/lua/mtx-metapost.lua new file mode 100644 index 000000000..9bdd1260f --- /dev/null +++ b/scripts/context/lua/mtx-metapost.lua @@ -0,0 +1,171 @@ +if not modules then modules = { } end modules ['mtx-metapost'] = { -- this was mtx-mptopdf + version = 0.100, + comment = "companion to mtxrun.lua", + author = "Taco Hoekwater & Hans Hagen", + copyright = "ConTeXt Development Team", + license = "see context related readme files" +} + +scripts = scripts or { } +scripts.mptopdf = scripts.mptopdf or { } +scripts.mptopdf.aux = scripts.mptopdf.aux or { } + +local format, find, gsub = string.format, string.find, string.gsub + +local function assumes_latex(filename) + local d = io.loaddata(filename) or "" + return find(d,"\\documentstyle") or find(d,"\\documentclass") or find(d,"\\begin{document}") +end + +local template = "\\startTEXpage\n\\convertMPtoPDF{%s}{1}{1}\n\\stopTEXpage" +local texified = "\\starttext\n%s\n\\stoptext" +local splitter = "\\startTEXpage\\externalfigure[%s][page=%s]\\stopTEXpage" +local tempname = "mptopdf-temp.tex" + +local function do_convert(filename) + if find(filename,".%d+$") or find(filename,"%.mps$") then + io.savedata(tempname,format(template,filename)) + local resultname = format("%s-%s.pdf",file.nameonly(filename),file.extname(filename)) + local result = os.execute(format([[context --once --batch --purge --result=%s "%s"]],resultname,tempname)) + return lfs.isfile(resultname) and resultname + end +end + +local function do_split(filename,numbers) + local name = file.nameonly(filename) + for i=1,#numbers do + io.savedata(tempname,format(splitter,file.addsuffix(name,"pdf"),i)) + local resultname = format("%s-%s.pdf",name,numbers[i]) + local result = os.execute(format([[context --once --batch --purge --result=%s "%s"]],resultname,tempname)) + end +end + +local function do_texify(str) + -- This only works for flat mp files i.e. outer beginfigs. Normally a + -- context user will directly make a tex file. Of course we can make + -- this script more clever, but why should we as better methods exist. + local numbers = { } + str = "\\startMPinclusions\n".. str .. "\n\\stopMPinclusions" + str = gsub(str,"beginfig%s*%(%s*(.-)%s*%)%s*;%s*",function(s) + numbers[#numbers+1] = tonumber(s) or 0 + return "\n\\stopMPinclusions\n\\startMPpage\n" + end) + str = gsub(str,"%s*endfig%s*;%s*","\n\\stopMPpage\n\\startMPinclusions\n") + str = gsub(str,"\\startMPinclusions%s*\\stopMPinclusions","") + str = gsub(str,"[\n\r]+","\n") + return format(texified,str), numbers +end + +local function do_convert_all(filename) + local results = dir.glob(file.nameonly(filename) .. ".*") -- reset + local report = { } + for i=1,#results do + local filename = results[i] + local resultname = do_convert(filename) + if resultname then + report[#report+1] = { filename, resultname } + end + end + if #report > 0 then + logs.simple("number of converted files: %i", #report) + logs.simple("") + for i=1,#report do + local r = report[i] + logs.simple("%s => %s", r[1], r[2]) + end + else + logs.simple("no files are converted for '%s'",filename) + end +end + +local function do_convert_one(filename) + local resultname = do_convert(filename) + if resultname then + logs.simple("%s => %s", filename,resultname) + else + logs.simple("no result for '%s'",filename) + end +end + +function scripts.mptopdf.convertall() + local rawmp = environment.arguments.rawmp or false + local metafun = environment.arguments.metafun or false + local latex = environment.arguments.latex or false + local pattern = environment.arguments.pattern or false + local split = environment.arguments.split or false + local files + if pattern then + files = dir.glob(file.nameonly(filename)) + else + files = environment.files + end + if #files > 0 then + for i=1,#files do + local filename = files[i] + if file.suffix(filename) == "mp" then + local command, convert, texdata, numbers + if rawmp then + if metafun then + command, convert = format("mpost --progname=mpost --mem=metafun %s",filename), true + else + command, convert = format("mpost --mem=mpost %s",filename), true + end + else + if latex or assumes_latex(filename) then + command, convert = format("mpost --mem=mpost --tex=latex %s",filename), true + elseif texexec then + command, convert = format("texexec --mptex %s",filename), true + else + texdata, numbers = do_texify(io.loaddata(filename) or "") + io.savedata(tempname,texdata) + command, convert = format("context --result=%s --purge --once %s",file.nameonly(filename),tempname), false + end + end + logs.simple("running: %s\n",command) + local done = os.execute(command) + if done then + if convert then + do_convert_all(filename) + elseif split then + do_split(filename,numbers) + -- already pdf, maybe optionally split + end + else + logs.simple("error while processing mp file '%s'", filename) + end + else + do_convert_one(filename) + end + end + else + logs.simple("no files match to process") + end +end + +logs.extendbanner("MetaPost to PDF processor 0.10") + +messages.help = [[ +--rawmp raw metapost run +--metafun use metafun instead of plain +--latex force --tex=latex +--texexec force texexec usage (mkii) +--split split single result file into pages + +intended usage: + +mtxrun --script metapost yourfile.mp +mtxrun --script metapost --split yourfile.mp +mtxrun --script metapost yourfile.123 myfile.mps + +other usage resembles mptopdf.pl +]] + +if environment.files[1] then + scripts.mptopdf.convertall() +else + if not environment.arguments.help then + logs.simple("provide MP output file (or pattern)") + logs.simple("") + end + logs.help(messages.help) +end diff --git a/scripts/context/lua/mtx-mptopdf.lua b/scripts/context/lua/mtx-mptopdf.lua deleted file mode 100644 index 4662c2830..000000000 --- a/scripts/context/lua/mtx-mptopdf.lua +++ /dev/null @@ -1,127 +0,0 @@ -if not modules then modules = { } end modules ['mtx-mptopdf'] = { - version = 1.303, - comment = "companion to mtxrun.lua, patched by HH so errors are his", - author = "Taco Hoekwater, Elvenkind BV, Dordrecht NL", - copyright = "Elvenkind BV / ConTeXt Development Team", - license = "see context related readme files" -} - -scripts = scripts or { } -scripts.mptopdf = scripts.mptopdf or { } -scripts.mptopdf.aux = scripts.mptopdf.aux or { } - -local dosish = os.type == 'windows' -local miktex = dosish and environment.TEXSYSTEM and environment.TEXSYSTEM:find("miktex") -local escapeshell = environment.SHELL and environment.SHELL:find("sh") and true - -function scripts.mptopdf.aux.find_latex(fname) - local d = io.loaddata(fname) or "" - return d:find("\\documentstyle") or d:find("\\documentclass") or d:find("\\begin{document}") -end - -function scripts.mptopdf.aux.do_convert (fname) - local command, done, pdfdest = "", 0, "" - if fname:find(".%d+$") or fname:find("%.mps$") then - if miktex then - command = "pdftex -undump=mptopdf" - else - command = "pdftex -fmt=mptopdf -progname=context" - end - if dosish then - command = string.format('%s \\relax "%s"',command,fname) - else - command = string.format('%s \\\\relax "%s"',command,fname) - end - local result = os.execute(command) - if result == 0 then - local name, suffix = file.nameonly(fname), file.extname(fname) - local pdfsrc = name .. ".pdf" - if lfs.isfile(pdfsrc) then - pdfdest = name .. "-" .. suffix .. ".pdf" - os.rename(pdfsrc, pdfdest) - if lfs.isfile(pdfsrc) then -- rename failed - file.copy(pdfsrc, pdfdest) - end - done = 1 - end - end - end - return done, pdfdest -end - -function scripts.mptopdf.aux.make_mps(fn,latex,rawmp,metafun) - local rest, mpbin = latex and " --tex=latex " or " ", "" - if rawmp then - if metafun then - mpbin = "mpost --progname=mpost --mem=metafun" - else - mpbin = "mpost --mem=mpost" - end - else - if latex then - mpbin = "mpost --mem=mpost" - else - mpbin = "texexec --mptex" - end - end - local runner = mpbin .. rest .. fn - logs.simple("running: %s\n", runner) - return (os.execute(runner)) -end - -function scripts.mptopdf.convertall() - local rawmp = environment.arguments.rawmp or false - local metafun = environment.arguments.metafun or false - local latex = environment.arguments.latex or false - local files = dir.glob(environment.files) - if #files > 0 then - local fn = files[1] - if #files == 1 and fn:find("%.mp$") then - latex = scripts.mptopdf.aux.find_latex(fn) or latex - end - if scripts.mptopdf.aux.make_mps(fn,latex,rawmp,metafun) then - files = dir.glob(file.nameonly(fn) .. ".*") -- reset - else - logs.simple("error while processing mp file '%s'", fn) - exit(1) - end - local report = { } - for i=1,#files do - local fn = files[i] - local success, name = scripts.mptopdf.aux.do_convert(fn) - if success > 0 then - report[#report+1] = { fn, name } - end - end - if #report > 0 then - logs.simple("number of converted files: %i", #report) - logs.simple("") - for i=1,#report do - local r = report[i] - logs.simple("%s => %s", r[1], r[2]) - end - else - logs.simple("no files are converted") - end - else - logs.simple("no files match %s", table.concat(environment.files,' ')) - end -end - -logs.extendbanner("MetaPost to PDF Converter 0.51") - -messages.help = [[ ---rawmp raw metapost run ---metafun use metafun instead of plain ---latex force --tex=latex -]] - -if environment.files[1] then - scripts.mptopdf.convertall() -else - if not environment.arguments.help then - logs.simple("provide MP output file (or pattern)") - logs.simple("") - end - logs.help(messages.help) -end diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index d264c05ab..75a527188 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -207,9 +207,6 @@ local squote = P("'") local dquote = P('"') local space = P(" ") -patterns.somecontent = (anything - newline - space)^1 -patterns.beginline = #(1-newline) - local utfbom_32_be = P('\000\000\254\255') local utfbom_32_le = P('\255\254\000\000') local utfbom_16_be = P('\255\254') @@ -282,6 +279,9 @@ patterns.undouble = (dquote/"") * patterns.nodquote * (dquote/"") patterns.unquoted = patterns.undouble + patterns.unsingle -- more often undouble patterns.unspacer = ((patterns.spacer^1)/"")^0 +patterns.somecontent = (anything - newline - space)^1 -- (utf8char - newline - space)^1 +patterns.beginline = #(1-newline) + local unquoted = Cs(patterns.unquoted * endofstring) -- not C function string.unquoted(str) @@ -13754,7 +13754,7 @@ runners.registered = { makempy = { 'makempy.pl', true }, mptopdf = { 'mptopdf.pl', true }, pstopdf = { 'pstopdf.rb', true }, -- converts ps (and some more) images, does some cleaning (replaced) --- examplex = { 'examplex.rb', false }, + -- examplex = { 'examplex.rb', false }, concheck = { 'concheck.rb', false }, runtools = { 'runtools.rb', true }, textools = { 'textools.rb', true }, @@ -13763,9 +13763,9 @@ runners.registered = { rlxtools = { 'rlxtools.rb', true }, pdftools = { 'pdftools.rb', true }, mpstools = { 'mpstools.rb', true }, --- exatools = { 'exatools.rb', true }, + -- exatools = { 'exatools.rb', true }, xmltools = { 'xmltools.rb', true }, --- luatools = { 'luatools.lua', true }, + -- luatools = { 'luatools.lua', true }, mtxtools = { 'mtxtools.rb', true }, pdftrimwhite = { 'pdftrimwhite.pl', false } } diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index d264c05ab..75a527188 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -207,9 +207,6 @@ local squote = P("'") local dquote = P('"') local space = P(" ") -patterns.somecontent = (anything - newline - space)^1 -patterns.beginline = #(1-newline) - local utfbom_32_be = P('\000\000\254\255') local utfbom_32_le = P('\255\254\000\000') local utfbom_16_be = P('\255\254') @@ -282,6 +279,9 @@ patterns.undouble = (dquote/"") * patterns.nodquote * (dquote/"") patterns.unquoted = patterns.undouble + patterns.unsingle -- more often undouble patterns.unspacer = ((patterns.spacer^1)/"")^0 +patterns.somecontent = (anything - newline - space)^1 -- (utf8char - newline - space)^1 +patterns.beginline = #(1-newline) + local unquoted = Cs(patterns.unquoted * endofstring) -- not C function string.unquoted(str) @@ -13754,7 +13754,7 @@ runners.registered = { makempy = { 'makempy.pl', true }, mptopdf = { 'mptopdf.pl', true }, pstopdf = { 'pstopdf.rb', true }, -- converts ps (and some more) images, does some cleaning (replaced) --- examplex = { 'examplex.rb', false }, + -- examplex = { 'examplex.rb', false }, concheck = { 'concheck.rb', false }, runtools = { 'runtools.rb', true }, textools = { 'textools.rb', true }, @@ -13763,9 +13763,9 @@ runners.registered = { rlxtools = { 'rlxtools.rb', true }, pdftools = { 'pdftools.rb', true }, mpstools = { 'mpstools.rb', true }, --- exatools = { 'exatools.rb', true }, + -- exatools = { 'exatools.rb', true }, xmltools = { 'xmltools.rb', true }, --- luatools = { 'luatools.lua', true }, + -- luatools = { 'luatools.lua', true }, mtxtools = { 'mtxtools.rb', true }, pdftrimwhite = { 'pdftrimwhite.pl', false } } diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index d264c05ab..75a527188 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -207,9 +207,6 @@ local squote = P("'") local dquote = P('"') local space = P(" ") -patterns.somecontent = (anything - newline - space)^1 -patterns.beginline = #(1-newline) - local utfbom_32_be = P('\000\000\254\255') local utfbom_32_le = P('\255\254\000\000') local utfbom_16_be = P('\255\254') @@ -282,6 +279,9 @@ patterns.undouble = (dquote/"") * patterns.nodquote * (dquote/"") patterns.unquoted = patterns.undouble + patterns.unsingle -- more often undouble patterns.unspacer = ((patterns.spacer^1)/"")^0 +patterns.somecontent = (anything - newline - space)^1 -- (utf8char - newline - space)^1 +patterns.beginline = #(1-newline) + local unquoted = Cs(patterns.unquoted * endofstring) -- not C function string.unquoted(str) @@ -13754,7 +13754,7 @@ runners.registered = { makempy = { 'makempy.pl', true }, mptopdf = { 'mptopdf.pl', true }, pstopdf = { 'pstopdf.rb', true }, -- converts ps (and some more) images, does some cleaning (replaced) --- examplex = { 'examplex.rb', false }, + -- examplex = { 'examplex.rb', false }, concheck = { 'concheck.rb', false }, runtools = { 'runtools.rb', true }, textools = { 'textools.rb', true }, @@ -13763,9 +13763,9 @@ runners.registered = { rlxtools = { 'rlxtools.rb', true }, pdftools = { 'pdftools.rb', true }, mpstools = { 'mpstools.rb', true }, --- exatools = { 'exatools.rb', true }, + -- exatools = { 'exatools.rb', true }, xmltools = { 'xmltools.rb', true }, --- luatools = { 'luatools.lua', true }, + -- luatools = { 'luatools.lua', true }, mtxtools = { 'mtxtools.rb', true }, pdftrimwhite = { 'pdftrimwhite.pl', false } } diff --git a/tex/context/base/buff-ver.lua b/tex/context/base/buff-ver.lua index 958021374..070224751 100644 --- a/tex/context/base/buff-ver.lua +++ b/tex/context/base/buff-ver.lua @@ -10,7 +10,7 @@ if not modules then modules = { } end modules ['buff-ver'] = { -- supposed to use different names for their own variants. local type, next, rawset, rawget, setmetatable, getmetatable = type, next, rawset, rawget, setmetatable, getmetatable -local format, lower, match, find, sub = string.format, string.lower, string.match, string.find, string.sub +local format, lower, upper,match, find, sub = string.format, string.lower, string.upper, string.match, string.find, string.sub local splitlines = string.splitlines local concat = table.concat local C, P, R, V, Carg, Cc, Cs = lpeg.C, lpeg.P, lpeg.R, lpeg.V, lpeg.Carg, lpeg.Cc, lpeg.Cs @@ -20,6 +20,10 @@ local tabtospace = utilities.strings.tabtospace local variables = interfaces.variables local settings_to_array = utilities.parsers.settings_to_array +local trace_visualize = false trackers.register("buffers.visualize", function(v) trace_visualize = v end) + +local report_buffers = logs.new("buffers") + visualizers = visualizers or { } local specifications = { } visualizers.specifications = specifications @@ -150,10 +154,14 @@ function visualizers.newhandler(name,data) end function visualizers.newgrammar(name,t) + name = lower(name) t = t or { } local g = visualizers.specifications[name] g = g and g.grammar if g then + if trace_visualize then + report_buffers("cloning grammar '%s'",name) + end for k,v in next, g do if not t[k] then t[k] = v @@ -167,10 +175,17 @@ function visualizers.newgrammar(name,t) end local function getvisualizer(method,nature) + method = lower(method) local m = specifications[method] or specifications.default if nature then + if trace_visualize then + report_buffers("getting visualizer '%s' with nature '%s'",method,nature) + end return m and (m[nature] or m.parser) or nil else + if trace_visualize then + report_buffers("getting visualizer '%s'",method) + end return m and m.parser or nil end end @@ -206,6 +221,7 @@ visualizers.makepattern = makepattern visualizers.makenested = makenested function visualizers.load(name) + name = lower(name) if rawget(specifications,name) == nil then name = lower(name) local texname = findfile(format("v-%s.mkiv",name)) @@ -216,8 +232,13 @@ function visualizers.load(name) texname = findfile(addsuffix(name,"lua" )) end if texname == "" or luaname == "" then - -- error message + if trace_visualize then + report_buffers("unknown visualizer '%s'",name) + end else + if trace_visualize then + report_buffers("loading visualizer '%s'",name) + end lua.registercode(luaname) context.input(texname) end @@ -232,6 +253,10 @@ function commands.doifelsevisualizer(name) end function visualizers.register(name,specification) + name = lower(name) + if trace_visualize then + report_buffers("registering visualizer '%s'",name) + end specifications[name] = specification local parser, handler = specification.parser, specification.handler local displayparser = specification.display or parser @@ -301,7 +326,7 @@ local function texcommand(s) end local function defaultmethod(s,settings) - lpegmatch(getvisualizer("default"),s,1,settings) + lpegmatch(getvisualizer("default"),lower(s),1,settings) end -- we can consider using a nested instead @@ -316,6 +341,9 @@ end function visualizers.registerescapepattern(name,before,after,normalmethod,escapemethod) local escapepattern = escapepatterns[name] if not escapepattern then + if trace_visualize then + report_buffers("registering escape pattern, name: '%s', before: '%s', after: '%s'",name,before,after) + end before, after = P(before) * space_pattern, space_pattern * P(after) escapepattern = ( (before / "") @@ -331,6 +359,9 @@ end function visualizers.registerescapecommand(name,token,normalmethod,escapecommand) local escapepattern = escapepatterns[name] if not escapepattern then + if trace_visualize then + report_buffers("registering escape token, name: '%s', token: '%s'",name,token) + end token = P(token) local notoken = hack((1 - token)^1) local cstoken = name_pattern * space_pattern @@ -348,7 +379,7 @@ local escapedvisualizers = { } local function visualize(content,settings) -- maybe also method in settings if content and content ~= "" then - local method = settings.method or "default" + local method = lower(settings.method or "default") local m local e = settings.escape if e and e ~= "" then @@ -382,8 +413,14 @@ local function visualize(content,settings) -- maybe also method in settings local nature = settings.nature or "display" local n = m and m[nature] if n then + if trace_visualize then + report_buffers("visualize using method '%s' and nature '%s'",method,nature) + end n(content,settings) else + if trace_visualize then + report_buffers("visualize using method '%s'",method) + end fallback(content,1,settings) end end @@ -417,11 +454,11 @@ end -- -- -local space = C(patterns.space) * CargOne / f_space -local newline = C(patterns.newline) * CargOne / f_newline -local emptyline = C(patterns.emptyline) * CargOne / f_emptyline -local beginline = C(patterns.beginline) * CargOne / f_beginline -local anything = C(patterns.somecontent^1) * CargOne / f_default +local space = C(patterns.space) * CargOne / f_space +local newline = C(patterns.newline) * CargOne / f_newline +local emptyline = C(patterns.emptyline) * CargOne / f_emptyline +local beginline = C(patterns.beginline) * CargOne / f_beginline +local anything = C(patterns.somecontent) * CargOne / f_default local verbosed = (space + newline * (emptyline^0) * beginline + anything)^0 diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 99bca8f23..032c56370 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2011.01.13 10:20} +\newcontextversion{2011.01.14 14:32} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 986e5122c..e50ba37f1 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.01.13 10:20} +\edef\contextversion{2011.01.14 14:32} %D For those who want to use this: diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv index 93e020d93..9be2feb10 100644 --- a/tex/context/base/font-ini.mkiv +++ b/tex/context/base/font-ini.mkiv @@ -2095,11 +2095,16 @@ % \newconditional\fontsareloaded +% \def\preloaddefaultfonts +% {\resetpreloadfonts +% \usetypescript[modern]% +% \setuptypeface[modern]% +% %\setupbodyfont[modern]% +% \showmessage\m!fonts6{\normalizedbodyfontsize\normalspace\fontstyle}} + \def\preloaddefaultfonts {\resetpreloadfonts - \usetypescript[modern]% - \setuptypeface[modern]% - %\setupbodyfont[modern]% + \setupbodyfont[modern,\fontstyle,\fontbody]% \showmessage\m!fonts6{\normalizedbodyfontsize\normalspace\fontstyle}} \def\resetpreloadfonts diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua index 6b611c2c8..9193bac9a 100644 --- a/tex/context/base/l-lpeg.lua +++ b/tex/context/base/l-lpeg.lua @@ -40,9 +40,6 @@ local squote = P("'") local dquote = P('"') local space = P(" ") -patterns.somecontent = (anything - newline - space)^1 -patterns.beginline = #(1-newline) - local utfbom_32_be = P('\000\000\254\255') local utfbom_32_le = P('\255\254\000\000') local utfbom_16_be = P('\255\254') @@ -115,6 +112,9 @@ patterns.undouble = (dquote/"") * patterns.nodquote * (dquote/"") patterns.unquoted = patterns.undouble + patterns.unsingle -- more often undouble patterns.unspacer = ((patterns.spacer^1)/"")^0 +patterns.somecontent = (anything - newline - space)^1 -- (utf8char - newline - space)^1 +patterns.beginline = #(1-newline) + local unquoted = Cs(patterns.unquoted * endofstring) -- not C function string.unquoted(str) diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index c150ffdf2..d530f5937 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -441,6 +441,11 @@ \stopextendcatcodetable \to \everydonknuthmode +% \def\prefermathcatcodes +% {\catcode\underscoreasciicode\subscriptcatcode +% \catcode\caretasciicode \superscriptcatcode +% \catcode\ampersandasciicode \alignmentcatcode} + %D Even more drastic: \unexpanded\def\asciimode diff --git a/tex/context/base/meta-pdf.lua b/tex/context/base/meta-pdf.lua index ad4bcca81..929c2047e 100644 --- a/tex/context/base/meta-pdf.lua +++ b/tex/context/base/meta-pdf.lua @@ -24,7 +24,7 @@ local pdfgraycode = lpdf.graycode local pdfspotcode = lpdf.spotcode local pdftransparencycode = lpdf.transparencycode local pdffinishtransparencycode = lpdf.finishtransparencycode -local pdfliteral = node.pdfliteral +local pdfliteral = nodes.pool.pdfliteral metapost.mptopdf = metapost.mptopdf or { } local mptopdf = metapost.mptopdf @@ -50,12 +50,14 @@ end resetall() --- todo: collect and flush packed using pdfliteral node injection but we're --- in no hurry as this kind of conversion does not happen that often in mkiv +-- -- this does not work as expected (displacement of text) +-- -- beware, needs another comment hack +-- +-- local function pdfcode(str) +-- context(pdfliteral(str)) +-- end -local function pdfcode(str) -- could be a node.write instead - context(pdfliteral(str)) -end +local pdfcode = context.pdfliteral local function mpscode(str) if ignore_path then @@ -510,7 +512,6 @@ local verbose = ( -- order matters in terms of speed / we could check for procset first local captures_old = ( space + verbose + preamble )^0 ---~ local captures_new = ( space + procset + preamble + verbose )^0 local captures_new = ( space + verbose + procset + preamble )^0 local function parse(m_data) @@ -532,11 +533,13 @@ function mptopdf.convertmpstopdf(name) mps.colormodel = tex.attribute[a_colorspace] statistics.starttiming(mptopdf) mptopdf.nofconverted = mptopdf.nofconverted + 1 + -- pdfcode(format("%% mptopdf begin: n=%s, file=%s",mptopdf.nofconverted,file.basename(name))) pdfcode(format("\\letterpercent\\space mptopdf begin: n=%s, file=%s",mptopdf.nofconverted,file.basename(name))) pdfcode("q 1 0 0 1 0 0 cm") parse(m_data) pdfcode(pdffinishtransparencycode()) pdfcode("Q") + -- pdfcode("% mptopdf end") pdfcode("\\letterpercent\\space mptopdf end") resetall() statistics.stoptiming(mptopdf) @@ -545,7 +548,6 @@ function mptopdf.convertmpstopdf(name) end end - -- status info statistics.register("mps conversion time",function() diff --git a/tex/context/base/v-default.lua b/tex/context/base/v-default.lua index 5da94bf3c..2f5c44245 100644 --- a/tex/context/base/v-default.lua +++ b/tex/context/base/v-default.lua @@ -20,8 +20,8 @@ local grammar = { "visualizer", beginline = makepattern(handler,"beginline",patterns.beginline), newline = makepattern(handler,"newline", patterns.newline), space = makepattern(handler,"space", patterns.space), - default = makepattern(handler,"default", patterns.anything), - content = makepattern(handler,"default", patterns.somecontent), + default = makepattern(handler,"default", patterns.utf8char), + content = makepattern(handler,"default", patterns.somecontent), -- not too efficient -- handy diff --git a/tex/context/base/v-lua.lua b/tex/context/base/v-lua.lua index 97d1b27df..a7ca42cf8 100644 --- a/tex/context/base/v-lua.lua +++ b/tex/context/base/v-lua.lua @@ -134,13 +134,6 @@ local handler = visualizers.newhandler { name_c = visualizename_c, } -local space = patterns.space -local anything = patterns.anything -local newline = patterns.newline -local emptyline = patterns.emptyline -local beginline = patterns.beginline -local somecontent = patterns.somecontent - local comment = P("--") local name = (patterns.letter + patterns.underscore) * (patterns.letter + patterns.underscore + patterns.digit)^0 @@ -156,14 +149,6 @@ local close = P("]") * C(equals) * P("]") local closeeq = Cmt(close * Cb("init"), function(s,i,a,b) return a == b end) local longstring = open * Cs((P(1) - closeeq)^0) * close * Carg(1) ---~ local simple = P ( -- here we hook into the handler but it is default so we could use that ---~ makepattern(handler,"space",space) ---~ + makepattern(handler,"newline",newline) ---~ * makepattern(handler,"emptyline",emptyline) ---~ * makepattern(handler,"beginline",beginline) ---~ + makepattern(handler,"default",anything) ---~ )^0 - local function long(content,equals,settings) handler.boundary(format("[%s[",equals or "")) visualizers.write(content,settings) -- unhandled @@ -171,25 +156,6 @@ local function long(content,equals,settings) end local grammar = visualizers.newgrammar("default", { "visualizer", ---~ emptyline = ---~ makepattern(handler,"emptyline",emptyline), ---~ beginline = ---~ makepattern(handler,"beginline",beginline), ---~ newline = ---~ makepattern(handler,"newline",newline), ---~ space = ---~ makepattern(handler,"space",space), ---~ default = ---~ makepattern(handler,"default",anything), ---~ line = ---~ V("newline") * V("emptyline")^0 * V("beginline"), ---~ whitespace = ---~ (V("space") + V("line"))^1, ---~ optionalwhitespace = ---~ (V("space") + V("line"))^0, ---~ content = ---~ makepattern(handler,"default",somecontent), - sstring = makepattern(handler,"quote",patterns.dquote) * (V("whitespace") + makepattern(handler,"string",1-patterns.dquote))^0 -- patterns.nodquote diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 65f20d760..71ebb60fb 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 : 01/13/11 10:20:58 +-- merge date : 01/14/11 14:32:03 do -- begin closure to overcome local limits and interference @@ -173,9 +173,6 @@ local squote = P("'") local dquote = P('"') local space = P(" ") -patterns.somecontent = (anything - newline - space)^1 -patterns.beginline = #(1-newline) - local utfbom_32_be = P('\000\000\254\255') local utfbom_32_le = P('\255\254\000\000') local utfbom_16_be = P('\255\254') @@ -248,6 +245,9 @@ patterns.undouble = (dquote/"") * patterns.nodquote * (dquote/"") patterns.unquoted = patterns.undouble + patterns.unsingle -- more often undouble patterns.unspacer = ((patterns.spacer^1)/"")^0 +patterns.somecontent = (anything - newline - space)^1 -- (utf8char - newline - space)^1 +patterns.beginline = #(1-newline) + local unquoted = Cs(patterns.unquoted * endofstring) -- not C function string.unquoted(str) |