summaryrefslogtreecommitdiff
path: root/tex/context/base/supp-box.lua
blob: 49d16ed2aa77b9f468503f3de4169934a4ffcbc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
if not modules then modules = { } end modules ['supp-box'] = {
    version   = 1.001,
    comment   = "companion to supp-box.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

-- this is preliminary code

local nodecodes   = nodes.nodecodes

local disc_code   = nodecodes.disc
local hlist_code  = nodecodes.hlist
local vlist_code  = nodecodes.vlist

local new_penalty = nodes.pool.penalty
local free_node   = node.free

function hyphenatedlist(list)
    while list do
        local id = list.id
        local next = list.next
        local prev = list.prev
        if id == disc_code then
            local hyphen = list.pre
            if hyphen then
                local penalty = new_penalty(-500)
                hyphen.next = penalty
                penalty.prev = hyphen
                prev.next = hyphen
                next.prev = penalty
                penalty.next = next
                hyphen.prev = prev
                list.pre = nil
                free_node(list)
            end
        elseif id == vlist_code or id == hlist_code then
            hyphenatedlist(list.list)
        end
        list = next
    end
end

commands.hyphenatedlist = hyphenatedlist

function commands.showhyphenatedinlist(list)
    commands.writestatus("show hyphens",nodes.listtoutf(list))
end

-- processisolatedwords