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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
%D \module
%D [ file=typo-fln,
%D version=2013.08.22, % comes from the few years older m-newstuff
%D title=\CONTEXT\ Typesetting Macros,
%D subtitle=First Lines,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{ConTeXt Typesetting Macros / First Lines}
%D I had this code laying around for a while \unknown\ probably as a side effect
%D of cleaning up the supp-fun modules. There is probably room for improvement
%D and more features.
% \setupbodyfont[pagella]
%
% \starttext
%
% \setupindenting[medium,yes]
%
% \definefirstline
% [smallcaps]
% [alternative=line,
% color=darkred,
% style=\setfontfeature{smallcaps}]
%
% \setfirstline[smallcaps] \input tufte \par
% \setfirstline[smallcaps] \input ward \par
% \setfirstline[smallcaps] \input knuth \par
% \setfirstline[smallcaps] \input bryson \par
%
% \definefirstline
% [smallcaps]
% [alternative=word,
% color=darkblue,
% style=bold,
% n=2]
%
% \setfirstline[smallcaps] \input tufte \par
% \setfirstline[smallcaps] \input ward \par
% \setfirstline[smallcaps] \input knuth \par
% \setfirstline[smallcaps] \input bryson \par
%
% \stoptext
\unprotect
\registerctxluafile{typo-fln}{1.001}
\definesystemattribute[firstline][public]
\installcorenamespace {firstline}
\installcommandhandler \??firstline {firstline} \??firstline
\setupfirstline
[\c!alternative=\v!line,
%\c!style=,
%\c!color=,
\c!n=0]
\appendtoks
\begingroup
\usefirstlinestyleandcolor\c!style\c!color
\setxvalue{\??firstline:\currentfirstline}{\ctxlua{commands.definefirstline {
alternative = "\firstlineparameter\c!alternative",
ma = \the\attribute\colormodelattribute,
ca = \the\attribute\colorattribute,
ta = \the\attribute\transparencyattribute,
n = \number\firstlineparameter\c!n,
font = \fontid\font,
dynamic = \number\attribute\zerocount,
}}}%
\endgroup
\to \everydefinefirstline
\unexpanded\def\setfirstline[#1]%
{\ifcsname\??firstline:#1\endcsname
\edef\typo_firstline_set{\typo_firstline_set_indeed{\number\csname\??firstline:#1\endcsname}}%
\else
\let\typo_firstline_set\relax
\fi}
\unexpanded\def\typo_firstline_set_indeed#1%
{\dontleavehmode
\begingroup
\attribute\firstlineattribute#1\relax
\kern\zeropoint % we need a node
\hskip\zeropoint\s!plus\emwidth\relax % can be an option
\globallet\typo_firstline_set\relax
\endgroup}
\let\typo_firstline_set\relax
% \appendtoks
% \typo_firstline_set % has to be done later
% \to \everypar
\protect
\endinput
|