summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2015-08-24 11:15:06 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2015-08-24 11:15:06 +0200
commita3f1162458e295b0c0adcd5cbd41529ca9ca7c4d (patch)
tree0eb7c59a2bfb0e59d466362a03a4f6020e46a689
parentd04b4e27d9dcfe3a245b83b2ea7885c95e57b2ca (diff)
downloadcontext-a3f1162458e295b0c0adcd5cbd41529ca9ca7c4d.tar.gz
2015-08-24 10:56:00
-rw-r--r--scripts/context/lua/mtx-context.lua2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/cont-run.lua4
-rw-r--r--tex/context/base/context-version.pdfbin4208 -> 4204 bytes
-rw-r--r--tex/context/base/context.mkiv3
-rw-r--r--tex/context/base/file-job.lua6
-rw-r--r--tex/context/base/lpdf-mis.lua2
-rw-r--r--tex/context/base/page-lin.lua226
-rw-r--r--tex/context/base/page-lin.mkvi13
-rw-r--r--tex/context/base/sort-ini.lua2
-rw-r--r--tex/context/base/sort-lan.lua6
-rw-r--r--tex/context/base/status-files.pdfbin24435 -> 24442 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin255521 -> 255169 bytes
-rw-r--r--tex/context/base/task-ini.lua2
-rw-r--r--tex/context/base/typo-bld.lua13
-rw-r--r--tex/context/base/typo-lin.lua192
-rw-r--r--tex/context/base/typo-lin.mkiv25
-rw-r--r--tex/context/base/typo-mar.lua31
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
19 files changed, 394 insertions, 137 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index 0837a1b50..1cd288d3a 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -590,6 +590,7 @@ function scripts.context.run(ctxdata,filename)
local a_texformat = getargument("texformat")
local a_keeptuc = getargument("keeptuc")
local a_keeplog = getargument("keeplog")
+ local a_export = getargument("export")
-- the following flag is not officially supported because i cannot forsee
-- side effects (so no bug reports please) .. we provide --sandbox that
@@ -716,6 +717,7 @@ function scripts.context.run(ctxdata,filename)
fulljobname = validstring(filename),
files = concat(files,","),
ctx = validstring(ctxname),
+ export = a_export and true or nil,
}
--
for k, v in next, environment.arguments do
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 6da086f23..c8c3251a6 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.08.21 19:57}
+\newcontextversion{2015.08.24 10:53}
%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/cont-run.lua b/tex/context/base/cont-run.lua
index 08bbe5c3c..0420ed01c 100644
--- a/tex/context/base/cont-run.lua
+++ b/tex/context/base/cont-run.lua
@@ -192,7 +192,7 @@ local function processjob()
report("processing as xml: %s",filename)
context.starttext()
- context.xmlprocess("main",filename,"")
+ context.xmlprocess("main",filename,"")
context.stoptext()
elseif suffix == "cld" or arguments.forcecld then
@@ -209,7 +209,7 @@ local function processjob()
report("processing as lua: %s",filename)
context.starttext()
- context.ctxlua(string.format('dofile("%s")',filename))
+ context.ctxlua(string.format('dofile("%s")',filename))
context.stoptext()
elseif suffix == "mp" or arguments.forcemp then
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 978bb525b..4997de8aa 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index e161d8055..de5c4e2d0 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -39,7 +39,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2015.08.21 19:57}
+\edef\contextversion{2015.08.24 10:53}
\edef\contextkind {beta}
%D For those who want to use this:
@@ -190,6 +190,7 @@
%loadmarkfile{supp-num} % obsolete
\loadmarkfile{typo-ini}
+\loadmarkfile{typo-lin}
\loadmarkfile{typo-bld} % par builders
\loadmarkfile{typo-inj}
diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua
index 3a034f0a3..19a02c477 100644
--- a/tex/context/base/file-job.lua
+++ b/tex/context/base/file-job.lua
@@ -64,7 +64,7 @@ local v_project = variables.project
local v_environment = variables.environment
local v_product = variables.product
local v_component = variables.component
-local c_prefix = variables.prefix
+local v_yes = variables.yes
-- main code .. there is some overlap .. here we have loc://
@@ -955,6 +955,10 @@ function document.setcommandline() -- has to happen at the tex end in order to e
context.usepath { arguments.path }
end
+ if arguments.export then
+ context.setupbackend { export = v_yes }
+ end
+
local inputfile = validstring(arguments.input)
if inputfile and dirname(inputfile) == "." and lfs.isfile(inputfile) then
diff --git a/tex/context/base/lpdf-mis.lua b/tex/context/base/lpdf-mis.lua
index e4f5055a4..f09a60902 100644
--- a/tex/context/base/lpdf-mis.lua
+++ b/tex/context/base/lpdf-mis.lua
@@ -365,7 +365,7 @@ local function pagespecification()
extrabox("CropBox",cropoffset,true) -- mandate for rendering
extrabox("TrimBox",trimoffset,true) -- mandate for pdf/x
extrabox("BleedBox",bleedoffset) -- optional
- extrabox("ArtBox",artoffset) -- optional
+ -- extrabox("ArtBox",artoffset) -- optional .. unclear what this is meant to do
end
lpdf.registerpagefinalizer(pagespecification,"page specification")
diff --git a/tex/context/base/page-lin.lua b/tex/context/base/page-lin.lua
index 73dba30b6..359aed877 100644
--- a/tex/context/base/page-lin.lua
+++ b/tex/context/base/page-lin.lua
@@ -43,12 +43,14 @@ local v_no = variables.no
local nodecodes = nodes.nodecodes
local skipcodes = nodes.skipcodes
local whatcodes = nodes.whatcodes
+local listcodes = nodes.listcodes
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
local whatsit_code = nodecodes.whatsit
local glue_code = nodecodes.glue
local glyph_code = nodecodes.glyph
+local line_code = listcodes.line
local leftskip_code = skipcodes.leftskip
local textdir_code = whatcodes.dir
@@ -72,6 +74,9 @@ local getlist = nuts.getlist
local getbox = nuts.getbox
local getfield = nuts.getfield
+local setprop = nuts.setprop
+local getprop = nuts.getprop
+
local setfield = nuts.setfield
local traverse_id = nuts.traverse_id
@@ -92,6 +97,8 @@ local new_kern = nodepool.kern
local ctx_convertnumber = context.convertnumber
local ctx_makelinenumber = context.makelinenumber
+local addtoline = typesetters.paragraphs.addtoline
+
-- cross referencing
function lines.number(n)
@@ -237,38 +244,96 @@ local function check_number(n,a,skip,sameline)
report_lines("skipping line number %s for setup %a: %s (%s)",#current_list,a,s,d.continue or v_no)
end
end
- ctx_makelinenumber(tag,skipflag,s,getfield(n,"width"),getfield(n,"dir"))
+ local p = getprop(n,"line")
+ ctx_makelinenumber(tag,skipflag,s,p.hsize,p.reverse and "TRT" or "TLT") -- getfield(n,"dir"))
end
end
--- xlist
--- xlist
--- hlist
+-- print(nodes.idstostring(list))
-local function identify(list)
- if list then
- for n in traverse_id(hlist_code,list) do
+-- hlists of type line will only have an attribute when the line number attribute
+-- still set at par building time which is not always the case unless we explicitly
+-- do a par before we end the line
+
+-- todo: check for a: when <= 0 then false
+
+local function lineisnumbered(n)
+ local n = getlist(n)
+ while n do
+ local id = getid(n)
+ if id == hlist_code or id == vlist_code then
+ -- this can hit fast as we inherit anchor attributes from parent
local a = getattr(n,a_linenumber)
- if a then
- return list, a
+ if a and a > 0 then
+ return a
+ end
+ elseif id == glyph_code then
+ local a = getattr(n,a_linenumber)
+ if a and a > 0 then
+ return a
+ else
+ return false
end
end
- local n = list
- while n do
- local id = getid(n)
- if id == hlist_code or id == vlist_code then
- local ok, a = identify(getlist(n))
- if ok then
- return ok, a
+ n = getnext(n)
+ end
+end
+
+local function listisnumbered(list)
+ if list then
+ for n in traverse_id(hlist_code,list) do
+ if getsubtype(n) == line_code then
+ local a = getattr(n,a_linenumber)
+ if a then
+ -- a quick test for lines (only valid when \par before \stoplinenumbering)
+ return a > 0 and list or false
+ else
+ -- a bit slower one, assuming that we have normalized and anchored
+ if lineisnumbered(n) then
+ return list
+ end
end
end
- n = getnext(n)
end
end
end
-function boxed.stage_zero(n) -- not used
- return identify(getlist(getbox(n)))
+local function findnumberedlist(list)
+ -- we assume wrapped boxes, only one with numbers
+ local n = list
+ while n do
+ local id = getid(n)
+ if id == hlist_code then
+ if getsubtype(n) == line_code then
+ local a = getattr(n,a_linenumber)
+ if a then
+ return a > 0 and list
+ end
+ return
+ else
+ local list = getlist(n)
+ if lineisnumbered(list) then
+ return n
+ end
+ local okay = findnumberedlist(list)
+ if okay then
+ return okay
+ end
+ end
+ elseif id == vlist_code then
+ local list = getlist(n)
+ if listisnumbered(list) then
+ return list
+ end
+ local okay = findnumberedlist(list)
+ if okay then
+ return okay
+ end
+ elseif id == glyph_code then
+ return
+ end
+ n = getnext(n)
+ end
end
-- reset ranges per page
@@ -279,40 +344,36 @@ function boxed.stage_one(n,nested)
current_list = { }
local box = getbox(n)
if box then
- local found = nil
- local list = getlist(box)
- if list and nested then
- list, found = identify(list)
+ local list = getlist(box)
+ if not list then
+ return
+ end
+ if nested then
+ local id = getid(box)
+ if id == vlist_code then
+ if listisnumbered(list) then
+ -- ok
+ else
+ list = findnumberedlist(list)
+ end
+ else -- hlist
+ list = findnumberedlist(list)
+ end
end
+ -- we assume we have a vlist
if list then
- local last_a, last_v, skip = nil, -1, false
+ local last_a = nil
+ local last_v = -1
+ local skip = false
for n in traverse_id(hlist_code,list) do -- attr test here and quit as soon as zero found
- if getfield(n,"height") == 0 and getfield(n,"depth") == 0 then
+ local subtype = getsubtype(n)
+ if subtype ~= line_code then
+ -- go on
+ elseif getfield(n,"height") == 0 and getfield(n,"depth") == 0 then
-- skip funny hlists -- todo: check line subtype
else
- local list = getlist(n)
- local a = getattr(list,a_linenumber)
--- if a and a < 0 then
--- break
--- end
- if not a or a == 0 then
- local n = getnext(list)
- while n do
- local id = getid(n)
- if id == glyph_code then
- break
- elseif id == whatsit_code and getsubtype(n) == textdir_code then
- n = getnext(n)
- elseif id == glue_code and getsubtype(n) == leftskip_code then -- first in list
- n = getnext(n)
- else
- -- can be hlist or skip (e.g. footnote line)
- n = getnext(n)
- end
- end
- a = n and getattr(n,a_linenumber)
- end
- if a and a > 0 then
+ local a = lineisnumbered(n)
+ if a then
if last_a ~= a then
local da = data[a]
local ma = da.method
@@ -341,54 +402,12 @@ function boxed.stage_one(n,nested)
end
skip = false
end
--- setattr(list,a_linenumber,-1)
end
end
end
end
end
--- todo: a general model for attaching stuff l/r
-
--- setfield(ti,"next",l)
--- setfield(l,"prev",ti)
--- local h = copy_node(n)
--- -- setfield(h,"dir","TLT")
--- setfield(h,"list",ti) -- the number
--- setfield(n,"list",h)
-
--- function boxed.stage_two(n,m)
--- if #current_list > 0 then
--- m = m or lines.scratchbox
--- local t, tn = { }, 0
--- for l in traverse_id(hlist_code,getlist(getbox(m))) do
--- tn = tn + 1
--- t[tn] = copy_node(l) -- use take_box instead
--- end
--- for i=1,#current_list do
--- local li = current_list[i]
--- local n, m, ti = li[1], li[2], t[i]
--- if ti then
--- local d = getfield(n,"dir")
--- local l = getlist(n)
--- if d == "TRT" then
--- local w = getfield(n,"width")
--- ti = hpack_nodes(linked_nodes(new_kern(-w),ti,new_kern(w)))
--- end
--- setfield(ti,"next",l)
--- setfield(l,"prev",ti)
--- setfield(n,"list",ti)
--- resolve(n,m)
--- else
--- report_lines("error in linenumbering (1)")
--- return
--- end
--- end
--- end
--- end
-
-local addtoline = typesetters.paragraphs and typesetters.paragraphs.addtoline
-
function boxed.stage_two(n,m)
if #current_list > 0 then
m = m or lines.scratchbox
@@ -401,19 +420,16 @@ function boxed.stage_two(n,m)
local li = current_list[i]
local n, m, ti = li[1], li[2], t[i]
if ti then
- if addtoline then
- addtoline(n,ti)
- else
- local d = getfield(n,"dir")
- local l = getlist(n)
- if d == "TRT" then
- local w = getfield(n,"width")
- ti = hpack_nodes(linked_nodes(new_kern(-w),ti,new_kern(w)))
- end
- setfield(ti,"next",l)
- setfield(l,"prev",ti)
- setfield(n,"list",ti)
- end
+ -- local d = getfield(n,"dir")
+ -- local l = getlist(n)
+ -- if d == "TRT" then
+ -- local w = getfield(n,"width")
+ -- ti = hpack_nodes(linked_nodes(new_kern(-w),ti,new_kern(w)))
+ -- end
+ -- setfield(ti,"next",l)
+ -- setfield(l,"prev",ti)
+ -- setfield(n,"list",ti)
+ addtoline(n,ti)
resolve(n,m)
else
report_lines("error in linenumbering (1)")
@@ -423,6 +439,10 @@ function boxed.stage_two(n,m)
end
end
+-- function boxed.stage_zero(n) -- not used
+-- return identify(getlist(getbox(n)))
+-- end
+
implement {
name = "linenumbersstageone",
actions = boxed.stage_one,
diff --git a/tex/context/base/page-lin.mkvi b/tex/context/base/page-lin.mkvi
index d7bdd0050..804667e5e 100644
--- a/tex/context/base/page-lin.mkvi
+++ b/tex/context/base/page-lin.mkvi
@@ -421,15 +421,22 @@
\def\page_line_handle_left#align#width#distance%
{\llap
{\page_lines_number_inject#align#width%
- \kern\dimexpr#distance+\d_page_lines_distance\relax
+ \kern\dimexpr
+ #distance+\d_page_lines_distance
+ \ifconditional\c_page_lines_dir_left_to_right\else+\d_page_lines_line_width\fi
+ \relax
\the\everylinenumber
\hss}}
\def\page_line_handle_right#align#width#distance%
{\rlap
- {\kern\dimexpr#distance+\d_page_lines_distance+\d_page_lines_line_width\relax
+ {\kern\dimexpr
+ #distance+\d_page_lines_distance
+ \ifconditional\c_page_lines_dir_left_to_right+\d_page_lines_line_width\fi
+ \relax
\page_lines_number_inject#align#width%
- \the\everylinenumber}}
+ \the\everylinenumber
+ \hss}}
\setuvalue{\??linenumberinghandler\v!left}%
{\page_line_handle_left\p_align\leftmarginwidth\leftmargindistance}
diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua
index c2e07e162..b21308657 100644
--- a/tex/context/base/sort-ini.lua
+++ b/tex/context/base/sort-ini.lua
@@ -312,7 +312,7 @@ local function update() -- prepare parent chains, needed when new languages are
end
end
-local function setlanguage(l,m,d,u) -- this will become a specification table
+local function setlanguage(l,m,d,u) -- this will become a specification table (also keep this one as it's used in manuals)
language = (l ~= "" and l) or constants.defaultlanguage
data = definitions[language or constants.defaultlanguage] or definitions[constants.defaultlanguage]
method = (m ~= "" and m) or (data.method ~= "" and data.method) or constants.defaultmethod
diff --git a/tex/context/base/sort-lan.lua b/tex/context/base/sort-lan.lua
index 6b0cc5007..e84692afc 100644
--- a/tex/context/base/sort-lan.lua
+++ b/tex/context/base/sort-lan.lua
@@ -103,10 +103,10 @@ definitions['de'] = {
},
}
-definitions['deo'] = { parent = 'de' } -- old german
+definitions['deo'] = { parent = 'de' } -- old german
-definitions['de-DE'] = { parent = 'de' } -- german - Germany
-definitions['de-CH'] = { parent = 'de' } -- german - Swiss
+definitions['de-DE'] = { parent = 'de' } -- german - Germany
+definitions['de-CH'] = { parent = 'de' } -- german - Swiss
-- german - Austria
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index c75d2d3ec..39fe66e14 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index d2eb6d76b..39607f265 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/task-ini.lua b/tex/context/base/task-ini.lua
index 986044c6e..192f116e0 100644
--- a/tex/context/base/task-ini.lua
+++ b/tex/context/base/task-ini.lua
@@ -111,6 +111,8 @@ appendaction("math", "builders", "builders.kernel.mlist_to_hlist")
------------("math", "builders", "noads.handlers.italics", nil, "nohead") -- disabled
appendaction("math", "builders", "typesetters.directions.processmath") -- disabled (has to happen pretty late)
+appendaction("finalizers", "normalizers", "typesetters.paragraphs.normalize") -- enabled
+
appendaction("finalizers", "lists", "typesetters.margins.localhandler") -- disabled
appendaction("finalizers", "lists", "builders.paragraphs.keeptogether")
------------("finalizers", "lists", "nodes.handlers.graphicvadjust") -- todo
diff --git a/tex/context/base/typo-bld.lua b/tex/context/base/typo-bld.lua
index bc3fe6911..964d0cd7e 100644
--- a/tex/context/base/typo-bld.lua
+++ b/tex/context/base/typo-bld.lua
@@ -179,7 +179,7 @@ end)
nodes.builders = nodes.builder or { }
local builders = nodes.builders
-local actions = nodes.tasks.actions("vboxbuilders")
+local vboxactions = nodes.tasks.actions("vboxbuilders")
function builders.vpack_filter(head,groupcode,size,packtype,maxdepth,direction)
local done = false
@@ -187,7 +187,7 @@ function builders.vpack_filter(head,groupcode,size,packtype,maxdepth,direction)
starttiming(builders)
if trace_vpacking then
local before = nodes.count(head)
- head, done = actions(head,groupcode,size,packtype,maxdepth,direction)
+ head, done = vboxactions(head,groupcode,size,packtype,maxdepth,direction)
local after = nodes.count(head)
if done then
nodes.processors.tracer("vpack","changed",head,groupcode,before,after,true)
@@ -195,7 +195,7 @@ function builders.vpack_filter(head,groupcode,size,packtype,maxdepth,direction)
nodes.processors.tracer("vpack","unchanged",head,groupcode,before,after,true)
end
else
- head, done = actions(head,groupcode)
+ head, done = vboxactions(head,groupcode)
end
stoptiming(builders)
end
@@ -205,7 +205,8 @@ end
-- This one is special in the sense that it has no head and we operate on the mlv. Also,
-- we need to do the vspacing last as it removes items from the mvl.
-local actions = nodes.tasks.actions("mvlbuilders")
+local pageactions = nodes.tasks.actions("mvlbuilders")
+----- lineactions = nodes.tasks.actions("linebuilders")
local function report(groupcode,head)
report_page_builder("trigger: %s",groupcode)
@@ -241,12 +242,12 @@ function builders.buildpage_filter(groupcode)
if trace_page_builder then
report(groupcode,head)
end
- head, done = actions(head,groupcode)
+ head, done = pageactions(head,groupcode)
stoptiming(builders)
-- -- doesn't work here (not passed on?)
-- tex.pagegoal = tex.vsize - tex.dimen.d_page_floats_inserted_top - tex.dimen.d_page_floats_inserted_bottom
texlists.contrib_head = head or nil -- needs checking
--- tex.setlist("contrib_head",head,head and nodes.tail(head))
+ -- tex.setlist("contrib_head",head,head and nodes.tail(head))
return done and head or true -- no return value needed
else
-- happens quite often
diff --git a/tex/context/base/typo-lin.lua b/tex/context/base/typo-lin.lua
new file mode 100644
index 000000000..fcd68da7d
--- /dev/null
+++ b/tex/context/base/typo-lin.lua
@@ -0,0 +1,192 @@
+if not modules then modules = { } end modules ['typo-lin'] = {
+ version = 1.001,
+ comment = "companion to typo-lin.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- can become typo-par or so
+
+local trace_anchors = false trackers.register("paragraphs.anchors", function(v) trace_anchors = v end)
+
+local nuts = nodes.nuts
+local nodecodes = nodes.nodecodes
+local gluecodes = nodes.gluecodes
+local listcodes = nodes.listcodes
+local whatcodes = nodes.whatsitcodes
+
+local hlist_code = nodecodes.hlist
+local glue_code = nodecodes.glue
+local whatsit_code = nodecodes.whatsit
+local line_code = listcodes.line
+local leftskip_code = gluecodes.leftskip
+local rightskip_code = gluecodes.rightskip
+local textdir_code = whatcodes.textdir
+local localpar_code = whatcodes.localpar
+
+local tonut = nodes.tonut
+local tonode = nodes.tonode
+
+local traverse_id = nuts.traverse_id
+local insert_before = nuts.insert_before
+local insert_after = nuts.insert_after
+local findtail = nuts.tail
+local remove_node = nuts.remove
+local hpack_nodes = nuts.hpack
+
+local getsubtype = nuts.getsubtype
+local getlist = nuts.getlist
+local getid = nuts.getid
+local getnext = nuts.getnext
+local getfield = nuts.getfield
+local setfield = nuts.setfield
+
+local setprop = nuts.setprop
+local getprop = nuts.getprop
+
+local nodepool = nuts.pool
+local new_glue = nodepool.glue
+local new_kern = nodepool.kern
+local new_leftskip = nodepool.leftskip
+local new_rightskip = nodepool.rightskip
+local new_hlist = nodepool.hlist
+local new_vlist = nodepool.vlist
+local new_rule = nodepool.rule
+
+local texgetcount = tex.getcount
+
+local paragraphs = { }
+typesetters.paragraphs = paragraphs
+
+-- also strip disc
+
+-- We only need to normalize the left side because when we mess around
+-- we keep the page stream order (and adding content to the right of the
+-- line is a no-go for tagged etc. For the same reason we don't use two
+-- left anchors (each side fo leftskip) because there can be stretch. But,
+-- maybe there are good reasons for having just that anchor (mostly for
+-- educational purposes I guess.)
+
+-- At this stage the localpar node is no longer of any use so we remove
+-- it (each line has the direction attached). We might at some point also
+-- strip the disc nodes as they no longer serve a purpose but that can
+-- better be a helper. Anchoring left has advantage of keeping page stream.
+
+-- indent : hlist type 3
+-- hangindent : shift and width
+
+-- new_glue(0,65536,65536,2,2) -- hss (or skip -width etc)
+
+-- -- rightskip checking
+--
+-- local tail = findtail(head)
+-- local rightskip = nil
+-- local right = new_hlist()
+-- local id = getid(tail)
+-- if id == glue_code then
+-- local subtype = getsubtype(tail)
+-- if subtype == rightskip_code then
+-- rightskip = tail
+-- end
+-- end
+-- if not rightskip then
+-- print("inserting rightskip")
+-- rightskip = new_rightskip()
+-- insert_after(head,tail,rightskip)
+-- tail = rightskip
+-- end
+-- insert_after(head,tail,right)
+--
+-- tail = tail,
+-- right = {
+-- pack = right,
+-- head = nil,
+-- tail = nil,
+-- }
+
+-- todo: see if we can hook into box in buildpagefilter .. saves traverse
+
+function paragraphs.normalize(head,...)
+ if texgetcount("pagebodymode") > 0 then
+ -- can be an option, maybe we need a proper state in lua itself
+ return head, false
+ end
+ for line in traverse_id(hlist_code,tonut(head)) do
+ if getsubtype(line) == line_code then
+ local head = getlist(line)
+ local leftskip = nil
+ local anchor = new_hlist()
+ local id = getid(head)
+ local shift = getfield(line,"shift")
+ local width = getfield(line,"width")
+ local hsize = tex.hsize
+ local reverse = getfield(line,"dir") == "TRT" or false
+ if id == glue_code then
+ local subtype = getsubtype(head)
+ if subtype == leftskip_code then
+ leftskip = head
+ end
+ local next = getnext(head)
+ if next and getsubtype(next) == localpar_code then
+ head = remove_node(head,next,true)
+ end
+ elseif id == whatsit_code then
+ if getsubtype(head) == localpar_code then
+ head = remove_node(head,head,true)
+ end
+ end
+ head = insert_before(head,head,anchor)
+ if reverse then
+ shift = shift + width - hsize
+ head = insert_before(head,head,new_kern(shift))
+ insert_after(head,anchor,new_kern(-shift))
+ else
+ head = insert_before(head,head,new_kern(-shift))
+ end
+ if not leftskip then
+ head = insert_before(head,head,new_leftskip(0))
+ end
+setfield(anchor,"attr",getfield(line,"attr"))
+-- print(nodes.idstostring(head))
+-- print("NORMALIZE",line)
+ setfield(line,"list",head)
+ setprop(line,"line",{
+ reverse = reverse,
+ width = width,
+ hsize = hsize,
+ shift = shift,
+ head = head,
+ anchor = {
+ pack = anchor,
+ head = nil,
+ tail = nil,
+ },
+ })
+ end
+ end
+ return head, true
+end
+
+function paragraphs.addtoline(n,list)
+ local line = getprop(n,"line")
+ if line then
+ if trace_anchors and not line.traced then
+ line.traced = true
+ local rule = new_rule(2*65536,2*65536,1*65536)
+ local list = insert_before(rule,rule,new_kern(-1*65536))
+ paragraphs.addtoline(n,list)
+ end
+ local list = tonut(list)
+ local what = line.anchor
+ local tail = what.tail
+ local blob = new_hlist(list)
+ if tail then
+ insert_after(what.head,what.tail,blob)
+ else
+ setfield(what.pack,"list",blob)
+ what.head = blob
+ end
+ what.tail = blob
+ end
+end
diff --git a/tex/context/base/typo-lin.mkiv b/tex/context/base/typo-lin.mkiv
new file mode 100644
index 000000000..eba08b4c8
--- /dev/null
+++ b/tex/context/base/typo-lin.mkiv
@@ -0,0 +1,25 @@
+%D \module
+%D [ file=typo-lin,
+%D version=2015.08.01,
+%D title=\CONTEXT\ Typographic Macros,
+%D subtitle=Line Normalization,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%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 Typographic Macros / Normalization}
+
+%D Beware: the mvl callback is also called when a line is added to a vbox.
+
+\registerctxluafile{typo-lin}{1.001}
+
+\unprotect
+
+% nothing yet / experimental
+
+\protect \endinput
+
diff --git a/tex/context/base/typo-mar.lua b/tex/context/base/typo-mar.lua
index 9808c55c7..832d29279 100644
--- a/tex/context/base/typo-mar.lua
+++ b/tex/context/base/typo-mar.lua
@@ -179,6 +179,8 @@ local texget = tex.get
local isleftpage = layouts.status.isleftpage
local registertogether = builders.paragraphs.registertogether -- tonode
+local addtoline = typesetters.paragraphs.addtoline
+
local a_margindata = attributes.private("margindata")
local a_specialcontent = attributes.private("specialcontent")
local a_linenumber = attributes.private('linenumber')
@@ -681,20 +683,21 @@ local function inject(parent,head,candidate)
end
setfield(box,"shift",shift)
setfield(box,"width",0)
- if not head then
- head = box
- elseif getid(head) == whatsit_code and getsubtype(head) == localpar_code then
- -- experimental
- if getfield(head,"dir") == "TRT" then
- local list = hpack_nodes(linked_nodes(new_kern(candidate.hsize),getlist(box),new_kern(-candidate.hsize)))
- setfield(box,"list",list)
- end
- insert_node_after(head,head,box)
- else
- setfield(head,"prev",box)
- setfield(box,"next",head)
- head = box
- end
+ -- if not head then
+ -- head = box
+ -- elseif getid(head) == whatsit_code and getsubtype(head) == localpar_code then
+ -- -- experimental
+ -- if getfield(head,"dir") == "TRT" then
+ -- local list = hpack_nodes(linked_nodes(new_kern(candidate.hsize),getlist(box),new_kern(-candidate.hsize)))
+ -- setfield(box,"list",list)
+ -- end
+ -- insert_node_after(head,head,box)
+ -- else
+ -- setfield(head,"prev",box)
+ -- setfield(box,"next",head)
+ -- head = box
+ -- end
+ addtoline(parent,box)
setattr(box,a_margindata,nofstatus)
if trace_margindata then
report_margindata("injected, location %a, shift %p",location,shift)
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index cc522eb5c..b1babe8c9 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 : 08/21/15 19:57:22
+-- merge date : 08/24/15 10:53:49
do -- begin closure to overcome local limits and interference