summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/tex4ht/diagram.4ht
blob: b5b0de6a9b4925bf5fdabd09cee5d6f33f9e83d5 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% diagram.4ht                          2008-09-16-11:44 %
% Copyright (C) 2008             Eitan M. Gurari         %
%                                                        %
% This work may be distributed and/or modified under the %
% conditions of the LaTeX Project Public License, either %
% version 1.3c of this license or (at your option) any   %
% later version. The latest version of this license is   %
% in                                                     %
%   http://www.latex-project.org/lppl.txt                %
% and version 1.3c or later is part of all distributions %
% of LaTeX version 2005/12/01 or later.                  %
%                                                        %
% This work has the LPPL maintenance status "maintained".%
%                                                        %
% This Current Maintainer of this work                   %
% is Eitan M. Gurari.                                    %
%                                                        %
% If you modify this program your changing its signature %
% with a directive of the following form will be         %
% appreciated.                                           %
%            \message{signature}                         %
%                                                        %
%                             gurari@cse.ohio-state.edu  %
%                 http://www.cse.ohio-state.edu/~gurari  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\immediate\write-1{version 2008-09-16-11:44}

  \inner@frame = 0pt
\outer@frame = 0pt

\NewConfigure{diagram}{6}



\NewConfigure{stipulation}{4}

\NewConfigure{piececounter}{2}


\pend:def\@dia@authors{\ifauth@r \a:authors\fi}
\append:def\@dia@authors{\ifauth@r \b:authors \fi}
\NewConfigure{authors}{2}
\pend:def\@dia@condition{\if@condition \a:condition\fi}
\append:def\@dia@condition{\if@condition \b:condition \fi}
\NewConfigure{condition}{2}
\pend:def\@dia@solution{\a:solution}
\append:def\@dia@solution{\b:solution }
\NewConfigure{solution}{2}
\pend:def\@dia@award{\if@award\a:award\fi}
\append:def\@dia@award{\if@award\b:award\fi }
\NewConfigure{award}{2}
\pend:def\@dia@dedic{\if@dedication\a:dedic\fi}
\append:def\@dia@dedic{\if@dedication\b:dedic \fi}
\NewConfigure{dedic}{2}
\pend:def\@dia@number{\ifdi@no\a:number\fi}
\append:def\@dia@number{\ifdi@no\b:number\fi}
\NewConfigure{number}{2}

\pend:def\@dia@twins{\ifauth@r \a:twins\fi}
\append:def\@dia@twins{\ifauth@r \b:twins\fi}
\NewConfigure{twins}{2}
\pend:def\@dia@remark{\ifauth@r \a:remark\fi}
\append:def\@dia@remark{\ifauth@r \b:remark \fi}
\NewConfigure{remark}{2}

\pend:def\dia@above{\a:above}
\append:def\dia@above{\b:above }
\NewConfigure{above}{2}

\pend:def\dia@below{\a:below}
\append:def\dia@below{\b:below }
\NewConfigure{below}{2}

\pend:def\@dia@correction{\if@correction\a:correction\fi}
\append:def\@dia@correction{\if@correction\b:correction\fi }
\NewConfigure{correction}{2}
\def\putsol{\immediate\closeout\s@lfd\input\jobname.sol}%\cl@arsol}
\pend:def\putsol{\HAssign\solNum=0}
\def\showlabel#1{\if@develop\a:showlabel\hbox{\labelfont#1}\b:showlabel\fi}
\NewConfigure{showlabel}{2}

