Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56752 - in branches/release: . boost/algorithm/string boost/archive boost/config boost/fusion boost/graph boost/math boost/numeric/ublas boost/program_options boost/property_tree boost/python boost/regex boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/qi/nonterminal boost/spirit/home/qi/numeric/detail boost/spirit/home/support boost/spirit/repository/home/qi/nonterminal boost/system boost/tr1 boost/type_traits boost/utility boost/wave libs libs/config libs/fusion libs/graph_parallel libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/numeric/ublas libs/program_options libs/property_tree libs/python libs/regex libs/serialization libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/system libs/timer libs/tr1 libs/type_traits libs/utility libs/wave status tools/build/v2 tools/quickbook tools/quickbook/detail tools/quickbook/doc tools/quickbook/test tools/regression tools/wave
From: daniel_james_at_[hidden]
Date: 2009-10-12 15:54:39


Author: danieljames
Date: 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
New Revision: 56752
URL: http://svn.boost.org/trac/boost/changeset/56752

Log:
Merge quickbook 1.5 from trunk.

Merged revisions 55905-55917,56077,56715,56717-56719 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r55905 | danieljames | 2009-08-31 12:36:13 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Update quickbook version number.
........
  r55906 | danieljames | 2009-08-31 12:36:23 +0100 (Mon, 31 Aug 2009) | 4 lines
  
  Create entry for 1.5 in the change log.
  
  Starting it of with some of the changes that have been made to quickbook
  since 1.4 - considering the first 1.4 release as the proper 1.4 release.
........
  r55907 | danieljames | 2009-08-31 12:36:34 +0100 (Mon, 31 Aug 2009) | 3 lines
  
  Wrap the template info in a struct.
  
  So that I can add extra scoping info.
........
  r55908 | danieljames | 2009-08-31 12:36:47 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Implement static/lexical scoping for 1.5. Refs #2034.
........
  r55909 | danieljames | 2009-08-31 12:37:04 +0100 (Mon, 31 Aug 2009) | 1 line
  
  In quickbook 1.5 don't mix '..' and whitespace seperators for template arguments. Refs #1174
........
  r55910 | danieljames | 2009-08-31 12:37:17 +0100 (Mon, 31 Aug 2009) | 2 lines
  
  Put the quickbook version numbers in a single header, along with convenience
  functions for using them in spirit grammars.
........
  r55911 | danieljames | 2009-08-31 12:37:32 +0100 (Mon, 31 Aug 2009) | 3 lines
  
  Ignore spaces after 'section:' for quickbook 1.5+ Refs #2712
  
  And warn when section id is empty after colon.
........
  r55912 | danieljames | 2009-08-31 12:37:48 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Introduce temporary id variable.
........
  r55913 | danieljames | 2009-08-31 12:37:59 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Table ids. Refs #1194.
........
  r55914 | danieljames | 2009-08-31 12:38:11 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Separate out the current version of the template argument parser, as I want to create a new one for 1.5
........
  r55915 | danieljames | 2009-08-31 12:38:20 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Don't use seperators that are in brackets, or are escaped. Refs #2036.
........
  r55916 | danieljames | 2009-08-31 12:38:33 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Add missing table tests.
........
  r55917 | danieljames | 2009-08-31 12:38:47 +0100 (Mon, 31 Aug 2009) | 1 line
  
  Support image attributes. Refs #1157.
........
  r56077 | djowel | 2009-09-07 02:35:24 +0100 (Mon, 07 Sep 2009) | 1 line
  
  fix for msvc
........
  r56715 | danieljames | 2009-10-11 17:18:04 +0100 (Sun, 11 Oct 2009) | 1 line
  
  Use qualified ids in tables, and fix a bug generating ids when there isn't a section.
........
  r56717 | danieljames | 2009-10-11 19:21:11 +0100 (Sun, 11 Oct 2009) | 1 line
  
  Document the simplified quickbook 1.5 argument separators.
........
  r56718 | danieljames | 2009-10-11 19:21:32 +0100 (Sun, 11 Oct 2009) | 1 line
  
  Use quickbook 1.5 in the document block example.
........
  r56719 | danieljames | 2009-10-11 19:21:48 +0100 (Sun, 11 Oct 2009) | 1 line
  
  Add table ids to the documentation.
........

Added:
   branches/release/tools/quickbook/detail/quickbook.hpp
      - copied, changed from r55917, /trunk/tools/quickbook/detail/quickbook.hpp
   branches/release/tools/quickbook/test/fail-template-arguments3.quickbook
      - copied unchanged from r55917, /trunk/tools/quickbook/test/fail-template-arguments3.quickbook
   branches/release/tools/quickbook/test/fail-template-lookup1.quickbook
      - copied unchanged from r55917, /trunk/tools/quickbook/test/fail-template-lookup1.quickbook
   branches/release/tools/quickbook/test/heading.gold
      - copied unchanged from r56715, /trunk/tools/quickbook/test/heading.gold
   branches/release/tools/quickbook/test/heading.quickbook
      - copied unchanged from r56715, /trunk/tools/quickbook/test/heading.quickbook
   branches/release/tools/quickbook/test/image_1_5.gold
      - copied unchanged from r55917, /trunk/tools/quickbook/test/image_1_5.gold
   branches/release/tools/quickbook/test/image_1_5.quickbook
      - copied unchanged from r55917, /trunk/tools/quickbook/test/image_1_5.quickbook
   branches/release/tools/quickbook/test/section_1_4.gold
      - copied unchanged from r55917, /trunk/tools/quickbook/test/section_1_4.gold
   branches/release/tools/quickbook/test/section_1_4.quickbook
      - copied unchanged from r55917, /trunk/tools/quickbook/test/section_1_4.quickbook
   branches/release/tools/quickbook/test/section_1_5.gold
      - copied unchanged from r55917, /trunk/tools/quickbook/test/section_1_5.gold
   branches/release/tools/quickbook/test/section_1_5.quickbook
      - copied unchanged from r55917, /trunk/tools/quickbook/test/section_1_5.quickbook
   branches/release/tools/quickbook/test/table_1_5.gold
      - copied, changed from r55917, /trunk/tools/quickbook/test/table_1_5.gold
   branches/release/tools/quickbook/test/table_1_5.quickbook
      - copied, changed from r55917, /trunk/tools/quickbook/test/table_1_5.quickbook
   branches/release/tools/quickbook/test/templates_1_5.gold
      - copied unchanged from r55917, /trunk/tools/quickbook/test/templates_1_5.gold
   branches/release/tools/quickbook/test/templates_1_5.quickbook
      - copied unchanged from r55917, /trunk/tools/quickbook/test/templates_1_5.quickbook
Properties modified:
   branches/release/ (props changed)
   branches/release/boost/algorithm/string/ (props changed)
   branches/release/boost/archive/ (props changed)
   branches/release/boost/config/ (props changed)
   branches/release/boost/fusion/ (props changed)
   branches/release/boost/graph/ (props changed)
   branches/release/boost/math/ (props changed)
   branches/release/boost/numeric/ublas/ (props changed)
   branches/release/boost/program_options/ (props changed)
   branches/release/boost/property_tree/ (props changed)
   branches/release/boost/python/ (props changed)
   branches/release/boost/regex/ (props changed)
   branches/release/boost/serialization/ (props changed)
   branches/release/boost/signals/ (props changed)
   branches/release/boost/signals2/ (props changed)
   branches/release/boost/spirit/ (props changed)
   branches/release/boost/spirit/home/ (props changed)
   branches/release/boost/spirit/home/qi/nonterminal/rule.hpp (props changed)
   branches/release/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp (props changed)
   branches/release/boost/spirit/home/support/attributes.hpp (props changed)
   branches/release/boost/spirit/repository/home/qi/nonterminal/subrule.hpp (props changed)
   branches/release/boost/system/ (props changed)
   branches/release/boost/tr1/ (props changed)
   branches/release/boost/type_traits/ (props changed)
   branches/release/boost/utility/value_init.hpp (props changed)
   branches/release/boost/wave/ (props changed)
   branches/release/index.html (props changed)
   branches/release/libs/config/ (props changed)
   branches/release/libs/fusion/ (props changed)
   branches/release/libs/graph_parallel/ (props changed)
   branches/release/libs/libraries.htm (props changed)
   branches/release/libs/maintainers.txt (props changed)
   branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
   branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
   branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
   branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
   branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
   branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
   branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
   branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
   branches/release/libs/numeric/ublas/ (props changed)
   branches/release/libs/program_options/ (props changed)
   branches/release/libs/property_tree/ (props changed)
   branches/release/libs/python/ (props changed)
   branches/release/libs/regex/ (props changed)
   branches/release/libs/serialization/ (props changed)
   branches/release/libs/signals/ (props changed)
   branches/release/libs/signals2/ (props changed)
   branches/release/libs/spirit/ (props changed)
   branches/release/libs/spirit/classic/example/ (props changed)
   branches/release/libs/spirit/example/ (props changed)
   branches/release/libs/spirit/phoenix/ (props changed)
   branches/release/libs/spirit/test/ (props changed)
   branches/release/libs/spirit/test/qi/optional.cpp (props changed)
   branches/release/libs/system/ (props changed)
   branches/release/libs/timer/ (props changed)
   branches/release/libs/tr1/ (props changed)
   branches/release/libs/type_traits/ (props changed)
   branches/release/libs/utility/swap.html (props changed)
   branches/release/libs/utility/value_init.htm (props changed)
   branches/release/libs/utility/value_init_test.cpp (props changed)
   branches/release/libs/wave/ (props changed)
   branches/release/status/ (props changed)
   branches/release/tools/build/v2/ (props changed)
   branches/release/tools/regression/ (props changed)
   branches/release/tools/wave/ (props changed)
Text files modified:
   branches/release/tools/quickbook/block.hpp | 30 ++++
   branches/release/tools/quickbook/detail/actions.cpp | 236 ++++++++++++++++++++++++++++++++-------
   branches/release/tools/quickbook/detail/actions.hpp | 43 ++++++-
   branches/release/tools/quickbook/detail/actions_class.cpp | 9 +
   branches/release/tools/quickbook/detail/actions_class.hpp | 6 +
   branches/release/tools/quickbook/detail/quickbook.cpp | 3
   branches/release/tools/quickbook/detail/quickbook.hpp | 16 +-
   branches/release/tools/quickbook/detail/template_stack.cpp | 30 +++-
   branches/release/tools/quickbook/detail/template_stack.hpp | 39 +++++-
   branches/release/tools/quickbook/doc/quickbook.qbk | 75 ++++++++----
   branches/release/tools/quickbook/doc_info.hpp | 3
   branches/release/tools/quickbook/phrase.hpp | 85 +++++++++++---
   branches/release/tools/quickbook/test/Jamfile.v2 | 8 +
   branches/release/tools/quickbook/test/table_1_5.gold | 33 ++++
   branches/release/tools/quickbook/test/table_1_5.quickbook | 12 +
   branches/release/tools/quickbook/test/templates_1_4.gold | 9 +
   branches/release/tools/quickbook/test/templates_1_4.quickbook | 24 +++
   17 files changed, 530 insertions(+), 131 deletions(-)

Modified: branches/release/tools/quickbook/block.hpp
==============================================================================
--- branches/release/tools/quickbook/block.hpp (original)
+++ branches/release/tools/quickbook/block.hpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -10,6 +10,7 @@
 #if !defined(BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP)
 #define BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
 
+#include "./detail/quickbook.hpp"
 #include "./detail/utils.hpp"
 #include "./phrase.hpp"
 #include <boost/spirit/include/classic_core.hpp>
@@ -121,13 +122,32 @@
                         | eps_p [actions.error]
                         )
                     ;
+
+ element_id =
+ ':'
+ >>
+ (
+ if_p(qbk_since(105u)) [space]
+ >> (+(alnum_p | '_')) [assign_a(actions.element_id)]
+ | eps_p [actions.element_id_warning]
+ [assign_a(actions.element_id)]
+ )
+ | eps_p [assign_a(actions.element_id)]
+ ;
+
+ element_id_1_5 =
+ if_p(qbk_since(105u)) [
+ element_id
+ ]
+ .else_p [
+ eps_p [assign_a(actions.element_id)]
+ ]
+ ;
 
                 begin_section =
                        "section"
>> hard_space
- >> (':' >> (*(alnum_p | '_')) [assign_a(actions.section_id)]
- | eps_p [assign_a(actions.section_id)]
- )
+ >> element_id
>> phrase [actions.begin_section]
                     ;
 
@@ -283,6 +303,8 @@
                 table =
                     "table"
>> (eps_p(*blank_p >> eol_p) | hard_space)
+ >> element_id_1_5
+ >> (eps_p(*blank_p >> eol_p) | space)
>> (*(anychar_p - eol)) [assign_a(actions.table_title)]
>> +eol
>> *table_row
@@ -419,7 +441,7 @@
                             xinclude, include, hard_space, eol, paragraph_end,
                             template_, template_id, template_formal_arg,
                             template_body, identifier, dummy_block, import,
- inside_paragraph;
+ inside_paragraph, element_id, element_id_1_5;
 
             symbols<> paragraph_end_markups;
 

Modified: branches/release/tools/quickbook/detail/actions.cpp
==============================================================================
--- branches/release/tools/quickbook/detail/actions.cpp (original)
+++ branches/release/tools/quickbook/detail/actions.cpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -14,6 +14,7 @@
 #include <boost/filesystem/convenience.hpp>
 #include <boost/filesystem/fstream.hpp>
 #include <boost/lexical_cast.hpp>
+#include "./quickbook.hpp"
 #include "./actions.hpp"
 #include "./utils.hpp"
 #include "./markups.hpp"
