1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Block Level Elements</title>
6 <link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
7 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8 <link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9 <link rel="up" href="../../quickbook.html" title="Chapter 50. Quickbook 1.7">
10 <link rel="prev" href="phrase.html" title="Phrase Level Elements">
11 <link rel="next" href="../versions.html" title="Language Versions">
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <table cellpadding="2" width="100%"><tr>
15 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
16 <td align="center"><a href="../../../../index.html">Home</a></td>
17 <td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
18 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20 <td align="center"><a href="../../../../more/index.htm">More</a></td>
23 <div class="spirit-nav">
24 <a accesskey="p" href="phrase.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../quickbook.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../versions.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
27 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
28 <a name="quickbook.syntax.block"></a>Block Level Elements</h2></div></div></div>
29 <div class="toc"><dl class="toc">
30 <dt><span class="section"><a href="block.html#quickbook.syntax.block.xinclude">xinclude</a></span></dt>
31 <dt><span class="section"><a href="block.html#quickbook.syntax.block.paragraphs">Paragraphs</a></span></dt>
32 <dt><span class="section"><a href="block.html#quickbook.syntax.block.lists">Lists</a></span></dt>
33 <dt><span class="section"><a href="block.html#quickbook.syntax.block.code">Code</a></span></dt>
34 <dt><span class="section"><a href="block.html#quickbook.syntax.block.escape_back">Escaping
35 Back To QuickBook</a></span></dt>
36 <dt><span class="section"><a href="block.html#quickbook.syntax.block.preformatted">Preformatted</a></span></dt>
37 <dt><span class="section"><a href="block.html#quickbook.syntax.block.blockquote">Blockquote</a></span></dt>
38 <dt><span class="section"><a href="block.html#quickbook.syntax.block.admonitions">Admonitions</a></span></dt>
39 <dt><span class="section"><a href="block.html#quickbook.syntax.block.headings">Headings</a></span></dt>
40 <dt><span class="section"><a href="block.html#quickbook.syntax.block.generic_heading">Generic
41 Heading</a></span></dt>
42 <dt><span class="section"><a href="block.html#quickbook.syntax.block.macros">Macros</a></span></dt>
43 <dt><span class="section"><a href="block.html#quickbook.syntax.block.predefined_macros">Predefined
44 Macros</a></span></dt>
45 <dt><span class="section"><a href="block.html#quickbook.syntax.block.templates">Templates</a></span></dt>
46 <dt><span class="section"><a href="block.html#quickbook.syntax.block.blurbs">Blurbs</a></span></dt>
47 <dt><span class="section"><a href="block.html#quickbook.syntax.block.tables">Tables</a></span></dt>
48 <dt><span class="section"><a href="block.html#quickbook.syntax.block.variable_lists">Variable
50 <dt><span class="section"><a href="block.html#quickbook.syntax.block.include">Include</a></span></dt>
51 <dt><span class="section"><a href="block.html#quickbook.syntax.block.import">Import</a></span></dt>
52 <dt><span class="section"><a href="block.html#quickbook.syntax.block.block">Plain
53 blocks</a></span></dt>
56 <div class="titlepage"><div><div><h3 class="title">
57 <a name="quickbook.syntax.block.xinclude"></a><a name="quickbook.ref.xinclude"></a><a class="link" href="block.html#quickbook.syntax.block.xinclude" title="xinclude">xinclude</a>
58 </h3></div></div></div>
60 You can include another XML file with:
62 <pre class="programlisting">[xinclude file.xml]
65 This is useful when file.xml has been generated by Doxygen and contains your
69 <code class="literal">xinclude</code> paths are normally used unchanged in the generated
70 documentation, which will not work if you wish them to be relative to the
71 current quickbook file. Quickbook can add a <code class="literal">xml:base</code> attribute
72 to the boostbook documentation to specify where <code class="literal">xinclude</code>
73 files should be found. For example, if you wish them to be relative to the
74 current quickbook file:
76 <pre class="programlisting">[article Article with xincludes
84 Now the xinclude should work if <code class="literal">file.xml</code> is in the same
85 directory as the quickbook file. Although it might not work if you distribute
86 the generated files (as their relative directories can change).
89 Say the article is generated in a sub-directory, by running something like:
91 <pre class="programlisting">quickbook article.qbk --output-file=output/article.xml
94 This will generate a boostbook root tag:
96 <pre class="programlisting"><article id="article_with_xincludes"
97 last-revision="$Date: 2013/08/20 08:26:48 $"
99 xmlns:xi="http://www.w3.org/2001/XInclude">
102 Because <code class="literal">xml:base</code> is set to <code class="literal">..</code>, the
103 xml processor will know to look in the parent directory to find <code class="literal">file.xml</code>,
104 which it comes across the <code class="literal">xi:include</code> tag.
107 <div class="section">
108 <div class="titlepage"><div><div><h3 class="title">
109 <a name="quickbook.syntax.block.paragraphs"></a><a name="quickbook.ref.paragraphs"></a><a class="link" href="block.html#quickbook.syntax.block.paragraphs" title="Paragraphs">Paragraphs</a>
110 </h3></div></div></div>
112 Paragraphs start left-flushed and are terminated by two or more newlines.
113 No markup is needed for paragraphs. QuickBook automatically detects paragraphs
114 from the context. Block markups [section, endsect, h1, h2, h3, h4, h5, h6,
115 blurb, (block-quote) ':', pre, def, table and include ] may also terminate
116 a paragraph. This is a new paragraph...
119 <div class="section">
120 <div class="titlepage"><div><div><h3 class="title">
121 <a name="quickbook.syntax.block.lists"></a><a name="quickbook.ref.lists"></a><a class="link" href="block.html#quickbook.syntax.block.lists" title="Lists">Lists</a>
122 </h3></div></div></div>
123 <div class="toc"><dl class="toc">
124 <dt><span class="section"><a href="block.html#quickbook.syntax.block.lists.ordered_lists">Ordered
125 lists</a></span></dt>
126 <dt><span class="section"><a href="block.html#quickbook.syntax.block.lists.list_hierarchies">List
127 Hierarchies</a></span></dt>
128 <dt><span class="section"><a href="block.html#quickbook.syntax.block.lists.long_list_lines">Long
129 List Lines</a></span></dt>
130 <dt><span class="section"><a href="block.html#quickbook.syntax.block.lists.unordered_lists">Unordered
131 lists</a></span></dt>
132 <dt><span class="section"><a href="block.html#quickbook.syntax.block.lists.mixed_lists">Mixed
133 lists</a></span></dt>
134 <dt><span class="section"><a href="block.html#quickbook.syntax.block.lists.list_paragraphs">Paragraphs
135 in lists</a></span></dt>
136 <dt><span class="section"><a href="block.html#quickbook.syntax.block.lists.list_tags">Explicit
137 list tags</a></span></dt>
139 <div class="section">
140 <div class="titlepage"><div><div><h4 class="title">
141 <a name="quickbook.syntax.block.lists.ordered_lists"></a><a name="quickbook.ref.ordered_lists"></a><a class="link" href="block.html#quickbook.syntax.block.lists.ordered_lists" title="Ordered lists">Ordered
143 </h4></div></div></div>
144 <pre class="programlisting"># One
151 <div class="orderedlist"><ol class="orderedlist" type="1">
152 <li class="listitem">
155 <li class="listitem">
158 <li class="listitem">
163 <div class="section">
164 <div class="titlepage"><div><div><h4 class="title">
165 <a name="quickbook.syntax.block.lists.list_hierarchies"></a><a name="quickbook.ref.list_hierarchies"></a><a class="link" href="block.html#quickbook.syntax.block.lists.list_hierarchies" title="List Hierarchies">List
167 </h4></div></div></div>
169 List hierarchies are supported. Example:
171 <pre class="programlisting"># One
186 <div class="orderedlist"><ol class="orderedlist" type="1">
187 <li class="listitem">
190 <li class="listitem">
193 <li class="listitem">
195 <div class="orderedlist"><ol class="orderedlist" type="a">
196 <li class="listitem">
199 <li class="listitem">
202 <li class="listitem">
207 <li class="listitem">
209 <div class="orderedlist"><ol class="orderedlist" type="a"><li class="listitem">
211 <div class="orderedlist"><ol class="orderedlist" type="i">
212 <li class="listitem">
215 <li class="listitem">
221 <li class="listitem">
226 <div class="section">
227 <div class="titlepage"><div><div><h4 class="title">
228 <a name="quickbook.syntax.block.lists.long_list_lines"></a><a name="quickbook.ref.long_list_lines"></a><a class="link" href="block.html#quickbook.syntax.block.lists.long_list_lines" title="Long List Lines">Long
230 </h4></div></div></div>
232 Long lines will be wrapped appropriately. Example:
234 <pre class="programlisting"># A short item.
235 # A very long item. A very long item. A very long item.
236 A very long item. A very long item. A very long item.
237 A very long item. A very long item. A very long item.
238 A very long item. A very long item. A very long item.
239 A very long item. A very long item. A very long item.
242 <div class="orderedlist"><ol class="orderedlist" type="1">
243 <li class="listitem">
246 <li class="listitem">
247 A very long item. A very long item. A very long item. A very long item.
248 A very long item. A very long item. A very long item. A very long item.
249 A very long item. A very long item. A very long item. A very long item.
250 A very long item. A very long item. A very long item.
252 <li class="listitem">
257 <div class="section">
258 <div class="titlepage"><div><div><h4 class="title">
259 <a name="quickbook.syntax.block.lists.unordered_lists"></a><a name="quickbook.ref.unordered_lists"></a><a class="link" href="block.html#quickbook.syntax.block.lists.unordered_lists" title="Unordered lists">Unordered
261 </h4></div></div></div>
262 <pre class="programlisting">* First
269 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
270 <li class="listitem">
273 <li class="listitem">
276 <li class="listitem">
281 <div class="section">
282 <div class="titlepage"><div><div><h4 class="title">
283 <a name="quickbook.syntax.block.lists.mixed_lists"></a><a name="quickbook.ref.mixed_lists"></a><a class="link" href="block.html#quickbook.syntax.block.lists.mixed_lists" title="Mixed lists">Mixed
285 </h4></div></div></div>
287 Mixed lists (ordered and unordered) are supported. Example:
289 <pre class="programlisting"># One
300 <div class="orderedlist"><ol class="orderedlist" type="1">
301 <li class="listitem">
304 <li class="listitem">
307 <li class="listitem">
309 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
310 <li class="listitem">
313 <li class="listitem">
316 <li class="listitem">
321 <li class="listitem">
328 <pre class="programlisting"># 1
344 <div class="orderedlist"><ol class="orderedlist" type="1">
345 <li class="listitem">
347 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
348 <li class="listitem">
350 <div class="orderedlist"><ol class="orderedlist" type="a">
351 <li class="listitem">
354 <li class="listitem">
359 <li class="listitem">
364 <li class="listitem">
366 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
367 <li class="listitem">
370 <li class="listitem">
372 <div class="orderedlist"><ol class="orderedlist" type="a">
373 <li class="listitem">
376 <li class="listitem">
378 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
379 <li class="listitem">
382 <li class="listitem">
393 <div class="section">
394 <div class="titlepage"><div><div><h4 class="title">
395 <a name="quickbook.syntax.block.lists.list_paragraphs"></a><a name="quickbook.ref.list_paragraphs"></a><a class="link" href="block.html#quickbook.syntax.block.lists.list_paragraphs" title="Paragraphs in lists">Paragraphs
397 </h4></div></div></div>
399 In quickbook 1.7 onwards, you can nest paragraphs in lists by separating
400 them with blank lines:
402 <pre class="programlisting">* List item 1, paragraph 1
404 List item 1, paragraph 2
406 * List item 2, paragraph 1
408 List item 2, paragraph 2
413 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
414 <li class="listitem">
416 List item 1, paragraph 1
419 List item 1, paragraph 2
422 <li class="listitem">
424 List item 2, paragraph 1
427 List item 2, paragraph 2
432 <div class="section">
433 <div class="titlepage"><div><div><h4 class="title">
434 <a name="quickbook.syntax.block.lists.list_tags"></a><a name="quickbook.ref.list_tags"></a><a class="link" href="block.html#quickbook.syntax.block.lists.list_tags" title="Explicit list tags">Explicit
436 </h4></div></div></div>
438 Sometimes the wiki-style list markup can be tricky to use, especially if
439 you wish to include more complicated markup with the list. So in quickbook
440 1.6, an alternative way to mark up lists introduced:
442 <pre class="programlisting">[ordered_list [item1][item2]]
447 <pre class="programlisting"># item1
453 <pre class="programlisting">[itemized_list [item1][item2]]
458 <pre class="programlisting">* item1
463 <div class="section">
464 <div class="titlepage"><div><div><h3 class="title">
465 <a name="quickbook.syntax.block.code"></a><a name="quickbook.ref.code"></a><a class="link" href="block.html#quickbook.syntax.block.code" title="Code">Code</a>
466 </h3></div></div></div>
468 Preformatted code starts with a space or a tab. The code will be syntax highlighted
469 according to the current <a class="link" href="phrase.html#quickbook.ref.source_mode">Source
472 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
474 <span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
475 <span class="special">{</span>
476 <span class="comment">// Sample code</span>
477 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Hello, World\n"</span><span class="special">;</span>
478 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
479 <span class="special">}</span>
481 <pre class="programlisting"><span class="keyword">import</span> <span class="identifier">cgi</span>
483 <span class="keyword">def</span> <span class="identifier">cookForHtml</span><span class="special">(</span><span class="identifier">text</span><span class="special">):</span>
484 <span class="string">'''"Cooks" the input text for HTML.'''</span>
486 <span class="keyword">return</span> <span class="identifier">cgi</span><span class="special">.</span><span class="identifier">escape</span><span class="special">(</span><span class="identifier">text</span><span class="special">)</span>
489 Macros that are already defined are expanded in source code. Example:
491 <pre class="programlisting">[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]]
492 [def __boost__ [@http://www.boost.org/libs/libraries.htm boost]]
494 using __boost__::__array__;
499 <pre class="programlisting">using <a href="http://www.boost.org/libs/libraries.htm" target="_top">boost</a>::<a href="http://www.boost.org/doc/html/array/reference.html" target="_top">array</a>;
502 In quickbook 1.7 and later, you can include <a class="link" href="block.html#quickbook.ref.callouts">callouts</a>
503 in code blocks, like so:
505 <pre class="programlisting">[!c++]
506 std::string foo_bar() /*< The /Mythical/ FooBar.
507 See [@http://en.wikipedia.org/wiki/Foobar Foobar for details] >*/
509 return "foo-bar"; /*< return 'em, foo-bar man! >*/
515 <pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">foo_bar</span><span class="special">()</span> <a class="co" name="quickbook.syntax.block.code.c0" href="block.html#quickbook.syntax.block.code.c1"><img src="../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a>
516 <span class="special">{</span>
517 <span class="keyword">return</span> <span class="string">"foo-bar"</span><span class="special">;</span> <a class="co" name="quickbook.syntax.block.code.c2" href="block.html#quickbook.syntax.block.code.c3"><img src="../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a>
518 <span class="special">}</span>
520 <div class="calloutlist"><table border="0" summary="Callout list">
522 <td width="5%" valign="top" align="left"><p><a name="quickbook.syntax.block.code.c1"></a><a href="#quickbook.syntax.block.code.c0"><img src="../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td>
523 <td valign="top" align="left"><p>
524 The <span class="emphasis"><em>Mythical</em></span> FooBar. See <a href="http://en.wikipedia.org/wiki/Foobar" target="_top">Foobar
529 <td width="5%" valign="top" align="left"><p><a name="quickbook.syntax.block.code.c3"></a><a href="#quickbook.syntax.block.code.c2"><img src="../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td>
530 <td valign="top" align="left"><p>
531 return 'em, foo-bar man!
536 <div class="section">
537 <div class="titlepage"><div><div><h3 class="title">
538 <a name="quickbook.syntax.block.escape_back"></a><a name="quickbook.ref.escape_back"></a><a class="link" href="block.html#quickbook.syntax.block.escape_back" title="Escaping Back To QuickBook">Escaping
539 Back To QuickBook</a>
540 </h3></div></div></div>
542 Inside code, code blocks and inline code, QuickBook does not allow any markup
543 to avoid conflicts with the target syntax (e.g. c++). In case you need to
544 switch back to QuickBook markup inside code, you can do so using a language
545 specific <span class="emphasis"><em>escape-back</em></span> delimiter. In C++ and Python, the
546 delimiter is the double tick (back-quote): "``" and "``".
549 <pre class="programlisting">void <a href="http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz" target="_top">foo</a>()
556 <pre class="programlisting">void <a href="http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz" target="_top">foo</a>()
561 When escaping from code to QuickBook, only phrase level markups are allowed.
562 Block level markups like lists, tables etc. are not allowed.
565 <div class="section">
566 <div class="titlepage"><div><div><h3 class="title">
567 <a name="quickbook.syntax.block.preformatted"></a><a name="quickbook.ref.preformatted"></a><a class="link" href="block.html#quickbook.syntax.block.preformatted" title="Preformatted">Preformatted</a>
568 </h3></div></div></div>
570 Sometimes, you don't want some preformatted text to be parsed as source code.
571 In such cases, use the <code class="literal">[pre ... ]</code> markup block.
573 <pre class="programlisting">[pre
575 Some *preformatted* text Some *preformatted* text
577 Some *preformatted* text Some *preformatted* text
579 Some *preformatted* text Some *preformatted* text
584 Spaces, tabs and newlines are rendered as-is. Unlike all quickbook block
585 level markup, pre (and Code) are the only ones that allow multiple newlines.
586 The markup above will generate:
588 <pre class="programlisting">
589 Some <span class="bold"><strong>preformatted</strong></span> text Some <span class="bold"><strong>preformatted</strong></span> text
591 Some <span class="bold"><strong>preformatted</strong></span> text Some <span class="bold"><strong>preformatted</strong></span> text
593 Some <span class="bold"><strong>preformatted</strong></span> text Some <span class="bold"><strong>preformatted</strong></span> text
597 Notice that unlike Code, phrase markup such as font style is still permitted
598 inside <code class="literal">pre</code> blocks.
601 <div class="section">
602 <div class="titlepage"><div><div><h3 class="title">
603 <a name="quickbook.syntax.block.blockquote"></a><a name="quickbook.ref.blockquote"></a><a class="link" href="block.html#quickbook.syntax.block.blockquote" title="Blockquote">Blockquote</a>
604 </h3></div></div></div>
605 <pre class="programlisting">[:sometext...]
607 <div class="blockquote"><blockquote class="blockquote"><p>
608 Indents the paragraph. This applies to one paragraph only.
609 </p></blockquote></div>
611 <div class="section">
612 <div class="titlepage"><div><div><h3 class="title">
613 <a name="quickbook.syntax.block.admonitions"></a><a name="quickbook.ref.admonitions"></a><a class="link" href="block.html#quickbook.syntax.block.admonitions" title="Admonitions">Admonitions</a>
614 </h3></div></div></div>
615 <pre class="programlisting">[note This is a note]
617 [important This is important]
618 [caution This is a caution]
619 [warning This is a warning]
622 generates <a href="http://www.docbook.org/" target="_top">DocBook</a> admonitions:
624 <div class="note"><table border="0" summary="Note">
626 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td>
627 <th align="left">Note</th>
629 <tr><td align="left" valign="top"><p>
633 <div class="tip"><table border="0" summary="Tip">
635 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../doc/src/images/tip.png"></td>
636 <th align="left">Tip</th>
638 <tr><td align="left" valign="top"><p>
642 <div class="important"><table border="0" summary="Important">
644 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../doc/src/images/important.png"></td>
645 <th align="left">Important</th>
647 <tr><td align="left" valign="top"><p>
651 <div class="caution"><table border="0" summary="Caution">
653 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../doc/src/images/caution.png"></td>
654 <th align="left">Caution</th>
656 <tr><td align="left" valign="top"><p>
660 <div class="warning"><table border="0" summary="Warning">
662 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../doc/src/images/warning.png"></td>
663 <th align="left">Warning</th>
665 <tr><td align="left" valign="top"><p>
670 These are the only admonitions supported by <a href="http://www.docbook.org/" target="_top">DocBook</a>.
671 So, for example <code class="literal">[information This is some information]</code>
672 is unlikely to produce the desired effect.
675 <div class="section">
676 <div class="titlepage"><div><div><h3 class="title">
677 <a name="quickbook.syntax.block.headings"></a><a name="quickbook.ref.headings"></a><a class="link" href="block.html#quickbook.syntax.block.headings" title="Headings">Headings</a>
678 </h3></div></div></div>
679 <pre class="programlisting">[h1 Heading 1]
687 <a name="quickbook.syntax.block.headings.h0"></a>
688 <span class="phrase"><a name="quickbook.syntax.block.headings.heading_1"></a></span><a class="link" href="block.html#quickbook.syntax.block.headings.heading_1">Heading
692 <a name="quickbook.syntax.block.headings.h1"></a>
693 <span class="phrase"><a name="quickbook.syntax.block.headings.heading_2"></a></span><a class="link" href="block.html#quickbook.syntax.block.headings.heading_2">Heading
697 <a name="quickbook.syntax.block.headings.h2"></a>
698 <span class="phrase"><a name="quickbook.syntax.block.headings.heading_3"></a></span><a class="link" href="block.html#quickbook.syntax.block.headings.heading_3">Heading
702 <a name="quickbook.syntax.block.headings.h3"></a>
703 <span class="phrase"><a name="quickbook.syntax.block.headings.heading_4"></a></span><a class="link" href="block.html#quickbook.syntax.block.headings.heading_4">Heading
707 <a name="quickbook.syntax.block.headings.h4"></a>
708 <span class="phrase"><a name="quickbook.syntax.block.headings.heading_5"></a></span><a class="link" href="block.html#quickbook.syntax.block.headings.heading_5">Heading
712 <a name="quickbook.syntax.block.headings.h5"></a>
713 <span class="phrase"><a name="quickbook.syntax.block.headings.heading_6"></a></span><a class="link" href="block.html#quickbook.syntax.block.headings.heading_6">Heading
717 You can specify an id for a heading:
719 <pre class="programlisting">[h1:heading_id A heading to link to]
722 To link to it, you'll need to include the enclosing section's id:
724 <pre class="programlisting">[link document_id.section_id.heading_id The link text]
727 Although you can preceed a heading by an <a class="link" href="phrase.html#quickbook.ref.anchors">anchor</a>
728 if you wish to use a location independent link.
731 If a heading doesn't have an id, one will be automatically generated with
732 a normalized name with <code class="literal">name="document_id.section_id.normalized_header_text"</code>
733 (i.e. valid characters are <code class="literal">a-z</code>, <code class="literal">A-Z</code>,
734 <code class="literal">0-9</code> and <code class="literal">_</code>. All non-valid characters
735 are converted to underscore and all upper-case are converted to lower-case.
736 For example: Heading 1 in section Section 2 will be normalized to <code class="literal">section_2.heading_1</code>).
739 <pre class="programlisting">[link document_id.section_id.normalized_header_text The link text]
742 to link to them. See <a class="link" href="phrase.html#quickbook.ref.anchor_links">Anchor links</a>
743 and <a class="link" href="structure.html#quickbook.ref.section">Section</a> for more info.
745 <div class="note"><table border="0" summary="Note">
747 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td>
748 <th align="left">Note</th>
750 <tr><td align="left" valign="top"><p>
751 Specifying heading ids is a quickbook 1.6 feature, earlier versions don't
756 <div class="section">
757 <div class="titlepage"><div><div><h3 class="title">
758 <a name="quickbook.syntax.block.generic_heading"></a><a name="quickbook.ref.generic_heading"></a><a class="link" href="block.html#quickbook.syntax.block.generic_heading" title="Generic Heading">Generic
760 </h3></div></div></div>
762 In cases when you don't want to care about the heading level (1 to 6), you
763 can use the <span class="emphasis"><em>Generic Heading</em></span>:
765 <pre class="programlisting">[heading Heading]
768 The <span class="emphasis"><em>Generic Heading</em></span> assumes the level, plus one, of
769 the innermost section where it is placed. For example, if it is placed in
770 the outermost section, then, it assumes <span class="emphasis"><em>h2</em></span>.
773 Headings are often used as an alternative to sections. It is used particularly
774 if you do not want to start a new section. In many cases, however, headings
775 in a particular section is just flat. Example:
777 <pre class="programlisting">[section A]
784 Here we use h2 assuming that section A is the outermost level. If it is placed
785 in an inner level, you'll have to use h3, h4, etc. depending on where the
786 section is. In general, it is the section level plus one. It is rather tedious,
787 however, to scan the section level everytime. If you rewrite the example
788 above as shown below, this will be automatic:
790 <pre class="programlisting">[section A]
797 They work well regardless where you place them. You can rearrange sections
798 at will without any extra work to ensure correct heading levels. In fact,
799 with <span class="emphasis"><em>section</em></span> and <span class="emphasis"><em>heading</em></span>, you have
800 all you need. <span class="emphasis"><em>h1</em></span>..<span class="emphasis"><em>h6</em></span> becomes redundant.
801 <span class="emphasis"><em>h1</em></span>..<span class="emphasis"><em>h6</em></span> might be deprecated in the
805 <div class="section">
806 <div class="titlepage"><div><div><h3 class="title">
807 <a name="quickbook.syntax.block.macros"></a><a name="quickbook.ref.macros"></a><a class="link" href="block.html#quickbook.syntax.block.macros" title="Macros">Macros</a>
808 </h3></div></div></div>
809 <pre class="programlisting">[def macro_identifier some text]
812 When a macro is defined, the identifier replaces the text anywhere in the
813 file, in paragraphs, in markups, etc. macro_identifier is a string of non-
814 white space characters except ']'. A macro may not follow an alphabetic character
815 or the underscore. The replacement text can be any phrase (even marked up).
818 <pre class="programlisting">[def sf_logo [$http://sourceforge.net/sflogo.php?group_id=28447&amp;type=1]]
822 Now everywhere the sf_logo is placed, the picture will be inlined.
825 <span class="inlinemediaobject"><img src="http://sourceforge.net/sflogo.php?group_id=28447&type=1"></span>
827 <div class="tip"><table border="0" summary="Tip">
829 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../doc/src/images/tip.png"></td>
830 <th align="left">Tip</th>
832 <tr><td align="left" valign="top"><p>
833 It's a good idea to use macro identifiers that are distinguishable. For
834 instance, in this document, macro identifiers have two leading and trailing
835 underscores (e.g. <code class="literal">__spirit__</code>). The reason is to avoid
836 unwanted macro replacement.
840 Links (URLS) and images are good candidates for macros. <span class="bold"><strong>1</strong></span>)
841 They tend to change a lot. It is a good idea to place all links and images
842 in one place near the top to make it easy to make changes. <span class="bold"><strong>2</strong></span>)
843 The syntax is not pretty. It's easier to read and write, e.g. <code class="literal">__spirit__</code>
844 than <code class="computeroutput">[@http://spirit.sourceforge.net Spirit]</code>.
849 <pre class="programlisting">[def :-) [$theme/smiley.png]]
850 [def __spirit__ [@http://spirit.sourceforge.net Spirit]]
853 (See <a class="link" href="phrase.html#quickbook.ref.images">Images</a> and <a class="link" href="phrase.html#quickbook.ref.links">Links</a>)
856 Invoking these macros:
858 <pre class="programlisting">Hi __spirit__ :-)
864 Hi <a href="http://spirit.sourceforge.net" target="_top">Spirit</a> <span class="inlinemediaobject"><img src="../../../src/images/smiley.png"></span>
867 <div class="section">
868 <div class="titlepage"><div><div><h3 class="title">
869 <a name="quickbook.syntax.block.predefined_macros"></a><a name="quickbook.ref.predefined_macros"></a><a class="link" href="block.html#quickbook.syntax.block.predefined_macros" title="Predefined Macros">Predefined
871 </h3></div></div></div>
873 Quickbook has some predefined macros that you can already use.
876 <a name="quickbook.syntax.block.predefined_macros.predefined_macros"></a><p class="title"><b>Table 50.3. Predefined Macros</b></p>
877 <div class="table-contents"><table class="table" summary="Predefined Macros">
904 <code class="literal">__DATE__</code>
921 <code class="literal">__TIME__</code>
938 <code class="literal">__FILENAME__</code>
943 Quickbook source filename
955 <br class="table-break">
957 <div class="section">
958 <div class="titlepage"><div><div><h3 class="title">
959 <a name="quickbook.syntax.block.templates"></a><a name="quickbook.ref.templates"></a><a class="link" href="block.html#quickbook.syntax.block.templates" title="Templates">Templates</a>
960 </h3></div></div></div>
962 Templates provide a more versatile text substitution mechanism. Templates
963 come in handy when you need to create parameterizable, multi-line, boilerplate
964 text that you specify once and expand many times. Templates accept one or
965 more arguments. These arguments act like place-holders for text replacement.
966 Unlike simple macros, which are limited to phrase level markup, templates
967 can contain block level markup (e.g. paragraphs, code blocks and tables).
972 <pre class="programlisting">[template person[name age what]
974 Hi, my name is [name]. I am [age] years old. I am a [what].
978 <a name="quickbook.ref.template_identifier"></a><h4>
979 <a name="quickbook.syntax.block.templates.h0"></a>
980 <span class="phrase"><a name="quickbook.syntax.block.templates.template_identifier"></a></span><a class="link" href="block.html#quickbook.syntax.block.templates.template_identifier">Template Identifier</a>
983 Template identifiers can either consist of:
985 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
986 <li class="listitem">
987 An initial alphabetic character or the underscore, followed by zero or
988 more alphanumeric characters or the underscore. This is similar to your
989 typical C/C++ identifier.
991 <li class="listitem">
992 A single character punctuation (a non-alphanumeric printable character)
996 <a name="quickbook.syntax.block.templates.h1"></a>
997 <span class="phrase"><a name="quickbook.syntax.block.templates.formal_template_arguments"></a></span><a class="link" href="block.html#quickbook.syntax.block.templates.formal_template_arguments">Formal
998 Template Arguments</a>
1001 Template formal arguments are identifiers consisting of an initial alphabetic
1002 character or the underscore, followed by zero or more alphanumeric characters
1003 or the underscore. This is similar to your typical C/C++ identifier.
1006 A template formal argument temporarily hides a template of the same name
1007 at the point where the <a class="link" href="phrase.html#quickbook.ref.template_expansion">template
1008 is expanded</a>. Note that the body of the <code class="literal">person</code> template
1009 above refers to <code class="literal">name</code> <code class="literal">age</code> and <code class="literal">what</code>
1010 as <code class="literal">[name]</code> <code class="literal">[age]</code> and <code class="literal">[what]</code>.
1011 <code class="literal">name</code> <code class="literal">age</code> and <code class="literal">what</code>
1012 are actually templates that exist in the duration of the template call.
1015 <a name="quickbook.syntax.block.templates.h2"></a>
1016 <span class="phrase"><a name="quickbook.syntax.block.templates.template_body"></a></span><a class="link" href="block.html#quickbook.syntax.block.templates.template_body">Template
1020 The template body can be just about any QuickBook block or phrase. There
1021 are actually two forms. Templates may be phrase or block level. Phrase templates
1024 <pre class="programlisting">[template sample[arg1 arg2...argN] replacement text... ]
1027 Block templates are of the form:
1029 <pre class="programlisting">[template sample[arg1 arg2...argN]
1034 The basic rule is as follows: if a newline immediately follows the argument
1035 list, then it is a block template, otherwise, it is a phrase template. Phrase
1036 templates are typically expanded as part of phrases. Like macros, block level
1037 elements are not allowed in phrase templates.
1040 <a name="quickbook.syntax.block.templates.h3"></a>
1041 <span class="phrase"><a name="quickbook.syntax.block.templates.template_expansion"></a></span><a class="link" href="block.html#quickbook.syntax.block.templates.template_expansion">Template
1045 You expand a template this way:
1047 <pre class="programlisting">[template_identifier arg1..arg2..arg3]
1050 At template expansion, you supply the actual arguments. The template will
1051 be expanded with your supplied arguments. Example:
1053 <pre class="programlisting">[person James Bond..39..Spy]
1054 [person Santa Clause..87..Big Red Fatso]
1057 Which will expand to:
1060 Hi, my name is James Bond. I am 39 years old. I am a Spy.
1063 Hi, my name is Santa Clause. I am 87 years old. I am a Big Red Fatso.
1065 <div class="caution"><table border="0" summary="Caution">
1067 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../doc/src/images/caution.png"></td>
1068 <th align="left">Caution</th>
1070 <tr><td align="left" valign="top"><p>
1071 A word of caution: Templates are recursive. A template can call another
1072 template or even itself, directly or indirectly. There are no control structures
1073 in QuickBook (yet) so this will always mean infinite recursion. QuickBook
1074 can detect this situation and report an error if recursion exceeds a certain
1079 Each actual argument can be a word, a text fragment or just about any <a class="link" href="phrase.html" title="Phrase Level Elements">QuickBook phrase</a>. Arguments are
1080 separated by the double dot <code class="literal">".."</code> and terminated
1081 by the close parenthesis.
1084 Note that templates and template parameters can't be expanded everywhere,
1085 only where text is interpreted as a phrase. So they can't be expanded in
1086 places such as table titles and link's urls. If you want to use a template
1087 to generate a link based of the template parameter, you can't use a normal
1088 link and will need to use escaped docbook instead. Example:
1090 <pre class="programlisting">[template boost_ticket[key] '''<ulink url="https://svn.boost.org/trac/boost/ticket/'''[key]'''">#'''[key]'''</ulink>''']
1098 <a href="https://svn.boost.org/trac/boost/ticket/2035" target="_top">#2035</a>
1100 <div class="caution"><table border="0" summary="Caution">
1102 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../doc/src/images/caution.png"></td>
1103 <th align="left">Caution</th>
1105 <tr><td align="left" valign="top"><p>
1106 Since quickbook doesn't understand the context where the parameter is being
1107 used, it will interpret it as quickbook markup, so when writing a template
1108 like this, you'll need to escape any meaningful punctuation.
1112 <a name="quickbook.syntax.block.templates.h4"></a>
1113 <span class="phrase"><a name="quickbook.syntax.block.templates.nullary_templates"></a></span><a class="link" href="block.html#quickbook.syntax.block.templates.nullary_templates">Nullary
1117 Nullary templates look and act like simple macros. Example:
1119 <pre class="programlisting">[template alpha[]&apos;&apos;&apos;&amp;#945;&apos;&apos;&apos;]
1120 [template beta[]&apos;&apos;&apos;&amp;#946;&apos;&apos;&apos;]
1125 <pre class="programlisting">Some squigles...[*[alpha][beta]]</pre>
1130 Some squiggles...<span class="bold"><strong>αβ</strong></span>
1133 The difference with macros are
1135 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1136 <li class="listitem">
1137 The explicit <a class="link" href="phrase.html#quickbook.ref.template_expansion">template
1138 expansion syntax</a>. This is an advantage because, now, we don't
1139 have to use obscure naming conventions like double underscores (e.g.
1140 __alpha__) to avoid unwanted macro replacement.
1142 <li class="listitem">
1143 The template is expanded at the point where it is invoked. A macro is
1144 expanded immediately at its point of declaration. This is subtle and
1145 can cause a slight difference in behavior especially if you refer to
1146 other macros and templates in the body.
1150 The empty brackets after the template identifier (<code class="literal">alpha[]</code>)
1151 indicates no arguments. If the template body does not look like a template
1152 argument list, we can elide the empty brackets. Example:
1154 <pre class="programlisting">[template aristotle_quote Aristotle: [*['Education is the best provision
1155 for the journey to old age.]]]
1160 <pre class="programlisting">Here's a quote from [aristotle_quote].
1166 Here's a quote from Aristotle: <span class="bold"><strong><span class="emphasis"><em>Education
1167 is the best provision for the journey to old age.</em></span></strong></span>.
1170 The disadvantage is that you can't avoid the space between the template identifier,
1171 <code class="computeroutput">aristotle_quote</code>, and the template body "Aristotle...".
1172 This space will be part of the template body. If that space is unwanted,
1173 use empty brackets or use the space escape: "<code class="computeroutput">\ </code>".
1176 <pre class="programlisting">[template tag\ _tag]
1181 <pre class="programlisting">`struct` x[tag];
1187 <code class="computeroutput">struct</code> x_tag;
1190 You have a couple of ways to do it. I personally prefer the explicit empty
1194 <a name="quickbook.syntax.block.templates.h5"></a>
1195 <span class="phrase"><a name="quickbook.syntax.block.templates.simple_arguments"></a></span><a class="link" href="block.html#quickbook.syntax.block.templates.simple_arguments">Simple
1199 As mentioned, arguments are separated by the double dot <code class="literal">".."</code>.
1200 Alternatively, if the double dot isn't used and more than one argument is
1201 expected, QuickBook uses whitespace to separate the arguments, following
1204 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1205 <li class="listitem">
1206 Break the last argument into two, at the first space found (<code class="literal">'',
1207 '\n', \t' or '\r'</code>).
1209 <li class="listitem">
1210 Repeat until there are enough arguments or if there are no more spaces
1211 found (in which case, an error is reported).
1217 <pre class="programlisting">[template simple[a b c d] [a][b][c][d]]
1227 "w x y z" is initially treated as a single argument because we
1228 didn't supply any <code class="literal">".."</code> separators. However,
1229 since <code class="literal">simple</code> expects 4 arguments, "w x y z"
1230 is broken down iteratively (applying the logic above) until we have "w",
1234 QuickBook only tries to get the arguments it needs. For example:
1236 <pre class="programlisting">[simple w x y z trail]
1245 The arguments being: "w", "x", "y" and "z
1248 <div class="caution"><table border="0" summary="Caution">
1250 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../doc/src/images/caution.png"></td>
1251 <th align="left">Caution</th>
1253 <tr><td align="left" valign="top"><p>
1254 The behavior described here is for QuickBook 1.5. In older versions you
1255 could use both the double dot and whitespace as separators in the same
1256 template call. If your document is marked up as an older version, it will
1257 use the old behavior, which is described in the <a href="http://www.boost.org/doc/libs/1_40_0/doc/html/quickbook/syntax.html#quickbook.syntax.block.templates.simple_arguments" target="_top">QuickBook
1258 1.4 documentation</a>.
1262 <a name="quickbook.syntax.block.templates.h6"></a>
1263 <span class="phrase"><a name="quickbook.syntax.block.templates.punctuation_templates"></a></span><a class="link" href="block.html#quickbook.syntax.block.templates.punctuation_templates">Punctuation
1267 With templates, one of our objectives is to allow us to rewrite QuickBook
1268 in QuickBook (as a qbk library). For that to happen, we need to accommodate
1269 single character punctuation templates which are fairly common in QuickBook.
1270 You might have noticed that single character punctuations are allowed as
1271 <a class="link" href="block.html#quickbook.ref.template_identifier">template identifiers</a>.
1274 <pre class="programlisting">[template ![bar] <hey>[bar]</hey>]
1277 Now, expanding this:
1279 <pre class="programlisting">[!baz]
1284 <pre class="programlisting"><hey>baz</hey>
1287 <div class="section">
1288 <div class="titlepage"><div><div><h3 class="title">
1289 <a name="quickbook.syntax.block.blurbs"></a><a name="quickbook.ref.blurbs"></a><a class="link" href="block.html#quickbook.syntax.block.blurbs" title="Blurbs">Blurbs</a>
1290 </h3></div></div></div>
1291 <pre class="programlisting">[blurb :-) [*An eye catching advertisement or note...]
1293 <a href="http://spirit.sourceforge.net" target="_top">Spirit</a> is an object-oriented recursive-descent parser generator framework
1294 implemented using template meta-programming techniques. Expression templates
1295 allow us to approximate the syntax of Extended Backus-Normal Form (EBNF)
1303 <div class="titlepage"><div><div><p class="title"><b></b></p></div></div></div>
1305 <span class="inlinemediaobject"><img src="../../../src/images/smiley.png"></span>
1306 <span class="bold"><strong>An eye catching advertisement or note...</strong></span>
1309 <a href="http://spirit.sourceforge.net" target="_top">Spirit</a> is an object-oriented
1310 recursive-descent parser generator framework implemented using template meta-programming
1311 techniques. Expression templates allow us to approximate the syntax of Extended
1312 Backus-Normal Form (EBNF) completely in C++.
1315 <div class="note"><table border="0" summary="Note">
1317 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td>
1318 <th align="left">Note</th>
1320 <tr><td align="left" valign="top"><p>
1321 Prefer <a class="link" href="block.html#quickbook.ref.admonitions">admonitions</a> wherever
1326 <div class="section">
1327 <div class="titlepage"><div><div><h3 class="title">
1328 <a name="quickbook.syntax.block.tables"></a><a name="quickbook.ref.tables"></a><a class="link" href="block.html#quickbook.syntax.block.tables" title="Tables">Tables</a>
1329 </h3></div></div></div>
1330 <pre class="programlisting">[table:id A Simple Table
1331 [[Heading 1] [Heading 2] [Heading 3]]
1332 [[R0-C0] [R0-C1] [R0-C2]]
1333 [[R1-C0] [R1-C1] [R1-C2]]
1334 [[R2-C0] [R2-C1] [R2-C2]]
1341 <a name="quickbook.syntax.block.tables.id"></a><p class="title"><b>Table 50.4. A Simple Table</b></p>
1342 <div class="table-contents"><table class="table" summary="A Simple Table">
1420 <br class="table-break"><p>
1421 The table title is optional. The first row of the table is automatically
1422 treated as the table header; that is, it is wrapped in <code class="literal"><thead>...</thead></code>
1423 XML tags. Note that unlike the original QuickDoc, the columns are nested
1427 Giving tables an id is a new feature for quickbook 1.5 onwards. As with sections,
1428 the id is optional. If the table has a title but no id, an id will be generated
1429 from the title. The table above can be linked to using:
1431 <pre class="programlisting">[link quickbook.syntax.block.tables.id link to table]
1434 which will generate:
1437 <a class="link" href="block.html#quickbook.syntax.block.tables.id" title="Table 50.4. A Simple Table">link to table</a>
1440 The syntax is free-format and allows big cells to be formatted nicely. Example:
1442 <pre class="programlisting">[table Table with fat cells
1443 [[Heading 1] [Heading 2]]
1445 [Row 0, Col 0: a small cell]
1447 Row 0, Col 1: a big fat cell with paragraphs
1449 Boost provides free peer-reviewed portable C++ source libraries.
1451 We emphasize libraries that work well with the C++ Standard Library.
1452 Boost libraries are intended to be widely useful, and usable across
1453 a broad spectrum of applications. The Boost license encourages both
1454 commercial and non-commercial use.
1458 [Row 1, Col 0: a small cell]
1459 [Row 1, Col 1: a small cell]
1467 <a name="quickbook.syntax.block.tables.table_with_fat_cells"></a><p class="title"><b>Table 50.5. Table with fat cells</b></p>
1468 <div class="table-contents"><table class="table" summary="Table with fat cells">
1489 Row 0, Col 0: a small cell
1494 Row 0, Col 1: a big fat cell with paragraphs
1497 Boost provides free peer-reviewed portable C++ source libraries.
1498 We emphasize libraries that work well with the C++ Standard Library.
1499 Boost libraries are intended to be widely useful, and usable across
1500 a broad spectrum of applications. The Boost license encourages
1501 both commercial and non-commercial use.
1508 Row 1, Col 0: a small cell
1513 Row 1, Col 1: a small cell
1520 <br class="table-break"><p>
1521 Here's how to have preformatted blocks of code in a table cell:
1523 <pre class="programlisting">[table Table with code
1528 #include <iostream>
1532 std::cout << "Hello, World!" << std::endl;
1540 <a name="quickbook.syntax.block.tables.table_with_code"></a><p class="title"><b>Table 50.6. Table with code</b></p>
1541 <div class="table-contents"><table class="table" summary="Table with code">
1565 <pre class="programlisting">#include <iostream>
1569 std::cout << "Hello, World!" << std::endl;
1577 <br class="table-break">
1579 <div class="section">
1580 <div class="titlepage"><div><div><h3 class="title">
1581 <a name="quickbook.syntax.block.variable_lists"></a><a name="quickbook.ref.variable_lists"></a><a class="link" href="block.html#quickbook.syntax.block.variable_lists" title="Variable Lists">Variable
1583 </h3></div></div></div>
1584 <pre class="programlisting">[variablelist A Variable List
1585 [[term 1] [The definition of term 1]]
1586 [[term 2] [The definition of term 2]]
1588 The definition of term 3.
1590 Definitions may contain paragraphs.
1597 <div class="variablelist">
1598 <p class="title"><b>A Variable List</b></p>
1599 <dl class="variablelist">
1600 <dt><span class="term">term 1</span></dt>
1602 The definition of term 1
1604 <dt><span class="term">term 2</span></dt>
1606 The definition of term 2
1608 <dt><span class="term">term 3</span></dt>
1611 The definition of term 3.
1614 Definitions may contain paragraphs.
1620 The rules for variable lists are the same as for tables, except that only
1621 2 "columns" are allowed. The first column contains the terms, and
1622 the second column contains the definitions. Those familiar with HTML will
1623 recognize this as a "definition list".
1626 <div class="section">
1627 <div class="titlepage"><div><div><h3 class="title">
1628 <a name="quickbook.syntax.block.include"></a><a name="quickbook.ref.include"></a><a class="link" href="block.html#quickbook.syntax.block.include" title="Include">Include</a>
1629 </h3></div></div></div>
1631 You can include one QuickBook file from another. The syntax is simply:
1633 <pre class="programlisting">[include someother.qbk]
1636 In quickbook 1.6 and later, if the included file has a <a class="link" href="structure.html#quickbook.ref.docinfo">docinfo
1637 block</a> then it will create a nested document. This will be processed
1638 as a standalone document, although any macros or templates from the enclosing
1639 file will still be defined.
1642 Otherwise the included file will be processed as if it had been cut and pasted
1643 into the current document, with the following exceptions:
1645 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1646 <li class="listitem">
1647 The __FILENAME__ predefined macro will reflect the name of the file currently being
1650 <li class="listitem">
1651 Any macros or templates defined in the included file are scoped to that
1652 file, i.e. they are not added to the enclosing file.
1655 <div class="note"><table border="0" summary="Note">
1657 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td>
1658 <th align="left">Note</th>
1660 <tr><td align="left" valign="top"><p>
1661 In quickbook 1.5 and earlier templates weren't scoped in included files.
1662 If you want to use templates or macros from a file in quickbook 1.6, use
1663 <a class="link" href="block.html#quickbook.ref.import">import</a> instead.
1667 The <code class="literal">[include]</code> directive lets you specify a document id
1668 to use for the included file. You can specify the id like this:
1670 <pre class="programlisting">[include:someid someother.qbk]
1673 All auto-generated anchors will use the document id as a unique prefix. So
1674 for instance, if there is a top section in someother.qbk named "Intro",
1675 the named anchor for that section will be "someid.intro", and you
1676 can link to it with <code class="literal">[link someid.intro The Intro]</code>.
1679 If the included file has a docinfo block, an id specified in an <code class="literal">[include]</code>
1680 directive will overwrite it.
1683 You can also include C, C++ and python source files. This will include any
1684 quickbook blocks in the file that aren't inside of named code snippets. See
1685 the <a class="link" href="block.html#quickbook.ref.import">Import section</a> for syntax
1686 details. For example, say you included this file:
1688 <pre class="programlisting">/**
1689 * Hello world example
1692 // In this comment, the backtick indicates that this is a
1693 // quickbook source block that will be included.
1696 First include the appropriate header: [hello_includes]
1697 Then write your main function: [hello_main]
1700 // This defines a code snippet, the syntax is
1701 // described in the import section. It's available
1702 // in the whole of this source file, not just after
1706 #include <iostream>
1711 std::cout << "Hello, trivial example" << std::endl;
1718 <pre class="programlisting">First include the appropriate header:
1720 #include <iostream>
1722 Then write your main function:
1725 std::cout << "Hello, trivial example" << std::endl;
1729 <div class="section">
1730 <div class="titlepage"><div><div><h3 class="title">
1731 <a name="quickbook.syntax.block.import"></a><a name="quickbook.ref.import"></a><a class="link" href="block.html#quickbook.syntax.block.import" title="Import">Import</a>
1732 </h3></div></div></div>
1734 In quickbook 1.6 and later if you wish to use a template, macro or code snippet
1735 from a file, you need to import it. This will not include any of the content
1736 from that file, but will pull templates, macros and code snippets into the
1737 current file's scope.
1740 With quickbook files, this allows you to create template and macro libraries.
1741 For python (indicated by the <code class="computeroutput">.py</code> extension), C or C++ files
1742 this allows you to include code snippets from source files, so that your
1743 code examples can be kept up to date and fully tested.
1746 <a name="quickbook.syntax.block.import.h0"></a>
1747 <span class="phrase"><a name="quickbook.syntax.block.import.example"></a></span><a class="link" href="block.html#quickbook.syntax.block.import.example">Example</a>
1750 You can effortlessly import code snippets from source code into your QuickBook.
1751 The following illustrates how this is done:
1753 <pre class="programlisting">[import ../test/stub.cpp]
1760 <pre class="programlisting">[import ../test/stub.cpp]
1763 collects specially marked-up code snippets from <a href="../../../../tools/quickbook/test/stub.cpp" target="_top">stub.cpp</a>
1764 and places them in your QuickBook file as virtual templates. Each of the
1765 specially marked-up code snippets has a name (e.g. <code class="computeroutput">foo</code> and
1766 <code class="computeroutput">bar</code> in the example above). This shall be the template identifier
1767 for that particular code snippet. The second and third line above does the
1768 actual template expansion:
1770 <pre class="programlisting">[foo]
1777 This is the <span class="bold"><strong><span class="emphasis"><em>foo</em></span></strong></span> function.
1780 This description can have paragraphs...
1782 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1783 <li class="listitem">
1786 <li class="listitem">
1791 And any quickbook block markup.
1793 <pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">foo</span><span class="special">()</span>
1794 <span class="special">{</span>
1795 <span class="comment">// return 'em, foo man!</span>
1796 <span class="keyword">return</span> <span class="string">"foo"</span><span class="special">;</span>
1797 <span class="special">}</span>
1800 This is the <span class="bold"><strong><span class="emphasis"><em>bar</em></span></strong></span> function
1802 <pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">bar</span><span class="special">()</span>
1803 <span class="special">{</span>
1804 <span class="comment">// return 'em, bar man!</span>
1805 <span class="keyword">return</span> <span class="string">"bar"</span><span class="special">;</span>
1806 <span class="special">}</span>
1809 Some trailing text here
1812 <a name="quickbook.syntax.block.import.h1"></a>
1813 <span class="phrase"><a name="quickbook.syntax.block.import.code_snippet_markup"></a></span><a class="link" href="block.html#quickbook.syntax.block.import.code_snippet_markup">Code
1817 Note how the code snippets in <a href="../../../../tools/quickbook/test/stub.cpp" target="_top">stub.cpp</a>
1818 get marked up. We use distinguishable comments following the form:
1820 <pre class="programlisting">//[id
1825 The first comment line above initiates a named code-snippet. This prefix
1826 will not be visible in quickbook. The entire code-snippet in between <code class="computeroutput">//[id</code>
1827 and <code class="computeroutput">//]</code> will be inserted as a template in quickbook with name
1828 <span class="emphasis"><em><span class="emphasis"><em>id</em></span></em></span>. The comment <code class="computeroutput">//]</code>
1829 ends a code-snippet This too will not be visible in quickbook.
1831 <a name="quickbook.ref.callouts"></a><h4>
1832 <a name="quickbook.syntax.block.import.h2"></a>
1833 <span class="phrase"><a name="quickbook.syntax.block.import.special_comments"></a></span><a class="link" href="block.html#quickbook.syntax.block.import.special_comments">Special
1837 Special comments of the form:
1839 <pre class="programlisting">//` some [*quickbook] markup here
1844 <pre class="programlisting">/*` some [*quickbook] markup here */
1847 will be parsed by QuickBook. This can contain quickbook <span class="emphasis"><em>blocks</em></span>
1848 (e.g. sections, paragraphs, tables, etc). In the first case, the initial
1849 slash-slash, tick and white-space shall be ignored. In the second, the initial
1850 slash-star-tick and the final star-slash shall be ignored.
1853 Special comments of the form:
1855 <pre class="programlisting">/*<- this C++ comment will be ignored ->*/
1860 <pre class="programlisting">/*<-*/ "this c++ code will be ignored" /*->*/
1865 <pre class="programlisting">//<-
1871 can be used to inhibit code from passing through to quickbook. All text between
1872 the delimeters will simply be ignored.
1875 Comments of this form:
1877 <pre class="programlisting">//=int main() {}
1882 <pre class="programlisting">/*=foo()*/
1885 will be displayed as code that isn't in comments. This allows you to include
1886 some code in the snippet but not actually use it when compiling your example.
1889 <a name="quickbook.syntax.block.import.h3"></a>
1890 <span class="phrase"><a name="quickbook.syntax.block.import.callouts"></a></span><a class="link" href="block.html#quickbook.syntax.block.import.callouts">Callouts</a>
1893 Special comments of the form:
1895 <pre class="programlisting">/*< some [*quickbook] markup here >*/
1898 will be regarded as callouts. These will be collected, numbered and rendered
1899 as a "callout bug" (a small icon with a number). After the whole
1900 snippet is parsed, the callout list is generated. See <a href="http://www.docbook.org/tdg/en/html/callout.html" target="_top">Callouts</a>
1901 for details. Example:
1903 <pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">foo_bar</span><span class="special">()</span> <a class="co" name="quickbook.syntax.block.import.c0" href="block.html#quickbook.syntax.block.import.c1"><img src="../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a>
1904 <span class="special">{</span>
1905 <span class="keyword">return</span> <span class="string">"foo-bar"</span><span class="special">;</span> <a class="co" name="quickbook.syntax.block.import.c2" href="block.html#quickbook.syntax.block.import.c3"><img src="../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a>
1906 <span class="special">}</span>
1908 <div class="calloutlist"><table border="0" summary="Callout list">
1910 <td width="5%" valign="top" align="left"><p><a name="quickbook.syntax.block.import.c1"></a><a href="#quickbook.syntax.block.import.c0"><img src="../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td>
1911 <td valign="top" align="left"><p>
1912 The <span class="emphasis"><em>Mythical</em></span> FooBar. See <a href="http://en.wikipedia.org/wiki/Foobar" target="_top">Foobar
1917 <td width="5%" valign="top" align="left"><p><a name="quickbook.syntax.block.import.c3"></a><a href="#quickbook.syntax.block.import.c2"><img src="../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td>
1918 <td valign="top" align="left"><p>
1919 return 'em, foo-bar man!
1924 This is the actual code:
1926 <pre class="programlisting">//[ foo_bar
1927 std::string foo_bar() /*< The /Mythical/ FooBar.
1928 See [@http://en.wikipedia.org/wiki/Foobar Foobar for details] >*/
1930 return "foo-bar"; /*< return 'em, foo-bar man! >*/
1935 The callouts bugs are placed exactly where the special callout comment is
1936 situated. It can be anywhere in the code. The bugs can be rather obtrusive,
1937 however. They get in the way of the clarity of the code. Another special
1938 callout comment style is available:
1940 <pre class="programlisting">/*<< some [*quickbook] markup here >>*/
1943 This is the line-oriented version of the callout. With this, the "bug"
1944 is placed at the very left of the code block, away from the actual code.
1945 By placing it at the far left, the code is rendered un-obscured. Example:
1947 <pre class="programlisting"><span class="keyword">class</span> <span class="identifier">x</span>
1948 <span class="special">{</span>
1949 <span class="keyword">public</span><span class="special">:</span>
1951 <a class="co" name="quickbook.syntax.block.import.c4" href="block.html#quickbook.syntax.block.import.c5"><img src="../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a><span class="identifier">x</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">n</span><span class="special">(</span><span class="number">0</span><span class="special">)</span>
1952 <span class="special">{</span>
1953 <span class="special">}</span>
1955 <a class="co" name="quickbook.syntax.block.import.c6" href="block.html#quickbook.syntax.block.import.c7"><img src="../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a><span class="special">~</span><span class="identifier">x</span><span class="special">()</span>
1956 <span class="special">{</span>
1957 <span class="special">}</span>
1959 <a class="co" name="quickbook.syntax.block.import.c8" href="block.html#quickbook.syntax.block.import.c9"><img src="../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a><span class="keyword">int</span> <span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span>
1960 <span class="special">{</span>
1961 <span class="keyword">return</span> <span class="identifier">n</span><span class="special">;</span>
1962 <span class="special">}</span>
1964 <a class="co" name="quickbook.syntax.block.import.c10" href="block.html#quickbook.syntax.block.import.c11"><img src="../../../../doc/src/images/callouts/4.png" alt="4" border="0"></a><span class="keyword">void</span> <span class="identifier">set</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">n_</span><span class="special">)</span>
1965 <span class="special">{</span>
1966 <span class="identifier">n</span> <span class="special">=</span> <span class="identifier">n_</span><span class="special">;</span>
1967 <span class="special">}</span>
1968 <span class="special">};</span>
1970 <div class="calloutlist"><table border="0" summary="Callout list">
1972 <td width="5%" valign="top" align="left"><p><a name="quickbook.syntax.block.import.c5"></a><a href="#quickbook.syntax.block.import.c4"><img src="../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td>
1973 <td valign="top" align="left"><p>
1978 <td width="5%" valign="top" align="left"><p><a name="quickbook.syntax.block.import.c7"></a><a href="#quickbook.syntax.block.import.c6"><img src="../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td>
1979 <td valign="top" align="left"><p>
1984 <td width="5%" valign="top" align="left"><p><a name="quickbook.syntax.block.import.c9"></a><a href="#quickbook.syntax.block.import.c8"><img src="../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> </p></td>
1985 <td valign="top" align="left"><p>
1986 Get the <code class="computeroutput">n</code> member variable
1990 <td width="5%" valign="top" align="left"><p><a name="quickbook.syntax.block.import.c11"></a><a href="#quickbook.syntax.block.import.c10"><img src="../../../../doc/src/images/callouts/4.png" alt="4" border="0"></a> </p></td>
1991 <td valign="top" align="left"><p>
1992 Set the <code class="computeroutput">n</code> member variable
1997 See the actual code here: <a href="../../../../tools/quickbook/test/stub.cpp" target="_top">tools/quickbook/test/stub.cpp</a>
2000 <div class="section">
2001 <div class="titlepage"><div><div><h3 class="title">
2002 <a name="quickbook.syntax.block.block"></a><a name="quickbook.ref.block"></a><a class="link" href="block.html#quickbook.syntax.block.block" title="Plain blocks">Plain
2004 </h3></div></div></div>
2006 <code class="computeroutput">block</code> is a plain block element, that doesn't wrap its contents
2007 in any docbook or boostbook tags. This can be useful when using escaped docbook
2008 block tags, such as:
2010 <pre class="programlisting">[template chapter[title]
2011 [block'''<chapter><title>'''[title]'''</title>''']
2014 [template chapterend
2015 [block'''</chapter>''']
2018 [chapter An example chapter]
2025 Without the <code class="computeroutput">block</code> element, the <code class="computeroutput">chapter</code> and <code class="computeroutput">chapterend</code>
2026 templates would be wrapped in paragraph tags.
2028 <div class="note"><table border="0" summary="Note">
2030 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td>
2031 <th align="left">Note</th>
2033 <tr><td align="left" valign="top"><p>
2034 In this example, the template body has to start with a newline so that
2035 the template will be interpreted in block mode.
2040 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
2041 <td align="left"></td>
2042 <td align="right"><div class="copyright-footer">Copyright © 2002, 2004, 2006 Joel de Guzman,
2043 Eric Niebler<br>Copyright © 2010-2017 Daniel James<p>
2044 Distributed under the Boost Software License, Version 1.0. (See accompanying
2045 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
2050 <div class="spirit-nav">
2051 <a accesskey="p" href="phrase.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../quickbook.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../versions.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>