summaryrefslogtreecommitdiff
path: root/tex/context/base/m-hemistich.mkiv
blob: 7a849d415beb89aa829f4678f9dc67df7ab654ed (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
%D \module
%D   [       file=m-hemistich,
%D        version=2013.08.26,
%D          title=\CONTEXT\ Extra Modules,
%D       subtitle=Hemistiches,
%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.

%D This is an experimental module for Idris. More is possible but not now.

\unprotect

\installcorenamespace{hemistich}

\installcommandhandler \??hemistich {hemistich} \??hemistich

\setuphemistich
  [\c!width=\v!local,
   \c!distance=4\emwidth,
   \c!separator=\vl\hskip.25em\vl]

\unexpanded\def\hemistiches
  {\dosingleempty\dohemistiches}

\unexpanded\def\dohemistiches
  {\dodohemistiches\empty}

\unexpanded\def\dodohemistiches#1[#2]#3#4%
  {\dontleavehmode
   \begingroup
   \doifelseassignment{#2}
     {\edef\currenthemistich{#1}%
      \setupcurrenthemistich[#2]}
     {\def\currenthemistich{#2}}%
   \doifelse{\hemistichparameter\c!width}\v!local
     {\scratchwidth\availablehsize}
     {\scratchwidth\hemistichparameter\c!width\relax}%
   \spaceskip\zeropoint\s!plus\plusone\s!fill\relax
   \dostarttagged\t!division\currenthemistich
   \hbox to \scratchwidth\bgroup
     \scratchwidth.5\dimexpr\scratchwidth-\hemistichparameter\c!distance\relax
     \hbox to \scratchwidth\bgroup
       \dostarttagged\t!construct\c!lefttext
       \usehemistichstyleandcolor\c!leftstyle\c!leftcolor#3%
       \dostoptagged
     \egroup
     \hss
     \begingroup
       \dostarttagged\t!construct\c!separator
       \usehemistichstyleandcolor\c!separatorstyle\c!separatorcolor
       \hemistichparameter\c!separator
       \dostoptagged
     \endgroup
     \hss
     \hbox to \scratchwidth\bgroup
       \dostarttagged\t!construct\c!righttext
       \usehemistichstyleandcolor\c!rightstyle\c!rightcolor#4%
       \dostoptagged
     \egroup
   \egroup
   \dostoptagged
   \endgroup}

\unexpanded\def\hemistichescaesura#1#2#3%
  {\dodohemistiches\empty[\c!separator={#2}]{#1}{#3}}

\appendtoks
    \setvalue{\currenthemistich}{\dohemistiches{\currenthemistich}}%
\to \everydefinehemistich

\protect

\continueifinputfile{m-hemistich.mkiv}

\setuphemistich
  [leftcolor=darkred,
   separatorcolor=darkgreen,
   rightcolor=darkblue]

\setupwhitespace
  [big]

\starttext

% \righttoleft

\hemistichescaesura{left side of the brain}{equals}{right side of the brain}

\hemistiches{left side of the brain}{right side of the brain}

\startitemize
    \startitem
        \hemistiches{left side of the brain}{right side of the brain}
        \startitemize
            \startitem
                \hemistiches{left side of the brain}{right side of the brain}
                \startitemize
                    \startitem
                        \hemistiches{left side of the brain}{right side of the brain}
                    \stopitem
                \stopitemize
            \stopitem
        \stopitemize
        \startitem
            \hemistiches{left side of the brain}{right side of the brain}
        \stopitem
    \stopitem
\stopitemize

\startitemize
\item \hemistiches{left side of the brain}{right side of the brain}
\stopitemize

\stoptext