summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2010-10-20 00:20:12 +0300
committerMarius <mariausol@gmail.com>2010-10-20 00:20:12 +0300
commitf93975efd76053e907d19114d4ba576ae44da134 (patch)
treebde9a37d4fd9dd8eae1ce89d3adb154cfe5d3d5d /tex
parent8009e0ec2449002df344f784da9fe6846abc774f (diff)
downloadcontext-f93975efd76053e907d19114d4ba576ae44da134.tar.gz
beta 2010.10.19 23:03
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/anch-pos.lua57
-rw-r--r--tex/context/base/back-pdf.lua2
-rw-r--r--tex/context/base/bibl-bib.lua17
-rw-r--r--tex/context/base/bibl-tra.lua1
-rw-r--r--tex/context/base/bibl-tra.mkiv2
-rw-r--r--tex/context/base/buff-ini.lua188
-rw-r--r--tex/context/base/char-ini.lua2
-rw-r--r--tex/context/base/char-utf.lua8
-rw-r--r--tex/context/base/chem-ini.lua8
-rw-r--r--tex/context/base/chem-str.lua6
-rw-r--r--tex/context/base/cldf-ini.mkiv19
-rw-r--r--tex/context/base/cldf-ver.lua22
-rw-r--r--tex/context/base/colo-ini.lua2
-rw-r--r--tex/context/base/colo-ini.mkiv6
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv6
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/core-con.lua67
-rw-r--r--tex/context/base/core-job.lua16
-rw-r--r--tex/context/base/core-mis.mkiv2
-rw-r--r--tex/context/base/core-uti.lua3
-rw-r--r--tex/context/base/font-col.lua18
-rw-r--r--tex/context/base/font-col.mkiv7
-rw-r--r--tex/context/base/font-ctx.lua43
-rw-r--r--tex/context/base/font-fbk.lua9
-rw-r--r--tex/context/base/font-ini.lua6
-rw-r--r--tex/context/base/font-ini.mkiv51
-rw-r--r--tex/context/base/font-map.lua2
-rw-r--r--tex/context/base/font-ota.lua8
-rw-r--r--tex/context/base/font-tra.mkiv8
-rw-r--r--tex/context/base/font-uni.mkiv3
-rw-r--r--tex/context/base/grph-inc.lua42
-rw-r--r--tex/context/base/grph-inc.mkiv8
-rw-r--r--tex/context/base/grph-swf.lua9
-rw-r--r--tex/context/base/l-table.lua61
-rw-r--r--tex/context/base/lang-ini.lua2
-rw-r--r--tex/context/base/lang-url.lua10
-rw-r--r--tex/context/base/lpdf-fld.lua6
-rw-r--r--tex/context/base/lpdf-ini.lua8
-rw-r--r--tex/context/base/lpdf-mis.lua3
-rw-r--r--tex/context/base/lpdf-ren.lua1
-rw-r--r--tex/context/base/lpdf-swf.lua1
-rw-r--r--tex/context/base/lpdf-wid.lua6
-rw-r--r--tex/context/base/m-timing.tex4
-rw-r--r--tex/context/base/math-ali.mkiv4
-rw-r--r--tex/context/base/meta-pdf.lua14
-rw-r--r--tex/context/base/meta-pdh.mkiv4
-rw-r--r--tex/context/base/mlib-pdf.lua24
-rw-r--r--tex/context/base/mlib-pdf.mkiv3
-rw-r--r--tex/context/base/mlib-pps.lua23
-rw-r--r--tex/context/base/mlib-pps.mkiv9
-rw-r--r--tex/context/base/mult-cld.lua335
-rw-r--r--tex/context/base/mult-cld.mkiv2
-rw-r--r--tex/context/base/node-fin.lua4
-rw-r--r--tex/context/base/node-ser.lua28
-rw-r--r--tex/context/base/node-tra.lua30
-rw-r--r--tex/context/base/pack-lyr.mkiv4
-rw-r--r--tex/context/base/pack-rul.mkiv2
-rw-r--r--tex/context/base/page-flt.lua7
-rw-r--r--tex/context/base/page-lin.lua10
-rw-r--r--tex/context/base/page-mar.mkiv6
-rw-r--r--tex/context/base/page-txt.mkiv18
-rw-r--r--tex/context/base/pret-lua.lua37
-rw-r--r--tex/context/base/pret-mp.lua16
-rw-r--r--tex/context/base/pret-tex.lua15
-rw-r--r--tex/context/base/pret-xml.lua15
-rw-r--r--tex/context/base/prop-ini.mkiv2
-rw-r--r--tex/context/base/regi-ini.lua5
-rw-r--r--tex/context/base/s-fnt-10.tex45
-rw-r--r--tex/context/base/s-fnt-11.tex36
-rw-r--r--tex/context/base/s-fnt-24.tex2
-rw-r--r--tex/context/base/s-fnt-25.tex55
-rw-r--r--tex/context/base/s-fnt-30.tex25
-rw-r--r--tex/context/base/s-inf-01.tex32
-rw-r--r--tex/context/base/s-reg-01.tex23
-rw-r--r--tex/context/base/s-sys-01.tex61
-rw-r--r--tex/context/base/scrn-int.lua7
-rw-r--r--tex/context/base/scrn-men.mkiv2
-rw-r--r--tex/context/base/spac-hor.lua1
-rw-r--r--tex/context/base/spac-ver.lua43
-rw-r--r--tex/context/base/strc-bkm.lua3
-rw-r--r--tex/context/base/strc-blk.lua19
-rw-r--r--tex/context/base/strc-doc.lua20
-rw-r--r--tex/context/base/strc-doc.mkiv1
-rw-r--r--tex/context/base/strc-ini.lua26
-rw-r--r--tex/context/base/strc-lst.lua4
-rw-r--r--tex/context/base/strc-not.lua41
-rw-r--r--tex/context/base/strc-num.mkiv2
-rw-r--r--tex/context/base/strc-pag.lua4
-rw-r--r--tex/context/base/strc-ref.lua65
-rw-r--r--tex/context/base/strc-ref.mkiv2
-rw-r--r--tex/context/base/strc-reg.lua122
-rw-r--r--tex/context/base/strc-reg.mkiv64
-rw-r--r--tex/context/base/strc-ren.mkiv26
-rw-r--r--tex/context/base/strc-sec.mkiv26
-rw-r--r--tex/context/base/strc-syn.lua26
-rw-r--r--tex/context/base/strc-tag.lua2
-rw-r--r--tex/context/base/supp-box.mkiv6
-rw-r--r--tex/context/base/supp-fil.lua45
-rw-r--r--tex/context/base/supp-fil.mkiv4
-rw-r--r--tex/context/base/syst-lua.lua6
-rw-r--r--tex/context/base/tabl-ntb.mkiv2
-rw-r--r--tex/context/base/tabl-tbl.mkiv4
-rw-r--r--tex/context/base/toks-ini.lua3
-rw-r--r--tex/context/base/trac-log.lua17
-rw-r--r--tex/context/base/util-pck.lua42
-rw-r--r--tex/context/base/util-prs.lua2
-rw-r--r--tex/context/base/util-tab.lua1
-rw-r--r--tex/context/base/x-ldx.tex12
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua79
111 files changed, 1180 insertions, 1201 deletions
diff --git a/tex/context/base/anch-pos.lua b/tex/context/base/anch-pos.lua
index 28d32089d..d47109891 100644
--- a/tex/context/base/anch-pos.lua
+++ b/tex/context/base/anch-pos.lua
@@ -13,7 +13,6 @@ more efficient.</p>
--ldx]]--
local concat, format = table.concat, string.format
-local texprint, ctxcatcodes = tex.print, tex.ctxcatcodes
local lpegmatch = lpeg.match
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
@@ -55,20 +54,20 @@ function jobpositions.doifelse(name)
commands.testcase(collected[name] or tobesaved[name])
end
-function jobpositions.MPp(id) local jpi = collected[id] or tobesaved[id] texprint(ctxcatcodes,(jpi and jpi[1]) or '0' ) end
-function jobpositions.MPx(id) local jpi = collected[id] or tobesaved[id] texprint(ctxcatcodes,(jpi and jpi[2]) or '0pt') end
-function jobpositions.MPy(id) local jpi = collected[id] or tobesaved[id] texprint(ctxcatcodes,(jpi and jpi[3]) or '0pt') end
-function jobpositions.MPw(id) local jpi = collected[id] or tobesaved[id] texprint(ctxcatcodes,(jpi and jpi[4]) or '0pt') end
-function jobpositions.MPh(id) local jpi = collected[id] or tobesaved[id] texprint(ctxcatcodes,(jpi and jpi[5]) or '0pt') end
-function jobpositions.MPd(id) local jpi = collected[id] or tobesaved[id] texprint(ctxcatcodes,(jpi and jpi[6]) or '0pt') end
+function jobpositions.MPp(id) local jpi = collected[id] or tobesaved[id] context(jpi and jpi[1] or '0' ) end
+function jobpositions.MPx(id) local jpi = collected[id] or tobesaved[id] context(jpi and jpi[2] or '0pt') end
+function jobpositions.MPy(id) local jpi = collected[id] or tobesaved[id] context(jpi and jpi[3] or '0pt') end
+function jobpositions.MPw(id) local jpi = collected[id] or tobesaved[id] context(jpi and jpi[4] or '0pt') end
+function jobpositions.MPh(id) local jpi = collected[id] or tobesaved[id] context(jpi and jpi[5] or '0pt') end
+function jobpositions.MPd(id) local jpi = collected[id] or tobesaved[id] context(jpi and jpi[6] or '0pt') end
function jobpositions.MPx(id)
local jpi = collected[id] or tobesaved[id]
local x = jpi and jpi[2]
if x then
- texprint(ctxcatcodes,format('\\the\\dimexpr%s-%s\\relax',x,dx)) -- no space after dimexpr !
+ context('\\the\\dimexpr%s-%s\\relax',x,dx)
else
- texprint(ctxcatcodes,'0pt')
+ context('0pt')
end
end
@@ -76,9 +75,9 @@ function jobpositions.MPy(id)
local jpi = collected[id] or tobesaved[id]
local y = jpi and jpi[3]
if y then
- texprint(ctxcatcodes,format('\\the\\dimexpr%s-%s\\relax',y,dy)) -- no space after dimexpr !
+ context('\\the\\dimexpr%s-%s\\relax',y,dy)
else
- texprint(ctxcatcodes,'0pt')
+ context('0pt')
end
end
@@ -89,59 +88,54 @@ end
function jobpositions.MPxy(id)
local jpi = collected[id] or tobesaved[id]
if jpi then
- texprint(ctxcatcodes,format('(%s-%s,%s-%s)',jpi[2],dx,jpi[3],dy))
---~ texprint(ctxcatcodes,'(',jpi[2],'-',dx,',',jpi[3],'-',dy,')')
+ context('(%s-%s,%s-%s)',jpi[2],dx,jpi[3],dy)
else
- texprint(ctxcatcodes,'(0,0)')
+ context('(0,0)')
end
end
function jobpositions.MPll(id)
local jpi = collected[id] or tobesaved[id]
if jpi then
- texprint(ctxcatcodes,format('(%s-%s,%s-%s-%s)',jpi[2],dx,jpi[3],jpi[6],dy))
---~ texprint(ctxcatcodes,'(',jpi[2],'-',dx,',',jpi[3],'-',jpi[6],'-',dy,')')
+ context('(%s-%s,%s-%s-%s)',jpi[2],dx,jpi[3],jpi[6],dy)
else
- texprint(ctxcatcodes,'(0,0)')
+ context('(0,0)')
end
end
function jobpositions.MPlr(id)
local jpi = collected[id] or tobesaved[id]
if jpi then
- texprint(ctxcatcodes,format('(%s+%s-%s,%s-%s-%s)',jpi[2],jpi[4],dx,jpi[3],jpi[6],dy))
---~ texprint(ctxcatcodes,'(',jpi[2],'+',jpi[4],'-',dx,',',jpi[3],'-',jpi[6],'-',dy,')')
+ context('(%s+%s-%s,%s-%s-%s)',jpi[2],jpi[4],dx,jpi[3],jpi[6],dy)
else
- texprint(ctxcatcodes,'(0,0)')
+ context('(0,0)')
end
end
function jobpositions.MPur(id)
local jpi = collected[id] or tobesaved[id]
if jpi then
- texprint(ctxcatcodes,format('(%s+%s-%s,%s+%s-%s)',jpi[2],jpi[4],dx,jpi[3],jpi[5],dy))
---~ texprint(ctxcatcodes,'(',jpi[2],'+',jpi[4],'-',dx,',',jpi[3],'+',jpi[5],'-',dy,')')
+ context('(%s+%s-%s,%s+%s-%s)',jpi[2],jpi[4],dx,jpi[3],jpi[5],dy)
else
- texprint(ctxcatcodes,'(0,0)')
+ context('(0,0)')
end
end
function jobpositions.MPul(id)
local jpi = collected[id] or tobesaved[id]
if jpi then
- texprint(ctxcatcodes,format('(%s-%s,%s+%s-%s)',jpi[2],dx,jpi[3],jpi[5],dy))
---~ texprint(ctxcatcodes,'(',jpi[2],'-',dx,',',jpi[3],'+',jpi[5],'-',dy,')')
+ context('(%s-%s,%s+%s-%s)',jpi[2],dx,jpi[3],jpi[5],dy)
else
- texprint(ctxcatcodes,'(0,0)')
+ context('(0,0)')
end
end
function jobpositions.MPpos(id)
local jpi = collected[id] or tobesaved[id]
if jpi then
- texprint(ctxcatcodes,concat(jpi,',',1,6))
+ context(concat(jpi,',',1,6))
else
- texprint(ctxcatcodes,'0,0,0,0,0,0')
+ context('0,0,0,0,0,0')
end
end
@@ -150,19 +144,18 @@ local splitter = lpeg.Ct(lpeg.splitat(","))
function jobpositions.MPplus(id,n,default)
local jpi = collected[id] or tobesaved[id]
if not jpi then
- texprint(ctxcatcodes,default)
+ context(default)
else
local split = jpi[0]
if not split then
split = lpegmatch(splitter,jpi[7])
jpi[0] = split
end
- texprint(ctxcatcodes,split[n] or default)
+ context(split[n] or default)
end
end
function jobpositions.MPrest(id,default)
local jpi = collected[id] or tobesaved[id]
- -- texprint(ctxcatcodes,(jpi and jpi[7] and concat(jpi,",",7,#jpi)) or default)
- texprint(ctxcatcodes,(jpi and jpi[7]) or default)
+ context(jpi and jpi[7] or default)
end
diff --git a/tex/context/base/back-pdf.lua b/tex/context/base/back-pdf.lua
index 4341b465a..425e1ad15 100644
--- a/tex/context/base/back-pdf.lua
+++ b/tex/context/base/back-pdf.lua
@@ -20,8 +20,6 @@ local char, byte, format, gsub, rep, gmatch = string.char, string.byte, string.f
local concat = table.concat
local round = math.round
local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
-local texsprint, texwrite = tex.sprint, tex.write
-local ctxcatcodes = tex.ctxcatcodes
local backends, lpdf, nodes, node = backends, lpdf, nodes, node
diff --git a/tex/context/base/bibl-bib.lua b/tex/context/base/bibl-bib.lua
index db9fef14d..5e759eff2 100644
--- a/tex/context/base/bibl-bib.lua
+++ b/tex/context/base/bibl-bib.lua
@@ -638,9 +638,6 @@ end
if commands then
- local texsprint = tex and tex.sprint
- local ctxcatcodes = tex and tex.ctxcatcodes
-
local sessions = { }
function commands.definebibtexsession(name)
@@ -674,7 +671,7 @@ if commands then
if collected then
local author = collected[1].dt[1] or ""
if author ~= "" then
- texsprint(ctxcatcodes,authors.concat(author,method,what,settings))
+ context(authors.concat(author,method,what,settings))
end
end
end
@@ -684,7 +681,7 @@ if commands then
local c = collected[1]
local year = xmlfilter(c,"xml://field[@name='year']/text()")
local author = xmlfilter(c,"xml://field[@name='author']/text()")
- texsprint(ctxcatcodes,authors.short(author,year))
+ context(authors.short(author,year))
end
end
@@ -718,29 +715,29 @@ if commands then
function bibtex.authorref(id,list)
local result = collectauthoryears(id,list,method,what)
for author, years in next, result do
- texsprint(ctxcatcodes,authors.concat(author,method,what,settings))
+ context(authors.concat(author,method,what,settings))
end
end
function bibtex.authoryearref(id,list)
local result = collectauthoryears(id,list,method,what)
for author, years in next, result do
- texsprint(ctxcatcodes,authors.concat(author,method,what,settings)," (",concat(years,", "),")")
+ context("%s (%s)",authors.concat(author,method,what,settings),concat(years,", "))
end
end
function bibtex.authoryearsref(id,list)
local result = collectauthoryears(id,list,method,what)
for author, years in next, result do
- texsprint(ctxcatcodes,"(",authors.concat(author,method,what,settings),", ",concat(years,", "),")")
+ context("(%s, %s)",authors.concat(author,method,what,settings),concat(years,", "))
end
end
function bibtex.singularorplural(singular,plural)
if lastconcatsize and lastconcatsize > 1 then
- texsprint(ctxcatcodes,plural)
+ context(plural)
else
- texsprint(ctxcatcodes,singular)
+ context(singular)
end
end
diff --git a/tex/context/base/bibl-tra.lua b/tex/context/base/bibl-tra.lua
index 60a673546..f901b1f0a 100644
--- a/tex/context/base/bibl-tra.lua
+++ b/tex/context/base/bibl-tra.lua
@@ -13,7 +13,6 @@ bibtex.hacks = bibtex.hacks or { }
local hacks = bibtex.hacks
local match, gmatch, format, concat, sort = string.match, string.gmatch, string.format, table.concat, table.sort
-local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
local variables, constants = interfaces.variables, interfaces.constants
local trace_bibtex = false trackers.register("publications.bibtex", function(v) trace_bibtex = v end)
diff --git a/tex/context/base/bibl-tra.mkiv b/tex/context/base/bibl-tra.mkiv
index 56886e28b..a0ef32c82 100644
--- a/tex/context/base/bibl-tra.mkiv
+++ b/tex/context/base/bibl-tra.mkiv
@@ -682,7 +682,7 @@
% {\letvalue{#1@num}\!!zerocount
% \doloop
% {\doifdefinedelse{\??pb @#1\recurselevel}
-% {\letvalue{\??pb @#1\recurselevel}\empty} % why not undefined?
+% {\letvalueempty{\??pb @#1\recurselevel}} % why not undefined?
% {\exitloop}}}
% \def\clearbibitemtwo#1%
diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua
index 0564c70cf..cb41b48cf 100644
--- a/tex/context/base/buff-ini.lua
+++ b/tex/context/base/buff-ini.lua
@@ -22,7 +22,7 @@ local report_buffers = logs.new("buffers")
local utf = unicode.utf8
-local concat, texsprint, texprint, texwrite = table.concat, tex.sprint, tex.print, tex.write
+local concat, texprint, texwrite = table.concat, tex.print, tex.write
local utfbyte, utffind, utfgsub = utf.byte, utf.find, utf.gsub
local type, next = type, next
local huge = math.huge
@@ -43,6 +43,7 @@ buffers = {
}
local buffers = buffers
+local context = context
local data = buffers.data
local flags = buffers.flags
@@ -106,26 +107,36 @@ function buffers.doifelsebuffer(name)
commands.testcase(data[name] ~= nil)
end
-flags.optimizeverbatim = true
-flags.countemptylines = false
+-- handy helpers
+--
+-- \sop[color] switch_of_pretty
+-- \bop[color] begin_of_pretty
+-- \eop end_of_pretty
+-- \obs obeyedspace
+-- \char <n> special characters
+
+local sop = context.sop
+local bop = context.bop
+local eop = context.eop
+local obs = context.obs
+local par = context.par
+local chr = context.char
-local no_break_command = "\\doverbatimnobreak"
-local do_break_command = "\\doverbatimgoodbreak"
-local begin_of_line_command = "\\doverbatimbeginofline"
-local end_of_line_command = "\\doverbatimendofline"
-local empty_line_command = "\\doverbatimemptyline"
+local bgroup = context.bgroup
+local egroup = context.egroup
-local begin_of_display_command = "\\doverbatimbeginofdisplay"
-local end_of_display_command = "\\doverbatimendofdisplay"
-local begin_of_inline_command = "\\doverbatimbeginofinline"
-local end_of_inline_command = "\\doverbatimendofinline"
+flags.optimizeverbatim = true
+flags.countemptylines = false
+
+local doverbatimnobreak = context.doverbatimnobreak
+local doverbatimgoodbreak = context.doverbatimgoodbreak
function buffers.verbatimbreak(n,m)
if flags.optimizeverbatim then
if n == 2 or n == m then
- texsprint(no_break_command)
+ doverbatimnobreak()
elseif n > 1 then
- texsprint(do_break_command)
+ doverbatimgoodbreak()
end
end
end
@@ -399,14 +410,11 @@ function buffers.inspect(name)
if type(b) == "table" then
for k=1,#b do
local v = b[k]
- if v == "" then
- texsprint(ctxcatcodes,"[crlf]\\par ") -- space ?
- else
- texsprint(ctxcatcodes,(gsub(v,"(.)",tobyte)),"\\par")
- end
+ context(v == "" and "[crlf]" or gsub(v,"(.)",tobyte))
+ par()
end
else
- texsprint(ctxcatcodes,(gsub(b,"(.)",tobyte)))
+ context((gsub(b,"(.)",tobyte)))
end
end
end
@@ -463,6 +471,14 @@ end
local default = buffers.newvisualizer(visualizers.defaultname)
+default.begin_of_display = context.doverbatimbeginofdisplay
+default.end_of_display = context.doverbatimendofdisplay
+default.begin_of_inline = context.doverbatimbeginofinline
+default.end_of_inline = context.doverbatimendofinline
+default.begin_of_line = context.doverbatimbeginofline
+default.end_of_line = context.doverbatimendofline
+default.empty_line = context.doverbatimemptyline
+
--~ print(variables.typing) os.exit()
-- will become cleaner
@@ -561,34 +577,23 @@ function hooks.line(str)
return (currenthandler.line or default.line)(str)
end
--- defaults
-
-function default.begin_of_display(currentvisualizer)
- texsprint(ctxcatcodes,begin_of_display_command,"{",currentvisualizer,"}")
-end
-
-function default.end_of_display()
- texsprint(ctxcatcodes,end_of_display_command)
-end
+buffers.currentcolors = { } -- todo: registercurrentcolor and preset sop then ... faster or at least precreate tables
-function default.begin_of_inline(currentvisualizer)
- texsprint(ctxcatcodes,begin_of_inline_command,"{",currentvisualizer,"}")
-end
-
-function default.end_of_inline()
- texsprint(ctxcatcodes,end_of_inline_command)
-end
-
-function default.begin_of_line(n)
- texsprint(ctxcatcodes, begin_of_line_command,"{",n,"}")
-end
-
-function default.end_of_line()
- texsprint(ctxcatcodes,end_of_line_command)
-end
-
-function default.empty_line()
- texsprint(ctxcatcodes,empty_line_command)
+function buffers.changestate(n, state)
+ if n then
+ if state ~= n then
+ if state > 0 then
+ sop { buffers.currentcolors[n] }
+ else
+ bop { buffers.currentcolors[n] }
+ end
+ return n
+ end
+ elseif state > 0 then
+ eop()
+ return 0
+ end
+ return state
end
function default.line(str)
@@ -600,7 +605,7 @@ function default.flush_line(str)
if visualizers.obeyspace then
for c in utfcharacters(str) do
if c == " " then
- texsprint(ctxcatcodes,"\\obs")
+ obs()
else
texwrite(c)
end
@@ -614,42 +619,6 @@ end
buffers.commands.nested = "\\switchslantedtype "
---~ function visualizers.flushnested(str, enable) -- todo: no utf, vrb catcodes, kind of obsolete mess
---~ str = gsub(str," *[\n\r]+ *"," ")
---~ local result, c, nested, i = "", "", 0, 1
---~ local commands = buffers.commands -- otherwise wrong commands
---~ while i < #str do -- slow
---~ c = sub(str,i,i+1)
---~ if c == "<<" then
---~ nested = nested + 1
---~ if enable then
---~ result = result .. "{" .. commands.nested
---~ else
---~ result = result .. "{"
---~ end
---~ i = i + 2
---~ elseif c == ">>" then
---~ if nested > 0 then
---~ nested = nested - 1
---~ result = result .. "}"
---~ end
---~ i = i + 2
---~ else
---~ c = sub(str,i,i)
---~ if c == " " then
---~ result = result .. "\\obs "
---~ elseif find(c,"%a") then
---~ result = result .. c
---~ else
---~ result = result .. "\\char" .. byte(c) .. " "
---~ end
---~ i = i + 1
---~ end
---~ end
---~ result = result .. "\\char" .. byte(sub(str,i,i)) .. " " .. rep("}",nested)
---~ texsprint(ctxcatcodes,result)
---~ end
-
function visualizers.flushnested(str, enable) -- todo: no utf, vrb catcodes, kind of obsolete mess
str = gsub(str," *[\n\r]+ *"," ")
local c, nested, i = "", 0, 1
@@ -658,63 +627,38 @@ function visualizers.flushnested(str, enable) -- todo: no utf, vrb catcodes, kin
c = sub(str,i,i+1)
if c == "<<" then
nested = nested + 1
+ bgroup()
if enable then
- texsprint(ctxcatcodes,"{",commands.nested)
- else
- texsprint(ctxcatcodes,"{")
+ context(commands.nested)
end
i = i + 2
elseif c == ">>" then
if nested > 0 then
nested = nested - 1
- texsprint(ctxcatcodes,"}")
+ egroup()
end
i = i + 2
else
c = sub(str,i,i)
if c == " " then
- texsprint(ctxcatcodes,"\\obs")
+ obs()
elseif find(c,"%a") then
- texsprint(ctxcatcodes,c)
+ context(c)
else
- texsprint(ctxcatcodes,"\\char",byte(c)," ")
+ chr(byte(c))
end
i = i + 1
end
end
- texsprint(ctxcatcodes,"\\char",byte(sub(str,i,i))," ",rep("}",nested))
-end
-
--- handy helpers
---
--- \sop[color] switch_of_pretty
--- \bop[color] begin_of_pretty
--- \eop end_of_pretty
--- \obs obeyedspace
--- \char <n> special characters
-
-buffers.currentcolors = { }
-
-function buffers.changestate(n, state)
- if n then
- if state ~= n then
- if state > 0 then
- texsprint(ctxcatcodes,"\\sop[",buffers.currentcolors[n],"]")
- else
- texsprint(ctxcatcodes,"\\bop[",buffers.currentcolors[n],"]")
- end
- return n
- end
- elseif state > 0 then
- texsprint(ctxcatcodes,"\\eop")
- return 0
+ chr(byte(sub(str,i,i)))
+ for i=1,#nested do
+ egroup()
end
- return state
end
function buffers.finishstate(state)
if state > 0 then
- texsprint(ctxcatcodes,"\\eop")
+ eop()
return 0
else
return state
@@ -732,9 +676,9 @@ end
function buffers.flushresult(result,nested)
if nested then
- texsprint(ctxcatcodes,buffers.replacenested(concat(result)))
+ context(buffers.replacenested(concat(result)))
else
- texsprint(ctxcatcodes,concat(result))
+ context(concat(result))
end
end
@@ -786,7 +730,7 @@ local function flush_escaped_line(str,pattern,flushline)
flushline(a)
end
if b and b ~= "" then
- texsprint(ctxcatcodes,"{",b,"}")
+ context(b)
end
if c then
if c == "" then
diff --git a/tex/context/base/char-ini.lua b/tex/context/base/char-ini.lua
index a6b033b08..b3ac6fc22 100644
--- a/tex/context/base/char-ini.lua
+++ b/tex/context/base/char-ini.lua
@@ -500,10 +500,8 @@ else -- keep this
-- by this time, we're still in normal catcode mode
-- subtle: not "\\",contextname but "\\"..contextname
if chr.unicodeslot < 128 then
- -- texprint(ctxcatcodes, "\\chardef\\"..contextname,"=",u)
texprint(ctxcatcodes,format("\\chardef\\%s=%s",contextname,u))
else
- -- texprint(ctxcatcodes, "\\let\\"..contextname,"=",utfchar(u))
texprint(ctxcatcodes,format("\\let\\%s=%s",contextname,utfchar(u)))
if is_letter[category] then
lettered[#lettered+1] = "\\c"..u.."\\l"
diff --git a/tex/context/base/char-utf.lua b/tex/context/base/char-utf.lua
index c3549ec01..d8ffdeed0 100644
--- a/tex/context/base/char-utf.lua
+++ b/tex/context/base/char-utf.lua
@@ -23,8 +23,6 @@ local utf = unicode.utf8
local utfchar, utfbyte, utfgsub = utf.char, utf.byte, utf.gsub
local concat, gmatch, gsub = table.concat, string.gmatch, string.gsub
local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
-local ctxcatcodes = tex.ctxcatcodes
-local texsprint = tex.sprint
local allocate = utilities.storage.allocate
-- todo: trackers
@@ -269,9 +267,9 @@ end
commands = commands or { }
-function commands.uchar(first,second)
- texsprint(ctxcatcodes,utfchar(first*256+second))
-end
+--~ function commands.uchar(first,second)
+--~ context(utfchar(first*256+second))
+--~ end
--[[ldx--
<p>A few helpers (used to be <t>luat-uni<t/>).</p>
diff --git a/tex/context/base/chem-ini.lua b/tex/context/base/chem-ini.lua
index 776647554..4bbfe4c38 100644
--- a/tex/context/base/chem-ini.lua
+++ b/tex/context/base/chem-ini.lua
@@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['chem-ini'] = {
license = "see context related readme files"
}
-local format, texsprint = string.format, tex.sprint
+local format = string.format
local lpegmatch = lpeg.match
local P, R, V, Cc, Cs = lpeg.P, lpeg.R, lpeg.V, lpeg.Cc, lpeg.Cs
@@ -15,7 +15,7 @@ local trace_molecules = false trackers.register("chemistry.molecules", functio
local report_chemistry = logs.new("chemistry")
-local ctxcatcodes = tex.ctxcatcodes
+local context = context
chemicals = chemicals or { }
local chemicals = chemicals
@@ -72,8 +72,8 @@ function commands.molecule(str)
if trace_molecules then
local rep = lpegmatch(parser,str)
report_chemistry("molecule %s => %s",str,rep)
- texsprint(ctxcatcodes,rep)
+ context(rep)
else
- texsprint(ctxcatcodes,lpegmatch(parser,str))
+ context(lpegmatch(parser,str))
end
end
diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua
index 7cd713470..f574a8ac4 100644
--- a/tex/context/base/chem-str.lua
+++ b/tex/context/base/chem-str.lua
@@ -18,13 +18,13 @@ local report_chemistry = logs.new("chemistry")
local format, gmatch, match, lower, gsub = string.format, string.gmatch, string.match, string.lower, string.gsub
local concat, insert, remove = table.concat, table.insert, table.remove
local apply = structures.processors.apply
-local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
local lpegmatch = lpeg.match
local settings_to_array = utilities.parsers.settings_to_array
local P, R, S, C, Cs, Ct, Cc = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg.Ct, lpeg.Cc
local variables = interfaces.variables
+local context = context
chemicals = chemicals or { }
local chemicals = chemicals
@@ -481,9 +481,9 @@ function chemicals.inline(spec)
local s = spec[i]
local inl = inline[lower(s)]
if inl then
- texsprint(ctxcatcodes,inl)
+ context(inl)
else
- texsprint(ctxcatcodes,format("\\chemicalinline{%s}",molecule(s)))
+ context.chemicalinline(molecule(s))
end
end
end
diff --git a/tex/context/base/cldf-ini.mkiv b/tex/context/base/cldf-ini.mkiv
new file mode 100644
index 000000000..b8731fe29
--- /dev/null
+++ b/tex/context/base/cldf-ini.mkiv
@@ -0,0 +1,19 @@
+%D \module
+%D [ file=cldf-ini,
+%D version=2010.10.19,,
+%D title=\CONTEXT\ \LUA\ Document Functions,
+%D subtitle=Initialization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=Hans Hagen]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Lua Documents / Functions}
+
+%registerctxluafile{cldf-ini}{1.001} % maybe mult-cld moves here
+\registerctxluafile{cldf-ver}{1.001}
+
+\endinput
diff --git a/tex/context/base/cldf-ver.lua b/tex/context/base/cldf-ver.lua
new file mode 100644
index 000000000..0d7d55649
--- /dev/null
+++ b/tex/context/base/cldf-ver.lua
@@ -0,0 +1,22 @@
+if not modules then modules = { } end modules ['cldf-ver'] = {
+ version = 1.001,
+ comment = "companion to cldf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local concat = table.concat
+
+local context = context
+
+function table.tocontext(...)
+ local function flush(...)
+ context(concat{...,"\n"})
+ end
+ context.starttyping()
+ context.pushcatcodes("verbatim")
+ table.tohandle(flush,...)
+ context.stoptyping()
+ context.popcatcodes()
+end
diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua
index cba78954d..77b2ea888 100644
--- a/tex/context/base/colo-ini.lua
+++ b/tex/context/base/colo-ini.lua
@@ -9,8 +9,6 @@ if not modules then modules = { } end modules ['colo-ini'] = {
local type, tonumber = type, tonumber
local concat = table.concat
local format, gmatch, gsub, lower, match, find = string.format, string.gmatch, string.gsub, string.lower, string.match, string.find
-local texsprint = tex.sprint
-local ctxcatcodes = tex.ctxcatcodes
local trace_define = false trackers.register("colors.define",function(v) trace_define = v end)
diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv
index 1795f2e3a..a94495a0b 100644
--- a/tex/context/base/colo-ini.mkiv
+++ b/tex/context/base/colo-ini.mkiv
@@ -371,7 +371,7 @@
\def\dodefinepalet[#1][#2]%
{\doifassignmentelse{#2}
{%\showcolormessage\m!colors6{#1}%
- \letvalue{\??pa#1}\empty
+ \letvalueempty{\??pa#1}%
\setevalue{\??pa\??pa#1}{#2}%
\def\dodododefinepalet[##1=##2]%
{\doifvaluesomething{\??pa#1}
@@ -765,8 +765,8 @@
% Since we couple definitions, we could stick to one test. Todo. Same for mpcolor.
-\letvalue{(cs:-}\empty
-\letvalue{(ts:-}\empty
+\letvalueempty{(cs:-}
+\letvalueempty{(ts:-}
\def\doactivatecolor#1% : in currentpalet, maybe not, ugly
{\def\currentcolorname{#1}%
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 3a3f1a94b..5744d86a6 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{2010.10.18 11:11}
+\newcontextversion{2010.10.19 23:03}
%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 a6fff168c..4156f2b59 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -108,7 +108,7 @@
%D We already need some synonyms (patterns). At runtime this
%D file will be reloaded.
-\loadcorefile{cont-fil}
+\loadmarkfile{cont-fil}
%D \CONTEXT\ does not implement its own table handling. We
%D just go for the best there is and load \TABLE. Just to be
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 69441cb33..89226a9a9 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -114,7 +114,7 @@
\loadmarkfile{core-fil}
\loadmarkfile{core-con}
-\loadcorefile{cont-fil}
+\loadmarkfile{cont-fil}
\loadmarkfile{regi-ini}
\loadcorefile{regi-syn}
@@ -332,10 +332,12 @@
\loadmarkfile{page-app}
\loadmarkfile{meta-fig}
-\loadmarkfile{node-bck} % overloads anch-pgr (experimental and undocumented)
+\loadmarkfile{node-bck} % overloads anch-pgr (experimental and undocumented)
\loadmarkfile{lang-spa} % will become obsolete
+\loadmarkfile{cldf-ini} % this can come later
+
\loadmarkfile{bibl-bib}
\loadmarkfile{bibl-tra}
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index 0b70197c7..00a426a14 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{2010.10.18 11:11}
+\edef\contextversion{2010.10.19 23:03}
%D For those who want to use this:
diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua
index 7c1bb01f9..8f90eac16 100644
--- a/tex/context/base/core-con.lua
+++ b/tex/context/base/core-con.lua
@@ -22,30 +22,27 @@ local utfchar, utfbyte = utf.char, utf.byte
local tonumber, tostring = tonumber, tostring
local settings_to_array = utilities.parsers.settings_to_array
-local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
local allocate = utilities.storage.allocate
+local context = context
+
converters = converters or { }
local converters = converters
languages = languages or { }
local languages = languages
-local function flush(...)
- texsprint(ctxcatcodes,...)
-end
-
function converters.convert(method,n,direct)
local method = converters[method]
if method then
return method(n,direct)
else
- return direct and n or flush(n)
+ return direct and n or context(n)
end
end
function converters.numberst(n,direct)
- return direct and n or flush(n)
+ return direct and n or context(n)
end
--~ ['arabic-digits'] = {
@@ -149,7 +146,7 @@ local fallback = utf.byte('0')
local function chr(n,m,direct)
local s = (n > 0 and n < 27 and utfchar(n+m)) or ""
- if direct then return s else flush(s) end
+ if direct then return s else context(s) end
end
--~ local function chrs(n,m,direct)
@@ -157,7 +154,7 @@ end
--~ chrs(floor((n-1)/26),m)
--~ n = (n-1)%26 + 1
--~ end
---~ flush(utfchar(n+m))
+--~ context(utfchar(n+m))
--~ end
local function chrs(n,m,direct,t)
@@ -173,19 +170,11 @@ local function chrs(n,m,direct,t)
if direct then
return concat(t)
else
- flush(concat(t))
+ context(concat(t))
end
end
end
---~ local function maxchrs(n,m,cmd,direct)
---~ if n > m then
---~ maxchrs(floor((n-1)/m),m,cmd)
---~ n = (n-1)%m + 1
---~ end
---~ flush(format("%s{%s}",cmd,n))
---~ end
-
local function maxchrs(n,m,cmd,direct,t) -- direct is not ok
if not t then
t = { }
@@ -199,7 +188,7 @@ local function maxchrs(n,m,cmd,direct,t) -- direct is not ok
if direct then
return concat(t)
else
- flush(concat(t))
+ context(concat(t))
end
end
end
@@ -219,7 +208,7 @@ converters.maxchrs = maxchrs
--~ n = (n-1)%max+1
--~ end
--~ n = chr(n,mapping)
---~ flush(escapes[n] or utfchar(n))
+--~ context(escapes[n] or utfchar(n))
--~ end
--~ local lccodes, uccodes = characters.lccode, characters.uccode
@@ -270,7 +259,7 @@ local function do_alphabetic(n,mapping,mapper,direct,verbose,t)
if direct then
return concat(t)
else
- flush(concat(t))
+ context(concat(t))
end
end
end
@@ -289,7 +278,7 @@ function converters.Characters(n,direct) return chrs(n,64,direct) end
function converters.weekday(day,month,year,direct)
local s = date("%w",time{year=year,month=month,day=day}) + 1
- if direct then return s else flush(s) end
+ if direct then return s else context(s) end
end
function converters.isleapyear(year)
@@ -298,7 +287,7 @@ end
function converters.leapyear(year)
local s = converters.isleapyear(year) and 1 or 0
- if direct then return s else flush(s) end
+ if direct then return s else context(s) end
end
local days = {
@@ -308,17 +297,17 @@ local days = {
function converters.nofdays(year,month,direct)
local s = days[converters.isleapyear(year)][month]
- if direct then return s else flush(s) end
+ if direct then return s else context(s) end
end
-function converters.year (direct) local s = date("%Y") if direct then return s else flush(s) end end
-function converters.year (direct) local s = date("%Y") if direct then return s else flush(s) end end
-function converters.month (direct) local s = date("%m") if direct then return s else flush(s) end end
-function converters.hour (direct) local s = date("%H") if direct then return s else flush(s) end end
-function converters.minute (direct) local s = date("%M") if direct then return s else flush(s) end end
-function converters.second (direct) local s = date("%S") if direct then return s else flush(s) end end
+function converters.year (direct) local s = date("%Y") if direct then return s else context(s) end end
+function converters.year (direct) local s = date("%Y") if direct then return s else context(s) end end
+function converters.month (direct) local s = date("%m") if direct then return s else context(s) end end
+function converters.hour (direct) local s = date("%H") if direct then return s else context(s) end end
+function converters.minute (direct) local s = date("%M") if direct then return s else context(s) end end
+function converters.second (direct) local s = date("%S") if direct then return s else context(s) end end
function converters.textime(direct) local s = tonumber(date("%H")) * 60 + tonumber(date("%M"))
- if direct then return s else flush(s) end end
+ if direct then return s else context(s) end end
local roman = {
{ [0] = '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX' },
@@ -334,8 +323,8 @@ local function toroman(n)
end
end
-function converters.romannumerals(n,direct) local s = lower(toroman(n)) if direct then return s else flush(s) end end
-function converters.Romannumerals(n,direct) local s = toroman(n) if direct then return s else flush(s) end end
+function converters.romannumerals(n,direct) local s = lower(toroman(n)) if direct then return s else context(s) end end
+function converters.Romannumerals(n,direct) local s = toroman(n) if direct then return s else context(s) end end
converters.toroman = toroman
@@ -385,8 +374,8 @@ function converters.toabjad(n,what)
end
end
-function converters.abjadnumerals (n,direct) local s = converters.toabjad(n,false) if direct then return s else flush(s) end end
-function converters.abjadnodotnumerals(n,direct) local s = converters.toabjad(n,true ) if direct then return s else flush(s) end end
+function converters.abjadnumerals (n,direct) local s = converters.toabjad(n,false) if direct then return s else context(s) end end
+function converters.abjadnodotnumerals(n,direct) local s = converters.toabjad(n,true ) if direct then return s else context(s) end end
local vector = {
normal = {
@@ -526,9 +515,9 @@ end
--~ print(v,tochinese(v),tochinese(v,"all"),tochinese(v,"cap"))
--~ end
-function converters.chinesenumerals (n) local s = tochinese(n,"normal") if direct then return s else flush(s) end end
-function converters.chinesecapnumerals(n) local s = tochinese(n,"cap" ) if direct then return s else flush(s) end end
-function converters.chineseallnumerals(n) local s = tochinese(n,"all" ) if direct then return s else flush(s) end end
+function converters.chinesenumerals (n) local s = tochinese(n,"normal") if direct then return s else context(s) end end
+function converters.chinesecapnumerals(n) local s = tochinese(n,"cap" ) if direct then return s else context(s) end end
+function converters.chineseallnumerals(n) local s = tochinese(n,"all" ) if direct then return s else context(s) end end
--~ Well, since the one asking for this didn't test it the following code is not
--~ enabled.
@@ -653,7 +642,7 @@ function converters.convert(method,n,direct) -- todo: language
elseif sequence then
return do_alphabetic(n,sequence,false,direct,true)
else
- return direct and n or flush(n)
+ return direct and n or context(n)
end
end
end
diff --git a/tex/context/base/core-job.lua b/tex/context/base/core-job.lua
index 474eb86bf..abbbf4e5e 100644
--- a/tex/context/base/core-job.lua
+++ b/tex/context/base/core-job.lua
@@ -11,7 +11,7 @@ local ctxcatcodes, texcatcodes = tex.ctxcatcodes, tex.texcatcodes
local lower, format, find, gmatch, gsub, match = string.lower, string.format, string.find, string.gmatch, string.gsub, string.match
local concat = table.concat
-local commands, resolvers = commands, resolvers
+local commands, resolvers, context = commands, resolvers, context
-- main code
@@ -106,9 +106,9 @@ local function convertexamodes(str)
local data = xml.text(e)
local mode = match(label,"^mode:(.+)$")
if mode then
- texsprint(ctxcatcodes,format("\\enablemode[%s:%s]",mode,data))
+ context.enablemode { format("%s:%s",mode,data) }
end
- texsprint(ctxcatcodes,format("\\setvariable{exa:variables}{%s}{%s}",label,gsub(data,"([{}])","\\%1")))
+ context.setvariable("exa:variables",label,(gsub(data,"([{}])","\\%1")))
end
end
end
@@ -150,7 +150,7 @@ end
--~ for sa in gmatch(a,"[^ ,]+") do
--~ for sb in gmatch(b,"[^ ,]+") do
--~ if sa == sb then
---~ texsprint(ctxcatcodes,"\\def\\commalistelement{",sa,"}")
+--~ context.setvalue("commalistelement",sa)
--~ return true
--~ end
--~ end
@@ -158,24 +158,24 @@ end
--~ elseif ba then
--~ for sa in gmatch(a,"[^ ,]+") do
--~ if sa == b then
---~ texsprint(ctxcatcodes,"\\def\\commalistelement{",b,"}")
+--~ context.setvalue("commalistelement",b)
--~ return true
--~ end
--~ end
--~ elseif bb then
--~ for sb in gmatch(b,"[^ ,]+") do
--~ if a == sb then
---~ texsprint(ctxcatcodes,"\\def\\commalistelement{",a,"}")
+--~ context.setvalue("commalistelement",sb)
--~ return true
--~ end
--~ end
--~ else
--~ if a == b then
---~ texsprint(ctxcatcodes,"\\def\\commalistelement{",a,"}")
+--~ context.setvalue("commalistelement",a)
--~ return true
--~ end
--~ end
---~ texsprint(ctxcatcodes,"\\let\\commalistelement\\empty")
+--~ context.letvalueempty("commalistelement")
--~ return false
--~ end
--~ local function doifinsetelse(a,b)
diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv
index ff69f0011..239af98ad 100644
--- a/tex/context/base/core-mis.mkiv
+++ b/tex/context/base/core-mis.mkiv
@@ -292,7 +292,7 @@
\setvalue{\e!start\currentparagraph}%
{\bgroup
\edef\currentparagraph{#1}%
- \letvalue{\s!do\s!next\currentparagraph}\empty
+ \letvalueempty{\s!do\s!next\currentparagraph}%
\setvalue{\e!stop\currentparagraph}{\getvalue\currentparagraph\egroup}%
\getvalue\currentparagraph}%
\getparameters[\??al\currentparagraph]%
diff --git a/tex/context/base/core-uti.lua b/tex/context/base/core-uti.lua
index 1681646df..88afb35a9 100644
--- a/tex/context/base/core-uti.lua
+++ b/tex/context/base/core-uti.lua
@@ -19,7 +19,6 @@ saves much runtime but at the cost of more memory usage.</p>
local format, match = string.format, string.match
local next, type, tostring = next, type, tostring
-local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
local definetable, accesstable = utilities.tables.definetable, utilities.tables.accesstable
local serialize = table.serialize
local packers = utilities.packers
@@ -94,7 +93,7 @@ local function initializer()
end
tobesaved.randomseed = r
for cs, value in next, collected do
- texsprint(ctxcatcodes,format("\\xdef\\%s{%s}",cs,value))
+ context.setxvalue(cs,value)
end
end
diff --git a/tex/context/base/font-col.lua b/tex/context/base/font-col.lua
index 357567d14..59ba0547c 100644
--- a/tex/context/base/font-col.lua
+++ b/tex/context/base/font-col.lua
@@ -8,18 +8,16 @@ if not modules then modules = { } end modules ['font-col'] = {
-- possible optimization: delayed initialization of vectors
-local format, gmatch, texsprint, type = string.format, string.gmatch, tex.sprint, type
+local gmatch, type = string.gmatch, type
local traverse_id, first_character = node.traverse_id, node.first_character
local lpegmatch = lpeg.match
local settings_to_hash = utilities.parsers.settings_to_hash
-local ctxcatcodes = tex.ctxcatcodes
-
local trace_collecting = false trackers.register("fonts.collecting", function(v) trace_collecting = v end)
local report_fonts = logs.new("fonts")
-local fonts = fonts
+local fonts, context = fonts, context
fonts.collections = fonts.collections or { }
local collections = fonts.collections
@@ -166,20 +164,20 @@ function collections.prepare(name)
report_fonts("def: applying collection %s to %s (file: %s)",name,current,filename)
end
list = { }
- texsprint(ctxcatcodes,"\\dostartcloningfonts") -- move this to tex \dostart...
+ context.dostartcloningfonts() -- move this to tex \dostart...
for i=1,#d do
local f = d[i]
local name = f.font
local scale = f.rscale or 1
if lpegmatch(okay,name) then
- texsprint(ctxcatcodes,format("\\doclonefonta{%s}{%s}",name,scale)) -- define with unique specs
+ context.doclonefonta(name,scale) -- define with unique specs
else
- texsprint(ctxcatcodes,format("\\doclonefontb{%s}{%s}",name,scale)) -- define with inherited specs
+ context.doclonefontb(name,scale) -- define with inherited specs
end
- texsprint(ctxcatcodes,format("\\ctxlua{fonts.collections.stage_1('%s')}",name)) -- registering main font
+ context.doclonefontstageone(name) -- registering main font
end
- texsprint(ctxcatcodes,format("\\ctxlua{fonts.collections.stage_2('%s')}",name)) -- preparing clone vectors
- texsprint(ctxcatcodes,"\\dostopcloningfonts")
+ context.doclonefontstagetwo(name) -- preparing clone vectors
+ context.dostopcloningfonts()
elseif trace_collecting then
local filename = file.basename(fontdata[current].filename or "?")
report_fonts("def: error in applying collection %s to %s (file: %s)",name,current,filename)
diff --git a/tex/context/base/font-col.mkiv b/tex/context/base/font-col.mkiv
index 181b985f6..0ace4854f 100644
--- a/tex/context/base/font-col.mkiv
+++ b/tex/context/base/font-col.mkiv
@@ -93,6 +93,13 @@
\def\doclonefontb#1% #2
{\doclonefonta{#1 \savedfontspec}}
+\def\doclonefontstageone#1%
+ {\ctxlua{fonts.collections.stage_1("#1")}}
+
+\def\doclonefontstagetwo#1%
+ {\ctxlua{fonts.collections.stage_2("#1")}}
+
+
% check : only replace when present in replacement font (default: no)
% force : force replacent even when basefont has glyph (default: yes)
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index b6c0dd3f3..8802ccb64 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['font-ctx'] = {
-- needs a cleanup: merge of replace, lang/script etc
-local texsprint, count, texsetcount, write_nl = tex.sprint, tex.count, tex.setcount, texio.write_nl
+local texcount, texsetcount, write_nl = tex.count, tex.setcount, texio.write_nl
local format, gmatch, match, find, lower, gsub, byte = string.format, string.gmatch, string.match, string.find, string.lower, string.gsub, string.byte
local concat, serialize = table.concat, table.serialize
local settings_to_hash, hash_to_string = utilities.parsers.settings_to_hash, utilities.parsers.hash_to_string
@@ -18,8 +18,6 @@ local tostring, next, type = tostring, next, type
local lpegmatch = lpeg.match
local round = math.round
-local ctxcatcodes = tex.ctxcatcodes
-
local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end)
local trace_usage = false trackers.register("fonts.usage", function(v) trace_usage = v end)
local trace_mapfiles = false trackers.register("fonts.mapfiles", function(v) trace_mapfiles = v end)
@@ -43,7 +41,9 @@ local setups = specifiers.contextsetups
local numbers = specifiers.contextnumbers
local merged = specifiers.contextmerged
local synonyms = specifiers.synonyms
+
local triggers = fonts.triggers
+local names = fonts.names
-- Beware, number can be shared between redefind features but as it is
-- applied only for special cases it probably doesn't matter.
@@ -349,35 +349,40 @@ local getspecification = definers.getspecification
-- we can make helper macros which saves parsing (but normaly not
-- that many calls, e.g. in mk a couple of 100 and in metafun 3500)
+local setdefaultfontname = context.fntsetdefname
+local setsomefontname = context.fntsetsomename
+local setemptyfontsize = context.fntsetnopsize
+local setsomefontsize = context.fntsetsomesize
+
function definers.stage_one(str)
statistics.starttiming(fonts)
local fullname, size = lpegmatch(splitpattern,str)
local lookup, name, sub, method, detail = getspecification(fullname)
if not name then
report_define("strange definition '%s'",str)
- texsprint(ctxcatcodes,"\\fcglet\\somefontname\\defaultfontfile")
+ setdefaultfontname()
elseif name == "unknown" then
- texsprint(ctxcatcodes,"\\fcglet\\somefontname\\defaultfontfile")
+ setdefaultfontname()
else
- texsprint(ctxcatcodes,"\\fcxdef\\somefontname{",name,"}")
+ setsomefontname(name)
end
-- we can also use a count for the size
if size and size ~= "" then
local mode, size = lpegmatch(sizepattern,size)
if size and mode then
- count.scaledfontmode = mode
- texsprint(ctxcatcodes,"\\def\\somefontsize{",size,"}")
+ texcount.scaledfontmode = mode
+ setsomefontsize(size)
else
- count.scaledfontmode = 0
- texsprint(ctxcatcodes,"\\let\\somefontsize\\empty")
+ texcount.scaledfontmode = 0
+ setemptyfontsize()
end
elseif true then
-- so we don't need to check in tex
- count.scaledfontmode = 2
- texsprint(ctxcatcodes,"\\let\\somefontsize\\empty")
+ texcount.scaledfontmode = 2
+ setemptyfontsize()
else
- count.scaledfontmode = 0
- texsprint(ctxcatcodes,"\\let\\somefontsize\\empty")
+ texcount.scaledfontmode = 0
+ setemptyfontsize()
end
specification = definers.makespecification(str,lookup,name,sub,method,detail,size)
end
@@ -434,7 +439,7 @@ function definers.stage_two(global,cs,str,size,classfeatures,fontfeatures,classf
end
tex.definefont(global,cs,tfmdata)
-- resolved (when designsize is used):
- texsprint(ctxcatcodes,format("\\def\\somefontsize{%isp}",fontdata[tfmdata].size))
+ setsomefontsize(fontdata[tfmdata].size .. "sp")
texsetcount("global","lastfontid",tfmdata)
else
-- local t = os.clock(t)
@@ -448,7 +453,7 @@ function definers.stage_two(global,cs,str,size,classfeatures,fontfeatures,classf
report_define("defining %s with id %s as \\%s (features: %s/%s, fallbacks: %s/%s)",name,id,cs,classfeatures,fontfeatures,classfallbacks,fontfallbacks)
end
-- resolved (when designsize is used):
- texsprint(ctxcatcodes,format("\\def\\somefontsize{%isp}",tfmdata.size or 655360))
+ setsomefontsize((tfmdata.size or 655360) .. "sp")
--~ if specification.fallbacks then
--~ fonts.collections.prepare(specification.fallbacks)
--~ end
@@ -569,7 +574,7 @@ function fonts.dimenfactor(unit,tfmdata)
end
function fonts.cleanname(name)
- texsprint(ctxcatcodes,fonts.names.cleanname(name))
+ context(names.cleanname(name))
end
local p, f = 1, "%0.1fpt" -- normally this value is changed only once
@@ -581,7 +586,7 @@ function fonts.nbfs(amount,precision)
p = precision
f = "%0." .. p .. "fpt"
end
- texsprint(ctxcatcodes,lpegmatch(stripper,format(f,amount/65536)))
+ context(lpegmatch(stripper,format(f,amount/65536)))
end
-- for the moment here, this will become a chain of extras that is
@@ -682,7 +687,7 @@ function fonts.char(n) -- todo: afm en tfm
n = nametoslot(n)
end
if type(n) == "number" then
- texsprint(ctxcatcodes,format("\\char%s ",n))
+ context.char(n)
end
end
diff --git a/tex/context/base/font-fbk.lua b/tex/context/base/font-fbk.lua
index ea6854456..5916319fc 100644
--- a/tex/context/base/font-fbk.lua
+++ b/tex/context/base/font-fbk.lua
@@ -9,7 +9,8 @@ if not modules then modules = { } end modules ['font-fbk'] = {
local cos, tan, rad, format = math.cos, math.tan, math.rad, string.format
local utfbyte, utfchar = utf.byte, utf.char
-local trace_combining = false trackers.register("fonts.combining", function(v) trace_combining = v end)
+local trace_combining = false trackers.register("fonts.combining", function(v) trace_combining = v end)
+local trace_combining_all = false trackers.register("fonts.combining.all", function(v) trace_combining_all = v end)
trackers.register("fonts.composing", "fonts.combining")
@@ -105,7 +106,7 @@ function vf.aux.compose_characters(g) -- todo: scaling depends on call location
charsacc = acc and chars[acc]
end
if charsacc then
- if trace_combining then
+ if trace_combining_all then
report_combining("%s (0x%05X) = %s (0x%05X) + %s (0x%05X)",utfchar(i),i,utfchar(chr),chr,utfchar(acc),acc)
end
local chr_t = cache[chr]
@@ -178,7 +179,7 @@ function vf.aux.compose_characters(g) -- todo: scaling depends on call location
end
done = true
end
- elseif trace_combining then
+ elseif trace_combining_all then
report_combining("%s (0x%05X) = %s (0x%05X)",utfchar(i),i,utfchar(chr),chr)
end
chars[i] = t
@@ -300,7 +301,7 @@ fallbacks['textcent'] = function (g)
end
fallbacks['texteuro'] = function (g)
- local c = byte("C")
+ local c = utfbyte("C")
local t = table.fastcopy(g.characters[c],true)
local d = cos(rad(90+(g.italicangle)))
local vfspecials = backends.tables.vfspecials
diff --git a/tex/context/base/font-ini.lua b/tex/context/base/font-ini.lua
index 8209f483e..fd4465d62 100644
--- a/tex/context/base/font-ini.lua
+++ b/tex/context/base/font-ini.lua
@@ -23,7 +23,7 @@ fontloader.totable = fontloader.to_table
-- vtf comes first
-- fix comes last
-fonts = fonts or { }
+fonts = fonts or { }
-- we will also have des and fam hashes
@@ -86,9 +86,9 @@ fonts.definers.specifiers.synonyms = fonts.definers.specifiers.synonyms or { }
-- tracing
-if not fonts.color then
+if not fonts.colors then
- fonts.color = allocate {
+ fonts.colors = allocate {
set = function() end,
reset = function() end,
}
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index bb5661c19..79e5529ff 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -975,11 +975,14 @@
\expandafter\dogetfontparameteryes
\fi}
-% hm, was wrong, class/global reversed
+% helpers, some day these will be toks and counts
-\let\fcglobal\global
-\let\fcxdef \xdef
-\let\fcglet \glet
+\def\fntsetdefname {\global\let\somefontname\defaultfontfile}
+\def\fntsetsomename{\gdef\somefontname} % {#1}
+\def\fntsetnopsize {\let\somefontsize\empty}
+\def\fntsetsomesize{\def\somefontsize} % {#1}
+
+% end of helpers
\def\nonodefinefontsynonymnop
{\@EA\let\csname\??ff\@@fontname\s!features \endcsname\undefined
@@ -987,9 +990,9 @@
\@EA\let\csname\??ff\@@fontname\s!goodies \endcsname\undefined}
\def\nonodefinefontsynonymyes
- {\fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\undefined
- \fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\undefined
- \fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!goodies \endcsname\undefined}
+ {\global\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\undefined
+ \global\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\undefined
+ \global\@EA\let\csname\??ff\fontclass\@@fontname\s!goodies \endcsname\undefined}
\def\dodododefinefontsynonymnop
{\@EA\let\csname\??ff\@@fontname\s!features \endcsname\@@ff@@features
@@ -997,9 +1000,9 @@
\@EA\let\csname\??ff\@@fontname\s!goodies \endcsname\@@ff@@goodies}
\def\dodododefinefontsynonymyes
- {\fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\@@ff@@features
- \fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks
- \fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!goodies \endcsname\@@ff@@goodies}
+ {\global\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\@@ff@@features
+ \global\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks
+ \global\@EA\let\csname\??ff\fontclass\@@fontname\s!goodies \endcsname\@@ff@@goodies}
\let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater
@@ -1482,7 +1485,7 @@
% only once
\else
% prevent loop (hence \empty)
- \letvalue{\@size@#1}\empty
+ \letvalueempty{\@size@#1}%
\pushmacro\fontclass % new per 26102009
\edef\fontclass{#2}% % new per 26102009
\defineunknownfont{#1}%
@@ -1701,8 +1704,8 @@
\def\dodefinebodyfontyesxx#1#2[#3#4#5=#6]% style body def
{\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5]
- \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#5*\endcsname\undefined
- \unexpanded\@EA\fcxdef\csname\fontclass#2#1#3#4#5\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#5}{\normalunexpanded{#6}}}}
+ \global\@EA\let\csname*\fontclass#2#1#3#4#5*\endcsname\undefined
+ \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#5\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#5}{\normalunexpanded{#6}}}}
\def\dodefinebodyfontnopmm#1#2[#3#4#5=#6]% style body def
{\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5]
@@ -1715,12 +1718,12 @@
\def\dodefinebodyfontyesmm#1#2[#3#4#5=#6]% style body def
{\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5]
- \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#51*\endcsname\undefined
- \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#52*\endcsname\undefined
- \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#53*\endcsname\undefined
- \unexpanded\@EA\fcxdef\csname\fontclass#2#1#3#4#51\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#51}{\normalunexpanded{#6}}}%
- \unexpanded\@EA\fcxdef\csname\fontclass#2#1#3#4#52\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#52}{\normalunexpanded{#6}}}%
- \unexpanded\@EA\fcxdef\csname\fontclass#2#1#3#4#53\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#53}{\normalunexpanded{#6}}}}
+ \global\@EA\let\csname*\fontclass#2#1#3#4#51*\endcsname\undefined
+ \global\@EA\let\csname*\fontclass#2#1#3#4#52*\endcsname\undefined
+ \global\@EA\let\csname*\fontclass#2#1#3#4#53*\endcsname\undefined
+ \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#51\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#51}{\normalunexpanded{#6}}}%
+ \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#52\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#52}{\normalunexpanded{#6}}}%
+ \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#53\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#53}{\normalunexpanded{#6}}}}
\def\checkbodyfont#1% tests for ttsl mmbf
{\edef\c!!mm{#1}%
@@ -2170,10 +2173,10 @@
% \ifcsname\@fontclass@#1\endcsname
% \edef\fontclass{#1}%
% \else
-% \letvalue{\@no@fontclass@#1}\empty
+% \letvalueempty{\@no@fontclass@#1}%
% \fi
% \else
-% \letvalue{\@no@fontclass@#1}\empty
+% \letvalueempty{\@no@fontclass@#1}%
% \fi}
\def\trycurrentfontclass#1%
@@ -2191,12 +2194,12 @@
\edef\fontclass{#1}%
\else
% todo: message
- \letvalue{\@no@fontclass@#1}\empty
+ \letvalueempty{\@no@fontclass@#1}%
\fi
\fi
\else
% todo: message
- \letvalue{\@no@fontclass@#1}\empty
+ \letvalueempty{\@no@fontclass@#1}%
\fi}
\let\defaultfontstyle \c!rm
@@ -3988,7 +3991,7 @@
\else\ifthirdargument
\setvalue{\??sx#1::#2}{#3}%
\else\ifsecondargument
- \letvalue{\??sx#1::#2}\empty
+ \letvalueempty{\??sx#1::#2}%
\fi\fi\fi}
\unexpanded\def\styleinstance[#1]% will be made faster
diff --git a/tex/context/base/font-map.lua b/tex/context/base/font-map.lua
index 5e7135013..46e84ada2 100644
--- a/tex/context/base/font-map.lua
+++ b/tex/context/base/font-map.lua
@@ -16,8 +16,6 @@ local trace_unimapping = false trackers.register("otf.unimapping", function(v)
local report_otf = logs.new("load otf")
-local ctxcatcodes = tex and tex.ctxcatcodes
-
--[[ldx--
<p>Eventually this code will disappear because map files are kind
of obsolete. Some code may move to runtime or auxiliary modules.</p>
diff --git a/tex/context/base/font-ota.lua b/tex/context/base/font-ota.lua
index 73e2c578b..d148eddbf 100644
--- a/tex/context/base/font-ota.lua
+++ b/tex/context/base/font-ota.lua
@@ -43,7 +43,7 @@ local traverse_node_list = node.traverse
local fontdata = fonts.ids
local state = attributes.private('state')
-local fontcolors = fonts.colors
+local fontscolors = fonts.colors
local fcs = (fontscolors and fontscolors.set) or function() end
local fcr = (fontscolors and fontscolors.reset) or function() end
@@ -161,6 +161,10 @@ local isol_fina_medi_init = {
[0x077E] = true, [0x077F] = true, [zwj] = true,
}
+local mark = {
+ [0x0650] = true,
+}
+
local arab_warned = { }
-- todo: gref
@@ -231,7 +235,7 @@ function analyzers.methods.arab(head,font,attr) -- maybe make a special version
if current.id == glyph_code and current.subtype<256 and current.font == font and not has_attribute(current,state) then
done = true
local char = current.char
- if marks[char] then
+ if marks[char] or mark[char] then
set_attribute(current,state,5) -- mark
if trace_analyzing then fcs(current,"font:mark") end
elseif isol[char] then -- can be zwj or zwnj too
diff --git a/tex/context/base/font-tra.mkiv b/tex/context/base/font-tra.mkiv
index e47c8c49d..527941162 100644
--- a/tex/context/base/font-tra.mkiv
+++ b/tex/context/base/font-tra.mkiv
@@ -40,10 +40,10 @@
{\ctxlua{nodes.tracers.steppers.glyphs(\number\otfcollector,#1)}%
\unhbox\otfcollector}
-\def\otfstepcharcommand#1#2% font char
+\def\otfstepcharcommand#1#2#3% font char class
{\removeunwantedspaces
\hskip.5em plus .125em\relax
- U+\hexnumber{#2}:\ruledhbox{\ctxlua{nodes.tracers.fontchar(#1,#2)}}%
+ \doif{#3}{mark}{\underbar}{U+\hexnumber{#2}}:\ruledhbox{\ctxlua{nodes.tracers.fontchar(#1,#2)}}%
\hskip.5em plus .125em\relax}
\def\otfstepmessagecommand#1#2%
@@ -58,10 +58,10 @@
\blank}
\def\showotfstepchars#1%
- {\ctxlua{nodes.tracers.steppers.codes(#1,\!!bs\detokenize{\otfstepcharcommand}\!!es)}}
+ {\ctxlua{nodes.tracers.steppers.codes(#1,"otfstepcharcommand")}}
\def\showotfstepmessages#1%
- {\ctxlua{nodes.tracers.steppers.messages(#1,\!!bs\detokenize{\otfstepmessagecommand}\!!es,true)}}
+ {\ctxlua{nodes.tracers.steppers.messages(#1,"otfstepmessagecommand",true)}}
\def\showotfstepfeatures
{\ctxlua{nodes.tracers.steppers.features()}}
diff --git a/tex/context/base/font-uni.mkiv b/tex/context/base/font-uni.mkiv
index 40ab75ed6..ea60aa017 100644
--- a/tex/context/base/font-uni.mkiv
+++ b/tex/context/base/font-uni.mkiv
@@ -19,7 +19,8 @@
\unprotect
-\def\uchar#1#2{\ctxlua{commands.uchar(\number#1,\number#2)}}
+%def\uchar#1#2{\ctxlua{commands.uchar(,)}}
+\def\uchar#1#2{\ctxcontext{utf.char(\number\numexpr#1*256+#2\relax)}}
\let\uc\uchar
diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua
index 5f290edb1..240a84e6b 100644
--- a/tex/context/base/grph-inc.lua
+++ b/tex/context/base/grph-inc.lua
@@ -40,14 +40,13 @@ run TeX code from within Lua. Some more functionality will move to Lua.
-- commands.writestatus -> report
local format, lower, find, match, gsub, gmatch = string.format, string.lower, string.find, string.match, string.gsub, string.gmatch
-local texsprint, texbox = tex.sprint, tex.box
+local texbox = tex.box
local contains = table.contains
local concat = table.concat
local todimen = string.todimen
local settings_to_array = utilities.parsers.settings_to_array
local allocate = utilities.storage.allocate
-local ctxcatcodes = tex.ctxcatcodes
local variables = interfaces.variables
local codeinjections = backends.codeinjections
local nodeinjections = backends.nodeinjections
@@ -60,9 +59,9 @@ local trace_inclusion = false trackers.register("figures.inclusion", function
local report_graphics = logs.new("graphics")
---- some extra img functions ---
+local context, img = context, img
-local img = img
+--- some extra img functions ---
local imgkeys = img.keys()
@@ -337,8 +336,6 @@ function figures.pop()
end
end
--- maybe move texsprint to tex
-
function figures.get(category,tag,default)
local value = figuredata[category]
value = value and value[tag]
@@ -350,7 +347,7 @@ function figures.get(category,tag,default)
end
function figures.tprint(category,tag,default)
- texsprint(ctxcatcodes,figures.get(category,tag,default))
+ context(figures.get(category,tag,default))
end
function figures.current()
@@ -743,7 +740,7 @@ function figures.include(data)
return (includers[ds.format] or includers.generic)(data)
end
function figures.scale(data) -- will become lua code
- texsprint(ctxcatcodes,"\\doscalefigure")
+ context.doscalefigure()
return data
end
function figures.done(data)
@@ -861,29 +858,32 @@ function includers.generic(data)
box.width, box.height, box.depth = figure.width, figure.height, 0 -- new, hm, tricky, we need to do that in tex (yet)
texbox[nr] = box
ds.objectnumber = figure.objnum
- texsprint(ctxcatcodes,"\\relocateexternalfigure")
+ context.relocateexternalfigure()
end
return data
end
-- -- -- nongeneric -- -- --
-function checkers.nongeneric(data,command)
+function checkers.nongeneric(data,command) -- todo: macros and context.*
local dr, du, ds = data.request, data.used, data.status
local name = du.fullname or "unknown nongeneric"
local hash = name
if dr.object then
- -- hm, bugged
+ -- hm, bugged ... waiting for an xform interface
if not job.objects.get("FIG::"..hash) then
- texsprint(ctxcatcodes,command)
- texsprint(ctxcatcodes,format("\\setobject{FIG}{%s}\\vbox{\\box\\foundexternalfigure}",hash))
+ if type(command) == "function" then
+ command()
+ end
+ context.dosetfigureobject(hash)
end
- texsprint(ctxcatcodes,format("\\global\\setbox\\foundexternalfigure\\vbox{\\getobject{FIG}{%s}}",hash))
- else
- texsprint(ctxcatcodes,command)
+ context.doboxfigureobject(hash)
+ elseif type(command) == "function" then
+ command()
end
return data
end
+
function includers.nongeneric(data)
return data
end
@@ -942,9 +942,9 @@ end
function checkers.mps(data)
local mprun, mpnum = internal(data.used.fullname)
if mpnum then
- return checkers.nongeneric(data,format("\\docheckfiguremprun{%s}{%s}",mprun,mpnum))
+ return checkers.nongeneric(data,function() context.docheckfiguremprun(mprun,mpnum) end)
else
- return checkers.nongeneric(data,format("\\docheckfiguremps{%s}",data.used.fullname))
+ return checkers.nongeneric(data,function() context.docheckfiguremps(data.used.fullname) end)
end
end
includers.mps = includers.nongeneric
@@ -956,7 +956,7 @@ function existers.tex(askedname)
return (askedname ~= "" and askedname) or false
end
function checkers.tex(data)
- return checkers.nongeneric(data,format("\\docheckfiguretex{%s}", data.used.fullname))
+ return checkers.nongeneric(data,function() context.docheckfiguretex(data.used.fullname) end)
end
includers.tex = includers.nongeneric
@@ -964,7 +964,7 @@ includers.tex = includers.nongeneric
existers.buffer = existers.tex
function checkers.buffer(data)
- return checkers.nongeneric(data,format("\\docheckfigurebuffer{%s}", file.nameonly(data.used.fullname)))
+ return checkers.nongeneric(data,function() context.docheckfigurebuffer(file.nameonly(data.used.fullname)) end)
end
includers.buffers = includers.nongeneric
@@ -972,7 +972,7 @@ includers.buffers = includers.nongeneric
existers.cld = existers.tex
function checkers.cld(data)
- return checkers.nongeneric(data,format("\\docheckfigurecld{%s}", data.used.fullname))
+ return checkers.nongeneric(data,function() context.docheckfigurecld(data.used.fullname) end)
end
includers.cld = includers.nongeneric
diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv
index e74c437a0..730fe1ee5 100644
--- a/tex/context/base/grph-inc.mkiv
+++ b/tex/context/base/grph-inc.mkiv
@@ -396,6 +396,14 @@
\externalfigure[#1][#2,\c!display=,\c!object=\v!no]%
\stopnointerference}
+% helpers (will be replaced when xforms are accessible at the lua end)
+
+\def\dosetfigureobject#1%
+ {\setobject{FIG}{#1}\vbox{\box\foundexternalfigure}}
+
+\def\doboxfigureobject#1%
+ {\global\setbox\foundexternalfigure\vbox{\getobject{FIG}{#1}}} % probably one vbox too many
+
% figurebases
\def\usefigurebase[#1]%
diff --git a/tex/context/base/grph-swf.lua b/tex/context/base/grph-swf.lua
index deff3defa..c597a77f8 100644
--- a/tex/context/base/grph-swf.lua
+++ b/tex/context/base/grph-swf.lua
@@ -6,13 +6,12 @@ if not modules then modules = { } end modules ['grph-swf'] = {
license = "see context related readme files"
}
-local format = string.format
+local todimen = number.todimen
-local texsprint = tex.sprint
-local ctxcatcodes = tex.ctxcatcodes
local nodeinjections = backends.nodeinjections
local figures = figures
+local context = context
function figures.checkers.swf(data)
local dr, du, ds = data.request, data.used, data.status
@@ -21,7 +20,7 @@ function figures.checkers.swf(data)
local foundname = du.fullname
dr.width, dr.height = width, height
du.width, du.height, du.foundname = width, height, foundname
- texsprint(ctxcatcodes,format("\\startfoundexternalfigure{%ssp}{%ssp}",width,height))
+ context.startfoundexternalfigure(todimen(width),todimen(height))
nodeinjections.insertswf {
foundname = foundname,
width = width,
@@ -31,7 +30,7 @@ function figures.checkers.swf(data)
-- controls = dr.controls,
-- label = dr.label,
}
- texsprint(ctxcatcodes,"\\stopfoundexternalfigure")
+ context.stopfoundexternalfigure()
return data
end
diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua
index 1a871f0fe..b9753dd26 100644
--- a/tex/context/base/l-table.lua
+++ b/tex/context/base/l-table.lua
@@ -297,13 +297,6 @@ function table.fromhash(t)
return h
end
---~ print(table.serialize(t), "\n")
---~ print(table.serialize(t,"name"), "\n")
---~ print(table.serialize(t,false), "\n")
---~ print(table.serialize(t,true), "\n")
---~ print(table.serialize(t,"name",true), "\n")
---~ print(table.serialize(t,"name",true,true), "\n")
-
table.serialize_functions = true
table.serialize_compact = true
table.serialize_inline = true
@@ -395,8 +388,8 @@ local function do_serialize(root,name,depth,level,indexed)
--~ if v == root then
-- circular
--~ else
- local t = type(v)
- if compact and first and type(k) == "number" and k >= first and k <= last then
+ local t, tk = type(v), type(k)
+ if compact and first and tk == "number" and k >= first and k <= last then
if t == "number" then
if hexify then
handle(format("%s 0x%04X,",depth,v))
@@ -438,17 +431,18 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s __p__=nil,",depth))
end
elseif t == "number" then
- --~ if hexify then
- --~ handle(format("%s %s=0x%04X,",depth,key(k),v))
- --~ else
- --~ handle(format("%s %s=%s,",depth,key(k),v)) -- %.99g
- --~ end
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=0x%04X,",depth,k,v))
else
handle(format("%s [%s]=%s,",depth,k,v)) -- %.99g
end
+ elseif tk == "boolean" then
+ if hexify then
+ handle(format("%s [%s]=0x%04X,",depth,tostring(k),v))
+ else
+ handle(format("%s [%s]=%s,",depth,tostring(k),v)) -- %.99g
+ end
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
if hexify then
handle(format("%s %s=0x%04X,",depth,k,v))
@@ -464,26 +458,28 @@ local function do_serialize(root,name,depth,level,indexed)
end
elseif t == "string" then
if reduce and tonumber(v) then
- --~ handle(format("%s %s=%s,",depth,key(k),v))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=%s,",depth,k,v))
else
handle(format("%s [%s]=%s,",depth,k,v))
end
+ elseif tk == "boolean" then
+ handle(format("%s [%s]=%s,",depth,tostring(k),v))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s=%s,",depth,k,v))
else
handle(format("%s [%q]=%s,",depth,k,v))
end
else
- --~ handle(format("%s %s=%q,",depth,key(k),v))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=%q,",depth,k,v))
else
handle(format("%s [%s]=%q,",depth,k,v))
end
+ elseif tk == "boolean" then
+ handle(format("%s [%s]=%q,",depth,tostring(k),v))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s=%q,",depth,k,v))
else
@@ -492,13 +488,14 @@ local function do_serialize(root,name,depth,level,indexed)
end
elseif t == "table" then
if not next(v) then
- --~ handle(format("%s %s={},",depth,key(k)))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]={},",depth,k))
else
handle(format("%s [%s]={},",depth,k))
end
+ elseif tk == "boolean" then
+ handle(format("%s [%s]={},",depth,tostring(k)))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s={},",depth,k))
else
@@ -507,13 +504,14 @@ local function do_serialize(root,name,depth,level,indexed)
elseif inline then
local st = simple_table(v)
if st then
- --~ handle(format("%s %s={ %s },",depth,key(k),concat(st,", ")))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]={ %s },",depth,k,concat(st,", ")))
else
handle(format("%s [%s]={ %s },",depth,k,concat(st,", ")))
end
+ elseif tk == "boolean" then -- or find(k,"^%d+$") then
+ handle(format("%s [%s]={ %s },",depth,tostring(k),concat(st,", ")))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s={ %s },",depth,k,concat(st,", ")))
else
@@ -526,13 +524,14 @@ local function do_serialize(root,name,depth,level,indexed)
do_serialize(v,k,depth,level+1)
end
elseif t == "boolean" then
- --~ handle(format("%s %s=%s,",depth,key(k),tostring(v)))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=%s,",depth,k,tostring(v)))
else
handle(format("%s [%s]=%s,",depth,k,tostring(v)))
end
+ elseif tk == "boolean" then -- or find(k,"^%d+$") then
+ handle(format("%s [%s]=%s,",depth,tostring(k),tostring(v)))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s=%s,",depth,k,tostring(v)))
else
@@ -540,13 +539,14 @@ local function do_serialize(root,name,depth,level,indexed)
end
elseif t == "function" then
if functions then
- --~ handle(format('%s %s=loadstring(%q),',depth,key(k),dump(v)))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=loadstring(%q),",depth,k,dump(v)))
else
handle(format("%s [%s]=loadstring(%q),",depth,k,dump(v)))
end
+ elseif tk == "boolean" then
+ handle(format("%s [%s]=loadstring(%q),",depth,tostring(k),dump(v)))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s=loadstring(%q),",depth,k,dump(v)))
else
@@ -554,13 +554,14 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
else
- --~ handle(format("%s %s=%q,",depth,key(k),tostring(v)))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=%q,",depth,k,tostring(v)))
else
handle(format("%s [%s]=%q,",depth,k,tostring(v)))
end
+ elseif tk == "boolean" then -- or find(k,"^%d+$") then
+ handle(format("%s [%s]=%q,",depth,tostring(k),tostring(v)))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s=%q,",depth,k,tostring(v)))
else
@@ -869,5 +870,5 @@ function table.sequenced(t,sep,simple) -- hash only
end
function table.print(...)
- print(table.serialize(...))
+ table.tohandle(print,...)
end
diff --git a/tex/context/base/lang-ini.lua b/tex/context/base/lang-ini.lua
index d66b2645b..7bbf42aa7 100644
--- a/tex/context/base/lang-ini.lua
+++ b/tex/context/base/lang-ini.lua
@@ -157,7 +157,7 @@ function languages.synonym(synonym,tag) -- convenience function
end
function languages.installed(separator)
- tex.sprint(tex.ctxcatcodes,concat(table.sortedkeys(registered),separator or ","))
+ context(concat(table.sortedkeys(registered),separator or ","))
end
function languages.associate(tag,script,language) -- not yet used
diff --git a/tex/context/base/lang-url.lua b/tex/context/base/lang-url.lua
index 2453739db..ecde7f3ae 100644
--- a/tex/context/base/lang-url.lua
+++ b/tex/context/base/lang-url.lua
@@ -11,7 +11,7 @@ local utf = unicode.utf8
local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
local utfbyte, utfgsub = utf.byte, utf.gsub
-local ctxcatcodes, texsprint = tex.ctxcatcodes, tex.sprint
+context = context
commands = commands or { }
local commands = commands
@@ -76,15 +76,15 @@ function hyphenatedurl.action(str, left, right, disc)
for s in utfcharacters(str) do
n = n + 1
if s == d then
- texsprint(ctxcatcodes,"\\d{",utfbyte(s),"}")
+ context.d(utfbyte(s))
else
local c = chars[s]
if not c or n<=b or n>=e then
- texsprint(ctxcatcodes,"\\n{",utfbyte(s),"}")
+ context.n(utfbyte(s))
elseif c == 1 then
- texsprint(ctxcatcodes,"\\b{",utfbyte(s),"}")
+ context.b(utfbyte(s))
elseif c == 2 then
- texsprint(ctxcatcodes,"\\a{",utfbyte(s),"}")
+ context.a(utfbyte(s))
end
end
end
diff --git a/tex/context/base/lpdf-fld.lua b/tex/context/base/lpdf-fld.lua
index afb48ba53..9e49e0098 100644
--- a/tex/context/base/lpdf-fld.lua
+++ b/tex/context/base/lpdf-fld.lua
@@ -12,7 +12,6 @@ if not modules then modules = { } end modules ['lpdf-fld'] = {
local gmatch, lower, format = string.gmatch, string.lower, string.format
local lpegmatch = lpeg.match
-local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
local bpfactor, todimen = number.dimenfactors.bp, string.todimen
local trace_fields = false trackers.register("widgets.fields", function(v) trace_fields = v end)
@@ -22,6 +21,7 @@ local report_fields = logs.new("fields")
local backends, lpdf = backends, lpdf
local variables = interfaces.variables
+local context = context
local references = structures.references
local settings_to_array = utilities.parsers.settings_to_array
@@ -422,7 +422,7 @@ function codeinjections.getdefaultfieldvalue(name)
end
end
if default then
- tex.sprint(ctxcatcodes,default)
+ context(default)
end
end
end
@@ -529,7 +529,7 @@ function codeinjections.getfieldgroup(name)
end
end
if g then
- texsprint(ctxcatcodes,g)
+ context(g)
end
end
end
diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua
index 882fdfab5..a39040d7f 100644
--- a/tex/context/base/lpdf-ini.lua
+++ b/tex/context/base/lpdf-ini.lua
@@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['lpdf-ini'] = {
local setmetatable, getmetatable, type, next, tostring, tonumber, rawset = setmetatable, getmetatable, type, next, tostring, tonumber, rawset
local char, byte, format, gsub, concat, match, sub, gmatch = string.char, string.byte, string.format, string.gsub, table.concat, string.match, string.sub, string.gmatch
local utfvalues = string.utfvalues
-local texwrite, texset, texsprint, ctxcatcodes = tex.write, tex.set, tex.sprint, tex.ctxcatcodes
+local texset = tex.set
local sind, cosd = math.sind, math.cosd
local lpegmatch = lpeg.match
@@ -28,7 +28,7 @@ local trace_detail = false trackers.register("backend.detail", function
local report_backends = logs.new("backends")
-local backends = backends
+local backends, context = backends, context
backends.pdf = backends.pdf or {
comment = "backend for directly generating pdf output",
@@ -631,7 +631,7 @@ local collected = pdfdictionary {
} ; collected = collected()
function lpdf.collectedresources()
- tex.sprint(tex.ctxcatcodes,collected)
+ context(collected)
end
function lpdf.adddocumentextgstate (k,v) d_extgstates [k] = v end
@@ -657,7 +657,7 @@ registerpagefinalizer(checkshades,3,"shades")
function lpdf.rotationcm(a)
local s, c = sind(a), cosd(a)
- texwrite(format("%s %s %s %s 0 0 cm",c,s,-s,c))
+ context("%s %s %s %s 0 0 cm",c,s,-s,c)
end
-- ! -> universaltime
diff --git a/tex/context/base/lpdf-mis.lua b/tex/context/base/lpdf-mis.lua
index 6bf277d4b..39d7fbae8 100644
--- a/tex/context/base/lpdf-mis.lua
+++ b/tex/context/base/lpdf-mis.lua
@@ -17,8 +17,7 @@ if not modules then modules = { } end modules ['lpdf-mis'] = {
local next, tostring = next, tostring
local format = string.format
-local texsprint, texset = tex.sprint, tex.set
-local ctxcatcodes = tex.ctxcatcodes
+local texset = tex.set
local backends, lpdf, nodes = backends, lpdf, nodes
diff --git a/tex/context/base/lpdf-ren.lua b/tex/context/base/lpdf-ren.lua
index 33513c0d1..6cc00fc3e 100644
--- a/tex/context/base/lpdf-ren.lua
+++ b/tex/context/base/lpdf-ren.lua
@@ -10,7 +10,6 @@ if not modules then modules = { } end modules ['lpdf-ren'] = {
local tostring, tonumber, next = tostring, tonumber, next
local format = string.format
-local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
local settings_to_array = utilities.parsers.settings_to_array
local backends, lpdf = backends, lpdf
diff --git a/tex/context/base/lpdf-swf.lua b/tex/context/base/lpdf-swf.lua
index c3e340db0..a55ad9d1b 100644
--- a/tex/context/base/lpdf-swf.lua
+++ b/tex/context/base/lpdf-swf.lua
@@ -124,6 +124,5 @@ function backends.pdf.nodeinjections.insertswf(spec)
-- controls = spec.controls,
-- label = spec.label,
}
- -- texsprint(ctxcatcodes,format("\\pdfannot width %ssp height %ssp {%s}",spec.width,spec.height,annotation())) -- brrrr
node.write(pdfannotation(spec.width,spec.height,0,annotation()))
end
diff --git a/tex/context/base/lpdf-wid.lua b/tex/context/base/lpdf-wid.lua
index 3a2d1338e..1dd0a60d5 100644
--- a/tex/context/base/lpdf-wid.lua
+++ b/tex/context/base/lpdf-wid.lua
@@ -6,8 +6,8 @@ if not modules then modules = { } end modules ['lpdf-wid'] = {
license = "see context related readme files"
}
-local format, gmatch, gsub, find = string.format, string.gmatch, string.gsub, string.find
-local texsprint, ctxcatcodes, texbox, texcount = tex.sprint, tex.ctxcatcodes, tex.box, tex.count
+local gmatch, gsub, find = string.gmatch, string.gsub, string.find
+local texbox, texcount = tex.box, tex.count
local settings_to_array = utilities.parsers.settings_to_array
local settings_to_hash = utilities.parsers.settings_to_hash
@@ -57,7 +57,7 @@ end
function codeinjections.presetsymbol(symbol)
if not presets[symbol] then
- texsprint(ctxcatcodes,format("\\predefinesymbol[%s]",symbol))
+ context.predefinesymbol { symbol }
end
end
diff --git a/tex/context/base/m-timing.tex b/tex/context/base/m-timing.tex
index e5c315c74..8ecdd2d69 100644
--- a/tex/context/base/m-timing.tex
+++ b/tex/context/base/m-timing.tex
@@ -40,10 +40,10 @@ local progress = moduledata.progress
function progress.show(filename,parameters,nodes,other)
for n, name in pairs(parameters or progress.parameters(filename)) do
- tex.sprint(tex.ctxcatcodes,string.format("\\ShowNamedUsage{%s}{%s}{%s}",filename or progress.defaultfilename,name,other or ""))
+ context.ShowNamedUsage(filename or progress.defaultfilename,name,other or "")
end
for n, name in pairs(nodes or progress.nodes(filename)) do
- tex.sprint(tex.ctxcatcodes,string.format("\\ShowNamedUsage{%s}{%s}{%s}",filename or progress.defaultfilename,name,other or ""))
+ context.ShowNamedUsage(filename or progress.defaultfilename,name,other or "")
end
end
\stopluacode
diff --git a/tex/context/base/math-ali.mkiv b/tex/context/base/math-ali.mkiv
index 872cc3b82..a97326413 100644
--- a/tex/context/base/math-ali.mkiv
+++ b/tex/context/base/math-ali.mkiv
@@ -193,8 +193,8 @@
\def\rightofeqalign{\getvalue{\??eq:\v!right:\number\eqaligncolumn}}
\def\doseteqaligncolumn#1%
- {\letvalue{\??eq:\v!left :\number\eqaligncolumn}\empty
- \letvalue{\??eq:\v!right:\number\eqaligncolumn}\empty
+ {\letvalueempty{\??eq:\v!left :\number\eqaligncolumn}%
+ \letvalueempty{\??eq:\v!right:\number\eqaligncolumn}%
\doif{#1}\v!left {\letvalue{\??eq:\v!right:\number\eqaligncolumn}\hfill}%
\doif{#1}\v!right {\letvalue{\??eq:\v!left :\number\eqaligncolumn}\hfill}%
\doif{#1}\v!middle{\letvalue{\??eq:\v!right:\number\eqaligncolumn}\hfill
diff --git a/tex/context/base/meta-pdf.lua b/tex/context/base/meta-pdf.lua
index 4b4126559..0c77469a8 100644
--- a/tex/context/base/meta-pdf.lua
+++ b/tex/context/base/meta-pdf.lua
@@ -13,11 +13,10 @@ if not modules then modules = { } end modules ['meta-pdf'] = {
local concat, format, gsub, find, byte, gmatch, match = table.concat, string.format, string.gsub, string.find, string.byte, string.gmatch, string.match
local lpegmatch = lpeg.match
local round = math.round
-local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
local report_mptopdf = logs.new("mptopdf")
-local mplib, metapost, lpdf = mplib, metapost, lpdf
+local mplib, metapost, lpdf, context = mplib, metapost, lpdf, context
local pdfrgbcode = lpdf.rgbcode
local pdfcmykcode = lpdf.cmykcode
@@ -25,6 +24,7 @@ local pdfgraycode = lpdf.graycode
local pdfspotcode = lpdf.spotcode
local pdftransparencycode = lpdf.transparencycode
local pdffinishtransparencycode = lpdf.finishtransparencycode
+local pdfliteral = node.pdfliteral
metapost.mptopdf = metapost.mptopdf or { }
local mptopdf = metapost.mptopdf
@@ -54,11 +54,7 @@ resetall()
-- in no hurry as this kind of conversion does not happen that often in mkiv
local function pdfcode(str) -- could be a node.write instead
- texsprint(ctxcatcodes,"\\pdfliteral{",str,"}")
-end
-
-local function texcode(str)
- texsprint(ctxcatcodes,str)
+ context(pdfliteral(str))
end
local function mpscode(str)
@@ -133,7 +129,7 @@ function mps.newpath()
end
function mps.boundingbox(llx, lly, urx, ury)
- texcode("\\MPSboundingbox{" .. llx .. "}{" .. lly .. "}{" .. urx .. "}{" .. ury .. "}")
+ context.MPSboundingbox(llx,lly,urx,ury)
end
function mps.moveto(x,y)
@@ -227,7 +223,7 @@ function mps.textext(font, scale, str) -- old parser
dx, dy = m_stack_path[1][1], m_stack_path[1][2]
end
flushconcat()
- texcode("\\MPStextext{"..font.."}{"..scale.."}{"..str.."}{"..dx.."}{"..dy.."}")
+ context.MPStextext(font,scale,str,dx,dy)
resetpath()
end
diff --git a/tex/context/base/meta-pdh.mkiv b/tex/context/base/meta-pdh.mkiv
index ec9bab9d8..e953d6c25 100644
--- a/tex/context/base/meta-pdh.mkiv
+++ b/tex/context/base/meta-pdh.mkiv
@@ -555,7 +555,7 @@
% {\noexpand\handleMPfigurespecial{\gMPs1}{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}{\gMPs8}}}
%
% \def\handleMPfigurespecial#1#2#3#4#5#6#7#8% todo : combine with ext fig
-% {\global\letvalue{\@@MPSK#8}\empty
+% {\letgvalueempty{\@@MPSK#8}%
% \vbox to \zeropoint
% {\vss
% \hbox to \zeropoint
@@ -595,7 +595,7 @@
% {\noexpand\handleMPhyperlink{\gMPs1}{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}}}
%
% \def\handleMPhyperlink#1#2#3#4#5#6%
-% {\global\letvalue{\@@MPSK#6}\empty
+% {\letgvalueempty{\@@MPSK#6}%
% \setbox\scratchbox\hbox
% {\setbox\scratchbox\null
% \wd\scratchbox\dimexpr-#1\onebasepoint+#3\onebasepoint\relax
diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua
index 44d2367a1..47c93513a 100644
--- a/tex/context/base/mlib-pdf.lua
+++ b/tex/context/base/mlib-pdf.lua
@@ -7,16 +7,14 @@ if not modules then modules = { } end modules ['mlib-pdf'] = {
}
local format, concat, gsub = string.format, table.concat, string.gsub
-local texsprint = tex.sprint
local abs, sqrt, round = math.abs, math.sqrt, math.round
local allocate = utilities.storage.allocate
local report_mplib = logs.new("mplib")
-local mplib = mplib
+local mplib, context = mplib, context
-local ctxcatcodes = tex.ctxcatcodes
local copy_node = node.copy
local write_node = node.write
@@ -92,10 +90,10 @@ function metapost.flushers.pdf.comment(message)
if savedliterals then
local last = #savedliterals + 1
savedliterals[last] = message
- texsprint(ctxcatcodes,"\\MPLIBtoPDF{",last,"}")
+ context.MPLIBtoPDF(last)
else
savedliterals = { message }
- texsprint(ctxcatcodes,"\\MPLIBtoPDF{1}")
+ context.MPLIBtoPDF(1)
end
end
end
@@ -103,14 +101,14 @@ end
function metapost.flushers.pdf.startfigure(n,llx,lly,urx,ury,message)
savedliterals = nil
metapost.n = metapost.n + 1
- texsprint(ctxcatcodes,format("\\startMPLIBtoPDF{%s}{%s}{%s}{%s}",llx,lly,urx,ury))
+ context.startMPLIBtoPDF(llx,lly,urx,ury)
if message then metapost.flushers.pdf.comment(message) end
end
function metapost.flushers.pdf.stopfigure(message)
if message then metapost.flushers.pdf.comment(message) end
- texsprint(ctxcatcodes,"\\stopMPLIBtoPDF")
- texsprint(ctxcatcodes,"\\ctxlua{metapost.flushreset()}") -- maybe just at the beginning
+ context.stopMPLIBtoPDF()
+ context.MPLIBflushreset() -- maybe just at the beginning
end
function metapost.flushers.pdf.flushfigure(pdfliterals) -- table
@@ -119,17 +117,17 @@ function metapost.flushers.pdf.flushfigure(pdfliterals) -- table
if savedliterals then
local last = #savedliterals + 1
savedliterals[last] = pdfliterals
- texsprint(ctxcatcodes,"\\MPLIBtoPDF{",last,"}")
+ context.MPLIBtoPDF(last)
else
savedliterals = { pdfliterals }
- texsprint(ctxcatcodes,"\\MPLIBtoPDF{1}")
+ context.MPLIBtoPDF(1)
end
end
end
function metapost.flushers.pdf.textfigure(font,size,text,width,height,depth) -- we could save the factor
text = gsub(text,".","\\hbox{%1}") -- kerning happens in metapost (i have to check if this is true for mplib)
- texsprint(ctxcatcodes,format("\\MPLIBtextext{%s}{%s}{%s}{%s}{%s}",font,size,text,0,-number.dimenfactors.bp*depth))
+ context.MPLIBtextext(font,size,text,0,-number.dimenfactors.bp*depth)
end
local bend_tolerance = 131/65536
@@ -474,7 +472,7 @@ local t = { }
local flusher = {
startfigure = function()
t = { }
- texsprint(ctxcatcodes,"\\startnointerference")
+ context.startnointerference()
end,
flushfigure = function(literals)
for i=1, #literals do
@@ -482,7 +480,7 @@ local flusher = {
end
end,
stopfigure = function()
- texsprint(ctxcatcodes,"\\stopnointerference")
+ context.stopnointerference()
end
}
diff --git a/tex/context/base/mlib-pdf.mkiv b/tex/context/base/mlib-pdf.mkiv
index 096c47cc6..8506b3b15 100644
--- a/tex/context/base/mlib-pdf.mkiv
+++ b/tex/context/base/mlib-pdf.mkiv
@@ -90,4 +90,7 @@
\box\scratchbox
\endgroup}
+\def\MPLIBflushreset
+ {\ctxlua{metapost.flushreset()}}
+
\protect \endinput
diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua
index 9e8ad4ba0..e0592ca02 100644
--- a/tex/context/base/mlib-pps.lua
+++ b/tex/context/base/mlib-pps.lua
@@ -12,18 +12,16 @@ if not modules then modules = { } end modules ['mlib-pps'] = { -- prescript, pos
-- todo: report max textexts
local format, gmatch, concat, round, match = string.format, string.gmatch, table.concat, math.round, string.match
-local sprint = tex.sprint
local tonumber, type = tonumber, type
local lpegmatch = lpeg.match
local texbox = tex.box
-local copy_list = node.copy_list
-local free_list = node.flush_list
+local copy_list, free_list = node.copy_list, node.flush_list
local P, S, V, Cs = lpeg.P, lpeg.S, lpeg.V, lpeg.Cs
local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming
-local ctxcatcodes = tex.ctxcatcodes
+local context = context
local trace_textexts = false trackers.register("metapost.textexts", function(v) trace_textexts = v end)
@@ -242,7 +240,7 @@ function specials.fg(specification,object,result,flusher) -- graphics
if sy == 0 then sy = 0.00001 end
local before = specification and function()
flusher.flushfigure(result)
- sprint(ctxcatcodes,format("\\MPLIBfigure{%f}{%f}{%f}{%f}{%f}{%f}{%s}",sx,rx,ry,sy,tx,ty,specification))
+ context.MPLIBfigure(sx,rx,ry,sy,tx,ty,specification)
object.path = nil
return object, { }
end
@@ -257,8 +255,7 @@ function specials.ps(specification,object,result) -- positions
local label = specification
x = x - metapost.llx
y = metapost.ury - y
- -- report_mplib( "todo: position '%s' at (%s,%s) with (%s,%s)",label,x,y,w,h)
- sprint(ctxcatcodes,format("\\dosavepositionwhd{%s}{0}{%sbp}{%sbp}{%sbp}{%sbp}{0pt}",label,x,y,w,h))
+ context.MPLIBpositionwhd(label,x,y,w,h)
return { }, nil, nil, nil
end
@@ -427,7 +424,7 @@ function specials.tf(specification,object)
if trace_textexts then
report_mplib("setting textext %s (first pass)",n)
end
- sprint(ctxcatcodes,format("\\MPLIBsettext{%s}{%s}",n,str))
+ context.MPLIBsettext(n,str)
metapost.multipass = true
end
return { }, nil, nil, nil
@@ -437,8 +434,8 @@ local factor = 65536*(7227/7200)
function metapost.edefsxsy(wd,ht,dp) -- helper for figure
local hd = ht + dp
- commands.edef("sx",(wd ~= 0 and factor/wd) or 0)
- commands.edef("sy",(hd ~= 0 and factor/hd) or 0)
+ context.setvalue("sx",wd ~= 0 and factor/wd or 0)
+ context.setvalue("sy",hd ~= 0 and factor/hd or 0)
end
local function sxsy(wd,ht,dp) -- helper for text
@@ -468,7 +465,7 @@ function specials.ts(specification,object,result,flusher)
flusher.flushfigure(result)
local box = textexts[n]
if box then
- sprint(ctxcatcodes,format("\\MPLIBgettextscaled{%s}{%s}{%s}",n,sxsy(box.width,box.height,box.depth)))
+ context.MPLIBgettextscaled(n,sxsy(box.width,box.height,box.depth))
else
-- error
end
@@ -738,7 +735,7 @@ function metapost.graphic_base_pass(mpsformat,str,initializations,preamble,asked
if not flushed or not metapost.optimize then
-- tricky, we can only ask once for objects and therefore
-- we really need a second run when not optimized
- sprint(ctxcatcodes,format("\\ctxlua{metapost.graphic_extra_pass(%s)}",askedfig or "false"))
+ context.MPLIBextrapass(askedfig or "false")
end
else
metapost.process(mpsformat, {
@@ -764,7 +761,7 @@ function metapost.graphic_extra_pass(askedfig)
current_graphic,
nofig or do_end_fig
}, false, nil, false, true, askedfig )
- sprint(ctxcatcodes,format("\\ctxlua{metapost.resettextexts()}")) -- must happen afterwards
+ context.MPLIBresettexts() -- must happen afterwards
end
local start = [[\starttext]]
diff --git a/tex/context/base/mlib-pps.mkiv b/tex/context/base/mlib-pps.mkiv
index 2eb0ccad4..d131e9117 100644
--- a/tex/context/base/mlib-pps.mkiv
+++ b/tex/context/base/mlib-pps.mkiv
@@ -50,4 +50,13 @@
\def\MPLIBgraphictext#1%
{\startTEXpage[\c!scale=10000]#1\stopTEXpage}
+\def\MPLIBpositionwhd#1#2#3#4#5%
+ {\dosavepositionwhd{#1}{0}{#2sp}{#3sp}{#4sp}{#5sp}{0sp}}
+
+\def\MPLIBextrapass#1%
+ {\ctxlua{metapost.graphic_extra_pass(#1)}}
+
+\def\MPLIBresettexts
+ {\ctxlua{metapost.resettextexts()}}
+
\protect \endinput
diff --git a/tex/context/base/mult-cld.lua b/tex/context/base/mult-cld.lua
index a9fbab0bc..2ff0568c1 100644
--- a/tex/context/base/mult-cld.lua
+++ b/tex/context/base/mult-cld.lua
@@ -68,7 +68,7 @@ local function _flush_(n)
end
function context.restart()
- _stack_, _n_ = { }, 0
+ _stack_, _n_ = { }, 0
end
context._stack_ = _stack_
@@ -111,43 +111,10 @@ function tex.fprint(...) -- goodie
texsprint(currentcatcodes,format(...))
end
-local trace_context = logs.new("context") -- here
-
-function context.trace(intercept)
- local normalflush = flush
- flush = function(...)
- trace_context(concat({...},"",2))
- if not intercept then
- normalflush(...)
- end
- end
- context.trace = function() end
-end
-
-function context.getflush()
- return flush
-end
-
-function context.setflush(newflush)
- local oldflush = flush
- flush = newflush or flush
- return oldflush
-end
-
-trackers.register("context.flush", function(v) if v then context.trace() end end)
-trackers.register("context.intercept", function(v) if v then context.trace(true) end end) -- will become obsolete
-
---~ context.trace()
-
--- beware, we had command as part of the flush and made it "" afterwards so that we could
--- keep it there (...,command,...) but that really confuses the tex machinery
-
local function writer(command,first,...)
- if not command then
- -- error
- elseif first == nil then
- flush(currentcatcodes,command)
- else
+--~ if first == nil then -- we can move the first test to the caller (twice: direct and boolean)
+--~ flush(currentcatcodes,command)
+--~ else
local t = { first, ... }
flush(currentcatcodes,command) -- todo: ctx|prt|texcatcodes
local direct = false
@@ -227,16 +194,18 @@ local function writer(command,first,...)
if direct then
trace_context("error: direct flushing used in '%s' without following argument",command)
end
- end
+--~ end
end
---~ experiments.register("context.writer",function()
---~ writer = newwriter
---~ end)
-
local function indexer(t,k)
- local c = "\\" .. k -- .. " "
- local f = function(...) return writer(c,...) end
+ local c = "\\" .. k
+ local f = function(first,...)
+ if first == nil then
+ flush(currentcatcodes,c)
+ else
+ return writer(c,first,...)
+ end
+ end
t[k] = f
return f
end
@@ -265,9 +234,8 @@ local function caller(t,f,a,...)
-- ignored: a ...
if f then
flush(currentcatcodes,"^^M")
- else
+ elseif a ~= nil then
writer("",a,...)
- -- trace_context("warning: 'context' gets argument 'false' which is currently unsupported")
end
elseif typ == "thread" then
trace_context("coroutines not supported as we cannot yield across boundaries")
@@ -281,9 +249,71 @@ end
setmetatable(context, { __index = indexer, __call = caller } )
--- the only non macro:
+-- logging
+
+local trace_context = logs.new("context") -- here
+local trace_stack = { }
+
+local normalflush = flush
+local normalwriter = writer
+local currenttrace = nil
+local nofwriters = 0
+local nofflushes = 0
+
+statistics.register("traced context", function()
+ if nofwriters > 0 or nofflushes > 0 then
+ return format("writers: %s, flushes: %s, maxstack: %s",nofwriters,nofflushes,_n_)
+ end
+end)
+
+local tracedwriter = function(...)
+ nofwriters = nofwriters + 1
+ local t, f = { "w : " }, flush
+ flush = function(...)
+ t[#t+1] = concat({...},"",2)
+ normalflush(...)
+ end
+ normalwriter(...)
+ flush = f
+ currenttrace(concat(t))
+end
+
+local tracedflush = function(...)
+ nofflushes = nofflushes + 1
+ normalflush(...)
+ local t = { ... }
+ t[1] = "f : " -- replaces the catcode
+ currenttrace(concat(t))
+end
+
+local function pushlogger(trace)
+ insert(trace_stack,currenttrace)
+ currenttrace = trace
+ flush, writer = tracedflush, tracedwriter
+end
+
+local function poplogger()
+ currenttrace = remove(trace_stack)
+ if not currenttrace then
+ flush, writer = normalflush, normalwriter
+ end
+end
+
+local function settracing(v)
+ if v then
+ pushlogger(trace_context)
+ else
+ poplogger()
+ end
+end
+
+trackers.register("context.trace",settracing)
-local trace_cld = false
+context.pushlogger = pushlogger
+context.poplogger = poplogger
+context.settracing = settracing
+
+local trace_cld = false trackers.register("context.files", function(v) trace_cld = v end)
function context.runfile(filename)
local foundname = resolvers.findtexfile(file.addsuffix(filename,"cld")) or ""
@@ -307,31 +337,15 @@ function context.runfile(filename)
end
end
--- tracking is using the regular mechanism; we need to define
--- these 'macro' functions explictly as otherwise they are are
--- delayed (as all commands print back to tex, so that tracing
--- would be enabled afterwards)
+-- some functions
-trackers.register("cld.print", function(v)
- trace_cld = v
- if v then
- flush = function(c,...)
- texiowrite(...)
- texsprint(c,...)
- end
- else
- flush = texsprint
+function context.direct(first,...)
+ if first ~= nil then
+ return writer("",first,...)
end
-end)
-
-function context.enabletrackers (str) trackers.enable (str) end
-function context.disabletrackers(str) trackers.disable(str) end
-
-function context.direct(...)
- return writer("",...)
end
-function context.char(k)
+function context.char(k) -- todo: if catcode == letter or other then just the utf
if type(k) == "table" then
for i=1,#k do
context(format([[\char%s\relax]],k[i]))
@@ -341,88 +355,29 @@ function context.char(k)
end
end
+function context.chardef(cs,u)
+ context(format([[\chardef\%s=%s\relax]],k))
+end
+
function context.par()
context([[\par]]) -- no need to add {} there
end
--- see demo-cld.cld for an example
-
--- context.starttext(true)
--- context.chapter({ "label" }, "title", true)
--- context.chapter(function() return { "label" } end, "title", true)
---
--- context.startchapter({ title = "test" }, { more = "oeps" }, true)
---
--- context.bTABLE(true)
--- for i=1,10 do
--- context.bTR()
--- for i=1,10 do
--- context.bTD()
--- context("%#2i",math.random(99))
--- context.eTD()
--- end
--- context.eTR(true)
--- end
--- context.eTABLE(true)
---
--- context.stopchapter(true)
---
--- context.stoptext(true)
+function context.bgroup()
+ context("{")
+end
---~ Not that useful yet. Maybe something like this when the main loop
---~ is a coroutine. It also does not help taking care of nested calls.
---~ Even worse, it interferes with other mechanisms using context calls.
---~
---~ local create, yield, resume = coroutine.create, coroutine.yield, coroutine.resume
---~ local getflush, setflush = context.getflush, context.setflush
---~ local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
---~
---~ function context.direct(f)
---~ local routine = create(f)
---~ local oldflush = getflush()
---~ function newflush(...)
---~ oldflush(...)
---~ yield(true)
---~ end
---~ setflush(newflush)
---~
---~ -- local function resumecontext()
---~ -- local done = resume(routine)
---~ -- if not done then
---~ -- return
---~ -- end
---~ -- resumecontext() -- stack overflow ... no tail recursion
---~ -- end
---~ -- context.resume = resumecontext
---~ -- texsprint(ctxcatcodes,"\\ctxlua{context.resume()}")
---~
---~ local function resumecontext()
---~ local done = resume(routine)
---~ if not done then
---~ return
---~ end
---~ -- texsprint(ctxcatcodes,"\\exitloop")
---~ texsprint(ctxcatcodes,"\\ctxlua{context.resume()}") -- can be simple macro call
---~ end
---~ context.resume = resumecontext
---~ -- texsprint(ctxcatcodes,"\\doloop{\\ctxlua{context.resume()}}") -- can be fast loop at the tex end
---~ texsprint(ctxcatcodes,"\\ctxlua{context.resume()}")
---~
---~ end
---~
---~ function something()
---~ context("\\setbox0")
---~ context("\\hbox{hans hagen xx}")
---~ context("\\the\\wd0/\\box0")
---~ end
---~
---~ context.direct(something)
+function context.egroup()
+ context("}")
+end
--- this might be generalized: register some primitives as: accepting this or that
--- we can also speed this up
+function context.verbatim(...)
+ flush(vrbcatcodes,...)
+end
+-- context.delayed
-local delayed = { } context.delayed = delayed -- maybe also global
+local delayed = { } context.delayed = delayed -- maybe also store them
local function indexer(t,k)
local f = function(...)
@@ -435,7 +390,6 @@ local function indexer(t,k)
return f
end
-
local function caller(t,...)
local a = { ... }
return function()
@@ -445,10 +399,37 @@ end
setmetatable(delayed, { __index = indexer, __call = caller } )
---~ context.test("test 1",context.delayed(" test 2a "),"test 3")
---~ context.test("test 1",context.delayed.test(" test 2b "),"test 3")
+-- context.nested
--- experimental:
+local nested = { } context.nested = nested
+
+local function indexer(t,k)
+ local f = function(...)
+ local t, savedflush = { }, flush
+ flush = function(c,f,s,...) -- catcodes are ignored
+ t[#t+1] = s and concat{f,s,...} or f -- optimized for #args == 1
+ end
+ context[k](...)
+ flush = savedflush
+ return concat(t)
+ end
+ t[k] = f
+ return f
+end
+
+local function caller(t,...)
+ local t, savedflush = { }, flush
+ flush = function(c,f,s,...) -- catcodes are ignored
+ t[#t+1] = s and concat{f,s,...} or f -- optimized for #args == 1
+ end
+ context(...)
+ flush = savedflush
+ return concat(t)
+end
+
+setmetatable(nested, { __index = indexer, __call = caller } )
+
+-- metafun
local metafun = { } context.metafun = metafun
@@ -502,6 +483,7 @@ function metafun.color(name)
return format([[\MPcolor{%s}]],name)
end
+-- metafun.delayed
local delayed = { } metafun.delayed = delayed
@@ -525,3 +507,62 @@ local function caller(t,...)
end
setmetatable(delayed, { __index = indexer, __call = caller } )
+
+--~ Not that useful yet. Maybe something like this when the main loop
+--~ is a coroutine. It also does not help taking care of nested calls.
+--~ Even worse, it interferes with other mechanisms using context calls.
+--~
+--~ local create, yield, resume = coroutine.create, coroutine.yield, coroutine.resume
+--~ local getflush, setflush = context.getflush, context.setflush
+--~ local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
+--~
+--~ function context.getflush()
+--~ return flush
+--~ end
+--~
+--~ function context.setflush(newflush)
+--~ local oldflush = flush
+--~ flush = newflush or flush
+--~ return oldflush
+--~ end
+--~
+--~ function context.direct(f)
+--~ local routine = create(f)
+--~ local oldflush = getflush()
+--~ function newflush(...)
+--~ oldflush(...)
+--~ yield(true)
+--~ end
+--~ setflush(newflush)
+--~
+--~ -- local function resumecontext()
+--~ -- local done = resume(routine)
+--~ -- if not done then
+--~ -- return
+--~ -- end
+--~ -- resumecontext() -- stack overflow ... no tail recursion
+--~ -- end
+--~ -- context.resume = resumecontext
+--~ -- texsprint(ctxcatcodes,"\\ctxlua{context.resume()}")
+--~
+--~ local function resumecontext()
+--~ local done = resume(routine)
+--~ if not done then
+--~ return
+--~ end
+--~ -- texsprint(ctxcatcodes,"\\exitloop")
+--~ texsprint(ctxcatcodes,"\\ctxlua{context.resume()}") -- can be simple macro call
+--~ end
+--~ context.resume = resumecontext
+--~ -- texsprint(ctxcatcodes,"\\doloop{\\ctxlua{context.resume()}}") -- can be fast loop at the tex end
+--~ texsprint(ctxcatcodes,"\\ctxlua{context.resume()}")
+--~
+--~ end
+--~
+--~ function something()
+--~ context("\\setbox0")
+--~ context("\\hbox{hans hagen xx}")
+--~ context("\\the\\wd0/\\box0")
+--~ end
+--~
+--~ context.direct(something)
diff --git a/tex/context/base/mult-cld.mkiv b/tex/context/base/mult-cld.mkiv
index 6b94f3f21..7fcb96553 100644
--- a/tex/context/base/mult-cld.mkiv
+++ b/tex/context/base/mult-cld.mkiv
@@ -11,8 +11,6 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D This is just an idea, maybe a bad one.
-
\writestatus{loading}{ConTeXt Multilingual Macros / Lua}
\registerctxluafile{mult-cld}{1.001}
diff --git a/tex/context/base/node-fin.lua b/tex/context/base/node-fin.lua
index 943af3837..af2ba0421 100644
--- a/tex/context/base/node-fin.lua
+++ b/tex/context/base/node-fin.lua
@@ -9,8 +9,6 @@ if not modules then modules = { } end modules ['node-fin'] = {
-- this module is being reconstructed
local next, type, format = next, type, string.format
-local texsprint = tex.sprint
-local ctxcatcodes = tex.ctxcatcodes
local attributes, nodes, node = attributes, nodes, node
@@ -63,7 +61,7 @@ end
-- function states.flush()
-- if #collected > 0 then
-- for i=1,#collected do
--- texsprint(ctxcatcodes,collected[i]) -- we're in context mode anyway
+-- context(collected[i]) -- we're in context mode anyway
-- end
-- collected = { }
-- states.collected = collected
diff --git a/tex/context/base/node-ser.lua b/tex/context/base/node-ser.lua
index c7bc53a3a..fd211b2c8 100644
--- a/tex/context/base/node-ser.lua
+++ b/tex/context/base/node-ser.lua
@@ -13,8 +13,6 @@ local type, format, concat, rep = type, string.format, table.concat, string.rep
local allocate = utilities.storage.allocate
-local ctxcatcodes = tex.ctxcatcodes
-
local nodes, node = nodes, node
local traverse = node.traverse
@@ -233,26 +231,36 @@ function nodes.serializebox(n,flat,verbose,name)
return nodes.serialize(nodes.totable(tex.box[n],flat,verbose),name)
end
-function nodes.visualizebox(...)
- tex.print(ctxcatcodes,"\\starttyping")
- tex.print(nodes.serializebox(...))
- tex.print("\\stoptyping")
+-- keep:
+--
+-- function nodes.visualizebox(...)
+-- tex.print(ctxcatcodes,"\\starttyping")
+-- tex.print(nodes.serializebox(...))
+-- tex.print("\\stoptyping")
+-- end
+
+function nodes.visualizebox(...) -- to be checked .. will move to module anyway
+ context.starttyping()
+ context.pushcatcodes("verbatim")
+ context(nodes.serializebox(...))
+ context.stoptyping()
+ context.popcatcodes()
end
-function nodes.list(head,n) -- name might change to nodes.type
+function nodes.list(head,n) -- name might change to nodes.type -- to be checked .. will move to module anyway
if not n then
- tex.print(ctxcatcodes,"\\starttyping")
+ context.starttyping(true)
end
while head do
local id = head.id
- tex.print(rep(" ",n or 0) .. tostring(head) .. "\n")
+ tex.write(rep(" ",n or 0) .. tostring(head) .. "\n")
if id == hlist_code or id == vlist_code then
nodes.list(head.list,(n or 0)+1)
end
head = head.next
end
if not n then
- tex.print("\\stoptyping")
+ context.stoptyping(true)
end
end
diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua
index a5056d88d..8094f3736 100644
--- a/tex/context/base/node-tra.lua
+++ b/tex/context/base/node-tra.lua
@@ -17,14 +17,12 @@ local format, match, gmatch, concat, rep = string.format, string.match, string.g
local lpegmatch = lpeg.match
local write_nl = texio.write_nl
-local ctxcatcodes = tex.ctxcatcodes
-
local report_nodes = logs.new("nodes")
fonts = fonts or { }
nodes = nodes or { }
-local fonts, nodes, node = fonts, nodes, node
+local fonts, nodes, node, context = fonts, nodes, node, context
fonts.tfm = fonts.tfm or { }
fonts.ids = fonts.ids or { }
@@ -55,7 +53,6 @@ local first_character = node.first_character
local node_type = node.type
local traverse_nodes = node.traverse
-local texsprint = tex.sprint
local fontdata = fonts.ids
local fontchar = fonts.chr
@@ -260,9 +257,9 @@ function step_tracers.features()
end
end
if #t > 0 then
- texsprint(ctxcatcodes,concat(t,", "))
+ context(concat(t,", "))
else
- texsprint(ctxcatcodes,"no features")
+ context("no features")
end
return
end
@@ -273,7 +270,7 @@ end
function tracers.fontchar(font,char)
local n = new_glyph()
n.font, n.char, n.subtype = font, char, 256
- node.write(n)
+ context(n)
end
function step_tracers.codes(i,command)
@@ -282,14 +279,17 @@ function step_tracers.codes(i,command)
local id = c.id
if id == glyph_code then
if command then
- texsprint(ctxcatcodes,format("%s{%s}{%s}",command,c.font,c.char))
+ local f, c = c.font,c.char
+ local d = fontdata[f].descriptions
+ local d = d and d[c]
+ context[command](f,c,d and d.class or "")
else
- texsprint(ctxcatcodes,format("[%s:U+%04X]",c.font,c.char))
+ context("[%s:U+%04X]",c.font,c.char)
end
elseif id == whatsit_code and (c.subtype == localpar_code or c.subtype == dir_code) then
- texsprint(ctxcatcodes,format("[%s]",c.dir))
+ context("[%s]",c.dir)
else
- texsprint(ctxcatcodes,format("[%s]",node_type(id)))
+ context("[%s]",node_type(id))
end
c = c.next
end
@@ -300,11 +300,13 @@ function step_tracers.messages(i,command,split)
if list then
for i=1,#list do
local l = list[i]
- if split then
+ if not command then
+ context("(%s)",l)
+ elseif split then
local a, b = match(l,"^(.-)%s*:%s*(.*)$")
- texsprint(ctxcatcodes,format("%s{%s}{%s}",command,a or l,b or ""))
+ context[command](a or l or "",b or "")
else
- texsprint(ctxcatcodes,format("%s{%s}",command,l))
+ context[command](l)
end
end
end
diff --git a/tex/context/base/pack-lyr.mkiv b/tex/context/base/pack-lyr.mkiv
index 7ef6baea4..8b35a98a7 100644
--- a/tex/context/base/pack-lyr.mkiv
+++ b/tex/context/base/pack-lyr.mkiv
@@ -426,9 +426,9 @@
% \unexpanded\def\flushlayer[#1]%
% {\doifelsevalue{\??ll#1\c!state}\v!next
-% {\global\letvalue{\??ll#1\c!state}\v!start} % dangerous, stack-built-up
+% {\letgvalue{\??ll#1\c!state}\v!start} % dangerous, stack-built-up
% {\doifelsevalue{\??ll#1\c!state}\v!continue
-% {\global\letvalue{\??ll#1\c!state}\v!repeat} % dangerous, stack-built-up
+% {\letgvalue{\??ll#1\c!state}\v!repeat} % dangerous, stack-built-up
% {\doifelsevalue{\??ll#1\c!doublesided}\v!yes
% {\doifundefinedelse{\@@layerbox#1}%
% {\dodoflushlayerA[#1]}
diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv
index 23c6073fb..cc3a34b11 100644
--- a/tex/context/base/pack-rul.mkiv
+++ b/tex/context/base/pack-rul.mkiv
@@ -2730,7 +2730,7 @@
\v!none=>\letvalue{\??kd#1\c!left }\relax % new
\letvalue{\??kd#1\c!right}\relax % new
\settrue\framedtextlocationnone]%
- \letvalue{\??kd#1\c!location}\empty
+ \letvalueempty{\??kd#1\c!location}%
% removed 06/2001
% \forgetparindent
% added 06/2001 [see demo-bbv]
diff --git a/tex/context/base/page-flt.lua b/tex/context/base/page-flt.lua
index 282ca0cc5..e3357a97e 100644
--- a/tex/context/base/page-flt.lua
+++ b/tex/context/base/page-flt.lua
@@ -11,7 +11,6 @@ if not modules then modules = { } end modules ['page-flt'] = {
local insert, remove = table.insert, table.remove
local find = string.find
local setdimen, setbox, setcount, texbox = tex.setdimen, tex.setbox, tex.setcount, tex.box
-local texwrite, texsprint, ctxcatcodes = tex.write, tex.sprint, tex.ctxcatcodes
local copy_node_list = node.copy_list
@@ -48,7 +47,7 @@ function floats.stacked(which) -- floats.thenofstacked
end
function floats.thestacked(which)
- return texwrite(#stacks[which or default])
+ return context(#stacks[which or default])
end
function floats.push()
@@ -168,7 +167,7 @@ end
function floats.thevar(name,default)
local value = last and last.data[name] or default
if value and value ~= "" then
- texsprint(ctxcatcodes,value)
+ context(value)
end
end
@@ -246,7 +245,7 @@ function floats.thecheckedpagefloat(packed)
end
end
end
- texsprint(ctxcatcodes,result)
+ context(result)
end
local method = C((1-S(", :"))^1)
diff --git a/tex/context/base/page-lin.lua b/tex/context/base/page-lin.lua
index 895f0ec80..186989839 100644
--- a/tex/context/base/page-lin.lua
+++ b/tex/context/base/page-lin.lua
@@ -12,11 +12,9 @@ local trace_numbers = false trackers.register("lines.numbers", function(v) tra
local report_lines = logs.new("lines")
-local format = string.format
-local texsprint, texwrite, texbox = tex.sprint, tex.write, tex.box
-local ctxcatcodes = tex.ctxcatcodes
+local texbox = tex.box
-local attributes, nodes, node = attributes, nodes, node
+local attributes, nodes, node, context = attributes, nodes, node, context
nodes.lines = nodes.lines or { }
local lines = nodes.lines
@@ -107,7 +105,7 @@ filters.line = filters.line or { }
function filters.line.default(data)
-- helpers.title(data.entries.linenumber or "?",data.metadata)
- texsprint(ctxcatcodes,format("\\convertnumber{%s}{%s}",data.entries.conversion or "numbers",data.entries.linenumber or "0"))
+ context.convertnumber(data.entries.conversion or "numbers",data.entries.linenumber or "0")
end
function filters.line.page(data,prefixspec,pagespec) -- redundant
@@ -115,7 +113,7 @@ function filters.line.page(data,prefixspec,pagespec) -- redundant
end
function filters.line.linenumber(data) -- raw
- texwrite(data.entries.linenumber or "0")
+ context(data.entries.linenumber or "0")
end
-- boxed variant, todo: use number mechanism
diff --git a/tex/context/base/page-mar.mkiv b/tex/context/base/page-mar.mkiv
index 037dc1298..6a1691a00 100644
--- a/tex/context/base/page-mar.mkiv
+++ b/tex/context/base/page-mar.mkiv
@@ -484,9 +484,9 @@
%
% an alternative:
%
-% \letvalue{\??im\v!laag\c!offset}\empty
-% \letvalue{\??im +\c!offset}\empty
-% \letvalue{\??im -\c!offset}\empty
+% \letvalueempty{\??im\v!laag\c!offset}
+% \letvalueempty{\??im +\c!offset}
+% \letvalueempty{\??im -\c!offset}
%
% \def\doinmargin[#1][#2][#3][#4][#5]% #6 #7
% {\doifnumberelse{#4}
diff --git a/tex/context/base/page-txt.mkiv b/tex/context/base/page-txt.mkiv
index 2ac9cb6b9..69ef8c270 100644
--- a/tex/context/base/page-txt.mkiv
+++ b/tex/context/base/page-txt.mkiv
@@ -172,8 +172,8 @@
{\c!rightstyle\c!rightcolor\c!rightwidth}{#3}%
{\c!rightstyle\c!rightcolor\c!rightwidth}{#3}}%
\else\ifsecondargument % new
- \letvalue{\??tk#1\v!text\c!lefttext }\empty
- \letvalue{\??tk#1\v!text\c!righttext }\empty
+ \letvalueempty{\??tk#1\v!text\c!lefttext}%
+ \letvalueempty{\??tk#1\v!text\c!righttext}%
\setvalue{\??tk#1\v!text\c!middletext}{\dosingletexts{#1}\v!text\c!style\c!color\c!width{#2}}%
\else
\dosixtupleempty\dosetuptexts[#1][\v!text ][][][][]%
@@ -367,19 +367,19 @@
\def\doresettextcontent[#1][#2][#3]% header text middle
{\ifthirdargument
- \letvalue{\??tk#1#2\executeifdefined{:\c!text:#3:}\c!middletext}\empty
+ \letvalueempty{\??tk#1#2\executeifdefined{:\c!text:#3:}\c!middletext}%
\else\ifsecondargument
- \letvalue{\??tk#1#2\c!lefttext }\empty
- \letvalue{\??tk#1#2\c!middletext}\empty
- \letvalue{\??tk#1#2\c!righttext }\empty
+ \letvalueempty{\??tk#1#2\c!lefttext}%
+ \letvalueempty{\??tk#1#2\c!middletext}%
+ \letvalueempty{\??tk#1#2\c!righttext}%
\fi\fi}
\let\settext \settextcontent % downward compatibility
\let\resettext\resettextcontent % downward compatibility
-\setvalue{:\c!middle:\c!text:}{\c!middletext}
-\setvalue{:\c!left :\c!text:}{\c!lefttext }
-\setvalue{:\c!right :\c!text:}{\c!righttext }
+\letvalue{:\c!middle:\c!text:}\c!middletext
+\letvalue{:\c!left :\c!text:}\c!lefttext
+\letvalue{:\c!right :\c!text:}\c!righttext
%D The next series of macros is not that easy to read,
%D because they hook into the main page building macros. By
diff --git a/tex/context/base/pret-lua.lua b/tex/context/base/pret-lua.lua
index 723c019d7..6a74670b2 100644
--- a/tex/context/base/pret-lua.lua
+++ b/tex/context/base/pret-lua.lua
@@ -14,10 +14,10 @@ local utf = unicode.utf8
local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
local utfbyte, utffind = utf.byte, utf.find
local byte, sub, find, match = string.byte, string.sub, string.find, string.match
-local texsprint, texwrite = tex.sprint, tex.write
-local ctxcatcodes = tex.ctxcatcodes
+local texwrite = tex.write
local buffers = buffers
+local context = context
local changestate, finishstate = buffers.changestate, buffers.finishstate
@@ -95,9 +95,9 @@ end
visualizer.styles = {
core = "",
- base = "\\sl ",
- five = "\\sl ",
- libs = "\\sl ",
+ base = "sl ",
+ five = "sl ",
+ libs = "sl ",
}
local styles = visualizer.styles
@@ -121,8 +121,9 @@ local function flush_lua_word(state, word)
local id = known_words[word]
if id then
state = changestate(2,state)
- if styles[id] then
- texsprint(ctxcatcodes,styles[id])
+ local style = styles[id]
+ if style and style ~= "" then
+ context[style]()
end
texwrite(word)
state = finishstate(state)
@@ -145,15 +146,19 @@ end
-- we will also provide a proper parser based pretty printer although normaly
-- a pretty printer should handle faulty code too (educational purposes)
+local space = context.obs
+
local function written(state,c,i)
if c == " " then
state = finishstate(state)
- texsprint(ctxcatcodes,"\\obs")
+ space()
elseif c == "\t" then
state = finishstate(state)
- texsprint(ctxcatcodes,"\\obs")
+ space()
if buffers.visualizers.enabletab then
- texsprint(ctxcatcodes,rep("\\obs ",i%buffers.visualizers.tablength))
+ for i=1,i%buffers.visualizers.tablength do
+ space()
+ end
end
else
texwrite(c)
@@ -172,7 +177,11 @@ function visualizer.flush_line(str, nested)
if comment then
-- flush the comment and then process the code
for c in utfcharacters(comment) do
- if c == " " then texsprint(ctxcatcodes,"\\obs") else texwrite(c) end
+ if c == " " then
+ space()
+ else
+ texwrite(c)
+ end
end
state = changestate(states['--'], state)
texwrite("]]")
@@ -180,7 +189,11 @@ function visualizer.flush_line(str, nested)
incomment = false
else
for c in utfcharacters(str) do
- if c == " " then texsprint(ctxcatcodes,"\\obs") else texwrite(c) end
+ if c == " " then
+ space()
+ else
+ texwrite(c)
+ end
end
end
comment = nil
diff --git a/tex/context/base/pret-mp.lua b/tex/context/base/pret-mp.lua
index 2e89588be..c701d63c8 100644
--- a/tex/context/base/pret-mp.lua
+++ b/tex/context/base/pret-mp.lua
@@ -10,8 +10,7 @@ local utf = unicode.utf8
local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
local utfbyte, utffind = utf.byte, utf.find
-local texsprint, texwrite = tex.sprint, tex.write
-local ctxcatcodes = tex.ctxcatcodes
+local texwrite = tex.write
local buffers = buffers
@@ -114,8 +113,8 @@ visualizer.identifiers.metafun = {
visualizer.styles = {
primitives = "",
- plain = "\\sl",
- metafun = "\\sl",
+ plain = "sl",
+ metafun = "sl",
}
local styles = visualizer.styles
@@ -161,8 +160,9 @@ local function flush_mp_word(state, word, intex)
local id = known_words[word]
if id then
state = changestate(2,state)
- if styles[id] then
- texsprint(ctxcatcodes,styles[id])
+ local style = styles[id]
+ if style and style ~= "" then
+ context[style]()
end
texwrite(word)
state = finishstate(state)
@@ -184,6 +184,8 @@ end
-- to be considered: visualizer => table [result, instr, incomment, word]
+local space = context.obs
+
function visualizer.flush_line(str,nested)
local state, word, instr, intex, incomment = 0, nil, false, false, false
buffers.currentcolors = colors
@@ -191,7 +193,7 @@ function visualizer.flush_line(str,nested)
if c == " " then
state, intex = flush_mp_word(state, word, intex)
word = nil
- texsprint(ctxcatcodes,"\\obs")
+ space()
elseif incomment then
texwrite(c)
elseif c == '%' then
diff --git a/tex/context/base/pret-tex.lua b/tex/context/base/pret-tex.lua
index 851155122..0baf576c8 100644
--- a/tex/context/base/pret-tex.lua
+++ b/tex/context/base/pret-tex.lua
@@ -10,11 +10,10 @@ local utf = unicode.utf8
local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
local utfbyte, utffind = utf.byte, utf.find
-local rep = string.rep
-local texsprint, texwrite = tex.sprint, tex.write
-local ctxcatcodes, vrbcatcodes = tex.ctxcatcodes, tex.vrbcatcodes
+local texwrite = tex.write
local buffers = buffers
+local context = context
local changestate, finishstate = buffers.changestate, buffers.finishstate
@@ -38,6 +37,8 @@ local states = {
local chardata = characters.data
local is_letter = characters.is_letter
+local space = context.obs
+
function visualizer.flush_line(str,nested)
local state, first, i = 0, false, 0
buffers.currentcolors = colors
@@ -45,13 +46,15 @@ function visualizer.flush_line(str,nested)
i = i + 1
if c == " " then
state = finishstate(state)
- texsprint(ctxcatcodes,"\\obs")
+ space()
first = false
elseif c == "\t" then
state = finishstate(state)
- texsprint(ctxcatcodes,"\\obs")
+ space()
if buffers.visualizers.enabletab then
- texsprint(ctxcatcodes,rep("\\obs ",i%buffers.visualizers.tablength))
+ for i=1,i%buffers.visualizers.tablength do
+ space()
+ end
i = 0
end
first = false
diff --git a/tex/context/base/pret-xml.lua b/tex/context/base/pret-xml.lua
index e449d9d98..0a79ed78a 100644
--- a/tex/context/base/pret-xml.lua
+++ b/tex/context/base/pret-xml.lua
@@ -14,11 +14,10 @@ if not modules then modules = { } end modules ['pret-xml'] = {
local utf = unicode.utf8
local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
local utfbyte, utffind = utf.byte, utf.find
-local rep = string.rep
-local texsprint, texwrite = tex.sprint, tex.write
-local ctxcatcodes = tex.ctxcatcodes
+local texwrite = tex.write
local buffers = buffers
+local context = context
local changestate, finishstate = buffers.changestate, buffers.finishstate
@@ -42,6 +41,8 @@ function visualizer.reset()
state, intag, dotag, inentity, inquote = 0, false, false, false, false
end
+local space = context.obs
+
function visualizer.flush_line(str,nested)
buffers.currentcolors = colors
for c in utfcharacters(str) do
@@ -63,13 +64,15 @@ function visualizer.flush_line(str,nested)
texwrite(c)
elseif c == " " then
state = finishstate(state)
- texsprint(ctxcatcodes,"\\obs")
+ space()
intag = false
elseif c == "\t" then
state = finishstate(state)
- texsprint(ctxcatcodes,"\\obs")
+ space()
if buffers.visualizers.enabletab then
- texsprint(ctxcatcodes,rep("\\obs ",i%buffers.visualizers.tablength))
+ for i=1,i%buffers.visualizers.tablength do
+ space()
+ end
end
intag = false
elseif c == "<" then
diff --git a/tex/context/base/prop-ini.mkiv b/tex/context/base/prop-ini.mkiv
index 97d72582e..ada358f6d 100644
--- a/tex/context/base/prop-ini.mkiv
+++ b/tex/context/base/prop-ini.mkiv
@@ -123,7 +123,7 @@
\getparameters[\??py][#1]%
\fi}
-\letvalue{\??py\s!empty}\empty
+\letvalueempty{\??py\s!empty}
% beware, normally \*parameter concerns the current one
diff --git a/tex/context/base/regi-ini.lua b/tex/context/base/regi-ini.lua
index f69f8866f..561b8d8f4 100644
--- a/tex/context/base/regi-ini.lua
+++ b/tex/context/base/regi-ini.lua
@@ -8,9 +8,6 @@ if not modules then modules = { } end modules ['regi-ini'] = {
local utf = unicode.utf8
local char, utfchar, gsub = string.char, utf.char, string.gsub
-local texsprint = tex.sprint
-
-local ctxcatcodes = tex.ctxcatcodes
--[[ldx--
<p>Regimes take care of converting the input characters into
@@ -48,7 +45,7 @@ function regimes.setsynonym(synonym,target)
end
function regimes.truename(regime)
- texsprint(ctxcatcodes,(regime and synonyms[synonym] or regime) or regimes.currentregime)
+ context((regime and synonyms[synonym] or regime) or regimes.currentregime)
end
function regimes.load(regime)
diff --git a/tex/context/base/s-fnt-10.tex b/tex/context/base/s-fnt-10.tex
index 216d9d232..8214946c6 100644
--- a/tex/context/base/s-fnt-10.tex
+++ b/tex/context/base/s-fnt-10.tex
@@ -17,17 +17,18 @@ local format, sprint = string.format, tex.sprint
function fonts.otf.show_all()
local tfmdata = fonts.ids[font.current()]
if tfmdata and tfmdata.shared then
+ local NC, NR, char = context.NC, context.NR, context.char
local otfdata = tfmdata.shared.otfdata
if otfdata and otfdata.luatex then
local unicodes = otfdata.luatex.unicodes
- sprint(tex.ctxcatcodes,format("\\starttabulate[|l|r|c|]"))
+ context.starttabulate { "|l|r|c|" }
for i, name in ipairs(table.sortedkeys(unicodes)) do
local unicode = unicodes[name]
if unicode >= 0 then
- sprint(tex.ctxcatcodes,format("\\NC %s \\NC %s \\NC \\char%s \\NC\\NR",name,unicode,unicode))
+ NC() context(name) NC() context(unicode) NC() char(unicode) NC() NR()
end
end
- sprint(tex.ctxcatcodes,format("\\stoptabulate"))
+ context.stoptabulate()
end
end
end
@@ -35,15 +36,21 @@ end
function fonts.show_all()
local tfmdata = fonts.ids[font.current()]
if tfmdata then
+ local NC, NR, HL, char, bold, tttf = context.NC, context.NR, context.HL, context.char, context.bold, context.tttf
local chars = tfmdata.characters
local descs = tfmdata.descriptions or { }
local data = characters.data
- sprint(tex.ctxcatcodes,format("\\setuptabulate[header=repeat]"))
- sprint(tex.ctxcatcodes,format("\\starttabulatehead"))
- sprint(tex.ctxcatcodes,"\\NC\\bf unicode\\NC\\bf visual\\NC\\bf index\\NC\\bf glyph\\NC\\bf adobe\\NC\\bf context\\NC\\NR")
- sprint(tex.ctxcatcodes,"\\HL")
- sprint(tex.ctxcatcodes,format("\\stoptabulatehead"))
- sprint(tex.ctxcatcodes,format("\\starttabulate[|l|c|l|p|p|p|]"))
+ -- context.setuptabulate { header = "repeat" }
+ context.starttabulatehead()
+ NC() bold("unicode")
+ NC() bold("visual")
+ NC() bold("index")
+ NC() bold("glyph")
+ NC() bold("adobe")
+ NC() bold("context")
+ NC() NR()
+ context.stoptabulatehead()
+ context.starttabulate { "|l|c|l|p|p|p|" }
for k, unicode in ipairs(table.sortedkeys(chars)) do
-- for unicode, _ in table.sortedpairs(chars) do
if unicode >= 0 then
@@ -77,22 +84,27 @@ function fonts.show_all()
cname = mname
end
end
- sprint(tex.ctxcatcodes,format("\\NC\\tttf U+%05X\\NC\\char%s\\NC\\tttf %05X\\NC\\tttf %s\\NC\\tttf %s\\NC\\tttf %s\\NC\\NR",unicode,unicode,index,gname,aname,cname))
+ NC() tttf() context("U+%05X",unicode)
+ NC() char(unicode)
+ NC() tttf() context("%05X",index)
+ NC() tttf() context(gname)
+ NC() tttf() context(aname)
+ NC() tttf() context(cname)
+ NC() NR()
end
end
- sprint(tex.ctxcatcodes,format("\\stoptabulate"))
+ context.stoptabulate()
else
- sprint(tex.ctxcatcodes,"problems")
+ context("problems")
end
end
function fonts.show_glyphs()
local tfmdata = fonts.ids[font.current()]
if tfmdata then
- local chars = tfmdata.characters
- for k, v in ipairs(table.sortedkeys(chars)) do
+ for k, v in ipairs(table.sortedkeys(tfmdata.characters)) do
if v >=0 then
- sprint(tex.ctxcatcodes,format("\\dontleavehmode{\\strut\\char%s}\\endgraf",v))
+ context.showglyph(v) -- local macro
end
end
end
@@ -120,6 +132,7 @@ end
\def\ShowAllGlyphs#1#2#3%
{\bgroup
\page
+ \def\showglyph##1{\dontleavehmode\strut\char##1\relax\par}
\font\TestFontA=#1 at 12pt
\font\TestFontB=#1 at #2
\setuplayout[style=\TestFontA]
@@ -139,7 +152,7 @@ end
\starttext
-% \ShowCompleteFont{name:dejavusansmono}{10pt}{2}
+% \ShowCompleteFont{name:dejavusansmono}{10pt}{1}
% \ShowCompleteFont{name:dejavuserif}{10pt}{2}
% \ShowCompleteFont{name:officinasansbookitcregular}{10pt}{2}
% \ShowCompleteFont{name:officinaserifbookitcregular}{10pt}{2}
diff --git a/tex/context/base/s-fnt-11.tex b/tex/context/base/s-fnt-11.tex
index 8f855cc72..f2171ecd0 100644
--- a/tex/context/base/s-fnt-11.tex
+++ b/tex/context/base/s-fnt-11.tex
@@ -26,19 +26,31 @@
function fonts.names.table(pattern,reload,all)
local t = fonts.names.list(pattern,reload)
if t then
- tex.sprint(tex.ctxcatcodes,"\\start\\nonknuthmode\\starttabulate[|T|T|T|T|T|]")
- tex.sprint(tex.ctxcatcodes,"\\NC hashname\\NC type\\NC fontname\\NC filename\\NC\\NR\\HL")
- for v,tv in table.sortedpairs(t) do
- local kind, name, file = tv[1], tv[2], tv[3]
- if all or v == string.lower(name) then
- if kind and name and file then
- tex.sprint(tex.ctxcatcodes,string.format("\\NC %s\\NC %s\\NC %s\\NC %s\\NC\\NR",v,kind,name,file))
- else
- logs.report("font table", "skipping %s", v)
+ local NC, NR, HL = context.NC, context.NR, context.HL
+ context.start()
+ context.nonknuthmode()
+ context.starttabulate { "|T|T|T|T|T|" }
+ NC(false,hashname)
+ NC(false,type)
+ NC(false,fontname)
+ NC(false,filename)
+ NC() NR() HL()
+ for v,tv in table.sortedpairs(t) do
+ local kind, name, file = tv[1], tv[2], tv[3]
+ if all or v == string.lower(name) then
+ if kind and name and file then
+ NC(false,v)
+ NC(false,kind)
+ NC(false,name)
+ NC(false,file)
+ NC() NR()
+ else
+ logs.report("font table", "skipping %s", v)
+ end
+ end
end
- end
- end
- tex.sprint(tex.ctxcatcodes,"\\stoptabulate\\stop")
+ context.stoptabulate()
+ context.stop()
end
end
\stopluacode
diff --git a/tex/context/base/s-fnt-24.tex b/tex/context/base/s-fnt-24.tex
index 073588033..de485557b 100644
--- a/tex/context/base/s-fnt-24.tex
+++ b/tex/context/base/s-fnt-24.tex
@@ -48,7 +48,7 @@ function fonts.analyzers.cjktest(first,second)
if (not first or first == "") or first == k then
for kk, vv in next, example do
if (not second or second == "") or second == kk then
- tex.sprint(tex.ctxcatcodes,string.format("\\ShowChineseCombiChar{%s}{%s}{%s}{%s}",v,vv,k,kk))
+ context.ShowChineseCombiChar(v,vv,k,kk)
end
end
end
diff --git a/tex/context/base/s-fnt-25.tex b/tex/context/base/s-fnt-25.tex
index 6f95d07c6..f04b31c28 100644
--- a/tex/context/base/s-fnt-25.tex
+++ b/tex/context/base/s-fnt-25.tex
@@ -75,14 +75,14 @@
{mathsymbol: #1~\ruledhbox{\char#2}\par}
\startluacode
+local concat = table.concat
+local format, lower = string.format, string.lower
+
function document.showmathfont(id,slot)
local data = characters.data
local tfmdata = fonts.ids[id]
local characters = tfmdata.characters
local sorted = (slot and { slot }) or table.sortedkeys(characters)
- local function report(...)
- tex.sprint(tex.ctxcatcodes,string.format(...))
- end
local virtual, names = tfmdata.type == "virtual", { }
if virtual then
for k, v in ipairs(tfmdata.fonts) do
@@ -91,17 +91,16 @@ function document.showmathfont(id,slot)
end
end
local round = math.round
--- print(table.serialize(names))
-local limited = true
+ local limited = true
for _, s in next, sorted do
if not limited or s < 0xF0000 then
local char = characters[s]
if char then
local info = data[s]
local cnext, cvert_variants, choriz_variants = char.next, char.vert_variants, char.horiz_variants
- report("\\startmathfontlistentry")
- report("\\mathfontlistentryhexdectit{U+%05X}{%s}{%s}",s,s,string.lower(info.description or "no description, private to font"))
- report("\\mathfontlistentrywdhtdpic{%s}{%s}{%s}{%s}",round(char.width or 0),round(char.height or 0),round(char.depth or 0),round(char.italic or 0))
+ context.startmathfontlistentry()
+ context.mathfontlistentryhexdectit(format("U+%05X",s),s,lower(info.description or "no description, private to font"))
+ context.mathfontlistentrywdhtdpic(round(char.width or 0),round(char.height or 0),round(char.depth or 0),round(char.italic or 0))
if virtual then
local commands = char.commands
if commands then
@@ -110,24 +109,24 @@ local limited = true
local ci = commands[i]
if ci[1] == "slot" then
local fnt, idx = ci[2], ci[3]
- t[#t+1] = string.format("%s/%0X",names[fnt] or fnt,idx)
+ t[#t+1] = format("%s/%0X",names[fnt] or fnt,idx)
end
end
if #t > 0 then
- report("\\mathfontlistentryresource{%s}",table.concat(t,", "))
+ context.mathfontlistentryresource(concat(t,", "))
end
end
end
if info.mathclass then
- report("\\mathfontlistentryclassname{%s}{%s}",info.mathclass,info.mathname or "no name")
+ context.mathfontlistentryclassname(info.mathclass,info.mathname or "no name")
end
if info.mathspec then
for i=1,#info.mathspec do
- report("\\mathfontlistentryclassname{%s}{%s}",info.mathspec[i].class,info.mathspec[i].name or "no name")
+ context.mathfontlistentryclassname(info.mathspec[i].class,info.mathspec[i].name or "no name")
end
end
if info.mathsymbol then
- report("\\mathfontlistentrysymbol{U+%05X}{%s}",info.mathsymbol,info.mathsymbol)
+ context.mathfontlistentrysymbol(format("U+%05X",info.mathsymbol),info.mathsymbol)
end
if cnext then
local t, done = { }, { }
@@ -137,7 +136,7 @@ local limited = true
break
else
done[cnext] = true
- t[#t+1] = string.format("\\mathfontlistentrynext{U+%05X}{%s}",cnext,cnext)
+ t[#t+1] = context.nested.mathfontlistentrynext(format("U+%05X",cnext),cnext)
cnext = characters[cnext]
cvert_variants = cnext.vert_variants or cvert_variants
choriz_variants = cnext.horiz_variants or choriz_variants
@@ -151,29 +150,29 @@ local limited = true
if cvert_variants then
local t = { }
for k, v in next, cvert_variants do
- t[#t+1] = string.format("\\fontlistentryvariants{U+%05X}{%s}",v.glyph,v.glyph)
+ t[#t+1] = context.nested.fontlistentryvariants(format("U+%05X",v.glyph),v.glyph)
end
cvert_variants = t
end
if choriz_variants then
local t = { }
for k, v in next, choriz_variants do
- t[#t+1] = string.format("\\fontlistentryvariants{U+%05X}{%s}",v.glyph,v.glyph)
+ t[#t+1] = context.nested.fontlistentryvariants(format("U+%05X",v.glyph),v.glyph)
end
choriz_variants = t
end
local cvariants = choriz_variants or cvert_variants
if cvariants and cnext then
- report("\\mathfontlistentrynextvariantslist{%s}{%s}",table.concat(cnext," => "),table.concat(cvariants," => "))
+ context.mathfontlistentrynextvariantslist(concat(cnext," => "),concat(cvariants," => "))
else
if cnext then
- report("\\mathfontlistentrynextlist{%s}",table.concat(cnext," => "))
+ context.mathfontlistentrynextlist(concat(cnext," => "))
end
if cvariants then
- report("\\mathfontlistentryvariantslist{%s}",table.concat(cvariants," "))
+ context.mathfontlistentryvariantslist(concat(cvariants," "))
end
end
- report("\\stopmathfontlistentry")
+ context.stopmathfontlistentry()
end
end
end
@@ -184,13 +183,13 @@ end
\starttext
\setupbodyfont[cambria, 12pt] \showmathfontcharacters
- \setupbodyfont[lmvirtual,12pt] \showmathfontcharacters
- \setupbodyfont[pxvirtual,12pt] \showmathfontcharacters
- \setupbodyfont[txvirtual,12pt] \showmathfontcharacters
- \setupbodyfont[palatino, 10pt] \showmathfontcharacters
- \setupbodyfont[mathtimes,12pt] \showmathfontcharacters
- \setupbodyfont[stix, 12pt] \showmathfontcharacters
- \setupbodyfont[xits, 12pt] \showmathfontcharacters
- \setupbodyfont[lucida, 12pt] \showmathfontcharacters
+% \setupbodyfont[lmvirtual,12pt] \showmathfontcharacters
+% \setupbodyfont[pxvirtual,12pt] \showmathfontcharacters
+% \setupbodyfont[txvirtual,12pt] \showmathfontcharacters
+% \setupbodyfont[palatino, 10pt] \showmathfontcharacters
+% \setupbodyfont[mathtimes,12pt] \showmathfontcharacters
+% \setupbodyfont[stix, 12pt] \showmathfontcharacters
+% \setupbodyfont[xits, 12pt] \showmathfontcharacters
+% \setupbodyfont[lucida, 12pt] \showmathfontcharacters
\stoptext
diff --git a/tex/context/base/s-fnt-30.tex b/tex/context/base/s-fnt-30.tex
index 81b6c8d19..1daf6806e 100644
--- a/tex/context/base/s-fnt-30.tex
+++ b/tex/context/base/s-fnt-30.tex
@@ -15,20 +15,23 @@
function document.show_character_data(n)
local n = characters.number(n)
local d = characters.data[n]
+ local NC, NR = context.NC, context.NR
if d then
local function entry(label,name)
- texsprint(tex.ctxcatcodes,format("\\NC %s\\NC %s\\NC\\NR",label,characters.valid(d[name])))
+ NC() context(label)
+ NC() context(characters.valid(d[name])
+ NC() NR()
end
- texsprint(tex.ctxcatcodes,"\\starttabulate[|Tl|Tl|]")
- entry("unicode index" , "unicodeslot")
- entry("context name" , "contextname")
- entry("adobe name" , "adobename")
- entry("category" , "category")
- entry("description" , "description")
- entry("uppercase code", "uccode")
- entry("lowercase code", "lccode")
- entry("specials" , "specials")
- texsprint(tex.ctxcatcodes,"\\stoptabulate ")
+ context.starttabulate { "|Tl|Tl|]" }
+ entry("unicode index" , "unicodeslot")
+ entry("context name" , "contextname")
+ entry("adobe name" , "adobename")
+ entry("category" , "category")
+ entry("description" , "description")
+ entry("uppercase code", "uccode")
+ entry("lowercase code", "lccode")
+ entry("specials" , "specials")
+ context.stoptabulate()
end
end
\stopluacode
diff --git a/tex/context/base/s-inf-01.tex b/tex/context/base/s-inf-01.tex
index a2a693ae2..cf8cca80e 100644
--- a/tex/context/base/s-inf-01.tex
+++ b/tex/context/base/s-inf-01.tex
@@ -15,7 +15,6 @@
\startluacode
local format, gsub, find, match = string.format, string.gsub, string.find, string.match
- local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
local list, size, comp, used, nope = { }, { }, { }, { mkii = { }, mkiv = { } }, { 0, 0, 0, 0 }
@@ -105,8 +104,10 @@
function document.context_state_1(what)
local max, what, norm = prepare(what)
- texsprint(ctxcatcodes,"\\starttabulate[|Tc|T|T|T|T|]")
- texsprint(ctxcatcodes,"\\NC category\\NC")
+ context.starttabulate { "|Tc|T|T|T|T|]" }
+ context.NC()
+ context(category)
+ context.NC()
for i, t in ipairs(types) do
local n, m = 0, 0
for k, v in pairs(list) do
@@ -114,30 +115,35 @@
n = n + nn
m = m + (mm or nn)
end
- texsprint(ctxcatcodes,format("\\Top{%s}{%s}{%s}{%s}\\NC",t,norm(max),n,m))
+ context.Top(t,norm(max),n,m)
+ context.NC()
end
- texsprint(ctxcatcodes,"\\NC\\NR\\HL")
+ context.NC()
+ context.NR()
+ context.HL()
for k, v in table.sortedpairs(what) do
local c = (what == size and comp[k]) or nope
- local cat = format("%s~%s~~%s",(used.mkii[k] and "ii") or "~~",(used.mkiv[k] and "iv") or "~~",k)
- texsprint(ctxcatcodes,"\\NC",cat,"\\NC")
+ context.NC()
+ context("%s~%s~~%s",(used.mkii[k] and "ii") or "~~",(used.mkiv[k] and "iv") or "~~",k)
+ context.NC()
for i, t in ipairs(types) do
- texsprint(ctxcatcodes,format("\\Bar{%s}{%s}{%s}{%s}\\NC",t,v[i],c[i],norm(v[i])))
+ context.Bar(t,v[i],c[i],norm(v[i]))
+ context.NC()
end
- texsprint(ctxcatcodes,"\\NR")
+ context.NR()
end
- texsprint(ctxcatcodes,"\\stoptabulate")
+ context.stoptabulate()
end
function document.context_state_2(what)
local max, what, norm = prepare(what)
for k, v in table.sortedpairs(what) do
local c = (what == size and comp[k]) or nope
- texsprint(ctxcatcodes,format("\\StartUp{%s}",k))
+ context.StartUp(k)
for i, t in ipairs(types) do
- texsprint(ctxcatcodes,format("\\Up{%s}{%s}",t,norm(v[i])))
+ context.Up(t,norm(v[i]))
end
- texsprint(ctxcatcodes,"\\StopUp")
+ context.StopUp()
end
end
diff --git a/tex/context/base/s-reg-01.tex b/tex/context/base/s-reg-01.tex
index 123b97384..5ed86cb4e 100644
--- a/tex/context/base/s-reg-01.tex
+++ b/tex/context/base/s-reg-01.tex
@@ -26,15 +26,26 @@ function regimes.show(regime)
regime = regimes.synonyms[regime] or regime
local r = regimes.data[regime]
if r then
- tex.sprint(tc,"\\starttabulate[|rT|T|rT|lT|lT|lT|]")
+ context.starttabulate { "|rT|T|rT|lT|lT|lT|" }
for k, v in ipairs(r) do
- tex.sprint(tex.ctxcatcodes, string.format("\\NC %s\\NC\\getvalue{%s}\\NC %s\\NC %s\\NC %s\\NC %s\\NC\\NR", k,
- characters.contextname(v), characters.hexindex(v), characters.contextname(v),
- characters.category(v), characters.description(v)))
+ context.NC()
+ context(k)
+ context.NC()
+ context.getvalue(characters.contextname(v))
+ context.NC()
+ context(characters.hexindex(v))
+ context.NC()
+ context(characters.contextname(v))
+ context.NC()
+ context(characters.category(v))
+ context.NC()
+ context(characters.description(v))
+ context.NC()
+ context.NR()
end
- tex.sprint(tex.ctxcatcodes,"\\stoptabulate")
+ context.stoptabulate()
else
- tex.sprint(tex.ctxcatcodes,"unknown regime " .. regime)
+ context("unknown regime %s",regime)
end
end
\stopluacode
diff --git a/tex/context/base/s-sys-01.tex b/tex/context/base/s-sys-01.tex
deleted file mode 100644
index 77d3410c4..000000000
--- a/tex/context/base/s-sys-01.tex
+++ /dev/null
@@ -1,61 +0,0 @@
-% engine=luatex
-
-%D \module
-%D [ file=s-sys-01,
-%D version=2008.03.32,
-%D title=\CONTEXT\ Style File,
-%D subtitle=Generate List of Math Symbol,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\startluacode
-function showmath()
- local slots = mathematics.slots.traditional
- local escape = characters.filters.utf.private.escape
- local data = characters.data
- tex.sprint(tex.ctxcatcodes,"\\starttabulate[|T|c|T|T|T|T||||]")
- local texsprint = tex.sprint
-% -- function texsprint(a,b) print(b) end
- for _, v in ipairs(table.sortedkeys(slots)) do
- local t, d, u = slots[v], data[v], escape(utf.char(v))
- local class, name, description = d.mathclass or "", d.mathname or "" , d.description or ""
- if class == "accent" then
- u = ""
- end
- if t[3] and t[4] then
- texsprint(tex.ctxcatcodes,string.format(
- "\\NC 0x%04X\\NC $%s$\\NC %s\\NC 0x%04X\\NC %s\\NC 0x%04X\\NC %s\\NC %s\\NC %s\\NC\\NR",
- v,u,t[1],t[2],t[3],t[4],class,name,description))
- else
- texsprint(tex.ctxcatcodes,string.format(
- "\\NC 0x%04X\\NC $%s$\\NC %s\\NC 0x%04X\\NC\\NC\\NC %s\\NC %s\\NC %s\\NC\\NR",
- v,u,t[1],t[2],class,name,description))
- end
- end
- tex.sprint(tex.ctxcatcodes,"\\stoptabulate")
-end
-\stopluacode
-
-\setuplayout
- [backspace=1cm,
- topspace=1cm,
- footer=1cm,
- header=0cm,
- height=middle,
- width=middle]
-
-\setupbodyfont
- [9pt]
-
-\setupfootertexts
- []
- [math characters -- \pagenumber]
-
-\starttext
-\ctxlua{showmath()}
-\stoptext
diff --git a/tex/context/base/scrn-int.lua b/tex/context/base/scrn-int.lua
index 556ead7c5..7bb1a7a66 100644
--- a/tex/context/base/scrn-int.lua
+++ b/tex/context/base/scrn-int.lua
@@ -6,9 +6,6 @@ if not modules then modules = { } end modules ['scrn-int'] = {
license = "see context related readme files"
}
-local format = string.format
-local texsprint, texcount, ctxcatcodes = tex.sprint, tex.count, tex.ctxcatcodes
-
interactions = interactions or { }
local interactions = interactions
@@ -47,7 +44,7 @@ end
function attachments.var(label,key)
local at = attachments[label]
- texsprint(ctxcatcodes,at and at[key] or "")
+ context(at and at[key] or "")
end
function soundclips.register(specification)
@@ -87,7 +84,7 @@ end
function renderings.var(label,key)
local rn = renderings[label]
- texsprint(ctxcatcodes,rn and rn[key] or "")
+ context(rn and rn[key] or "")
end
-- linked lists
diff --git a/tex/context/base/scrn-men.mkiv b/tex/context/base/scrn-men.mkiv
index 3ab7e3e22..1e987f098 100644
--- a/tex/context/base/scrn-men.mkiv
+++ b/tex/context/base/scrn-men.mkiv
@@ -93,7 +93,7 @@
\def\dodefineinteractionmenu[#1][#2][#3]% [name] [location] [settings|parent] % right right vertical
{\ifsecondargument
\ifcsname\??am:\c!list:#2\endcsname \else
- \letvalue{\??am:\c!list:#2}\empty
+ \letvalueempty{\??am:\c!list:#2}%
\fi
\normalexpanded{\noexpand\addtocommalist{#1}\@EA\noexpand\csname\??am:\c!list:#2\endcsname}%
\setvalue{\@@dodolistelement#1}{\def\dosomelistelement{\dodomenulistelement{#1}}}%
diff --git a/tex/context/base/spac-hor.lua b/tex/context/base/spac-hor.lua
index 6cb6e3f49..09920bd46 100644
--- a/tex/context/base/spac-hor.lua
+++ b/tex/context/base/spac-hor.lua
@@ -26,7 +26,6 @@ function commands.autonextspace(str) -- todo: use nexttoken
local ch = match(str,"the letter (.)") or match(str,"the character (.)")
ch = ch and chardata[utfbyte(ch)]
if ch and can_have_space[ch.category] then
- -- texsprint(ctxcatcodes,"\\space") -- faster
context.space()
end
end
diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua
index 5eb9b3683..d58eaa329 100644
--- a/tex/context/base/spac-ver.lua
+++ b/tex/context/base/spac-ver.lua
@@ -22,7 +22,7 @@ if not modules then modules = { } end modules ['spac-ver'] = {
local next, type, tonumber = next, type, tonumber
local format, gmatch, concat, match, rep = string.format, string.gmatch, table.concat, string.match, string.rep
local ceil, floor, max, min, round, abs = math.ceil, math.floor, math.max, math.min, math.round, math.abs
-local texsprint, texlists, texdimen, texbox = tex.sprint, tex.lists, tex.dimen, tex.box
+local texlists, texdimen, texbox = tex.lists, tex.dimen, tex.box
local lpegmatch = lpeg.match
local unpack = unpack or table.unpack
local points = number.points
@@ -30,9 +30,8 @@ local allocate = utilities.storage.allocate
local P, C, R, S, Cc = lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.Cc
-local nodes, node, trackers, attributes = nodes, node, trackers, attributes
+local nodes, node, trackers, attributes, context = nodes, node, trackers, attributes, context
-local ctxcatcodes = tex.ctxcatcodes
local variables = interfaces.variables
local starttiming = statistics.starttiming
@@ -527,11 +526,6 @@ storage.register("builders/vspacing/data/skip", vspacing.data.skip, "builders.vs
do -- todo: interface.variables
- local function logger(c,...)
- report_vspacing(concat {...})
- texsprint(c,...)
- end
-
vspacing.fixed = false
local map = vspacing.data.map
@@ -547,7 +541,7 @@ do -- todo: interface.variables
-- This will change: just node.write and we can store the values in skips which
-- then obeys grouping
- local function analyze(str,oldcategory,texsprint) -- we could use shorter names
+ local function analyze(str,oldcategory) -- we could use shorter names
for s in gmatch(str,"([^ ,]+)") do
local amount, keyword, detail = lpegmatch(splitter,s)
if not keyword then
@@ -555,37 +549,37 @@ do -- todo: interface.variables
else
local mk = map[keyword]
if mk then
- category = analyze(mk,category,texsprint)
+ category = analyze(mk,category)
elseif keyword == k_fixed then
- texsprint(ctxcatcodes,"\\fixedblankskip")
+ context.fixedblankskip()
elseif keyword == k_flexible then
- texsprint(ctxcatcodes,"\\flexibleblankskip")
+ context.flexibleblankskip()
elseif keyword == k_category then
local category = tonumber(detail)
if category then
- texsprint(ctxcatcodes,"\\setblankcategory{",category,"}")
+ context.setblankcategory(category)
if category ~= oldcategory then
- texsprint(ctxcatcodes,"\\flushblankhandling")
+ context.flushblankhandling()
oldcategory = category
end
end
elseif keyword == k_order and detail then
local order = tonumber(detail)
if order then
- texsprint(ctxcatcodes,"\\setblankorder{",order,"}")
+ context.setblankorder(order)
end
elseif keyword == k_penalty and detail then
local penalty = tonumber(detail)
if penalty then
- texsprint(ctxcatcodes,"\\setblankpenalty{",penalty,"}")
+ context.setblankpenalty(penalty)
end
else
amount = tonumber(amount) or 1
local sk = skip[keyword]
if sk then
- texsprint(ctxcatcodes,"\\addpredefinedblankskip{",amount,"}{",keyword,"}")
+ context.addpredefinedblankskip(amount,keyword)
else -- no check
- texsprint(ctxcatcodes,"\\addaskedblankskip{",amount,"}{",keyword,"}")
+ context.addaskedblankskip(amount,keyword)
end
end
end
@@ -594,10 +588,15 @@ do -- todo: interface.variables
end
function vspacing.analyze(str)
- local texsprint = (trace_vspacing and logger) or texsprint
- texsprint(ctxcatcodes,"\\startblankhandling")
- analyze(str,1,texsprint)
- texsprint(ctxcatcodes,"\\stopblankhandling")
+ if trace_vspacing then
+ context.pushlogger(report_vspacing)
+ end
+ context.startblankhandling()
+ analyze(str,1)
+ context.stopblankhandling()
+ if trace_vspacing then
+ context.poplogger()
+ end
end
--
diff --git a/tex/context/base/strc-bkm.lua b/tex/context/base/strc-bkm.lua
index f9ce93eef..87327618c 100644
--- a/tex/context/base/strc-bkm.lua
+++ b/tex/context/base/strc-bkm.lua
@@ -14,8 +14,7 @@ if not modules then modules = { } end modules ['strc-bkm'] = {
-- we should hook the placement into everystoptext ... needs checking
local format, concat, gsub = string.format, table.concat, string.gsub
-local texsprint, utfvalues = tex.sprint, string.utfvalues
-local ctxcatcodes = tex.ctxcatcodes
+local utfvalues = string.utfvalues
local settings_to_hash = utilities.parsers.settings_to_hash
local codeinjections = backends.codeinjections
diff --git a/tex/context/base/strc-blk.lua b/tex/context/base/strc-blk.lua
index b3a36306e..d02fdeb7b 100644
--- a/tex/context/base/strc-blk.lua
+++ b/tex/context/base/strc-blk.lua
@@ -8,14 +8,13 @@ if not modules then modules = { } end modules ['strc-blk'] = {
-- this one runs on top of buffers and structure
-local texprint, format, gmatch, find = tex.print, string.format, string.gmatch, string.find
+local type = type
+local gmatch, find = string.gmatch, string.find
local lpegmatch = lpeg.match
local settings_to_set, settings_to_array = utilities.parsers.settings_to_set, utilities.parsers.settings_to_array
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
-local ctxcatcodes = tex.ctxcatcodes
-
-local structures = structures
+local structures, context = structures, context
structures.blocks = structures.blocks or { }
@@ -36,25 +35,25 @@ end
job.register('structures.blocks.collected', tobesaved, initializer)
-local printer = (lpeg.patterns.textline/texprint)^0 -- can be shared
+local printer = (lpeg.patterns.textline/tex.print)^0 -- can be shared
function blocks.print(name,data,hide)
if hide then
- texprint(ctxcatcodes,format("\\dostarthiddenblock{%s}",name))
+ context.dostarthiddenblock(name)
else
- texprint(ctxcatcodes,format("\\dostartnormalblock{%s}",name))
+ context.dostartnormalblock(name)
end
if type(data) == "table" then
for i=1,#data do
- texprint(data[i])
+ context(data[i])
end
else
lpegmatch(printer,data)
end
if hide then
- texprint(ctxcatcodes,"\\dostophiddenblock")
+ context.dostophiddenblock()
else
- texprint(ctxcatcodes,"\\dostopnormalblock")
+ context.dostopnormalblock()
end
end
diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua
index d1048972b..322322e2a 100644
--- a/tex/context/base/strc-doc.lua
+++ b/tex/context/base/strc-doc.lua
@@ -27,7 +27,7 @@ local trace_detail = false trackers.register("structures.detail", funct
local report_structure = logs.new("structure")
-local structures = structures
+local structures, context = structures, context
local helpers = structures.helpers
local documents = structures.documents
@@ -156,7 +156,7 @@ function sections.getlevel(name)
end
function sections.way(way,by)
- texsprint(ctxcatcodes,(gsub(way,"^"..by,"")))
+ context((gsub(way,"^"..by,"")))
end
function sections.setblock(name)
@@ -385,7 +385,7 @@ end
function sections.cct()
local metadata = data.status[data.depth].metadata
- texsprint((metadata and metadata.catcodes) or ctxcatcodes)
+ context(metadata and metadata.catcodes or ctxcatcodes)
end
function sections.structuredata(depth,key,default,honorcatcodetable) -- todo: spec table and then also depth
@@ -405,20 +405,20 @@ function sections.structuredata(depth,key,default,honorcatcodetable) -- todo: sp
local metadata = data.metadata
texsprint((metadata and metadata.catcodes) or ctxcatcodes,d)
elseif not honorcatcodetable then
- texsprint(ctxcatcodes,d)
+ context(d)
elseif type(honorcatcodetable) == "number" then
texsprint(honorcatcodetable,d)
elseif type(honorcatcodetable) == "string" and honorcatcodetable ~= "" then
honorcatcodetable = tex[honorcatcodetable] or ctxcatcodes-- we should move ctxcatcodes to another table, ctx or so
texsprint(honorcatcodetable,d)
else
- texsprint(ctxcatcodes,d)
+ context(d)
end
return
end
end
if default then
- texsprint(ctxcatcodes,default)
+ context(default)
end
end
@@ -429,7 +429,7 @@ function sections.userdata(depth,key,default)
userdata = userdata and userdata.userdata
userdata = (userdata and userdata[key]) or default
if userdata then
- texsprint(ctxcatcodes,userdata)
+ context(userdata)
end
end
end
@@ -510,8 +510,7 @@ local function process(index,numbers,ownnumbers,criterium,separatorset,conversio
if ownnumber ~= "" then
sprintprocessor(ctxcatcodes,ownnumber)
elseif conversion and conversion ~= "" then -- traditional (e.g. used in itemgroups)
- texsprint(ctxcatcodes,format("\\convertnumber{%s}{%s}",conversion,number))
- -- context.convertnumber(conversion,number)
+ context.convertnumber(conversion,number)
else
local theconversion = sets.get("structure:conversions",block,conversionset,index,"numbers")
sprintprocessor(ctxcatcodes,theconversion,function(str)
@@ -767,8 +766,7 @@ end
--~ if ownnumber ~= "" then
--~ sprintprocessor(ctxcatcodes,ownnumber)
--~ elseif conversion and conversion ~= "" then -- traditional (e.g. used in itemgroups)
---~ texsprint(ctxcatcodes,format("\\convertnumber{%s}{%s}",conversion,number))
---~ --~ context.convertnumber(conversion,number)
+--~ context.convertnumber(conversion,number)
--~ else
--~ local theconversion = sets.get("structure:conversions",block,conversionset,index,"numbers")
--~ sprintprocessor(ctxcatcodes,theconversion,function(str)
diff --git a/tex/context/base/strc-doc.mkiv b/tex/context/base/strc-doc.mkiv
index 154466dfe..972e50f78 100644
--- a/tex/context/base/strc-doc.mkiv
+++ b/tex/context/base/strc-doc.mkiv
@@ -211,6 +211,7 @@
\def\structurevariable #1{\ctxlua{structures.sections.structuredata(nil,"#1")}}
\def\structureuservariable #1{\ctxlua{structures.sections.userdata(nil,"#1")}}
\def\structurenumber {\ctxlua{structures.sections.fullnumber()}}
+\def\structuretitle {\ctxlua{structures.sections.title()}}
\def\structurecatcodedget #1{\ctxlua{structures.sections.structuredata(nil,"#1",nil,true)}} % bad name
\def\structuregivencatcodedget#1#2{\ctxlua{structures.sections.structuredata(nil,"#1",nil,\number#2)}} % bad name
\def\structureautocatcodedget #1#2{\ctxlua{structures.sections.structuredata(nil,"#1",nil,"#2")}}
diff --git a/tex/context/base/strc-ini.lua b/tex/context/base/strc-ini.lua
index 164b60f33..00130b922 100644
--- a/tex/context/base/strc-ini.lua
+++ b/tex/context/base/strc-ini.lua
@@ -142,8 +142,6 @@ local function simplify(d,nodefault)
t[k] = v
end
end
---~ print(table.serialize(d,"before"))
---~ print(table.serialize(t,"after"))
return next(t) and t
elseif nodefault then
return nil
@@ -181,29 +179,29 @@ local tags = {
function helpers.title(title,metadata) -- coding is xml is rather old and not that much needed now
if title and title ~= "" then -- so it might disappear
if metadata then
- if metadata.coding == "xml" then -- title can contain raw xml
+ local xmlsetup = metadata.xmlsetup
+ if metadata.coding == "xml" then
+ -- title can contain raw xml
local tag = tags[metadata.kind] or tags.generic
local xmldata = format("<?xml version='1.0'?><%s>%s</%s>",tag,title,tag)
- local command = format("\\xmlprocessbuffer{%s}{%s}{%s}","dummy",tag,metadata.xmlsetup or "")
buffers.set(tag,xmldata)
if trace_processors then
- report_processors("xmldata: %s",xmldata)
- report_processors("feeding: %s",command)
+ report_processors("putting xml data in buffer: %s",xmldata)
+ report_processors("processing buffer with setup '%s' and tag '%s'",xmlsetup or "",tag)
end
- texsprint(ctxcatcodes,command)
- elseif metadata.xmlsetup then -- title is reference to node (so \xmlraw should have been used)
- local command = format("\\xmlsetup{%s}{%s}",title,metadata.xmlsetup)
+ context.xmlprocessbuffer("dummy",tag,xmlsetup or "")
+ elseif xmlsetup then -- title is reference to node (so \xmlraw should have been used)
if trace_processors then
- report_processors("feeding: %s",command)
+ report_processors("feeding xmlsetup '%s' using node '%s'",xmlsetup,title)
end
- texsprint(ctxcatcodes,command)
+ context.xmlsetup(title,metadata.xmlsetup)
else
local catcodes = metadata.catcodes
if catcodes == notcatcodes or catcodes == xmlcatcodes then
if trace_processors then
report_processors("cct: %s (overloads %s), txt: %s",ctxcatcodes,catcodes,title)
end
- texsprint(ctxcatcodes,title) -- nasty
+ context(title) -- nasty
else
if trace_processors then
report_processors("cct: %s, txt: %s",catcodes,title)
@@ -217,7 +215,7 @@ function helpers.title(title,metadata) -- coding is xml is rather old and not th
end
end
--- -- -- processors -- -- -- syntax: processor->data
+-- -- -- processors -- -- -- syntax: processor->data ... not ok yet
local processors = structures.processors
@@ -242,7 +240,7 @@ function processors.split(str)
end
end
-function processors.sprint(catcodes,str,fnc,...)
+function processors.sprint(catcodes,str,fnc,...) -- not ok: mixed
local p, s = lpegmatch(splitter,str)
local code
if registered[p] then
diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua
index 428bd8710..9709e7180 100644
--- a/tex/context/base/strc-lst.lua
+++ b/tex/context/base/strc-lst.lua
@@ -406,8 +406,7 @@ function lists.process(specification)
local r = lists.result[i]
local m = r.metadata
local s = specials and r.numberdata and specials[table.zerostrippedconcat(r.numberdata.numbers,".")] or ""
- texsprint(ctxcatcodes,format("\\processlistofstructure{%s}{%s}{%i}{%s}",m.name,m.kind,i,s))
---~ context.processlistofstructure(m.name,m.kind,i,s)
+ context.processlistofstructure(m.name,m.kind,i,s)
end
end
@@ -478,7 +477,6 @@ function lists.savedtitle(name,n,tag)
local titledata = data.titledata
if titledata then
helpers.title(titledata[tag] or titledata.title or "",data.metadata)
---~ texsprint(ctxcatcodes,titledata[tag] or titledata.title or "")
end
end
end
diff --git a/tex/context/base/strc-not.lua b/tex/context/base/strc-not.lua
index 123a03807..a5e9f1ad0 100644
--- a/tex/context/base/strc-not.lua
+++ b/tex/context/base/strc-not.lua
@@ -8,9 +8,7 @@ if not modules then modules = { } end modules ['strc-not'] = {
local format = string.format
local next = next
-local texsprint, texwrite, texcount = tex.sprint, tex.write, tex.count
-
-local ctxcatcodes = tex.ctxcatcodes
+local texcount = tex.count
local trace_notes = false trackers.register("structures.notes", function(v) trace_notes = v end)
@@ -33,6 +31,7 @@ local notestates = notes.states
local notedata = { }
local variables = interfaces.variables
+local context = context
-- state: store, insert, postpone
@@ -51,7 +50,7 @@ function notes.store(tag,n)
end
state.start = state.start or nnd
end
- texwrite(#nd)
+ context(#nd)
end
local function get(tag,n)
@@ -140,7 +139,7 @@ end
function notes.getstate(tag)
local state = notestates[tag]
- texsprint(ctxcatcodes,(state and state.kind ) or "unknown")
+ context(state and state.kind or "unknown")
end
function notes.doifcontent(tag)
@@ -235,7 +234,7 @@ function notes.deltapage(tag,n)
what = 3
end
end
- texwrite(what)
+ context(what)
end
function notes.postpone()
@@ -268,7 +267,7 @@ function notes.getsymbolpage(tag,n)
if trace_notes then
report_notes("note %s of '%s' has page %s",n,tag,p)
end
- texwrite(p)
+ context(p)
end
function notes.getnumberpage(tag,n)
@@ -276,7 +275,7 @@ function notes.getnumberpage(tag,n)
li = li and li.pagenumber
li = li and li.numbers
li = li and li[1]
- texwrite(li or 0)
+ context(li or 0)
end
function notes.flush(tag,whatkind,how) -- store and postpone
@@ -291,7 +290,7 @@ function notes.flush(tag,whatkind,how) -- store and postpone
report_notes("flushing state %s of %s from %s to %s",whatkind,tag,ns,#nd)
end
for i=ns,#nd do
- texsprint(ctxcatcodes,format("\\handlenoteinsert{%s}{%s}",tag,i))
+ context.handlenoteinsert(tag,i)
end
end
state.start = nil
@@ -303,20 +302,20 @@ function notes.flush(tag,whatkind,how) -- store and postpone
end
-- todo: as registers: start, stop, inbetween
for i=ns,#nd do
--- tricky : trialtypesetting
-if how == variables.page then
- local rp = get(tag,i)
- rp = rp and rp.references
- rp = rp and rp.symbolpage or 0
- if rp > texcount.realpageno then
- state.start = i
- return
- end
-end
+ -- tricky : trialtypesetting
+ if how == variables.page then
+ local rp = get(tag,i)
+ rp = rp and rp.references
+ rp = rp and rp.symbolpage or 0
+ if rp > texcount.realpageno then
+ state.start = i
+ return
+ end
+ end
if i > ns then
- texsprint(ctxcatcodes,format("\\betweennoteitself{%s}",tag))
+ context.betweennoteitself(tag)
end
- texsprint(ctxcatcodes,format("\\handlenoteitself{%s}{%s}",tag,i))
+ context.handlenoteitself(tag,i)
end
end
state.start = nil
diff --git a/tex/context/base/strc-num.mkiv b/tex/context/base/strc-num.mkiv
index d2ed5dad1..32fcc9e7f 100644
--- a/tex/context/base/strc-num.mkiv
+++ b/tex/context/base/strc-num.mkiv
@@ -59,8 +59,6 @@
\def\autostructureprefixsegments#1% todo: \c!prefixsegments=\v!auto
{2:\thenamedstructureheadlevel{\ctxlua{structures.sections.way("#1\c!way","\v!by")}}}
-% \letvalue{\??nn\s!empty}\empty
-
\def\structurecounterparameter#1#2%
{\csname
\ifcsname\??nn#1#2\endcsname
diff --git a/tex/context/base/strc-pag.lua b/tex/context/base/strc-pag.lua
index fde2de942..3dc70b6a3 100644
--- a/tex/context/base/strc-pag.lua
+++ b/tex/context/base/strc-pag.lua
@@ -9,7 +9,6 @@ if not modules then modules = { } end modules ['strc-pag'] = {
local texcount, format = tex.count, string.format
local ctxcatcodes = tex.ctxcatcodes
-local texsprint, texwrite = tex.sprint, tex.write
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
local trace_pages = false trackers.register("structures.pages", function(v) trace_pages = v end)
@@ -28,6 +27,7 @@ local counters = structures.counters
local counterdata = counters.data
local variables = interfaces.variables
+local context = context
-- storage
@@ -94,7 +94,7 @@ function pages.number(realdata,pagespec)
processors.sprint(ctxcatcodes,starter)
end
if conversion ~= "" then
- texsprint(ctxcatcodes,format("\\convertnumber{%s}{%s}",conversion,userpage))
+ context.convertnumber(conversion,userpage)
else
if conversionset == "" then conversionset = "default" end
local theconversion = sets.get("structure:conversions",block,conversionset,1,"numbers") -- to be checked: 1
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index 12b4b2558..459cbb9bb 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['strc-ref'] = {
local format, find, gmatch, match, concat = string.format, string.find, string.gmatch, string.match, table.concat
local lpegmatch, lpegP, lpegCs = lpeg.match, lpeg.P, lpeg.Cs
-local texsprint, texwrite, texcount, texsetcount = tex.sprint, tex.write, tex.count, tex.setcount
+local texcount, texsetcount = tex.count, tex.setcount
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
local setmetatable, rawget = setmetatable, rawget
@@ -18,9 +18,9 @@ local trace_referencing = false trackers.register("structures.referencing", fun
local report_references = logs.new("references")
-local ctxcatcodes = tex.ctxcatcodes
local variables = interfaces.variables
local constants = interfaces.constants
+local context = context
local settings_to_array = utilities.parsers.settings_to_array
local unsetvalue = attributes.unsetvalue
@@ -188,7 +188,7 @@ function references.setnextinternal(kind,name)
end
function references.currentorder(kind,name)
- texwrite((orders[kind] and orders[kind][name]) or lastorder)
+ context(orders[kind] and orders[kind][name] or lastorder)
end
function references.set(kind,prefix,tag,data)
@@ -206,7 +206,7 @@ function references.set(kind,prefix,tag,data)
tobesaved[prefix] = pd
end
pd[ref] = data
- texsprint(ctxcatcodes,format("\\dofinish%sreference{%s}{%s}",kind,prefix,ref))
+ context.dofinishsomereference(kind,prefix,ref)
end
end
end
@@ -352,9 +352,9 @@ function references.urls.get(name,method,space) -- method: none, before, after,
if u then
local url, file = u[1], u[2]
if file and file ~= "" then
- texsprint(ctxcatcodes,url,"/",file)
+ context("%s/%s",url,file)
else
- texsprint(ctxcatcodes,url)
+ context(url)
end
end
end
@@ -379,7 +379,7 @@ end
function references.files.get(name,method,space) -- method: none, before, after, both, space: yes/no
local f = files[name]
if f then
- texsprint(ctxcatcodes,f[1])
+ context(f[1])
end
end
@@ -452,7 +452,7 @@ end
function references.programs.get(name)
local f = programs[name]
if f then
- texsprint(ctxcatcodes,f[1])
+ context(f[1])
end
end
@@ -470,7 +470,7 @@ end
-- shared by urls and files
function references.whatfrom(name)
- texsprint(ctxcatcodes,(urls[name] and variables.url) or (files[name] and variables.file) or variables.unknown)
+ context((urls[name] and variables.url) or (files[name] and variables.file) or variables.unknown)
end
--~ function references.from(name)
@@ -478,21 +478,21 @@ end
--~ if u then
--~ local url, file, description = u[1], u[2], u[3]
--~ if description ~= "" then
---~ texsprint(ctxcatcodes,format("\\dofromurldescription{%s}",description))
+--~ context.dofromurldescription(description)
--~ -- ok
--~ elseif file and file ~= "" then
---~ texsprint(ctxcatcodes,format("\\dofromurlliteral{%s}",url .. "/" .. file))
+--~ context.dofromurlliteral(url .. "/" .. file)
--~ else
---~ texsprint(ctxcatcodes,format("\\dofromurlliteral{%s}",url))
+--~ context(dofromurlliteral,url)
--~ end
--~ else
--~ local f = files[name]
--~ if f then
--~ local description, file = f[1], f[2]
--~ if description ~= "" then
---~ texsprint(ctxcatcodes,format("\\dofromfiledescription{%s}",description))
+--~ context.dofromfiledescription(description)
--~ else
---~ texsprint(ctxcatcodes,format("\\dofromfileliteral{%s}",file))
+--~ context.dofromfileliteral(file)
--~ end
--~ end
--~ end
@@ -792,25 +792,25 @@ function references.expandcurrent() -- todo: two booleans: o_has_tex& a_has_tex
if operation then
if find(operation,"\\") then -- if o_has_tex then
if not done then
- texsprint(ctxcatcodes,b)
+ context(b)
done = true
end
- texsprint(ctxcatcodes,format(o,i,operation))
+ context(o,i,operation)
end
end
local arguments = ci.arguments
if arguments then
if find(arguments,"\\") then -- if a_has_tex then
if not done then
- texsprint(ctxcatcodes,b)
+ context(b)
done = true
end
- texsprint(ctxcatcodes,format(a,i,arguments))
+ context(a,i,arguments)
end
end
end
if done then
- texsprint(ctxcatcodes,e)
+ context(e)
end
end
end
@@ -1186,7 +1186,7 @@ end
function references.getinternalreference(n) -- n points into list (todo: registers)
local l = lists.collected[n]
- texsprint(ctxcatcodes,(l and l.references.internal) or n)
+ context(l and l.references.internal or n)
end
--
@@ -1195,7 +1195,7 @@ function references.getcurrentmetadata(tag)
local data = currentreference and currentreference.i
data = data and data.metadata and data.metadata[tag]
if data then
- texsprint(ctxcatcodes,data)
+ context(data)
end
end
@@ -1207,16 +1207,9 @@ end
references.currentmetadata = currentmetadata
function references.getcurrentprefixspec(default) -- todo: message
- texsprint(ctxcatcodes,"\\getreferencestructureprefix{",
- currentmetadata("kind") or "?", "}{", currentmetadata("name") or "?", "}{", default or "?", "}")
+ context.getreferencestructureprefix(currentmetadata("kind") or "?",currentmetadata("name") or "?",default or "?")
end
---~ function references.getcurrentprefixspec(default) -- we can consider storing the data at the lua end
---~ context.getreferencestructureprefix(currentmetadata("kind"),currentmetadata("name"),default)
---~ end
-
---
-
function references.filter(name,...) -- number page title ...
local data = currentreference and currentreference.i
if data then
@@ -1270,7 +1263,7 @@ function filters.generic.number(data,what,prefixspec) -- todo: spec and then no
else
local useddata = data.useddata
if useddata and useddsta.number then
- tex.sprint(tex.ctxcatcodes,useddata.number)
+ context(useddata.number)
end
end
end
@@ -1285,9 +1278,9 @@ function filters.generic.page(data,prefixspec,pagespec)
if not number then
-- error
elseif conversion then
- tex.sprint(tex.ctxcatcodes,format("\\convertnumber{%s}{%s}",conversion,number))
+ context.convertnumber(conversion,number)
else
- tex.sprint(tex.ctxcatcodes,number)
+ context(number)
end
else
helpers.prefixpage(data,prefixspec,pagespec)
@@ -1310,7 +1303,7 @@ function filters.user.unknown(data,name)
end
local namedata = userdata and userdata[name]
if namedata then
- texsprint(ctxcatcodes,namedata)
+ context(namedata)
end
end
end
@@ -1318,12 +1311,10 @@ end
filters.text = { }
function filters.text.title(data)
--- texsprint(ctxcatcodes,"[text title]")
helpers.title(data.entries.text or "?",data.metadata)
end
function filters.text.number(data)
--- texsprint(ctxcatcodes,"[text number]")
helpers.title(data.entries.text or "?",data.metadata)
end
@@ -1341,7 +1332,7 @@ function filters.section.number(data,what,prefixspec)
else
local useddata = data.useddata
if useddata and useddata.number then
- tex.sprint(tex.ctxcatcodes,useddata.number)
+ context(useddata.number)
end
end
end
@@ -1405,7 +1396,7 @@ end
function references.realpage() -- special case, we always want result
local cs = references.analyze()
- texwrite(cs.realpage or 0)
+ context(cs.realpage or 0)
end
local plist
diff --git a/tex/context/base/strc-ref.mkiv b/tex/context/base/strc-ref.mkiv
index 437782ff7..19930591d 100644
--- a/tex/context/base/strc-ref.mkiv
+++ b/tex/context/base/strc-ref.mkiv
@@ -118,6 +118,8 @@
\let\dofinishpagereference\dofinishfullreference
\let\dofinishuserreference\dofinishfullreference
+\def\dofinishsomereference#1{\executeifdefined{dofinish#1reference}\gobbletwoarguments}
+
\def\dodosetreference
{\ifreferencing
\expandafter\dododosetreference
diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua
index 59356bf30..c5519141f 100644
--- a/tex/context/base/strc-reg.lua
+++ b/tex/context/base/strc-reg.lua
@@ -7,11 +7,10 @@ if not modules then modules = { } end modules ['strc-reg'] = {
}
local next, type = next, type
-local texwrite, texsprint, texcount = tex.write, tex.sprint, tex.count
+local texwrite, texcount = tex.write, tex.count
local format, gmatch, concat = string.format, string.gmatch, table.concat
local utfchar = utf.char
local lpegmatch = lpeg.match
-local ctxcatcodes = tex.ctxcatcodes
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
local trace_registers = false trackers.register("structures.registers", function(v) trace_registers = v end)
@@ -34,6 +33,7 @@ local replacements = sorters.replacements
local processor_split = processors.split
local variables = interfaces.variables
+local context = context
local matchingtilldepth, numberatdepth = sections.matchingtilldepth, sections.numberatdepth
@@ -444,7 +444,7 @@ function registers.userdata(index,name)
local data = references.internals[tonumber(index)]
data = data and data.userdata and data.userdata[name]
if data then
- texsprint(ctxcatcodes,data)
+ context(data)
end
end
@@ -458,58 +458,42 @@ function registers.flush(data,options,prefixspec,pagespec)
-- for i=1,#result do
-- usedtags[#usedtags+1] = result[i].tag
-- end
+ -- context.setvalue("usedregistertags",concat(usedtags,",")) -- todo: { } and escape special chars
--
- -- texsprint(ctxcatcodes,"\\def\\usedregistertags{",concat(usedtags,","),"}") -- todo: { } and escape special chars
- --
- texsprint(ctxcatcodes,"\\startregisteroutput")
+ context.startregisteroutput()
local collapse_singles = options.compress == interfaces.variables.yes
local collapse_ranges = options.compress == interfaces.variables.all
local result = data.result
-- todo ownnumber
local function pagenumber(entry)
local er = entry.references
- local proc = entry.processors and entry.processors[2]
- texsprint(ctxcatcodes,"\\registeronepage{",er.internal or 0,"}{",er.realpage or 0,"}{") -- internal realpage content
- if proc then
- texsprint(ctxcatcodes,"\\applyprocessor{",proc,"}{")
- helpers.prefixpage(entry,prefixspec,pagespec)
- texsprint(ctxcatcodes,"}")
- else
- helpers.prefixpage(entry,prefixspec,pagespec)
- end
- texsprint(ctxcatcodes,"}")
+ context.registeronepage(
+ entry.processors and entry.processors[2] or "",
+ er.internal or 0,
+ er.realpage or 0,
+ function() helpers.prefixpage(entry,prefixspec,pagespec) end
+ )
end
local function pagerange(f_entry,t_entry,is_last)
- local er = f_entry.references
- local proc = f_entry.processors and f_entry.processors[2]
- texsprint(ctxcatcodes,"\\registerpagerange{",er.internal or 0,"}{",er.realpage or 0,"}{")
- if proc then
- texsprint(ctxcatcodes,"\\applyprocessor{",proc,"}{")
- helpers.prefixpage(f_entry,prefixspec,pagespec)
- texsprint(ctxcatcodes,"}")
- else
- helpers.prefixpage(f_entry,prefixspec,pagespec)
- end
- local er = t_entry.references
- texsprint(ctxcatcodes,"}{",er.internal or 0,"}{",er.lastrealpage or er.realpage or 0,"}{")
- if is_last then
- if proc then
- texsprint(ctxcatcodes,"\\applyprocessor{",proc,"}{")
- helpers.prefixlastpage(t_entry,prefixspec,pagespec) -- swaps page and realpage keys
- texsprint(ctxcatcodes,"}")
- else
- helpers.prefixlastpage(t_entry,prefixspec,pagespec) -- swaps page and realpage keys
- end
- else
- if proc then
- texsprint(ctxcatcodes,"\\applyprocessor{",proc,"}{")
- helpers.prefixpage(t_entry,prefixspec,pagespec)
- texsprint(ctxcatcodes,"}")
- else
- helpers.prefixpage(t_entry,prefixspec,pagespec)
+ local fer = f_entry.references
+ local ter = t_entry.references
+ context.registerpagerange(
+ f_entry.processors and f_entry.processors[2] or "",
+ fer.internal or 0,
+ fer.realpage or 0,
+ function()
+ helpers.prefixpage(f_entry,prefixspec,pagespec)
+ end,
+ ter.internal or 0,
+ ter.lastrealpage or ter.realpage or 0,
+ function()
+ if is_last then
+ helpers.prefixlastpage(t_entry,prefixspec,pagespec) -- swaps page and realpage keys
+ else
+ helpers.prefixpage (t_entry,prefixspec,pagespec)
+ end
end
- end
- texsprint(ctxcatcodes,"}")
+ )
end
--
-- maybe we can nil the splits and save memory
@@ -558,7 +542,7 @@ function registers.flush(data,options,prefixspec,pagespec)
local done = { false, false, false, false }
local data = sublist.data
local d, n = 0, 0
- texsprint(ctxcatcodes,"\\startregistersection{",sublist.tag,"}")
+ context.startregistersection(sublist.tag)
while d < #data do
d = d + 1
local entry = data[d]
@@ -572,37 +556,25 @@ function registers.flush(data,options,prefixspec,pagespec)
if e[i] and e[i] ~= "" then
done[i] = e[i]
if n == i then
- texsprint(ctxcatcodes,"\\stopregisterentries\\startregisterentries{",n,"}")
+ context.stopregisterentries()
+ context.startregisterentries(n)
else
while n > i do
n = n - 1
- texsprint(ctxcatcodes,"\\stopregisterentries")
+ context.stopregisterentries()
end
while n < i do
n = n + 1
- texsprint(ctxcatcodes,"\\startregisterentries{",n,"}")
+ context.startregisterentries(n)
end
end
local internal = entry.references.internal or 0
local seeparent = entry.references.seeparent or ""
+ local processor = entry.processors and entry.processors[1] or ""
if metadata then
- texsprint(ctxcatcodes,"\\registerentry{",internal,"}{",seeparent,"}{")
- local proc = entry.processors and entry.processors[1]
- if proc then
- texsprint(ctxcatcodes,"\\applyprocessor{",proc,"}{")
- helpers.title(e[i],metadata)
- texsprint(ctxcatcodes,"}")
- else
- helpers.title(e[i],metadata)
- end
- texsprint(ctxcatcodes,"}")
+ context.registerentry(processor,internal,seeparent,function() helpers.title(e[i],metadata) end)
else
- local proc = entry.processors and entry.processors[1]
- if proc then
- texsprint(ctxcatcodes,"\\applyprocessor{",proc,"}{\\registerentry{",internal,"}{",seeindex,"}{",e[i],"}}")
- else
- texsprint(ctxcatcodes,"\\registerentry{",internal,"}{",seeindex,"}{",e[i],"}")
- end
+ context.registerentry(processor,internal,seeindex,e[i])
end
else
done[i] = false
@@ -611,7 +583,7 @@ function registers.flush(data,options,prefixspec,pagespec)
end
local kind = entry.metadata.kind
if kind == 'entry' then
- texsprint(ctxcatcodes,"\\startregisterpages")
+ context.startregisterpages()
--~ collapse_ranges = true
if collapse_singles or collapse_ranges then
-- we collapse ranges and keep existing ranges as they are
@@ -759,29 +731,25 @@ function registers.flush(data,options,prefixspec,pagespec)
end
end
end
- texsprint(ctxcatcodes,"\\stopregisterpages")
+ context.stopregisterpages()
elseif kind == 'see' then
-- maybe some day more words
- texsprint(ctxcatcodes,"\\startregisterseewords")
+ context.startregisterseewords()
local seeindex = entry.references.seeindex or ""
local seetext = entry.seeword.text or ""
local proc = entry.processors and entry.processors[1]
-- todo: metadata like normal entries
- if proc then
- texsprint(ctxcatcodes,"\\applyprocessor{",proc,"}{\\registeroneword{0}{",seeindex,"}{",seetext,"}}")
- else
- texsprint(ctxcatcodes,"\\registeroneword{0}{",seeindex,"}{",seetext,"}")
- end
- texsprint(ctxcatcodes,"\\stopregisterseewords")
+ context.registeroneword(proc or "",0,seeindex,seetext)
+ context.stopregisterseewords()
end
end
while n > 0 do
- texsprint(ctxcatcodes,"\\stopregisterentries")
+ context.stopregisterentries()
n = n - 1
end
- texsprint(ctxcatcodes,"\\stopregistersection")
+ context.stopregistersection()
end
- texsprint(ctxcatcodes,"\\stopregisteroutput")
+ context.stopregisteroutput()
-- for now, maybe at some point we will do a multipass or so
data.result = nil
data.metadata.sorted = false
diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv
index f16c27663..94250767c 100644
--- a/tex/context/base/strc-reg.mkiv
+++ b/tex/context/base/strc-reg.mkiv
@@ -705,74 +705,74 @@
\def\registeronepagerangeseparator{|\endash|}
-\def\withregisterpagecommand#1#2#3%
- {\def\currentregisterpageindex{#1}%
+\def\withregisterpagecommand#1#2#3#4%
+ {\def\currentregisterpageindex{#2}%
\iflocation
- \goto{\registerparameter\c!pagecommand{#3}}[internal(#1)]%
+ \goto{\registerparameter\c!pagecommand{#4}}[internal(#2)]%
\else
- \registerparameter\c!pagecommand{#3}%
+ \registerparameter\c!pagecommand{#4}%
\fi}
-\def\registeronepage#1#2#3% content
+\def\registeronepage#1#2#3#4% #1:processor content
{\registerpageseparator
\dostarttagged\t!registerpage\empty
- \withregisterpagecommand{#1}{#2}{#3}%
+ \withregisterpagecommand{#1}{#2}{#3}{#4}%
\dostoptagged}
-\def\registerpagerange#1#2#3#4#5#6% content, content todo: -- configurable
+\def\registerpagerange#1#2#3#4#5#6#7% #1:processor content, content todo: -- configurable
{\registerpageseparator
\dostarttagged\t!registerpagerange\empty
\dostarttagged\t!registerfrompage\empty
- \withregisterpagecommand{#1}{#2}{#3}%
+ \withregisterpagecommand{#1}{#2}{#3}{#4}%
\dostoptagged
\registeronepagerangeseparator
\dostarttagged\t!registertopage\empty
- \withregisterpagecommand{#4}{#5}{#6}%
+ \withregisterpagecommand{#1}{#5}{#6}{#7}%
\dostoptagged
\dostoptagged}
-\def\registeroneword#1#2#3% #1:internal #2:seeindex #3:word
+\def\registeroneword#1#2#3#4% #1:processor #2:internal #3:seeindex #4:word
{\registerpageseparator
- \def\currentregisterpageindex{#1}%
+ \def\currentregisterpageindex{#2}%
\dostarttagged\t!registersee\empty
\iflocation
- \def\currentregisterseeindex{#2}%
+ \def\currentregisterseeindex{#3}%
\else
\let\currentregisterseeindex\empty
\fi
\ifx\currentregisterseeindex\empty
- \registerseeword{#3}%
+ \registerseeword{#1}{#4}%
\else
% [>\currentregisterseeindex]%
- \registerseeword{\goto{#3}[seeindex:\currentregisterseeindex]}%
+ \registerseeword{#1}{\goto{#4}[seeindex:\currentregisterseeindex]}%
\fi
\dostoptagged}
-\def\doapplyregisterentrycommand#1%
+\def\doapplyregisterentrycommand#1#2% processor text
{\dostarttagged\t!registerentry\empty
\ifx\currentregisterseeindex\empty \else
\dontleavehmode
% [<\currentregisterseeindex]%
\pagereference[seeindex:\currentregisterseeindex]% maybe some day we will support an area
\fi
- \registerparameter\c!textcommand{\limitedregisterentry{\registerparameter\c!deeptextcommand{#1}}}%
+ \applyprocessor{#1}{\registerparameter\c!textcommand{\limitedregisterentry{\registerparameter\c!deeptextcommand{#2}}}}%
\dostoptagged}
-\def\defaultregisterentry#1#2#3% #1:internal #2:seeindex #3:word
- {\def\currentregisterpageindex{#1}%
+\def\defaultregisterentry#1#2#3#4% #1:processor #2:internal #3:seeindex #4:word
+ {\def\currentregisterpageindex{#2}%
\iflocation
- \def\currentregisterseeindex{#2}%
+ \def\currentregisterseeindex{#3}%
\doifelse{\registerparameter\c!interaction}\v!text
- {\directgoto{\setlocationcolor\??ia\doapplyregisterentrycommand{#3}}[internal(#1)]}
- {\doapplyregisterentrycommand{#3}}%
+ {\directgoto{\setlocationcolor\??ia\doapplyregisterentrycommand{#1}{#4}}[internal(#2)]}
+ {\doapplyregisterentrycommand{#1}{#4}}%
\else
\let\currentregisterseeindex\empty
- \doapplyregisterentrycommand{#3}%
+ \doapplyregisterentrycommand{#1}{#4}%
\fi}
-\def\defaultregisterseeword#1%
+\def\defaultregisterseeword#1#2% processor word
{\dostarttagged\t!registersee\empty
- \labeltexts\v!see{#1}%
+ \applyprocessor{#1}{\labeltexts\v!see{#2}}%
\dostoptagged}
\let\registerseeword \defaultregisterseeword
@@ -810,18 +810,18 @@
\setvalue{\??id:\c!symbol:\v!none}%
{\let\registerpageseparatorsymbol\empty
- \let\registeronepage \gobblethreearguments
- \let\registerpagerange \gobblesixarguments}
+ \let\registeronepage \gobblefourarguments
+ \let\registerpagerange \gobblesevenarguments}
\setvalue{\??id:\c!symbol:1}%
{\let\registerpageseparatorsymbol\space
- \def\registeronepage {\symbol[1]\gobblethreearguments}%
- \def\registerpagerange {\symbol[1]\gobblesixarguments}}
+ \def\registeronepage {\symbol[1]\gobblefourarguments}%
+ \def\registerpagerange {\symbol[1]\gobblesevenarguments}}
\setvalue{\??id:\c!symbol:2}%
{\let\registerpageseparatorsymbol\space
- \def\registeronepage {\registerpagebuttonsymbol\gobblethreearguments}%
- \def\registerpagerange {\registerpagebuttonsymbol\gobblesixarguments}}
+ \def\registeronepage {\registerpagebuttonsymbol\gobblefourarguments}%
+ \def\registerpagerange {\registerpagebuttonsymbol\gobblesevenarguments}}
\def\setregisterpagerendering
{\doifelse{\registerparameter\c!pagenumber}\v!no
@@ -833,8 +833,8 @@
\csname\??id:\c!symbol:\currentregisterpagesymbol\endcsname
\else
\let\registerpageseparatorsymbol\space
- \def\registeronepage {\registerparameter\c!symbol\gobblethreearguments}%
- \def\registerpagerange {\registerparameter\c!symbol\gobblesixarguments}%
+ \def\registeronepage {\registerparameter\c!symbol\gobblefourarguments}%
+ \def\registerpagerange {\registerparameter\c!symbol\gobblesevenarguments}%
\fi\fi}
\appendtoks
diff --git a/tex/context/base/strc-ren.mkiv b/tex/context/base/strc-ren.mkiv
index f815e26c5..c78f0413e 100644
--- a/tex/context/base/strc-ren.mkiv
+++ b/tex/context/base/strc-ren.mkiv
@@ -77,21 +77,19 @@
% \ifcase\headtimingmode#1\fi % can introduce cr
\structureheadparameter\c!commandbefore
\placeheadmargintexts
+ \ifcsname\??nh\currentstructurehead\c!deeptextcommand\endcsname
+ \expandafter\let\expandafter\deepstructuretitlecommand\csname\??nh\currentstructurehead\c!deeptextcommand\endcsname
+ \fi
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
- \structureheadparameter\c!textcommand% struts can be nilled with \setnostrut
- {\setstrut
- \begstrut
- \ifcase\headtimingmode\hbox{#1}\fi
- \executeifdefined{\??nh\currentstructurehead\c!deeptextcommand}\firstofoneargument{#2}%
- \endstrut}% \hbox prevents break
+ % struts can be nilled with \setnostrut, the \hbox prevents break
+ \structureheadparameter\c!textcommand{\setstrut\begstrut\ifcase\headtimingmode\hbox{#1}\fi#2\endstrut}%
\xdef\localheadheight {\the\strutht}%
\xdef\localheaddepth {\the\strutdp}%
\xdef\localheadlineheight{\the\lineheight}%
% == \globallet\localheaddepth\strutdepth
\else
\ifcase\headtimingmode#1\fi
- \structureheadparameter\c!textcommand
- {\executeifdefined{\??nh\currentstructurehead\c!deeptextcommand}\firstofoneargument{#2}}%
+ \structureheadparameter\c!textcommand{#2}%
\fi
\structureheadparameter\c!commandafter
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
@@ -104,16 +102,14 @@
\setupheadcomponentfont\c!numberstyle\c!numbercolor
% \getvalue{\??ko\currentstructurehead\c!commandbefore}% strange, why here? moved 21/11/2005
\placeheadmargintexts
+ \ifcsname\??nh\currentstructurehead\c!deepnumbercommand\endcsname
+ \expandafter\let\expandafter\deepstructurenumbercommand\csname\??nh\currentstructurehead\c!deeptextcommand\endcsname
+ \fi
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
% can be nilled with \setnostrut
- \structureheadparameter\c!numbercommand
- {\setstrut
- \begstrut
- \executeifdefined{\??nh\currentstructurehead\c!deepnumbercommand}\firstofoneargument{#2}%
- \endstrut}%
+ \structureheadparameter\c!numbercommand{\setstrut\begstrut#2\endstrut}%
\else
- \structureheadparameter\c!numbercommand
- {\executeifdefined{\??nh\currentstructurehead\c!deepnumbercommand}\firstofoneargument{#2}}%
+ \structureheadparameter\c!numbercommand{#2}%
\fi
\endgroup}
diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv
index 17846aec0..f872043cb 100644
--- a/tex/context/base/strc-sec.mkiv
+++ b/tex/context/base/strc-sec.mkiv
@@ -83,7 +83,7 @@
{\global\advance\maxstructuredepth\plusone
\setevalue{\??nh#1\c!level}{\the\maxstructuredepth}%
\setstructurelevel{#1}{\the\maxstructuredepth}%
-% \letvalue{\??nh#1\c!marking}\empty % ?
+ %\letvalueempty{\??nh#1\c!marking}% ?
%\writestatus{structure}{#1\ifx\laststructuresectionname\empty\else\space->\space\laststructuresectionname\fi}%
\normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\??nh\laststructuresectionname]}%
% this is a rather practical default that we don't want to be part of the parent chain
@@ -96,7 +96,7 @@
% so far for these default inheritances
\definemarking[#1]%
\ifnum\maxstructuredepth>\plusone
-% \normalexpanded{\noexpand\couplemarking[#1][\laststructuresectionname]}% so, the child inherits settings from the parent
+ %\normalexpanded{\noexpand\couplemarking[#1][\laststructuresectionname]}% so, the child inherits settings from the parent
\normalexpanded{\noexpand\relatemarking[#1][\laststructuresectionname]}% so, the parent will reset the child
\fi
\xdef\laststructuresectionname{#1}}}
@@ -411,19 +411,31 @@
\currentstructuresynchronize}
% \unexpanded\def\fullstructureheadnumber{\labeltexts{\structureheadparameter\c!label}{\structurenumber}} % todo
+% \def\fullstructureheadtitle {\structurevariable{titledata.title}} % no catcode!
+% \unexpanded\def\fullstructureheadtitle{\structureautocatcodedget{titledata.title}{\structureheadparameter\s!catcodes}}
+
+\let\deepstructurenumbercommand\relax
+\let\deepstructuretitlecommand \relax
\unexpanded\def\fullstructureheadnumber
{\edef\currentstructureheadlabeltag{\currentstructureblock\c!label}%
\dostarttagged\t!sectionnumber\empty
- \labeltexts{\structureheadparameter\currentstructureheadlabeltag}{\structurenumber}%
+ \labeltexts
+ {\structureheadparameter\currentstructureheadlabeltag}
+ {\ifx\deepstructurenumbercommand\relax
+ \structurenumber
+ \else
+ \normalexpanded{\noexpand\deepstructurenumbercommand{\structurenumber}}%
+ \fi}%
\dostoptagged}
-% \def\fullstructureheadtitle {\structurevariable{titledata.title}} % no catcode!
-% \unexpanded\def\fullstructureheadtitle{\structureautocatcodedget{titledata.title}{\structureheadparameter\s!catcodes}}
-
\unexpanded\def\fullstructureheadtitle
{\dostarttagged\t!sectiontitle\empty
- \ctxlua{structures.sections.title()}%
+ \ifx\deepstructuretitlecommand\relax
+ \structuretitle
+ \else
+ \normalexpanded{\noexpand\deepstructuretitlecommand{\structuretitle}}%
+ \fi
\dostoptagged}
\let\currentstructurehead \empty
diff --git a/tex/context/base/strc-syn.lua b/tex/context/base/strc-syn.lua
index 005036843..dc8e2e951 100644
--- a/tex/context/base/strc-syn.lua
+++ b/tex/context/base/strc-syn.lua
@@ -7,11 +7,9 @@ if not modules then modules = { } end modules ['str-syn'] = {
}
local next, type = next, type
-local texwrite, texsprint, format = tex.write, tex.sprint, string.format
+local texwrite, format = tex.write, string.format
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
-local ctxcatcodes = tex.ctxcatcodes
-
-- interface to tex end
local structures = structures
@@ -82,7 +80,7 @@ function synonyms.synonym(class,tag)
if d then
local de = d.definition
de.used = true
- texsprint(ctxcatcodes,de.synonym)
+ context(de.synonym)
end
end
@@ -92,7 +90,7 @@ function synonyms.meaning(class,tag)
if d then
local de = d.definition
de.used = true
- texsprint(ctxcatcodes,de.meaning)
+ context(de.meaning)
end
end
@@ -149,24 +147,26 @@ function synonyms.finalize(data,options)
data.result = split
end
-function synonyms.flush(data,options) -- maybe pass the settings differently
- local kind = data.metadata.kind -- hack, will be done better
---~ texsprint(ctxcatcodes,format("\\start%soutput",kind))
+-- for now, maybe at some point we will do a multipass or so
+-- maybe pass the settings differently
+
+function synonyms.flush(data,options)
+ local kind = data.metadata.kind -- hack, will be done better
+ -- context[format("\\start%soutput",kind)]()
local result = data.result
local sorted = table.sortedkeys(result)
for k=1,#sorted do
local letter = sorted[k]
local sublist = result[letter]
local data = sublist.data
---~ texsprint(ctxcatcodes,format("\\start%ssection{%s}",kind,sublist.tag))
+ -- context[format("\\start%ssection",kind)](sublist.tag)
for d=1,#data do
local entry = data[d].definition
- texsprint(ctxcatcodes,format("\\%sentry{%s}{%s}{%s}{%s}",kind,d,entry.tag,entry.synonym,entry.meaning or ""))
+ context("\\%sentry{%s}{%s}{%s}{%s}",kind,d,entry.tag,entry.synonym,entry.meaning or "")
end
---~ texsprint(ctxcatcodes,format("\\stop%ssection",kind))
+ -- context[format("\\stop%ssection",kind)]()
end
---~ texsprint(ctxcatcodes,format("\\stop%soutput",kind))
- -- for now, maybe at some point we will do a multipass or so
+ -- context[format("\\stop%soutput",kind)]()
data.result = nil
data.metadata.sorted = false
end
diff --git a/tex/context/base/strc-tag.lua b/tex/context/base/strc-tag.lua
index 15773b448..f853cdd85 100644
--- a/tex/context/base/strc-tag.lua
+++ b/tex/context/base/strc-tag.lua
@@ -11,7 +11,7 @@ if not modules then modules = { } end modules ['strc-tag'] = {
local insert, remove, unpack, concat = table.insert, table.remove, table.unpack, table.concat
local gsub, find, topattern, format = string.gsub, string.find, string.topattern, string.format
local lpegmatch = lpeg.match
-local texattribute, texsprint, ctxcatcodes = tex.attribute, tex.sprint, tex.ctxcatcodes
+local texattribute = tex.attribute
local allocate = utilities.storage.allocate
local settings_to_hash = utilities.parsers.settings_to_hash
diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv
index f1ed751a0..a419e1801 100644
--- a/tex/context/base/supp-box.mkiv
+++ b/tex/context/base/supp-box.mkiv
@@ -2775,8 +2775,8 @@
% \def\docommand##1{\global\letbeundefined{\@@stacktag#1:##1}}%
% \processcommacommand[\getvalue{\@@stacklst#1}]\docommand
% \fi
-% \global\letvalue{\@@stacklst#1}\empty
-% \global\letvalue{\@@stackmax#1}\!!zeropoint}
+% \letgvalueempty{\@@stacklst#1}%
+% \letgvalue{\@@stackmax#1}\!!zeropoint}
%
% \def\savebox#1#2% stack name
% {\dowithnextbox
@@ -2828,7 +2828,7 @@
\ifcsname\@@stacklst#1\endcsname
\processcommacommand[\getvalue{\@@stacklst#1}]\docommand
\fi
- \global\letvalue{\@@stacklst#1}\empty}
+ \letgvalueempty{\@@stacklst#1}}
\def\savebox#1#2% stack name
{% beware, \setxvalue defines the cs beforehand so we cannot use the
diff --git a/tex/context/base/supp-fil.lua b/tex/context/base/supp-fil.lua
index 7ab86a51d..62252bf06 100644
--- a/tex/context/base/supp-fil.lua
+++ b/tex/context/base/supp-fil.lua
@@ -8,6 +8,8 @@ if not modules then modules = { } end modules ['supp-fil'] = {
-- This module will be redone !
+-- context is not defined yet! todo! (we need to load tupp-fil after cld)
+
--[[ldx--
<p>It's more convenient to manipulate filenames (paths) in
<l n='lua'/> than in <l n='tex'/>. These methods have counterparts
@@ -15,7 +17,7 @@ at the <l n='tex'/> side.</p>
--ldx]]--
local find, gsub, match, format, concat = string.find, string.gsub, string.match, string.format, table.concat
-local texsprint, texwrite, ctxcatcodes = tex.sprint, tex.write, tex.ctxcatcodes
+local texcount = tex.count
local trace_modules = false trackers.register("modules.loading", function(v) trace_modules = v end)
@@ -27,14 +29,14 @@ environment = environment or { }
local environment = environment
function commands.checkfilename(str) -- "/whatever..." "c:..." "http://..."
- commands.chardef("kindoffile",boolean.tonumber(find(str,"^/") or find(str,"[%a]:")))
+ texcount.kindoffile = (find(str,"^/") or find(str,"[%a]:") and 1) or 0
end
function commands.thesanitizedfilename(str)
- texwrite((gsub(str,"\\","/")))
+ context((gsub(str,"\\","/")))
end
-local def, chardef, testcase = commands.def, commands.chardef, commands.testcase
+local testcase = commands.testcase
function commands.splitfilename(fullname)
local path, name, base, suffix, kind = '', fullname, fullname, '', 0
@@ -46,19 +48,13 @@ function commands.splitfilename(fullname)
if b and s then
name, suffix = b, s
end
- if path == "" then
- kind = 0
- elseif path == '.' then
- kind = 1
- else
- kind = 2
- end
- def("splitofffull", fullname)
- def("splitoffpath", path)
- def("splitoffbase", base)
- def("splitoffname", name)
- def("splitofftype", suffix)
- chardef("splitoffkind", kind)
+ texcount.splitoffkind = (path == "" and 0) or (path == '.' and 1) or 2
+ local setvalue = context.setvalue
+ setvalue("splitofffull", fullname)
+ setvalue("splitoffpath", path)
+ setvalue("splitoffbase", base)
+ setvalue("splitoffname", name)
+ setvalue("splitofftype", suffix)
end
function commands.splitfiletype(fullname)
@@ -67,14 +63,15 @@ function commands.splitfiletype(fullname)
if n and s then
name, suffix = n, s
end
- def("splitofffull", fullname)
- def("splitoffpath", "")
- def("splitoffname", name)
- def("splitofftype", suffix)
+ local setvalue = context.setvalue
+ setvalue("splitofffull", fullname)
+ setvalue("splitoffpath", "")
+ setvalue("splitoffname", name)
+ setvalue("splitofftype", suffix)
end
function commands.doifparentfileelse(n)
- testcase(n==environment.jobname or n==environment.jobname..'.tex' or n==environment.outputfilename)
+ testcase(n == environment.jobname or n == environment.jobname .. '.tex' or n == environment.outputfilename)
end
-- saves some .15 sec on 12 sec format generation
@@ -91,7 +88,7 @@ function commands.doiffileexistelse(name)
end
function commands.lastexistingfile()
- texsprint(ctxcatcodes,lastexistingfile)
+ context(lastexistingfile)
end
-- more, we can cache matches
@@ -152,7 +149,7 @@ function commands.doreadfile(protocol,path,name) -- better do a split and then p
else
specification = ((path == "") and format("%s:///%s",protocol,name)) or format("%s:///%s/%s",protocol,path,name)
end
- texsprint(ctxcatcodes,resolvers.findtexfile(specification))
+ context(resolvers.findtexfile(specification))
end
-- modules can only have a tex or mkiv suffix or can have a specified one
diff --git a/tex/context/base/supp-fil.mkiv b/tex/context/base/supp-fil.mkiv
index 33cf3ea78..55b8528ae 100644
--- a/tex/context/base/supp-fil.mkiv
+++ b/tex/context/base/supp-fil.mkiv
@@ -176,7 +176,7 @@
%D NEW:
-\chardef\kindoffile=0 % 0=normal 1=full path spec (or http) / set at the lua end
+\newconstant\kindoffile % 0=normal 1=full path spec (or http) / set at the lua end
\def\checkfilename#1{\ctxlua{commands.checkfilename([[#1]])}}
@@ -454,7 +454,7 @@
%D
%D \start \typebuffer \getbuffer \stop
-\def\splitoffroot{.} \chardef\splitoffkind\zerocount
+\def\splitoffroot{.} \newconstant\splitoffkind
\let\splitofffull\empty
\let\splitoffpath\empty
diff --git a/tex/context/base/syst-lua.lua b/tex/context/base/syst-lua.lua
index 94928dd01..da9269ac3 100644
--- a/tex/context/base/syst-lua.lua
+++ b/tex/context/base/syst-lua.lua
@@ -81,12 +81,6 @@ function commands.doifinsetelse(a,b)
return testcase(false)
end
-function commands. def (cs,value) texsprint(ctxcatcodes,format( "\\def\\%s{%s}",cs,value)) end
-function commands.edef (cs,value) texsprint(ctxcatcodes,format("\\edef\\%s{%s}",cs,value)) end
-function commands.gdef (cs,value) texsprint(ctxcatcodes,format("\\gdef\\%s{%s}",cs,value)) end
-function commands.xdef (cs,value) texsprint(ctxcatcodes,format("\\xdef\\%s{%s}",cs,value)) end
-function commands.chardef(cs,value) texsprint(ctxcatcodes,format("\\chardef\\%s=%s\\relax",cs,value)) end
-
local pattern = lpeg.patterns.validdimen
function commands.doifdimenstringelse(str)
diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv
index 80e1ff20d..e2420850d 100644
--- a/tex/context/base/tabl-ntb.mkiv
+++ b/tex/context/base/tabl-ntb.mkiv
@@ -276,7 +276,7 @@
\processcommalist[#1]\dodosetupTABLE}
\def\nopTABLEparameters[#1][#2]%
- {\letvalue{\@@tblprefix#1}\empty}
+ {\letvalueempty{\@@tblprefix#1}} % can be made faster
\def\setTABLEparameters[#1][#2]%
{\pushTBLparameters
diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv
index ca5aa426d..afdf210e1 100644
--- a/tex/context/base/tabl-tbl.mkiv
+++ b/tex/context/base/tabl-tbl.mkiv
@@ -705,8 +705,8 @@
\c!margin,\c!align,\c!rulecolor,\c!rulethickness,EQ]%
\setuvalue{\e!start#1::#2}{\dofinalstarttabulate[#1][#2][#3]}%
\setuvalue{\e!start#1}{\bgroup\dosubstarttabulate[#1]}%
- \letvalue{\??tt#1-\v!header}\empty
- \letvalue{\??tt#1-\v!footer }\empty
+ \letvalueempty{\??tt#1-\v!header}%
+ \letvalueempty{\??tt#1-\v!footer}%
\else\ifsecondargument
\definetabulate[#1][][#2]%
\else
diff --git a/tex/context/base/toks-ini.lua b/tex/context/base/toks-ini.lua
index cb2807b24..7a4c221a4 100644
--- a/tex/context/base/toks-ini.lua
+++ b/tex/context/base/toks-ini.lua
@@ -34,7 +34,6 @@ a module.</p>
local token, tex = token, tex
local texsprint = tex.sprint
-local ctxcatcodes = tex.ctxcatcodes
local createtoken = token.create
local csname_id = token.csname_id
@@ -107,7 +106,7 @@ function collectors.install(tag,end_cs)
local t = get_next()
local a, b = t[1], t[3]
if b == endcs then
- texsprint('\\' ..end_cs)
+ texsprint('\\' ..end_cs) -- to be checked, can be context[end_cs]()
return
elseif a == call and registered[b] then
expand()
diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua
index 2c0ffb3db..bffcc6c2e 100644
--- a/tex/context/base/trac-log.lua
+++ b/tex/context/base/trac-log.lua
@@ -394,19 +394,6 @@ function logs.obsolete(old,new)
end
end
-if tex.error then
-
- function logs.texerrormessage(...) -- for the moment we put this function here
- tex.error(format(...), { })
- end
-
-else
-
- function logs.texerrormessage(...) -- for the moment we put this function here
- local v = format(...)
- tex.sprint(tex.ctxcatcodes,"\\errmessage{")
- tex.sprint(tex.vrbcatcodes,v)
- tex.print(tex.ctxcatcodes,"}")
- end
-
+function logs.texerrormessage(...) -- for the moment we put this function here
+ tex.error(format(...), { })
end
diff --git a/tex/context/base/util-pck.lua b/tex/context/base/util-pck.lua
index 585123b5c..cd1fc510e 100644
--- a/tex/context/base/util-pck.lua
+++ b/tex/context/base/util-pck.lua
@@ -20,9 +20,9 @@ local function hashed(t)
local s = { }
for k, v in next, t do
if type(v) == "table" then
- s[#s+1] = k.."={"..hashed(v).."}"
+ s[#s+1] = k .. "={" .. hashed(v) .. "}"
else
- s[#s+1] = k.."="..tostring(v)
+ s[#s+1] = k .. "=" .. tostring(v)
end
end
sort(s)
@@ -32,7 +32,7 @@ end
local function simplehashed(t)
local s = { }
for k, v in next, t do
- s[#s+1] = k.."="..v
+ s[#s+1] = k.. "=" .. v
end
sort(s)
return concat(s,",")
@@ -41,20 +41,38 @@ end
packers.hashed = hashed
packers.simplehashed = simplehashed
+--~ local function pack(t,keys,hash,index)
+--~ for k,v in next, t do
+--~ if type(v) == "table" then
+--~ pack(v,keys,hash,index)
+--~ end
+--~ if keys[k] and type(v) == "table" then
+--~ local h = hashed(v)
+--~ local i = hash[h]
+--~ if not i then
+--~ i = #index + 1
+--~ index[i] = v
+--~ hash[h] = i
+--~ end
+--~ t[k] = i
+--~ end
+--~ end
+--~ end
+
local function pack(t,keys,hash,index)
for k,v in next, t do
if type(v) == "table" then
pack(v,keys,hash,index)
- end
- if keys[k] and type(v) == "table" then
- local h = hashed(v)
- local i = hash[h]
- if not i then
- i = #index+1
- index[i] = v
- hash[h] = i
+ if keys[k] then
+ local h = hashed(v)
+ local i = hash[h]
+ if not i then
+ i = #index + 1
+ index[i] = v
+ hash[h] = i
+ end
+ t[k] = i
end
- t[k] = i
end
end
end
diff --git a/tex/context/base/util-prs.lua b/tex/context/base/util-prs.lua
index 4580a02b8..a42715d0d 100644
--- a/tex/context/base/util-prs.lua
+++ b/tex/context/base/util-prs.lua
@@ -14,7 +14,7 @@ parsers.patterns = parsers.patterns or { }
local P, R, V, C, Ct, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Carg
local lpegmatch = lpeg.match
local concat, format, gmatch = table.concat, string.format, string.gmatch
-local tostring, type = tostring, type
+local tostring, type, next = tostring, type, next
local sortedhash = table.sortedhash
local escape, left, right = P("\\"), P('{'), P('}')
diff --git a/tex/context/base/util-tab.lua b/tex/context/base/util-tab.lua
index 323f3e2c7..6c0ae8970 100644
--- a/tex/context/base/util-tab.lua
+++ b/tex/context/base/util-tab.lua
@@ -12,6 +12,7 @@ local tables = utilities.tables
local format, gmatch = string.format, string.gmatch
local concat, insert, remove = table.concat, table.insert, table.remove
+local setmetatable = setmetatable
function tables.definetable(target) -- defines undefined tables
local composed, t = nil, { }
diff --git a/tex/context/base/x-ldx.tex b/tex/context/base/x-ldx.tex
index 398ca2345..44f936d32 100644
--- a/tex/context/base/x-ldx.tex
+++ b/tex/context/base/x-ldx.tex
@@ -1,6 +1,6 @@
\doifnotmode{mkiv}{\endinput}
-\setupxml[method=mkiv,default=hidden]
+\setupxml[default=hidden]
\usemodule[x][mathml]
@@ -136,11 +136,11 @@
\usemodule[abr-02]
-% key -> kw
-% dqs -> dq
-% sqs -> sq
-% line -> ln
-% code -> cd
+% key -> kw
+% dqs -> dq
+% sqs -> sq
+% line -> ln
+% code -> cd
% comment -> tx (text)
\definetypeface[mainfacenormal] [ss][sans] [iwona] [default]
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index a6ee0673c..4af7af557 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 : 10/18/10 11:11:34
+-- merge date : 10/19/10 23:03:29
do -- begin closure to overcome local limits and interference
@@ -934,13 +934,6 @@ function table.fromhash(t)
return h
end
---~ print(table.serialize(t), "\n")
---~ print(table.serialize(t,"name"), "\n")
---~ print(table.serialize(t,false), "\n")
---~ print(table.serialize(t,true), "\n")
---~ print(table.serialize(t,"name",true), "\n")
---~ print(table.serialize(t,"name",true,true), "\n")
-
table.serialize_functions = true
table.serialize_compact = true
table.serialize_inline = true
@@ -1032,8 +1025,8 @@ local function do_serialize(root,name,depth,level,indexed)
--~ if v == root then
-- circular
--~ else
- local t = type(v)
- if compact and first and type(k) == "number" and k >= first and k <= last then
+ local t, tk = type(v), type(k)
+ if compact and first and tk == "number" and k >= first and k <= last then
if t == "number" then
if hexify then
handle(format("%s 0x%04X,",depth,v))
@@ -1075,17 +1068,18 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s __p__=nil,",depth))
end
elseif t == "number" then
- --~ if hexify then
- --~ handle(format("%s %s=0x%04X,",depth,key(k),v))
- --~ else
- --~ handle(format("%s %s=%s,",depth,key(k),v)) -- %.99g
- --~ end
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=0x%04X,",depth,k,v))
else
handle(format("%s [%s]=%s,",depth,k,v)) -- %.99g
end
+ elseif tk == "boolean" then
+ if hexify then
+ handle(format("%s [%s]=0x%04X,",depth,tostring(k),v))
+ else
+ handle(format("%s [%s]=%s,",depth,tostring(k),v)) -- %.99g
+ end
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
if hexify then
handle(format("%s %s=0x%04X,",depth,k,v))
@@ -1101,26 +1095,28 @@ local function do_serialize(root,name,depth,level,indexed)
end
elseif t == "string" then
if reduce and tonumber(v) then
- --~ handle(format("%s %s=%s,",depth,key(k),v))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=%s,",depth,k,v))
else
handle(format("%s [%s]=%s,",depth,k,v))
end
+ elseif tk == "boolean" then
+ handle(format("%s [%s]=%s,",depth,tostring(k),v))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s=%s,",depth,k,v))
else
handle(format("%s [%q]=%s,",depth,k,v))
end
else
- --~ handle(format("%s %s=%q,",depth,key(k),v))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=%q,",depth,k,v))
else
handle(format("%s [%s]=%q,",depth,k,v))
end
+ elseif tk == "boolean" then
+ handle(format("%s [%s]=%q,",depth,tostring(k),v))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s=%q,",depth,k,v))
else
@@ -1129,13 +1125,14 @@ local function do_serialize(root,name,depth,level,indexed)
end
elseif t == "table" then
if not next(v) then
- --~ handle(format("%s %s={},",depth,key(k)))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]={},",depth,k))
else
handle(format("%s [%s]={},",depth,k))
end
+ elseif tk == "boolean" then
+ handle(format("%s [%s]={},",depth,tostring(k)))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s={},",depth,k))
else
@@ -1144,13 +1141,14 @@ local function do_serialize(root,name,depth,level,indexed)
elseif inline then
local st = simple_table(v)
if st then
- --~ handle(format("%s %s={ %s },",depth,key(k),concat(st,", ")))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]={ %s },",depth,k,concat(st,", ")))
else
handle(format("%s [%s]={ %s },",depth,k,concat(st,", ")))
end
+ elseif tk == "boolean" then -- or find(k,"^%d+$") then
+ handle(format("%s [%s]={ %s },",depth,tostring(k),concat(st,", ")))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s={ %s },",depth,k,concat(st,", ")))
else
@@ -1163,13 +1161,14 @@ local function do_serialize(root,name,depth,level,indexed)
do_serialize(v,k,depth,level+1)
end
elseif t == "boolean" then
- --~ handle(format("%s %s=%s,",depth,key(k),tostring(v)))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=%s,",depth,k,tostring(v)))
else
handle(format("%s [%s]=%s,",depth,k,tostring(v)))
end
+ elseif tk == "boolean" then -- or find(k,"^%d+$") then
+ handle(format("%s [%s]=%s,",depth,tostring(k),tostring(v)))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s=%s,",depth,k,tostring(v)))
else
@@ -1177,13 +1176,14 @@ local function do_serialize(root,name,depth,level,indexed)
end
elseif t == "function" then
if functions then
- --~ handle(format('%s %s=loadstring(%q),',depth,key(k),dump(v)))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=loadstring(%q),",depth,k,dump(v)))
else
handle(format("%s [%s]=loadstring(%q),",depth,k,dump(v)))
end
+ elseif tk == "boolean" then
+ handle(format("%s [%s]=loadstring(%q),",depth,tostring(k),dump(v)))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s=loadstring(%q),",depth,k,dump(v)))
else
@@ -1191,13 +1191,14 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
else
- --~ handle(format("%s %s=%q,",depth,key(k),tostring(v)))
- if type(k) == "number" then -- or find(k,"^%d+$") then
+ if tk == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=%q,",depth,k,tostring(v)))
else
handle(format("%s [%s]=%q,",depth,k,tostring(v)))
end
+ elseif tk == "boolean" then -- or find(k,"^%d+$") then
+ handle(format("%s [%s]=%q,",depth,tostring(k),tostring(v)))
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
handle(format("%s %s=%q,",depth,k,tostring(v)))
else
@@ -1506,7 +1507,7 @@ function table.sequenced(t,sep,simple) -- hash only
end
function table.print(...)
- print(table.serialize(...))
+ table.tohandle(print,...)
end
end -- closure
@@ -3114,7 +3115,7 @@ fontloader.totable = fontloader.to_table
-- vtf comes first
-- fix comes last
-fonts = fonts or { }
+fonts = fonts or { }
-- we will also have des and fam hashes
@@ -3177,9 +3178,9 @@ fonts.definers.specifiers.synonyms = fonts.definers.specifiers.synonyms or { }
-- tracing
-if not fonts.color then
+if not fonts.colors then
- fonts.color = allocate {
+ fonts.colors = allocate {
set = function() end,
reset = function() end,
}
@@ -5096,8 +5097,6 @@ local trace_unimapping = false trackers.register("otf.unimapping", function(v)
local report_otf = logs.new("load otf")
-local ctxcatcodes = tex and tex.ctxcatcodes
-
--[[ldx--
<p>Eventually this code will disappear because map files are kind
of obsolete. Some code may move to runtime or auxiliary modules.</p>
@@ -10650,7 +10649,7 @@ local traverse_node_list = node.traverse
local fontdata = fonts.ids
local state = attributes.private('state')
-local fontcolors = fonts.colors
+local fontscolors = fonts.colors
local fcs = (fontscolors and fontscolors.set) or function() end
local fcr = (fontscolors and fontscolors.reset) or function() end
@@ -10768,6 +10767,10 @@ local isol_fina_medi_init = {
[0x077E] = true, [0x077F] = true, [zwj] = true,
}
+local mark = {
+ [0x0650] = true,
+}
+
local arab_warned = { }
-- todo: gref
@@ -10838,7 +10841,7 @@ function analyzers.methods.arab(head,font,attr) -- maybe make a special version
if current.id == glyph_code and current.subtype<256 and current.font == font and not has_attribute(current,state) then
done = true
local char = current.char
- if marks[char] then
+ if marks[char] or mark[char] then
set_attribute(current,state,5) -- mark
if trace_analyzing then fcs(current,"font:mark") end
elseif isol[char] then -- can be zwj or zwnj too