$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r73337 - in trunk/tools/quickbook: src test test/doc-info test/unit
From: dnljms_at_[hidden]
Date: 2011-07-24 16:40:43
Author: danieljames
Date: 2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
New Revision: 73337
URL: http://svn.boost.org/trac/boost/changeset/73337
Log:
Quickbook: Use an id generator to aviod collisions.
Added:
   trunk/tools/quickbook/src/id_generator.cpp   (contents, props changed)
   trunk/tools/quickbook/src/id_generator.hpp   (contents, props changed)
Text files modified: 
   trunk/tools/quickbook/src/Jamfile.v2                     |     1                                         
   trunk/tools/quickbook/src/actions.cpp                    |   135 ++++++++++++++++++++++++--------------- 
   trunk/tools/quickbook/src/actions_class.cpp              |     8 +-                                      
   trunk/tools/quickbook/src/actions_class.hpp              |     7 -                                       
   trunk/tools/quickbook/src/doc_info_actions.cpp           |     8 +                                       
   trunk/tools/quickbook/src/fwd.hpp                        |     1                                         
   trunk/tools/quickbook/src/quickbook.cpp                  |    24 +++---                                  
   trunk/tools/quickbook/src/template_stack.cpp             |     5                                         
   trunk/tools/quickbook/src/template_stack.hpp             |    20 +++++                                   
   trunk/tools/quickbook/test/anchor.gold                   |    10 +-                                      
   trunk/tools/quickbook/test/blocks.gold                   |     8 +-                                      
   trunk/tools/quickbook/test/callouts.gold                 |    32 ++++----                                
   trunk/tools/quickbook/test/code-block.gold               |     2                                         
   trunk/tools/quickbook/test/doc-info/duplicates-1.1.gold  |     2                                         
   trunk/tools/quickbook/test/doc-info/duplicates-1.5.gold  |     2                                         
   trunk/tools/quickbook/test/doc-info/source-mode-1.4.gold |     2                                         
   trunk/tools/quickbook/test/doc-info/source-mode-1.5.gold |     2                                         
   trunk/tools/quickbook/test/doc-info/source-mode-1.6.gold |     2                                         
   trunk/tools/quickbook/test/heading.gold                  |     6                                         
   trunk/tools/quickbook/test/heading_1_6.gold              |     6                                         
   trunk/tools/quickbook/test/identifier_1_5.gold           |     2                                         
   trunk/tools/quickbook/test/identifier_1_6.gold           |     2                                         
   trunk/tools/quickbook/test/quickbook-manual.gold         |    62 +++++++++---------                      
   trunk/tools/quickbook/test/table_1_3.gold                |    14 ++--                                    
   trunk/tools/quickbook/test/template-section.gold         |     2                                         
   trunk/tools/quickbook/test/unicode-escape.gold           |     2                                         
   trunk/tools/quickbook/test/unit/Jamfile.v2               |     2                                         
   trunk/tools/quickbook/test/utf-8-bom.gold                |     2                                         
   trunk/tools/quickbook/test/utf-8.gold                    |     2                                         
   trunk/tools/quickbook/test/xml-escape_1_2.gold           |     2                                         
   trunk/tools/quickbook/test/xml-escape_1_5.gold           |     2                                         
   31 files changed, 217 insertions(+), 160 deletions(-)
Modified: trunk/tools/quickbook/src/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/src/Jamfile.v2	(original)
+++ trunk/tools/quickbook/src/Jamfile.v2	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -28,6 +28,7 @@
     utils.cpp
     input_path.cpp
     values.cpp
+    id_generator.cpp
     post_process.cpp
     collector.cpp
     template_stack.cpp
Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp	(original)
+++ trunk/tools/quickbook/src/actions.cpp	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -29,6 +29,7 @@
 #include "input_path.hpp"
 #include "block_tags.hpp"
 #include "phrase_tags.hpp"
+#include "id_generator.hpp"
 
 namespace quickbook
 {
@@ -58,12 +59,23 @@
                 it != end; ++it)
             {
                 tgt << "<anchor id=\"";
-                detail::print_string(*it, tgt.get());
+                detail::print_string(
+                    actions.ids.add(*it, id_generator::explicit_id),
+                    tgt.get());
                 tgt << "\"/>";
             }
             
             actions.anchors.clear();
-        }    
+        }
+        
+        std::string add_anchor(quickbook::actions& actions,
+                std::string const& id,
+                id_generator::categories category = id_generator::explicit_id)
+        {
+            std::string placeholder = actions.ids.add(id, category);
+            actions.anchors.push_back(placeholder);
+            return placeholder;
+        }
     }
 
     void list_action(quickbook::actions&, value);
@@ -268,8 +280,7 @@
         value_consumer values = phrase;
         actions.phrase
             << "<footnote id=\""
-            << actions.doc_id << ".f"
-            << boost::lexical_cast<std::string>(actions.footnote_id_count++)
+            << actions.ids.add(actions.doc_id + ".f", id_generator::numbered)
             << "\"><para>"
             << values.consume().get_boostbook()
             << "</para></footnote>";
@@ -347,16 +358,22 @@
             level = heading_list.get_tag() - block_tags::heading1 + 1;
         }
 
-        std::string anchor;
         std::string linkend;
 
         if (!generic && qbk_version_n < 103) // version 1.2 and below
         {
-            anchor = actions.section_id + '.' +
-                detail::make_identifier(content.get_boostbook());
+            add_anchor(actions,
+                actions.section_id + '.' +
+                    detail::make_identifier(content.get_boostbook()),
+                id_generator::generated);
         }
         else
         {
+            id_generator::categories category =
+                !element_id.empty() ?
+                    id_generator::explicit_id :
+                    id_generator::generated;
+
             std::string id =
                 !element_id.empty() ?
                     element_id.get_quickbook() :
@@ -366,15 +383,20 @@
                             content.get_boostbook()
                     );
 
-            linkend = anchor =
-                fully_qualified_id(actions.doc_id, actions.qualified_section_id, id);
+            linkend = add_anchor(actions,
+                fully_qualified_id(actions.doc_id,
+                    actions.qualified_section_id, id),
+                category);
         }
 
-        actions.anchors.push_back(anchor);
-        write_anchors(actions, actions.out);
-        
+        write_anchors(actions, actions.out);        
         write_bridgehead(actions.out, level,
-            content.get_boostbook(), anchor + "-heading", linkend);
+            content.get_boostbook(),
+            actions.ids.add(
+                fully_qualified_id(actions.doc_id,
+                    actions.qualified_section_id, "h"),
+                id_generator::numbered),
+            linkend);
     }
 
     void simple_phrase_action::operator()(char mark) const
@@ -576,7 +598,7 @@
         if(actions.suppress) return;
         
         value_consumer values = anchor;
-        actions.anchors.push_back(values.consume().get_quickbook());
+        add_anchor(actions, values.consume().get_quickbook());
         values.finish();
     }
 
@@ -1088,8 +1110,7 @@
             while (arg != args.end())
             {
                 if (!actions.templates.add(
-                        template_symbol(*tpl, empty_params, arg->content,
-                            arg->filename, &scope)))
+                        template_symbol(*tpl, empty_params, *arg, &scope)))
                 {
                     detail::outerr(actions.filename, pos.line)
                         << "Duplicate Symbol Found" << std::endl;
@@ -1114,7 +1135,8 @@
             //
             // Note: this is now done in the grammar.
 
-            if (escape)
+            // TODO: For escape, should this be surrounded in escape comments?
+            if (body.type == template_body::raw_output || escape)
             {
                 //  escape the body of the template
                 //  we just copy out the literal body
@@ -1162,6 +1184,7 @@
 
         std::string identifier = values.consume(template_tags::identifier).get_quickbook();
 
+        std::vector<std::string> callout_ids;
         std::vector<template_body> args;
 
         BOOST_FOREACH(value arg, values)
@@ -1238,18 +1261,25 @@
 
                 for(unsigned int i = 0; i < size; ++i)
                 {
-                    std::string callout_id = actions.doc_id +
-                        boost::lexical_cast<std::string>(actions.callout_id_count + i);
+                    std::string callout_id1 =
+                        actions.ids.add(
+                            actions.doc_id + ".c",
+                            id_generator::numbered);
+                    std::string callout_id2 =
+                        actions.ids.add(
+                            actions.doc_id + ".c",
+                            id_generator::numbered);
 
                     std::string code;
-                    code += "'''";
-                    code += "<co id=\"" + callout_id + "co\" ";
-                    code += "linkends=\"" + callout_id + "\" />";
-                    code += "'''";
+                    code += "<co id=\"" + callout_id1 + "\" ";
+                    code += "linkends=\"" + callout_id2 + "\" />";
 
+                    // TODO: This isn't a qbk_value...
                     args.push_back(template_body(
                         qbk_value(code, pos, template_tags::phrase),
-                        actions.filename));
+                        actions.filename, template_body::raw_output));
+                    callout_ids.push_back(callout_id1);
+                    callout_ids.push_back(callout_id2);
                 }
             }
 
@@ -1307,10 +1337,11 @@
         {
             BOOST_ASSERT(phrase.empty());
             block += "<calloutlist>";
+            int i = 0;
             BOOST_FOREACH(value c, symbol->callouts)
             {
-                std::string callout_id = actions.doc_id +
-                    boost::lexical_cast<std::string>(actions.callout_id_count++);
+                std::string callout_id1 = callout_ids[i++];
+                std::string callout_id2 = callout_ids[i++];
 
                 std::string callout_value;
                 actions.push();
@@ -1332,8 +1363,8 @@
                     return;
                 }
                 
-                block += "<callout arearefs=\"" + callout_id + "co\" ";
-                block += "id=\"" + callout_id + "\">";
+                block += "<callout arearefs=\"" + callout_id1 + "\" ";
+                block += "id=\"" + callout_id2 + "\">";
                 block += callout_value;
                 block += "</callout>";
             }
@@ -1430,19 +1461,25 @@
         std::string table_id;
         if(qbk_version_n >= 105) {
             if(!element_id.empty()) {
-                table_id = fully_qualified_id(actions.doc_id,
-                    actions.qualified_section_id, element_id);
+                table_id = actions.ids.add(
+                    fully_qualified_id(actions.doc_id,
+                        actions.qualified_section_id, element_id),
+                    id_generator::explicit_id);
             }
             else if(has_title) {
-                table_id = fully_qualified_id(actions.doc_id,
-                    actions.qualified_section_id,
-                    detail::make_identifier(title));
+                table_id = actions.ids.add(
+                    fully_qualified_id(actions.doc_id,
+                        actions.qualified_section_id,
+                        detail::make_identifier(title)),
+                    id_generator::generated);
             }
         }
         else if (has_title)
         {
-            table_id = actions.doc_id + ".t" +
-                boost::lexical_cast<std::string>(actions.table_id_count++);
+            table_id = actions.ids.add(
+                    fully_qualified_id(actions.doc_id,
+                        actions.qualified_section_id, "t"),
+                id_generator::numbered);
         }
 
         // Emulating the old behaviour which used the width of the final
@@ -1533,23 +1570,18 @@
         actions.qualified_section_id += actions.section_id;
         ++actions.section_level;
 
-        actions::string_list saved_anchors;
-        saved_anchors.swap(actions.anchors);
-
-        if (qbk_version_n < 103) // version 1.2 and below
-        {
-            actions.out << "\n<section id=\""
-                << actions.doc_id << "." << actions.section_id << "\">\n";
-        }
-        else // version 1.3 and above
-        {
-            actions.out << "\n<section id=\"" << actions.doc_id
-                << "." << actions.qualified_section_id << "\">\n";
-        }
+        // TODO: This could be awkward if there's a clash, possibly
+        // needs another category, between explicit and generated.
+        std::string full_id = actions.ids.add(
+            qbk_version_n < 103 ?
+                actions.doc_id + "." + actions.section_id :
+                actions.doc_id + "." + actions.qualified_section_id,
+            !element_id.empty() ?
+                id_generator::explicit_id :
+                id_generator::generated);
 
+        actions.out << "\n<section id=\"" << full_id << "\">\n";
         actions.out << "<title>";
-
-        actions.anchors.swap(saved_anchors);
         write_anchors(actions, actions.out);
 
         if (qbk_version_n < 103) // version 1.2 and below
