|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61080 - in branches/quickbook-1.5-spirit2: . test
From: daniel_james_at_[hidden]
Date: 2010-04-05 15:44:00
Author: danieljames
Date: 2010-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
New Revision: 61080
URL: http://svn.boost.org/trac/boost/changeset/61080
Log:
Similar escape fix for older quickbook documentation versions.
Added:
branches/quickbook-1.5-spirit2/test/xml-escape_1_2.gold
- copied, changed from r61079, /branches/quickbook-1.5-spirit2/test/xml-escape.gold
branches/quickbook-1.5-spirit2/test/xml-escape_1_2.quickbook
- copied, changed from r61079, /branches/quickbook-1.5-spirit2/test/xml-escape.quickbook
branches/quickbook-1.5-spirit2/test/xml-escape_1_5.gold (contents, props changed)
- copied, changed from r61079, /branches/quickbook-1.5-spirit2/test/xml-escape.gold
branches/quickbook-1.5-spirit2/test/xml-escape_1_5.quickbook (contents, props changed)
- copied, changed from r61079, /branches/quickbook-1.5-spirit2/test/xml-escape.quickbook
Removed:
branches/quickbook-1.5-spirit2/test/xml-escape.gold
branches/quickbook-1.5-spirit2/test/xml-escape.quickbook
Text files modified:
branches/quickbook-1.5-spirit2/boostbook.cpp | 8 ++++----
branches/quickbook-1.5-spirit2/doc_info.hpp | 7 +++++--
branches/quickbook-1.5-spirit2/doc_info_grammar.cpp | 12 ++++++++----
branches/quickbook-1.5-spirit2/encoder_impl.hpp | 24 ++++++++++++++++++++++++
branches/quickbook-1.5-spirit2/html.cpp | 6 +++---
branches/quickbook-1.5-spirit2/test/Jamfile.v2 | 3 ++-
branches/quickbook-1.5-spirit2/test/xml-escape_1_2.gold | 3 +--
branches/quickbook-1.5-spirit2/test/xml-escape_1_2.quickbook | 2 +-
8 files changed, 48 insertions(+), 17 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-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
@@ -482,12 +482,12 @@
;
}
- if (!info.doc_license.empty())
+ if (!boost::apply_visitor(empty_visitor(), info.doc_license))
{
state.phrase
<< "<legalnotice>\n"
<< "<para>\n"
- << info.doc_license
+ << boost::apply_visitor(encode_raw_visitor(*this), info.doc_license)
<< "\n"
<< "</para>\n"
<< "</legalnotice>\n"
@@ -495,11 +495,11 @@
;
}
- if (!info.doc_purpose.empty())
+ if (!boost::apply_visitor(empty_visitor(), info.doc_purpose))
{
state.phrase
<< "<" << info.doc_type << "purpose>\n"
- << info.doc_purpose
+ << boost::apply_visitor(encode_raw_visitor(*this), info.doc_purpose)
<< "</" << info.doc_type << "purpose>\n"
<< "\n"
;
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-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
@@ -13,6 +13,7 @@
#include <vector>
#include <string>
#include <utility>
+#include <boost/variant/variant.hpp>
#include "fwd.hpp"
#include "strings.hpp"
@@ -25,6 +26,8 @@
typedef std::vector<copyright_entry> copyright_list;
typedef std::pair<std::string, std::string> author;
typedef std::vector<author> author_list;
+ typedef boost::variant<raw_string, std::string> variant_string;
+ enum variant_string_enum { raw_string_type, string_type };
std::string doc_type;
raw_string doc_title;
@@ -32,10 +35,10 @@
raw_string doc_id;
raw_string doc_dirname;
copyright_list doc_copyrights;
- std::string doc_purpose;
+ variant_string doc_purpose;
raw_string doc_category;
author_list doc_authors;
- std::string doc_license;
+ variant_string doc_license;
raw_string doc_last_revision;
bool ignore;
};
Modified: branches/quickbook-1.5-spirit2/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/doc_info_grammar.cpp 2010-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
@@ -65,11 +65,12 @@
qi::rule<iterator, std::string()> phrase;
qi::rule<iterator, raw_source()> doc_version, doc_id, doc_dirname, doc_category, doc_last_revision;
qi::rule<iterator, std::string()> doc_source_mode; // TODO: raw_source
- qi::rule<iterator, std::string()> doc_purpose, doc_license;
+ qi::rule<iterator, doc_info::variant_string()> doc_purpose, doc_license;
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;
+ qi::rule<iterator, quickbook::raw_string()> raw_phrase;
};
doc_info_grammar::doc_info_grammar(quickbook::actions& actions)
@@ -148,7 +149,7 @@
doc_purpose =
"purpose" >> hard_space
>> (
- qi::eps(qbk_before(103)) >> qi::raw[phrase] |
+ qi::eps(qbk_before(103)) >> raw_phrase |
qi::eps(qbk_since(103)) >> phrase
)
;
@@ -168,12 +169,11 @@
doc_license =
"license" >> hard_space
>> (
- qi::eps(qbk_before(103)) >> qi::raw[phrase] |
+ qi::eps(qbk_before(103)) >> raw_phrase |
qi::eps(qbk_since(103)) >> phrase
)
;
-
doc_source_mode =
"source-mode" >> hard_space
>> (
@@ -183,6 +183,10 @@
)
;
+ raw_phrase =
+ qi::raw[phrase] [qi::_val = qi::_1]
+ ;
+
phrase =
qi::eps [actions.phrase_push]
>> *( common
Modified: branches/quickbook-1.5-spirit2/encoder_impl.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/encoder_impl.hpp (original)
+++ branches/quickbook-1.5-spirit2/encoder_impl.hpp 2010-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
@@ -102,4 +102,28 @@
typedef std::vector<footnote> footnotes;
std::stack<footnotes> footnote_stack;
};
+
+ struct empty_visitor {
+ typedef bool result_type;
+
+ template <typename T>
+ bool operator()(T const& x) const {
+ return x.empty();
+ }
+ };
+
+ struct encode_raw_visitor {
+ typedef std::string result_type;
+
+ encoder& encoder_;
+ encode_raw_visitor(encoder& e) : encoder_(e) {}
+
+ std::string operator()(raw_string const& x) const {
+ return encoder_.encode(x);
+ }
+
+ std::string operator()(std::string const& x) const {
+ return x;
+ }
+ };
}
\ No newline at end of file
Modified: branches/quickbook-1.5-spirit2/html.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/html.cpp (original)
+++ branches/quickbook-1.5-spirit2/html.cpp 2010-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
@@ -440,7 +440,7 @@
;
if(!info.doc_authors.empty() || !info.doc_copyrights.empty() ||
- !info.doc_license.empty())
+ !boost::apply_visitor(empty_visitor(), info.doc_license))
{
state.phrase << "<dl>\n";
@@ -510,12 +510,12 @@
}
}
- if (!info.doc_license.empty())
+ if (!boost::apply_visitor(empty_visitor(), info.doc_license))
{
state.phrase
<< "<dt>License:</dt>\n"
<< "<dd>"
- << info.doc_license
+ << boost::apply_visitor(encode_raw_visitor(*this), info.doc_license)
<< "</dd>\n"
;
}
Modified: branches/quickbook-1.5-spirit2/test/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5-spirit2/test/Jamfile.v2 (original)
+++ branches/quickbook-1.5-spirit2/test/Jamfile.v2 2010-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
@@ -37,7 +37,8 @@
[ quickbook-test doc-info-1 ]
[ quickbook-test callouts ]
[ quickbook-test simple_markup ]
- [ quickbook-test xml-escape ]
+ [ quickbook-test xml-escape_1_2 ]
+ [ quickbook-test xml-escape_1_5 ]
[ quickbook-fail-test fail-include ]
[ quickbook-fail-test fail-import ]
[ quickbook-fail-test fail-template-arguments1 ]
Deleted: branches/quickbook-1.5-spirit2/test/xml-escape.gold
==============================================================================
--- branches/quickbook-1.5-spirit2/test/xml-escape.gold 2010-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
+++ (empty file)
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="test_that______are_being_escaped_" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
- xmlns:xi="http://www.w3.org/2001/XInclude">
- <title>Test that &, < are being escaped.</title>
- <articleinfo>
- <articlepurpose>
- & should be &amp;, < should &lt;
- </articlepurpose>
- </articleinfo>
- <section id="test_that______are_being_escaped_.escapes___explicitly_written_markup">
- <title><link linkend="test_that______are_being_escaped_.escapes___explicitly_written_markup">Escapes
- & explicitly written markup</link></title>
- <itemizedlist>
- <listitem>
- & -> &amp;
- </listitem>
- <listitem>
- < -> &lt;
- </listitem>
- <listitem>
- > -> &gt;
- </listitem>
- <listitem>
- " -> &quot;
- </listitem>
- </itemizedlist>
- </section>
-</article>
Deleted: branches/quickbook-1.5-spirit2/test/xml-escape.quickbook
==============================================================================
--- branches/quickbook-1.5-spirit2/test/xml-escape.quickbook 2010-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
+++ (empty file)
@@ -1,13 +0,0 @@
-[article Test that &, < are being escaped.
- [quickbook 1.5]
- [purpose & should be &, < should <]
-]
-
-[section Escapes & explicitly written markup]
-
-* & -> &
-* < -> <
-* > -> >
-* " -> "
-
-[endsect]
\ No newline at end of file
Copied: branches/quickbook-1.5-spirit2/test/xml-escape_1_2.gold (from r61079, /branches/quickbook-1.5-spirit2/test/xml-escape.gold)
==============================================================================
--- /branches/quickbook-1.5-spirit2/test/xml-escape.gold (original)
+++ branches/quickbook-1.5-spirit2/test/xml-escape_1_2.gold 2010-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
@@ -9,8 +9,7 @@
</articlepurpose>
</articleinfo>
<section id="test_that______are_being_escaped_.escapes___explicitly_written_markup">
- <title><link linkend="test_that______are_being_escaped_.escapes___explicitly_written_markup">Escapes
- & explicitly written markup</link></title>
+ <title>Escapes & explicitly written markup</title>
<itemizedlist>
<listitem>
& -> &amp;
Copied: branches/quickbook-1.5-spirit2/test/xml-escape_1_2.quickbook (from r61079, /branches/quickbook-1.5-spirit2/test/xml-escape.quickbook)
==============================================================================
--- /branches/quickbook-1.5-spirit2/test/xml-escape.quickbook (original)
+++ branches/quickbook-1.5-spirit2/test/xml-escape_1_2.quickbook 2010-04-05 15:43:57 EDT (Mon, 05 Apr 2010)
@@ -1,5 +1,5 @@
[article Test that &, < are being escaped.
- [quickbook 1.5]
+ [quickbook 1.2]
[purpose & should be &, < should <]
]
Copied: branches/quickbook-1.5-spirit2/test/xml-escape_1_5.gold (from r61079, /branches/quickbook-1.5-spirit2/test/xml-escape.gold)
==============================================================================
Copied: branches/quickbook-1.5-spirit2/test/xml-escape_1_5.quickbook (from r61079, /branches/quickbook-1.5-spirit2/test/xml-escape.quickbook)
==============================================================================
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