|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53736 - in branches/quickbook-1.5: . detail test
From: daniel_james_at_[hidden]
Date: 2009-06-07 16:34:48
Author: danieljames
Date: 2009-06-07 16:34:47 EDT (Sun, 07 Jun 2009)
New Revision: 53736
URL: http://svn.boost.org/trac/boost/changeset/53736
Log:
Table ids. Refs #1194.
Text files modified:
branches/quickbook-1.5/block.hpp | 37 ++++++++++++++++++++++++++-----------
branches/quickbook-1.5/detail/actions.cpp | 20 ++++++++++++++++----
branches/quickbook-1.5/detail/actions.hpp | 2 +-
branches/quickbook-1.5/detail/actions_class.hpp | 2 +-
branches/quickbook-1.5/test/Jamfile.v2 | 1 +
5 files changed, 45 insertions(+), 17 deletions(-)
Modified: branches/quickbook-1.5/block.hpp
==============================================================================
--- branches/quickbook-1.5/block.hpp (original)
+++ branches/quickbook-1.5/block.hpp 2009-06-07 16:34:47 EDT (Sun, 07 Jun 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>
@@ -22,7 +23,6 @@
namespace quickbook
{
using namespace boost::spirit::classic;
- extern unsigned qbk_version_n;
template <typename Actions, bool skip_initial_spaces = false>
struct block_grammar : grammar<block_grammar<Actions> >
@@ -122,19 +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
- >> ( ':' >>
- (
- if_p(qbk_since(105u)) [space]
- >> (+(alnum_p | '_')) [assign_a(actions.element_id)]
- | eps_p [actions.section_warning]
- [assign_a(actions.element_id)]
- )
- | eps_p [assign_a(actions.element_id)]
- )
+ >> element_id
>> phrase [actions.begin_section]
;
@@ -290,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
@@ -426,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/quickbook-1.5/detail/actions.cpp
==============================================================================
--- branches/quickbook-1.5/detail/actions.cpp (original)
+++ branches/quickbook-1.5/detail/actions.cpp 2009-06-07 16:34:47 EDT (Sun, 07 Jun 2009)
@@ -819,10 +819,19 @@
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 = actions.element_id;
+ else if(has_title) table_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());
@@ -830,7 +839,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";
@@ -965,10 +977,10 @@
}
}
- void section_warning_action::operator()(iterator first, iterator) const
+ 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 section id after 'section:'.\n";
+ detail::outwarn(pos.file,pos.line) << "Empty id.\n";
}
fs::path path_difference(fs::path const& outdir, fs::path const& path)
Modified: branches/quickbook-1.5/detail/actions.hpp
==============================================================================
--- branches/quickbook-1.5/detail/actions.hpp (original)
+++ branches/quickbook-1.5/detail/actions.hpp 2009-06-07 16:34:47 EDT (Sun, 07 Jun 2009)
@@ -709,7 +709,7 @@
int& error_count;
};
- struct section_warning_action
+ struct element_id_warning_action
{
void operator()(iterator first, iterator last) const;
};
Modified: branches/quickbook-1.5/detail/actions_class.hpp
==============================================================================
--- branches/quickbook-1.5/detail/actions_class.hpp (original)
+++ branches/quickbook-1.5/detail/actions_class.hpp 2009-06-07 16:34:47 EDT (Sun, 07 Jun 2009)
@@ -192,7 +192,7 @@
begin_section_action begin_section;
end_section_action end_section;
- section_warning_action section_warning;
+ element_id_warning_action element_id_warning;
xinclude_action xinclude;
include_action include;
import_action import;
Modified: branches/quickbook-1.5/test/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5/test/Jamfile.v2 (original)
+++ branches/quickbook-1.5/test/Jamfile.v2 2009-06-07 16:34:47 EDT (Sun, 07 Jun 2009)
@@ -27,6 +27,7 @@
[ quickbook-test import ]
[ quickbook-test section_1_4 ]
[ quickbook-test section_1_5 ]
+ [ quickbook-test table_1_5 ]
[ quickbook-fail-test fail-include ]
[ quickbook-fail-test fail-import ]
[ quickbook-fail-test fail-template-arguments1 ]
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