\def\@dia@solution{%
   \bgroup%
   \parindent\z@%
   \csname a:sol-title\endcsname
   {\bf
      \noindent\if@label\showlabel{\the\label@tk}\fi
      \csname a:sol-number\endcsname
      \the\number@tk       \csname b:sol-number\endcsname) %
      \ifauth@r%
         \csname a:sol-author\endcsname
         \ifnormal@names%
            \the\aut@tk%
         \else%
            {\@notfirstfalse% We are the first one
            \let\@action=\@solname%
            \@parseTokenlist\aut@tk;}:%
         \fi%
         \csname b:sol-author\endcsname
      \fi%
   }%
   \if@develop\if@judgement\a:judgement\the\judgement@tk\b:judgement\fi\fi%
   \csname b:sol-title\endcsname
   \par%
   \the\sol@tk\par%
   \if@comment\the\comment@tk\par\fi%
   \egroup%
}
\NewConfigure{judgement}{2}
\NewConfigure{sol-number}{2}
\NewConfigure{sol-author}{2}
\NewConfigure{sol-title}{2}
\def\@dia@source{%
   {\if@source%
      \a:source
      \sourcefont%
      \if@sourcenr\the\sourcenr@tk\ \fi
      \the\source@tk%
      \a:date
      \ifnum\from@month>\z@%
         \if@day%
            \ \ \the\day@tk .\write@month\from@month%
         \else%
            \ \ \write@month\from@month%
         \fi%
         \ifnum\to@month>\z@ -\write@month\to@month\fi%
         \if@day .\else /\fi%
      \else%
         \ \ %
      \fi%
      \if@year\the\year@tk\fi%
      \b:date
      \if@issue /\a:issue\the\issue@tk\b:issue\fi%
      \if@pages ,\ \a:pages\the\pages@tk\b:pages\fi%
      \par%
      \b:source
   \fi}%
}
\NewConfigure{source}{2}
\NewConfigure{source}{2}
\NewConfigure{date}{2}
\NewConfigure{issue}{2}
\NewConfigure{pages}{2}

  \let\:EndIgnore\relax
  \def\:Ignore{\bgroup
     \catcode`\\=12
     \long\def\:temp##1:EndIgnore{\egroup}\:temp
  }
  \ifx \setboardwidth\:UnDef \expandafter\:Ignore\fi
     \def\@dia@stipulation{%
   \if@stipulation%
      \a:stipulation
      \bgroup%
      \stipfont%
      \c:stipulation \the\stipulation@tk \d:stipulation
      \ifx@twins%
         \let\below@newline\@twinskip%
         \@dia@twins%
      \else\ifx@cond%
         \let\below@newline\@twinskip%
         \@dia@condition%
      \fi\fi%
      \egroup%
      \b:stipulation
      \let\below@newline\newline%
   \else%
      \x@twinsfalse%
      \x@condfalse%
      \let\below@newline\relax%
   \fi%
}
\def\put@count{%
   % First we build the box with the figure count
   \ifthenelse{\boolean{piececounter}}{%
        \a:piececounter
        \if@show@computer%
            C\if@computer +\else --\fi
            \ \
        \fi%
            (\arabic{cpd@whitePieces}+\arabic{cpd@blackPieces}%
        \ifthenelse{\value{cpd@neutralPieces}>0}{+\arabic{cpd@neutralPieces}}{})%
          \b:piececounter
   }{}%
}
\def\put@plane{%
   % We might want gridchess
     \if@stdgrid%
        \@stdgrid%
     \fi%
   % Let us first set the fieldframes
   \if@fieldframe%
      \let\@action\read@square%
      \let\plane@job\set@frame%
      \@addToPlane\fieldframe@tk%
   \fi%
   % Now we set text to all squares which are given using \fieldtext
   \if@fieldtext%
      \let\@action\p@rsetext%
      \let\plane@job\set@text%
      \@addToPlane\fieldtext@tk%
   \fi%
   % Then we should add the gridlines
   \if@gridlines%
      \let\@action\read@plane%
      \let\plane@job\@selGrid%
      \@addToPlane\gridlines@tk%
   \else%
      \if@stereo%
        \stereo@center%
     \fi%
   \fi%
   % Now we should clear the board
   \clear@board%
   % Let us now parse the list of pieces
   \if@pieces%
      \let\@action\p@rsepieces%
      \let\piece@job\l@@k\let\plane@job\set@piece%
      \@parseTokenlist\pieces@tk,%
   \fi%
   % Now we clear all fields, which are given using \nofields
   \if@nofields%
      \let\@action\read@square%
      \let\plane@job\set@nofield%
      \@parseTokenlist\nofields@tk,%
   \fi%
   % Now we can put the pieces to the board
   \global\setbox\plane@box=\hbox{%
      \vbox{\rlap{\box\plane@box}}%
      \vbox{%
         \a:diagram
         \chessfont%
         \baselineskip=\z@\lineskip=\z@%
         \@rows=\rows@max%
         % \multiply\@rows by \lines@max%
         \loop%
            % \advance\@rows -\lines@max%
            % \put@line\@rows%
            % Remove \put@line in future versions
            \advance\@rows \m@ne%
            \tmp:cnt=\@rows \advance\tmp:cnt by 1
            \edef\HRow{\the\tmp:cnt}%
            \c:diagram \put@row\@rows \d:diagram
         \ifnum\@rows>\z@\repeat%
         \b:diagram
     }%
   }%
}
\def\put@row#1{%
   \lin@\z@%
   \help@b=#1%
   \advance\help@b\brd@ff%
   \hbox{%
      \if@stereo%
         \ifnum\current@plane>\z@%
            \ifnum\@rows=12%
               \llap{\raise .5\sq@width\hbox{\boardfont c6\ }}%
            \fi%
         \fi%
      \fi%
      \hbox to \z@{\vbox to \sq@width{}}%
      \set@current@square@index{\lin@}{#1}%
      \loop%
         \tmp:cnt=\lin@ \advance\tmp:cnt by 1\relax
         \edef\HCol{\the\tmp:cnt}%
         \e:diagram
         \get@current@square@value%
         \ifthenelse{\value{cpd@current@square@value}=\m@ne}%
          {\wF}%
          {\char\value{cpd@current@square@value}}%
         % \ifnum\count\help@b=\m@ne\wF%
         % \else\char\count\help@b\fi%
         \advance\lin@\@ne%
         \addtocounter{cpd@current@square@index}{1}%
         % \advance\help@b\@ne%
         \f:diagram
      \ifnum\lin@<\lines@max\repeat%
   }%
}

  \:EndIgnore
  \ifx \setboardwidth\:UnDef \else \expandafter\:Ignore\fi
     \def\@dia@stipulation{%
   \a:stipulation
   \bgroup%
   \stipfont%
   \hbox{%
      \a:piececounter
      \if@show@computer%
         C\if@computer +\else --\fi
      \fi%
      \iffigcnt%
         \if@show@computer\ \ \fi{} (\the\w@cnt+\the\b@cnt
                \ifnum\z@<\n@cnt+\the\n@cnt\fi)%
      \fi%
      \b:piececounter
      \if@stipulation \c:stipulation\the
                   \stipulation@tk \d:stipulation\fi
      \ifx@twins \@dia@twins\fi%
      \ifx@cond \@dia@condition\fi%
   }%
   \egroup%
   \b:stipulation
}
\def\put@plane{%
   % We might want gridchess
     \if@stdgrid%
        \@stdgrid%
     \fi%
   % Let us first set the fieldframes
   \if@fieldframe%
      \let\@action\read@square%
      \let\plane@job\set@frame%
      \@addToPlane\fieldframe@tk%
   \fi%
   % Then we should add the gridlines
   \if@gridlines%
      \let\@action\read@plane%
      \let\plane@job\@selGrid%
      \@addToPlane\gridlines@tk%
   \else%
      \if@stereo%
        \stereo@center%
     \fi%
   \fi%
   % Now we should clear the board
   \clear@board%
   % Let us now parse the list of pieces
   \if@pieces%
      \let\@action\p@rsepieces%
      \let\piece@job\l@@k\let\plane@job\set@piece%
      \@parseTokenlist\pieces@tk,%
   \fi%
   % Now we clear all fields, which are given using \nofields
   \if@nofields%
      \let\@action\read@square%
      \let\plane@job\set@nofield%
      \@parseTokenlist\nofields@tk,%
   \fi%
   \global\setbox\plane@box=\hbox{
   % Now we can put the pieces to the board
      \vbox{\IgnorePar\box\plane@box}%
      \vbox{%
        \a:diagram
        \chessfont%
         \baselineskip=\z@\lineskip=\z@%
         \@rows=\rows@max%
         \multiply\@rows by \lines@max%
         \loop%
            \advance\@rows -\lines@max%
            \tmp:cnt=\@rows \divide\tmp:cnt by 8 \advance\tmp:cnt by 1
            \edef\HRow{\the\tmp:cnt}%
            \c:diagram  \put@line\@rows \d:diagram
         \ifnum\@rows>\z@\repeat%
         \b:diagram
      }%
   }%
}
\def\put@line#1{%
   \lin@\z@%
   \help@b=#1\advance\help@b\brd@ff%
   \hbox{%
      \if@stereo%
         \ifnum\current@plane>\z@%
            \ifnum\@rows=12%
               \llap{\raise .5\sq@width\hbox{\boardfont c6\ }}%
            \fi%
         \fi%
      \fi%
      \hbox to \z@{\vbox to \sq@width{}}%
      \loop%
         \tmp:cnt=\lin@ \advance\tmp:cnt by 1\relax
         \edef\HCol{\the\tmp:cnt}%
         \e:diagram
         \ifnum\count\help@b=\m@ne\wF%
         \else  \char\count\help@b\fi%
         \advance\lin@\@ne\advance\help@b\@ne%
         \f:diagram
      \ifnum\lin@<\lines@max\repeat%
   }%
}

  \:EndIgnore
\Hinput{diagram}
\endinput