Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64830 - in trunk/tools/quickbook: . detail doc test
From: daniel_james_at_[hidden]
Date: 2010-08-15 12:47:28


Author: danieljames
Date: 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
New Revision: 64830
URL: http://svn.boost.org/trac/boost/changeset/64830

Log:
Overhaul some of the template code.

* Store the location along with the contents of the template body, so
  the location should usually be correct now. Exceptions are code
  snippets, because they get rewritten, and the extra newlines added to
  block template.
* Store if a template is a block template at the time of creation. Using
  spirit to decide, rather than handwritten C++.
* Fix callout list markup.
* Fix the `skip_initial_spaces` stuff in `block.hpp`. This never really
  worked before. No longer have to skip spaces in `parse_template` in
  `actions.cpp`.
Text files modified:
   trunk/tools/quickbook/block.hpp | 19 +-
   trunk/tools/quickbook/code_snippet.hpp | 4
   trunk/tools/quickbook/detail/actions.cpp | 226 +++++++++++++++++++++------------------
   trunk/tools/quickbook/detail/actions.hpp | 12 ++
   trunk/tools/quickbook/detail/actions_class.cpp | 1
   trunk/tools/quickbook/detail/actions_class.hpp | 4
   trunk/tools/quickbook/detail/template_stack.cpp | 8
   trunk/tools/quickbook/detail/template_stack.hpp | 34 ++++-
   trunk/tools/quickbook/doc/quickbook.qbk | 2
   trunk/tools/quickbook/phrase.hpp | 36 +++---
   trunk/tools/quickbook/test/callouts.gold | 70 ++++++------
   trunk/tools/quickbook/test/quickbook-manual.gold | 17 ++
   12 files changed, 251 insertions(+), 182 deletions(-)

Modified: trunk/tools/quickbook/block.hpp
==============================================================================
--- trunk/tools/quickbook/block.hpp (original)
+++ trunk/tools/quickbook/block.hpp 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -24,11 +24,11 @@
 {
     using namespace boost::spirit::classic;
 
- template <typename Actions, bool skip_initial_spaces = false>
+ template <typename Actions>
     struct block_grammar : grammar<block_grammar<Actions> >
     {
- block_grammar(Actions& actions_)
- : actions(actions_) {}
+ block_grammar(Actions& actions_, bool skip_initial_spaces = false)
+ : actions(actions_), skip_initial_spaces(skip_initial_spaces) { }
 
         template <typename Scanner>
         struct definition
@@ -40,10 +40,10 @@
                 using detail::var;
                 Actions& actions = self.actions;
 
- if (skip_initial_spaces)
+ if (self.skip_initial_spaces)
                 {
                     start_ =
- *(space_p | comment) >> blocks >> blank
+ *(blank_p | comment) >> blocks >> blank
                         ;
                 }
                 else
@@ -58,10 +58,9 @@
                     | code
                     | list [actions.list]
                     | hr [actions.hr]
- | comment >> +eol
+ | +eol
                     | paragraph [actions.inside_paragraph]
                                                         [actions.write_paragraphs]
- | eol
                     )
                     ;
 
@@ -254,7 +253,10 @@
                             )
>> space >> ']'
                     )
- >> template_body [actions.template_body]
+ >> ( eps_p(*blank_p >> eol_p) [assign_a(actions.template_block, true_)]
+ | eps_p [assign_a(actions.template_block, false_)]
+ )
+ >> template_body [actions.template_body]
                     ;
 
                 template_body =
@@ -471,6 +473,7 @@
         };
 
         Actions& actions;
+ bool const skip_initial_spaces;
     };
 }
 

Modified: trunk/tools/quickbook/code_snippet.hpp
==============================================================================
--- trunk/tools/quickbook/code_snippet.hpp (original)
+++ trunk/tools/quickbook/code_snippet.hpp 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -35,7 +35,7 @@
         std::string code;
         std::string snippet;
         std::string id;
- std::vector<std::string> callouts;
+ std::vector<template_body> callouts;
         std::vector<template_symbol>& storage;
         std::string const doc_id;
         char const* const source_type;
@@ -166,12 +166,14 @@
 
                 inline_callout =
                     "/*<"
