Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75445 - in branches/quickbook-dev/tools/quickbook: doc src test
From: dnljms_at_[hidden]
Date: 2011-11-10 13:16:39


Author: danieljames
Date: 2011-11-10 13:16:37 EST (Thu, 10 Nov 2011)
New Revision: 75445
URL: http://svn.boost.org/trac/boost/changeset/75445

Log:
Quickbook: Better table titles.
Text files modified:
   branches/quickbook-dev/tools/quickbook/doc/1_6.qbk | 21 +++++++++++----------
   branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp | 8 ++------
   branches/quickbook-dev/tools/quickbook/src/grammar_impl.hpp | 1 +
   branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp | 7 +++++++
   branches/quickbook-dev/tools/quickbook/test/table-1_6.gold | 30 ++++++++++++++++++++++++++++++
   branches/quickbook-dev/tools/quickbook/test/table-1_6.quickbook | 9 +++++++--
   6 files changed, 58 insertions(+), 18 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/doc/1_6.qbk
==============================================================================
--- branches/quickbook-dev/tools/quickbook/doc/1_6.qbk (original)
+++ branches/quickbook-dev/tools/quickbook/doc/1_6.qbk 2011-11-10 13:16:37 EST (Thu, 10 Nov 2011)
@@ -152,21 +152,22 @@
 [*\[bold\]]. In this case it's just a subtle visual difference, but it
 could cause odd problems, for example when nested in a table cell.
 
-Also, unescaped square brackets aren't allowed in a table title now. If
-there are any it ends the title. So this is now an empty table:
+[endsect] [/escapes]
 
- [table Empty]
+[section:table Table Titles]
 
-While an open bracket will be treated as the start of the table rows:
+Table titles are not parsed as phrases, so some markup is allowd:
 
- [table Simple[[heading 1][heading 2]][[cell 1][cell 2]]]
+[table [*bold title]]
 
-I'm not sure if this is the best course as it doesn't allow for any
-markup or templates in the table title in the future. But the problem is
-that if they are allowed in the title it might be ambiguous where the
-title ends and the cells begin.
+Which is an empty table with a bold title. The title is no longer ended
+by a newline, but by either a closing square bracket, or two opening
+square brackets - which you get at the start of the table cells, so
+this now works:
 
-[endsect] [/escapes]
+ [table Simple[[heading 1][heading 2]][[cell 1][cell 2]]]
+
+[endsect] [/table]
 
 [section:xmlbase XML base]
 

Modified: branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp 2011-11-10 13:16:37 EST (Thu, 10 Nov 2011)
@@ -239,13 +239,9 @@
             | qbk_since(106)
>> actions.to_value(table_tags::title)
                 [
- *(escape
- | line_comment
- | (cl::anychar_p - (*(line_comment | cl::blank_p) >> (cl::eol_p | '[' | ']')))
- [actions.plain_char]
- )
+ table_title_phrase
                 ]
- >> (*eol)
+ >> space
             ;
 
         elements.add

Modified: branches/quickbook-dev/tools/quickbook/src/grammar_impl.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/grammar_impl.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/grammar_impl.hpp 2011-11-10 13:16:37 EST (Thu, 10 Nov 2011)
@@ -72,6 +72,7 @@
         cl::rule<scanner> inline_phrase;
         cl::rule<scanner> paragraph_phrase;
         cl::rule<scanner> extended_phrase;
+ cl::rule<scanner> table_title_phrase;
         cl::rule<scanner> inside_paragraph;
         cl::rule<scanner> command_line;
         cl::rule<scanner> escape;

Modified: branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp 2011-11-10 13:16:37 EST (Thu, 10 Nov 2011)
@@ -211,6 +211,13 @@
             ]
             ;
 
+ table_title_phrase =
+ actions.values.save()
+ [ *( ~cl::eps_p(space >> (']' | '[' >> space >> '['))
+ >> local.common(element_info::in_phrase)
+ )
+ ]
+ ;
         // Top level blocks
         block_start = local.top_level;
 

Modified: branches/quickbook-dev/tools/quickbook/test/table-1_6.gold
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/table-1_6.gold (original)
+++ branches/quickbook-dev/tools/quickbook/test/table-1_6.gold 2011-11-10 13:16:37 EST (Thu, 10 Nov 2011)
@@ -237,6 +237,36 @@
       </tbody>
     </tgroup>
   </informaltable>
+ <table frame="all" id="table_tests.title_on_multiple_lines_with_bol">
+ <title>Title on multiple lines with <emphasis role="bold">bold</emphasis> text?</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ Cell 1
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>
+ Cell 2
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
   <section id="table_tests.section1">
     <title><link linkend="table_tests.section1">Section 1</link></title>
     <table frame="all" id="table_tests.section1.table1">

Modified: branches/quickbook-dev/tools/quickbook/test/table-1_6.quickbook
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/table-1_6.quickbook (original)
+++ branches/quickbook-dev/tools/quickbook/test/table-1_6.quickbook 2011-11-10 13:16:37 EST (Thu, 10 Nov 2011)
@@ -41,8 +41,6 @@
     [[cell]]
 ]
 
-[/ This one might be considered to be a bug. ]
-
 [table [/ Multi line
 comment]
     Title
@@ -57,6 +55,13 @@
     [[Cell 2]]
 ]
 
+[table Title on multiple
+ lines with *bold* text?
+ [[Heading]]
+ [[Cell 1]]
+ [[Cell 2]]
+]
+
 [section:section1 Section 1]
 
 [table:table1 Table 1


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