|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60053 - in trunk/tools/quickbook: . detail test
From: daniel_james_at_[hidden]
Date: 2010-03-01 14:40:16
Author: danieljames
Date: 2010-03-01 14:40:15 EST (Mon, 01 Mar 2010)
New Revision: 60053
URL: http://svn.boost.org/trac/boost/changeset/60053
Log:
Add a unicode escape sequence.
Added:
trunk/tools/quickbook/test/unicode-escape.gold (contents, props changed)
trunk/tools/quickbook/test/unicode-escape.quickbook (contents, props changed)
Text files modified:
trunk/tools/quickbook/detail/actions.cpp | 16 ++++++++++++++++
trunk/tools/quickbook/detail/actions.hpp | 8 ++++++++
trunk/tools/quickbook/detail/actions_class.cpp | 1 +
trunk/tools/quickbook/detail/actions_class.hpp | 1 +
trunk/tools/quickbook/phrase.hpp | 4 ++++
trunk/tools/quickbook/test/Jamfile.v2 | 1 +
6 files changed, 31 insertions(+), 0 deletions(-)
Modified: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp (original)
+++ trunk/tools/quickbook/detail/actions.cpp 2010-03-01 14:40:15 EST (Mon, 01 Mar 2010)
@@ -14,6 +14,7 @@
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/regex/pending/unicode_iterator.hpp>
#include "./quickbook.hpp"
#include "./actions.hpp"
#include "./utils.hpp"
@@ -415,6 +416,21 @@
detail::print_char(*first, phrase.get());
}
+ void escape_unicode_action::operator()(iterator first, iterator last) const
+ {
+ using namespace std;
+ std::string value(first, last);
+ boost::uint32_t unicode_value = strtol(value.c_str(), 0, 16);
+ if(unicode_value < 128) {
+ detail::print_char(unicode_value, phrase.get());
+ }
+ else {
+ boost::utf8_output_iterator<ostream_iterator<char> > phrase_iter(
+ ostream_iterator<char>(phrase.get()));
+ *phrase_iter++ = unicode_value;
+ }
+ }
+
void attribute_action::operator()(iterator first, iterator last) const
{
boost::spirit::classic::file_position const pos = first.get_position();
Modified: trunk/tools/quickbook/detail/actions.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.hpp (original)
+++ trunk/tools/quickbook/detail/actions.hpp 2010-03-01 14:40:15 EST (Mon, 01 Mar 2010)
@@ -368,6 +368,14 @@
collector& phrase;
};
+ struct escape_unicode_action
+ {
+ escape_unicode_action(collector& phrase) : phrase(phrase) {}
+ void operator()(iterator first, iterator last) const;
+
+ collector& phrase;
+ };
+
struct attribute_action
{
// Handle image attributes
Modified: trunk/tools/quickbook/detail/actions_class.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions_class.cpp (original)
+++ trunk/tools/quickbook/detail/actions_class.cpp 2010-03-01 14:40:15 EST (Mon, 01 Mar 2010)
@@ -98,6 +98,7 @@
, tip(out, temp_para, tip_pre, tip_post)
, plain_char(phrase)
, raw_char(phrase)
+ , escape_unicode(phrase)
, attribute(attributes, attribute_name)
, image(phrase, attributes, image_fileref)
, cond_phrase_pre(phrase, conditions, macro)
Modified: trunk/tools/quickbook/detail/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions_class.hpp (original)
+++ trunk/tools/quickbook/detail/actions_class.hpp 2010-03-01 14:40:15 EST (Mon, 01 Mar 2010)
@@ -122,6 +122,7 @@
phrase_action warning, caution, important, note, tip;
plain_char_action plain_char;
raw_char_action raw_char;
+ escape_unicode_action escape_unicode;
attribute_action attribute;
image_action image;
cond_phrase_action_pre cond_phrase_pre;
Modified: trunk/tools/quickbook/phrase.hpp
==============================================================================
--- trunk/tools/quickbook/phrase.hpp (original)
+++ trunk/tools/quickbook/phrase.hpp 2010-03-01 14:40:15 EST (Mon, 01 Mar 2010)
@@ -275,6 +275,10 @@
str_p("\\n") [actions.break_]
| "\\ " // ignore an escaped char
| '\\' >> punct_p [actions.raw_char]
+ | "\\u">> repeat_p(1,4)
+ [
+ chset<>("0-9a-fA-F")
+ ] [actions.escape_unicode]
| (
("'''" >> !eol) [actions.escape_pre]
>> *(anychar_p - "'''") [actions.raw_char]
Modified: trunk/tools/quickbook/test/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/Jamfile.v2 (original)
+++ trunk/tools/quickbook/test/Jamfile.v2 2010-03-01 14:40:15 EST (Mon, 01 Mar 2010)
@@ -50,6 +50,7 @@
[ quickbook-fail-test fail-template-section-3 ]
[ quickbook-test utf-8 ]
[ quickbook-test utf-8-bom ]
+ [ quickbook-test unicode-escape ]
[ quickbook-fail-test utf-16be-bom ]
[ quickbook-fail-test utf-16le-bom ]
;
Added: trunk/tools/quickbook/test/unicode-escape.gold
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/unicode-escape.gold 2010-03-01 14:40:15 EST (Mon, 01 Mar 2010)
@@ -0,0 +1,85 @@
+<?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="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>
+ <articleinfo>
+ </articleinfo>
+ <anchor id="utf_8_test.i__t__rn__ti__n__liz__ti__n"/>
+ <bridgehead renderas="sect2">
+ <link linkend="utf_8_test.i__t__rn__ti__n__liz__ti__n">Iñtërnâtiônà lizætiøn</link>
+ </bridgehead>
+ <itemizedlist>
+ <listitem>
+ Îα Alpha
+ </listitem>
+ <listitem>
+ Îβ Beta
+ </listitem>
+ <listitem>
+ Îγ Gamma
+ </listitem>
+ <listitem>
+ Îδ Delta
+ </listitem>
+ <listitem>
+ Îε Epsilon
+ </listitem>
+ <listitem>
+ Îζ Zeta
+ </listitem>
+ <listitem>
+ Îη Eta
+ </listitem>
+ <listitem>
+ Îθ Theta
+ </listitem>
+ <listitem>
+ Îι Iota
+ </listitem>
+ <listitem>
+ Îκ Kappa
+ </listitem>
+ <listitem>
+ Îλ Lambda
+ </listitem>
+ <listitem>
+ Îμ Mu
+ </listitem>
+ <listitem>
+ Îν Nu
+ </listitem>
+ <listitem>
+ Îξ Xi
+ </listitem>
+ <listitem>
+ Îο Omicron
+ </listitem>
+ <listitem>
+ Î Ï Pi
+ </listitem>
+ <listitem>
+ Î¡Ï Rho
+ </listitem>
+ <listitem>
+ ΣÏÏ Sigma
+ </listitem>
+ <listitem>
+ Î¤Ï Tau
+ </listitem>
+ <listitem>
+ Î¥Ï
Upsilon
+ </listitem>
+ <listitem>
+ Î¦Ï Phi
+ </listitem>
+ <listitem>
+ Î§Ï Chi
+ </listitem>
+ <listitem>
+ Î¨Ï Psi
+ </listitem>
+ <listitem>
+ Î©Ï Omega
+ </listitem>
+ </itemizedlist>
+</article>
Added: trunk/tools/quickbook/test/unicode-escape.quickbook
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/unicode-escape.quickbook 2010-03-01 14:40:15 EST (Mon, 01 Mar 2010)
@@ -0,0 +1,30 @@
+[article UTF-8 test
+ [quickbook 1.5]
+]
+
+[heading I\uF1t\uEBrn\uE2ti\uF4n\uE0liz\uE6ti\uF8n]
+
+* \u0391\u03B1 Alpha
+* \u0392\u03B2 Beta
+* \u0393\u03B3 Gamma
+* \u0394\u03B4 Delta
+* \u0395\u03B5 Epsilon
+* \u0396\u03B6 Zeta
+* \u0397\u03B7 Eta
+* \u0398\u03B8 Theta
+* \u0399\u03B9 Iota
+* \u039A\u03BA Kappa
+* \u039B\u03BB Lambda
+* \u039C\u03BC Mu
+* \u039D\u03BD Nu
+* \u039E\u03BE Xi
+* \u039F\u03BF Omicron
+* \u03A0\u03C0 Pi
+* \u03A1\u03C1 Rho
+* \u03A3\u03C3\u03C2 Sigma
+* \u03A4\u03C4 Tau
+* \u03A5\u03C5 Upsilon
+* \u03A6\u03C6 Phi
+* \u03A7\u03C7 Chi
+* \u03A8\u03C8 Psi
+* \u03A9\u03C9 Omega
\ 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