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