From 83222078cd1f2f9d2c12279653c48dfd70390f1c Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Mon, 12 May 2014 08:14:15 +0200 Subject: 2014-05-08 11:19:00 --- tex/context/base/buff-ini.lua | 10 +- tex/context/base/buff-ini.mkiv | 8 +- tex/context/base/buff-ver.mkiv | 2 +- tex/context/base/chem-str.lua | 39 ++-- tex/context/base/chem-str.mkiv | 14 +- tex/context/base/cldf-prs.lua | 42 +++- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4061 -> 4063 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/core-con.lua | 60 ++++- tex/context/base/core-con.mkiv | 4 +- tex/context/base/font-run.mkiv | 2 +- tex/context/base/math-frc.mkiv | 45 ++++ tex/context/base/math-map.lua | 249 +++++++++++++-------- tex/context/base/math-noa.lua | 34 --- tex/context/base/meta-ini.mkiv | 1 + tex/context/base/mlib-lua.lua | 77 ++++--- tex/context/base/mtx-context-listing.tex | 17 +- tex/context/base/mult-def.mkiv | 1 + tex/context/base/mult-ini.lua | 12 +- tex/context/base/mult-low.lua | 1 + tex/context/base/mult-mps.lua | 2 + tex/context/base/node-ref.lua | 5 +- tex/context/base/pack-mrl.mkiv | 2 +- tex/context/base/pack-rul.lua | 44 ++++ tex/context/base/s-math-coverage.lua | 158 ++++++------- tex/context/base/s-math-coverage.mkiv | 2 + tex/context/base/status-files.pdf | Bin 24625 -> 24652 bytes tex/context/base/status-lua.pdf | Bin 242466 -> 242951 bytes tex/context/base/strc-blk.mkiv | 3 +- tex/context/base/tabl-tbl.mkiv | 7 +- tex/context/base/tabl-xnt.mkvi | 2 +- tex/context/base/tabl-xtb.lua | 25 ++- tex/context/base/tabl-xtb.mkvi | 8 +- tex/context/base/util-sci.lua | 78 ++++--- tex/context/base/x-mathml.lua | 2 +- tex/context/fonts/lm-math.lfg | 2 +- tex/context/fonts/lm.lfg | 15 +- tex/generic/context/luatex/luatex-fonts-enc.lua | 7 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 3 +- tex/generic/context/luatex/luatex-math.tex | 3 +- 41 files changed, 620 insertions(+), 370 deletions(-) (limited to 'tex') diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua index 84532f072..c4046d649 100644 --- a/tex/context/base/buff-ini.lua +++ b/tex/context/base/buff-ini.lua @@ -194,7 +194,7 @@ local continue = false -- An \n is unlikely to show up as \r is the endlinechar but \n is more generic -- for us. --- This fits the way we fetch verbatim: the indentatio before the sentinel +-- This fits the way we fetch verbatim: the indentation before the sentinel -- determines the stripping. -- str = [[ @@ -238,7 +238,7 @@ local whatever = (P(1)-eol)^0 * eol^1 local strippers = { } -local function undent(str) -- new version, needs testing +local function undent(str) -- new version, needs testing: todo: not always needed, like in xtables local margin = lpegmatch(getmargin,str) if type(margin) ~= "string" then return str @@ -255,7 +255,7 @@ local function undent(str) -- new version, needs testing return lpegmatch(stripper,str) or str end -function commands.grabbuffer(name,begintag,endtag,bufferdata,catcodes) -- maybe move \\ to call +function commands.grabbuffer(name,begintag,endtag,bufferdata,catcodes,doundent) -- maybe move \\ to call local dn = getcontent(name) if dn == "" then nesting = 0 @@ -291,8 +291,8 @@ function commands.grabbuffer(name,begintag,endtag,bufferdata,catcodes) -- maybe if last == "\n" or last == "\r" then -- \n is unlikely as \r is the endlinechar dn = sub(dn,1,-2) end - if autoundent then - dn = undent(dn) + if doundent or (autoundent and doundent == nil) then + dn = undent(dn) end end assign(name,dn,catcodes) diff --git a/tex/context/base/buff-ini.mkiv b/tex/context/base/buff-ini.mkiv index 4ea3042b6..6582e3587 100644 --- a/tex/context/base/buff-ini.mkiv +++ b/tex/context/base/buff-ini.mkiv @@ -39,8 +39,8 @@ \def\buff_start[#1][#2]% {\buff_start_indeed{}{#1}{\e!start\v!buffer}{\e!stop\v!buffer}} -\def\buff_start_indeed#1#2#3#4% \donothing needed ! - {\normalexpanded{\buff_pickup{#2}{#3}{#4}{}{\buff_stop{#4}}}} +\def\buff_start_indeed#1#2#3#4#5% \donothing needed ! #5=undent) + {\normalexpanded{\buff_pickup{#2}{#3}{#4}{}{\buff_stop{#4}}\plusone}} \unexpanded\def\grabbufferdata % was: \dostartbuffer {\begingroup % (4) @@ -64,7 +64,7 @@ \let\buff_finish\relax \let\buff_gobble\relax -\unexpanded\def\buff_pickup#1#2#3#4#5% name, startsequence, stopsequence, before, after +\unexpanded\def\buff_pickup#1#2#3#4#5#6% name, startsequence, stopsequence, before, after, undent {\begingroup % (1) #4% \begingroup % (2) @@ -77,7 +77,7 @@ #5}% \def\buff_gobble##1#3% is detokenize needed? TEST %{\ctxcommand{grabbuffer("#1","#2","#3",\!!bs\detokenize{##1}\!!es)} % space ? - {\ctxcommand{grabbuffer("#1","#2","#3",\!!bs>##1\!!es,\catcodetableofbuffer)}% space ? + {\ctxcommand{grabbuffer("#1","#2","#3",\!!bs>##1\!!es,\catcodetableofbuffer,\ifnum#6=\plusone true\else false\fi)}% space ? \buff_gobble \buff_finish}% \buff_gobble} diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index 17dfd9d69..8b9bd1764 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -471,7 +471,7 @@ \normalexpanded{\buff_verbatim_type_block{\e!start\currenttyping}{\e!stop\currenttyping}}} \unexpanded\def\buff_verbatim_type_block#1#2% - {\buff_pickup{_typing_}{#1}{#2}{}{\buff_verbatim_type_block_verbatim_indeed{#1}{#2}}} % was dowithbuffer + {\buff_pickup{_typing_}{#1}{#2}{}{\buff_verbatim_type_block_verbatim_indeed{#1}{#2}}\plusone} % was dowithbuffer \def\buff_verbatim_type_block_verbatim_indeed#1#2% {\buff_verbatim_initialize_typing_two diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua index 347363345..cd7a2db06 100644 --- a/tex/context/base/chem-str.lua +++ b/tex/context/base/chem-str.lua @@ -147,6 +147,8 @@ local one_keys = { es = "line", ed = "line", et = "line", + au = "line", + ad = "line", cz = "text", rot = "transform", dir = "transform", @@ -156,6 +158,7 @@ local one_keys = { local ring_keys = { db = "line", + hb = "line", br = "line", lr = "line", rr = "line", @@ -316,7 +319,7 @@ local pattern = -- print(lpegmatch(pattern,"RZ13=x")) -- 1 RZ false false table x local f_initialize = 'if unknown context_chem : input mp-chem.mpiv ; fi ;' -local f_start_structure = formatters['chem_start_structure(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);'] +local f_start_structure = formatters['chem_start_structure(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);'] local f_set_trace_bounds = formatters['chem_trace_boundingbox := %l ;'] local f_stop_structure = 'chem_stop_structure;' local f_start_component = 'chem_start_component;' @@ -536,6 +539,8 @@ local function process(level,spec,text,n,rulethickness,rulecolor,offset,default_ if not t then txt, t = fetch(txt) end if t then t = molecule(processor_tostring(t)) +-- local p, t = processors.split(t) +-- m = m + 1 ; metacode[m] = f_text(operation,p or align,variant,si,t) m = m + 1 ; metacode[m] = f_text(operation,align,variant,si,t) end end @@ -605,7 +610,7 @@ end -- -- rulethickness in points -local function checked(d,factor,unit,scale) +local function checked(d,bondlength,unit,scale) if d == v_none then return 0 end @@ -613,9 +618,9 @@ local function checked(d,factor,unit,scale) if not n then -- assume dimen elseif n >= 10 or n <= -10 then - return factor * unit * n / 1000 + return bondlength * unit * n / 1000 else - return factor * unit * n + return bondlength * unit * n end local n = todimen(d) if n then @@ -625,7 +630,7 @@ local function checked(d,factor,unit,scale) end end -local function calculated(height,bottom,top,factor,unit,scale) +local function calculated(height,bottom,top,bondlength,unit,scale) local scaled = 0 if height == v_none then -- this always wins @@ -634,24 +639,24 @@ local function calculated(height,bottom,top,factor,unit,scale) top = "0pt" elseif height == v_fit then height = "true" - bottom = bottom == v_fit and "true" or topoints(checked(bottom,factor,unit,scale)) - top = top == v_fit and "true" or topoints(checked(top, factor,unit,scale)) + bottom = bottom == v_fit and "true" or topoints(checked(bottom,bondlength,unit,scale)) + top = top == v_fit and "true" or topoints(checked(top, bondlength,unit,scale)) else - height = checked(height,factor,unit,scale) + height = checked(height,bondlength,unit,scale) if bottom == v_fit then if top == v_fit then bottom = height / 2 top = bottom else - top = checked(top,factor,unit,scale) + top = checked(top,bondlength,unit,scale) bottom = height - top end elseif top == v_fit then - bottom = checked(bottom,factor,unit,scale) + bottom = checked(bottom,bondlength,unit,scale) top = height - bottom else - bottom = checked(bottom,factor,unit,scale) - top = checked(top, factor,unit,scale) + bottom = checked(bottom,bondlength,unit,scale) + top = checked(top, bondlength,unit,scale) local ratio = height / (bottom+top) bottom = bottom * ratio top = top * ratio @@ -669,7 +674,7 @@ function chemistry.start(settings) local width = settings.width or v_fit local height = settings.height or v_fit local unit = settings.unit or 655360 - local factor = settings.factor or 3 + local bondlength = settings.factor or 3 local rulethickness = settings.rulethickness or 65536 local rulecolor = settings.rulecolor or "" local axiscolor = settings.framecolor or "" @@ -683,7 +688,7 @@ function chemistry.start(settings) -- align = settings.symalign or "auto" if trace_structure then - report_chemistry("unit %p, factor %s, symalign %s",unit,factor,align) + report_chemistry("unit %p, bondlength %s, symalign %s",unit,bondlength,align) end if align ~= "" then align = "." .. align @@ -713,8 +718,8 @@ function chemistry.start(settings) local sp_width = 0 local sp_height = 0 -- - width, left, right, sp_width = calculated(width, left, right,factor,unit,scale) - height, bottom, top, sp_height = calculated(height,bottom,top, factor,unit,scale) + width, left, right, sp_width = calculated(width, left, right,bondlength,unit,scale) + height, bottom, top, sp_height = calculated(height,bottom,top, bondlength,unit,scale) -- if width ~= "true" and height ~= "true" and texgetcount("@@trialtypesetting") ~= 0 then if trace_structure then @@ -736,7 +741,7 @@ function chemistry.start(settings) metacode[#metacode+1] = f_start_structure( chemistry.structures, left, right, top, bottom, - rotation, topoints(unit), factor, topoints(offset), + rotation, topoints(unit), bondlength, scale, topoints(offset), tostring(settings.axis == v_on), topoints(rulethickness), tostring(axiscolor) ) metacode[#metacode+1] = f_set_trace_bounds(trace_boundingbox) ; diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv index d9ec1842b..6aec16f9e 100644 --- a/tex/context/base/chem-str.mkiv +++ b/tex/context/base/chem-str.mkiv @@ -705,14 +705,14 @@ \setupchemical [\c!frame=, - \c!width=\v!fit, % or unitless number, multiplies scale*EmWidth - \c!height=\v!fit, % or unitless number, multiplies scale*EmWidth - \c!left=\v!fit, % or unitless number, multiplies scale*EmWidth - \c!right=\v!fit, % or unitless number, multiplies scale*EmWidth - \c!top=\v!fit, % or unitless number, multiplies scale*EmWidth - \c!bottom=\v!fit, % or unitless number, multiplies scale*EmWidth + \c!width=\v!fit, % or unitless number, multiplies scale*unit + \c!height=\v!fit, % or unitless number, multiplies scale*unit + \c!left=\v!fit, % or unitless number, multiplies scale*unit + \c!right=\v!fit, % or unitless number, multiplies scale*unit + \c!top=\v!fit, % or unitless number, multiplies scale*unit + \c!bottom=\v!fit, % or unitless number, multiplies scale*unit \c!bodyfont=, - \c!scale=\v!normal, % small, normal or medium, big, or unitless number (multiplies EmWidth) + \c!scale=\v!normal, % small, normal or medium, big, or unitless number (multiplies unit) \c!size=\v!medium, \c!textsize=\v!big, % how is textsize used?? \c!axis=\v!off, diff --git a/tex/context/base/cldf-prs.lua b/tex/context/base/cldf-prs.lua index 160d30b19..1554b5e57 100644 --- a/tex/context/base/cldf-prs.lua +++ b/tex/context/base/cldf-prs.lua @@ -15,17 +15,18 @@ local format = string.format local cpatterns = patterns.context or { } patterns.context = cpatterns +local utf8char = patterns.utf8char +local cardinal = patterns.cardinal + +local leftbrace = P("{") +local rightbrace = P("}") local backslash = P("\\") -local csname = backslash * P(1) * (1-backslash)^0 +local csname = backslash * P(1) * (1-backslash-leftbrace)^0 * P(" ")^0 local sign = P("+") / "\\textplus " + P("-") / "\\textminus " -local leftbrace = P("{") -local rightbrace = P("}") local nested = P { leftbrace * (V(1) + (1-rightbrace))^0 * rightbrace } local subscript = P("_") local superscript = P("^") -local utf8char = patterns.utf8char -local cardinal = patterns.cardinal -- local scripts = P { "start", -- start = V("csname") + V("lowfirst") + V("highfirst"), @@ -35,22 +36,41 @@ local cardinal = patterns.cardinal -- highfirst = superscript * ( Cc("\\hilo{%s}{%s}") * V("content") * subscript + Cc("\\high{%s}") ) * V("content") / format, -- } -local scripts = P { "start", - start = V("csname") + V("lowfirst") + V("highfirst"), +-- local scripts = P { "start", +-- start = (V("csname") + V("lowfirst") + V("highfirst"))^1, +-- csname = csname, +-- content = Cs(V("csname") + nested + sign^-1 * (cardinal + utf8char)), +-- lowfirst = (subscript /"") * ( Cc("\\lohi{") * V("content") * Cc("}{") * (superscript/"") + Cc("\\low{" ) ) * V("content") * Cc("}"), +-- highfirst = (superscript/"") * ( Cc("\\hilo{") * V("content") * Cc("}{") * (subscript /"") + Cc("\\high{") ) * V("content") * Cc("}"), +-- } + +local scripted = Cs { "start", + start = (V("csname") + V("nested") + V("lowfirst") + V("highfirst") + V("utf8char"))^1, + rest = V("csname") + V("nested") + V("lowfirst") + V("highfirst"), csname = csname, - content = Cs(V("csname") + nested + sign^-1 * (cardinal + utf8char)), + utf8char = utf8char, + -- nested = leftbrace * (V("rest") + (V("utf8char")-rightbrace))^0 * rightbrace, + nested = leftbrace * (V("start") -rightbrace)^0 * rightbrace, + content = Cs(V("nested") + sign^-1 * (cardinal + V("utf8char"))), + content = V("nested") + sign^-1 * (cardinal + V("utf8char")), lowfirst = (subscript /"") * ( Cc("\\lohi{") * V("content") * Cc("}{") * (superscript/"") + Cc("\\low{" ) ) * V("content") * Cc("}"), highfirst = (superscript/"") * ( Cc("\\hilo{") * V("content") * Cc("}{") * (subscript /"") + Cc("\\high{") ) * V("content") * Cc("}"), } -local scripted = Cs((csname + scripts + utf8char)^0) -cpatterns.scripts = scripts +-- local scripted = Cs((scripts)) + +-- cpatterns.scripts = scripts cpatterns.csname = csname cpatterns.scripted = scripted cpatterns.nested = nested --- inspect(scripted) -- print(lpegmatch(scripted,"10^-3_x")) +-- print(lpegmatch(scripted,"\\L {C_5}")) +-- print(lpegmatch(scripted,"\\SL{}")) +-- print(lpegmatch(scripted,"\\SL{C_5}")) +-- print(lpegmatch(scripted,"\\SL{C_5}")) +-- print(lpegmatch(scripted,"{C_5}")) +-- print(lpegmatch(scripted,"{\\C_5}")) -- print(lpegmatch(scripted,"10^-a")) diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index e3df6f7bf..812647e80 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2014.04.28 23:24} +\newcontextversion{2014.05.08 11:18} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index 6450c43f1..c77c0777f 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index e1ade2ba1..c5b82329f 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -28,7 +28,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2014.04.28 23:24} +\edef\contextversion{2014.05.08 11:18} \edef\contextkind {beta} %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 73ca3e304..3ccfb3e23 100644 --- a/tex/context/base/core-con.lua +++ b/tex/context/base/core-con.lua @@ -18,6 +18,7 @@ local floor, date, time, concat = math.floor, os.date, os.time, table.concat local lower, rep, match = string.lower, string.rep, string.match local utfchar, utfbyte = utf.char, utf.byte local tonumber, tostring = tonumber, tostring +local P, C, Cs, lpegmatch = lpeg.P, lpeg.C, lpeg.Cs, lpeg.match local context = context local commands = commands @@ -124,13 +125,26 @@ local counters = allocate { languages.counters = counters -counters['ar'] = counters['arabic'] -counters['gr'] = counters['greek'] -counters['g'] = counters['greek'] -counters['sl'] = counters['slovenian'] -counters['kr'] = counters['korean'] -counters['kr-p'] = counters['korean-parent'] -counters['kr-c'] = counters['korean-circle'] +counters['ar'] = counters['arabic'] +counters['gr'] = counters['greek'] +counters['g'] = counters['greek'] +counters['sl'] = counters['slovenian'] +counters['kr'] = counters['korean'] +counters['kr-p'] = counters['korean-parent'] +counters['kr-c'] = counters['korean-circle'] + +counters['thainumerals'] = counters['thai'] +counters['devanagarinumerals'] = counters['devanagari'] +counters['gurmurkhinumerals'] = counters['gurmurkhi'] +counters['gujaratinumerals'] = counters['gujarati'] +counters['tibetannumerals'] = counters['tibetan'] +counters['greeknumerals'] = counters['greek'] +counters['arabicnumerals'] = counters['arabic'] +counters['persiannumerals'] = counters['persian'] +counters['arabicexnumerals'] = counters['persian'] +counters['koreannumerals'] = counters['korean'] +counters['koreanparentnumerals'] = counters['korean-parent'] +counters['koreancirclenumerals'] = counters['korean-circle'] local fallback = utfbyte('0') @@ -207,6 +221,11 @@ function converters.Character (n) return chr (n,upper_offset) end function converters.characters(n) return chrs(n,lower_offset) end function converters.Characters(n) return chrs(n,upper_offset) end +converters['a'] = converters.characters +converters['A'] = converters.Characters +converters['AK'] = converters.Characters +converters['KA'] = converters.Characters + function commands.alphabetic(n,c) context(do_alphabetic(n,counters[c],lowercharacter)) end function commands.Alphabetic(n,c) context(do_alphabetic(n,counters[c],uppercharacter)) end function commands.character (n) context(chr (n,lower_offset)) end @@ -271,6 +290,13 @@ converters.toroman = toroman converters.Romannumerals = toroman converters.romannumerals = function(n) return lower(toroman(n)) end +converters['i'] = converters.romannumerals +converters['I'] = converters.Romannumerals +converters['r'] = converters.romannumerals +converters['R'] = converters.Romannumerals +converters['KR'] = converters.Romannumerals +converters['RK'] = converters.Romannumerals + function commands.romannumerals(n) context(lower(toroman(n))) end function commands.Romannumerals(n) context( toroman(n)) end @@ -472,6 +498,10 @@ function converters.chinesenumerals (n) return tochinese(n,"normal") end function converters.chinesecapnumerals(n) return tochinese(n,"cap" ) end function converters.chineseallnumerals(n) return tochinese(n,"all" ) end +converters['cn'] = converters.chinesenumerals +converters['cn-c'] = converters.chinesecapnumerals +converters['cn-a'] = converters.chineseallnumerals + function commands.chinesenumerals (n) context(tochinese(n,"normal")) end function commands.chinesecapnumerals(n) context(tochinese(n,"cap" )) end function commands.chineseallnumerals(n) context(tochinese(n,"all" )) end @@ -701,8 +731,6 @@ end -- verbose numbers --- verbose numbers - local data = allocate() local verbose = { data = data } converters.verbose = verbose @@ -948,6 +976,20 @@ function commands.verbose(n,language) context(t and t.translate(n) or n) end +-- These are just helpers but not really for the tex end. Do we have to +-- use translate here? + +local whitespace = lpeg.patterns.whitespace +local word = (1-whitespace) / characters.upper * (1-whitespace)^1 +local spacing = whitespace^1 +local pattern_one = Cs(word * P(1)^1) +local pattern_all = Cs((word + spacing)^1) + +function converters.word (s) return s end +function converters.words(s) return s end +function converters.Word (s) return lpegmatch(pattern_one,s) end +function converters.Words(s) return lpegmatch(pattern_all,s) end + -- -- local v_day = variables.day diff --git a/tex/context/base/core-con.mkiv b/tex/context/base/core-con.mkiv index a43473ced..47c7c88d5 100644 --- a/tex/context/base/core-con.mkiv +++ b/tex/context/base/core-con.mkiv @@ -686,8 +686,8 @@ \defineconversion [kr-c] [\koreancirclenumerals] \defineconversion [chinesenumerals] [\chinesenumerals] -\defineconversion [chinesecapnumeralscn] [\chinesecapnumerals] -\defineconversion [chineseallnumeralscn] [\chineseallnumerals] +\defineconversion [chinesecapnumerals] [\chinesecapnumerals] +\defineconversion [chineseallnumerals] [\chineseallnumerals] \defineconversion [cn] [\chinesenumerals] \defineconversion [cn-c] [\chinesecapnumerals] diff --git a/tex/context/base/font-run.mkiv b/tex/context/base/font-run.mkiv index 66f1acc91..cb40adedd 100644 --- a/tex/context/base/font-run.mkiv +++ b/tex/context/base/font-run.mkiv @@ -311,7 +311,7 @@ \ifdefined\databox \else \newbox\databox \fi -\unexpanded\gdef\testminimalbaseline#1% +\unexpanded\gdef\testminimalbaseline#1% to be used in a tabulate {\setbox\databox\ruledhbox{#1}% \scratchdimen\ht\databox \advance\scratchdimen\dp\databox diff --git a/tex/context/base/math-frc.mkiv b/tex/context/base/math-frc.mkiv index f4f3f2b84..7032c665b 100644 --- a/tex/context/base/math-frc.mkiv +++ b/tex/context/base/math-frc.mkiv @@ -106,12 +106,57 @@ \c!rulethickness=.25\exheight, \c!left=0x2E, \c!right=0x2E, + \c!topdistance=, + \c!bottomdistance=, \c!rule=\v!auto] \appendtoks \setuevalue{\currentmathfraction}{\math_frac{\currentmathfraction}}% \to \everydefinemathfraction +% Sometimes users want control over the distances: + +\let\math_fraction_set_distance\relax + +\appendtoks + \math_fraction_set_distance +\to \everymathematics + +\unexpanded\def\math_fraction_set_distance_top + {\Umathfractionnumup \displaystyle\m_math_fraction_distance_top + \relax} + +\unexpanded\def\math_fraction_set_distance_bot + {\Umathfractiondenomdown\displaystyle\m_math_fraction_distance_bot + \relax} + +\unexpanded\def\math_fraction_set_distance_all + {\Umathfractionnumup \displaystyle\m_math_fraction_distance_top + \Umathfractiondenomdown\displaystyle\m_math_fraction_distance_bot + \relax} + +\appendtoks + \ifx\currentmathfraction\empty + \edef\m_math_fraction_distance_top{\mathfractionparameter\c!topdistance}% + \edef\m_math_fraction_distance_bot{\mathfractionparameter\c!bottomdistance}% + \ifx\m_math_fraction_distance_top\empty + \ifx\m_math_fraction_distance_bot\empty + \let\math_fraction_set_distance\relax + \else + \let\math_fraction_set_distance\math_fraction_set_distance_bot + \fi + \else + \ifx\m_math_fraction_distance_bot\empty + \let\math_fraction_set_distance\math_fraction_set_distance_top + \else + \let\math_fraction_set_distance\math_fraction_set_distance_all + \fi + \fi + \fi +\to \everysetupmathfraction + +% So far for control. + \newdimen\d_math_fraction_margin \unexpanded\def\math_frac#1% diff --git a/tex/context/base/math-map.lua b/tex/context/base/math-map.lua index 8d301ac33..f2a588fc7 100644 --- a/tex/context/base/math-map.lua +++ b/tex/context/base/math-map.lua @@ -44,8 +44,8 @@ local registerotffeature = otffeatures.register local setmetatableindex = table.setmetatableindex -local texgetattribute = tex.getattribute -local texsetattribute = tex.setattribute +local texgetattribute = tex.getattribute +local texsetattribute = tex.setattribute local trace_greek = false trackers.register("math.greek", function(v) trace_greek = v end) local report_remapping = logs.reporter("mathematics","remapping") @@ -59,7 +59,52 @@ local mathematics = mathematics -- diagnostics and quick and dirty alphabet tracing (s-mat-10.mkiv) as we deal with -- it otherwise. -mathematics.gaps = { +-- todo: allocate + +mathematics.styles = allocate { "regular", "sansserif", "monospaced", "fraktur", "script", "blackboard" } +mathematics.alternatives = allocate { "normal", "bold", "italic", "bolditalic" } +mathematics.sets = allocate { "ucletters", "lcletters", "digits", "ucgreek", "lcgreek", "symbols" } + +mathematics.charactersets = allocate { + ucletters = { + 0x00041, 0x00042, 0x00043, 0x00044, 0x00045, + 0x00046, 0x00047, 0x00048, 0x00049, 0x0004A, + 0x0004B, 0x0004C, 0x0004D, 0x0004E, 0x0004F, + 0x00050, 0x00051, 0x00052, 0x00053, 0x00054, + 0x00055, 0x00056, 0x00057, 0x00058, 0x00059, + 0x0005A, + }, + lcletters = { + 0x00061, 0x00062, 0x00063, 0x00064, 0x00065, + 0x00066, 0x00067, 0x00068, 0x00069, 0x0006A, + 0x0006B, 0x0006C, 0x0006D, 0x0006E, 0x0006F, + 0x00070, 0x00071, 0x00072, 0x00073, 0x00074, + 0x00075, 0x00076, 0x00077, 0x00078, 0x00079, + 0x0007A, + }, + digits = { + 0x00030, 0x00031, 0x00032, 0x00033, 0x00034, + 0x00035, 0x00036, 0x00037, 0x00038, 0x00039, + }, + ucgreek = { + 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, + 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, + 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, + 0x03A0, 0x03A1, 0x03A3, 0x03A4, 0x03A5, + 0x03A6, 0x03A7, 0x03A8, 0x03A9 + }, + lcgreek = { + 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, + 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, + 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, + 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, + 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, + 0x03D1, 0x03D5, 0x03D6, 0x03F0, 0x03F1, + 0x03F4, 0x03F5 + }, +} + +mathematics.gaps = allocate { [0x1D455] = 0x0210E, -- ℎ h [0x1D49D] = 0x0212C, -- ℬ script B [0x1D4A0] = 0x02130, -- ℰ script E @@ -112,9 +157,10 @@ registerotffeature { -- following approach permits easier remapping of a-a, A-Z and 0-9 to -- fallbacks; symbols is currently mostly greek -local function todigit(n) local t = { } for i=0, 9 do t[0x00030+i] = n+i end return t end -local function toupper(n) local t = { } for i=0,25 do t[0x00041+i] = n+i end return t end -local function tolower(n) local t = { } for i=0,25 do t[0x00061+i] = n+i end return t end +local function todigit (n) local t = { } for i=0, 9 do t[0x00030+i] = n+i end return t end +local function toupper (n) local t = { } for i=0,25 do t[0x00041+i] = n+i end return t end +local function tolower (n) local t = { } for i=0,25 do t[0x00061+i] = n+i end return t end +local function tovector(t) return t end local regular_tf = { digits = todigit(0x00030), @@ -143,7 +189,7 @@ local regular_tf = { } local regular_it = { - digits = regular_tf.digits, + digits = tovector(regular_tf.digits), ucletters = toupper(0x1D434), lcletters = { -- H [0x00061]=0x1D44E, [0x00062]=0x1D44F, [0x00063]=0x1D450, [0x00064]=0x1D451, [0x00065]=0x1D452, @@ -202,7 +248,7 @@ local regular_bf= { } local regular_bi = { - digits = regular_bf.digits, + digits = tovector(regular_bf.digits), ucletters = toupper(0x1D468), lcletters = tolower(0x1D482), ucgreek = { @@ -238,18 +284,18 @@ local sansserif_tf = { digits = todigit(0x1D7E2), ucletters = toupper(0x1D5A0), lcletters = tolower(0x1D5BA), - lcgreek = regular_tf.lcgreek, - ucgreek = regular_tf.ucgreek, - symbols = regular_tf.symbols, + lcgreek = tovector(regular_tf.lcgreek), + ucgreek = tovector(regular_tf.ucgreek), + symbols = tovector(regular_tf.symbols), } local sansserif_it = { - digits = regular_tf.digits, + digits = tovector(regular_tf.digits), ucletters = toupper(0x1D608), lcletters = tolower(0x1D622), - lcgreek = regular_tf.lcgreek, - ucgreek = regular_tf.ucgreek, - symbols = regular_tf.symbols, + lcgreek = tovector(regular_tf.lcgreek), + ucgreek = tovector(regular_tf.ucgreek), + symbols = tovector(regular_tf.symbols), } local sansserif_bf = { @@ -279,7 +325,7 @@ local sansserif_bf = { } local sansserif_bi = { - digits = sansserif_bf.digits, + digits = tovector(sansserif_bf.digits), ucletters = toupper(0x1D63C), lcletters = tolower(0x1D656), ucgreek = { @@ -315,16 +361,20 @@ local monospaced_tf = { digits = todigit(0x1D7F6), ucletters = toupper(0x1D670), lcletters = tolower(0x1D68A), - lcgreek = sansserif_tf.lcgreek, - ucgreek = sansserif_tf.ucgreek, - symbols = sansserif_tf.symbols, + lcgreek = tovector(sansserif_tf.lcgreek), + ucgreek = tovector(sansserif_tf.ucgreek), + symbols = tovector(sansserif_tf.symbols), } +local monospaced_it = tovector(sansserif_it) +local monospaced_bf = tovector(sansserif_bf) +local monospaced_bi = tovector(sansserif_bi) + local monospaced = { tf = monospaced_tf, - it = sansserif_tf, - bf = sansserif_tf, - bi = sansserif_bf, + it = monospaced_tf, + bf = monospaced_tf, + bi = monospaced_bf, } local blackboard_tf = { @@ -362,7 +412,7 @@ local blackboard = { } local fraktur_tf= { - digits = regular_tf.digits, + digits = tovector(regular_tf.digits), ucletters = { -- C H I R Z [0x00041]=0x1D504, [0x00042]=0x1D505, [0x00043]=0x0212D, [0x00044]=0x1D507, [0x00045]=0x1D508, [0x00046]=0x1D509, [0x00047]=0x1D50A, [0x00048]=0x0210C, [0x00049]=0x02111, [0x0004A]=0x1D50D, @@ -372,18 +422,18 @@ local fraktur_tf= { [0x0005A]=0x02128, }, lcletters = tolower(0x1D51E), - lcgreek = regular_tf.lcgreek, - ucgreek = regular_tf.ucgreek, - symbols = regular_tf.symbols, + lcgreek = tovector(regular_tf.lcgreek), + ucgreek = tovector(regular_tf.ucgreek), + symbols = tovector(regular_tf.symbols), } local fraktur_bf = { - digits = regular_bf.digits, + digits = tovector(regular_bf.digits), ucletters = toupper(0x1D56C), lcletters = tolower(0x1D586), - lcgreek = regular_bf.lcgreek, - ucgreek = regular_bf.ucgreek, - symbols = regular_bf.symbols, + lcgreek = tovector(regular_bf.lcgreek), + ucgreek = tovector(regular_bf.ucgreek), + symbols = tovector(regular_bf.symbols), } local fraktur = { -- ok @@ -394,7 +444,7 @@ local fraktur = { -- ok } local script_tf = { - digits = regular_tf.digits, + digits = tovector(regular_tf.digits), ucletters = { -- B E F H I L M R -- P 2118 [0x00041]=0x1D49C, [0x00042]=0x0212C, [0x00043]=0x1D49E, [0x00044]=0x1D49F, [0x00045]=0x02130, [0x00046]=0x02131, [0x00047]=0x1D4A2, [0x00048]=0x0210B, [0x00049]=0x02110, [0x0004A]=0x1D4A5, @@ -411,18 +461,18 @@ local script_tf = { [0x00075]=0x1D4CA, [0x00076]=0x1D4CB, [0x00077]=0x1D4CC, [0x00078]=0x1D4CD, [0x00079]=0x1D4CE, [0x0007A]=0x1D4CF, }, - lcgreek = regular_tf.lcgreek, - ucgreek = regular_tf.ucgreek, - symbols = regular_tf.symbols, + lcgreek = tovector(regular_tf.lcgreek), + ucgreek = tovector(regular_tf.ucgreek), + symbols = tovector(regular_tf.symbols), } local script_bf = { - digits = regular_bf.digits, + digits = tovector(regular_bf.digits), ucletters = toupper(0x1D4D0), lcletters = tolower(0x1D4EA), - lcgreek = regular_bf.lcgreek, - ucgreek = regular_bf.ucgreek, - symbols = regular_bf.symbols, + lcgreek = tovector(regular_bf.lcgreek), + ucgreek = tovector(regular_bf.ucgreek), + symbols = tovector(regular_bf.symbols), } local script = { @@ -441,80 +491,83 @@ local alphabets = allocate { script = script, } -mathematics.alphabets = alphabets +alphabets.tt = tovector(monospaced) +alphabets.ss = tovector(sansserif) +alphabets.rm = tovector(regular) +alphabets.bb = tovector(blackboard) +alphabets.fr = tovector(fraktur) +alphabets.sr = tovector(script) -local boldmap = { } - -local function remap(tf,bf) - for _, alphabet in next, alphabets do - local tfdata = alphabet[tf] - local bfdata = alphabet[bf] - if tfdata then - for k, tfd in next, tfdata do - if type(tfd) == "table" then - local bfd = bfdata[k] - if bfd then - for n, u in next, tfd do - local bn = bfd[n] - if bn then - boldmap[u] = bn - end - end - end - end - end - end - end -end +monospaced.normal = tovector(monospaced_tf) +monospaced.italic = tovector(monospaced_it) +monospaced.bold = tovector(monospaced_bf) +monospaced.bolditalic = tovector(monospaced_bi) + +sansserif.normal = tovector(sansserif_tf) +sansserif.italic = tovector(sansserif_it) +sansserif.bold = tovector(sansserif_bf) +sansserif.bolditalic = tovector(sansserif_bi) + +regular.normal = tovector(regular_tf) +regular.italic = tovector(regular_it) +regular.bold = tovector(regular_bf) +regular.bolditalic = tovector(regular_bi) + +alphabets.serif = tovector(regular) +alphabets.type = tovector(monospaced) +alphabets.teletype = tovector(monospaced) -remap("tf","bf") -remap("it","bi") +mathematics.alphabets = alphabets + +local mathremap = allocate { } +mathematics.mapremap = mathremap -mathematics.boldmap = boldmap +local boldmap = allocate { } +mathematics.boldmap = boldmap -local mathremap = allocate { } +-- all math (a bit of redundancy here) for alphabet, styles in next, alphabets do -- per 9/6/2011 we also have attr for missing for style, data in next, styles do -- let's keep the long names (for tracing) local n = #mathremap + 1 - data.attribute = n - data.alphabet = alphabet - data.style = style - mathremap[n] = data + local d = { + attribute = n, + alphabet = alphabet, + style = style, + } + styles[style] = d + setmetatableindex(d,data) -- we could use a alphadata table + mathremap[n] = d end end -mathematics.mapremap = mathremap - --- beware, these are shared tables (no problem since they're not --- in unicode) - -alphabets.tt = monospaced -alphabets.ss = sansserif -alphabets.rm = regular -alphabets.bb = blackboard -alphabets.fr = fraktur -alphabets.sr = script - -alphabets.serif = regular -alphabets.type = monospaced -alphabets.teletype = monospaced - -regular.normal = regular_tf -regular.italic = regular_it -regular.bold = regular_bf -regular.bolditalic = regular_bi +-- bold math + +local function remapbold(tf,bf) + local styles = mathematics.styles + local sets = mathematics.sets + for i=1,#styles do + for j=1,#sets do + local one = styles[i] + local two = sets[j] + local a = alphabets[one] + local tf = a[tf][two] + local bf = a[bf][two] + if tf and bf then + for k, v in next, tf do + boldmap[v] = bf[k] + end + end + end + end +end -sansserif.normal = sansserif_tf -sansserif.italic = sansserif_it -sansserif.bold = sansserif_bf -sansserif.bolditalic = sansserif_bi +remapbold("tf","bf") +remapbold("it","bi") -monospaced.normal = monospaced_tf -monospaced.italic = monospaced_it -monospaced.bold = monospaced_bf -monospaced.bolditalic = monospaced_bi +-- table.save("e:/tmp/a.lua",alphabets) +-- table.save("e:/tmp/b.lua",boldmap) function mathematics.tostyle(attribute) local r = mathremap[attribute] diff --git a/tex/context/base/math-noa.lua b/tex/context/base/math-noa.lua index a7f0fcf55..3a0af01cc 100644 --- a/tex/context/base/math-noa.lua +++ b/tex/context/base/math-noa.lua @@ -251,40 +251,6 @@ local familymap = { [0] = "pseudobold", } --- families[math_char] = function(pointer) --- if getfield(pointer,"fam") == 0 then --- local a = getattr(pointer,a_mathfamily) --- if a and a > 0 then --- setattr(pointer,a_mathfamily,0) --- if a > 5 then --- local char = getchar(pointer) --- local bold = boldmap[char] --- local newa = a - 3 --- if bold then --- setattr(pointer,a_exportstatus,char) --- setfield(pointer,"char",bold) --- if trace_families then --- report_families("replacing %C by bold %C, family %s with remap %s becomes %s with remap %s",char,bold,a,familymap[a],newa,familymap[newa]) --- end --- else --- if trace_families then --- report_families("no bold replacement for %C, family %s with remap %s becomes %s with remap %s",char,a,familymap[a],newa,familymap[newa]) --- end --- end --- setfield(pointer,"fam",newa) --- else --- if trace_families then --- local char = getchar(pointer) --- report_families("family of %C becomes %s with remap %s",char,a,familymap[a]) --- end --- setfield(pointer,"fam",a) --- end --- else --- -- pointer.fam = 0 --- end --- end --- end - families[math_char] = function(pointer) if getfield(pointer,"fam") == 0 then local a = getattr(pointer,a_mathfamily) diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index 281143e40..555deca2c 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -220,6 +220,7 @@ \defineMPinstance[metafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] \defineMPinstance[extrafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] \defineMPinstance[doublefun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!double] +\defineMPinstance[binaryfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!binary] \defineMPinstance[decimalfun][\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!decimal] \defineMPinstance[mprun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] \defineMPinstance[metapost] [\s!format=mpost] diff --git a/tex/context/base/mlib-lua.lua b/tex/context/base/mlib-lua.lua index 9c7a2e43a..e3a3ba5d8 100644 --- a/tex/context/base/mlib-lua.lua +++ b/tex/context/base/mlib-lua.lua @@ -8,6 +8,8 @@ if not modules then modules = { } end modules ['mlib-pdf'] = { -- This is very preliminary code! +-- maybe we need mplib.model, but how with instances + local type, tostring, select, loadstring = type, tostring, select, loadstring local formatters = string.formatters local find, gsub = string.find, string.gsub @@ -51,14 +53,25 @@ function mp._f_() end end -local f_pair = formatters["(%s,%s)"] -local f_triplet = formatters["(%s,%s,%s)"] -local f_quadruple = formatters["(%s,%s,%s,%s)"] +local f_numeric = formatters["%.16f"] +local f_pair = formatters["(%.16f,%.16f)"] +local f_triplet = formatters["(%.16f,%.16f,%.16f)"] +local f_quadruple = formatters["(%.16f,%.16f,%.16f,%.16f)"] function mp.print(...) for i=1,select("#",...) do - n = n + 1 - buffer[n] = tostring((select(i,...))) + local value = select(i,...) + if value then + n = n + 1 + local t = type(value) + if t == "number" then + buffer[n] = f_numeric(value) + elseif t == "string" then + buffer[n] = value + else + buffer[n] = tostring(value) + end + end end end @@ -113,14 +126,23 @@ end local f_code = formatters["%s return mp._f_()"] -function metapost.runscript(code) - local f = loadstring(f_code(code)) - if f then - return tostring(f()) - else - return "" - end -end +-- function metapost.runscript(code) +-- local f = loadstring(f_code(code)) +-- if f then +-- local result = f() +-- if result then +-- local t = type(result) +-- if t == "number" then +-- return f_numeric(result) +-- elseif t == "string" then +-- return result +-- else +-- return tostring(result) +-- end +-- end +-- end +-- return "" +-- end local cache, n = { }, 0 -- todo: when > n then reset cache or make weak @@ -128,29 +150,34 @@ function metapost.runscript(code) if trace_enabled and trace_luarun then report_luarun("code: %s",code) end + local f if n > 100 then cache = nil -- forget about caching - local f = loadstring(f_code(code)) - if f then - return tostring(f()) - else - return "" - end + f = loadstring(f_code(code)) else - local f = cache[code] - if f then - return tostring(f()) - else + f = cache[code] + if not f then f = loadstring(f_code(code)) if f then n = n + 1 cache[code] = f - return tostring(f()) + end + end + end + if f then + local result = f() + if result then + local t = type(result) + if t == "number" then + return f_numeric(result) + elseif t == "string" then + return result else - return "" + return tostring(result) end end end + return "" end -- function metapost.initializescriptrunner(mpx) diff --git a/tex/context/base/mtx-context-listing.tex b/tex/context/base/mtx-context-listing.tex index d69db9934..2a333c789 100644 --- a/tex/context/base/mtx-context-listing.tex +++ b/tex/context/base/mtx-context-listing.tex @@ -20,7 +20,8 @@ % --sort : sort filenames first % --topspace=dimension : distance above first line % --backspace=dimension : distance before left margin -% --pretty : pretty print comform suffix (temporarily disabled) +% --pretty : pretty print comform suffix +% --scite : pretty print comform suffix using scite lexer % --bodyfont=list : additional bodyfont settings % --paperformat=spec : paper*print or paperxprint % @@ -70,11 +71,16 @@ } local pattern = document.arguments.pattern + local scite = document.arguments.scite if pattern then document.files = dir.glob(pattern) end + if scite then + context.usemodule { "scite" } + end + if #document.files > 0 then if document.arguments.sort then table.sort(document.files) @@ -94,19 +100,24 @@ { function() context.detokenize(pattern and filename or file.basename(filename)) return true end }, { function() context.pagenumber() return true end } ) - if pretty then + if scite then + context.scitefile { filename } -- here { } + elseif pretty then if type(pretty) ~= "string" or pretty == "" then context.setuptyping { option = "color" } else context.setuptyping { option = types[pretty] or pretty } end + context.typefile(filename) + else + context.typefile(filename) end - context.typefile(filename) end end else context("no files given") end + \stopluacode \stoptext diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv index 35b212710..f6548c75b 100644 --- a/tex/context/base/mult-def.mkiv +++ b/tex/context/base/mult-def.mkiv @@ -97,6 +97,7 @@ \def\s!double {double} \def\s!decimal {decimal} +\def\s!binary {binary} \def\s!current {current} diff --git a/tex/context/base/mult-ini.lua b/tex/context/base/mult-ini.lua index 08f1639d0..62e983abc 100644 --- a/tex/context/base/mult-ini.lua +++ b/tex/context/base/mult-ini.lua @@ -265,9 +265,15 @@ function interfaces.cachesetup(t) end end -function interfaces.is_command(str) - return (str and str ~= "" and token.csname_name(token.create(str)) ~= "") or false -- there will be a proper function for this -end +-- if token.lookup then +-- interfaces.is_command = token.lookup +-- else + + function interfaces.is_command(str) + return (str and str ~= "" and token.csname_name(token.create(str)) ~= "") or false -- there will be a proper function for this + end + +-- end function interfaces.interfacedcommand(name) local command = complete.commands[name] diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index 86095edab..f41104986 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -98,6 +98,7 @@ return { "startproject", "stopproject", "project", "starttext", "stoptext", "startnotext", "stopnotext","startdocument", "stopdocument", "documentvariable", "setupdocument", "startmodule", "stopmodule", "usemodule", "usetexmodule", "useluamodule","setupmodule","currentmoduleparameter","moduleparameter", + "everystarttext", -- "startTEXpage", "stopTEXpage", -- "startMPpage", "stopMPpage", -- already catched by nested lexer diff --git a/tex/context/base/mult-mps.lua b/tex/context/base/mult-mps.lua index 104b9d42e..717536fbf 100644 --- a/tex/context/base/mult-mps.lua +++ b/tex/context/base/mult-mps.lua @@ -60,6 +60,8 @@ return { "expandafter", "minute", "hour", "outputformat", "outputtemplate", "filenametemplate", "fontmapfile", "fontmapline", "fontpart", "fontsize", "glyph", "restoreclipcolor", "troffmode", + -- + "runscript", }, commands = { "beginfig", "endfig", diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua index c55db4ea3..78ef409bc 100644 --- a/tex/context/base/node-ref.lua +++ b/tex/context/base/node-ref.lua @@ -416,17 +416,20 @@ function references.get(n) -- not public so functionality can change return sn and sn[1] end -local function makereference(width,height,depth,reference) +local function makereference(width,height,depth,reference) -- height and depth are of parent local sr = stack[reference] if sr then if trace_references then report_reference("resolving attribute %a",reference) end local resolved, ht, dp, set, n = sr[1], sr[2], sr[3], sr[4], sr[5] +-- logs.report("temp","child: ht=%p dp=%p, parent: ht=%p dp=%p",ht,dp,height,depth) if ht then if height < ht then height = ht end if depth < dp then depth = dp end end +-- logs.report("temp","used: ht=%p dp=%p",height,depth) +-- step = 0 local annot = nodeinjections.reference(width,height,depth,set) if annot then annot = tonut(annot) diff --git a/tex/context/base/pack-mrl.mkiv b/tex/context/base/pack-mrl.mkiv index 3e81a4d69..c0097cb5f 100644 --- a/tex/context/base/pack-mrl.mkiv +++ b/tex/context/base/pack-mrl.mkiv @@ -614,7 +614,7 @@ \fi \doifelse{\directtextrulesparameter\c!depthcorrection}\v!on\pack_textrule_correct_depth_yes\pack_textrule_correct_depth_nop \nointerlineskip - \dontleavehmode\vbox + \noindent\vbox % was \dontleavehmode {\color[\directtextrulesparameter\c!rulecolor] {\hrule\s!depth\directtextrulesparameter\c!rulethickness\s!height\zeropoint\s!width\availablehsize}}} {\pack_textrule_with_text{#1}}% diff --git a/tex/context/base/pack-rul.lua b/tex/context/base/pack-rul.lua index 5796da800..0c29eb5f1 100644 --- a/tex/context/base/pack-rul.lua +++ b/tex/context/base/pack-rul.lua @@ -14,6 +14,8 @@ if not modules then modules = { } end modules ['pack-rul'] = { -- challenge: adapt glue_set -- setfield(h,"glue_set", getfield(h,"glue_set") * getfield(h,"width")/maxwidth -- interesting ... doesn't matter much +local type = type + local hlist_code = nodes.nodecodes.hlist local vlist_code = nodes.nodecodes.vlist local box_code = nodes.listcodes.box @@ -29,6 +31,7 @@ local setfield = nuts.setfield local getnext = nuts.getnext local getprev = nuts.getprev local getlist = nuts.getlist +local getid = nuts.getid local getsubtype = nuts.getsubtype local getbox = nuts.getbox @@ -152,3 +155,44 @@ function commands.doanalyzeframedbox(n) texsetdimen("global","framedfirstheight",firstheight or 0) texsetdimen("global","framedlastdepth",lastdepth or 0) end + + +function nodes.maxboxwidth(box) + local boxwidth = getfield(box,"width") + if boxwidth == 0 then + return 0 + end + local list = getlist(box) + if not list then + return 0 + end + if getid(box) == hlist_code then + return boxwidth + end + local lastlinelength = 0 + local maxwidth = 0 + local function check(n,repack) + local l = getlist(n) + if l then + if repack then + local subtype = getsubtype(n) + if subtype == box_code or subtype == line_code then + lastlinelength = node_dimensions(l,getfield(n,"dir")) + else + lastlinelength = getfield(n,"width") + end + else + lastlinelength = getfield(n,"width") + end + if lastlinelength > maxwidth then + maxwidth = lastlinelength + end + end + end + for h in traverse_id(hlist_code,list) do -- no dir etc needed + check(h,true) + end + for v in traverse_id(vlist_code,list) do -- no dir etc needed + check(v,false) + end +end diff --git a/tex/context/base/s-math-coverage.lua b/tex/context/base/s-math-coverage.lua index 5f1c7cc5a..56880f76d 100644 --- a/tex/context/base/s-math-coverage.lua +++ b/tex/context/base/s-math-coverage.lua @@ -6,76 +6,37 @@ if not modules then modules = { } end modules ['s-math-coverage'] = { license = "see context related readme files" } -moduledata.math = moduledata.math or { } -moduledata.math.coverage = moduledata.math.coverage or { } - local utfchar, utfbyte = utf.char, utf.byte local formatters, lower = string.formatters, string.lower local concat = table.concat -local context = context -local NC, NR, HL = context.NC, context.NR, context.HL -local char, getglyph, bold = context.char, context.getglyph, context.bold +moduledata.math = moduledata.math or { } +moduledata.math.coverage = moduledata.math.coverage or { } -local ucgreek = { - 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, - 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, - 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, - 0x03A0, 0x03A1, 0x03A3, 0x03A4, 0x03A5, - 0x03A6, 0x03A7, 0x03A8, 0x03A9 -} +local context = context -local lcgreek = { - 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, - 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, - 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, - 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, - 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, - 0x03D1, 0x03D5, 0x03D6, 0x03F0, 0x03F1, - 0x03F4, 0x03F5 -} +local ctx_NC = context.NC +local ctx_NR = context.NR +local ctx_HL = context.HL -local ucletters = { - 0x00041, 0x00042, 0x00043, 0x00044, 0x00045, - 0x00046, 0x00047, 0x00048, 0x00049, 0x0004A, - 0x0004B, 0x0004C, 0x0004D, 0x0004E, 0x0004F, - 0x00050, 0x00051, 0x00052, 0x00053, 0x00054, - 0x00055, 0x00056, 0x00057, 0x00058, 0x00059, - 0x0005A, -} +local ctx_rawmathematics = context.formatted.rawmathematics +local ctx_mathematics = context.formatted.mathematics +local ctx_startimath = context.startimath +local ctx_stopimath = context.stopimath +local ctx_setmathattribute = context.setmathattribute +local ctx_underbar = context.underbar +local ctx_getglyph = context.getglyph -local lcletters = { - 0x00061, 0x00062, 0x00063, 0x00064, 0x00065, - 0x00066, 0x00067, 0x00068, 0x00069, 0x0006A, - 0x0006B, 0x0006C, 0x0006D, 0x0006E, 0x0006F, - 0x00070, 0x00071, 0x00072, 0x00073, 0x00074, - 0x00075, 0x00076, 0x00077, 0x00078, 0x00079, - 0x0007A, -} +local styles = mathematics.styles +local alternatives = mathematics.alternatives +local charactersets = mathematics.charactersets -local digits = { - 0x00030, 0x00031, 0x00032, 0x00033, 0x00034, - 0x00035, 0x00036, 0x00037, 0x00038, 0x00039, -} - -local styles = { - "regular", "sansserif", "monospaced", "fraktur", "script", "blackboard" -} +local getboth = mathematics.getboth +local remapalphabets = mathematics.remapalphabets -local alternatives = { - "normal", "bold", "italic", "bolditalic" -} - -local alphabets = { - ucletters, lcletters, ucgreek, lcgreek, digits, -} - -local getboth = mathematics.getboth -local remapalphabets = mathematics.remapalphabets - -local chardata = characters.data -local superscripts = characters.superscripts -local subscripts = characters.subscripts +local chardata = characters.data +local superscripts = characters.superscripts +local subscripts = characters.subscripts context.writestatus("math coverage","underline: not remapped") @@ -85,37 +46,37 @@ function moduledata.math.coverage.showalphabets() local style = styles[i] for i=1,#alternatives do local alternative = alternatives[i] - for i=1,#alphabets do - local alphabet = alphabets[i] - NC() + for i=1,#charactersets do + local alphabet = charactersets[i] + ctx_NC() if i == 1 then context("%s %s",style,alternative) end - NC() - context.startimath() - context.setmathattribute(style,alternative) + ctx_NC() + ctx_startimath() + ctx_setmathattribute(style,alternative) for i=1,#alphabet do local letter = alphabet[i] local id = getboth(style,alternative) local unicode = remapalphabets(letter,id) if not unicode then - context.underbar(utfchar(letter)) + ctx_underbar(utfchar(letter)) elseif unicode == letter then context(utfchar(unicode)) else context(utfchar(unicode)) end end - context.stopimath() - NC() + ctx_stopimath() + ctx_NC() local first = alphabet[1] local last = alphabet[#alphabet] local id = getboth(style,alternative) local f_unicode = remapalphabets(first,id) or utfbyte(first) local l_unicode = remapalphabets(last,id) or utfbyte(last) context("%05X - %05X",f_unicode,l_unicode) - NC() - NR() + ctx_NC() + ctx_NR() end end end @@ -126,15 +87,15 @@ function moduledata.math.coverage.showcharacters() context.startmixedcolumns() context.setupalign { "nothyphenated" } context.starttabulate { "|T|i2|Tpl|" } - for u, d in table.sortedpairs(chardata) do + for u, d in table.sortedhash(chardata) do local mathclass = d.mathclass local mathspec = d.mathspec if mathclass or mathspec then - NC() + ctx_NC() context("%05X",u) - NC() - getglyph("MathRoman",u) - NC() + ctx_NC() + ctx_getglyph("MathRoman",u) + ctx_NC() if mathspec then local t = { } for i=1,#mathspec do @@ -145,8 +106,8 @@ function moduledata.math.coverage.showcharacters() else context(mathclass) end - NC() - NR() + ctx_NC() + ctx_NR() end end context.stoptabulate() @@ -157,26 +118,33 @@ end function moduledata.math.coverage.showscripts() context.starttabulate { "|cT|c|cT|c|c|c|l|" } - for k, v in table.sortedpairs(table.merged(superscripts,subscripts)) do + for k, v in table.sortedhash(table.merged(superscripts,subscripts)) do local ck = utfchar(k) local cv = utfchar(v) local ss = superscripts[k] and "^" or "_" - NC() - context("%05X",k) - NC() - context(ck) - NC() - context("%05X",v) - NC() - context(cv) - NC() - context.formatted.rawmathematics("x%s = x%s%s",ck,ss,cv) - NC() - context.formatted.mathematics("x%s = x%s%s",ck,ss,cv) - NC() - context(lower(chardata[k].description)) - NC() - NR() + ctx_NC() context("%05X",k) + ctx_NC() context(ck) + ctx_NC() context("%05X",v) + ctx_NC() context(cv) + ctx_NC() ctx_rawmathematics("x%s = x%s%s",ck,ss,cv) + ctx_NC() ctx_mathematics("x%s = x%s%s",ck,ss,cv) + ctx_NC() context(lower(chardata[k].description)) + ctx_NC() ctx_NR() + end + context.stoptabulate() +end + +-- Handy too. + +function moduledata.math.coverage.showbold() + context.starttabulate { "|lT|cm|lT|cm|lT|" } + for k, v in table.sortedhash(mathematics.boldmap) do + ctx_NC() context("%U",k) + ctx_NC() context("%c",k) + ctx_NC() context("%U",v) + ctx_NC() context("%c",v) + ctx_NC() context(chardata[k].description) + ctx_NC() ctx_NR() end context.stoptabulate() end diff --git a/tex/context/base/s-math-coverage.mkiv b/tex/context/base/s-math-coverage.mkiv index d68ffe587..9f084b284 100644 --- a/tex/context/base/s-math-coverage.mkiv +++ b/tex/context/base/s-math-coverage.mkiv @@ -18,6 +18,7 @@ \installmodulecommandluasingle \showmathalphabets {moduledata.math.coverage.showalphabets} \installmodulecommandluasingle \showmathcharacters {moduledata.math.coverage.showcharacters} \installmodulecommandluasingle \showmathscripts {moduledata.math.coverage.showscripts} +\installmodulecommandluasingle \showmathbold {moduledata.math.coverage.showbold} \stopmodule @@ -30,5 +31,6 @@ \showmathalphabets \page \showmathcharacters \page \showmathscripts \page + \showmathbold \page \stoptext diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index f7a228bfc..60ed193df 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 547c0e785..c6c1623ed 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/strc-blk.mkiv b/tex/context/base/strc-blk.mkiv index 1dd144aa9..bceb66beb 100644 --- a/tex/context/base/strc-blk.mkiv +++ b/tex/context/base/strc-blk.mkiv @@ -41,7 +41,8 @@ \unexpanded\def\strc_blocks_begin[#1][#2]% {\normalexpanded{\buff_pickup{@block@}{\e!begin#1}{\e!end#1}} {}% before - {\ctxcommand{savestructureblock("#1","#2","@block@")}}}% after + {\ctxcommand{savestructureblock("#1","#2","@block@")}}% + \plusone}% after \let\strc_blocks_setup\relax diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index 1aeaa2e56..c25d61741 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -1066,6 +1066,9 @@ \def\tabl_tabulate_insert_content {\tabl_tabulate_insert_head + \ifcase\c_tabl_tabulate_repeathead \else + \tabulatenoalign{\penalty\zerocount}% added 7/5/2014 WS mail + \fi \tabl_tabulate_insert_body \tabl_tabulate_insert_foot \tabl_tabulate_remove_funny_line} @@ -2067,9 +2070,9 @@ \donetrue \fi\fi \ifdone - \c_tabl_tabulate_repeathead\executeifdefined{\??tabulateheader\tabulationparameter\c!header}\zerocount + \global\c_tabl_tabulate_repeathead\executeifdefined{\??tabulateheader\tabulationparameter\c!header}\zerocount \else - \c_tabl_tabulate_repeathead\zerocount + \global\c_tabl_tabulate_repeathead\zerocount \fi % \the\t_tabl_tabulate_initializers_first % collect more here diff --git a/tex/context/base/tabl-xnt.mkvi b/tex/context/base/tabl-xnt.mkvi index ffa1f501e..fd2de5a13 100644 --- a/tex/context/base/tabl-xnt.mkvi +++ b/tex/context/base/tabl-xnt.mkvi @@ -130,6 +130,6 @@ {\bgroup \tabl_x_prepare{#settings}% \edef\tabl_x_current_buffer{\tabl_x_default_buffer}% - \buff_pickup\tabl_x_current_buffer{bTABLE}{eTABLE}\relax\tabl_x_process} + \buff_pickup\tabl_x_current_buffer{bTABLE}{eTABLE}\relax\tabl_x_process\zerocount} \protect \endinput diff --git a/tex/context/base/tabl-xtb.lua b/tex/context/base/tabl-xtb.lua index d9daefe69..5728b80e9 100644 --- a/tex/context/base/tabl-xtb.lua +++ b/tex/context/base/tabl-xtb.lua @@ -66,6 +66,7 @@ local setfield = nuts.setfield local copy_node_list = nuts.copy_list local hpack_node_list = nuts.hpack local flush_node_list = nuts.flush_list +local takebox = nuts.takebox local nodepool = nuts.pool @@ -81,6 +82,7 @@ local v_height = variables.height local v_repeat = variables["repeat"] local v_max = variables.max local v_fixed = variables.fixed +local v_auto = variables.auto local xtables = { } typesetters.xtables = xtables @@ -257,13 +259,26 @@ function xtables.set_reflow_width() elseif dimensionstate == 3 then fixedrows[r] = height -- width fixedcolumns[c] = width -- height - else -- probably something frozen, like an image -- we could parse the list + elseif data.options[v_auto] then -- new per 5/5/2014 + data.autowidths[c] = true + else + -- no dimensions are set in the cell if width <= data.criterium_h and height >= data.criterium_v then + -- somewhat tricky branch if width > fixedcolumns[c] then -- how about a span here? - fixedcolumns[c] = width + -- maybe an image, so let's fix + fixedcolumns[c] = width + end + else + -- safeguard as it could be text that can be recalculated + -- and the previous branch could have happened in a previous + -- row and then forces a wrong one-liner in a multiliner + if width > fixedcolumns[c] then + data.autowidths[c] = true -- new per 5/5/2014 end end end + -- drc.dimensionstate = dimensionstate -- local nx, ny = drc.nx, drc.ny @@ -309,6 +324,7 @@ function xtables.initialize_reflow_height() end texsetdimen("d_tabl_x_width",w) local dimensionstate = drc.dimensionstate or 0 +-- print(r,c,w,data.autowidths[c]) if dimensionstate == 1 or dimensionstate == 3 then -- width was fixed so height is known texsetcount("c_tabl_x_skip_mode",1) @@ -385,7 +401,8 @@ function xtables.set_construct() -- end local drc = row[c] -- this will change as soon as in luatex we can reset a box list without freeing - drc.list = copy_node_list(getbox("b_tabl_x")) +-- drc.list = copy_node_list(getbox("b_tabl_x")) +drc.list = takebox("b_tabl_x") -- c = c + drc.nx - 1 -- data.currentcolumn = c end @@ -395,7 +412,7 @@ local function showwidths(where,widths,autowidths) for i=1,#widths do result[#result+1] = format("%12s%s",points(widths[i]),autowidths[i] and "*" or " ") end - return report_xtable("%s : %s",where,concat(result," ")) + return report_xtable("%s widths: %s",where,concat(result," ")) end function xtables.reflow_width() diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi index cca56dbee..06fb472cd 100644 --- a/tex/context/base/tabl-xtb.mkvi +++ b/tex/context/base/tabl-xtb.mkvi @@ -159,7 +159,7 @@ {\bgroup \tabl_x_prepare{#settings}% \edef\tabl_x_current_buffer{\tabl_x_default_buffer}% - \buff_pickup{\tabl_x_current_buffer}{startxtable}{stopxtable}\relax\tabl_x_process} + \buff_pickup{\tabl_x_current_buffer}{startxtable}{stopxtable}\relax\tabl_x_process\zerocount} \unexpanded\def\processxtablebuffer {\dosingleempty\tabl_x_process_buffer_directly} @@ -175,7 +175,7 @@ {\bgroup \let\tabl_x_start_table\tabl_x_process_buffer \edef\tabl_x_current_buffer{#name}% - \tabl_x_get_buffer % pickup settings + \tabl_x_get_buffer % settings \tabl_x_process} \unexpanded\def\tabl_x_start_ignore[#settings]% @@ -223,7 +223,7 @@ \tabl_x_check_textwidth \forgetall \edef\tabl_x_current_buffer{\tabl_x_default_buffer}% - \normalexpanded{\buff_pickup{\tabl_x_current_buffer}{\e!start\currentxtable}{\e!stop\currentxtable}\relax\tabl_x_process}} + \normalexpanded{\buff_pickup{\tabl_x_current_buffer}{\e!start\currentxtable}{\e!stop\currentxtable}\relax\tabl_x_process\zerocount}} \unexpanded\def\tabl_x_stop_named {} @@ -569,7 +569,7 @@ {\dostarttagged\t!tablecell\empty % can't we just tag the box \setbox\b_tabl_x\hbox\bgroup \letxtableparameter\c!width \d_tabl_x_width % overloads given width - \letxtableparameter\c!height\d_tabl_x_height % overloads given height + \letxtableparameter\c!height\d_tabl_x_height % overloads given height (commenting it ... nice option) \ctxcommand{x_table_init_construct()}% \inheritedxtableframed\bgroup \tabl_x_begin_of_cell diff --git a/tex/context/base/util-sci.lua b/tex/context/base/util-sci.lua index 98b05fe75..c3e24cd9d 100644 --- a/tex/context/base/util-sci.lua +++ b/tex/context/base/util-sci.lua @@ -54,7 +54,7 @@ local f_fore_none = formatters['.%s { display: inline ; font-weight: normal ; c local f_none_bold = formatters['.%s { display: inline ; font-weight: bold ; }'] local f_none_none = formatters['.%s { display: inline ; font-weight: normal ; }'] local f_div_class = formatters['
%s
'] -local f_linenumber = formatters['\n
%s
'] +local f_linenumber = formatters['
%s
\n'] local f_div_number = formatters['.linenumber { display: inline-block ; font-weight: normal ; width: %sem ; margin-right: 2em ; padding-right: .25em ; text-align: right ; background-color: #C7C7C7 ; }'] local replacer_regular = lpeg.replacer { @@ -63,13 +63,18 @@ local replacer_regular = lpeg.replacer { ["&"] = "&", } -local linenumber = 0 +local linenumber = 0 +local linenumbers = { } local replacer_numbered = lpeg.replacer { ["<"] = "<", [">"] = ">", ["&"] = "&", - [lpeg.patterns.newline] = function() linenumber = linenumber + 1 return f_linenumber(linenumber) end, + [lpeg.patterns.newline] = function() + linenumber = linenumber + 1 + linenumbers[linenumber] = f_linenumber(linenumber) + return "\n" + end, } local css = nil @@ -114,24 +119,19 @@ end local function exportstyled(lexer,text,numbered) local result = lexer.lex(lexer,text,0) - local start = 1 + local start = 1 local whites = exportwhites() - local buffer, b = { "
" }, 1
-    linenumber = 1
+    local buffer = { }
+    local b      = 0
+    linenumber   = 0
+    linenumbers  = { }
     local replacer = numbered and replacer_numbered or replacer_regular
-    if numbered then
-        b = b + 1
-        buffer[b] = f_linenumber(1)
-    end
     local n = #result
     for i=1,n,2 do
         local ii = i + 1
         local style = result[i]
         local position = result[ii]
         local txt = sub(text,start,position-1)
-        if ii == n then
-            txt = gsub(txt,"[%s]+$","")
-        end
         txt = lpegmatch(replacer,txt)
         b = b + 1
         if whites[style] then
@@ -141,9 +141,8 @@ local function exportstyled(lexer,text,numbered)
         end
         start = position
     end
-    buffer[b+1] = "
" buffer = concat(buffer) - return buffer + return buffer, concat(linenumbers) end local function exportcsslinenumber() @@ -154,28 +153,44 @@ local htmlfile = utilities.templates.replacer([[ - context util-sci web page: text + %title% -%lexedcontent% + + + + + +
%linenumbers%
%lexedcontent%
]]) -function scite.tohtml(data,lexname,numbered) +function scite.tohtml(data,lexname,numbered,title) + local source, lines = exportstyled(loadedlexers[lexname],data or "",numbered) return htmlfile { - lexedcontent = exportstyled(loadedlexers[lexname],data or "",numbered), -- before numberstyles + lexedcontent = source, -- before numberstyles lexingstyles = exportcsslexing(), numberstyles = exportcsslinenumber(), + title = title or "context source file", + linenumbers = lines, } end -function scite.filetohtml(filename,lexname,targetname,numbered) - io.savedata(targetname or "util-sci.html",scite.tohtml(io.loaddata(filename),lexname or file.suffix(filename),numbered)) +local function maketargetname(name) + if name then + return file.removesuffix(name) .. "-" .. file.suffix(name) .. ".html" + else + return "util-sci.html" + end +end + +function scite.filetohtml(filename,lexname,targetname,numbered,title) + io.savedata(targetname or "util-sci.html",scite.tohtml(io.loaddata(filename),lexname or file.suffix(filename),numbered,title or filename)) end function scite.css() @@ -192,7 +207,7 @@ local htmlfile = utilities.templates.replacer([[ - context util-sci web page: text + %title%