+ >> *space_p
>> (*(anychar_p - ">*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)]
>> ">*/"
                     ;
 
                 line_callout =
                     "/*<<"
+ >> *space_p
>> (*(anychar_p - ">>*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)]
>> ">>*/"
>> *space_p

Modified: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp (original)
+++ trunk/tools/quickbook/detail/actions.cpp 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -10,6 +10,7 @@
 =============================================================================*/
 #include <numeric>
 #include <functional>
+#include <algorithm>
 #include <boost/bind.hpp>
 #include <boost/filesystem/v2/convenience.hpp>
 #include <boost/filesystem/v2/fstream.hpp>
@@ -603,7 +604,8 @@
     {
         if (!actions.templates.add(
             template_symbol(actions.template_identifier, actions.template_info,
- std::string(first, last), first.get_position())))
+ std::string(first, last), first.get_position(),
+ actions.template_block, &actions.templates.top_scope())))
         {
             boost::spirit::classic::file_position const pos = first.get_position();
             detail::outerr(pos.file,pos.line)
@@ -617,48 +619,53 @@
 
     namespace
     {
- std::string::size_type find_bracket_end(std::string const& str, std::string::size_type pos)
+ iterator find_bracket_end(iterator begin, iterator const& end)
         {
             unsigned int depth = 1;
 
             while(depth > 0) {
- pos = str.find_first_of("[]\\", pos);
- if(pos == std::string::npos) return pos;
+ char const* search_chars = "[]\\";
+ begin = std::find_first_of(begin, end, search_chars, search_chars + 3);
+ if(begin == end) return begin;
 
- if(str[pos] == '\\')
+ if(*begin == '\\')
                 {
- pos += 2;
+ if(++begin == end) return begin;
+ ++begin;
                 }
                 else
                 {
- depth += (str[pos] == '[') ? 1 : -1;
- ++pos;
+ depth += (*begin == '[') ? 1 : -1;
+ ++begin;
                 }
             }
 
- return pos;
+ return begin;
         }
 
- std::string::size_type find_first_seperator(std::string const& str)
+ iterator find_first_seperator(iterator const& begin, iterator const& end)
         {
             if(qbk_version_n < 105) {
- return str.find_first_of(" \t\r\n");
+ char const* whitespace = " \t\r\n";
+ return std::find_first_of(begin, end, whitespace, whitespace + 4);
             }
             else {
- std::string::size_type pos = 0;
+ iterator pos = begin;
 
                 while(true)
                 {
- pos = str.find_first_of(" \t\r\n\\[", pos);
- if(pos == std::string::npos) return pos;
+ char const* search_chars = " \t\r\n\\[";
+ pos = std::find_first_of(pos, end, search_chars, search_chars + 6);
+ if(pos == end) return pos;
 
- switch(str[pos])
+ switch(*pos)
                     {
                     case '[':
- pos = find_bracket_end(str, pos + 1);
+ pos = find_bracket_end(++pos, end);
                         break;
                     case '\\':
- pos += 2;
+ if(++pos == end) return pos;
+ ++pos;
                         break;
                     default:
                         return pos;
@@ -668,7 +675,7 @@
         }
     
         bool break_arguments(
- std::vector<std::string>& args
+ std::vector<template_body>& args
           , std::vector<std::string> const& params
           , boost::spirit::classic::file_position const& pos
         )
@@ -682,23 +689,29 @@
 
             if (qbk_version_n < 105 || args.size() == 1)
             {
- while (args.size() < params.size() )
+
+ while (args.size() < params.size())
                 {
                     // Try to break the last argument at the first space found
                     // and push it into the back of args. Do this
                     // recursively until we have all the expected number of
                     // arguments, or if there are no more spaces left.
 
- std::string& str = args.back();
- std::string::size_type l_pos = find_first_seperator(str);
- if (l_pos == std::string::npos)
+ template_body& body = args.back();
+ iterator begin(body.content.begin(), body.content.end(), body.position.file);
+ iterator end(body.content.end(), body.content.end());
+
+ iterator l_pos = find_first_seperator(begin, end);
+ if (l_pos == end)
                         break;
- std::string first(str.begin(), str.begin()+l_pos);
- std::string::size_type r_pos = str.find_first_not_of(" \t\r\n", l_pos);
- if (r_pos == std::string::npos)
+ char const* whitespace = " \t\r\n";
+ char const* whitespace_end = whitespace + 4;
+ iterator r_pos = l_pos;
+ while(r_pos != end && std::find(whitespace, whitespace_end, *r_pos) != whitespace_end) ++r_pos;
+ if (r_pos == end)
                         break;
- std::string second(str.begin()+r_pos, str.end());
- str = first;
+ template_body second(std::string(r_pos, end), begin.get_position(), false);
+ body.content = std::string(begin, l_pos);
                     args.push_back(second);
                 }
             }
@@ -719,14 +732,14 @@
 
         std::pair<bool, std::vector<std::string>::const_iterator>
         get_arguments(
- std::vector<std::string>& args
+ std::vector<template_body>& args
           , std::vector<std::string> const& params
           , template_scope const& scope
           , boost::spirit::classic::file_position const& pos
           , quickbook::actions& actions
         )
         {
- std::vector<std::string>::const_iterator arg = args.begin();
+ std::vector<template_body>::const_iterator arg = args.begin();
             std::vector<std::string>::const_iterator tpl = params.begin();
             std::vector<std::string> empty_params;
 
@@ -735,7 +748,8 @@
             while (arg != args.end())
             {
                 if (!actions.templates.add(
- template_symbol(*tpl, empty_params, *arg, pos, &scope)))
+ template_symbol(*tpl, empty_params, arg->content,
+ arg->position, arg->is_block, &scope)))
                 {
                     detail::outerr(pos.file,pos.line)
                         << "Duplicate Symbol Found" << std::endl;
@@ -746,12 +760,11 @@
             }
             return std::make_pair(true, tpl);
         }
-
+
         bool parse_template(
- std::string body
+ template_body const& body
+ , bool escape
           , std::string& result
- , bool& is_block
- , boost::spirit::classic::file_position const& template_pos
           , quickbook::actions& actions
         )
         {
@@ -759,53 +772,43 @@
             // a phrase? We apply a simple heuristic: if the body starts with
             // a newline, then we regard it as a block, otherwise, we parse
             // it as a phrase.
+ //
+ // Note: this is now done in the grammar.
 
- body.reserve(body.size() + 2);
-
- std::string::const_iterator iter = body.begin();
- while (iter != body.end() && ((*iter == ' ') || (*iter == '\t')))
- ++iter; // skip spaces and tabs
- is_block = (iter != body.end()) && ((*iter == '\r') || (*iter == '\n'));
- bool r = false;
-
- if (actions.template_escape)
+ if (escape)
             {
                 // escape the body of the template
                 // we just copy out the literal body
- result = body;
- r = true;
+ result = body.content;
+ return true;
             }
- else if (!is_block)
+ else if (!body.is_block)
             {
                 simple_phrase_grammar<quickbook::actions> phrase_p(actions);
 
                 // do a phrase level parse
- iterator first(body.begin(), body.end(), actions.filename.file_string().c_str());
- first.set_position(template_pos);
- iterator last(body.end(), body.end());
- r = boost::spirit::classic::parse(first, last, phrase_p).full;
+ iterator first(body.content.begin(), body.content.end(), body.position);
+ iterator last(body.content.end(), body.content.end());
+ bool r = boost::spirit::classic::parse(first, last, phrase_p).full;
                 actions.phrase.swap(result);
+ return r;
             }
             else
             {
- block_grammar<quickbook::actions, true> block_p(actions);
+ block_grammar<quickbook::actions> block_p(actions, true);
 
                 // do a block level parse
                 // ensure that we have enough trailing newlines to eliminate
                 // the need to check for end of file in the grammar.
- body.push_back('\n');
- body.push_back('\n');
- while (iter != body.end() && ((*iter == '\r') || (*iter == '\n')))
- ++iter; // skip initial newlines
- iterator first(iter, body.end(), actions.filename.file_string().c_str());
- first.set_position(template_pos);
- iterator last(body.end(), body.end());
- r = boost::spirit::classic::parse(first, last, block_p).full;
+
+ std::string content = body.content + "\n\n";
+ iterator first(content.begin(), content.end(), body.position);
+ iterator last(content.end(), content.end());
+ bool r = boost::spirit::classic::parse(first, last, block_p).full;
                 actions.inside_paragraph();
                 actions.out.swap(result);
+ return r;
             }
-
- return r;
         }
     }
 
@@ -814,13 +817,22 @@
         int callout_id = 0;
     }
 
+ void template_arg_action::operator()(iterator first, iterator last) const
+ {
+ actions.template_args.push_back(
+ template_body(
+ std::string(first, last),
+ first.get_position(),
+ actions.template_block));
+ }
+
     void do_template_action::operator()(iterator first, iterator) const
     {
         // Get the arguments and clear values stored in action.
 
- std::vector<std::string> args;
+ std::vector<template_body> args;
         std::string identifier;
- std::swap(args, actions.template_info);
+ std::swap(args, actions.template_args);
         std::swap(identifier, actions.template_identifier);
         boost::spirit::classic::file_position const pos = first.get_position();
 
@@ -845,7 +857,6 @@
         BOOST_ASSERT(symbol);
             
         std::string result;
- bool is_block;
         actions.push(); // scope the actions' states
         {
             // Store the current section level so that we can ensure that
@@ -886,13 +897,12 @@
                     args.clear();
                 }
 
- BOOST_ASSERT(symbol->params.size() % 2 == 0);
- unsigned int size = symbol->params.size() / 2;
+ unsigned int size = symbol->params.size();
 
                 for(unsigned int i = 0; i < size; ++i)
                 {
                     std::string callout_id = actions.doc_id +
- boost::lexical_cast<std::string>(detail::callout_id++);
+ boost::lexical_cast<std::string>(detail::callout_id + i);
 
                     std::string code;
                     code += "'''";
@@ -900,15 +910,7 @@
                     code += "linkends=\"" + callout_id + "\" />";
                     code += "'''";
 
- args.push_back(code);
-
- code.clear();
- code += "'''";
- code += "<callout arearefs=\"" + callout_id + "co\" ";
- code += "id=\"" + callout_id + "\">";
- code += "'''";
-
- args.push_back(code);
+ args.push_back(template_body(code, first.get_position(), false));
                 }
             }
 
@@ -930,14 +932,16 @@
             ///////////////////////////////////
             // parse the template body:
 
- if (!parse_template(symbol->body, result, is_block, symbol->position, actions))
+ if (!parse_template(symbol->body, actions.template_escape, result, actions))
             {
                 boost::spirit::classic::file_position const pos = first.get_position();
                 detail::outerr(pos.file,pos.line)
- << "Expanding template:" << symbol->identifier << std::endl
+ << "Expanding "
+ << (symbol->body.is_block ? "block" : "phrase")
+ << " template: " << symbol->identifier << std::endl
                     << std::endl
                     << "------------------begin------------------" << std::endl
- << symbol->body
+ << symbol->body.content
                     << "------------------end--------------------" << std::endl
                     << std::endl;
                 actions.pop(); // restore the actions' states
@@ -959,7 +963,37 @@
         }
 
         actions.pop(); // restore the actions' states
- if(is_block) {
+
+ if(symbol->callout && symbol->callouts.size() > 0)
+ {
+ result += "<calloutlist>";
+ BOOST_FOREACH(template_body const& c, symbol->callouts)
+ {
+ std::string callout_id = actions.doc_id +
+ boost::lexical_cast<std::string>(detail::callout_id++);
+
+ std::string callout_value;
+ actions.push();
+ bool r = parse_template(c, false, callout_value, actions);
+ actions.pop();
+
+ if(!r)
+ {
+ detail::outerr(c.position.file, c.position.line)
+ << "Expanding callout." << std::endl;
+ ++actions.error_count;
+ return;
+ }
+
+ result += "<callout arearefs=\"" + callout_id + "co\" ";
+ result += "id=\"" + callout_id + "\">";
+ result += callout_value;
+ result += "</callout>";
+ }
+ result += "</calloutlist>";
+ }
+
+ if(symbol->body.is_block) {
             actions.inside_paragraph();
             actions.temp_para << result; // print it!!!
         }
@@ -1251,7 +1285,7 @@
     {
         code += "``[[callout" + boost::lexical_cast<std::string>(callouts.size()) + "]]``";
     
- callouts.push_back(std::string(first, last));
+ callouts.push_back(template_body(std::string(first, last), first.get_position(), true));
     }
 
     void code_snippet_actions::escaped_comment(iterator first, iterator last)
@@ -1289,32 +1323,15 @@
                 snippet += "```\n" + code + "```\n\n";
             }
 
- if(callouts.size() > 0)
+ for (size_t i = 0; i < callouts.size(); ++i)
             {
- std::vector<std::string> callout_items;
-
- snippet += "'''<calloutlist>'''";
- for (size_t i = 0; i < callouts.size(); ++i)
- {
- std::string callout_template = "[callout" + boost::lexical_cast<std::string>(i) + "]";
- std::string calloutitem_template = "[calloutitem" + boost::lexical_cast<std::string>(i) + "]";
-
- snippet += "[" + calloutitem_template + "]";
- snippet += "'''<para>'''";
- snippet += callouts[i];
- snippet += "\n";
- snippet += "'''</para>'''";
- snippet += "'''</callout>'''";
-
- params.push_back(callout_template);
- params.push_back(calloutitem_template);
- }
- snippet += "'''</calloutlist>'''";
+ params.push_back("[callout" + boost::lexical_cast<std::string>(i) + "]");
             }
         }
 
- template_symbol symbol(id, params, snippet, first.get_position());
+ template_symbol symbol(id, params, snippet, first.get_position(), true);
         symbol.callout = true;
+ symbol.callouts = callouts;
         storage.push_back(symbol);
 
         callouts.clear();
@@ -1393,12 +1410,13 @@
         actions.error_count +=
             load_snippets(path.string(), storage, ext, actions.doc_id);
 
- BOOST_FOREACH(template_symbol const& ts, storage)
+ BOOST_FOREACH(template_symbol& ts, storage)
         {
             std::string tname = ts.identifier;
+ ts.parent = &actions.templates.top_scope();
             if (!actions.templates.add(ts))
             {
- boost::spirit::classic::file_position const pos = ts.position;
+ boost::spirit::classic::file_position const pos = ts.body.position;
                 detail::outerr(pos.file, pos.line)
                     << "Template Redefinition: " << tname << std::endl;
                 ++actions.error_count;

Modified: trunk/tools/quickbook/detail/actions.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.hpp (original)
+++ trunk/tools/quickbook/detail/actions.hpp 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -632,6 +632,18 @@
 
         quickbook::actions& actions;
     };
+
+ struct template_arg_action
+ {
+ // Handles a template argument
+
+ template_arg_action(quickbook::actions& actions)
+ : actions(actions) {}
+
+ void operator()(iterator first, iterator last) const;
+
+ quickbook::actions& actions;
+ };
 
     struct do_template_action
     {

Modified: trunk/tools/quickbook/detail/actions_class.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions_class.cpp (original)
+++ trunk/tools/quickbook/detail/actions_class.cpp 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -162,6 +162,7 @@
         , macro_definition(*this)
         , do_macro(phrase)
         , template_body(*this)
+ , template_arg(*this)
         , do_template(*this)
         , url_pre(phrase, url_pre_)
         , url_post(phrase, url_post_)

Modified: trunk/tools/quickbook/detail/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions_class.hpp (original)
+++ trunk/tools/quickbook/detail/actions_class.hpp 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -93,6 +93,9 @@
         string_list template_info;
         int template_depth;
         bool template_escape;
+ bool template_block;
+ std::vector<quickbook::template_body>
+ template_args;
         template_stack templates;
         int error_count;
         std::string image_fileref;
@@ -186,6 +189,7 @@
         macro_definition_action macro_definition;
         do_macro_action do_macro;
         template_body_action template_body;
+ template_arg_action template_arg;
         do_template_action do_template;
         link_action url_pre;
         markup_action url_post;

Modified: trunk/tools/quickbook/detail/template_stack.cpp
==============================================================================
--- trunk/tools/quickbook/detail/template_stack.cpp (original)
+++ trunk/tools/quickbook/detail/template_stack.cpp 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -52,16 +52,14 @@
     bool template_stack::add(template_symbol const& ts)
     {
         BOOST_ASSERT(!scopes.empty());
+ BOOST_ASSERT(ts.parent);
         
         if (this->find_top_scope(ts.identifier)) {
             return false;
         }
         
- template_symbol symbol(ts);
- if(!ts.parent) symbol.parent = &top_scope();
-
- boost::spirit::classic::add(scopes.front().symbols, ts.identifier.c_str(),
- symbol);
+ boost::spirit::classic::add(scopes.front().symbols,
+ ts.identifier.c_str(), ts);
 
         return true;
     }

Modified: trunk/tools/quickbook/detail/template_stack.hpp
==============================================================================
--- trunk/tools/quickbook/detail/template_stack.hpp (original)
+++ trunk/tools/quickbook/detail/template_stack.hpp 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -21,6 +21,24 @@
 
 namespace quickbook
 {
+ struct template_body
+ {
+ template_body(
+ std::string const& content,
+ boost::spirit::classic::file_position position,
+ bool is_block
+ )
+ : content(content)
+ , position(position)
+ , is_block(is_block)
+ {
+ }
+
+ std::string content;
+ boost::spirit::classic::file_position position;
+ bool is_block;
+ };
+
     struct template_scope;
 
     struct template_symbol
@@ -30,24 +48,26 @@
                 std::vector<std::string> const& params,
                 std::string const& body,
                 boost::spirit::classic::file_position const& position,
+ bool is_block,
                 template_scope const* parent = 0)
            : identifier(identifier)
- , callout(false)
            , params(params)
- , body(body)
- , position(position)
- , parent(parent) {}
+ , body(body, position, is_block)
+ , parent(parent)
+ , callout(false)
+ , callouts() {}
 
         std::string identifier;
- bool callout;
         std::vector<std::string> params;
- std::string body;
- boost::spirit::classic::file_position position;
+ template_body body;
         
         // This is only used for quickbook 1.5+, 1.4 uses the dynamic scope.
         // TODO: I should probably call this something like lexical_parent
         // or static_parent for clarity.
         template_scope const* parent;
+
+ bool callout;
+ std::vector<template_body> callouts;
     };
 
     typedef boost::spirit::classic::symbols<template_symbol> template_symbols;

Modified: trunk/tools/quickbook/doc/quickbook.qbk
==============================================================================
--- trunk/tools/quickbook/doc/quickbook.qbk (original)
+++ trunk/tools/quickbook/doc/quickbook.qbk 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -225,6 +225,8 @@
 * Fix a couple of issues with the code block parser:
   * A comment with no indentation will now end a code block.
   * Code blocks no longer have to be followed by a blank line.
+* Improved tracking of file position in templates and imported code blocks.
+* Better generated markup for callout lists.
 * Further work on quickbook 1.6, still not stable.
   * Allow heading to have ids, using the syntax: `[heading:id title]`.
 

Modified: trunk/tools/quickbook/phrase.hpp
==============================================================================
--- trunk/tools/quickbook/phrase.hpp (original)
+++ trunk/tools/quickbook/phrase.hpp 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -132,13 +132,13 @@
                         (eps_p(punct_p)
>> actions.templates.scope
                         ) [assign_a(actions.template_identifier)]
- [clear_a(actions.template_info)]
+ [clear_a(actions.template_args)]
>> !template_args
                     ) | (
                         (actions.templates.scope
>> eps_p(hard_space)
                         ) [assign_a(actions.template_identifier)]
- [clear_a(actions.template_info)]
+ [clear_a(actions.template_args)]
>> space
>> !template_args
                     ) )
@@ -153,30 +153,31 @@
                     ]
                     ;
 
- template_args_1_4 =
- template_arg_1_4 [push_back_a(actions.template_info)]
- >> *(
- ".." >> template_arg_1_4 [push_back_a(actions.template_info)]
+ template_args_1_4 = template_arg_1_4 >> *(".." >> template_arg_1_4);
+
+ template_arg_1_4 =
+ ( eps_p(*blank_p >> eol_p) [assign_a(actions.template_block, true_)]
+ | eps_p [assign_a(actions.template_block, false_)]
                         )
+ >> template_inner_arg_1_4 [actions.template_arg]
                     ;
 
- template_arg_1_4 =
+ template_inner_arg_1_4 =
                     +(brackets_1_4 | (anychar_p - (str_p("..") | ']')))
                     ;
 
                 brackets_1_4 =
- '[' >> +template_arg_1_4 >> ']'
+ '[' >> template_inner_arg_1_4 >> ']'
                     ;
 
- template_args_1_5 =
- template_arg_1_5 [push_back_a(actions.template_info)]
- >> *(
- ".." >> template_arg_1_5 [push_back_a(actions.template_info)]
- )
- ;
+ template_args_1_5 = template_arg_1_5 >> *(".." >> template_arg_1_5);
 
                 template_arg_1_5 =
- +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p("..") | '[' | ']')))
+ ( eps_p(*blank_p >> eol_p) [assign_a(actions.template_block, true_)]
+ | eps_p [assign_a(actions.template_block, false_)]
+ )
+ >> (+(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p("..") | '[' | ']'))))
+ [actions.template_arg]
                     ;
 
                 template_inner_arg_1_5 =
