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