First instalment of a manual for Halibut. This lot covers the
[sgt/halibut] / doc / input.but
CommitLineData
11f2edfa 1\C{input} Halibut input format
2
3This chapter describes the format in which you should write
4documents to be processed by Halibut.
5
6\H{input-basics} The basics
7
8Halibut's input files mostly look like ordinary ASCII text files;
9you can edit them with any text editor you like.
10
11Writing paragraphs of ordinary text is very simple: you just write
12ordinary text in the ordinary way. You can wrap a paragraph across
13more than one line using line breaks in the text file, and Halibut
14will ignore this when it rewraps the paragraph for each output
15format. To separate paragraphs, use a blank line (i.e. two
16consecutive line breaks). For example, a fragment of Halibut input
17looking like this:
18
19\c This is a line of text.
20\c This is another line of text.
21\c
22\c This line is separated from the previous one by a blank line.
23
24will produce two paragraphs looking like this:
25
26\quote{
27This is a line of text.
28This is another line of text.
29
30This line is separated from the previous one by a blank line.
31}
32
33The first two lines of the input have been merged together into a
34single paragraph, and the line break in the input file was treated
35identically to the spaces between the individual words.
36
37Halibut is designed to have very few special characters. The only
38printable characters in Halibut input which will not be treated
39exactly literally in the output are the backslash (\c{\\}) and the
40braces (\c{\{} and \c{\}}). If you do not use these characters,
41\e{everything} else you might type in normal ASCII text is perfectly
42safe. If you do need to use any of those three characters in your
43document, you will have to precede each one with a backslash. Hence,
44for example, you could write
45
46\c This \\ is a backslash, and these are \{braces\}.
47
48and Halibut would generate the text
49
50\quote{
51This \\ is a backslash, and these are \{braces\}.
52}
53
54\H{input-inline} Simple inline formatting commands
55
56Halibut formatting commands all begin with a backslash, followed by
57a word or character identifying the command. Some of them then use
58braces to surround one or more pieces of text acted on by the
59command. (In fact, the \c{\\\\}, \c{\\\{} and \c{\\\}} sequences you
60met in \k{input-basics} are themselves formatting commands.)
61
62This section describes some simple formatting commands you can use
63in Halibut documents. The commands in this section are \e{inline}
64commands, which means you can use them in the middle of a paragraph.
65\K{input-para} describes some \e{paragraph} commands, which affect a
66whole paragraph at a time.
67
68\S{input-emph} \c{\\e}: Emphasising text
69
70Possibly the most obvious piece of formatting you might want to use
71in a document is \e{emphasis}. To emphasise text, you use the
72\c{\\e} command, and follow it up with the text to be emphasised in
73braces. For example, the first sentence in this paragraph was
74generated using the Halibut input
75
76\c Possibly the most obvious piece of formatting you might want to use
77\c in a document is \e{emphasis}.
78
79\S{input-code} \c{\\c} and \c{\\cw}: Displaying computer code inline
80
81Halibut was primarily designed to produce software manuals. It can
82be used for other types of document as well, but software manuals
83are its speciality.
84
85In software manuals, you often want to format text in a way that
86indicates that it is something you might see displayed verbatim on
87a computer screen. In printed manuals, this is typically done by
88setting that text in a font which is obviously fixed-width. This
89provides a visual cue that the text being displayed is code, and it
90also ensures that punctuation marks are clearly separated and shown
91individually (so that a user can copy the text accurately and
92conveniently).
93
94Halibut provides \e{two} commands for this, which are subtly
95different. The names of those commands are \c{\\c} (\q{code}) and
96\c{\\cw} (\q{weak code}). You use them just like \c{\\e}, by
97following them with some text in braces. For example, this...
98
99\c This sentence contains some \c{code} and some \cw{weak code}.
100
101... produces this:
102
103\quote{
104This sentence contains some \c{code} and some \cw{weak code}.
105}
106
107The distinction between code and weak code is mainly important when
108producing plain text output. Plain text output is typically viewed
109in a fixed-width font, so there is no need (and no way) to change
110font in order to make the order of punctuation marks clear. However,
111marking text as code is also \e{sometimes} done to provide a visual
112distinction between it and the text around it, so that the reader
113knows where the literal computer text starts and stops; and in plain
114text, this cannot be done by changing font, so there needs to be an
115alternative way.
116
117So in the plain text back end, things marked as code (\c{\\c}) will
118be surrounded by quote marks, so that it's obvious where they start
119and finish. Things marked as weak code (\c{\\cw}) will not look any
120different from normal text.
121
122I recommend using weak code for any application where it is
123\e{obvious} that the text is literal computer input or output. For
124example, if the text is capitalised, that's usually good enough. If
125I talk about the Pentium's \cw{EAX} and \cw{EDX} registers, for
126example, you don't need quotes to notice that those are special; so
127I would write that in Halibut as \q{\c{the Pentium's \\cw\{EAX\} and
128\\cw\{EDX\} registers}}. But if I'm talking about the Unix command
129\c{man}, which is an ordinary English word in its own right, a reader
130might be slightly confused if it appeared in the middle of a
131sentence undecorated; so I would write that as \q{\c{the Unix command
132\\c\{man\}}}.
133
134In summary:
135
136\b \c{\\c} means \q{this text \e{must} be visually distinct from the
137text around it}. Halibut's various output formats will do this by
138changing the font if possible, or by using quotes if not.
139
140\b \c{\\cw} means \q{it would be nice to display this text in a
141fixed-width font if possible, but it's not essential}.
142
143There is a separate mechanism for displaying computer code in an
144entire paragraph; see \k{input-codepara} for that one.
145
146\S{input-quotes} \c{\\q}: Quotation marks
147
148Halibut's various output formats don't all use the same conventions
149for displaying text in ordinary quotation marks (\q{like these}).
150Some output formats have access to proper matched quote characters,
151whereas others are restricted to using plain ASCII. Therefore, it is
152not ideal to use the ordinary ASCII double quote character in your
153document (although you can if you like).
154
155Halibut provides the formatting command \c{\\q} to indicate quoted
156text. If you write
157
158\c Here is some \q{text in quotes}.
159
160then Halibut will print
161
162\quote{
163Here is some \q{text in quotes}.
164}
165
166and in every output format Halibut generates, it will choose the
167best quote characters available to it in that format.
168
169You can still use ordinary ASCII double quotes if you prefer; or you
170could even use the \c{\\u} command (see \k{input-unicode}) to
171generate Unicode matched double quotes and fall back to the normal
172ASCII one if they aren't available. But I recommend using the
173built-in \c{\\q} command in most cases, because it's simple and does
174the best it can everywhere.
175
176(Note that if you're using the \c{\\c} or \c{\\cw} commands to
177display literal computer code, you probably \e{will} want to use
178literal ASCII quote characters, because it is likely to matter
179precisely which quote character you use.)
180
181\S{input-nonbreaking} \c{\\-} and \c{\\_}: Non-breaking hyphens and
182spaces
183
184If you use an ordinary hyphen in the middle of a word (such as
185\q{built-in}), Halibut's output formats will feel free to break a
186line after that hyphen when wrapping paragraphs. This is fine for a
187word like \q{built-in}, but if you were displaying some literal
188computer code such as the Emacs command
189\c{M\-x\_psychoanalyze\-pinhead}, you might prefer to see the whole
190hyphenated word treated as an unbreakable block. In some cases, you
191might even want to prevent the \e{space} in that command from
192becoming a line break.
193
194For these purposes, Halibut provides the commands \c{\\-} and
195\c{\\_}, which generate a non-breaking hyphen and a non-breaking
196space respectively. So the above Emacs command might be written as
197
198\c the Emacs command \c{M\-x\_psychoanalyze\-pinhead}
199
200Unfortunately, some of Halibut's output formats do not support
201non-breaking hyphens, and others don't support \e{breaking} hyphens!
202So Halibut cannot promise to honour these commands in all situations.
203All it can do is make a best effort.
204
205\S{input-date} \c{\\date}: Automatic date generation
206
207Sometimes you might want your document to give an up-to-date
208indication of the date on which it was run through Halibut.
209
210Halibut supplies the \c{\\date} command to do this. In its simplest
211form, you simply say
212
213\c This document was generated on \date.
214
215and Halibut generates something like
216
217\quote{
218This document was generated on \date.
219}
220
221If you would prefer the date to be generated in a specific format,
222you can follow the \c{\\date} command with a format specification in
223braces. The format specification will be run through the standard C
224function \c{strftime}, so any format acceptable to that function is
225acceptable here as well. I won't document the format here, because
226the details vary from computer to computer (although there is a
227standard core which should be supported everywhere). You should look
228at your local system's manual for \c{strftime} for details.
229
230Here's an example which generates the date in the international
231standard ISO 8601 format:
232
233\c This document was generated on \date{%Y-%m-%d %H:%M:%S}.
234
235And here's some sample output from that command:
236
237\quote{
238This document was generated on \date{%Y-%m-%d %H:%M:%S}.
239}
240
241\S{input-weblink} \c{\\W}: WWW hyperlinks
242
243Since one of Halibut's output formats is HTML, it's obviously useful
244to be able to provide links to arbitrary web sites in a Halibut
245document.
246
247This is done using the \c{\\W} command. \c{\\W} expects to be
248followed by \e{two} sets of braces. In the first set of braces you
249put a URL; in the second set you put the text which should be a
250hyperlink. For example, you might write
251
252\c Try searching on \W{http://www.google.com/}{Google}.
253
254and Halibut would generate
255
256\quote{
257Try searching on \W{http://www.google.com/}{Google}.
258}
259
260Note that hyperlinks, like the non-breaking commands discussed in
261\k{input-nonbreaking}, are \e{discretionary}: if an output format
262does not support them then they will just be left out completely. So
263unless you're \e{only} intending to use the HTML output format, you
264should avoid storing vital content in the URL part of a \c{\\W}
265command. The Google example above is reasonable (because most users
266are likely to be able to find Google for themselves even without a
267convenient hyperlink leading straight there), but if you really need
268to direct users to a specific web site, you will need to give the
269URL in actual displayed text (probably displayed as code as well).
270However, there's nothing to stop you making it a hyperlink \e{as
271well} for the convenience of HTML readers.
272
273The \c{\\W} command supports a piece of extra syntax to make this
274convenient for you. You can specify \c{\\c} or \c{\\cw} \e{between}
275the first and second pairs of braces. For example, you might write
276
277\c Google is located at \W{http://www.google.com/}\cw{www.google.com}.
278
279and Halibut would produce
280
281\quote{
282Google is located at \W{http://www.google.com/}\cw{www.google.com}.
283}
284
285\S{input-unicode} \c{\\u}: Specifying arbitrary Unicode characters
286
287When Halibut is finished, it should have full Unicode support. You
288should be able to specify any (reasonably well known) character set
289for your input document, and Halibut should convert it all to
290Unicode as it reads it in. Similarly, you should be able to specify
291the character set you want for each output format and have all the
292conversion done automatically.
293
294Currently, none of this is actually supported. Input text files are
295assumed to be in ISO 8859-1, and each output format has its own
296non-configurable character set (although the HTML output can use the
297\c{Ӓ} mechanism to output any Unicode character it likes).
298
299If you need to specify a Unicode character in your input document
300which is not supported by the input character set, you can use the
301\c{\\u} command to do this. \c{\\u} expects to be followed by a
302sequence of hex digits; so that \c{\\u0041}, for example, denotes
303the Unicode character \cw{0x0041}, which is the capital letter A.
304
305If a Unicode character specified in this way is not supported in a
306particular \e{output} format, you probably don't just want it to be
307omitted. So you can put a pair of braces after the \c{\\u} command
308containing fallback text. For example, to specify an amount of money
309in euros, you might write this:
310
311\c This is likely to cost \u20AC{EUR }2500 at least.
312
313Halibut will render that as a Euro sign \e{if available}, and
314the text \q{EUR } if not. In the output format you're currently
315reading in, the above input generates this:
316
317\quote{
318This is likely to cost \u20AC{EUR }2500 at least.
319}
320
321If you read it in other formats, you may see different results.
322
323\S{input-xref} \c{\\k} and \c{\\K}: Cross-references to other sections
324
325\K{intro-features} mentions that Halibut numbers the sections of
326your document automatically, and can generate cross-references to
327them on request. \c{\\k} and \c{\\K} are the commands used to
328generate those cross-references.
329
330To use one of these commands, you simply follow it with a pair of
331braces containing the keyword for the section in question. For
332example, you might write something like
333
334\c \K{input-xref} expands on \k{intro-features}.
335
336and Halibut would generate something like
337
338\quote{
339\K{input-xref} expands on \k{intro-features}.
340}
341
342The keywords \c{input-xref} and \c{intro-features} are section
343keywords used in this manual itself. In your own document, you would
344have supplied a keyword for each one of your own sections, and you
345would provide your own keywords for the \c{\\k} command to work on.
346
347The difference between \c{\\k} and \c{\\K} is simply that \c{\\K}
348starts the cross-reference text with a capital letter; so you would
349use \c{\\K} at the beginning of a sentence, and \c{\\k} everywhere
350else.
351
352In output formats which permit it, cross-references act as
353hyperlinks, so that clicking the mouse on a cross-reference takes
354you straight to the referenced section.
355
356The \c{\\k} commands are also used for referring to entries in a
357bibliography (see \k{input-biblio} for more about bibliographies),
358and can also be used for referring to an element of a numbered list
359by its number (see \k{input-list-number} for more about numbered
360lists).
361
362See \k{input-sections} for more about chapters and sections.
363
364\S{input-inline-comment} \c{\\#}: Inline comments
365
366If you want to include comments in your Halibut input, to be seen
367when reading it directly but not copied into the output text, then
368you can use \c{\\#} to do this. If you follow \c{\\#} with text in
369braces, that text will be ignored by Halibut.
370
371For example, you might write
372
373\c The typical behaviour of an antelope \#{do I mean gazelle?} is...
374
375and Halibut will simply leave out the aside about gazelles, and will
376generate nothing but
377
378\quote{
379The typical behaviour of an antelope \#{do I mean gazelle?} is...
380}
381
382The \c{\\#} command can also be used to produce a whole-paragraph
383comment; see \k{input-commentpara} for details of that.
384
385\H{input-para} Paragraph-level commands
386
387This section describes Halibut commands which affect an entire
388paragraph, or sometimes even \e{more} than one paragraph, at a time.
389
390\S{input-codepara} \c{\\c}: Displaying whole paragraphs of computer
391code
392
393\K{input-code} describes a mechanism for displaying computer code in
394the middle of a paragraph, a few words at a time.
395
396However, this is often not enough. Often, in a computer manual, you
397really want to show several lines of code in a display paragraph.
398
399This is also done using the \c{\\c} command, in a slightly different
400way. Instead of using it in the middle of a paragraph followed by
401braces, you can use it at the start of each line of a paragraph. For
402example, you could write
403
404\c \c #include <stdio.h>
405\c \c
406\c \c int main(int argc, char **argv) {
407\c \c printf("hello, world\n");
408\c \c return 0;
409\c \c }
410
411and Halibut would generate
412
413\quote{
414
415\c #include <stdio.h>
416\c
417\c int main(int argc, char **argv) {
418\c printf("hello, world\n");
419\c return 0;
420\c }
421
422}
423
424Note that the above paragraph makes use of a backslash and a pair of
425braces, and does \e{not} need to escape them in the way described in
426\k{input-basics}. This is because code paragraphs formatted in this
427way are a special case; the intention is that you can just copy and
428paste a lump of code out of another program, put \q{\cw{\\c }} at the
429start of every line, and simply \e{not have to worry} about the
430details - you don't have to go through the whole block looking for
431characters to escape.
432
433Since a backslash inside a code paragraph generates a literal
434backslash, this means you cannot use any other Halibut formatting
435commands inside a code paragraph. In particular, if you want to
436emphasise a particular word in the paragraph, you can't do that
437using \c{\\e} (\k{input-emph}) in the normal way.
438
439Therefore, Halibut provides an alternative means of emphasis in code
440paragraphs. Each line beginning with \c{\\c} can optionally be
441followed by a single line beginning with \c{\\e}, indicating the
442emphasis in that line. The emphasis line contains the letters \c{b}
443and \c{i} (for \q{bold} and \q{italic}, although some output formats
444might render \c{i} as underlining instead of italics), positioned
445to line up under the parts of the text that you want emphasised.
446
447For example, if you wanted to do syntax highlighting on the above C
448code by highlighting the preprocessor command in italic and the
449keywords in bold, you might do it like this:
450
451\c \c #include <stdio.h>
452\c \e iiiiiiiiiiiiiiiiii
453\c \c
454\c \c int main(int argc, char **argv) {
455\c \e bbb bbb bbbb
456\c \c printf("hello, world\n");
457\c \c return 0;
458\c \e bbbbbb
459\c \c }
460
461and Halibut would generate:
462
463\quote{
464
465\c #include <stdio.h>
466\e iiiiiiiiiiiiiiiiii
467\c
468\c int main(int argc, char **argv) {
469\e bbb bbb bbbb
470\c printf("hello, world\n");
471\c return 0;
472\e bbbbbb
473\c }
474
475}
476
477Note that not every \c{\\c} line has to be followed by a \c{\\e}
478line; they're optional.
479
480Also, note that highlighting within a code paragraph is
481\e{discretionary}. Not all of Halibut's output formats can support
482it (plain text, in particular, has no sensible way to do it). Unless
483you know you are using a restricted range of output formats, you
484should use highlighting in code paragraphs \e{only} as a visual aid,
485and not rely on it to convey any vital semantic content.
486
487\S{input-lists} \c{\\b}, \c{\\n}, \c{\\dt}, \c{\\dd}, \c{\\lcont}: Lists
488
489Halibut supports bulletted lists, numbered lists and description
490lists.
491
492\S2{input-list-bullet} \c{\\b}: Bulletted lists
493
494To create a bulletted list, you simply prefix each paragraph
495describing a bullet point with the command \c{\\b}. For example, this
496Halibut input:
497
498\c Here's a list:
499\c
500\c \b One.
501\c
502\c \b Two.
503\c
504\c \b Three.
505
506would produce this Halibut output:
507
508\quote{
509Here's a list:
510
511\b One.
512
513\b Two.
514
515\b Three.
516}
517
518\S2{input-list-number} \c{\\n}: Numbered lists
519
520Numbered lists are just as simple: instead of \c{\\b}, you use
521\c{\\n}, and Halibut takes care of getting the numbering right for
522you. For example:
523
524\c Here's a list:
525\c
526\c \n One.
527\c
528\c \n Two.
529\c
530\c \n Three.
531
532This produces the Halibut output:
533
534\quote{
535Here's a list:
536
537\n One.
538
539\n Two.
540
541\n Three.
542}
543
544The disadvantage of having Halibut sort out the list numbering for
545you is that if you need to refer to a list item by its number, you
546can't reliably do so. To get round this, Halibut allows an optional
547keyword in braces after the \c{\\n} command. This keyword can then
548be referenced using the \c{\\k} or \c{\\K} command (see
549\k{input-xref}) to provide the number of the list item. For example:
550
551\c Here's a list:
552\c
553\c \n One.
554\c
555\c \n{this-one} Two.
556\c
557\c \n Three.
558\c
559\c \n Now go back to step \k{this-one}.
560
561This produces the following output:
562
563\quote{
564Here's a list:
565
566\n One.
567
568\n{this-one} Two.
569
570\n Three.
571
572\n Now go back to step \k{this-one}.
573}
574
575\S2{input-list-description} \c{\\dt} and \c{\\dd}: Description lists
576
577To wrie a description list, you prefix alternate paragraphs with the
578\c{\\dt} (\q{described thing}) and \c{\\dd} (description) commands.
579For example:
580
581\c \dt Pelican
582\c
583\c \dd This is a large bird with a big beak.
584\c
585\c \dt Panda
586\c
587\c \dd This isn't.
588
589This produces the following output:
590
591\quote{
592
593\dt Pelican
594
595\dd This is a large bird with a big beak.
596
597\dt Panda
598
599\dd This isn't.
600
601}
602
603\S2{input-list-continuation} Continuing list items into further
604paragraphs
605
606All three of the above list types assume that each list item is a
607single paragraph. For a short, snappy list in which each item is
608likely to be only one or two words, this is perfectly sufficient;
609but occasionally you will find you want to include several
610paragraphs in a single list item, or even to nest other types of
611paragraph (such as code paragraphs, or other lists) inside a list
612item.
613
614To do this, you use the \c{\\lcont} command. This is a command which
615can span \e{multiple} paragraphs.
616
617After the first paragraph of a list item, include the text
618\c{\\lcont\{}. This indicates that the subsequent paragraph(s) are a
619\e{continuation} of the list item that has just been seen. So you
620can include further paragraphs, and eventually include a closing
621brace \c{\}} to finish the list continuation. After that, you can
622either continue adding other items to the original list, or stop
623immediately and return to writing normal paragraphs of text.
624
625Here's a (long) example.
626
627\c Here's a list:
628\c
629\c \n One. This item is followed by a code paragraph:
630\c
631\c \lcont{
632\c
633\c \c code
634\c \c paragraph
635\c
636\c }
637\c
638\c \n Two. Now when I say \q{two}, I mean:
639\c
640\c \lcont{
641\c
642\c \n Two, part one.
643\c
644\c \n Two, part two.
645\c
646\c \n Two, part three.
647\c
648\c }
649\c
650\c \n Three.
651
652The output produced by this fragment is:
653
654\quote{
655
656Here's a list:
657
658\n One. This item is followed by a code paragraph:
659
660\lcont{
661
662\c code
663\c paragraph
664
665}
666
667\n Two. Now when I say \q{two}, I mean:
668
669\lcont{
670
671\n Two, part one.
672
673\n Two, part two.
674
675\n Two, part three.
676
677}
678
679\n Three.
680
681}
682
683This syntax seems a little bit inconvenient, and perhaps
684counter-intuitive: you might expect the enclosing braces to have to
685go around the \e{whole} list item, rather than everything except the
686first paragraph.
687
688\c{\\lcont} is a recent addition to the Halibut input language;
689previously, \e{all} lists were required to use no more than one
690paragraph per list item. So it's certainly true that this feature
691looks like an afterthought because it \e{is} an afterthought, and
692it's possible that if I'd been designing the language from scratch
693with multiple-paragraph list items in mind, I would have made it
694look different.
695
696However, the advantage of doing it this way is that no enclosing
697braces are required in the \e{common} case: simple lists with only
698one paragraph per item are really, really easy to write. So I'm not
699too unhappy with the way it turned out; it obeys the doctrine of
700making simple things simple, and difficult things possible.
701
702Note that \c{\\lcont} can only be used on \c{\\b}, \c{\\n} and
703\c{\\dd} paragraphs; it cannot be used on \c{\\dt}.
704
705\S{input-rule} \c{\\rule}: Horizontal rules
706
707The command \c{\\rule}, appearing on its own as a paragraph, will
708cause a horizontal rule to be drawn, like this:
709
710\c Some text.
711\c
712\c \rule
713\c
714\c Some more text.
715
716This produces the following output:
717
718\quote{
719
720Some text.
721
722\rule
723
724Some more text.
725
726}
727
728\S{input-quote} \c{\\quote}: Indenting multiple paragraphs as a long
729quotation
730
731Quoting verbatim text using a code paragraph (\k{input-codepara}) is
732not always sufficient for your quoting needs. Sometimes you need to
733quote some normally formatted text, possibly in multiple paragraphs.
734
735To do this, you can use the \c{\\quote} command. Like \c{\\lcont},
736this is a command which expects to enclose at least one paragraph
737and possibly more. Simply write \c{\\quote\{} at the beginning of
738your quoted section, and \c{\}} at the end, and the paragraphs in
739between will be formatted to indicate that they are a quotation.
740
741(This very manual, in fact, uses this feature a lot: all of the
742examples of Halibut source followed by Halibut output have the
743output quoted using \c{\\quote}.)
744
745Here's some example Halibut input:
746
747\c In \q{Through the Looking Glass}, Lewis Carroll wrote:
748\c
749\c \quote{
750\c
751\c \q{The question is,} said Alice, \q{whether you \e{can} make
752\c words mean so many different things.}
753\c
754\c \q{The question is,} said Humpty Dumpty, \q{who is to be master -
755\c that's all.}
756\c
757\c }
758\c
759\c So now you know.
760
761The output generated by this is:
762
763\quote{
764
765In \q{Through the Looking Glass}, Lewis Carroll wrote:
766
767\quote{
768
769\q{The question is,} said Alice, \q{whether you \e{can} make
770words mean so many different things.}
771
772\q{The question is,} said Humpty Dumpty, \q{who is to be master -
773that's all.}
774
775}
776
777So now you know.
778
779}
780
781\S{input-sections} \c{\\C}, \c{\\H}, \c{\\S}, \c{\\A}, \c{\\U}:
782Chapter and section headings
783
784\K{intro-features} mentions that Halibut numbers the sections of
785your document automatically, and can generate cross-references to
786them on request; \k{input-xref} describes the \c{\\k} and \c{\\K}
787commands used to generate the cross-references. This section
788describes the commands used to set up the sections in the first
789place.
790
791A paragraph beginning with the \c{\\C} command defines a chapter
792heading. The \c{\\C} command expects to be followed by a pair of
793braces containing a keyword for the chapter; this keyword can then
794be used with the \c{\\k} and \c{\\K} commands to generate
795cross-references to the chapter. After the closing brace, the rest
796of the paragraph is used as the displayed chapter title. So the
797heading for the current chapter of this manual, for example, is
798written as
799
800\c \C{input} Halibut input format
801
802and this allows me to use the command \c{\\k\{input\}} to generate a
803cross-reference to that chapter somewhere else.
804
805The next level down from \c{\\C} is \c{\\H}, for \q{heading}. This
806is used in exactly the same way as \c{\\C}, but section headings
807defined with \c{\\H} are considered to be part of a containing
808chapter, and will be numbered with a pair of numbers. After \c{\\H}
809comes \c{\\S}, and if necessary you can then move on to \c{\\S2},
810\c{\\S3} and so on.
811
812For example, here's a sequence of heading commands. Normally these
813commands would be separated at least by blank lines (because each is
814a separate paragraph), and probably also by body text; but for the
815sake of brevity, both of those have been left out in this example.
816
817\c \C{foo} Using Foo
818\c \H{foo-intro} Introduction to Foo
819\c \H{foo-running} Running the Foo program
820\c \S{foo-inter} Running Foo interactively
821\c \S{foo-batch} Running Foo in batch mode
822\c \H{foo-trouble} Troubleshooting Foo
823\c \C{bar} Using Bar instead of Foo
824
825This would define two chapters with keywords \c{foo} and \c{bar},
826which would end up being called Chapter 1 and Chapter 2 (unless
827there were other chapters before them). The sections \c{foo-intro},
828\c{foo-running} and \c{foo-trouble} would be referred to as Section
8291.1, Section 1.2 and Section 1.3 respectively; the subsections
830\c{foo-inter} and \c{foo-batch} would be Section 1.2.1 and Section
8311.2.2. If there had been a \c{\\S2} command within one of those, it
832would have been something like Section 1.2.1.1.
833
834If you don't like the switch from \c{\\H} to \c{\\S}, you can use
835\c{\\S1} as a synonym for \c{\\S} and \c{\\S0} as a synonym for
836\c{\\H}. Chapters are still designated with \c{\\C}, because they
837need to be distinguished from other types of chapter such as
838appendices. (Personally, I like the \c{\\C},\c{\\H},\c{\\S} notation
839because it encourages me to think of my document as a hard disk :-)
840
841You can define an appendix by using \c{\\A} in place of \c{\\C}.
842This is no different from a chapter except that it's given a letter
843instead of a number, and cross-references to it will say \q{Appendix
844A} instead of \q{Chapter 9}. Subsections of an appendix will be
845numbered \q{A.1}, \q{A.2}, \q{A.2.1} and so on.
846
847If you want a particular section to be referred to as something
848other than a \q{chapter}, \q{section} or \q{appendix}, you can
849include a second pair of braces after the keyword. For example, if
850you're writing a FAQ chapter and you want cross-references between
851questions to refer to \q{question 1.2.3} instead of \q{section
8521.2.3}, you can write each section heading as
853
854\c \S{question-about-fish}{Question} What about fish?
855
856(The word \q{Question} should be given with an initial capital
857letter. Halibut will lower-case it when you refer to it using
858\c{\\k}, and will leave it alone if you use \c{\\K}.)
859
860This technique allows you to change the designation of
861\e{particular} sections. To make an overall change in what \e{every}
862section is called, see \k{input-config}.
863
864Finally, the \c{\\U} command defines an \e{unnumbered} chapter.
865These sometimes occur in books, for specialist purposes such as
866\q{Bibliography} or \q{Acknowledgements}. \c{\\U} does not expect a
867keyword argument, because there is no sensible way to generate an
868automatic cross-reference to such a chapter anyway.
869
870\S{input-blurb} \c{\\preamble}, \c{\\copyright}, \c{\\title},
871\c{\\versionid}: Miscellaneous blurb commands
872
873These four commands define a variety of special paragraph types.
874They are all used in the same way: you put the command at the start
875of a paragraph, and then just follow it with normal text, like this:
876
877\c \title My First Manual
878
879The four special paragraph types are:
880
881\dt \c{\\title}
882
883\dd This defines the overall title of the entire document. This
884title is treated specially in some output formats (for example, it's
885used in a \cw{<title>} tag in the HTML output), so it needs a
886special paragraph type to point it out.
887
888\dt \c{\\preamble}
889
890\dd This command indicates ordinary text that appears \e{before} the
891first chapter heading. \#{FIXME: figure out what Halibut actually
892does do with ordinary text before a chapter heading. Then figure out
893whether that's sensible. Then figure out what \preamble has to offer
894that's perceptibly different. Fix if necessary.}
895
896\dt \c{\\copyright}
897
898\dd This command indicates that the paragraph attached to it
899contains a copyright statement for the document. This text is
900usually displayed inline, in the same way as \c{\\preamble} text,
901but in some output formats it is given additional special treatment.
902For example, Windows Help files have a standard slot in which to
903store a copyright notice, so that other software can display it
904prominently.
905
906\dt \c{\\versionid}
907
908\dd This command indicates that the paragraph contains a version
909identifier, such as those produced by CVS (of the form \c{$\#{hope this
910defuses CVS}Id: thingy.but,v 1.6 2004/01/01 16:47:48 simon Exp $}).
911This text will be tucked away somewhere unobtrusive, so that anyone
912wanting to (for example) report errors to the document's author can
913pick out the version IDs and send them as part of the report, so
914that the author can tell at a glance which revision of the document
915is being discussed.
916
917\S{input-commentpara} \c{\\#}: Whole-paragraph comments
918
919\K{input-inline-comment} describes the use of the \c{\\#} command to
920put a short comment in the middle of a paragraph.
921
922If you need to use a \e{long} comment, Halibut also allows you to
923use \c{\\#} without braces, to indicate that an entire paragraph is
924a comment, like this:
925
926\c Here's a (fairly short) paragraph which will be displayed.
927\c
928\c \# Here's a comment paragraph which will not be displayed, no
929\c matter how long it goes on. All I needed to indicate this was the
930\c single \# at the start of the paragraph; I don't need one on
931\c every line or anything like that.
932\c
933\c Here's another displayed paragraph.
934
935When run through Halibut, this produces the following output:
936
937\quote{
938
939Here's a (fairly short) paragraph which will be displayed.
940
941\# Here's a comment paragraph which will not be displayed, no
942matter how long it goes on. All I needed to indicate this was the
943single \# at the start of the paragraph; I don't need one on
944every line or anything like that.
945
946Here's another displayed paragraph.
947
948}
949
950\H{input-biblio} Creating a bibliography
951
952If you need your document to refer to other documents (research
953papers, books, websites, whatever), you might find a bibliography
954feature useful.
955
956You can define a bibliography entry using the \c{\\B} command. This
957looks very like the \c{\\C} command and friends: it expects a
958keyword in braces, followed by some text describing the document
959being referred to. For example:
960
961\c \B{freds-book} \q{The Taming Of The Mongoose}, by Fred Bloggs.
962\c Published by Paperjam & Notoner, 1993.
963
964If this bibliography entry appears in the finished document, it will
965look something like this:
966
967\quote{
968
969\B{freds-book} \q{The Taming Of The Mongoose}, by Fred Bloggs.
970Published by Paperjam & Notoner, 1993.
971
972}
973
974I say \q{if} above because not all bibliography entries defined
975using the \c{\\B} command will necessarily appear in the finished
976document. They only appear if they are referred to by a \c{\\k}
977command (see \k{input-xref}). This allows you to (for example)
978maintain a single Halibut source file with a centralised database of
979\e{all} the references you have ever needed in any of your writings,
980include that file in every document you feed to Halibut, and have it
981only produce the bibliography entries you actually need for each
982particular document. (In fact, you might even want this centralised
983source file to be created automatically by, say, a Perl script from
984BibTeX input, so that you can share the same bibliography with users
985of other formatting software.)
986
987If you really want a bibliography entry to appear in the document
988even though no text explicitly refers to it, you can do that using
989the \c{\\nocite} command:
990
991\c \nocite{freds-book}
992
993Normally, each bibliography entry will be referred to (in citations
994and in the bibliography itself) by a simple reference number, such
995as \k{freds-book}. If you would rather use an alternative reference
996notation, such as [Fred1993], you can use the \c{\\BR}
997(\q{Bibliography Rewrite}) command to specify your own reference
998format for a particular book:
999
1000\c \BR{freds-book} [Fred1993]
1001
1002\H{input-index} Creating an index
1003
1004Halibut contains a comprehensive indexing mechanism, which attempts
1005to be reasonably easy to use in the common case in spite of its
1006power.
1007
1008\S{input-index-simple} Simple indexing
1009
1010In normal usage, you should be able to add index terms to your
1011document simply by using the \c{\\i} command to wrap one or two
1012words at a time. For example, if you write
1013
1014\c The \i{hippopotamus} is a particularly large animal.
1015
1016then the index will contain an entry under \q{hippopotamus},
1017pointing to that sentence (or as close to that sentence as the
1018output format sensibly permits).
1019
1020You can wrap more than one word in \c{\\i} as well:
1021
1022\c We recommend using a \i{torque wrench} for this job.
1023
1024\S{input-index-special} Special cases of indexing
1025
1026If you need to index a computer-related term, you can use the
1027special case \c{\\i\\c}:
1028
1029\c The \i\c{grep} command is what you want here.
1030
1031This will cause the word \q{grep} to appear in code style, as if the
1032\c{\\i} were not present and the input just said \c{\\c\{grep\}};
1033the word will also appear in code style in the actual index.
1034
1035If you want to simultaneously index and emphasise a word, there's
1036another special case \c{\\i\\e}:
1037
1038\c This is what we call a \i\e{paper jam}.
1039
1040This will cause the words \q{paper jam} to be emphasised in the
1041document, but (unlike the behaviour of \c{\\i\\c}) they will \e{not}
1042be emphasised in the index. This different behaviour is based on an
1043expectation that most people indexing a word of computer code will
1044still want it to look like code in the index, whereas most people
1045indexing an emphasised word will \e{not} want it emphasised in the
1046index.
1047
1048Sometimes you might want to index a term which is not explicitly
1049mentioned, but which is highly relevant to the text and you think
1050that somebody looking up that term in the index might find it useful
1051to be directed here. To do this you can use the \c{\\I} command, to
1052create an \e{invisible} index tag:
1053
1054\c If your printer runs out of toner, \I{replacing toner
1055\c cartridge}here is what to do:
1056
1057This input will produce only the output \q{If your printer runs out
1058of toner, here is what to do}; but an index entry will show up under
1059\q{replacing toner cartridge}, so that if a user thinks the obvious
1060place to start in the index is under R for \q{replacing}, they will
1061find their way here with a minimum of fuss.
1062
1063(It's worth noting that there is no functional difference between
1064\c{\\i\{foo\}} and \c{\\I\{foo\}foo}. The simple \c{\\i} case is
1065only a shorthand for the latter.)
1066
1067Finally, if you want to index a word at the start of a sentence, you
1068might very well not want it to show up with a capital letter in the
1069index. For this, Halibut provides the \c{\\ii} command, for \q{index
1070(case-)insensitively}. You use it like this:
1071
1072\c \ii{Lions} are at the top of the food chain in this area.
1073
1074This is equivalent to \c{\\I\{lions\}Lions}; in other words, the
1075text will say \q{Lions}, but it will show up in the index as
1076\q{lions}. The text inside \c{\\ii} is converted entirely into lower
1077case before being added to the index data.
1078
1079\S{input-index-rewrite} Fine-tuning the index
1080
1081Halibut's index mechanism as described so far still has a few
1082problems left:
1083
1084\b In a reasonably large index, it's often difficult to predict
1085which of several words a user will think of first when trying to
1086look something up. For example, if they want to know how to replace
1087a toner cartridge, they might look up \q{replacing} or they might
1088look up \q{toner cartridge}. You probably don't really want to have
1089to try to figure out which of those is more likely; instead, what
1090you'd like is to be able to effortlessly index the same set of
1091document locations under \e{both} terms.
1092
1093\b Also, you may find you've indexed the same concept under multiple
1094different index terms; for example, there might be several instances
1095of \c{\\i\{frog\}} and several of \c{\\i\{frogs\}}, so that you'd
1096end up with two separate index entries for what really ought to be
1097the same concept.
1098
1099\b You might well not want the word \q{\cw{grep}} to appear in the
1100index without explanation; you might prefer it to say something more
1101verbose such as \q{\cw{grep} command}, so that a user encountering
1102it in the index has some idea of what it is \e{without} having to
1103follow up the reference. However, you certainly don't want to have
1104to write \c{\\I\{\\cw\{grep\} command\}\\c\{grep\}} every time you
1105want to add an index term for this! You wanted to write
1106\c{\\i\\c\{grep\}} as shown in the previous section, and tidy it all
1107up afterwards.
1108
1109All of these problems can be cleaned up by the \c{\\IM} (for
1110\q{Index Modification}) command. \c{\\IM} expects to be followed by
1111one or more pairs of braces containing index terms as seen in the
1112document, and then a piece of text (not in braces) describing how it
1113should be shown in the index.
1114
1115So to rewrite the \c{grep} example above, you might do this:
1116
1117\c \IM{grep} \cw{grep} command
1118
1119This will arrange that the set of places in the document where you
1120asked Halibut to index \q{\cw{grep}} will be listed under
1121\q{\cw{grep} command} rather than just under \q{\cw{grep}}.
1122
1123You can specify more than one index term in a \c{\\IM} command; so
1124to merge the index terms \q{frog} and \q{frogs} into a single term,
1125you might do this:
1126
1127\c \IM{frog}{frogs} frog
1128
1129This will arrange that the single index entry \q{frog} will list
1130\e{all} the places in the document where you asked Halibut to index
1131either \q{frog} or \q{frogs}.
1132
1133You can use multiple \c{\\IM} commands to replicate the same set of
1134document locations in more than one index entry. For example:
1135
1136\c \IM{replacing toner cartridge} replacing toner cartridge
1137\c \IM{replacing toner cartridge} toner cartridge, replacing
1138
1139This will arrange that every place in the document where you have
1140indexed \q{replacing toner cartridge} will be listed both there
1141\e{and} under \q{toner cartridge, replacing}, so that no matter
1142whether the user looks under R or under T they will stil find their
1143way to the same parts of the document.
1144
1145In this example, note that although the first \c{\\IM} command
1146\e{looks} as if it's a tautology, it is still necessary, because
1147otherwise those document locations will \e{only} be indexed under
1148\q{toner cartridge, replacing}. If you have \e{no} explicit \c{\\IM}
1149commands for a particular index term, then Halibut will assume a
1150default one (typically \c{\\IM\{foo\}\_foo}, although it might be
1151\c{\\IM\{foo\}\_\\c\{foo\}} if you originally indexed using
1152\c{\\i\\c}); but as soon as you specify an explicit \c{\\IM},
1153Halibut discards its default implicit one, and you must then specify
1154that one explicitly as well if you wanted to keep it.
1155
1156\H{input-config} Configuring Halibut
1157
1158Halibut uses the \c{\\cfg} command to allow you to configure various
1159aspects of its functionality.
1160
1161The \c{\\cfg} command expects to be followed by at least one pair of
1162braces, and usually more after that. The first pair of braces
1163contains a keyword indicating what aspect of Halibut you want to
1164configure, and the meaning of the one(s) after that depends on the
1165first keyword.
1166
1167The current list of configuration keywords in the main Halibut code
1168is quite small. Here it is in full:
1169
1170\dt \cw{\\cfg\{chapter\}\{}\e{new chapter name}\cw{\}}
1171
1172\dd This tells Halibut that you don't want to call a chapter a
1173chapter any more. For example, if you give the command
1174\cw{\\cfg\{chapter\}\{Book\}}, then any chapter defined with the
1175\c{\\C} command will be labelled \q{Book} rather than \q{Chapter},
1176both in the section headings and in cross-references. This is
1177probably most useful if your document is not written in English.
1178
1179\dt \cw{\\cfg\{section\}\{}\e{new section name}\cw{\}}
1180
1181\dd Exactly like \c{chapter}, but changes the name given to
1182subsections of a chapter.
1183
1184\dt \cw{\\cfg\{appendix\}\{}\e{new appendix name}\cw{\}}
1185
1186\dd Exactly like \c{appendix}, but changes the name given to
1187appendices.
1188
1189In addition to these configuration commands, there are also
1190configuration commands provided by each individual output format.
1191These configuration commands are discussed along with each output
1192format, in FIXME.
1193
1194\H{input-macro} Defining macros
1195
1196If there's a complicated piece of Halibut source which you think
1197you're going to use a lot, you can define your own Halibut command
1198to produce that piece of source.
1199
1200In \k{input-unicode}, there is a sample piece of code which prints a
1201Euro sign, or replaces it with \q{EUR} if the Euro sign is not
1202available:
1203
1204\c This is likely to cost \u20AC{EUR }2500 at least.
1205
1206If your document quotes a \e{lot} of prices in Euros, you might not
1207want to spend all your time typing that out. So you could define a
1208macro, using the \c{\\define} command:
1209
1210\c \define{eur} \u20AC{EUR }
1211
1212Then you can just write
1213
1214\c This is likely to cost \eur 2500 at least.
1215
1216\# FIXME: need a NOP to allow text to directly follow this. \.?