aboutsummaryrefslogblamecommitdiffstats
path: root/include/podf
blob: 108f455020ba0014470eeff8bd7ba1ddb9ee7944 (plain) (tree)
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
































































































































































































































































































































































































































































































































                                                                                         

###############################################################################
#                                                                             #
#  Lout @PodSetup package for formatting Pod programs                         #
#                                                                             #
#  Jeffrey H. Kingston                                                        #
#  25 March 2000                                                              #
#                                                                             #
#  This package uses a filtered body parameter to convert Pod source          #
#  code into Lout source.  The filter program is prg2lout, which is           #
#  distributed with Lout and should be compiled and installed wherever        #
#  Lout itself is.                                                            #
#                                                                             #
###############################################################################

export @Pod
def @PodSetup
    named pipe               {           }  # pipe through this first
    named style
	named @OrIfPlain left x right y
	{ @BackEnd @Case { PlainText @Yield y else @Yield x } }
			     { varying @OrIfPlain fixed }  # print style


    # the following options apply when style is "fixed"

    named fixedtextfont			{ Courier Base -1p	} # text font
    named fixedtextbreak		{ adjust 1.0vx hyphen	} # text para breaking
    named fixedverbatimfont		{ Courier Base		} # verbatim font
    named fixedtabin			{ 8			} # tab interval
    named fixedtabout			{ 8s			} # tab width

    named fixedparagap			{ 1.0v			} # gap between paras
    named fixedlistgap			{ 1.0v			} # gap within lists
    named fixedlistindent		{ 0s			} # list label indent
    named fixedlistrightindent		{ 0s			} # list right indent
    named fixedlistlabelwidth		{ 2.0f			} # default label space
    named fixedlistlabelfont 		{ 			} # list label font
    named fixedlistlabelformat right @Body { @Body		} # list label format

    named fixedaheadfont		{ Bold +4p		} # =head1 font
    named fixedaheadbreak		{ lines 1.1vx		} # =head1 para break
    named fixedaheadformat right @Body	{ @DP @Body		} # =head1 format
    named fixedbheadfont		{ Bold +2p		} # =head2 font
    named fixedbheadbreak		{ lines 1.1vx		} # =head2 para break
    named fixedbheadformat right @Body	{ @Body			} # =head2 format
    named fixedcheadfont		{ Bold			} # =head3 font
    named fixedcheadbreak		{ lines 1.1vx		} # =head3 para break
    named fixedcheadformat right @Body	{ @Body			} # =head3 format

    named fixeditalicfont		{ Slope			} # font of I<>
    named fixeditalicformat right @Body	{ @Body			} # format of I<>
    named fixedboldfont			{ Bold			} # font of B<>
    named fixedboldformat right @Body	{ @Body			} # format of B<>
    named fixedcodefont			{ Base			} # font of C<>
    named fixedcodeformat right @Body	{ @Body			} # format of C<>
    named fixedfilefont			{ Slope			} # font of F<>
    named fixedfileformat right @Body	{ @Body			} # format of F<>
    named fixedlinkfont			{ Slope			} # font of L<>
    named fixedlinkformat right @Body	{ @Underline @Body	} # format of L<>
    named fixedindexfont		{ Slope			} # font of X<>
    named fixedindexformat right @Body	{ @Body			} # format of X<>


    # the following options apply when style is "varying"

    named varyingtextfont		{ 			} # text font
    named varyingtextbreak		{ adjust 1.0vx hyphen	} # text para breaking
    named varyingverbatimfont		{ Courier Base -1p	} # verbatim font
    named varyingtabin			{ 8			} # tab interval
    named varyingtabout			{ 8s			} # tab width

    named varyingparagap		{ 1.0v			} # gap between paras
    named varyinglistgap		{ 1.0v			} # gap within lists
    named varyinglistindent		{ 0s			} # list label indent
    named varyinglistrightindent	{ 0s			} # list right indent
    named varyinglistlabelwidth		{ 2.0f			} # default label space
    named varyinglistlabelfont 		{ 			} # list label font
    named varyinglistlabelformat right @Body { @Body		} # list label format

    named varyingaheadfont		{ Bold +4p		} # =head1 font
    named varyingaheadbreak		{ lines 1.1vx		} # =head1 para break
    named varyingaheadformat right @Body{ @DP @Body		} # =head1 format
    named varyingbheadfont		{ Bold +2p		} # =head2 font
    named varyingbheadbreak		{ lines 1.1vx		} # =head2 para break
    named varyingbheadformat right @Body{ @Body			} # =head2 format
    named varyingcheadfont		{ Bold			} # =head3 font
    named varyingcheadbreak		{ lines 1.1vx		} # =head3 para break
    named varyingcheadformat right @Body{ @Body			} # =head3 format

    named varyingitalicfont		{ Slope			} # font of I<>
    named varyingitalicformat right @Body	{ @Body			} # format of I<>
    named varyingboldfont		{ Bold			} # font of B<>
    named varyingboldformat right @Body	{ @Body			} # format of B<>
    named varyingcodefont		{ Courier Base -1p	} # font of C<>
    named varyingcodeformat right @Body	{ @Body			} # format of C<>
    named varyingfilefont		{ Slope			} # font of F<>
    named varyingfileformat right @Body	{ @Body			} # format of F<>
    named varyinglinkfont		{ Slope			} # font of L<>
    named varyinglinkformat right @Body	{ @Underline @Body	} # format of L<>
    named varyingindexfont		{ Slope			} # font of X<>
    named varyingindexformat right @Body{ @Body			} # format of X<>

    # the following options apply when style is "symbol"

    named symboltextfont		{ 			} # text font
    named symboltextbreak		{ adjust 1.0vx hyphen	} # text para breaking
    named symbolverbatimfont		{ Courier Base -1p	} # verbatim font
    named symboltabin			{ 8			} # tab interval
    named symboltabout			{ 8s			} # tab width

    named symbolparagap			{ 1.0v			} # gap between paras
    named symbollistgap			{ 1.0v			} # gap within lists
    named symbollistindent		{ 0s			} # list label indent
    named symbollistrightindent		{ 0s			} # list right indent
    named symbollistlabelwidth		{ 2.0f			} # default label space
    named symbollistlabelfont 		{ 			} # list label font
    named symbollistlabelformat right @Body { @Body		} # list label format

    named symbolaheadfont		{ Bold +4p		} # =head1 font
    named symbolaheadbreak		{ lines 1.1vx		} # =head1 para break
    named symbolaheadformat right @Body	{ @DP @Body		} # =head1 format
    named symbolbheadfont		{ Bold +2p		} # =head2 font
    named symbolbheadbreak		{ lines 1.1vx		} # =head2 para break
    named symbolbheadformat right @Body	{ @Body			} # =head2 format
    named symbolcheadfont		{ Bold			} # =head3 font
    named symbolcheadbreak		{ lines 1.1vx		} # =head3 para break
    named symbolcheadformat right @Body	{ @Body			} # =head3 format

    named symbolitalicfont		{ Slope			} # font of I<>
    named symbolitalicformat right @Body{ @Body			} # format of I<>
    named symbolboldfont		{ Bold			} # font of B<>
    named symbolboldformat right @Body	{ @Body			} # format of B<>
    named symbolcodefont		{ Courier Base -1p	} # font of C<>
    named symbolcodeformat right @Body	{ @Body			} # format of C<>
    named symbolfilefont		{ Slope			} # font of F<>
    named symbolfileformat right @Body	{ @Body			} # format of F<>
    named symbollinkfont		{ Slope			} # font of L<>
    named symbollinkformat right @Body	{ @Underline @Body	} # format of L<>
    named symbolindexfont		{ Slope			} # font of X<>
    named symbolindexformat right @Body	{ @Body			} # format of X<>