@@ -24,6 +25,20 @@
 
 namespace quickbook
 {
+ namespace {
+ std::string fully_qualified_id(std::string const& library_id,
+ std::string const& qualified_section_id,
+ std::string const& section_id)
+ {
+ std::string id = library_id;
+ if(!id.empty() && !qualified_section_id.empty()) id += '.';
+ id += qualified_section_id;
+ if(!id.empty() && !section_id.empty()) id += '.';
+ id += section_id;
+ return id;
+ }
+ }
+
     // Handles line-breaks (DEPRECATED!!!)
     void break_action::operator()(iterator first, iterator) const
     {
@@ -64,9 +79,8 @@
         }
         else // version 1.3 and above
         {
- std::string anchor =
- library_id + '.' + qualified_section_id + '.' +
- detail::make_identifier(str.begin(), str.end());
+ std::string anchor = fully_qualified_id(library_id, qualified_section_id,
+ detail::make_identifier(str.begin(), str.end()));
 
             out << "<anchor id=\"" << anchor << "\"/>"
                 << pre
@@ -88,9 +102,8 @@
         std::string str;
         phrase.swap(str);
 
- std::string anchor =
- library_id + '.' + qualified_section_id + '.' +
- detail::make_identifier(str.begin(), str.end());
+ std::string anchor = fully_qualified_id(library_id, qualified_section_id,
+ detail::make_identifier(str.begin(), str.end()));
 
         out
             << "<anchor id=\"" << anchor << "\"/>"
@@ -399,11 +412,29 @@
         detail::print_char(*first, phrase.get());
     }
 
- void image_action::operator()(iterator first, iterator last) const
+ void attribute_action::operator()(iterator first, iterator last) const
+ {
+ boost::spirit::classic::file_position const pos = first.get_position();
+
+ if (!attributes.insert(
+ attribute_map::value_type(attribute_name, std::string(first, last))
+ ).second)
+ {
+ detail::outerr(pos.file,pos.line)
+ << "Repeated attribute: " << attribute_name << ".\n";
+ }
+ }
+
+ void image_action::operator()(iterator, iterator) const
     {
- fs::path const img_path(std::string(first, last));
+ fs::path const img_path(image_fileref);
+
+ attribute_map::iterator it = attributes.find("alt");
+ std::string alt_text = it != attributes.end() ? it->second : fs::basename(img_path);
+ attributes.erase("alt");
+
+ attributes.insert(attribute_map::value_type("fileref", image_fileref));
 
- std::string attr_text;
         if(fs::extension(img_path) == ".svg")
         {
            //
@@ -417,7 +448,7 @@
            // a tiny box with scrollbars (Firefox), or else cropped to
            // fit in a tiny box (IE7).
            //
- attr_text = " format=\"SVG\"";
+ attributes.insert(attribute_map::value_type("format", "SVG"));
            //
            // Image paths are relative to the html subdirectory:
            //
@@ -451,8 +482,8 @@
            b = svg_text.find('\"', a + 1);
            if(a != std::string::npos)
            {
- attr_text.append(" contentwidth=");
- attr_text.append(svg_text.begin() + a, svg_text.begin() + b + 1);
+ attributes.insert(attribute_map::value_type("contentwidth",
+ std::string(svg_text.begin() + a + 1, svg_text.begin() + b)));
            }
            a = svg_text.find("height");
            a = svg_text.find('=', a);
@@ -460,24 +491,39 @@
            b = svg_text.find('\"', a + 1);
            if(a != std::string::npos)
            {
- attr_text.append(" contentdepth=");
- attr_text.append(svg_text.begin() + a, svg_text.begin() + b + 1);
+ attributes.insert(attribute_map::value_type("contentdepth",
+ std::string(svg_text.begin() + a + 1, svg_text.begin() + b)));
            }
         }
 
         phrase << "<inlinemediaobject>";
 
- phrase << "<imageobject><imagedata ";
- phrase << attr_text;
- phrase << " fileref=\"";
- while (first != last)
- detail::print_char(*first++, phrase.get());
- phrase << "\"></imagedata></imageobject>";
+ phrase << "<imageobject><imagedata";
+
+ for(attribute_map::const_iterator
+ attr_first = attributes.begin(), attr_last = attributes.end();
+ attr_first != attr_last; ++attr_first)
+ {
+ phrase << " " << attr_first->first << "=\"";
+
+ for(std::string::const_iterator
+ first = attr_first->second.begin(),
+ last = attr_first->second.end();
+ first != last; ++first)
+ {
+ if (*first == '\\' && ++first == last) break;
+ detail::print_char(*first, phrase.get());
+ }
+
+ phrase << "\"";
+ }
+
+ phrase << "></imagedata></imageobject>";
 
         // Also add a textobject -- use the basename of the image file.
         // This will mean we get "alt" attributes of the HTML img.
         phrase << "<textobject><phrase>";
- detail::print_string(fs::basename(img_path), phrase.get());
+ detail::print_string(alt_text, phrase.get());
         phrase << "</phrase></textobject>";
 
         phrase << "</inlinemediaobject>";
@@ -512,21 +558,79 @@
         actions.template_info.push_back(std::string(first, last));
         actions.templates.add(
             actions.template_info[0]
- , boost::make_tuple(actions.template_info, first.get_position()));
+ , template_symbol(actions.template_info, first.get_position()));
         actions.template_info.clear();
     }
 
     namespace
     {
+ std::string::size_type find_bracket_end(std::string const& str, std::string::size_type pos)
+ {
+ unsigned int depth = 1;
+
+ while(depth > 0) {
+ pos = str.find_first_of("[]\\", pos);
+ if(pos == std::string::npos) return pos;
+
+ if(str[pos] == '\\')
+ {
+ pos += 2;
+ }
+ else
+ {
+ depth += (str[pos] == '[') ? 1 : -1;
+ ++pos;
+ }
+ }
+
+ return pos;
+ }
+
+ std::string::size_type find_first_seperator(std::string const& str)
+ {
+ if(qbk_version_n < 105) {
+ return str.find_first_of(" \t\r\n");
+ }
+ else {
+ std::string::size_type pos = 0;
+
+ while(true)
+ {
+ pos = str.find_first_of(" \t\r\n\\[", pos);
+ if(pos == std::string::npos) return pos;
+
+ switch(str[pos])
+ {
+ case '[':
+ pos = find_bracket_end(str, pos + 1);
+ break;
+ case '\\':
+ pos += 2;
+ break;
+ default:
+ return pos;
+ }
+ }
+ }
+ }
+
         bool break_arguments(
             std::vector<std::string>& template_info
           , std::vector<std::string> const& template_
           , boost::spirit::classic::file_position const& pos
         )
         {
- if (template_.size()-1 != template_info.size())
+ // Quickbook 1.4-: If there aren't enough parameters seperated by
+ // '..' then seperate the last parameter using
+ // whitespace.
+ // Quickbook 1.5+: If '..' isn't used to seperate the parameters
+ // then use whitespace to separate them
+ // (2 = template name + argument).
+
+ if (qbk_version_n < 105 || template_info.size() == 2)
             {
- while (template_.size()-1 > template_info.size())
+ // template_.size() - 1 because template_ also includes the body.
+ while (template_info.size() < template_.size()-1 )
                 {
                     // Try to break the last argument at the first space found
                     // and push it into the back of template_info. Do this
@@ -534,7 +638,7 @@
                     // arguments, or if there are no more spaces left.
 
                     std::string& str = template_info.back();
- std::string::size_type l_pos = str.find_first_of(" \t\r\n");
+ std::string::size_type l_pos = find_first_seperator(str);
                     if (l_pos == std::string::npos)
                         break;
                     std::string first(str.begin(), str.begin()+l_pos);
@@ -545,18 +649,18 @@
                     str = first;
                     template_info.push_back(second);
                 }
+ }
 
- if (template_.size()-1 != template_info.size())
- {
- detail::outerr(pos.file, pos.line)
- << "Invalid number of arguments passed. Expecting: "
- << template_.size()-2
- << " argument(s), got: "
- << template_info.size()-1
- << " argument(s) instead."
- << std::endl;
- return false;
- }
+ if (template_info.size() != template_.size()-1)
+ {
+ detail::outerr(pos.file, pos.line)
+ << "Invalid number of arguments passed. Expecting: "
+ << template_.size()-2
+ << " argument(s), got: "
+ << template_info.size()-1
+ << " argument(s) instead."
+ << std::endl;
+ return false;
             }
             return true;
         }
@@ -565,6 +669,7 @@
         get_arguments(
             std::vector<std::string>& template_info
           , std::vector<std::string> const& template_
+ , template_scope const& scope
           , boost::spirit::classic::file_position const& pos
           , quickbook::actions& actions
         )
@@ -578,7 +683,7 @@
                 std::vector<std::string> tinfo;
                 tinfo.push_back(*tpl);
                 tinfo.push_back(*arg);
- template_symbol template_(tinfo, pos);
+ template_symbol template_(tinfo, pos, &scope);
 
                 if (actions.templates.find_top_scope(*tpl))
                 {
@@ -665,6 +770,17 @@
             return;
         }
 
+ // The template arguments should have the scope that the template was
+ // called from, not the template's own scope.
+ //
+ // Note that for quickbook 1.4- this value is just ignored when the
+ // arguments are expanded.
+ template_scope const& call_scope = actions.templates.top_scope();
+
+ template_symbol const* symbol =
+ actions.templates.find(actions.template_info[0]);
+ BOOST_ASSERT(symbol);
+
         std::string result;
         actions.push(); // scope the actions' states
         {
@@ -672,6 +788,13 @@
                 actions.templates.find(actions.template_info[0]);
             BOOST_ASSERT(symbol);
 
+ // Quickbook 1.4-: When expanding the tempalte continue to use the
+ // current scope (the dynamic scope).
+ // Quickbook 1.5+: Use the scope the template was defined in
+ // (the static scope).
+ if (qbk_version_n >= 105)
+ actions.templates.set_parent_scope(*boost::get<2>(*symbol));
+
             std::vector<std::string> template_ = boost::get<0>(*symbol);
             boost::spirit::classic::file_position template_pos = boost::get<1>(*symbol);
 
@@ -693,7 +816,8 @@
             bool get_arg_result;
             std::vector<std::string>::const_iterator tpl;
             boost::tie(get_arg_result, tpl) =
- get_arguments(template_info, template_, pos, actions);
+ get_arguments(template_info, template_,
+ call_scope, pos, actions);
 
             if (!get_arg_result)
             {
@@ -790,10 +914,26 @@
         std::string::iterator first = actions.table_title.begin();
         std::string::iterator last = actions.table_title.end();
         bool has_title = first != last;
+
+ std::string table_id;
+ if(qbk_version_n >= 105) {
+ if(!actions.element_id.empty()) {
+ table_id = fully_qualified_id(actions.doc_id,
+ actions.qualified_section_id, actions.element_id);
+ }
+ else if(has_title) {
+ table_id = fully_qualified_id(actions.doc_id,
+ actions.qualified_section_id,
+ detail::make_identifier(first, last));
+ }
+ }
 
         if (has_title)
         {
- actions.out << "<table frame=\"all\">\n";
+ actions.out << "<table frame=\"all\"";
+ if(!table_id.empty())
+ actions.out << " id=\"" << table_id << "\"";
+ actions.out << ">\n";
             actions.out << "<title>";
             while (first != last)
                 detail::print_char(*first++, actions.out.get());
@@ -801,7 +941,10 @@
         }
         else
         {
- actions.out << "<informaltable frame=\"all\">\n";
+ actions.out << "<informaltable frame=\"all\"";
+ if(!table_id.empty())
+ actions.out << " id=\"" << table_id << "\"";
+ actions.out << ">\n";
         }
 
         actions.out << "<tgroup cols=\"" << actions.table_span << "\">\n";
@@ -868,8 +1011,9 @@
 
     void begin_section_action::operator()(iterator first, iterator last) const
     {
- if (section_id.empty())
- section_id = detail::make_identifier(first, last);
+ section_id = element_id.empty() ?
+ detail::make_identifier(first, last) :
+ element_id;
 
         if (section_level != 0)
             qualified_section_id += '.';
@@ -934,6 +1078,12 @@
             qualified_section_id.erase(n, std::string::npos);
         }
     }
+
+ void element_id_warning_action::operator()(iterator first, iterator) const
+ {
+ boost::spirit::classic::file_position const pos = first.get_position();
+ detail::outwarn(pos.file,pos.line) << "Empty id.\n";
+ }
 
     fs::path path_difference(fs::path const& outdir, fs::path const& path)
     {
@@ -1069,7 +1219,7 @@
         std::vector<std::string> tinfo;
         tinfo.push_back(id);
         tinfo.push_back(snippet);
- storage.push_back(boost::make_tuple(tinfo, first.get_position()));
+ storage.push_back(template_symbol(tinfo, first.get_position()));
 
         callout_id += callouts.size();
         callouts.clear();

Modified: branches/release/tools/quickbook/detail/actions.hpp
==============================================================================
--- branches/release/tools/quickbook/detail/actions.hpp (original)
+++ branches/release/tools/quickbook/detail/actions.hpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -36,14 +36,12 @@
     namespace fs = boost::filesystem;
     typedef position_iterator<std::string::const_iterator> iterator;
     typedef symbols<std::string> string_symbols;
+ typedef std::map<std::string, std::string> attribute_map;
 
     struct actions;
     extern tm* current_time; // the current time
     extern tm* current_gm_time; // the current UTC time
     extern bool debug_mode;
- extern unsigned qbk_major_version;
- extern unsigned qbk_minor_version;
- extern unsigned qbk_version_n; // qbk_major_version * 100 + qbk_minor_version
     extern std::vector<std::string> include_path;
 
     // forward declarations
@@ -372,17 +370,40 @@
 
         collector& phrase;
     };
+
+ struct attribute_action
+ {
+ // Handle image attributes
+
+ attribute_action(
+ attribute_map& attributes
+ , std::string& attribute_name)
+ : attributes(attributes)
+ , attribute_name(attribute_name) {}
+
+ void operator()(iterator first, iterator last) const;
+
+ attribute_map& attributes;
+ std::string& attribute_name;
+ };
 
     struct image_action
     {
         // Handles inline images
 
- image_action(collector& phrase)
- : phrase(phrase) {}
+ image_action(
+ collector& phrase
+ , attribute_map& attributes
+ , std::string& image_fileref)
+ : phrase(phrase)
+ , attributes(attributes)
+ , image_fileref(image_fileref) {}
 
         void operator()(iterator first, iterator last) const;
 
         collector& phrase;
+ attribute_map& attributes;
+ std::string& image_fileref;
     };
 
     struct markup_action
@@ -671,13 +692,15 @@
           , std::string& library_id
           , std::string& section_id
           , int& section_level
- , std::string& qualified_section_id)
+ , std::string& qualified_section_id
+ , std::string& element_id)
         : out(out)
         , phrase(phrase)
         , library_id(library_id)
         , section_id(section_id)
         , section_level(section_level)
