s-references-show.mkiv /size: 3086 b    last modification: 2021-10-28 13:51
1
%D \module
2
%D [ file=s-references-show.mkiv,
3
%D version=2015.04.13,
4
%D title=\CONTEXT\ Style File,
5
%D subtitle=Reference Checking,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\startmodule
[
references
-
show
]
15 16
\unprotect
17 18
% \enabletrackers[nodes.references,nodes.destinations] % also shows areas
19 20
\enabletrackers
[
nodes
.
references
.
show
,
nodes
.
destinations
.
show
]
21 22
\enablehiddenbackground
% trick
23 24
\appendhiddenbackground
{
trace
-
references
}
25 26
\defineoverlay
27
[
trace
-
references
]
28
[
\directsetup
{
trace
:
references
:
onpage
}
]
29 30
\startluacode
31
local
pagelist
=
structures
.
references
.
tracedpages
32 33
function
commands
.
getreferencesonpage
(
n
)
34
n
=
tonumber
(
n
)
35
if
n
then
36
local
pagedata
=
pagelist
[
n
]
37
if
pagedata
then
38
context
(
"
%s references
"
,
#
pagedata
)
39
context
.
blank
(
)
40
for
i
=
1
,
#
pagedata
do
41
local
details
=
pagedata
[
i
]
42
local
prefix
=
details
[
1
]
43
local
reference
=
details
[
2
]
44
-- local internal = details[3]
45
-- context("%04i = %s : %s",internal,prefix == "" and "-" or prefix,reference)
46
context
(
"
%s : %s
"
,
prefix
=
=
"
"
and
"
-
"
or
prefix
,
reference
)
47
context
.
par
(
)
48
end
49
else
50
context
(
"
no references
"
)
51
end
52
else
53
context
(
"
no valid page
"
)
54
end
55
end
56 57
\stopluacode
58 59
\definecolor
60
[
trace
:
references
:
onpage
]
61
[
b
=
.
5
,
a
=
1
,
t
=
.
2
5
]
62 63
\defineframed
64
[
trace
:
references
:
onpage
]
65
[
\c!offset
=
2
\exheight
,
66
%\c!foregroundstyle=\infofont,
67
\c!frame
=
\v!off
,
68
\c!background
=
\v!color
,
69
\c!backgroundcolor
=
trace
:
references
:
onpage
,
70
\c!align
=
\v!normal
]
71 72
\startsetups
trace
:
references
:
onpage
73
\vbox
to
\vsize
\bgroup
74
\infofont
75
\vskip
\dimexpr
-
\topspace
-
\headerheight
+
2
\exheight
\relax
76
\hbox
to
\hsize
\bgroup
77
\doifoddpageelse
\hss
{
\hskip
\dimexpr
-
\cutspace
+
2
\exheight
\relax
}
%
78
\directlocalframed
[
79
trace
:
references
:
onpage
80
]
{
81
\ctxcommand{
getreferencesonpage
(
\the
\realpageno
)
}
82
}
83
\doifoddpageelse
{
\hskip
\dimexpr
-
\cutspace
+
2
\exheight
\relax
}
\hss
84
\egroup
85
\vss
86
\egroup
87
\stopsetups
88 89
\protect
90 91
\continueifinputfile
{
s
-
references
-
show
.
mkiv
}
92 93
\usemodule
[
art
-
0
1
]
94 95
\setupinteraction
96
[
state
=
start
]
97 98
\setuppagenumbering
99
[
alternative
=
doublesided
]
100 101
\starttext
102 103
\title
{
Contents
}
104 105
\placelist
[
chapter
]
106 107
\setupreferenceprefix
[
zero
]
108 109
\chapter
[
crap
]
{
foo
}
110 111
\setupreferenceprefix
[
one
]
112 113
test
\pagereference
[
whatever
]
114 115
\dorecurse
{
5
}
{
116
\placefigure
117
[
here
]
[
bar
1
.
#
1
]
118
{
xx
}
{
\framed
{
xx
#
1
}
}
119
}
120 121
\setupreferenceprefix
[
two
]
122 123
\dorecurse
{
5
}
{
124
\placefigure
125
[
here
]
[
bar
2
.
#
1
]
126
{
xx
}
{
\framed
{
xx
#
1
}
}
127
}
128 129
\in
{
checked
}
[
bar
1
.
1
]
130
\in
{
checked
}
[
bar
2
.
1
]
131 132
\stoptext
133