Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77345 - in trunk/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2012-03-15 18:59:02


Author: danieljames
Date: 2012-03-15 18:59:00 EDT (Thu, 15 Mar 2012)
New Revision: 77345
URL: http://svn.boost.org/trac/boost/changeset/77345

Log:
Quickbook: Fix handling of section tags in lists.
Text files modified:
   trunk/tools/quickbook/src/actions.cpp | 8 ++++++++
   trunk/tools/quickbook/src/grammar_impl.hpp | 1 +
   trunk/tools/quickbook/src/main_grammar.cpp | 19 +++++++++++++++----
   trunk/tools/quickbook/test/list_test-1_5.gold | 16 ++++++++++++++++
   trunk/tools/quickbook/test/list_test-1_5.quickbook | 8 ++++++++
   trunk/tools/quickbook/test/list_test-1_6.gold | 22 ++++++++++++++++++++++
   trunk/tools/quickbook/test/list_test-1_6.quickbook | 9 ++++++++-
   7 files changed, 78 insertions(+), 5 deletions(-)

Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp (original)
+++ trunk/tools/quickbook/src/actions.cpp 2012-03-15 18:59:00 EDT (Thu, 15 Mar 2012)
@@ -313,6 +313,14 @@
 
     void list_item_action::operator()() const
     {
+ // Be careful as this is sometimes called in the wrong place
+ // for markup such as:
+ //
+ // * A
+ // [endsect]
+ //
+ // This action is called before [endsect] (to end the list item)
+ // and then also after it due to the way the parser works.
         std::string str;
         actions.phrase.swap(str);
         actions.out << str;

Modified: trunk/tools/quickbook/src/grammar_impl.hpp
==============================================================================
--- trunk/tools/quickbook/src/grammar_impl.hpp (original)
+++ trunk/tools/quickbook/src/grammar_impl.hpp 2012-03-15 18:59:00 EDT (Thu, 15 Mar 2012)
@@ -38,6 +38,7 @@
             in_block = phrase | maybe_block | nested_block | conditional_or_block | block,
             only_nested_block = nested_block,
             only_block = nested_block | conditional_or_block | block,
+ only_list_block = nested_block | conditional_or_block,
             only_contextual_block = maybe_block | nested_block | conditional_or_block | block
         };
 

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp (original)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2012-03-15 18:59:00 EDT (Thu, 15 Mar 2012)
@@ -27,8 +27,6 @@
 #include <boost/range/algorithm/find_first_of.hpp>
 #include <boost/range/as_literal.hpp>
 
-#include <iostream>
-
 namespace quickbook
 {
     namespace cl = boost::spirit::classic;
@@ -103,9 +101,18 @@
 
                 info_ = l.info;
 
- if (info_.type != element_info::phrase &&
+ if (!l.list_stack.empty() && !l.list_stack.top().root &&
+ info_.type == element_info::block)
+ {
+ // If in a list and the element is a block, end the list.
+ l.actions_.list_item();
+ l.clear_stack();
+ }
+ else if (info_.type != element_info::phrase &&
                         info_.type != element_info::maybe_block)
+ {
                     l.actions_.paragraph();
+ }
 
                 l.actions_.values.builder.reset();
                 
@@ -361,8 +368,12 @@
>> (cl::ch_p('*') | '#')
>> (*cl::blank_p) [local.list.still_in_block = true]
>> *( cl::eps_p(local.list.still_in_block)
- >> local.list_item(element_info::only_block)
+ >> ( qbk_since(106u) >> local.list_item(element_info::only_block)
+ | qbk_before(106u) >> local.list_item(element_info::only_list_block)
+ )
                 )
+ // TODO: This is sometimes called in the wrong place. Currently
+ // harmless.
>> cl::eps_p [actions.list_item]
             ;
 

Modified: trunk/tools/quickbook/test/list_test-1_5.gold
==============================================================================
--- trunk/tools/quickbook/test/list_test-1_5.gold (original)
+++ trunk/tools/quickbook/test/list_test-1_5.gold 2012-03-15 18:59:00 EDT (Thu, 15 Mar 2012)
@@ -383,4 +383,20 @@
       </listitem>
     </itemizedlist>
   </section>
+ <section id="list_test.list_immediately_following_markup_2">
+ <title><link linkend="list_test.list_immediately_following_markup_2">List immediately
+ following markup 2</link></title>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ One [section Nested section]
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ Two [endsect]
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ </section>
 </article>

Modified: trunk/tools/quickbook/test/list_test-1_5.quickbook
==============================================================================
--- trunk/tools/quickbook/test/list_test-1_5.quickbook (original)
+++ trunk/tools/quickbook/test/list_test-1_5.quickbook 2012-03-15 18:59:00 EDT (Thu, 15 Mar 2012)
@@ -98,3 +98,11 @@
 * Three
 
 [endsect]
+
+[section List immediately following markup 2]
+* One
+[section Nested section]
+* Two
+[endsect]
+
+[endsect]

Modified: trunk/tools/quickbook/test/list_test-1_6.gold
==============================================================================
--- trunk/tools/quickbook/test/list_test-1_6.gold (original)
+++ trunk/tools/quickbook/test/list_test-1_6.gold 2012-03-15 18:59:00 EDT (Thu, 15 Mar 2012)
@@ -420,6 +420,28 @@
       </listitem>
     </itemizedlist>
   </section>
+ <section id="list_test.list_immediately_following_mark0">
+ <title><link linkend="list_test.list_immediately_following_mark0">List immediately
+ following markup 2</link></title>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ One
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ <section id="list_test.list_immediately_following_mark0.nested_section">
+ <title><link linkend="list_test.list_immediately_following_mark0.nested_section">Nested
+ section</link></title>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ Two
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ </section>
+ </section>
   <section id="list_test.paragraphs_in_list_items">
     <title><link linkend="list_test.paragraphs_in_list_items">Paragraphs in list
     items</link></title>

Modified: trunk/tools/quickbook/test/list_test-1_6.quickbook
==============================================================================
--- trunk/tools/quickbook/test/list_test-1_6.quickbook (original)
+++ trunk/tools/quickbook/test/list_test-1_6.quickbook 2012-03-15 18:59:00 EDT (Thu, 15 Mar 2012)
@@ -103,6 +103,13 @@
 
 [endsect]
 
+[section List immediately following markup 2]
+* One
+[section Nested section]
+* Two
+[endsect]
+[endsect]
+
 [section Paragraphs in list items]
 
 * A1
@@ -125,4 +132,4 @@
 
    D2
 
-[endsect]
\ No newline at end of file
+[endsect]


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