- , qualified_section_id(qualified_section_id) {}
+ , qualified_section_id(qualified_section_id)
+ , element_id(element_id) {}
 
         void operator()(iterator first, iterator last) const;
 
@@ -687,6 +710,7 @@
         std::string& section_id;
         int& section_level;
         std::string& qualified_section_id;
+ std::string& element_id;
     };
 
     struct end_section_action
@@ -708,6 +732,11 @@
         std::string& qualified_section_id;
         int& error_count;
    };
+
+ struct element_id_warning_action
+ {
+ void operator()(iterator first, iterator last) const;
+ };
 
     struct xinclude_action
     {

Modified: branches/release/tools/quickbook/detail/actions_class.cpp
==============================================================================
--- branches/release/tools/quickbook/detail/actions_class.cpp (original)
+++ branches/release/tools/quickbook/detail/actions_class.cpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -52,6 +52,7 @@
         , source_mode("c++")
 
     // temporary or global state
+ , element_id()
         , table_title()
         , table_span(0)
         , table_header()
@@ -63,6 +64,9 @@
         , template_escape(false)
         , templates()
         , error_count(0)
+ , image_fileref()
+ , attribute_name()
+ , attributes()
 
     // actions
         , error(error_count)
@@ -93,7 +97,8 @@
         , tip(out, temp_para, tip_pre, tip_post)
         , plain_char(phrase)
         , raw_char(phrase)
- , image(phrase)
+ , attribute(attributes, attribute_name)
+ , image(phrase, attributes, image_fileref)
         , cond_phrase_pre(phrase, conditions, macro)
         , cond_phrase_post(phrase, conditions, macro)
 
@@ -166,7 +171,7 @@
         , end_cell(phrase, temp_para)
         , anchor(out)
 
- , begin_section(out, phrase, doc_id, section_id, section_level, qualified_section_id)
+ , begin_section(out, phrase, doc_id, section_id, section_level, qualified_section_id, element_id)
         , end_section(out, section_level, qualified_section_id, error_count)
         , xinclude(out, *this)
         , include(*this)

Modified: branches/release/tools/quickbook/detail/actions_class.hpp
==============================================================================
--- branches/release/tools/quickbook/detail/actions_class.hpp (original)
+++ branches/release/tools/quickbook/detail/actions_class.hpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -79,6 +79,7 @@
         std::stack<state_tuple> state_stack;
 
     // temporary or global state
+ std::string element_id;
         std::string table_title;
         unsigned table_span;
         std::string table_header;
@@ -91,6 +92,9 @@
         bool template_escape;
         template_stack templates;
         int error_count;
+ std::string image_fileref;
+ std::string attribute_name;
+ attribute_map attributes;
 
     // push/pop the states and the streams
         void push();
@@ -116,6 +120,7 @@
         phrase_action warning, caution, important, note, tip;
         plain_char_action plain_char;
         raw_char_action raw_char;
+ attribute_action attribute;
         image_action image;
         cond_phrase_action_pre cond_phrase_pre;
         cond_phrase_action_post cond_phrase_post;
@@ -191,6 +196,7 @@
 
         begin_section_action begin_section;
         end_section_action end_section;
+ element_id_warning_action element_id_warning;
         xinclude_action xinclude;
         include_action include;
         import_action import;

Modified: branches/release/tools/quickbook/detail/quickbook.cpp
==============================================================================
--- branches/release/tools/quickbook/detail/quickbook.cpp (original)
+++ branches/release/tools/quickbook/detail/quickbook.cpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -7,6 +7,7 @@
     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
     http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
+#include "./quickbook.hpp"
 #include "./actions_class.hpp"
 #include "../block.hpp"
 #include "../doc_info.hpp"
@@ -28,7 +29,7 @@
 #pragma warning(disable:4355)
 #endif
 
-#define QUICKBOOK_VERSION "Quickbook Version 1.4"
+#define QUICKBOOK_VERSION "Quickbook Version 1.5"
 
 namespace quickbook
 {

Copied: branches/release/tools/quickbook/detail/quickbook.hpp (from r55917, /trunk/tools/quickbook/detail/quickbook.hpp)
==============================================================================
--- /trunk/tools/quickbook/detail/quickbook.hpp (original)
+++ branches/release/tools/quickbook/detail/quickbook.hpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -25,22 +25,22 @@
             typedef bool type;
         };
         
- quickbook_range(unsigned min, unsigned max)
- : min(min), max(max) {}
+ quickbook_range(unsigned min_, unsigned max_)
+ : min_(min_), max_(max_) {}
         
         bool operator()() const {
- return qbk_version_n >= min && qbk_version_n < max;
+ return qbk_version_n >= min_ && qbk_version_n < max_;
         }
 
- unsigned min, max;
+ unsigned min_, max_;
     };
     
