From ef78ab8a5c18ea5f94f4e271e8e5f5416708f7a9 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Sat, 10 Jan 2015 02:15:05 +0100 Subject: 2015-01-10 00:46:00 --- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4385 -> 4383 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/lxml-lpt.lua | 5 +- tex/context/base/page-mix.mkiv | 2 +- tex/context/base/spac-chr.lua | 4 +- tex/context/base/status-files.pdf | Bin 24922 -> 24909 bytes tex/context/base/status-lua.pdf | Bin 333147 -> 333199 bytes tex/context/base/tabl-ntb.mkiv | 3 +- tex/context/base/typo-inj.mkiv | 4 + tex/context/base/typo-sus.lua | 285 +++++++++++++-------- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 12 files changed, 198 insertions(+), 111 deletions(-) (limited to 'tex') diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 4504cef0f..fe4223739 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{2015.01.09 10:43} +\newcontextversion{2015.01.10 00:44} %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 30da9e238..4f788b0c7 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 c502cb58b..06dd636bd 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{2015.01.09 10:43} +\edef\contextversion{2015.01.10 00:44} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua index a914c43ca..a38a7a8e2 100644 --- a/tex/context/base/lxml-lpt.lua +++ b/tex/context/base/lxml-lpt.lua @@ -1134,7 +1134,6 @@ expressions.print = function(...) return true end -expressions.contains = find expressions.find = find expressions.upper = upper expressions.lower = lower @@ -1158,6 +1157,10 @@ function expressions.contains(str,pattern) return false end +function xml.expressions.idstring(str) + return type(str) == "string" and gsub(str,"^#","") or "" +end + -- user interface local function traverse(root,pattern,handle) diff --git a/tex/context/base/page-mix.mkiv b/tex/context/base/page-mix.mkiv index fd72a6b49..ece93c948 100644 --- a/tex/context/base/page-mix.mkiv +++ b/tex/context/base/page-mix.mkiv @@ -367,7 +367,7 @@ {\edef\currentmixedcolumns{#1}% \firstargumentfalse}% \edef\currentmixedcolumnsmethod{\mixedcolumnsparameter\c!method}% - \mixedcolumnsparameter\c!before\relax % so, it doesn't list to local settings ! + \mixedcolumnsparameter\c!before\relax % so, it doesn't listen to local settings ! \csname\??mixedcolumnsbefore\currentmixedcolumnsmethod\endcsname\relax \begingroup \iffirstargument diff --git a/tex/context/base/spac-chr.lua b/tex/context/base/spac-chr.lua index 0cdec4b8f..81c0ce98b 100644 --- a/tex/context/base/spac-chr.lua +++ b/tex/context/base/spac-chr.lua @@ -112,8 +112,8 @@ local function inject_char_space(unicode,head,current,parent) end local function inject_nobreak_space(unicode,head,current,space,spacestretch,spaceshrink) - local attr = getfield(current,"attr") - local glue = new_glue(space,spacestretch,spaceshrink) + local attr = getfield(current,"attr") + local glue = new_glue(space,spacestretch,spaceshrink) local penalty = new_penalty(10000) setfield(glue,"attr",attr) setfield(current,"attr",nil) diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index f65c1abf4..94c0faf0f 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 7fe933655..2ead08753 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/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv index 2a36581b5..02fa82835 100644 --- a/tex/context/base/tabl-ntb.mkiv +++ b/tex/context/base/tabl-ntb.mkiv @@ -1264,7 +1264,8 @@ \fi} \unexpanded\def\tabl_ntb_row_align_stop_inject - {\nointerlineskip + {\par + \nointerlineskip \ifenableTBLbreak \tabl_ntb_after_page \fi diff --git a/tex/context/base/typo-inj.mkiv b/tex/context/base/typo-inj.mkiv index 3ac1c6623..0293f12fa 100644 --- a/tex/context/base/typo-inj.mkiv +++ b/tex/context/base/typo-inj.mkiv @@ -69,5 +69,9 @@ {\setuxvalue{typo_injectors_mark_#1}{\dontleavehmode\noexpand\ctxcommand{markinjector("#1")}}% \setuxvalue{typo_injectors_check_#1}{\noexpand\ctxcommand{checkinjector("#1")}}} +\unexpanded\def\dotestinjector#1% only for testing outside unprotect + {\csname typo_injectors_check_#1\endcsname + \csname typo_injectors_mark_#1\endcsname} + \protect \endinput diff --git a/tex/context/base/typo-sus.lua b/tex/context/base/typo-sus.lua index 6f4947b1f..9eef6196b 100644 --- a/tex/context/base/typo-sus.lua +++ b/tex/context/base/typo-sus.lua @@ -20,43 +20,53 @@ local closequote = { pf = true, } -local categories = characters.categories +local categories = characters.categories -local nodecodes = nodes.nodecodes +local nodecodes = nodes.nodecodes -local glyph_code = nodecodes.glyph -local kern_code = nodecodes.kern -local penalty_code = nodecodes.penalty -local glue_code = nodecodes.glue -local math_code = nodecodes.math -local hlist_code = nodecodes.hlist +local glyph_code = nodecodes.glyph +local kern_code = nodecodes.kern +local penalty_code = nodecodes.penalty +local glue_code = nodecodes.glue +local math_code = nodecodes.math +local hlist_code = nodecodes.hlist +local vlist_code = nodecodes.vlist -local nuts = nodes.nuts -local tonut = nodes.tonut -local tonode = nodes.tonode +local nuts = nodes.nuts +local tonut = nodes.tonut +local tonode = nodes.tonode -local getid = nuts.getid -local getchar = nuts.getchar -local getprev = nuts.getprev -local getnext = nuts.getnext -local getfield = nuts.getfield -local getattr = nuts.getattr -local getfont = nuts.getfont +local getid = nuts.getid +local getchar = nuts.getchar +local getprev = nuts.getprev +local getnext = nuts.getnext +local getfield = nuts.getfield +local getattr = nuts.getattr +local getfont = nuts.getfont +local getlist = nuts.getlist -local setcolor = nodes.tracers.colors.set -local insert_before = nuts.insert_before -local insert_after = nuts.insert_after -local end_of_math = nuts.end_of_math +local setfield = nuts.setfield +local setattr = nuts.setattr -local nodepool = nuts.pool +local setcolor = nodes.tracers.colors.set +local insert_before = nuts.insert_before +local insert_after = nuts.insert_after +local end_of_math = nuts.end_of_math -local new_rule = nodepool.rule -local new_kern = nodepool.kern -local new_penalty = nodepool.penalty +local nodepool = nuts.pool -local a_characters = attributes.private("characters") +local new_rule = nodepool.rule +local new_kern = nodepool.kern +local new_hlist = nodepool.hlist +----- new_penalty = nodepool.penalty -local threshold = 65536 / 4 +local a_characters = attributes.private("characters") +local a_suspecting = attributes.private('suspecting') +local a_suspect = attributes.private('suspect') +local texsetattribute = tex.setattribute +local enabled = false + +local threshold = 65536 / 4 local function special(n) if n then @@ -108,19 +118,19 @@ local function mark(head,current,id,color) head = insert_before(head,current,rule) head = insert_before(head,current,kern) setcolor(rule,color) - elseif id == kern_code then - local width = getfield(current,"kern") - local rule = new_rule(width) - local kern = new_kern(-width) - head = insert_before(head,current,rule) - head = insert_before(head,current,kern) - setcolor(rule,color) + -- elseif id == kern_code then + -- local width = getfield(current,"kern") + -- local rule = new_rule(width) + -- local kern = new_kern(-width) + -- head = insert_before(head,current,rule) + -- head = insert_before(head,current,kern) + -- setcolor(rule,color) else local width = getfield(current,"width") - local rule = new_rule(width,getfield(current,"height"),getfield(current,"depth")) - local kern = new_kern(-width) - head = insert_before(head,current,rule) - head = insert_before(head,current,kern) + local extra = fonts.hashes.xheights[getfont(current)] / 2 + local rule = new_rule(width,getfield(current,"height")+extra,getfield(current,"depth")+extra) + local hlist = new_hlist(rule) + head = insert_before(head,current,hlist) setcolor(rule,color) setcolor(current,"white") end @@ -131,95 +141,164 @@ end -- save enough time and it makes the code looks bad too ... after -- all, we seldom use this -function typesetters.showsuspects(head) +local colors = { + "darkred", + "darkgreen", + "darkblue", + "darkcyan", + "darkmagenta", + "darkyellow", + "darkgray", + "orange", +} + +local found = 0 + +function typesetters.marksuspects(head) local head = tonut(head) local current = head local lastdone = nil while current do - local id = getid(current) - if id == glyph_code then - local char = getchar(current) - local code = categories[char] - local done = false - if punctuation[code] then - local prev, pid = goback(current) - if prev and pid == glue_code then - done = "darkblue" - elseif prev and pid == math_code then - done = "darkgray" - else - local next, nid = goforward(current) - if next and nid ~= glue_code then - done = "darkblue" - end - end - elseif openquote[code] then - local next, nid = goforward(current) - if next and nid == glue_code then - done = "darkred" - end - elseif closequote[code] then - local prev, pid = goback(current) - if prev and pid == glue_code then - done = "darkred" - end - else - local prev, pid = goback(current) - if prev then - if pid == math_code then - done = "darkgray" - elseif pid == glyph_code and getfont(current) ~= getfont(prev) then - if lastdone ~= prev then - done = "darkgreen" + if getattr(current,a_suspecting) then + local id = getid(current) + if id == glyph_code then + local char = getchar(current) + local code = categories[char] + local done = false + if punctuation[code] then + local prev, pid = goback(current) + if prev and pid == glue_code then + done = 3 -- darkblue + elseif prev and pid == math_code then + done = 3 -- darkblue + else + local next, nid = goforward(current) + if next and nid ~= glue_code then + done = 3 -- darkblue end end - end - if not done then + elseif openquote[code] then local next, nid = goforward(current) - if next then - if nid == math_code then - done = "darkgray" - elseif nid == glyph_code and getfont(current) ~= getfont(next) then + if next and nid == glue_code then + done = 1 -- darkred + end + elseif closequote[code] then + local prev, pid = goback(current) + if prev and pid == glue_code then + done = 1 -- darkred + end + else + local prev, pid = goback(current) + if prev then + if pid == math_code then + done = 7-- darkgray + elseif pid == glyph_code and getfont(current) ~= getfont(prev) then if lastdone ~= prev then - done = "darkgreen" + done = 2 -- darkgreen + end + end + end + if not done then + local next, nid = goforward(current) + if next then + if nid == math_code then + done = 7 -- darkgray + elseif nid == glyph_code and getfont(current) ~= getfont(next) then + if lastdone ~= prev then + done = 2 -- darkgreen + end end end end end + if done then + setattr(current,a_suspect,done) + lastdone = current + found = found + 1 + end + current = getnext(current) + elseif id == math_code then + current = getnext(end_of_math(current)) + elseif id == glue_code then + local a = getattr(current,a_characters) + if a then + local prev = getprev(current) + local prid = prev and getid(prev) + local done = false + if prid == penalty_code and getfield(prev,"penalty") == 10000 then + done = 8 -- orange + else + done = 5 -- darkmagenta + end + if done then + setattr(current,a_suspect,done) + -- lastdone = current + found = found + 1 + end + end + current = getnext(current) + else + current = getnext(current) end - if done then - head = mark(head,current,id,done) - lastdone = current - end + else current = getnext(current) - elseif id == math_code then - current = getnext(end_of_math(current)) + end + end + return tonode(head), found > 0 +end + +local function showsuspects(head) + local current = head + while current do + local id = getid(current) + if id == glyph_code then + local a = getattr(current,a_suspect) + if a then + head, current = mark(head,current,id,colors[a]) + end elseif id == glue_code then - local a = getattr(current,a_characters) + local a = getattr(current,a_suspect) if a then - local prev = getprev(current) - local prid = prev and getid(prev) - if prid == penalty_code and getfield(prev,"penalty") == 10000 then - head = mark(head,current,id,"orange") - head = insert_before(head,current,new_penalty(10000)) - else - head = mark(head,current,id,"darkmagenta") + head, current = mark(head,current,id,colors[a]) + end + elseif id == math_code then + current = end_of_math(current) + elseif id == hlist_code or id == vlist_code then + local list = getlist(current) + if list then + local l = showsuspects(list) + if l ~= list then + setfield(current,"list",l) end end - current = getnext(current) - else - current = getnext(current) end + current = getnext(current) end - return tonode(head), false + return head end -nodes.tasks.appendaction("processors","after","typesetters.showsuspects") -nodes.tasks.disableaction("processors","typesetters.showsuspects") +function typesetters.showsuspects(head) + if found > 0 then + return tonode(showsuspects(tonut(head))), true + else + return head, false + end +end + +nodes.tasks.appendaction ("processors","after", "typesetters.marksuspects") +nodes.tasks.prependaction("shipouts", "normalizers","typesetters.showsuspects") + +nodes.tasks.disableaction("processors","typesetters.marksuspects") +nodes.tasks.disableaction("shipouts", "typesetters.showsuspects") -- or maybe a directive trackers.register("typesetters.suspects",function(v) - nodes.tasks.setaction("processors","typesetters.showsuspects",v) + texsetattribute(a_suspecting,v and 1 or unsetvalue) + if v and not enabled then + nodes.tasks.enableaction("processors","typesetters.marksuspects") + nodes.tasks.enableaction("shipouts", "typesetters.showsuspects") + enabled = true + end end) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 737aca4f9..3fff3ee0b 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 01/09/15 10:43:31 +-- merge date : 01/10/15 00:44:31 do -- begin closure to overcome local limits and interference -- cgit v1.2.3