@Begin


    export
    
	@PV @PPG @PLG @PLI @PLRI @PLLW @PLL @PHA @PHB @PHC
	@PFI @PFB @PFC @PFF @PFL @PFX @A "$>"

    def @Pod
	named style		{ style			} # style
	named pipe		{ pipe			} # pipe through this
	named textfont		{ dft			} # text font
	named textbreak		{ dft			} # text para breaking
	named verbatimfont	{ dft			} # verbatim font
	named tabin		{ dft			} # tab interval
	named tabout		{ dft			} # tab width
	named paragap		{ dft			} # gap between paras
	named listgap		{ dft			} # gap within lists
	named listindent	{ dft			} # list label indent
	named listrightindent	{ dft			} # list right indent
	named listlabelwidth	{ dft			} # default label space
	named listlabelfont 	{ dft			} # list label font
	named aheadfont		{ dft			} # =head1 font
	named aheadbreak	{ dft			} # =head1 para break
	named bheadfont		{ dft			} # =head2 font
	named bheadbreak	{ dft			} # =head2 para break
	named cheadfont		{ dft			} # =head3 font
	named cheadbreak	{ dft			} # =head3 para break
	named italicfont	{ dft			} # font of I<>
	named boldfont		{ dft			} # font of B<>
	named codefont		{ dft			} # font of C<>
	named filefont		{ dft			} # font of F<>
	named linkfont		{ dft			} # font of L<>
	named indexfont		{ dft			} # font of X<>
	body @Body			      		  # filtered, see below
    @Begin

	def @Test	# returns x unless x is dft
	    left x
	    named iffixed {}
	    named ifvarying {}
	    named ifsymbol {}
	{
	    x @Case {
		dft @Yield {
		    style @Case {
			fixed   @Yield { iffixed   }
			varying @Yield { ifvarying }
			symbol  @Yield { ifsymbol  }
		    }
		}
		else @Yield x
	    }
	}


	def @Else	# returns x, or y if x is dft
	    left x
	    right y
	{
	    x @Case {
		dft  @Yield y
		else @Yield x
	    }
	}


	def @InitTab
	{
	  tabin @Test
	      iffixed   { fixedtabin   }
	      ifvarying { varyingtabin }
	      ifsymbol  { symboltabin  }
	}


	def @InitTabWidth
	{
	  tabout @Test
	      iffixed   { fixedtabout   }
	      ifvarying { varyingtabout }
	      ifsymbol  { symboltabout  }
	}


	def @Filter
	{
	    pipe @Case {
		"" @Yield {
	    	    "prg2lout -r -lPod" -i{@FilterIn} -o{@FilterOut} -e{@FilterErr}
			-t{@InitTab} -T{@InitTabWidth}
		}
		else @Yield {
	    	    "cat" @FilterIn "|" pipe "|"
		    "prg2lout -r -lPod" -o{@FilterOut}
		    -e{@FilterErr} -t{@InitTab} -T{@InitTabWidth}
		}
	    }
	}


	def @InitFont
	{
	  textfont @Test
	      iffixed   { fixedtextfont   }
	      ifvarying { varyingtextfont }
	      ifsymbol  { symboltextfont  }
	}



	def @InitBreak
	{
	  textbreak @Test
	      iffixed   { fixedtextbreak   }
	      ifvarying { varyingtextbreak }
	      ifsymbol  { symboltextbreak  }
	}


	def printverbatim
		right x
	{
	    def verbfont
	    {
		verbatimfont @Test
		    iffixed   { fixedverbatimfont   }
		    ifvarying { varyingverbatimfont }
		    ifsymbol  { symbolverbatimfont  }
	    }

	    def verbatimstrut { @VContract { 0.5v @High ^/ / 0.5v @High } }

	    @OneCol verbfont @Font x |0io verbatimstrut
	}


	macro @PV { // printverbatim }


	def paragraphgap
	{
	    paragap @Test
		iffixed   { fixedparagap   }
		ifvarying { varyingparagap }
		ifsymbol  { symbolparagap  }
	}


	macro @PPG { //paragraphgap }


	def @PLG
	{
	    listgap @Test
		iffixed   { fixedlistgap   }
		ifvarying { varyinglistgap }
		ifsymbol  { symbollistgap  }
	}


	def @PLI
	{
	    listindent @Test
		iffixed   { fixedlistindent   }
		ifvarying { varyinglistindent }
		ifsymbol  { symbollistindent  }
	}


	def @PLRI
	{
	    listrightindent @Test
		iffixed   { fixedlistrightindent   }
		ifvarying { varyinglistrightindent }
		ifsymbol  { symbollistrightindent  }
	}


	def @PLLW right x
	{
	    def defaultwidth
	    {
	    	listlabelwidth @Test
		    iffixed   { fixedlistlabelwidth   }
		    ifvarying { varyinglistlabelwidth }
		    ifsymbol  { symbollistlabelwidth  }
	    }

	    def givenwidth
	    {
		style @Case {
		    fixed   @Yield { x"s" }
		    varying @Yield { x"f" }
		    symbol  @Yield { x"f" }
		}
	    }

	    x @Case {
		"" @Yield defaultwidth
		else @Yield givenwidth
	    }
	}


	def @PLL right x
	{
	    def value
	    {
		x @Case {
		    "*" @Yield @Bullet
		    else @Yield x
		}
	    }

	    style @Case {
		fixed @Yield fixedlistlabelformat {
		    { listlabelfont @Else fixedlistlabelfont } @Font value }
		varying @Yield varyinglistlabelformat {
		    { listlabelfont @Else varyinglistlabelfont } @Font value }
		symbol @Yield symbollistlabelformat {
		    { listlabelfont @Else symbollistlabelfont } @Font value }
	    }
	}


	def @PHA right x
	{
	    style @Case {
		fixed @Yield fixedaheadformat {
		    { aheadfont @Else fixedaheadfont } @Font
		    { aheadbreak @Else fixedaheadbreak } @Break x }
		varying @Yield varyingaheadformat {
		    { aheadfont @Else varyingaheadfont } @Font
		    { aheadbreak @Else varyingaheadbreak } @Break x }
		symbol @Yield symbolaheadformat {
		    { aheadfont @Else symbolaheadfont } @Font
		    { aheadbreak @Else varyingaheadbreak } @Break x }
	    }
	}


	def @PHB right x
	{
	    style @Case {
		fixed @Yield fixedbheadformat {
		    { bheadfont @Else fixedbheadfont } @Font
		    { bheadbreak @Else fixedbheadbreak } @Break x }
		varying @Yield varyingbheadformat {
		    { bheadfont @Else varyingbheadfont } @Font
		    { bheadbreak @Else varyingbheadbreak } @Break x }
		symbol @Yield symbolbheadformat {
		    { bheadfont @Else symbolbheadfont } @Font
		    { bheadbreak @Else varyingbheadbreak } @Break x }
	    }
	}


	def @PHC right x
	{
	    style @Case {
		fixed @Yield fixedcheadformat {
		    { cheadfont @Else fixedcheadfont } @Font
		    { cheadbreak @Else fixedcheadbreak } @Break x }
		varying @Yield varyingcheadformat {
		    { cheadfont @Else varyingcheadfont } @Font
		    { cheadbreak @Else varyingcheadbreak } @Break x }
		symbol @Yield symbolcheadformat {
		    { cheadfont @Else symbolcheadfont } @Font
		    { cheadbreak @Else varyingcheadbreak } @Break x }
	    }
	}


	def @PFI right x
	{
	    style @Case {
		fixed @Yield fixeditalicformat {
		    { italicfont @Else fixeditalicfont } @Font x }
		varying @Yield varyingitalicformat {
		    { italicfont @Else varyingitalicfont } @Font x }
		symbol @Yield symbolitalicformat {
		    { italicfont @Else symbolitalicfont } @Font x }
	    }
	}


	def @PFB right x
	{
	    style @Case {
		fixed @Yield fixedboldformat {
		    { boldfont @Else fixedboldfont } @Font x }
		varying @Yield varyingboldformat {
		    { boldfont @Else varyingboldfont } @Font x }
		symbol @Yield symbolboldformat {
		    { boldfont @Else symbolboldfont } @Font x }
	    }
	}


	def @PFC right x
	{
	    style @Case {
		fixed @Yield fixedcodeformat {
		    { codefont @Else fixedcodefont } @Font x }
		varying @Yield varyingcodeformat {
		    { codefont @Else varyingcodefont } @Font x }
		symbol @Yield symbolcodeformat {
		    { codefont @Else symbolcodefont } @Font x }
	    }
	}


	def @PFF right x
	{
	    style @Case {
		fixed @Yield fixedfileformat {
		    { filefont @Else fixedfilefont } @Font x }
		varying @Yield varyingfileformat {
		    { filefont @Else varyingfilefont } @Font x }
		symbol @Yield symbolfileformat {
		    { filefont @Else symbolfilefont } @Font x }
	    }
	}


	def @PFL right x
	{
	    style @Case {
		fixed @Yield fixedlinkformat {
		    { linkfont @Else fixedlinkfont } @Font x }
		varying @Yield varyinglinkformat {
		    { linkfont @Else varyinglinkfont } @Font x }
		symbol @Yield symbollinkformat {
		    { linkfont @Else symbollinkfont } @Font x }
	    }
	}


	def @PFX right x
	{
	    style @Case {
		fixed @Yield fixedindexformat {
		    { indexfont @Else fixedindexfont } @Font x }
		varying @Yield varyingindexformat {
		    { indexfont @Else varyingindexfont } @Font x }
		symbol @Yield symbolindexformat {
		    { indexfont @Else symbolindexfont } @Font x }
	    }
	}


	def @A		# get characters from the Adobe Symbol font
	    left sym
	    right x
	{
	    style @Case {
		symbol	@Yield { { Symbol Base } @Font @Char sym }
		else	@Yield { x			}
	    }
	}


	macro "$>" { {} & }


	@InitFont @Font @InitBreak @Break @Body

    @End @Pod

@End @PodSetup