Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75838 - in trunk/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-12-07 04:18:23


Author: danieljames
Date: 2011-12-07 04:18:22 EST (Wed, 07 Dec 2011)
New Revision: 75838
URL: http://svn.boost.org/trac/boost/changeset/75838

Log:
Quickbook: Fix ending a 1.6 list item by a paragraph.
Text files modified:
   trunk/tools/quickbook/src/main_grammar.cpp | 41 +++++++++++++++++++++++++++++++++++----
   trunk/tools/quickbook/test/list_test-1_6.gold | 31 ++++++++++++++++++++++++-----
   trunk/tools/quickbook/test/list_test-1_6.quickbook | 22 +++++++++++++++-----
   3 files changed, 77 insertions(+), 17 deletions(-)

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp (original)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2011-12-07 04:18:22 EST (Wed, 07 Dec 2011)
@@ -34,10 +34,18 @@
     namespace cl = boost::spirit::classic;
 
     struct list_stack_item {
- bool root;
- unsigned int indent;
- unsigned int indent2;
- char mark;
+ bool root; // Is this the root of the context
+ // (e.g. top, template, table cell etc.)
+ unsigned int indent; // Indent of list marker
+ // (or paragraph if not in a list)
+ unsigned int indent2; // Indent of paragraph
+ char mark; // List mark, '\0' if not in a list.
+
+ // Example of inside a list:
+ //
+ // |indent
+ // * List item
+ // |indent2
 
         list_stack_item() :
             root(true), indent(0), indent2(0), mark('\0') {}
@@ -809,9 +817,32 @@
 
                 if (!list_stack.top().root && new_indent == list_stack.top().indent)
                 {
+ // If the paragraph is aligned with the list item's marker,
+ // then end the current list item if that's aligned (or to
+ // the left of) the parent's paragraph.
+ //
+ // i.e.
+ //
+ // * Level 1
+ // * Level 2
+ //
+ // Still Level 2
+ //
+ // vs.
+ //
+ // * Level 1
+ // * Level 2
+ //
+ // Back to Level 1
+
                     list_stack_item save = list_stack.top();
                     list_stack.pop();
- if (new_indent == list_stack.top().indent) {
+
+ assert(list_stack.top().root ?
+ new_indent >= list_stack.top().indent :
+ new_indent > list_stack.top().indent);
+
+ if (new_indent <= list_stack.top().indent2) {
                         actions_.end_list_item();
                         actions_.end_list(save.mark);
                         list_indent = list_stack.top().indent;

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 2011-12-07 04:18:22 EST (Wed, 07 Dec 2011)
@@ -426,30 +426,49 @@
     <itemizedlist>
       <listitem>
         <simpara>
- One
+ A1
           <para>
- Two
+ A2
           </para>
         </simpara>
       </listitem>
       <listitem>
         <simpara>
- Three
+ B1
           <itemizedlist>
             <listitem>
               <simpara>
- Four
+ C1
                 <para>
- Five
+ C2
                 </para>
               </simpara>
             </listitem>
           </itemizedlist>
+ <para>
+ B2
+ </para>
         </simpara>
       </listitem>
       <listitem>
         <simpara>
- Six
+ D1
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ E1
+ <para>
+ E2
+ </para>
+ <para>
+ E3
+ </para>
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ <para>
+ D2
+ </para>
         </simpara>
       </listitem>
     </itemizedlist>

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 2011-12-07 04:18:22 EST (Wed, 07 Dec 2011)
@@ -105,14 +105,24 @@
 
 [section Paragraphs in list items]
 
-* One
+* A1
 
- Two
+ A2
 
-* Three
- * Four
+* B1
+ * C1
 
- Five
-* Six
+ C2
+
+ B2
+
+* D1
+ * E1
+
+ E2
+
+ E3
+
+ D2
 
 [endsect]
\ No newline at end of file


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