Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63621 - in trunk/tools/quickbook: detail test
From: daniel_james_at_[hidden]
Date: 2010-07-04 14:52:06


Author: danieljames
Date: 2010-07-04 14:52:05 EDT (Sun, 04 Jul 2010)
New Revision: 63621
URL: http://svn.boost.org/trac/boost/changeset/63621

Log:
Don't output empty paragraphs.
Text files modified:
   trunk/tools/quickbook/detail/actions.cpp | 22 ++++++++++++++++++++++
   trunk/tools/quickbook/detail/actions.hpp | 23 +++++++++++++++++++++++
   trunk/tools/quickbook/detail/actions_class.hpp | 4 ++--
   trunk/tools/quickbook/test/code-block-teletype.gold | 2 --
   trunk/tools/quickbook/test/quickbook-manual.gold | 8 --------
   trunk/tools/quickbook/test/templates.gold | 2 --
   6 files changed, 47 insertions(+), 14 deletions(-)

Modified: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp (original)
+++ trunk/tools/quickbook/detail/actions.cpp 2010-07-04 14:52:05 EDT (Sun, 04 Jul 2010)
@@ -67,6 +67,28 @@
         out << pre << str << post;
     }
 
+ void implicit_paragraph_action::operator()(iterator first, iterator last) const
+ {
+ std::string str;
+ phrase.swap(str);
+
+ // TODO: Use spirit to do this?
+
+ std::string::const_iterator
+ pos = str.begin(),
+ end = str.end();
+
+ while(pos != end && (
+ *pos == ' ' || *pos == '\t' || *pos == '\n' || *pos == '\r'))
+ {
+ ++pos;
+ }
+
+ if(pos != end) {
+ out << pre << str << post;
+ }
+ }
+
     void header_action::operator()(iterator first, iterator last) const
     {
         std::string str;

Modified: trunk/tools/quickbook/detail/actions.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.hpp (original)
+++ trunk/tools/quickbook/detail/actions.hpp 2010-07-04 14:52:05 EDT (Sun, 04 Jul 2010)
@@ -85,6 +85,29 @@
         std::string post;
     };
 
+ struct implicit_paragraph_action
+ {
+ // implicit paragraphs
+ // doesn't output the paragraph if it's only whitespace.
+
+ implicit_paragraph_action(
+ collector& out,
+ collector& phrase,
+ std::string const& pre,
+ std::string const& post)
+ : out(out)
+ , phrase(phrase)
+ , pre(pre)
+ , post(post) {}
+
+ void operator()(iterator first, iterator last) const;
+
+ collector& out;
+ collector& phrase;
+ std::string pre;
+ std::string post;
+ };
+
     struct header_action
     {
         // Handles paragraph, h1, h2, h3, h4, h5, h6,

Modified: trunk/tools/quickbook/detail/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions_class.hpp (original)
+++ trunk/tools/quickbook/detail/actions_class.hpp 2010-07-04 14:52:05 EDT (Sun, 04 Jul 2010)
@@ -113,8 +113,8 @@
         code_action code;
         code_action code_block;
         inline_code_action inline_code;
- phrase_action paragraph;
- phrase_action inside_paragraph;
+ implicit_paragraph_action paragraph;
+ implicit_paragraph_action inside_paragraph;
         generic_header_action h;
         header_action h1, h2, h3, h4, h5, h6;
         markup_action hr;

Modified: trunk/tools/quickbook/test/code-block-teletype.gold
==============================================================================
--- trunk/tools/quickbook/test/code-block-teletype.gold (original)
+++ trunk/tools/quickbook/test/code-block-teletype.gold 2010-07-04 14:52:05 EDT (Sun, 04 Jul 2010)
@@ -5,8 +5,6 @@
   <title>Code Block Teletype 1</title>
   <articleinfo>
   </articleinfo>
- <para>
- </para>
   <section id="code_block_teletype_1.a_code_block">
     <title><link linkend="code_block_teletype_1.a_code_block">A code block</link></title>
     

Modified: trunk/tools/quickbook/test/quickbook-manual.gold
==============================================================================
--- trunk/tools/quickbook/test/quickbook-manual.gold (original)
+++ trunk/tools/quickbook/test/quickbook-manual.gold 2010-07-04 14:52:05 EDT (Sun, 04 Jul 2010)
@@ -1541,8 +1541,6 @@
           highlighted according to the current <link linkend="quickbook.syntax.phrase.source_mode">Source
           Mode</link>:
         </para>
- <para>
- </para>
         
 <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">iostream</phrase><phrase role="special">&gt;</phrase>
 
@@ -1553,8 +1551,6 @@
     <phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
 <phrase role="special">}</phrase>
 </programlisting>
- <para>
- </para>
         
 <programlisting><phrase role="keyword">import</phrase> <phrase role="identifier">cgi</phrase>
 
@@ -1564,8 +1560,6 @@
     <phrase role="keyword">return</phrase> <phrase role="identifier">cgi</phrase><phrase role="special">.</phrase><phrase role="identifier">escape</phrase><phrase role="special">(</phrase><phrase role="identifier">text</phrase><phrase role="special">)</phrase>
 </programlisting>
         <para>
- </para>
- <para>
           Macros that are already defined are expanded in source code. Example:
         </para>
         
@@ -2840,8 +2834,6 @@
     </para>
     <section id="quickbook.install.windows">
       <title><link linkend="quickbook.install.windows"> Windows 2000, XP, 2003, Vista</link></title>
- <para>
- </para>
       <blockquote>
         <para>
           <emphasis>Section contributed by Julio M. Merino Vidal</emphasis>

Modified: trunk/tools/quickbook/test/templates.gold
==============================================================================
--- trunk/tools/quickbook/test/templates.gold (original)
+++ trunk/tools/quickbook/test/templates.gold 2010-07-04 14:52:05 EDT (Sun, 04 Jul 2010)
@@ -73,7 +73,5 @@
   </section>
   <section id="templates.empty_templates">
     <title><link linkend="templates.empty_templates">Empty Templates</link></title>
- <para>
- </para>
   </section>
 </article>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk