mtx-context-select.tex /size: 2896 b    last modification: 2020-07-01 14:35
1
% engine=luatex
2 3
%D \module
4
%D [ file=mtx-context-select,
5
%D version=2008.11.10, % about that time i started playing with this
6
%D title=\CONTEXT\ Extra Trickry,
7
%D subtitle=Selecting Files,
8
%D author=Hans Hagen,
9
%D date=\currentdate,
10
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
11
%C
12
%C This module is part of the \CONTEXT\ macro||package and is
13
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
14
%C details.
15 16
%D This is a \TEXEXEC\ features that has been moved to \MKIV.
17 18
% begin help
19
%
20
% usage: context --extra=select [options] list-of-files
21
%
22
% --sort : sort filenames first
23
% --topspace=dimension : distance above first line
24
% --backspace=dimension : distance before left margin
25
% --selection=list : n:m,p:q,...
26
% --paperformat=spec : paper*print or paperxprint or 'fit'
27
% --interaction : add hyperlinks
28
%
29
% end help
30 31
\input
mtx
-
context
-
common
.
tex
32 33
\setuppapersize
34
[
\getdocumentargumentdefault
{
paperformat
_
paper
}{
A
4
}
]
35
[
\getdocumentargumentdefault
{
paperformat
_
print
}{
A
4
}
]
36 37
\setuppaper
38
[
offset
=
\getdocumentargumentdefault
{
paperoffset
}{
0
pt
}
]
39 40
\setuplayout
41
[
width
=
middle
,
42
height
=
middle
,
43
topspace
=
\getdocumentargumentdefault
{
topspace
}{
0
pt
}
,
44
backspace
=
\getdocumentargumentdefault
{
backspace
}{
0
pt
}
,
45
location
=
middle
,
46
header
=
0
pt
,
47
footer
=
0
pt
]
48 49
\doif
{
\getdocumentargument
{
marking
}}
{
yes
}
{
50
\setuplayout
51
[
marking
=
on
]
52
}
53 54
\doif
{
\getdocumentargument
{
interaction
}}
{
yes
}
{
55
\setupinteraction
56
[
state
=
start
]
57
\setupexternalfigures
58
[
interaction
=
yes
]
59
}
60 61
\setupexternalfigures
62
[
directory
=]
63 64
\doifelse
{
\getdocumentargument
{
paperformat
_
paper
}}
{
fit
}
{
65
\doifdocumentfilename
{
1
}
{
66
\getfiguredimensions
67
[
\getdocumentfilename
{
1
}
]
68
\definepapersize
69
[
fit
]
70
[
width
=
\figurewidth
,
71
height
=
\figureheight
]
72
\setuppapersize
73
[
fit
]
74
[
fit
]
75
}
76
}
77 78
\starttext
79 80
\startluacode
81 82
local
papersize
=
document
.
arguments
.
paperformat_paper
or
"
A4
"
83
local
printsize
=
document
.
arguments
.
paperformat_print
or
"
A4
"
84
local
selection
=
document
.
arguments
.
selection
or
"
"
85
local
textwidth
=
document
.
arguments
.
textwidth
or
"
0cm
"
-- needed ?
86 87
if
#
document
.
files
=
=
0
then
88
context
(
"
no files given
"
)
89
elseif
selection
=
=
"
"
then
90
context
(
"
no selection given
"
)
91
else
92
if
document
.
arguments
.
sort
then
93
table
.
sort
(
document
.
files
)
94
end
95
for
_
,
filename
in
ipairs
(
document
.
files
)
do
96
if
not
string
.
find
(
filename
,
"
^mtx%-context%-
"
)
then
97
logs
.
report
(
"
select
"
,
filename
)
98
context
.
filterpages
(
99
{
filename
}
,
100
{
selection
}
,
101
{
width
=
textwidth
}
102
)
103
end
104
end
105
end
106 107
\stopluacode
108 109
\stoptext
110 111