1# $Id$
2#
3# >>Title::     Standard Library
4#
5# >>Copyright::
6# Copyright (c) 1992-1996, Ian Clatworthy (ianc@mincom.com).
7# You may distribute under the terms specified in the LICENSE file.
8#
9# >>History::
10# -----------------------------------------------------------------------
11# Date      Who     Change
12# 24-Oct-98 ianc    added KN/KP support
13# 29-Feb-96 ianc    SDF 2.000
14# -----------------------------------------------------------------------
15#
16# >>Purpose::
17# {{stdlib}} is the [[SDF]] library containing the built-in features.
18#
19# >>Description::
20# This library is {{2:always}} implicitly loaded.
21#
22# >>Limitations::
23#
24
25######## Declare the standard entities #########
26
27# Declare built-in paragraph styles
28!block parastyles
29Name    Category
30A0
31A1
32A2
33A3
34A4
35A5
36A6
37Addr
38E       example
39E80     example
40FA
41FOOTER
42FT
43GL
44GLD
45GLT
46H0
47H1
48H2
49H3
50H4
51H5
52H6
53HEADER
54L1
55L2
56L3
57L4
58L5
59L6
60Line
61LF1
62LF2
63LF3
64LF4
65LF5
66LF6
67LI1
68LI2
69LI3
70LI4
71LI5
72LI6
73LN1
74LN2
75LN3
76LN4
77LN5
78LN6
79LU1
80LU2
81LU3
82LU4
83LU5
84LU6
85N
86NB
87NE
88NV
89Note
90P0
91P1
92P2
93P3
94P4
95P5
96P6
97PB
98Sign
99V       example
100!endblock
101
102# Declare built-in phrase styles
103!block phrasestyles
104Name        Category
1051
1062
1073
108A
109B
110C           example
111E
112F
113I
114L
115N
116P
117S           example
118T
119U
120X
121Y
122CHAR        special
123CMD
124EMAIL
125EX          example
126ST
127FILE
128INLINE      special
129IMPORT      special
130PAGENUM     special
131PAGECOUNT   special
132PARATEXT    special
133PARANUM     special
134PARANUMONLY special
135PARASHORT   special
136PARALAST    special
137JUMP
138SECT
139SUB
140SUP
141!endblock
142
143# Declare built-in paragraph attributes
144# (Handled and removed prior to validation: obj, noevents)
145!block paraattrs
146Name        Type        Rule
147align       string      <1|Full|Left|Right|Center>
148first       string
149keep_next   boolean
150keep_prev   boolean
151label       string
152left        string
153nopb        boolean
154notoc       boolean
155noid        boolean
156continued   boolean
157sp_after    string
158sp_before   string
159top         string      <1|0|Page|Column|Left|Right>
160right       string
161wide        boolean
162component   string
163tabs        string
164in          integer
165orig_style  string
166out_style   string
167!endblock
168
169# Declare built-in phrase attributes
170# (Handled and removed prior to validation: expand, shrink)
171!block phraseattrs
172Name        Type        Rule
173bgcolor     string
174bold        boolean
175changed     boolean
176class       string
177color       string
178family      string
179id          string
180index       string
181index_type  string
182italics     boolean
183jump        string
184short       string
185size        string
186style       string
187underline   boolean
188verbatim    boolean
189xref        string
190!endblock
191
192# Declare built-in table styles
193!block tablestyles
194Name
195columns
196rows
197grid
198plain
199shade
200!endblock
201
202# Declare built-in table parameters
203!block tableparams
204Name        Type        Rule
205style       string
206format      string
207title       string
208wide        boolean
209narrow      boolean
210align       string      <Left|Center|Right|Inner|Outer>
211placement   string      <Float|Columntop|Pagetop|Lefttop|Righttop>
212landscape   string
213bgcolor     string
214cellspacing integer
215cellpadding integer
216listitem    integer
217tmargin     integer
218bmargin     integer
219lmargin     integer
220rmargin     integer
221colaligns   string
222!endblock
223
224# Declare built-in row parameters
225#!block rowparams
226#Name        Type        Rule
227#!endblock
228
229# Declare built-in cell parameters
230!block cellparams
231Name        Type        Rule
232align       string      <Left|Center|Right>
233valign      string      <Top|Middle|Bottom|Baseline>
234cols        integer
235rows        integer
236nowrap      boolean
237bgcolor     string
238fill        integer     <100|90|70|50|30|10|3|0>
239angle       integer     <0|90|180|270>
240bruling     string      <None|Vthin|Thin|Medium|Thick|Double>
241lruling     string      <None|Vthin|Thin|Medium|Thick|Double>
242rruling     string      <None|Vthin|Thin|Medium|Thick|Double>
243truling     string      <None|Vthin|Thin|Medium|Thick|Double>
244tmargin     integer
245bmargin     integer
246lmargin     integer
247rmargin     integer
248hidden      boolean
249!endblock
250
251######## Define the standard variables #########
252
253# Setup the default stuff
254!default OPT_LOOK   DEFAULT_LOOK
255!default OPT_LOCALE DEFAULT_LOCALE
256!default OPT_STYLE  "document"
257!default OPT_WIDTH  70
258!default OPT_PAGE_SIZE "global"
259
260# Declare restricted variable families
261!restrict 'OPT'
262!restrict 'DEFAULT'
263!restrict 'DOC'
264
265# Declare the option variables
266!block variables; family="OPT"
267Name                    Type        Rule
268BORDERS                 integer
269HEADINGS                integer
270NUMBER_PER_COMPONENT    boolean
271COMPONENT_COVER         boolean
272TEMPLATE                string
273LIST_INDENT             dimension
274MARGIN_TOP              string
275MARGIN_BOTTOM           string
276MARGIN_INNER            string
277MARGIN_OUTER            string
278LOCALE                  string
279!endblock
280
281# Character definitions
282!block define
283Name            Value
284amp             "{{CHAR:amp}}"
285bullet          "{{CHAR:bullet}}"
286c               "{{CHAR:c}}"
287cent            "{{CHAR:cent}}"
288dagger          "{{CHAR:dagger}}"
289doubledagger    "{{CHAR:doubledagger}}"
290emdash          "{{CHAR:emdash}}"
291endash          "{{CHAR:endash}}"
292emspace         "{{CHAR:emspace}}"
293enspace         "{{CHAR:enspace}}"
294nbdash          "{{CHAR:nbdash}}"
295nbspace         "{{CHAR:nbspace}}"
296nbsp            "{{CHAR:nbspace}}"
297nl              "{{CHAR:nl}}"
298pound           "{{CHAR:pound}}"
299r               "{{CHAR:r}}"
300reg             "{{CHAR:r}}"
301tab             "{{CHAR:tab}}"
302tm              "{{CHAR:tm}}"
303yen             "{{CHAR:yen}}"
304!endblock
305
306# Colour variables
307!block define; family="COLOR"
308Name    Value
309WHITE   'ffffff'
310BLACK   '000000'
311RED     'ff0000'
312GREEN   '00ff00'
313BLUE    '0000ff'
314YELLOW  'ffff00'
315MAGENTA 'ff00ff'
316CYAN    '00ffff'
317GREY    'c0c0c0'
318!endblock
319
320# Default FormatTime and case conversion variables.
321!block default; family="FORMAT"
322Name      Value
323DATETIME  '&FormatTime(\'$day $month $year, $hour:$minute0.$second0\', $_)'
324TIME      '&FormatTime(\'$hour:$minute0.$second0\', $_)'
325DATE      '&FormatTime(\'$day $month $year\', $_)'
326SDATE     '&FormatTime(\'$day0-$smonth-$syear\', $_)'
327YEAR      '&FormatTime(\'$year\', $_)'
328UPPER     '"\U$_"'
329LOWER     '"\L$_"'
330UPPER1    '"\u$_"'
331LOWER1    '"\l$_"'
332!endblock
333
334# Provide FULL and CONCISE DateTime formats for backwards compatibility
335!default FORMAT_FULL    FORMAT_DATETIME
336!default FORMAT_CONCISE FORMAT_SDATE
337
338# Declare generation control variables
339!block variables; family="DEFAULT"
340Name        Type        Rule
341TABLE_STYLE string
342XREF_STYLE  string
343TAB_SIZE    integer
344!endblock
345
346# Set the default generation controls
347!default DEFAULT_TABLE_STYLE "columns"
348!default DEFAULT_XREF_STYLE  "section"
349!default DEFAULT_TAB_SIZE    8
350
351# Declare column layout variables
352!block variables; family="OPT,OPT_IX"
353Name                    Type        Rule
354SIDEHEAD_WIDTH          dimension
355SIDEHEAD_GAP            dimension
356COLUMNS                 integer
357COLUMN_GAP              dimension
358!endblock
359
360# Declare page layout variables
361!block variables; family="PAGE_FIRST,PAGE_RIGHT,PAGE_LEFT"
362Name                Type        Rule
363HEADER_BORDER       string
364HEADER_HEIGHT       dimension
365HEADER_GAP          dimension
366FOOTER_BORDER       string
367FOOTER_HEIGHT       dimension
368FOOTER_GAP          dimension
369BACKGROUND          string
370!endblock
371
372# Declare header/footer variables
373!block variables; family="PAGE_FIRST,PAGE_RIGHT,PAGE_LEFT"
374Name                Type        Rule
375HEADER_INNER1       string
376HEADER_INNER2       string
377HEADER_CENTER1      string
378HEADER_CENTER2      string
379HEADER_OUTER1       string
380HEADER_OUTER2       string
381FOOTER_INNER0       string
382FOOTER_INNER1       string
383FOOTER_INNER2       string
384FOOTER_INNER3       string
385FOOTER_CENTER0      string
386FOOTER_CENTER1      string
387FOOTER_CENTER2      string
388FOOTER_CENTER3      string
389FOOTER_OUTER0       string
390FOOTER_OUTER1       string
391FOOTER_OUTER2       string
392FOOTER_OUTER3       string
393!endblock
394
395# Declare the document "title" variables
396!block variables; family="DOC"
397Name            Type        Rule
398COVER           string
399NAME            string
400TYPE            string
401STATUS          string
402AUTHOR          string
403AUTHOR2         string
404AUTHOR3         string
405CODE            string
406VERSION         string
407DISTRIBUTION    string
408PROJECT         string
409PRODUCT         string
410SECTION         integer
411APPROVE         string
412APPROVE2        string
413APPROVE3        string
414ID              string
415ID_SEP          string
416URL             string
417TITLE           string
418OWNER           string
419LOGO            string
420LOGO_BASE       string
421TITLE_LOGO      string
422TITLE_LOGO_BASE string
423ADMIN_LOGO      string
424ADMIN_LOGO_BASE string
425HTML_LOGO       string
426HTML_LOGO_BASE  string
427TOPIC_LOGO      string
428TOPIC_LOGO_BASE string
429MANUAL_LOGO     string
430COMPONENT_LOGO  string
431TOC             integer
432LOF             boolean
433LOT             boolean
434IX              boolean
435TWO_SIDES       boolean
436COMPONENT       string
437PAGED           boolean
438!endblock
439
440# Export these for use in generating lists
441#!block variables; family="DOC"; export
442!block variables; family="DOC"
443Name        Type        Rule
444TOC_TITLE   string
445TOC_GRAPHIC string
446LOF_TITLE   string
447LOT_TITLE   string
448!endblock
449
450# Set the default list indent (1/4 inch)
451!default OPT_LIST_INDENT 18
452
453# Modified date variable for easier memos, etc.
454!define MODIFIED_DATE DATE:DOC_MODIFIED
455
456# Generally useful SDF variables
457!define SDF             "{{PRD:SDF}}"
458!define SDF_WWW         "http://www.mincom.com/mtr/sdf"
459!define SDF_FTP         "ftp://ftp.mincom.com/pub/mtr/sdf"
460!define SDF_BUGS        '{{EMAIL:sdf-bugs@mincom.com}}'
461!define SDF_USERS       '{{EMAIL:sdf-users@mincom.com}}'
462
463######## Define the standard rules #########
464
465# If the text attribute is set, use it instead of the current text
466!on paragraph '';; if (defined($attr{'text'})) {$text = delete $attr{'text'}}
467!on phrase    '';; if (defined($attr{'text'})) {$text = delete $attr{'text'}}
468
469# For online target, ignore the style (i.e. make 'as-is') for hypertext jumps
470!if $var{'OPT_TARGET'} eq 'html' || $var{'OPT_TARGET'} eq 'hlp' || $var{'OPT_TARGET'} eq 'fvo'
471!on phrase '';; $style = 'A' if $attr{'jump'} ne ''
472!endif
473
474# Convert xref attributes to a special style, if the output is PostScript
475!if $var{'OPT_TARGET'} eq 'ps'
476!on phrase '';; &ConvertXRef
477!endif
478
479# Treat 'obj' paragraphs as phrases
480!on paragraph '';; &CheckParaObject
481
482# Support KN & KP (keep-next/previous) paragraph styles
483!on paragraph 'KN';; $style = N; $attr{'keep_next'} = 1
484!on paragraph 'KP';; $style = N; $attr{'keep_prev'} = 1
485
486# Automatic hypertext generation
487!on phrase 'JUMP' ;; $attr{'jump'} = $text
488!on phrase 'EMAIL';; $attr{'jump'} = "mailto:" . $text
489!on phrase 'SECT' ;; &BuildSectJump
490
491# If OPT_NOBARS is set, ignore change bars
492!if OPT_NOBARS
493!on paragraph '';; delete $attr{'changed'} if $attr{'changed'};
494!on phrase    '';; delete $attr{'changed'} if $attr{'changed'};
495!endif
496
497# Useful filters
498!on filter 'template';; $name='inline'; $params.="; expand"
499!on filter 'changed';; $name='sdf'; $params.="; changed"
500!on filter 'center' ;; $name='sdf'; $params.="; align=Center"
501!on filter 'chapter';; $name = 'sdf'
502!on filter 'glossary';; $name = 'plain'
503
504# Do nice things to phrases which look like URLs
505!on phrase '1';; \
506        if ($text =~ /^(http|ftp|telnet|news|gopher|wais|https|snews):/) {\
507            $style = 'JUMP'; \
508        }
509
510# Make URL an alias for JUMP
511!on phrase 'URL';; $style="JUMP"
512
513# For all level 1 headings, reset the current topic name
514#!on paragraph '[HAP]1';; $topic = $attr{'id'}
515!on paragraph '[HAP]1';; $topic = $text
516
517# Convert a glossary paragraph into term and definition paragraphs
518!if $var{'OPT_TARGET'} ne 'html'
519!on paragraph 'GL';; $style = 'GLT'; \
520                     ($text, $_rest) = split(/\t/, $text, 2);\
521                     &AppendText("GLD:" . $_rest)
522!endif
523
524# Give each heading a hypertext id, unless:
525# * it doesn't have one, or
526# * it already has one, or
527# * it has been explicitly excluded from the table of contents.
528!if &Var('OPT_DRIVER') ne 'raw'
529!on paragraph '[HAP]\d';; \
530    unless ($attr{'noid'} || $attr{'id'} ne '' || $attr{'notoc'}) { \
531        $attr{'id'} = $subsection_prefix{$text} . &TextToId($text); \
532    }
533!endif
534
535# If a file looks like a URL, assume it is (a PODism)
536!on phrase 'FILE';; if ($text =~ /^\w\w+:/) {$attr{'jump'} = $text}
537
538# Support POD phrase style names
539!on phrase 'C';; $style = 'EX'
540#!on phrase 'E';; $style = 'CHAR'
541!on phrase 'F';; $style = 'FILE'
542
543# DOC_PAGED needs to be set here (rather than in *.sdn) as sdn files
544# get invoked *after* DOC_PAGED triggers the page-related stuff.
545!if $var{'OPT_DRIVER'} eq 'mif' || $var{'HTMLDOC'}
546!define DOC_PAGED 1
547!endif
548
549
550######## Define the standard classes & objects #########
551
552# Note: Class definitions must occur AFTER the general rules defined above,
553# as defining a class adds rules to the event processing tables.
554# Likewise, rules which assume a class has been defined must go
555# AFTER the class definitions below.
556
557# Classes
558!class references    'REF,DOC'; 'Reference,Document'; 'Jump,Version,Status'
559!class terms         'TERM'   ; 'Term,Definition'
560!class products      'PRD'    ; 'Name'
561!class organisations 'ORG,ORGN'
562
563# Support REFNUMONLY - a reference where only the trailing number is output
564!on phrase 'REFNUMONLY';; $style = 'REF'; \
565    $attr{'text'} = ($text =~ /([\d\.]+)$/) ? $1 : $text
566
567# Objects
568!block products; data
569Name            Jump
570SDF             http://www.mincom.com/mtr/sdf/
571!endblock
572
573
574######## Load the standard libraries & modules #########
575
576!inherit "images"
577!use     "stdlib/macros"
578!use     "stdlib/langdefs"
579!use     "locale/$var{'OPT_LOCALE'}.sdl"
580