- inline quickbook_range qbk_since(unsigned min) {
- return quickbook_range(min, 999);
+ inline quickbook_range qbk_since(unsigned min_) {
+ return quickbook_range(min_, 999);
     }
     
- inline quickbook_range qbk_before(unsigned max) {
- return quickbook_range(0, max);
+ inline quickbook_range qbk_before(unsigned max_) {
+ return quickbook_range(0, max_);
     }
 }
 

Modified: branches/release/tools/quickbook/detail/template_stack.cpp
==============================================================================
--- branches/release/tools/quickbook/detail/template_stack.cpp (original)
+++ branches/release/tools/quickbook/detail/template_stack.cpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -18,14 +18,14 @@
         : scope(template_stack::parser(*this))
         , scopes()
     {
- scopes.push_front(template_symbols());
+ scopes.push_front(template_scope());
     }
     
     template_symbol* template_stack::find(std::string const& symbol) const
     {
- for (deque::const_iterator i = scopes.begin(); i != scopes.end(); ++i)
+ for (template_scope const* i = &*scopes.begin(); i; i = i->parent_scope)
         {
- if (template_symbol* ts = boost::spirit::classic::find(*i, symbol.c_str()))
+ if (template_symbol* ts = boost::spirit::classic::find(i->symbols, symbol.c_str()))
                 return ts;
         }
         return 0;
@@ -33,30 +33,46 @@
 
     template_symbol* template_stack::find_top_scope(std::string const& symbol) const
     {
- return boost::spirit::classic::find(scopes.front(), symbol.c_str());
+ return boost::spirit::classic::find(scopes.front().symbols, symbol.c_str());
     }
 
     template_symbols const& template_stack::top() const
     {
         BOOST_ASSERT(!scopes.empty());
+ return scopes.front().symbols;
+ }
+
+ template_scope const& template_stack::top_scope() const
+ {
+ BOOST_ASSERT(!scopes.empty());
         return scopes.front();
     }
     
+ // TODO: Should symbols defined by '[import]' use the current scope?
     void template_stack::add(std::string const& symbol, template_symbol const& ts)
     {
         BOOST_ASSERT(!scopes.empty());
- boost::spirit::classic::add(scopes.front(), symbol.c_str(), ts);
- }
+ boost::spirit::classic::add(scopes.front().symbols, symbol.c_str(),
+ boost::get<2>(ts) ? ts :
+ template_symbol(boost::get<0>(ts), boost::get<1>(ts), &top_scope()));
+ }
     
     void template_stack::push()
     {
- scopes.push_front(template_symbols());
+ template_scope const& old_front = scopes.front();
+ scopes.push_front(template_scope());
+ set_parent_scope(old_front);
     }
 
     void template_stack::pop()
     {
         scopes.pop_front();
     }
+
+ void template_stack::set_parent_scope(template_scope const& parent)
+ {
+ scopes.front().parent_scope = &parent;
+ }
 }
 
 

