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