@@ -1558,8 +1590,7 @@
         }
         else // version 1.3 and above
         {
-            actions.out << "<link linkend=\"" << actions.doc_id
-                << "." << actions.qualified_section_id << "\">"
+            actions.out << "<link linkend=\"" << full_id << "\">"
                 << content.get_boostbook()
                 << "</link>"
                 ;
Modified: trunk/tools/quickbook/src/actions_class.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.cpp	(original)
+++ trunk/tools/quickbook/src/actions_class.cpp	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -19,7 +19,8 @@
 
 namespace quickbook
 {
-    actions::actions(fs::path const& filein_, fs::path const& xinclude_base_, string_stream& out_)
+    actions::actions(fs::path const& filein_, fs::path const& xinclude_base_,
+            string_stream& out_, id_generator& ids)
         : grammar_()
 
     // header info
@@ -55,9 +56,6 @@
         , source_mode("c++")
 
     // temporary or global state
-        , callout_id_count(0)
-        , footnote_id_count(0)
-        , table_id_count(0)
         , template_depth(0)
         , templates()
         , error_count(0)
@@ -65,6 +63,8 @@
         , no_eols(true)
         , suppress(false)
         , warned_about_breaks(false)
+        , context(0)
+        , ids(ids)
 
     // actions
         , element(*this)
Modified: trunk/tools/quickbook/src/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.hpp	(original)
+++ trunk/tools/quickbook/src/actions_class.hpp	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -24,7 +24,8 @@
 
     struct actions
     {
-        actions(fs::path const& filein_, fs::path const& xinclude_base, string_stream& out_);
+        actions(fs::path const& filein_, fs::path const& xinclude_base, string_stream& out_,
+                id_generator&);
 
     private:
         boost::scoped_ptr<quickbook_grammar> grammar_;
@@ -93,9 +94,6 @@
         std::stack<string_symbols> macro_stack;
 
     // temporary or global state
-        int                     callout_id_count;
-        int                     footnote_id_count;
-        int                     table_id_count;
         int                     template_depth;
         template_stack          templates;
         int                     error_count;
@@ -104,6 +102,7 @@
         bool                    suppress;
         bool                    warned_about_breaks;
         int                     context;
+        id_generator&           ids;
 
     // push/pop the states and the streams
         void copy_macros_for_write();
Modified: trunk/tools/quickbook/src/doc_info_actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/doc_info_actions.cpp	(original)
+++ trunk/tools/quickbook/src/doc_info_actions.cpp	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -17,6 +17,7 @@
 #include "input_path.hpp"
 #include "actions_class.hpp"
 #include "doc_info_tags.hpp"
+#include "id_generator.hpp"
 
 namespace quickbook
 {
@@ -232,7 +233,7 @@
             << "     \"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd\">\n"
             << '<' << actions.doc_type << "\n"
             << "    id=\""
-            << actions.doc_id
+            << actions.ids.add(actions.doc_id, id_generator::explicit_id)
             << "\"\n";
         
         if(!lang.empty())
@@ -325,7 +326,10 @@
 
         if (!license.empty())
         {
-            tmp << "    <legalnotice id=\"legal." << actions.doc_id << "\">\n"
+            tmp << "    <legalnotice id=\""
+                << actions.ids.add(actions.doc_id + ".legal",
+                    id_generator::generated)
+                << "\">\n"
                 << "      <para>\n"
                 << "        " << doc_info_output(license, 103) << "\n"
                 << "      </para>\n"
Modified: trunk/tools/quickbook/src/fwd.hpp
==============================================================================
--- trunk/tools/quickbook/src/fwd.hpp	(original)
+++ trunk/tools/quickbook/src/fwd.hpp	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -18,6 +18,7 @@
     struct actions;
     struct quickbook_grammar;
     struct collector;
+    struct id_generator;
 
     typedef position_iterator<std::string::const_iterator> iterator;
 
Added: trunk/tools/quickbook/src/id_generator.cpp
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/src/id_generator.cpp	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -0,0 +1,349 @@
+/*=============================================================================
+    Copyright (c) 2011 Daniel James
+
+    Use, modification and distribution is subject to the Boost Software
+    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+    http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include "id_generator.hpp"
+#include "markups.hpp"
+#include "phrase_tags.hpp"
+#include <boost/lexical_cast.hpp>
+#include <algorithm>
+#include <vector>
+
+namespace quickbook
+{
+    // string_ref
+
+    class string_ref
+    {
+    public:
+        typedef std::string::const_iterator iterator;
+
+    private:
+        iterator begin_, end_;
+
+    public:
+        string_ref() : begin_(), end_() {}
+
+        explicit string_ref(iterator b, iterator e)
+            : begin_(b), end_(e) {}
+
+        explicit string_ref(std::string const& x)
+            : begin_(x.begin()), end_(x.end()) {}
+
+        iterator begin() const { return begin_; }
+        iterator end() const { return end_; }
+        
+        std::size_t size() const
+        {
+            return static_cast<std::size_t>(end_ - begin_);
+        }    
+    };
+
+    bool operator==(string_ref const& x, string_ref const& y);
+    bool operator<(string_ref const& x, string_ref const& y);
+
+    inline bool operator==(string_ref const& x, std::string const& y)
+    {
+        return x == string_ref(y);
+    }
+
+    inline bool operator==(std::string const& x, string_ref const& y)
+    {
+        return string_ref(x) == y;
+    }
+
+    inline bool operator<(string_ref const& x, std::string const& y)
+    {
+        return x < string_ref(y);
+    }
+
+    inline bool operator<(std::string const& x, string_ref const& y)
+    {
+        return string_ref(x) < y;
+    }
+
+    bool operator==(string_ref const& x, string_ref const& y)
+    {
+        return x.size() == y.size() &&
+            std::equal(x.begin(), x.end(), y.begin());
+    }
+
+    bool operator<(string_ref const& x, string_ref const& y)
+    {
+        return std::lexicographical_compare(
+            x.begin(), x.end(), y.begin(), y.end());
+    }
+
+    // id_generator
+
+    struct id_generator::id
+    {
+        id()
+          : category(id_generator::default_category),
+            used(false),
+            count(0) {}
+    
+        id_generator::categories category;
+
+        // These are updated when generating ids
+        bool used;
+        int count;
+    };
+
+    struct id_generator::placeholder
+    {
+        typedef std::pair<std::string const, id_generator::id> id_pair;
+
+        placeholder(id_generator::categories category, id_pair& id)
+          : category(category),
+            id(id),
+            final_id() {}
+    
+        id_generator::categories category;
+        id_pair& id;
+        std::string final_id; // Set in the second pass.
+    };
+    
+    id_generator::id_generator()
+    {
+    }
+
+    id_generator::~id_generator()
+    {
+    }
+
+    std::string id_generator::add(
+            std::string const& value,
+            id_generator::categories category)
+    {
+        std::string result;
+        id_generator::id& id = ids_[value];
+
+        // Doesn't check if explicit ids collide, could probably be a warning.
+        if (category == explicit_id)
+        {
+            id.category = category;
+            id.used = true;
+            result = value;
+        }
+        else
+        {
+            if (category < id.category) id.category = category;
+
+            // '$' can't appear in quickbook ids, so use it indicate a
+            // placeholder id.
+            result = "$" +
+                boost::lexical_cast<std::string>(placeholders_.size());
+            placeholders_.push_back(
+                id_generator::placeholder(category, *ids_.find(value)));
+        }
+
+        return result;
+    }
+
+    string_ref id_generator::get(string_ref value)
+    {
+        // If this isn't a placeholder id. 
+        if (value.size() <= 1 || *value.begin() != '$')
+            return value;
+
+        id_generator::placeholder& placeholder = placeholders_.at(
+            boost::lexical_cast<int>(std::string(
+                value.begin() + 1, value.end())));
+
+        if (placeholder.final_id.empty())
+        {
+            if (placeholder.category < id_generator::numbered &&
+                    !placeholder.id.second.used &&
+                    placeholder.id.second.category == placeholder.category)
+            {
+                placeholder.id.second.used = true;
+                placeholder.final_id = placeholder.id.first;
+            }
+            else while(true)
+            {
+                int count = placeholder.id.second.count++;
+                placeholder.final_id = placeholder.id.first +
+                    boost::lexical_cast<std::string>(count);
+                // TODO: Should add final_id to ids_, there are some
+                // edges cases where it could collide.
+                if (ids_.find(placeholder.final_id) == ids_.end())
+                    break;
+            }
+        }
+
+        return string_ref(placeholder.final_id);
+    }
+
+    // Very simple xml subset parser which replaces id values.
+    //
+    // I originally tried to integrate this into the post processor
+    // but that proved tricky. Alternatively it could use a proper
+    // xml parser, but I want this to be able to survive badly
+    // marked up escapes.
+
+    struct xml_processor
+    {
+        xml_processor();
+    
+        std::string escape_prefix;
+        std::string escape_postfix;
+        std::string processing_instruction_postfix;
+        std::string comment_postfix;
+        std::string tag_end;
+        std::string name_end;
+        std::vector<std::string> id_attributes;
+        
+        std::string replace(std::string const&, id_generator&);
+    };
+
+    std::string id_generator::replace_placeholders(std::string const& source)
+    {
+        xml_processor processor;
+        return processor.replace(source, *this);
+    }
+
+    namespace
+    {
+        char const* id_attributes_[] =
+        {
+            "id",
+            "linkend",
+            "linkends",
+            "arearefs"
+        };
+    }
+
+    xml_processor::xml_processor()
+        : escape_prefix("!--quickbook-escape-prefix-->")
+        , escape_postfix("!--quickbook-escape-postfix-->")
+        , processing_instruction_postfix("?>")
+        , comment_postfix("-->")
+        , tag_end(" \t\n\r>")
+        , name_end("= \t\n\r>")
+    {
+        static int const n_id_attributes = sizeof(id_attributes_)/sizeof(char const*);
+        for (int i = 0; i != n_id_attributes; ++i)
+        {
+            id_attributes.push_back(id_attributes_[i]);
+        }
+
+        std::sort(id_attributes.begin(), id_attributes.end());
+    }
+
+    std::string xml_processor::replace(std::string const& source, id_generator& ids)
+    {
+        std::string result;
+
+        typedef std::string::const_iterator iterator;
+        iterator pos = source.begin(), end = source.end();
+        iterator next = pos;
+
+        while (true) {
+            next = std::find(next, end, '<');
+            if (next == end) break;
+
+            if (end - pos > escape_prefix.size() && std::equal(
+                    escape_prefix.begin(), escape_prefix.end(), pos))
+            {
+                next = std::search(next + escape_prefix.size(), end,
+                    escape_postfix.begin(), escape_postfix.end());
+
+                if (next == end) break;
+
+                next += escape_postfix.size();
+                continue;
+            }
+
+            ++next;
+            if (next == end) break;
+
+            switch(*next)
+            {
+            case '?':
+                next = std::search(next, end,
+                    processing_instruction_postfix.begin(),
+                    processing_instruction_postfix.end());
+
+                if (next != end) next += processing_instruction_postfix.size();
+                break;
+            case '!':
+                if (end - next > 3 && next[1] == '-' && next[2] == '-')
+                {
+                    next = std::search(next + 3, end,
+                        comment_postfix.begin(), comment_postfix.end());
+
+                    if (next != end) next += comment_postfix.size();
+                }
+                else
+                {
+                    next = std::find(next + 1, end, '>');
+                    if (next != end) ++next;
+                }
+                break;
+            default:
+                if (*next >= 'a' || *next <= 'z' ||
+                        *next >= 'A' || *next <= 'Z' ||
+                        *next == '_' || *next == ':')
+                {
+                    next = std::find_first_of(
+                        next + 1, end, tag_end.begin(), tag_end.end());
+
+                    while (true) {
+                        while(next != end && (*next == ' ' || *next == '\t'))
+                            ++next;
+                            
+                        iterator name_start = next;
+
+                        next = std::find_first_of(
+                            next, end, name_end.begin(), name_end.end());
+                        
+                        if (next == end || *next == '>') break;
+
+                        string_ref name(name_start, next);
+                        ++next;
+
+                        while (next != end &&
+                                std::find(name_end.begin(), name_end.end(), *next)
+                                != name_end.end())
+                            ++next;
+
+                        if (next == end || (*next != '"' && *next != '\'')) break;
+
+                        char delim = *next;
+                        ++next;
+
+                        iterator value_start = next;
+
+                        next = std::find(next, end, delim);
+                        string_ref value(value_start, next);
+                        if (next == end) break;
+                        ++next;
+
+                        if (std::find(id_attributes.begin(),
+                                    id_attributes.end(), name)
+                                != id_attributes.end())
+                        {
+                            result.append(pos, value.begin());
+                            string_ref x = ids.get(value);
+                            result.append(x.begin(), x.end());
+                            pos = value.end();
+                        }
+                    }
+                }
+                else
+                {
+                    next = std::find(next + 1, end, '>');
+                    if (next != end) ++next;
+                }
+            }
+        }
+        
+        result.append(pos, source.end());
+        return result;
+    }
+}
Added: trunk/tools/quickbook/src/id_generator.hpp
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/src/id_generator.hpp	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -0,0 +1,53 @@
+/*=============================================================================
+    Copyright (c) 2011 Daniel James
+
+    Use, modification and distribution is subject to the Boost Software
+    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+    http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#if !defined(BOOST_QUICKBOOK_ID_GENERATOR_HPP)
+#define BOOST_QUICKBOOK_ID_GENERATOR_HPP
+
+#include "fwd.hpp"
+#include <boost/unordered/unordered_map.hpp>
+#include <deque>
+#include <string>
+
+namespace quickbook
+{
+    class string_ref;
+
+    class id_generator
+    {
+    public:
+
+        enum categories
+        {
+            explicit_id = 0,    // Explicitly given by user
+            generated,          // Generated from source, e.g. table title
+            numbered,           // Just used to avoid random docbook ids
+            default_category
+        };
+
+    private:
+
+        struct id;
+        struct placeholder;
+        typedef boost::unordered_map<std::string, id> placeholder_map;
+        
+        placeholder_map ids_;
+        std::deque<placeholder> placeholders_;
+
+    public:
+        id_generator();
+        ~id_generator();
+
+        std::string add(std::string const& id, categories priority);
+
+        std::string replace_placeholders(std::string const&);
+        string_ref get(string_ref placeholder);
+    };
+}
+
+#endif
\ No newline at end of file
Modified: trunk/tools/quickbook/src/quickbook.cpp
==============================================================================
--- trunk/tools/quickbook/src/quickbook.cpp	(original)
+++ trunk/tools/quickbook/src/quickbook.cpp	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -13,6 +13,7 @@
 #include "post_process.hpp"
 #include "utils.hpp"
 #include "input_path.hpp"
+#include "id_generator.hpp"
 #include <boost/program_options.hpp>
 #include <boost/filesystem/v3/path.hpp>
 #include <boost/filesystem/v3/operations.hpp>
@@ -112,12 +113,8 @@
     static int
     parse_document(
         fs::path const& filein_,
-        fs::path const& xinclude_base,
-            string_stream& out)
-    {
-        actions actor(filein_, xinclude_base, out);
-
-        set_macros(actor);
+        actions& actor)
+    {        
         bool r = parse_file(filein_, actor);
         if (actor.section_level != 0)
             detail::outwarn(filein_)
@@ -142,9 +139,14 @@
       , int linewidth
       , bool pretty_print)
     {
-        int result = 0;
         string_stream buffer;
-        result = parse_document(filein_, xinclude_base_, buffer);
+        id_generator ids;
+        actions actor(filein_, xinclude_base_, buffer, ids);
+        set_macros(actor);
+
+        int result = parse_document(filein_, actor);
+
+        std::string stage2 = ids.replace_placeholders(buffer.str());
 
         if (result == 0)
         {
@@ -154,7 +156,7 @@
             {
                 try
                 {
-                    fileout << post_process(buffer.str(), indent, linewidth);
+                    fileout << post_process(stage2, indent, linewidth);
                 }
                 catch (quickbook::post_process_failure&)
                 {
@@ -162,13 +164,13 @@
                     ::quickbook::detail::outerr()
                         << "Post Processing Failed."
                         << std::endl;
-                    fileout << buffer.str();
+                    fileout << stage2;
                     return 1;
                 }
             }
             else
             {
-                fileout << buffer.str();
+                fileout << stage2;
             }
         }
         return result;
Modified: trunk/tools/quickbook/src/template_stack.cpp
==============================================================================
--- trunk/tools/quickbook/src/template_stack.cpp	(original)
+++ trunk/tools/quickbook/src/template_stack.cpp	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -18,10 +18,12 @@
 {
     template_body::template_body(
             value const& content,
-            fs::path const& filename
+            fs::path const& filename,
+            content_type type
         )
         : content(content)
         , filename(filename)
+        , type(type)
     {
         assert(content.get_tag() == template_tags::block ||
             content.get_tag() == template_tags::phrase);
@@ -32,7 +34,6 @@
         return content.get_tag() == template_tags::block;
     }
 
-
     template_stack::template_stack()
         : scope(template_stack::parser(*this))
         , scopes()
Modified: trunk/tools/quickbook/src/template_stack.hpp
==============================================================================
--- trunk/tools/quickbook/src/template_stack.hpp	(original)
+++ trunk/tools/quickbook/src/template_stack.hpp	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -28,11 +28,18 @@
 
     struct template_body
     {
-        template_body(value const&, fs::path const&);
+        enum content_type
+        {
+            quickbook,
+            raw_output
+        };
+    
+        template_body(value const&, fs::path const&, content_type = quickbook);
         bool is_block() const;
 
         stored_value content;
         fs::path filename;        
+        content_type type;
     };
 
     struct template_scope;
@@ -42,6 +49,17 @@
         template_symbol(
                 std::string const& identifier,
                 std::vector<std::string> const& params,
+                template_body const& body,
+                template_scope const* parent = 0)
+           : identifier(identifier)
+           , params(params)
+           , body(body)
+           , parent(parent)
+           , callouts() {}
+
+           template_symbol(
+                std::string const& identifier,
+                std::vector<std::string> const& params,
                 value const& content,
                 fs::path const& filename,
                 template_scope const* parent = 0)
Modified: trunk/tools/quickbook/test/anchor.gold
==============================================================================
--- trunk/tools/quickbook/test/anchor.gold	(original)
+++ trunk/tools/quickbook/test/anchor.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -10,25 +10,25 @@
       want to make sure they appear in the correct place. <anchor id="a3"/>
     </para>
     <anchor id="anchor_test.anchors.this_heading_shouldn_t_pick_up_the_previous_anchor"/>
-    <bridgehead renderas="sect3" id="anchor_test.anchors.this_heading_shouldn_t_pick_up_the_previous_anchor-heading">
+    <bridgehead renderas="sect3" id="anchor_test.anchors.h0">
       <link linkend="anchor_test.anchors.this_heading_shouldn_t_pick_up_the_previous_anchor">This
       heading shouldn't pick up the previous anchor</link>
     </bridgehead>
     <anchor id="a4"/><anchor id="anchor_test.anchors.this_heading_should_pick_up_the_previous_anchor"/>
-    <bridgehead renderas="sect3" id="anchor_test.anchors.this_heading_should_pick_up_the_previous_anchor-heading">
+    <bridgehead renderas="sect3" id="anchor_test.anchors.h1">
       <link linkend="anchor_test.anchors.this_heading_should_pick_up_the_previous_anchor">This
       heading should pick up the previous anchor</link>
     </bridgehead>
     <anchor id="a5"/><anchor id="anchor_test.anchors.and_this_one"/>
-    <bridgehead renderas="sect3" id="anchor_test.anchors.and_this_one-heading">
+    <bridgehead renderas="sect3" id="anchor_test.anchors.h2">
       <link linkend="anchor_test.anchors.and_this_one">And this one</link>
     </bridgehead>
     <anchor id="a6"/><anchor id="anchor_test.anchors.also_this_one"/>
-    <bridgehead renderas="sect3" id="anchor_test.anchors.also_this_one-heading">
+    <bridgehead renderas="sect3" id="anchor_test.anchors.h3">
       <link linkend="anchor_test.anchors.also_this_one">Also this one</link>
     </bridgehead>
     <anchor id="a7"/><anchor id="anchors.finally_this"/>
-    <bridgehead renderas="sect3" id="anchors.finally_this-heading">
+    <bridgehead renderas="sect3" id="anchor_test.anchors.h4">
       Finally this
     </bridgehead>
     <anchor id="a8"/>
Modified: trunk/tools/quickbook/test/blocks.gold
==============================================================================
--- trunk/tools/quickbook/test/blocks.gold	(original)
+++ trunk/tools/quickbook/test/blocks.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -3,7 +3,7 @@
 <article id="various_blocks" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
  xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>Various blocks</title> <anchor id="various_blocks.blockquotes"/>
-  <bridgehead renderas="sect2" id="various_blocks.blockquotes-heading">
+  <bridgehead renderas="sect2" id="various_blocks.h0">
     <link linkend="various_blocks.blockquotes">Blockquotes</link>
   </bridgehead>
   <para>
@@ -26,7 +26,7 @@
     </para>
   </blockquote>
   <anchor id="various_blocks.admonitions"/>
-  <bridgehead renderas="sect2" id="various_blocks.admonitions-heading">
+  <bridgehead renderas="sect2" id="various_blocks.h1">
     <link linkend="various_blocks.admonitions">Admonitions</link>
   </bridgehead>
   <warning>
@@ -63,7 +63,7 @@
     </para>
   </warning>
   <anchor id="various_blocks.blurb"/>
-  <bridgehead renderas="sect2" id="various_blocks.blurb-heading">
+  <bridgehead renderas="sect2" id="various_blocks.h2">
     <link linkend="various_blocks.blurb">Blurb</link>
   </bridgehead>
   <sidebar role="blurb">
@@ -71,7 +71,7 @@
     Blurb
   </para>
   </sidebar> <anchor id="various_blocks.inline_blocks"/>
-  <bridgehead renderas="sect2" id="various_blocks.inline_blocks-heading">
+  <bridgehead renderas="sect2" id="various_blocks.h3">
     <link linkend="various_blocks.inline_blocks">Inline blocks</link>
   </bridgehead>
   <blockquote>
Modified: trunk/tools/quickbook/test/callouts.gold
==============================================================================
--- trunk/tools/quickbook/test/callouts.gold	(original)
+++ trunk/tools/quickbook/test/callouts.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -12,13 +12,13 @@
   <para>
     
 <programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
-  <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <!--quickbook-escape-prefix--><co id="callout_tests0co" linkends="callout_tests0" /><!--quickbook-escape-postfix-->
+  <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests.c0" linkends="callout_tests.c1" />
 <phrase role="special">}</phrase>
 
 </programlisting>
   </para>
   <calloutlist>
-    <callout arearefs="callout_tests0co" id="callout_tests0">
+    <callout arearefs="callout_tests.c0" id="callout_tests.c1">
       <para>
         create a uniform_int distribution
       </para>
@@ -30,13 +30,13 @@
   <para>
     
 <programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
-  <!--quickbook-escape-prefix--><co id="callout_tests1co" linkends="callout_tests1" /><!--quickbook-escape-postfix--><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="special">></phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+  <co id="callout_tests.c2" linkends="callout_tests.c3" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="special">></phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
 <phrase role="special">}</phrase>
 
 </programlisting>
   </para>
   <calloutlist>
-    <callout arearefs="callout_tests1co" id="callout_tests1">
+    <callout arearefs="callout_tests.c2" id="callout_tests.c3">
       <important>
         <para>
           test
@@ -50,13 +50,13 @@
   <para>
     
 <programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
-  <!--quickbook-escape-prefix--><co id="callout_tests2co" linkends="callout_tests2" /><!--quickbook-escape-postfix--><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="special">></phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+  <co id="callout_tests.c4" linkends="callout_tests.c5" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="special">></phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
 <phrase role="special">}</phrase>
 
 </programlisting>
   </para>
   <calloutlist>
-    <callout arearefs="callout_tests2co" id="callout_tests2">
+    <callout arearefs="callout_tests.c4" id="callout_tests.c5">
       <important>
         <para>
           test
@@ -70,13 +70,13 @@
   <para>
     
 <programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
-  <!--quickbook-escape-prefix--><co id="callout_tests3co" linkends="callout_tests3" /><!--quickbook-escape-postfix--><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="special">></phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+  <co id="callout_tests.c6" linkends="callout_tests.c7" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="special">></phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
 <phrase role="special">}</phrase>
 
 </programlisting>
   </para>
   <calloutlist>
-    <callout arearefs="callout_tests3co" id="callout_tests3">
+    <callout arearefs="callout_tests.c6" id="callout_tests.c7">
       <important>
         <para>
           test
@@ -90,24 +90,24 @@
   <para>
     
 <programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
-  <!--quickbook-escape-prefix--><co id="callout_tests4co" linkends="callout_tests4" /><!--quickbook-escape-postfix--><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="special">></phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
-<!--quickbook-escape-prefix--><co id="callout_tests5co" linkends="callout_tests5" /><!--quickbook-escape-postfix--><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <!--quickbook-escape-prefix--><co id="callout_tests6co" linkends="callout_tests6" /><!--quickbook-escape-postfix-->
+  <co id="callout_tests.c8" linkends="callout_tests.c9" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="special">></phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+<co id="callout_tests.c10" linkends="callout_tests.c11" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests.c12" linkends="callout_tests.c13" />
 <phrase role="special">}</phrase>
 
 </programlisting>
   </para>
   <calloutlist>
-    <callout arearefs="callout_tests4co" id="callout_tests4">
+    <callout arearefs="callout_tests.c8" id="callout_tests.c9">
       <para>
         callout 1
       </para>
     </callout>
-    <callout arearefs="callout_tests5co" id="callout_tests5">
+    <callout arearefs="callout_tests.c10" id="callout_tests.c11">
       <para>
         callout 2
       </para>
     </callout>
-    <callout arearefs="callout_tests6co" id="callout_tests6">
+    <callout arearefs="callout_tests.c12" id="callout_tests.c13">
       <para>
         create a uniform_int distribution
       </para>
@@ -115,16 +115,16 @@
   </calloutlist>
   <para>
     
-<programlisting><!--quickbook-escape-prefix--><co id="callout_tests7co" linkends="callout_tests7" /><!--quickbook-escape-postfix--><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <!--quickbook-escape-prefix--><co id="callout_tests8co" linkends="callout_tests8" /><!--quickbook-escape-postfix-->
+<programlisting><co id="callout_tests.c14" linkends="callout_tests.c15" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests.c16" linkends="callout_tests.c17" />
 </programlisting>
   </para>
   <calloutlist>
-    <callout arearefs="callout_tests7co" id="callout_tests7">
+    <callout arearefs="callout_tests.c14" id="callout_tests.c15">
       <para>
         callout 2
       </para>
     </callout>
-    <callout arearefs="callout_tests8co" id="callout_tests8">
+    <callout arearefs="callout_tests.c16" id="callout_tests.c17">
       <para>
         create a uniform_int distribution
       </para>
Modified: trunk/tools/quickbook/test/code-block.gold
==============================================================================
--- trunk/tools/quickbook/test/code-block.gold	(original)
+++ trunk/tools/quickbook/test/code-block.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -27,7 +27,7 @@
     Paragraph.
   </para>
   <anchor id="indented_code_blocks.code_blocks_separated_by_comment"/>
-  <bridgehead renderas="sect2" id="indented_code_blocks.code_blocks_separated_by_comment-heading">
+  <bridgehead renderas="sect2" id="indented_code_blocks.h0">
     <link linkend="indented_code_blocks.code_blocks_separated_by_comment">Code blocks
     separated by comment</link>
   </bridgehead>
Modified: trunk/tools/quickbook/test/doc-info/duplicates-1.1.gold
==============================================================================
--- trunk/tools/quickbook/test/doc-info/duplicates-1.1.gold	(original)
+++ trunk/tools/quickbook/test/doc-info/duplicates-1.1.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -17,7 +17,7 @@
     <copyright>
       <year>1963</year> <holder>Jane Doe</holder>
     </copyright>
-    <legalnotice id="legal.thing2">
+    <legalnotice id="thing2.legal">
       <para>
         Public Domain
       </para>
Modified: trunk/tools/quickbook/test/doc-info/duplicates-1.5.gold
==============================================================================
--- trunk/tools/quickbook/test/doc-info/duplicates-1.5.gold	(original)
+++ trunk/tools/quickbook/test/doc-info/duplicates-1.5.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -17,7 +17,7 @@
     <copyright>
       <year>1963</year> <holder>Jane Doe</holder>
     </copyright>
-    <legalnotice id="legal.thing2">
+    <legalnotice id="thing2.legal">
       <para>
         Public Domain
       </para>
Modified: trunk/tools/quickbook/test/doc-info/source-mode-1.4.gold
==============================================================================
--- trunk/tools/quickbook/test/doc-info/source-mode-1.4.gold	(original)
+++ trunk/tools/quickbook/test/doc-info/source-mode-1.4.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -3,7 +3,7 @@
 <article id="c___test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>C++ test</title>
   <articleinfo>
-    <legalnotice id="legal.c___test">
+    <legalnotice id="c___test.legal">
       <para>
         <code><phrase role="keyword">def</phrase> <phrase role="identifier">foo</phrase><phrase
         role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">):</phrase>
Modified: trunk/tools/quickbook/test/doc-info/source-mode-1.5.gold
==============================================================================
--- trunk/tools/quickbook/test/doc-info/source-mode-1.5.gold	(original)
+++ trunk/tools/quickbook/test/doc-info/source-mode-1.5.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -3,7 +3,7 @@
 <article id="c___test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>C++ test</title>
   <articleinfo>
-    <legalnotice id="legal.c___test">
+    <legalnotice id="c___test.legal">
       <para>
         <code><phrase role="keyword">def</phrase> <phrase role="identifier">foo</phrase><phrase
         role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">):</phrase>
Modified: trunk/tools/quickbook/test/doc-info/source-mode-1.6.gold
==============================================================================
--- trunk/tools/quickbook/test/doc-info/source-mode-1.6.gold	(original)
+++ trunk/tools/quickbook/test/doc-info/source-mode-1.6.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -3,7 +3,7 @@
 <article id="c___test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>C++ test</title>
   <articleinfo>
-    <legalnotice id="legal.c___test">
+    <legalnotice id="c___test.legal">
       <para>
         <code><phrase role="keyword">def</phrase> <phrase role="identifier">foo</phrase><phrase
         role="special">(</phrase><phrase role="identifier">x</phrase><phrase role="special">):</phrase>
Modified: trunk/tools/quickbook/test/heading.gold
==============================================================================
--- trunk/tools/quickbook/test/heading.gold	(original)
+++ trunk/tools/quickbook/test/heading.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -2,21 +2,21 @@
 <!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
 <article id="header" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>Header</title> <anchor id="header.header_test"/>
-  <bridgehead renderas="sect2" id="header.header_test-heading">
+  <bridgehead renderas="sect2" id="header.h0">
     <link linkend="header.header_test">Header Test</link>
   </bridgehead>
   <para>
     Testing headers without sections.
   </para>
   <anchor id="header._not_an_id"/>
-  <bridgehead renderas="sect2" id="header._not_an_id-heading">
+  <bridgehead renderas="sect2" id="header.h1">
     <link linkend="header._not_an_id">:Not an Id</link>
   </bridgehead>
   <para>
     Paragraph.
   </para>
   <anchor id="header._not_an_id_again"/>
-  <bridgehead renderas="sect3" id="header._not_an_id_again-heading">
+  <bridgehead renderas="sect3" id="header.h2">
     <link linkend="header._not_an_id_again">:Not an Id again</link>
   </bridgehead>
   <para>
Modified: trunk/tools/quickbook/test/heading_1_6.gold
==============================================================================
--- trunk/tools/quickbook/test/heading_1_6.gold	(original)
+++ trunk/tools/quickbook/test/heading_1_6.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -2,21 +2,21 @@
 <!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
 <article id="header" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>Header</title> <anchor id="header.header_test"/>
-  <bridgehead renderas="sect2" id="header.header_test-heading">
+  <bridgehead renderas="sect2" id="header.h0">
     <link linkend="header.header_test">Header Test</link>
   </bridgehead>
   <para>
     Paragraph.
   </para>
   <anchor id="header.heading_id"/>
-  <bridgehead renderas="sect2" id="header.heading_id-heading">
+  <bridgehead renderas="sect2" id="header.h1">
     <link linkend="header.heading_id">Heading with an id</link>
   </bridgehead>
   <para>
     Paragraph.
   </para>
   <anchor id="header.heading_id2"/>
-  <bridgehead renderas="sect3" id="header.heading_id2-heading">
+  <bridgehead renderas="sect3" id="header.h2">
     <link linkend="header.heading_id2">Heading with an id</link>
   </bridgehead>
   <para>
Modified: trunk/tools/quickbook/test/identifier_1_5.gold
==============================================================================
--- trunk/tools/quickbook/test/identifier_1_5.gold	(original)
+++ trunk/tools/quickbook/test/identifier_1_5.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -3,7 +3,7 @@
 <article id="identifiers_in_quickbook_1_5" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
  xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>Identifiers in quickbook 1.5</title> <anchor id="identifiers_in_quickbook_1_5.test_heading_with__code__phrase_role__identifier__code__phrase___code_"/>
-  <bridgehead renderas="sect2" id="identifiers_in_quickbook_1_5.test_heading_with__code__phrase_role__identifier__code__phrase___code_-heading">
+  <bridgehead renderas="sect2" id="identifiers_in_quickbook_1_5.h0">
     <link linkend="identifiers_in_quickbook_1_5.test_heading_with__code__phrase_role__identifier__code__phrase___code_">Test
     heading with <code><phrase role="identifier">code</phrase></code></link>
   </bridgehead>
Modified: trunk/tools/quickbook/test/identifier_1_6.gold
==============================================================================
--- trunk/tools/quickbook/test/identifier_1_6.gold	(original)
+++ trunk/tools/quickbook/test/identifier_1_6.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -3,7 +3,7 @@
 <article id="identifiers_in_quickbook_1_6" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
  xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>Identifiers in quickbook 1.6</title> <anchor id="identifiers_in_quickbook_1_6.test_heading_with__code_"/>
-  <bridgehead renderas="sect2" id="identifiers_in_quickbook_1_6.test_heading_with__code_-heading">
+  <bridgehead renderas="sect2" id="identifiers_in_quickbook_1_6.h0">
     <link linkend="identifiers_in_quickbook_1_6.test_heading_with__code_">Test heading
     with <code><phrase role="identifier">code</phrase></code></link>
   </bridgehead>
Modified: trunk/tools/quickbook/test/quickbook-manual.gold
==============================================================================
--- trunk/tools/quickbook/test/quickbook-manual.gold	(original)
+++ trunk/tools/quickbook/test/quickbook-manual.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -15,7 +15,7 @@
       <year>2002</year> <year>2004</year> <year>2006</year> <holder>Joel de Guzman,
       Eric Niebler</holder>
     </copyright>
-    <legalnotice id="legal.quickbook">
+    <legalnotice id="quickbook.legal">
       <para>
         Distributed under the Boost Software License, Version 1.0. (See accompanying
         file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt>)
@@ -104,7 +104,7 @@
   <section id="quickbook.change_log">
     <title><link linkend="quickbook.change_log">Change Log</link></title> <anchor
     id="quickbook.change_log.version_1_3"/>
-    <bridgehead renderas="sect3" id="quickbook.change_log.version_1_3-heading">
+    <bridgehead renderas="sect3" id="quickbook.change_log.h0">
       <link linkend="quickbook.change_log.version_1_3">Version 1.3</link>
     </bridgehead>
     <itemizedlist>
@@ -459,7 +459,7 @@
             </simpara>
           </listitem>
         </itemizedlist>
-        <table frame="all" id="quickbook.t0">
+        <table frame="all" id="quickbook.syntax.phrase.simple_formatting.t0">
           <title>More Formatting Samples</title>
           <tgroup cols="2">
             <thead>
@@ -779,7 +779,7 @@
           A C++ comment <code><phrase role="comment">// looks like this</phrase></code>
           whereas a Python comment <code><phrase role="comment">#looks like this</phrase></code>.
         </para>
-        <table frame="all" id="quickbook.t1">
+        <table frame="all" id="quickbook.syntax.phrase.source_mode.t0">
           <title>Supported Source Modes</title>
           <tgroup cols="2">
             <thead>
@@ -1707,27 +1707,27 @@
 [h6 Heading 6]
 <!--quickbook-escape-postfix--></programlisting>
         <anchor id="quickbook.syntax.block.headings.heading_1"/>
-        <bridgehead renderas="sect1" id="quickbook.syntax.block.headings.heading_1-heading">
+        <bridgehead renderas="sect1" id="quickbook.syntax.block.headings.h0">
           <link linkend="quickbook.syntax.block.headings.heading_1">Heading 1</link>
         </bridgehead>
         <anchor id="quickbook.syntax.block.headings.heading_2"/>
-        <bridgehead renderas="sect2" id="quickbook.syntax.block.headings.heading_2-heading">
+        <bridgehead renderas="sect2" id="quickbook.syntax.block.headings.h1">
           <link linkend="quickbook.syntax.block.headings.heading_2">Heading 2</link>
         </bridgehead>
         <anchor id="quickbook.syntax.block.headings.heading_3"/>
-        <bridgehead renderas="sect3" id="quickbook.syntax.block.headings.heading_3-heading">
+        <bridgehead renderas="sect3" id="quickbook.syntax.block.headings.h2">
           <link linkend="quickbook.syntax.block.headings.heading_3">Heading 3</link>
         </bridgehead>
         <anchor id="quickbook.syntax.block.headings.heading_4"/>
-        <bridgehead renderas="sect4" id="quickbook.syntax.block.headings.heading_4-heading">
+        <bridgehead renderas="sect4" id="quickbook.syntax.block.headings.h3">
           <link linkend="quickbook.syntax.block.headings.heading_4">Heading 4</link>
         </bridgehead>
         <anchor id="quickbook.syntax.block.headings.heading_5"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.headings.heading_5-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.headings.h4">
           <link linkend="quickbook.syntax.block.headings.heading_5">Heading 5</link>
         </bridgehead>
         <anchor id="quickbook.syntax.block.headings.heading_6"/>
-        <bridgehead renderas="sect6" id="quickbook.syntax.block.headings.heading_6-heading">
+        <bridgehead renderas="sect6" id="quickbook.syntax.block.headings.h5">
           <link linkend="quickbook.syntax.block.headings.heading_6">Heading 6</link>
         </bridgehead>
         <para>
@@ -1873,7 +1873,7 @@
         <para>
           Quickbook has some predefined macros that you can already use.
         </para>
-        <table frame="all" id="quickbook.t2">
+        <table frame="all" id="quickbook.syntax.block.predefined_macros.t0">
           <title>Predefined Macros</title>
           <tgroup cols="3">
             <thead>
@@ -1972,7 +1972,7 @@
 ]
 <!--quickbook-escape-postfix--></programlisting>
         <anchor id="quickbook.syntax.block.templates.template_identifier"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.template_identifier-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.h0">
           <link linkend="quickbook.syntax.block.templates.template_identifier">Template
           Identifier</link>
         </bridgehead>
@@ -1994,7 +1994,7 @@
           </listitem>
         </itemizedlist>
         <anchor id="quickbook.syntax.block.templates.formal_template_arguments"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.formal_template_arguments-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.h1">
           <link linkend="quickbook.syntax.block.templates.formal_template_arguments">Formal
           Template Arguments</link>
         </bridgehead>
@@ -2014,7 +2014,7 @@
           of the template call.
         </para>
         <anchor id="quickbook.syntax.block.templates.template_body"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.template_body-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.h2">
           <link linkend="quickbook.syntax.block.templates.template_body">Template
           Body</link>
         </bridgehead>
@@ -2041,7 +2041,7 @@
           block level elements are not allowed in phrase templates.
         </para>
         <anchor id="quickbook.syntax.block.templates.template_expansion"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.template_expansion-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.h3">
           <link linkend="quickbook.syntax.block.templates.template_expansion">Template
           Expansion</link>
         </bridgehead>
@@ -2084,7 +2084,7 @@
           by the close parenthesis.
         </para>
         <anchor id="quickbook.syntax.block.templates.nullary_templates"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.nullary_templates-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.h4">
           <link linkend="quickbook.syntax.block.templates.nullary_templates">Nullary
           Templates</link>
         </bridgehead>
@@ -2177,7 +2177,7 @@
           brackets, though.
         </para>
         <anchor id="quickbook.syntax.block.templates.simple_arguments"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.simple_arguments-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.h5">
           <link linkend="quickbook.syntax.block.templates.simple_arguments">Simple
           Arguments</link>
         </bridgehead>
@@ -2252,7 +2252,7 @@
           what do you think man?
         </para>
         <anchor id="quickbook.syntax.block.templates.punctuation_templates"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.punctuation_templates-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.templates.h6">
           <link linkend="quickbook.syntax.block.templates.punctuation_templates">Punctuation
           Templates</link>
         </bridgehead>
@@ -2330,7 +2330,7 @@
         <para>
           will generate:
         </para>
-        <table frame="all" id="quickbook.t3">
+        <table frame="all" id="quickbook.syntax.block.tables.t0">
           <title>A Simple Table</title>
           <tgroup cols="3">
             <thead>
@@ -2439,7 +2439,7 @@
         <para>
           and thus:
         </para>
-        <table frame="all" id="quickbook.t4">
+        <table frame="all" id="quickbook.syntax.block.tables.t1">
           <title>Table with fat cells</title>
           <tgroup cols="2">
             <thead>
@@ -2513,7 +2513,7 @@
     ]
 ]
 <!--quickbook-escape-postfix--></programlisting>
-        <table frame="all" id="quickbook.t5">
+        <table frame="all" id="quickbook.syntax.block.tables.t2">
           <title>Table with code</title>
           <tgroup cols="2">
             <thead>
@@ -2656,7 +2656,7 @@
           QuickBook's import facility provides a nice solution.
         </para>
         <anchor id="quickbook.syntax.block.import.example"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.import.example-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.import.h0">
           <link linkend="quickbook.syntax.block.import.example">Example</link>
         </bridgehead>
         <para>
@@ -2734,7 +2734,7 @@
           Some trailing text here
         </para>
         <anchor id="quickbook.syntax.block.import.code_snippet_markup"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.import.code_snippet_markup-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.import.h1">
           <link linkend="quickbook.syntax.block.import.code_snippet_markup">Code
           Snippet Markup</link>
         </bridgehead>
@@ -2756,7 +2756,7 @@
           This too will not be visible in quickbook.
         </para>
         <anchor id="quickbook.syntax.block.import.special_comments"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.import.special_comments-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.import.h2">
           <link linkend="quickbook.syntax.block.import.special_comments">Special
           Comments</link>
         </bridgehead>
@@ -2779,7 +2779,7 @@
           initial slash-star-tick and the final star-slash shall be ignored.
         </para>
         <anchor id="quickbook.syntax.block.import.callouts"/>
-        <bridgehead renderas="sect5" id="quickbook.syntax.block.import.callouts-heading">
+        <bridgehead renderas="sect5" id="quickbook.syntax.block.import.h3">
           <link linkend="quickbook.syntax.block.import.callouts">Callouts</link>
         </bridgehead>
         <para>
@@ -2796,20 +2796,20 @@
         </para>
         <para>
           
-<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">foo_bar</phrase><phrase role="special">()</phrase> <!--quickbook-escape-prefix--><co id="quickbook0co" linkends="quickbook0" /><!--quickbook-escape-postfix-->
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">foo_bar</phrase><phrase role="special">()</phrase> <co id="quickbook.c0" linkends="quickbook.c1" />
 <phrase role="special">{</phrase>
-    <phrase role="keyword">return</phrase> <phrase role="string">"foo-bar"</phrase><phrase role="special">;</phrase> <!--quickbook-escape-prefix--><co id="quickbook1co" linkends="quickbook1" /><!--quickbook-escape-postfix-->
+    <phrase role="keyword">return</phrase> <phrase role="string">"foo-bar"</phrase><phrase role="special">;</phrase> <co id="quickbook.c2" linkends="quickbook.c3" />
 <phrase role="special">}</phrase>
 </programlisting>
         </para>
         <calloutlist>
-          <callout arearefs="quickbook0co" id="quickbook0">
+          <callout arearefs="quickbook.c0" id="quickbook.c1">
             <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">
+          <callout arearefs="quickbook.c2" id="quickbook.c3">
             <para>
               return 'em, foo-bar man!
             </para>
@@ -3147,7 +3147,7 @@
   <section id="quickbook.faq">
     <title><link linkend="quickbook.faq">Frequently Asked Questions</link></title>
     <anchor id="quickbook.faq.can_i_use_quickbook_for_non_boost_documentation_"/>
-    <bridgehead renderas="sect3" id="quickbook.faq.can_i_use_quickbook_for_non_boost_documentation_-heading">
+    <bridgehead renderas="sect3" id="quickbook.faq.h0">
       <link linkend="quickbook.faq.can_i_use_quickbook_for_non_boost_documentation_">Can
       I use QuickBook for non-Boost documentation?</link>
     </bridgehead>
@@ -3191,7 +3191,7 @@
     <para>
       [cpp]
     </para>
-    <table frame="all" id="quickbook.t6">
+    <table frame="all" id="quickbook.ref.t0">
       <title>Syntax Compendium</title>
       <tgroup cols="3">
         <thead>
Modified: trunk/tools/quickbook/test/table_1_3.gold
==============================================================================
--- trunk/tools/quickbook/test/table_1_3.gold	(original)
+++ trunk/tools/quickbook/test/table_1_3.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -49,7 +49,7 @@
   </informaltable>
   <section id="table_1_3.section1">
     <title><link linkend="table_1_3.section1">Section 1</link></title>
-    <table frame="all" id="table_1_3.t1">
+    <table frame="all" id="table_1_3.section1.t0">
       <title>A & B</title>
       <tgroup cols="2">
         <thead>
@@ -82,14 +82,14 @@
         </tbody>
       </tgroup>
     </table>
-    <table frame="all" id="table_1_3.t2">
+    <table frame="all" id="table_1_3.section1.t1">
       <title>Empty Table</title>
       <tgroup cols="0">
         <tbody>
         </tbody>
       </tgroup>
     </table>
-    <table frame="all" id="table_1_3.t3">
+    <table frame="all" id="table_1_3.section1.t2">
       <title>Table with an empty cell</title>
       <tgroup cols="1">
         <tbody>
@@ -103,7 +103,7 @@
         </tbody>
       </tgroup>
     </table>
-    <table frame="all" id="table_1_3.t4">
+    <table frame="all" id="table_1_3.section1.t3">
       <title>Indentation</title>
       <tgroup cols="2">
         <thead>
@@ -142,7 +142,7 @@
         </tbody>
       </tgroup>
     </table>
-    <table frame="all" id="table_1_3.t6">
+    <table frame="all" id="table_1_3.section1.t4">
       <title>Nested Tables</title>
       <tgroup cols="1">
         <thead>
@@ -162,7 +162,7 @@
         <tbody>
           <row>
             <entry>
-              <table frame="all" id="table_1_3.t5">
+              <table frame="all" id="table_1_3.section1.t5">
                 <title>Inner Table</title>
                 <tgroup cols="2">
                   <thead>
@@ -208,7 +208,7 @@
       </tgroup>
     </table>
     <anchor id="id1"/>
-    <table frame="all" id="table_1_3.t7">
+    <table frame="all" id="table_1_3.section1.t6">
       <title>Table with anchors</title>
       <tgroup cols="1">
         <thead>
Modified: trunk/tools/quickbook/test/template-section.gold
==============================================================================
--- trunk/tools/quickbook/test/template-section.gold	(original)
+++ trunk/tools/quickbook/test/template-section.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -12,7 +12,7 @@
       Hello.
     </para>
     <anchor id="section_in_a_template.test.just_to_test_id_generation"/>
-    <bridgehead renderas="sect3" id="section_in_a_template.test.just_to_test_id_generation-heading">
+    <bridgehead renderas="sect3" id="section_in_a_template.test.h0">
       <link linkend="section_in_a_template.test.just_to_test_id_generation">Just
       to test id generation</link>
     </bridgehead>
Modified: trunk/tools/quickbook/test/unicode-escape.gold
==============================================================================
--- trunk/tools/quickbook/test/unicode-escape.gold	(original)
+++ trunk/tools/quickbook/test/unicode-escape.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -2,7 +2,7 @@
 <!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
 <article id="utf_8_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>UTF-8 test</title> <anchor id="utf_8_test.i__xf1_t__xeb_rn__xe2_ti__xf4_n__xe0_liz__xe6_ti__xf8_n"/>
-  <bridgehead renderas="sect2" id="utf_8_test.i__xf1_t__xeb_rn__xe2_ti__xf4_n__xe0_liz__xe6_ti__xf8_n-heading">
+  <bridgehead renderas="sect2" id="utf_8_test.h0">
     <link linkend="utf_8_test.i__xf1_t__xeb_rn__xe2_ti__xf4_n__xe0_liz__xe6_ti__xf8_n">Iñtërnâtiônàlizætiøn</link>
   </bridgehead>
   <itemizedlist>
Modified: trunk/tools/quickbook/test/unit/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/unit/Jamfile.v2	(original)
+++ trunk/tools/quickbook/test/unit/Jamfile.v2	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -13,5 +13,5 @@
     ;
 
 run values_test.cpp ../../src/values.cpp ;
-run post_process_test.cpp ../../src/post_process.cpp ;
+run post_process_test.cpp ../../src/post_process.cpp ../../src/id_generator.cpp ;
 run iterator_tests.cpp ../../src/values.cpp ;
Modified: trunk/tools/quickbook/test/utf-8-bom.gold
==============================================================================
--- trunk/tools/quickbook/test/utf-8-bom.gold	(original)
+++ trunk/tools/quickbook/test/utf-8-bom.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -2,7 +2,7 @@
 <!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
 <article id="utf_8_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>UTF-8 test</title> <anchor id="utf_8_test.i__t__rn__ti__n__liz__ti__n"/>
-  <bridgehead renderas="sect2" id="utf_8_test.i__t__rn__ti__n__liz__ti__n-heading">
+  <bridgehead renderas="sect2" id="utf_8_test.h0">
     <link linkend="utf_8_test.i__t__rn__ti__n__liz__ti__n">Iñtërnâtiônàlizætiøn</link>
   </bridgehead>
   <itemizedlist>
Modified: trunk/tools/quickbook/test/utf-8.gold
==============================================================================
--- trunk/tools/quickbook/test/utf-8.gold	(original)
+++ trunk/tools/quickbook/test/utf-8.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -2,7 +2,7 @@
 <!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
 <article id="utf_8_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>UTF-8 test</title> <anchor id="utf_8_test.i__t__rn__ti__n__liz__ti__n"/>
-  <bridgehead renderas="sect2" id="utf_8_test.i__t__rn__ti__n__liz__ti__n-heading">
+  <bridgehead renderas="sect2" id="utf_8_test.h0">
     <link linkend="utf_8_test.i__t__rn__ti__n__liz__ti__n">Iñtërnâtiônàlizætiøn</link>
   </bridgehead>
   <itemizedlist>
Modified: trunk/tools/quickbook/test/xml-escape_1_2.gold
==============================================================================
--- trunk/tools/quickbook/test/xml-escape_1_2.gold	(original)
+++ trunk/tools/quickbook/test/xml-escape_1_2.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -4,7 +4,7 @@
 dirname="test_that__amp____lt__are_being_escaped_" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
  xmlns:xi="http://www.w3.org/2001/XInclude">
   <libraryinfo>
-    <legalnotice id="legal.test_that__amp____lt__are_being_escaped_">
+    <legalnotice id="test_that__amp____lt__are_being_escaped_.legal">
       <para>
         & should be &amp;, < should &lt;
       </para>
Modified: trunk/tools/quickbook/test/xml-escape_1_5.gold
==============================================================================
--- trunk/tools/quickbook/test/xml-escape_1_5.gold	(original)
+++ trunk/tools/quickbook/test/xml-escape_1_5.gold	2011-07-24 16:40:38 EDT (Sun, 24 Jul 2011)
@@ -4,7 +4,7 @@
 dirname="test_that__amp____lt__are_being_escaped_" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
  xmlns:xi="http://www.w3.org/2001/XInclude">
   <libraryinfo>
-    <legalnotice id="legal.test_that__amp____lt__are_being_escaped_">
+    <legalnotice id="test_that__amp____lt__are_being_escaped_.legal">
       <para>
         & should be &amp;, < should &lt;
       </para>