|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63734 - in trunk/tools/quickbook: detail doc test
From: daniel_james_at_[hidden]
Date: 2010-07-08 03:13:29
Author: danieljames
Date: 2010-07-08 03:13:26 EDT (Thu, 08 Jul 2010)
New Revision: 63734
URL: http://svn.boost.org/trac/boost/changeset/63734
Log:
Fix xml encoding in a few places.
Added:
trunk/tools/quickbook/test/xml-escape_1_2.gold (contents, props changed)
trunk/tools/quickbook/test/xml-escape_1_2.quickbook (contents, props changed)
trunk/tools/quickbook/test/xml-escape_1_5.gold (contents, props changed)
trunk/tools/quickbook/test/xml-escape_1_5.quickbook (contents, props changed)
Text files modified:
trunk/tools/quickbook/detail/actions.cpp | 120 ++++++++++++++++++++++++++++-----------
trunk/tools/quickbook/doc/quickbook.qbk | 1
trunk/tools/quickbook/test/Jamfile.v2 | 2
3 files changed, 88 insertions(+), 35 deletions(-)
Modified: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp (original)
+++ trunk/tools/quickbook/detail/actions.cpp 2010-07-08 03:13:26 EDT (Thu, 08 Jul 2010)
@@ -1450,8 +1450,12 @@
void xml_author::operator()(std::pair<std::string, std::string> const& author) const
{
out << " <author>\n"
- << " <firstname>" << author.first << "</firstname>\n"
- << " <surname>" << author.second << "</surname>\n"
+ << " <firstname>";
+ detail::print_string(author.first, out.get());
+ out << "</firstname>\n"
+ << " <surname>";
+ detail::print_string(author.second, out.get());
+ out << "</surname>\n"
<< " </author>\n";
}
@@ -1464,7 +1468,9 @@
, copyright.first.end()
, xml_year(out));
- out << " <holder>" << copyright.second << "</holder>\n"
+ out << " <holder>";
+ detail::print_string(copyright.second, out.get());
+ out << "</holder>\n"
<< " </copyright>\n"
<< "\n"
;
@@ -1532,19 +1538,27 @@
<< " PUBLIC \"-//Boost//DTD BoostBook XML V1.0//EN\"\n"
<< " \"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd\">\n"
<< '<' << actions.doc_type << "\n"
- << " id=\"" << actions.doc_id << "\"\n";
+ << " id=\"";
+ detail::print_string(actions.doc_id, out.get());
+ out << "\"\n";
if(actions.doc_type == "library")
{
- out << " name=\"" << actions.doc_title << "\"\n";
+ out << " name=\"";
+ detail::print_string(actions.doc_title, out.get());
+ out << "\"\n";
}
if(!actions.doc_dirname.empty())
{
- out << " dirname=\"" << actions.doc_dirname << "\"\n";
+ out << " dirname=\"";
+ detail::print_string(actions.doc_dirname, out.get());
+ out << "\"\n";
}
- out << " last-revision=\"" << actions.doc_last_revision << "\" \n"
+ out << " last-revision=\"";
+ detail::print_string(actions.doc_last_revision, out.get());
+ out << "\" \n"
<< " xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n";
if(actions.doc_type == "library") {
@@ -1574,9 +1588,12 @@
{
if (!actions.doc_title.empty())
{
- out<< " <title>" << actions.doc_title;
- if (!actions.doc_version.empty())
- out << ' ' << actions.doc_version;
+ out<< " <title>";
+ detail::print_string(actions.doc_title, out.get());
+ if (!actions.doc_version.empty()) {
+ out << ' ';
+ detail::print_string(actions.doc_version, out.get());
+ }
out<< "</title>\n\n\n";
}
}
@@ -1607,35 +1624,68 @@
if (qbk_version_n < 103)
{
- // version < 1.3 compatibility
- actions.doc_license = actions.doc_license_1_1;
- actions.doc_purpose = actions.doc_purpose_1_1;
- }
-
- if (!actions.doc_license.empty())
- {
- out << " <legalnotice>\n"
- << " <para>\n"
- << " " << actions.doc_license << "\n"
- << " </para>\n"
- << " </legalnotice>\n"
- << "\n"
- ;
+ if (!actions.doc_license_1_1.empty())
+ {
+ out << " <legalnotice>\n"
+ << " <para>\n"
+ << " ";
+ detail::print_string(actions.doc_license_1_1, out.get());
+ out << "\n"
+ << " </para>\n"
+ << " </legalnotice>\n"
+ << "\n"
+ ;
+ }
}
-
- if (!actions.doc_purpose.empty())
+ else
{
- if (actions.doc_type == "library")
+ if (!actions.doc_license.empty())
{
- out << " <" << actions.doc_type << "purpose>\n"
- << " " << actions.doc_purpose
- << " </" << actions.doc_type << "purpose>\n"
+ out << " <legalnotice>\n"
+ << " <para>\n"
+ << " " << actions.doc_license << "\n"
+ << " </para>\n"
+ << " </legalnotice>\n"
<< "\n"
;
}
- else
+ }
+
+ if (qbk_version_n < 103)
+ {
+ if (!actions.doc_purpose_1_1.empty())
{
- invalid_attributes.push_back("purpose");
+ if (actions.doc_type == "library")
+ {
+ out << " <" << actions.doc_type << "purpose>\n"
+ << " ";
+ detail::print_string(actions.doc_purpose_1_1, out.get());
+ out << " </" << actions.doc_type << "purpose>\n"
+ << "\n"
+ ;
+ }
+ else
+ {
+ invalid_attributes.push_back("purpose");
+ }
+ }
+ }
+ else
+ {
+ if (!actions.doc_purpose.empty())
+ {
+ if (actions.doc_type == "library")
+ {
+ out << " <" << actions.doc_type << "purpose>\n"
+ << " " << actions.doc_purpose
+ << " </" << actions.doc_type << "purpose>\n"
+ << "\n"
+ ;
+ }
+ else
+ {
+ invalid_attributes.push_back("purpose");
+ }
}
}
@@ -1648,9 +1698,9 @@
end = actions.doc_categories.end();
it != end; ++it)
{
- out << " <" << actions.doc_type << "category name=\"category:"
- << *it
- << "\"></" << actions.doc_type << "category>\n"
+ out << " <" << actions.doc_type << "category name=\"category:";
+ detail::print_string(*it, out.get());
+ out << "\"></" << actions.doc_type << "category>\n"
<< "\n"
;
}
Modified: trunk/tools/quickbook/doc/quickbook.qbk
==============================================================================
--- trunk/tools/quickbook/doc/quickbook.qbk (original)
+++ trunk/tools/quickbook/doc/quickbook.qbk 2010-07-08 03:13:26 EDT (Thu, 08 Jul 2010)
@@ -204,6 +204,7 @@
* Don't require commas between authors in docinfo.
* Allow empty document bodies.
* Less empty paragraphs.
+* XML encode the documentation info correctly.
* Preparing for quickbook 1.6:
* When automatically generating ids for headers, use the quickbook
source, rather than the generated docbook.
Modified: trunk/tools/quickbook/test/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/Jamfile.v2 (original)
+++ trunk/tools/quickbook/test/Jamfile.v2 2010-07-08 03:13:26 EDT (Thu, 08 Jul 2010)
@@ -48,6 +48,8 @@
[ quickbook-test doc-info-4 ]
[ quickbook-test callouts ]
[ quickbook-test simple_markup ]
+ [ quickbook-test xml-escape_1_2 ]
+ [ quickbook-test xml-escape_1_5 ]
[ quickbook-test blocks ]
[ quickbook-fail-test fail-include ]
[ quickbook-fail-test fail-import ]
Added: trunk/tools/quickbook/test/xml-escape_1_2.gold
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/xml-escape_1_2.gold 2010-07-08 03:13:26 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,37 @@
+<?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">
+<library id="test_that______are_being_escaped_" name="Test that &, < are being escaped."
+dirname="test_that______are_being_escaped_" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <libraryinfo>
+ <librarypurpose>
+ & should be &amp;, < should &lt;
+ </librarypurpose>
+ </libraryinfo>
+ <title>Test that &, < are being escaped.</title>
+ <section id="test_that______are_being_escaped_.escapes___explicitly_written_markup">
+ <title>Escapes & explicitly written markup</title>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ & -> &amp;
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ < -> &lt;
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ > -> &gt;
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ " -> &quot;
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ </section>
+</library>
Added: trunk/tools/quickbook/test/xml-escape_1_2.quickbook
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/xml-escape_1_2.quickbook 2010-07-08 03:13:26 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,13 @@
+[library Test that &, < are being escaped.
+ [quickbook 1.2]
+ [purpose & should be &, < should <]
+]
+
+[section Escapes & explicitly written markup]
+
+* & -> &
+* < -> <
+* > -> >
+* " -> "
+
+[endsect]
\ No newline at end of file
Added: trunk/tools/quickbook/test/xml-escape_1_5.gold
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/xml-escape_1_5.gold 2010-07-08 03:13:26 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,38 @@
+<?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">
+<library id="test_that______are_being_escaped_" name="Test that &, < are being escaped."
+dirname="test_that______are_being_escaped_" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <libraryinfo>
+ <librarypurpose>
+ & should be &amp;, < should &lt;
+ </librarypurpose>
+ </libraryinfo>
+ <title>Test that &, < are being escaped.</title>
+ <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>
+ <simpara>
+ & -> &amp;
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ < -> &lt;
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ > -> &gt;
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ " -> &quot;
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ </section>
+</library>
Added: trunk/tools/quickbook/test/xml-escape_1_5.quickbook
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/xml-escape_1_5.quickbook 2010-07-08 03:13:26 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,13 @@
+[library Test that &, < are being escaped.
+ [quickbook 1.5]
+ [purpose & should be &, < should <]
+]
+
+[section Escapes & explicitly written markup]
+
+* & -> &
+* < -> <
+* > -> >
+* " -> "
+
+[endsect]
\ No newline at end of file
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk