summaryrefslogtreecommitdiff
path: root/tex/context/base/typo-wrp.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2014-11-12 19:15:03 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2014-11-12 19:15:03 +0100
commit58113383a37974c6d65694c80dbfabd96f29b4c2 (patch)
treeb5ff6951468a9d8ebe3937da4f2f16b8b2d838c3 /tex/context/base/typo-wrp.lua
parent412796f51a6c4e721018f37242013d62d7d82ad6 (diff)
downloadcontext-58113383a37974c6d65694c80dbfabd96f29b4c2.tar.gz
2014-11-12 18:18:00
Diffstat (limited to 'tex/context/base/typo-wrp.lua')
-rw-r--r--tex/context/base/typo-wrp.lua64
1 files changed, 64 insertions, 0 deletions
diff --git a/tex/context/base/typo-wrp.lua b/tex/context/base/typo-wrp.lua
new file mode 100644
index 000000000..e859d2ef2
--- /dev/null
+++ b/tex/context/base/typo-wrp.lua
@@ -0,0 +1,64 @@
+if not modules then modules = { } end modules ['typo-wrp'] = {
+ version = 1.001,
+ comment = "companion to typo-wrp.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local nodecodes = nodes.nodecodes
+
+local glue_code = nodecodes.glue
+local penalty_code = nodecodes.penalty
+local parfill_skip_code = nodes.gluecodes.parfillskip
+local user_penalty_code = nodes.penaltycodes.userpenalty
+
+local nuts = nodes.nuts
+local tonut = nodes.tonut
+local tonode = nodes.tonode
+
+local findtail = nuts.tail
+local getprev = nuts.getprev
+local getid = nuts.getid
+local getsubtype = nuts.getsubtype
+local getfield = nuts.getfield
+local remove = nuts.remove
+
+local wrappers = { }
+typesetters.wrappers = wrappers
+
+-- we really need to pass tail too ... but then we need to check all the plugins
+-- bah ... slowdown
+
+local function remove_dangling_crlf(head,tail)
+ if tail and getid(tail) == glue_code and getsubtype(tail) == parfill_skip_code then
+ tail = getprev(tail)
+ if tail and getid(tail) == penalty_code and getsubtype(tail) == user_penalty_code and getfield(tail,"penalty") == 10000 then
+ tail = getprev(tail)
+ if tail and getid(tail) == penalty_code and getsubtype(tail) == user_penalty_code and getfield(tail,"penalty") == -10000 then
+ if tail == head then
+ -- can't happen
+ else
+ remove(head,tail,true)
+ return head, tail, true
+ end
+ end
+ end
+ end
+ return head, tail, false
+end
+
+function wrappers.handler(head)
+ local head = tonut(head)
+ if head then
+ local tail = findtail(head)
+ local done = false
+ head, tail, done = remove_dangling_crlf(head,tail) -- will be action chain
+ end
+ return head, true
+end
+
+function commands.enablecrlf()
+ nodes.tasks.enableaction("processors","typesetters.wrappers.handler")
+ function commands.enablecrlf() end
+end