@@ -184,7 +185,7 @@
                     ;
 
                 brackets_1_5 =
- '[' >> +template_inner_arg_1_5 >> ']'
+ '[' >> template_inner_arg_1_5 >> ']'
                     ;
 
                 inline_code =
@@ -478,7 +479,8 @@
                             simple_teletype, source_mode, template_,
                             quote, code_block, footnote, replaceable, macro,
                             dummy_block, cond_phrase, macro_identifier, template_args,
- template_args_1_4, template_arg_1_4, brackets_1_4,
+ template_args_1_4, template_arg_1_4,
+ template_inner_arg_1_4, brackets_1_4,
                             template_args_1_5, template_arg_1_5,
                             template_inner_arg_1_5, brackets_1_5
                             ;

Modified: trunk/tools/quickbook/test/callouts.gold
==============================================================================
--- trunk/tools/quickbook/test/callouts.gold (original)
+++ trunk/tools/quickbook/test/callouts.gold 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -19,9 +19,13 @@
 
 </programlisting>
   </para>
- <para>
- <calloutlist><callout arearefs="callout_tests0co" id="callout_tests0"><para> create a uniform_int distribution </para></callout></calloutlist>
- </para>
+ <calloutlist>
+ <callout arearefs="callout_tests0co" id="callout_tests0">
+ <para>
+ create a uniform_int distribution
+ </para>
+ </callout>
+ </calloutlist>
   <para>
     Example 2:
   </para>
