1if not modules then modules = { } end modules ['spac-hor'] = {
2 version = 1.001,
3 comment = "companion to spac-hor.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local lpegmatch, P, C = lpeg.match, lpeg.P, lpeg.C
10
11local context = context
12
13local chardata = characters.data
14
15local p_check = P("the ") * (P("letter") + P("character")) * P(" ") * lpeg.patterns.utf8byte
16
17local can_have_space = table.tohash {
18 "lu", "ll", "lt", "lm", "lo",
19
20 "nd", "nl", "no",
21 "ps", "pi",
22
23
24 "sm", "sc", "sk", "so",
25
26
27}
28
29local function autonextspace(str)
30 local b = lpegmatch(p_check,str)
31 if b then
32 local d = chardata[b]
33 if d and can_have_space[d.category] then
34 context.space()
35 end
36 end
37end
38
39interfaces.implement {
40 name = "autonextspace",
41 actions = autonextspace,
42 arguments = "string",
43}
44 |