diff --git a/src/post_process.cpp b/src/post_process.cpp index 3c77351..dd38db0 100644 --- a/src/post_process.cpp +++ b/src/post_process.cpp @@ -32,9 +32,14 @@ namespace quickbook column = current_indent; } - void break_line() + void trim_spaces() { out.erase(out.find_last_not_of(' ')+1); // trim trailing spaces + } + + void break_line() + { + trim_spaces(); out += '\n'; indent(); } @@ -338,7 +343,9 @@ namespace quickbook void do_code(iter_type f, iter_type l) const { - state.out += '\n'; + state.printer_.trim_spaces(); + if (state.out[state.out.size() - 1] != '\n') + state.out += '\n'; // print the string taking care of line // ending CR/LF platform issues for (iter_type i = f; i != l; ++i) diff --git a/test/callouts.gold b/test/callouts.gold index a6ca2b1..51bef92 100644 --- a/test/callouts.gold +++ b/test/callouts.gold @@ -10,7 +10,6 @@ Now we can define a function that simulates an ordinary six-sided die. - int roll_die() { boost::uniform_int<> dist(1, 6); } @@ -28,7 +27,6 @@ Example 2: - int roll_die() { boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } @@ -48,7 +46,6 @@ Example 3: - int roll_die() { boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } @@ -68,7 +65,6 @@ Example 3 (again!): - int roll_die() { boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } @@ -88,7 +84,6 @@ Example 4: - int roll_die() { boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); boost::uniform_int<> dist(1, 6); @@ -114,7 +109,6 @@ - boost::uniform_int<> dist(1, 6); @@ -139,7 +133,6 @@ Now we can define a function that simulates an ordinary six-sided die. - int roll_die() { boost::uniform_int<> dist(1, 6); } @@ -157,7 +150,6 @@ Example 2: - int roll_die() { boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } @@ -177,7 +169,6 @@ Example 3: - int roll_die() { boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } @@ -197,7 +188,6 @@ Example 3 (again!): - int roll_die() { boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } @@ -217,7 +207,6 @@ Example 4: - int roll_die() { boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); boost::uniform_int<> dist(1, 6); @@ -243,7 +232,6 @@ - boost::uniform_int<> dist(1, 6); diff --git a/test/code-block-1.gold b/test/code-block-1.gold index 032eafe..7ee1588 100644 --- a/test/code-block-1.gold +++ b/test/code-block-1.gold @@ -8,7 +8,6 @@ A code block with proper indentation ;-) - #include <iostream> int main() diff --git a/test/code-block-2.gold b/test/code-block-2.gold index ef60bd7..d42c1a7 100644 --- a/test/code-block-2.gold +++ b/test/code-block-2.gold @@ -9,7 +9,6 @@ A code block with proper indentation ;-) - #include <iostream> int main() diff --git a/test/code-block-3.gold b/test/code-block-3.gold index 5111262..308b86e 100644 --- a/test/code-block-3.gold +++ b/test/code-block-3.gold @@ -6,7 +6,6 @@
Python code block - print "\xfabln\xeck" @@ -17,7 +16,6 @@ This isn't valid C++ but I think we should accept it; - std::cout<<"\xfabln\xeck"<<"\n"; diff --git a/test/code-block-cpp.gold b/test/code-block-cpp.gold index 793bf65..be33bfd 100644 --- a/test/code-block-cpp.gold +++ b/test/code-block-cpp.gold @@ -2,7 +2,7 @@
- C++ Code Blocks + C++ Code Blocks // No escape /* No escape */ /* No escape @@ -17,13 +17,11 @@ A badly formed comment: - /* Oh dear A badly formed comment with an escape: - /* Oh dear bold
diff --git a/test/code-block-python.gold b/test/code-block-python.gold index ec6c845..239d147 100644 --- a/test/code-block-python.gold +++ b/test/code-block-python.gold @@ -2,7 +2,7 @@
- Python Code Blocks + Python Code Blocks # No escape # Escape: bold # Escape: underlineitalic diff --git a/test/code-block-teletype.gold b/test/code-block-teletype.gold index 35ed79f..e36fb11 100644 --- a/test/code-block-teletype.gold +++ b/test/code-block-teletype.gold @@ -5,7 +5,6 @@ Code Block Teletype 1
<link linkend="code_block_teletype_1.a_code_block">A code block</link> - Just some plain text. With some quickbook thrown in? diff --git a/test/code-block.gold b/test/code-block.gold index 15b9214..8ca2281 100644 --- a/test/code-block.gold +++ b/test/code-block.gold @@ -6,13 +6,11 @@ In a paragraph. Still in a paragraph. - In a code block. Back in a paragraph. - Code block line 1. Code block line 2. Code block line 3. @@ -20,7 +18,6 @@ Code block line 2. Paragraph. - Code block with no trailing blank lines. @@ -30,10 +27,8 @@ Code block line 2. Code blocks separated by comment - First code block. - Second code block. [/ Comment in second code block] Still second code block. diff --git a/test/doc-info/source-mode-1.4.gold b/test/doc-info/source-mode-1.4.gold index c105559..f7fea9a 100644 --- a/test/doc-info/source-mode-1.4.gold +++ b/test/doc-info/source-mode-1.4.gold @@ -16,23 +16,18 @@ - int main() {} - def foo(): - def foo(x): - int main() {} - int main() {}
diff --git a/test/doc-info/source-mode-1.5.gold b/test/doc-info/source-mode-1.5.gold index e10aee2..340c5d2 100644 --- a/test/doc-info/source-mode-1.5.gold +++ b/test/doc-info/source-mode-1.5.gold @@ -15,31 +15,24 @@ - This shouldn't be highlighted. - int main() {} - int main() {} - def foo(): - def foo(x): - This shouldn't be highlighted - This shouldn't be highlighted. diff --git a/test/doc-info/source-mode-1.6.gold b/test/doc-info/source-mode-1.6.gold index 6c6cb20..e20ce00 100644 --- a/test/doc-info/source-mode-1.6.gold +++ b/test/doc-info/source-mode-1.6.gold @@ -15,43 +15,36 @@ - This shouldn't be highlighted.
C++ source mode include - int main() {}
- This shouldn't be highlighted.
Python source mode include - def foo():
- This shouldn't be highlighted.
Teletype source mode include - This shouldn't be highlighted
- This shouldn't be highlighted. diff --git a/test/include/code-import.gold b/test/include/code-import.gold index 5da7949..f160665 100644 --- a/test/include/code-import.gold +++ b/test/include/code-import.gold @@ -24,7 +24,6 @@ And any quickbook block markup. - std::string foo() { // return 'em, foo man! @@ -55,7 +54,6 @@ And any quickbook block markup. - def foo(): # return 'em, foo man! return "foo" @@ -84,7 +82,6 @@ And any quickbook block markup. - char* foo() { // return 'em, foo man! diff --git a/test/include/code-include.gold b/test/include/code-include.gold index 352f37e..8b3a06d 100644 --- a/test/include/code-include.gold +++ b/test/include/code-include.gold @@ -27,7 +27,6 @@ And any quickbook block markup. - char* foo() { // return 'em, foo man! diff --git a/test/preformatted.gold b/test/preformatted.gold index 79d0cc7..e3fb261 100644 --- a/test/preformatted.gold +++ b/test/preformatted.gold @@ -8,7 +8,6 @@ Here's the ubiquitous Hello World program in C++. - #include <iostream> int main() diff --git a/test/quickbook-manual.gold b/test/quickbook-manual.gold index 50c3a40..bf2ed6c 100644 --- a/test/quickbook-manual.gold +++ b/test/quickbook-manual.gold @@ -300,13 +300,10 @@ Can be placed anywhere. - [/ comment (no output generated) ] - [/ comments can be nested [/ some more here] ] - [/ Quickbook blocks can nest inside comments. [*Comment this out too!] ]
@@ -314,7 +311,6 @@ <link linkend="quickbook.syntax.phrase">Phrase Level Elements</link>
<link linkend="quickbook.syntax.phrase.font_styles">Font Styles</link> - ['italic], [*bold], [_underline], [^teletype], [-strikethrough] @@ -328,7 +324,6 @@ Like all non-terminal phrase level elements, this can of course be nested: - [*['bold-italic]] @@ -344,7 +339,6 @@ When you want content that may or must be replaced by the user, use the syntax: - [~replacement] @@ -356,7 +350,6 @@
<link linkend="quickbook.syntax.phrase.quotations">Quotations</link> - ["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein @@ -374,7 +367,6 @@ Like all phrase elements, quotations may be nested. Example: - ["Here's the rule for bargains: ["Do other men, for they would do you.] That's the true business precept.] @@ -392,7 +384,6 @@ the true business precept.] Simple markup for formatting text, common in many applications, is now supported: - /italic/, *bold*, _underline_, =teletype= @@ -656,7 +647,6 @@ the true business precept.] "have" to "full" in the following paragraph will be rendered as bold: - Baa baa black sheep, *have you any wool? Yes sir, yes sir, three bags full!* One for the master, one for the dame, @@ -670,7 +660,6 @@ And one for the little boy who lives down the lane. But in the following paragraph, bold is not applied: - Baa baa black sheep, *have you any wool? Yes sir, yes sir, three bags full! One for the master, one for the dame, @@ -688,7 +677,6 @@ And one for the little boy who lives down the lane. Inlining code in paragraphs is quite common when writing C++ documentation. We provide a very simple markup for this. For example, this: - This text has inlined code `int main() { return 0; }` in it. @@ -725,7 +713,6 @@ And one for the little boy who lives down the lane. the double-tick, instead of the single-tick, we are telling QuickBook to use preformatted blocks of code. Example: - `` #include <iostream> @@ -740,7 +727,6 @@ And one for the little boy who lives down the lane. will generate: - #include <iostream> int main() @@ -765,7 +751,6 @@ And one for the little boy who lives down the lane. where source-mode is one of the supported modes. For example, this: - Python's [python] `import` is rather like C++'s [c++] `#include`. A C++ comment `// looks like this` whereas a Python comment [python] `# looks like this`. @@ -832,7 +817,6 @@ C++ comment `// looks like this` whereas a Python comment [python]
<link linkend="quickbook.syntax.phrase.line_break">line-break</link> - [br] @@ -847,7 +831,6 @@ C++ comment `// looks like this` whereas a Python comment [python]
<link linkend="quickbook.syntax.phrase.anchors">Anchors</link> - [#named_anchor] @@ -861,7 +844,6 @@ Some link text].
<link linkend="quickbook.syntax.phrase.images">Images</link> - [$image.jpg]
@@ -1026,7 +998,6 @@ escape (no processing/formatting) role="special">] block, and the text will be put at the bottom of the current page. For example, this:
- [footnote A sample footnote] @@ -1038,7 +1009,7 @@ escape (no processing/formatting)
<link linkend="quickbook.syntax.phrase.footnotes.macro_expansion">Macro - Expansion</link> + Expansion __a_macro_identifier__ @@ -1047,7 +1018,7 @@ escape (no processing/formatting)
<link linkend="quickbook.syntax.phrase.footnotes.template_expansion">Template - Expansion</link> + Expansion [a_template_identifier] @@ -1065,7 +1036,6 @@ escape (no processing/formatting) Every document must begin with a Document Info section, which should look like this: - [document-type The Document Title [quickbook 1.3] [version 1.0] @@ -1161,7 +1131,6 @@ escape (no processing/formatting) Starting a new section is accomplished with: - [section:id The Section Title] @@ -1176,7 +1145,6 @@ escape (no processing/formatting) End a section with: - [endsect] @@ -1188,7 +1156,6 @@ escape (no processing/formatting) You can include another XML file with: - [xinclude file.xml] @@ -1210,7 +1177,7 @@ escape (no processing/formatting) <link linkend="quickbook.syntax.block.lists">Lists</link>
<link linkend="quickbook.syntax.block.lists.ordered_lists">Ordered - lists</link> + lists # One # Two # Three @@ -1242,7 +1209,6 @@ escape (no processing/formatting) List hierarchies are supported. Example: - # One # Two # Three @@ -1328,7 +1294,6 @@ escape (no processing/formatting) Long lines will be wrapped appropriately. Example: - # A short item. # A very long item. A very long item. A very long item. A very long item. A very long item. A very long item. @@ -1361,7 +1326,7 @@ escape (no processing/formatting)
<link linkend="quickbook.syntax.block.lists.unordered_lists">Unordered - lists</link> + lists * First * Second * Third @@ -1392,7 +1357,6 @@ escape (no processing/formatting) Mixed lists (ordered and unordered) are supported. Example: - # One # Two # Three @@ -1446,7 +1410,6 @@ escape (no processing/formatting) And... - # 1 * 1.a # 1.a.1 @@ -1544,7 +1507,6 @@ escape (no processing/formatting) highlighted according to the current Source Mode: - #include <iostream> int main() @@ -1554,7 +1516,6 @@ escape (no processing/formatting) return 0; } - import cgi def cookForHtml(text): @@ -1565,7 +1526,6 @@ escape (no processing/formatting) Macros that are already defined are expanded in source code. Example: - [def __array__ [@http://www.boost.org/doc/html/array/reference.html array]] [def __boost__ [@http://www.boost.org/libs/libraries.htm boost]] @@ -1574,7 +1534,6 @@ escape (no processing/formatting) Generates: - using boost::array;
@@ -1589,7 +1548,6 @@ escape (no processing/formatting) and Python, the delimiter is the double tick (back-quote): "``" and "``". Example:
- void ``[@http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz foo]``() { } @@ -1597,7 +1555,6 @@ escape (no processing/formatting) Will generate: - void foo() { } @@ -1613,7 +1570,6 @@ escape (no processing/formatting) Sometimes, you don't want some preformatted text to be parsed as C++. In such cases, use the [pre ... ] markup block.
- [pre Some *preformatted* text Some *preformatted* text @@ -1629,7 +1585,6 @@ escape (no processing/formatting) level markup, pre (and Code) are the only ones that allow multiple newlines. The markup above will generate:
- Some preformatted text Some preformatted text Some preformatted text Some preformatted text @@ -1644,7 +1599,6 @@ escape (no processing/formatting)
<link linkend="quickbook.syntax.block.blockquote">Blockquote</link> - [:sometext...]
@@ -1655,7 +1609,6 @@ escape (no processing/formatting)
<link linkend="quickbook.syntax.block.admonitions">Admonitions</link> - [note This is a note] [tip This is a tip] [important This is important] @@ -1698,7 +1651,6 @@ escape (no processing/formatting)
<link linkend="quickbook.syntax.block.headings">Headings</link> - [h1 Heading 1] [h2 Heading 2] [h3 Heading 3] @@ -1739,7 +1691,6 @@ escape (no processing/formatting) For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). You can use: - [link section_id.normalized_header_text The link text] @@ -1754,7 +1705,6 @@ escape (no processing/formatting) In cases when you don't want to care about the heading level (1 to 6), you can use the Generic Heading: - [heading Heading] @@ -1767,7 +1717,6 @@ escape (no processing/formatting) if you do not want to start a new section. In many cases, however, headings in a particular section is just flat. Example: - [section A] [h2 X] [h2 Y] @@ -1781,7 +1730,6 @@ escape (no processing/formatting) is rather tedious, however, to scan the section level everytime. If you rewrite the example above as shown below, this will be automatic: - [section A] [heading X] [heading Y] @@ -1799,7 +1747,6 @@ escape (no processing/formatting)
<link linkend="quickbook.syntax.block.macros">Macros</link> - [def macro_identifier some text] @@ -1809,7 +1756,6 @@ escape (no processing/formatting) character or the underscore. The replacement text can be any phrase (even marked up). Example: - [def sf_logo [$http://sourceforge.net/sflogo.php?group_id=28447&type=1]] sf_logo @@ -1841,7 +1787,6 @@ sf_logo Some more examples: - [def :-) [$theme/smiley.png]] [def __spirit__ [@http://spirit.sourceforge.net Spirit]] @@ -1852,7 +1797,6 @@ sf_logo Invoking these macros: - Hi __spirit__ :-) @@ -1964,7 +1908,6 @@ sf_logo Example template: - [template person[name age what] Hi, my name is [name]. I am [age] years old. I am a [what]. @@ -2022,13 +1965,11 @@ Hi, my name is [name]. I am [age] years old. I am a [what]. are actually two forms. Templates may be phrase or block level. Phrase templates are of the form: - [template sample[arg1 arg2...argN] replacement text... ] Block templates are of the form: - [template sample[arg1 arg2...argN] replacement text... ] @@ -2047,14 +1988,12 @@ replacement text... You expand a template this way: - [template_identifier arg1..arg2..arg3] At template expansion, you supply the actual arguments. The template will be expanded with your supplied arguments. Example: - [person James Bond..39..Spy] [person Santa Clause..87..Big Red Fatso] @@ -2089,14 +2028,12 @@ replacement text... Nullary templates look and act like simple macros. Example: - [template alpha[]'''&#945;'''] [template beta[]'''&#946;'''] Expanding: - Some squigles...[*[alpha][beta]] We have: @@ -2130,14 +2067,12 @@ replacement text... indicates no arguments. If the template body does not look like a template argument list, we can elide the empty brackets. Example: - [template aristotle_quote Aristotle: [*['Education is the best provision for the journey to old age.]]] Expanding: - Here's a quote from [aristotle_quote]. @@ -2155,13 +2090,11 @@ for the journey to old age.]]] use the space escape: "\ ". Example: - [template tag\ _tag] Then expanding: - `struct` x[tag]; @@ -2200,7 +2133,6 @@ for the journey to old age.]]] For example: - [template simple[a b c d] [a][b][c][d]] [simple w x y z] @@ -2220,7 +2152,6 @@ for the journey to old age.]]] QuickBook only tries to get the arguments it needs. For example: - [simple w x y z trail] @@ -2239,7 +2170,6 @@ for the journey to old age.]]] separators. It is possible to combine ".." separators with the argument passing simplification presented above. Example: - [simple what do you think ..m a n?] @@ -2261,25 +2191,21 @@ for the journey to old age.]]] template identifiers. Example: - [template ![bar] <hey>[bar]</hey>] Now, expanding this: - [!baz] We will have: - <hey>baz</hey>
<link linkend="quickbook.syntax.block.blurbs">Blurbs</link> - [blurb :-) [*An eye catching advertisement or note...] __spirit__ is an object-oriented recursive-descent parser generator framework @@ -2316,7 +2242,6 @@ for the journey to old age.]]]
<link linkend="quickbook.syntax.block.tables">Tables</link> - [table A Simple Table [[Heading 1] [Heading 2] [Heading 3]] [[R0-C0] [R0-C1] [R0-C2]] @@ -2411,7 +2336,6 @@ for the journey to old age.]]] in [ cells... ]. The syntax is free-format and allows big cells to be formatted nicely. Example: - [table Table with fat cells [[Heading 1] [Heading 2]] [ @@ -2493,7 +2417,6 @@ for the journey to old age.]]] Here's how to have preformatted blocks of code in a table cell: - [table Table with code [[Comment] [Code]] [ @@ -2536,7 +2459,6 @@ for the journey to old age.]]] - #include <iostream> int main() @@ -2554,7 +2476,6 @@ for the journey to old age.]]]
<link linkend="quickbook.syntax.block.variable_lists">Variable Lists</link> - [variablelist A Variable List [[term 1] [The definition of term 1]] [[term 2] [The definition of term 2]] @@ -2603,7 +2524,6 @@ for the journey to old age.]]] You can include one QuickBook file from another. The syntax is simply: - [include someother.qbk] @@ -2629,7 +2549,6 @@ for the journey to old age.]]] the id defaults to the filename ("someother", in the example above). You can specify the id like this: - [include:someid someother.qbk] @@ -2659,7 +2578,6 @@ for the journey to old age.]]] You can effortlessly import code snippets from source code into your QuickBook. The following illustrates how this is done: - [import ../test/stub.cpp] [foo] [bar] @@ -2667,7 +2585,6 @@ for the journey to old age.]]] The first line: - [import ../test/stub.cpp] @@ -2678,7 +2595,6 @@ for the journey to old age.]]] above). This shall be the template identifier for that particular code snippet. The second and third line above does the actual template expansion: - [foo] [bar] @@ -2707,7 +2623,6 @@ for the journey to old age.]]] And any quickbook block markup. - std::string foo() { // return 'em, foo man! @@ -2719,7 +2634,6 @@ for the journey to old age.]]] This is the bar function - std::string bar() { // return 'em, bar man! @@ -2737,7 +2651,6 @@ for the journey to old age.]]] Note how the code snippets in stub.cpp get marked up. We use distinguishable comments following the form: - //[id some code here //] @@ -2757,13 +2670,11 @@ for the journey to old age.]]] Special comments of the form: - //` some [*quickbook] markup here and: - /*` some [*quickbook] markup here */ @@ -2778,7 +2689,6 @@ for the journey to old age.]]] Special comments of the form: - /*< some [*quickbook] markup here >*/ @@ -2788,7 +2698,6 @@ for the journey to old age.]]] for details. Example: - std::string foo_bar() { return "foo-bar"; @@ -2920,7 +2829,6 @@ for the journey to old age.]]] - using xsltproc : "C:/Users/example/Documents/boost/xml/bin/xsltproc.exe" ; @@ -2974,7 +2882,6 @@ for the journey to old age.]]] - using quickbook : "C:/Users/example/Documents/boost/xml/bin/quickbook.exe" ; @@ -2994,7 +2901,6 @@ for the journey to old age.]]] role="identifier">xml packages. For example, using apt-get: - sudo apt-get install xsltprc docbook-xsl docbook-xml @@ -3014,7 +2920,6 @@ for the journey to old age.]]] the Boost Build documentation. - using xsltproc ; using boostbook @@ -3064,7 +2969,6 @@ for the journey to old age.]]] - using quickbook : /usr/local/bin/quickbook ; @@ -3113,7 +3017,6 @@ for the journey to old age.]]] You can use the following settings to highlight quickbook tags when editing quickbook files. - qbk=*.qbk lexer.*.qbk=props use.tabs.$(qbk)=0 @@ -3162,7 +3065,6 @@ comment.box.end.props=] For example: - using quickbook ; xml my_doc : my_doc.qbk ; @@ -3728,7 +3630,6 @@ boostbook standalone - # one # two # three @@ -3748,7 +3649,6 @@ boostbook standalone - * one * two * three @@ -3989,7 +3889,6 @@ boostbook standalone - [table Title [[a][b][c]] [[a][b][c]] @@ -4009,7 +3908,6 @@ boostbook standalone - [variablelist Title [[a][b]] [[a][b]] diff --git a/test/snippets/pass_thru.gold b/test/snippets/pass_thru.gold index 9889c91..91597d7 100644 --- a/test/snippets/pass_thru.gold +++ b/test/snippets/pass_thru.gold @@ -4,7 +4,6 @@ xmlns:xi="http://www.w3.org/2001/XInclude"> Pass thru test - /*============================================================================= Copyright (c) 2011 Daniel James @@ -15,7 +14,6 @@ - struct Foo{ Foo(); @@ -31,7 +29,6 @@ - def foo: print('foo') diff --git a/test/templates.gold b/test/templates.gold index 46da831..c53fef1 100644 --- a/test/templates.gold +++ b/test/templates.gold @@ -36,7 +36,6 @@ wxyz wxyz trail - int main() { std::cout << "Hello, World" << std::endl; @@ -143,7 +142,6 @@ - int main() {} Paragraphs 1 @@ -175,7 +173,6 @@ - int main() {}