@@ -33,17 +37,15 @@
 
 </programlisting>
   </para>
- <para>
- <calloutlist><callout arearefs="callout_tests1co" id="callout_tests1"><para>
- </para>
- <important>
- <para>
- test
- </para>
- </important>
- <para>
- </para></callout></calloutlist>
- </para>
+ <calloutlist>
+ <callout arearefs="callout_tests1co" id="callout_tests1">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
   <para>
     Example 3:
   </para>
@@ -55,17 +57,15 @@
 
 </programlisting>
   </para>
- <para>
- <calloutlist><callout arearefs="callout_tests2co" id="callout_tests2"><para>
- </para>
- <important>
- <para>
- test
- </para>
- </important>
- <para>
- </para></callout></calloutlist>
- </para>
+ <calloutlist>
+ <callout arearefs="callout_tests2co" id="callout_tests2">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
   <para>
     Example 3 (again!):
   </para>
@@ -77,15 +77,13 @@
 
 </programlisting>
   </para>
- <para>
- <calloutlist><callout arearefs="callout_tests3co" id="callout_tests3"><para>
- </para>
- <important>
- <para>
- test
- </para>
- </important>
- <para>
- </para></callout></calloutlist>
- </para>
+ <calloutlist>
+ <callout arearefs="callout_tests3co" id="callout_tests3">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
 </article>

