1%D \module 2%D [ file=typo-fln, 3%D version=2013.08.22, % comes from the few years older m-newstuff 4%D title=\CONTEXT\ Typesetting Macros, 5%D subtitle=First Lines, 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\writestatus{loading}{ConTeXt Typesetting Macros / First Lines} 15 16%D I had this code laying around for a while \unknown\ probably as a side effect 17%D of cleaning up the supp-fun modules. There is probably room for improvement 18%D and more features. 19 20% \setupbodyfont[pagella] 21% 22% \starttext 23% 24% \setupindenting[medium,yes] 25% 26% \definefirstline 27% [smallcaps] 28% [alternative=line, 29% color=darkred, 30% style=\setfontfeature{smallcaps}] 31% 32% \setfirstline[smallcaps] \input tufte \par 33% \setfirstline[smallcaps] \input ward \par 34% \setfirstline[smallcaps] \input knuth \par 35% \setfirstline[smallcaps] \input bryson \par 36% 37% \definefirstline 38% [smallcaps] 39% [alternative=word, 40% color=darkblue, 41% style=bold, 42% n=2] 43% 44% \setfirstline[smallcaps] \input tufte \par 45% \setfirstline[smallcaps] \input ward \par 46% \setfirstline[smallcaps] \input knuth \par 47% \setfirstline[smallcaps] \input bryson \par 48% 49% \stoptext 50 51\unprotect 52 53\registerctxluafile{typo-fln}{autosuffix} 54 55\definesystemattribute[firstline][public] 56 57\appendtoks 58 \c_attr_firstline\attributeunsetvalue 59\to \everyforgetall 60 61\installcorenamespace {firstline} 62 63\installcommandhandler \??firstline {firstline} \??firstline 64 65\setupfirstline 66 [\c!alternative=\v!line, 67 %\c!style=, 68 %\c!color=, 69 \c!n=1] 70 71\permanent\tolerant\protected\def\setfirstline[#1]% 72 {\edef\typo_firstline_handle{\typo_firstline_handle_indeed{#1}}} 73 74\protected\def\typo_firstline_handle_indeed#1% 75 {\dontleavehmode 76 \begingroup 77 \cdef\currentfirstline{#1}% 78 \usefirstlinestyleandcolor\c!style\c!color 79 80 alternative {\firstlineparameter\c!alternative}% 81 ma \c_attr_colormodel 82 ca \c_attr_color 83 ta \c_attr_transparency 84 n \numexpr\firstlineparameter\c!n\relax 85 font \fontid\font 86 dynamic \font_dynamic_value 87 \relax 88% \kern\zeropoint % we need a node 89% \hskip\zeropoint\s!plus\emwidth\relax % can be an option 90 \endgroup 91 \glettonothing\typo_firstline_handle} 92 93\lettonothing\typo_firstline_handle 94 95% goodie, question on list 96% 97% \defineframed[ChapterFramed][location=low,background=color,backgroundcolor=red,frame=off] 98% 99% \setuphead[chapter][deeptextcommand=\applytofirstcharacter\ChapterFramed] 100 101\permanent\protected\def\applytofirstcharacter#1% 102 {\begingroup 103 \dowithnextbox 104 {\nextbox{\csstring#1}% 105 \unhbox\nextbox 106 \endgroup}% 107 \hbox} 108 109\protect \endinput 110 |