buff-imp-default.lua /size: 1575 b    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
buff-imp-default
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to buff-imp-default.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 9
local
patterns
,
P
,
V
=
lpeg
.
patterns
,
lpeg
.
P
,
lpeg
.
V
10
local
makepattern
=
visualizers
.
makepattern
11 12
local
handler
=
visualizers
.
newhandler
(
)
13 14
local
grammar
=
{
"
visualizer
"
,
15 16
-- basic
17 18
signal
=
makepattern
(
handler
,
"
signal
"
,
visualizers
.
signalpattern
)
,
19
emptyline
=
makepattern
(
handler
,
"
emptyline
"
,
patterns
.
emptyline
)
,
20
beginline
=
makepattern
(
handler
,
"
beginline
"
,
patterns
.
beginline
)
,
21
newline
=
makepattern
(
handler
,
"
newline
"
,
patterns
.
newline
)
,
22
space
=
makepattern
(
handler
,
"
space
"
,
patterns
.
space
)
,
23
default
=
makepattern
(
handler
,
"
default
"
,
patterns
.
utf8character
)
,
24
content
=
makepattern
(
handler
,
"
default
"
,
patterns
.
somecontent
)
,
-- not too efficient
25 26
-- handy
27 28
-- line = V("newline") * V("emptyline")^0 * V("beginline"),
29
line
=
V
(
"
newline
"
)
*
V
(
"
emptyline
"
)
^
0
*
V
(
"
beginline
"
)
+
V
(
"
emptyline
"
)
+
V
(
"
newline
"
)
,
30
whitespace
=
(
V
(
"
space
"
)
+
V
(
"
line
"
)
)
^
1
,
31
optionalwhitespace
=
(
V
(
"
space
"
)
+
V
(
"
line
"
)
)
^
0
,
32 33
-- used
34 35
pattern
=
V
(
"
line
"
)
+
V
(
"
space
"
)
+
V
(
"
signal
"
)
+
V
(
"
content
"
)
,
36
visualizer
=
V
(
"
pattern
"
)
^
1
37 38
}
39 40
local
parser
=
P
(
grammar
)
41 42
visualizers
.
register
(
"
default
"
,
{
parser
=
parser
,
handler
=
handler
,
grammar
=
grammar
}
)
43