From cc517751b436ddcdc60d4e4c0bea0a3ffe8dd58d Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 20 Mar 2010 07:56:38 +0000 Subject: [PATCH] Merge from trunk, fixing unicode escapes in the process. [SVN r60730] --- doc/quickbook.qbk | 31 +++++++++++++++++++++++++++++-- phrase_grammar.cpp | 16 ++++++++++++---- test/unicode-escape.gold | 17 +++++++++++++++++ test/unicode-escape.quickbook | 11 +++++++++-- 4 files changed, 67 insertions(+), 8 deletions(-) diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index e585c9b..6849777 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -180,6 +180,16 @@ Features include: * Accept a space between `section:` and the section id. * Support table ids. +[h3 Version 1.5.1] + +* Improve the post processor's list of block elements. `table`, `entry` and + `varlistentry` are treated as blocks. `replaceable` is treated as an inline + element. +* Check that `[section]` and `[endsect]` tags are balanced in templates. +* Add unicode escape characters, eg. `\u03B1` for \u03B1. +* Support UTF-8 files with a unicode byte order mark. +* Disallow `[` in simple markup. Fixes some errors with mismatched punctuation. + [endsect] [section:syntax Syntax Summary] @@ -621,6 +631,23 @@ and table cells (see __tables__) may now contain paragraphs.] The escaped space: `\ ` also has a special meaning. The escaped space is removed from the output. +[endsect] +[section Unicode escape] + +You can enter any 16-bit unicode character by using `\u` followed by its 4 digit +hexadecimal code, or a 32-bit character by using `\U` followed by an 8 digit +hexadecimal code. eg. + +[pre''' +\u03B1 + \u03B2 +'''] + +will generate: + +[: +\u03B1 + \u03B2 +] + [endsect] [section Images] @@ -2108,8 +2135,8 @@ boostbook standalone : my_doc : - boost.image.src=images/my_project_logo.png - boost.image.alt="\\"My Project\\"" + boost.image.src\=images/my_project_logo.png + boost.image.alt\="\\"My Project\\"" boost.image.w=100 boost.image.h=50 nav.layout=none diff --git a/phrase_grammar.cpp b/phrase_grammar.cpp index 1ceaf1d..8c9d957 100644 --- a/phrase_grammar.cpp +++ b/phrase_grammar.cpp @@ -146,13 +146,15 @@ namespace quickbook qi::rule& escape_break = store_.create(); qi::rule& escape_punct = store_.create(); qi::rule& escape_markup = store_.create(); - qi::rule& escape_unicode = store_.create(); + qi::rule& escape_unicode16 = store_.create(); + qi::rule& escape_unicode32 = store_.create(); escape = ( escape_break | "\\ " // ignore an escaped char | escape_punct - | escape_unicode + | escape_unicode16 + | escape_unicode32 | escape_markup ) [actions.process] ; @@ -176,9 +178,15 @@ namespace quickbook >> "'''" ; - escape_unicode = + escape_unicode16 = "\\u" - >> qi::raw[qi::repeat(1,4)[qi::hex]] + >> qi::raw[qi::repeat(4)[qi::xdigit]] + >> qi::attr(nothing()) + ; + + escape_unicode32 = + "\\U" + >> qi::raw[qi::repeat(8)[qi::xdigit]] >> qi::attr(nothing()) ; diff --git a/test/unicode-escape.gold b/test/unicode-escape.gold index 8c2bd69..e2f8b12 100644 --- a/test/unicode-escape.gold +++ b/test/unicode-escape.gold @@ -82,4 +82,21 @@ Ωω Omega + + In the unlikely event that you've got a Mahjong font: + + + + 🀀 East Wind + + + 🀁 South Wind + + + 🀂 West Wind + + + 🀃 North Wind + + diff --git a/test/unicode-escape.quickbook b/test/unicode-escape.quickbook index ce4ad88..becdef6 100644 --- a/test/unicode-escape.quickbook +++ b/test/unicode-escape.quickbook @@ -2,7 +2,7 @@ [quickbook 1.5] ] -[heading I\uF1t\uEBrn\uE2ti\uF4n\uE0liz\uE6ti\uF8n] +[heading I\u00F1t\u00EBrn\u00E2ti\u00F4n\u00E0liz\u00E6ti\u00F8n] * \u0391\u03B1 Alpha * \u0392\u03B2 Beta @@ -27,4 +27,11 @@ * \u03A6\u03C6 Phi * \u03A7\u03C7 Chi * \u03A8\u03C8 Psi -* \u03A9\u03C9 Omega \ No newline at end of file +* \u03A9\u03C9 Omega + +In the unlikely event that you've got a Mahjong font: + +* \U0001F000 East Wind +* \U0001F001 South Wind +* \U0001F002 West Wind +* \U0001F003 North Wind \ No newline at end of file