Modified: branches/release/tools/quickbook/detail/template_stack.hpp
==============================================================================
--- branches/release/tools/quickbook/detail/template_stack.hpp (original)
+++ branches/release/tools/quickbook/detail/template_stack.hpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -21,6 +21,8 @@
 
 namespace quickbook
 {
+ struct template_scope;
+
     // template symbols with N arguments are stored as follows:
     //
     // vector<std::string>
@@ -28,22 +30,40 @@
     // 1: template param name[0]
     // 2: template param name[1]
     // ...
- // template param name[N]
- // template body
     // N: template param name[N-1]
     // N+1: template body
     // file position
+ // template scope (only used for 1.5+, 1.4- uses the dynamic scope)
 
     typedef boost::tuple<
             std::vector<std::string>
- , boost::spirit::classic::file_position>
+ , boost::spirit::classic::file_position
+ , template_scope const*>
     template_symbol;
 
     typedef boost::spirit::classic::symbols<template_symbol> template_symbols;
+
+ // template scope
+ //
+ // 1.4-: parent_scope is the previous scope on the stack
+ // (the template's dynamic parent).
+ // 1.5+: parent_scope is the template's lexical parent.
+ //
+ // This means that a search along the parent_scope chain will follow the
+ // correct lookup chain for that version of quickboook.
+ //
+ // symbols contains the templates defined in this scope.
+
+ struct template_scope
+ {
+ template_scope() : parent_scope() {}
+ template_scope const* parent_scope;
+ template_symbols symbols;
+ };
 
     struct template_stack
     {
- typedef std::deque<template_symbols> deque;
+ typedef std::deque<template_scope> deque;
 
         struct parser
         {
@@ -59,10 +79,9 @@
                 // search all scopes for the longest matching symbol.
                 typename Scanner::iterator_t f = scan.first;
                 std::ptrdiff_t len = -1;
- for (template_stack::deque::const_iterator i = ts.scopes.begin();
- i != ts.scopes.end(); ++i)
+ for (template_scope const* i = &*ts.scopes.begin(); i; i = i->parent_scope)
                 {
- boost::spirit::classic::match<> m = i->parse(scan);
+ boost::spirit::classic::match<> m = i->symbols.parse(scan);
                     if (m.length() > len)
                         len = m.length();
                     scan.first = f;
@@ -79,10 +98,16 @@
         template_symbol* find(std::string const& symbol) const;
         template_symbol* find_top_scope(std::string const& symbol) const;
         template_symbols const& top() const;
+ template_scope const& top_scope() const;
+ // Add the given template symbol to the current scope.
+ // If it doesn't have a scope, sets the symbol's scope to the current scope.
         void add(std::string const& symbol, template_symbol const& ts);
         void push();
         void pop();
 
+ // Set the current scope's parent.
+ void set_parent_scope(template_scope const&);
+
         boost::spirit::classic::functor_parser<parser> scope;
 
     private:

Modified: branches/release/tools/quickbook/doc/quickbook.qbk
==============================================================================
--- branches/release/tools/quickbook/doc/quickbook.qbk (original)
+++ branches/release/tools/quickbook/doc/quickbook.qbk 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -1,6 +1,6 @@
 [article Quickbook
- [quickbook 1.4]
- [version 1.4]
+ [quickbook 1.5]
+ [version 1.5]
     [authors [de Guzman, Joel], [Niebler, Eric]]
     [copyright 2002 2004 2006 Joel de Guzman, Eric Niebler]
     [purpose /WikiWiki/ style documentation tool]
@@ -11,7 +11,7 @@
     ]
 ]
 
-[/ QuickBook Document version 1.4 ]
+[/ QuickBook Document version 1.5 ]
 [/ Sept 24, 2002 ]
 [/ Sept 2, 2004 ]
 [/ Feb 14, 2005 ]
@@ -164,6 +164,21 @@
 * __cond__. Ala C++ #ifdef.
 * Searching of included and imported files in an extensible search path with
   `--include-path` (`-I`) option.
+
+[h3 Version 1.5]
+
+* Support multiple copyright entrys in document info.
+* Improved SVG support.
+* \[globalref\] for referencing BoostBook <global> entities.
+* Fail on error.
+* Fix crash for templates with too many arguments or trailing space.
+* Improved handling of unexpected characters in code blocks.
+* Improved handling of unmatched escape in code blocks.
+* Support for python snippets.
+* `teletype` source mode.
+* Use static scoping in templates, should be a lot more intuitive.
+* Accept a space between `section:` and the section id.
+* Support table ids.
 
 [endsect]
 
@@ -688,7 +703,7 @@
 
 [pre'''
 [document-type The Document Title
- [quickbook 1.3]
+ [quickbook 1.5]
     [version 1.0]
     [id the_document_name]
     [dirname the_document_dir]
@@ -715,7 +730,7 @@
 * reference
 * set
 
-quickbook 1.3 declares the version of quickbook the document is written for.
+quickbook 1.5 declares the version of quickbook the document is written for.
 In its absence, version 1.1 is assumed.
 
 =version=, =id=, =dirname=, =copyright=, =purpose=, =category=, =authors=,
@@ -1377,9 +1392,9 @@
 
 [heading Simple Arguments]
 
-As mentioned, arguments are separated by the double dot [^".."]. If there
-are less arguments passed than expected, QuickBook attempts to break the
-last argument into two or more arguments following this logic:
+As mentioned, arguments are separated by the double dot [^".."]. Alternatively,
+if the double dot isn't used and more than one argument is expected, QuickBook
+uses whitespace to separate the arguments, following this logic:
 
 * Break the last argument into two, at the first space found ([^'', '\\n',
   \\t' or '\\r']).
@@ -1415,18 +1430,12 @@
 
 The arguments being: "w", "x", "y" and "z trail".
 
-It should be obvious now that for simple arguments with no spaces, we can
-get by without separating the arguments with [^".."] separators. It is
-possible to combine [^".."] separators with the argument passing
-simplification presented above. Example:
-
-[pre'''
-[simple what do you think ..m a n?]
-''']
-
-will produce:
-
-[simple what do you think ..m a n?]
+[caution The behavior described here is for QuickBook 1.5. In older versions you
+could use both the double dot and whitespace as separators in the same template
+call. If your document is marked up as an older version, it will use the old
+behavior, which is described in the
+[@http://www.boost.org/doc/libs/1_40_0/doc/html/quickbook/syntax.html#quickbook.syntax.block.templates.simple_arguments
+QuickBook 1.4 documentation].]
 
 [heading Punctuation Templates]
 
@@ -1483,7 +1492,7 @@
 [section Tables]
 
 [pre'''
-[table A Simple Table
+[table:id A Simple Table
     [[Heading 1] [Heading 2] [Heading 3]]
     [[R0-C0] [R0-C1] [R0-C2]]
     [[R1-C0] [R1-C1] [R1-C2]]
@@ -1493,7 +1502,7 @@
 
 will generate:
 
-[table A Simple Table
+[table:id A Simple Table
     [[Heading 1] [Heading 2] [Heading 3]]
     [[R0-C0] [R0-C1] [R0-C2]]
     [[R2-C0] [R2-C1] [R2-C2]]
@@ -1501,10 +1510,24 @@
 ]
 
 The table title is optional. The first row of the table is automatically
-treated as the table header; that is, it is wrapped in
-[^<thead>...</thead>] XML tags. Note that unlike the original QuickDoc, the
-columns are nested in [ cells... ]. The syntax is free-format and allows
-big cells to be formatted nicely. Example:
+treated as the table header; that is, it is wrapped in [^<thead>...</thead>]
+XML tags. Note that unlike the original QuickDoc, the columns are nested in
+[cells... ].
+
+Giving tables an id is a new feature for quickbook 1.5 onwards. As with
+sections, the id is optional. If the table has a title but no id, an id will
+be generated from the title. The table above can be linked to using:
+
+[pre'''
+[link quickbook.syntax.block.tables.id link to table]
+''']
+
+which will generate:
+
+[link quickbook.syntax.block.tables.id link to table]
+
+The syntax is free-format and allows big cells to be formatted
+nicely. Example:
 
 [pre'''
 [table Table with fat cells

Modified: branches/release/tools/quickbook/doc_info.hpp
==============================================================================
--- branches/release/tools/quickbook/doc_info.hpp (original)
+++ branches/release/tools/quickbook/doc_info.hpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -11,6 +11,7 @@
 #define BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
 
 #include "./phrase.hpp"
+#include "./detail/quickbook.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_actor.hpp>
 #include <boost/spirit/include/classic_loops.hpp>
@@ -19,8 +20,6 @@
 namespace quickbook
 {
     using namespace boost::spirit::classic;
- extern unsigned qbk_major_version;
- extern unsigned qbk_minor_version;
 
     template <typename Actions>
     struct doc_info_grammar

Modified: branches/release/tools/quickbook/phrase.hpp
==============================================================================
--- branches/release/tools/quickbook/phrase.hpp (original)
+++ branches/release/tools/quickbook/phrase.hpp 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -10,11 +10,13 @@
 #if !defined(BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP)
 #define BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
 
+#include "./detail/quickbook.hpp"
 #include "detail/utils.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_confix.hpp>
 #include <boost/spirit/include/classic_chset.hpp>
 #include <boost/spirit/include/classic_assign_actor.hpp>
+#include <boost/spirit/include/classic_clear_actor.hpp>
 #include <boost/spirit/include/classic_if.hpp>
 
 namespace quickbook
@@ -116,13 +118,6 @@
>> actions.macro [actions.do_macro]
                     ;
 
- template_args =
- template_arg [push_back_a(actions.template_info)]
- >> *(
- ".." >> template_arg [push_back_a(actions.template_info)]
- )
- ;
-
                 static const bool true_ = true;
                 static const bool false_ = false;
 
@@ -148,12 +143,46 @@
>> eps_p(']')
                     ;
 
- brackets =
- '[' >> +template_arg >> ']'
+ template_args =
+ if_p(qbk_since(105u)) [
+ template_args_1_5
+ ].else_p [
+ template_args_1_4
+ ]
+ ;
+
+ 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_arg_1_4 =
+ +(brackets_1_4 | (anychar_p - (str_p("..") | ']')))
                     ;
 
- template_arg =
- +(brackets | (anychar_p - (str_p("..") | ']')))
+ brackets_1_4 =
+ '[' >> +template_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_arg_1_5 =
+ +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p("..") | '[' | ']')))
+ ;
+
+ template_inner_arg_1_5 =
+ +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p('[') | ']')))
+ ;
+
+ brackets_1_5 =
+ '[' >> +template_inner_arg_1_5 >> ']'
                     ;
 
                 inline_code =
@@ -262,11 +291,29 @@
                     ;
 
                 image =
- '$' >> blank
- >> (*(anychar_p -
- phrase_end)) [actions.image]
+ '$' >> blank [clear_a(actions.attributes)]
+ >> if_p(qbk_since(105u)) [
+ (+(
+ *space_p
+ >> +(anychar_p - (space_p | phrase_end | '['))
+ )) [assign_a(actions.image_fileref)]
+ >> hard_space
+ >> *(
+ '['
+ >> (*(alnum_p | '_')) [assign_a(actions.attribute_name)]
+ >> space
+ >> (*(anychar_p - (phrase_end | '[')))
+ [actions.attribute]
+ >> ']'
+ >> space
+ )
+ ].else_p [
+ (*(anychar_p -
+ phrase_end)) [assign_a(actions.image_fileref)]
+ ]
+ >> eps_p(']') [actions.image]
                     ;
-
+
                 url =
                         '@'
>> (*(anychar_p -
@@ -420,10 +467,12 @@
                             memberref, enumref, macroref, headerref, conceptref, globalref,
                             anchor, link, hard_space, eol, inline_code, simple_format,
                             simple_bold, simple_italic, simple_underline,
- simple_teletype, source_mode, template_, template_arg,
+ simple_teletype, source_mode, template_,
                             quote, code_block, footnote, replaceable, macro,
- brackets, template_args, dummy_block, cond_phrase,
- macro_identifier
+ dummy_block, cond_phrase, macro_identifier, template_args,
+ template_args_1_4, template_arg_1_4, brackets_1_4,
+ template_args_1_5, template_arg_1_5,
+ template_inner_arg_1_5, brackets_1_5
                             ;
 
             rule<Scanner> const&

Modified: branches/release/tools/quickbook/test/Jamfile.v2
==============================================================================
--- branches/release/tools/quickbook/test/Jamfile.v2 (original)
+++ branches/release/tools/quickbook/test/Jamfile.v2 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -22,17 +22,25 @@
     [ quickbook-test escape ]
     [ quickbook-test templates ]
     [ quickbook-test templates_1_4 ]
+ [ quickbook-test templates_1_5 ]
     [ quickbook-test xinclude ]
     [ quickbook-test import ]
+ [ quickbook-test section_1_4 ]
+ [ quickbook-test section_1_5 ]
+ [ quickbook-test heading ]
+ [ quickbook-test table_1_5 ]
+ [ quickbook-test image_1_5 ]
     [ quickbook-fail-test fail-include ]
     [ quickbook-fail-test fail-import ]
     [ quickbook-fail-test fail-template-arguments1 ]
     [ quickbook-fail-test fail-template-arguments2 ]
+ [ quickbook-fail-test fail-template-arguments3 ]
     [ quickbook-fail-test fail-cpp-mismatched-escape ]
     [ quickbook-fail-test fail-python-mismatched-escape ]
     [ quickbook-fail-test fail-post-process ]
     [ quickbook-fail-test fail-parse-error1 ]
     [ quickbook-fail-test fail-parse-error2 ]
+ [ quickbook-fail-test fail-template-lookup1 ]
     ;
 
 

Copied: branches/release/tools/quickbook/test/table_1_5.gold (from r55917, /trunk/tools/quickbook/test/table_1_5.gold)
==============================================================================
--- /trunk/tools/quickbook/test/table_1_5.gold (original)
+++ branches/release/tools/quickbook/test/table_1_5.gold 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -4,7 +4,7 @@
   <title>Table 1.5</title>
   <articleinfo>
   </articleinfo>
- <table frame="all" id="table1"> <title>Table 1</title>
+ <table frame="all" id="table_1_5.table1"> <title>Table 1</title>
   <tgroup cols="1">
     <thead>
       <row>
@@ -25,7 +25,7 @@
       </row>
     </tbody>
   </tgroup>
- </table> <table frame="all" id="table_2"> <title>Table 2</title>
+ </table> <table frame="all" id="table_1_5.table_2"> <title>Table 2</title>
   <tgroup cols="1">
     <thead>
       <row>
@@ -69,7 +69,7 @@
       </tbody>
     </tgroup>
   </informaltable>
- <informaltable frame="all" id="table4">
+ <informaltable frame="all" id="table_1_5.table4">
     <tgroup cols="1">
       <thead>
         <row>
@@ -91,7 +91,7 @@
       </tbody>
     </tgroup>
   </informaltable>
- <table frame="all" id="_table5_"> <title>-table5-</title>
+ <table frame="all" id="table_1_5._table5_"> <title>-table5-</title>
   <tgroup cols="1">
     <thead>
       <row>
@@ -113,4 +113,29 @@
     </tbody>
   </tgroup>
   </table>
+ <section id="table_1_5.section1">
+ <title><link linkend="table_1_5.section1"> Section 1</link></title> <table frame="all"
+ id="table_1_5.section1.table1"> <title>Table 1</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
 </article>

Copied: branches/release/tools/quickbook/test/table_1_5.quickbook (from r55917, /trunk/tools/quickbook/test/table_1_5.quickbook)
==============================================================================
--- /trunk/tools/quickbook/test/table_1_5.quickbook (original)
+++ branches/release/tools/quickbook/test/table_1_5.quickbook 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -1,5 +1,6 @@
 [article Table 1.5
     [quickbook 1.5]
+ [id table_1_5]
 ]
 
 [table:table1 Table 1
@@ -25,4 +26,13 @@
 [table:-table5-
     [[Heading]]
     [[cell]]
-]
\ No newline at end of file
+]
+
+[section:section1 Section 1]
+
+[table:table1 Table 1
+ [[Heading]]
+ [[cell]]
+]
+
+[endsect]
\ No newline at end of file

Modified: branches/release/tools/quickbook/test/templates_1_4.gold
==============================================================================
--- branches/release/tools/quickbook/test/templates_1_4.gold (original)
+++ branches/release/tools/quickbook/test/templates_1_4.gold 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -11,4 +11,13 @@
   <para>
     old
   </para>
+ <para>
+ {1-2} {1-2} {1-2 3 4} {1 2-3 4} {1 2 3-4} {[1-2} {1..2-3} {1..2-3}
+ </para>
+ <para>
+ {[binary 1 2- {1 2-y}} 4]
+ </para>
+ <para>
+ {1-2-3} {1-2-3} {1-2-3 4} {1 2-3-4} {[1-2-3}
+ </para>
 </article>

Modified: branches/release/tools/quickbook/test/templates_1_4.quickbook
==============================================================================
--- branches/release/tools/quickbook/test/templates_1_4.quickbook (original)
+++ branches/release/tools/quickbook/test/templates_1_4.quickbook 2009-10-12 15:54:36 EDT (Mon, 12 Oct 2009)
@@ -13,4 +13,26 @@
 
 [template y new]
 [template foo3[a y] [a]]
-[foo3 [y] old]
\ No newline at end of file
+[foo3 [y] old]
+
+[/ 1.4 template arguments]
+
+[template binary[x y] {[x]-[y]}]
+[binary 1..2] [/ {1-2} ]
+[binary 1 2] [/ {1-2} ]
+[binary 1..2 3 4] [/ {1-2 3 4} ]
+[binary 1 2..3 4] [/ {1 2-3 4} ]
+[binary 1 2 3..4] [/ {1 2 3-4} ]
+[binary [1..2] [/ {(1-2} but with a square bracket ]
+[binary 1.\.2..3] [/ {1..2-3} ]
+[binary 1.\.2 3] [/ {1..2-3} ]
+
+[binary [binary 1 2..3] 4] [/ {[binary 1 2- {1 2-y}} 4] ]
+[/ This is obviously wrong, but I don't feel up to fixing it at the moment.]
+
+[template ternary[x y z] {[x]-[y]-[z]}]
+[ternary 1..2..3] [/ {1-2-3} ]
+[ternary 1 2 3] [/ {1-2-3} ]
+[ternary 1..2 3 4] [/ {1-2-3 4} ]
+[ternary 1 2..3 4] [/ {1 2-3-4} ]
+[ternary [1..2..3] [/ {(1-2-3} (but with a square bracket) ]
\ 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