|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59572 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-02-07 09:49:01
Author: danieljames
Date: 2010-02-07 09:49:00 EST (Sun, 07 Feb 2010)
New Revision: 59572
URL: http://svn.boost.org/trac/boost/changeset/59572
Log:
Handle years better in the html encoder.
Very slight change to the parser - it'll now accept any integer for the
years, before it was only a 4 digit value.
Text files modified:
branches/quickbook-1.5-spirit2/boostbook.cpp | 2
branches/quickbook-1.5-spirit2/doc_info.cpp | 4 +-
branches/quickbook-1.5-spirit2/doc_info.hpp | 2
branches/quickbook-1.5-spirit2/html.cpp | 42 +++++++++++++++++++++++++++++++++++----
4 files changed, 41 insertions(+), 9 deletions(-)
Modified: branches/quickbook-1.5-spirit2/boostbook.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/boostbook.cpp (original)
+++ branches/quickbook-1.5-spirit2/boostbook.cpp 2010-02-07 09:49:00 EST (Sun, 07 Feb 2010)
@@ -399,7 +399,7 @@
{
state.phrase << "<copyright>\n";
- BOOST_FOREACH(std::string const& year, copyright.first) {
+ BOOST_FOREACH(unsigned int year, copyright.first) {
state.phrase << "<year>" << year << "</year>\n";
}
Modified: branches/quickbook-1.5-spirit2/doc_info.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info.cpp (original)
+++ branches/quickbook-1.5-spirit2/doc_info.cpp 2010-02-07 09:49:00 EST (Sun, 07 Feb 2010)
@@ -63,7 +63,7 @@
qi::rule<iterator> comment, space, hard_space;
qi::rule<iterator, std::pair<unsigned, unsigned>()> quickbook_version;
qi::rule<iterator, std::string()> phrase, doc_version, doc_id, doc_dirname, doc_category, doc_last_revision, doc_source_mode, doc_purpose, doc_license;
- qi::rule<iterator, std::pair<std::vector<std::string>, std::string>()> doc_copyright;
+ qi::rule<iterator, std::pair<std::vector<unsigned int>, std::string>()> doc_copyright;
qi::rule<iterator, std::vector<std::pair<std::string, std::string> >()> doc_authors;
qi::rule<iterator, boost::fusion::reverse_view<
std::pair<std::string, std::string> >()> doc_author;
@@ -139,7 +139,7 @@
doc_copyright =
"copyright"
>> hard_space
- >> +(qi::repeat(4)[qi::digit] >> space)
+ >> +(qi::uint_ >> space)
>> qi::raw[(*(qi::char_ - ']'))]
;
Modified: branches/quickbook-1.5-spirit2/doc_info.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info.hpp (original)
+++ branches/quickbook-1.5-spirit2/doc_info.hpp 2010-02-07 09:49:00 EST (Sun, 07 Feb 2010)
@@ -18,7 +18,7 @@
{
struct doc_info
{
- typedef std::vector<std::string> copyright_years;
+ typedef std::vector<unsigned int> copyright_years;
typedef std::pair<copyright_years, std::string> copyright_entry;
typedef std::vector<copyright_entry> copyright_list;
typedef std::pair<std::string, std::string> author;
Modified: branches/quickbook-1.5-spirit2/html.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/html.cpp (original)
+++ branches/quickbook-1.5-spirit2/html.cpp 2010-02-07 09:49:00 EST (Sun, 07 Feb 2010)
@@ -355,12 +355,33 @@
{
state.phrase << "<div>\nCopyright © ";
- bool previous = false;
- BOOST_FOREACH(std::string const& year, copyright.first) {
- if(previous) state.phrase << ", ";
- state.phrase << year;
- previous = true;
+ unsigned int range_state = 0;
+ unsigned int previous = 0;
+ BOOST_FOREACH(unsigned int year, copyright.first) {
+ switch(range_state) {
+ case 0: // Start
+ state.phrase << year;
+ range_state = 1;
+ break;
+ case 1: // Printed a year in last iteration
+ if(year == previous + 1) {
+ range_state = 2;
+ }
+ else {
+ state.phrase << ", " << year;
+ range_state = 1;
+ }
+ break;
+ case 2: // In the middle of a range
+ if(year != previous + 1) {
+ state.phrase << " - " << previous << ", " << year;
+ range_state = 1;
+ }
+ break;
+ }
+ previous = year;
}
+ if(range_state == 2) state.phrase << " - " << previous;
state.phrase
<< " "
@@ -373,6 +394,17 @@
<< "</p>\n";
}
+ if (!info.doc_license.empty())
+ {
+ state.phrase
+ << "<p class=\"license\">\n"
+ << info.doc_license
+ << "\n"
+ << "</p>\n"
+ << "\n"
+ ;
+ }
+
state.phrase
<< "</header>"
;
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