Modified: trunk/tools/quickbook/test/quickbook-manual.gold
==============================================================================
--- trunk/tools/quickbook/test/quickbook-manual.gold (original)
+++ trunk/tools/quickbook/test/quickbook-manual.gold 2010-08-15 12:47:21 EDT (Sun, 15 Aug 2010)
@@ -2802,10 +2802,19 @@
 <phrase role="special">}</phrase>
 </programlisting>
         </para>
- <para>
- <calloutlist><callout arearefs="quickbook0co" id="quickbook0"><para> The <emphasis>Mythical</emphasis> FooBar. See <ulink url="http://en.wikipedia.org/wiki/Foobar">Foobar
- for details</ulink> </para></callout><callout arearefs="quickbook1co" id="quickbook1"><para> return 'em, foo-bar man! </para></callout></calloutlist>
- </para>
+ <calloutlist>
+ <callout arearefs="quickbook0co" id="quickbook0">
+ <para>
+ The <emphasis>Mythical</emphasis> FooBar. See <ulink url="http://en.wikipedia.org/wiki/Foobar">Foobar
+ for details</ulink>
+ </para>
+ </callout>
+ <callout arearefs="quickbook1co" id="quickbook1">
+ <para>
+ return 'em, foo-bar man!
+ </para>
+ </callout>
+ </calloutlist>
         <para>
           Checkout <ulink url="../../test/stub.cpp">stub.cpp</ulink> to see the actual
           code.


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