Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75255 - in branches/quickbook-dev/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-11-02 03:58:33


Author: danieljames
Date: 2011-11-02 03:58:32 EDT (Wed, 02 Nov 2011)
New Revision: 75255
URL: http://svn.boost.org/trac/boost/changeset/75255

Log:
Quickbook: `role` tag for 1.6. Refs #5860.

This implements the markup `[role red Some red text]`. Although I'm not
sure I like it that much. It would be pretty easy to use a template for
the same effect.

This is just the quickbook part of supporting coloured text, to complete
the ticket there needs to be css support for html pages and xsl support
for pdfs.
Added:
   branches/quickbook-dev/tools/quickbook/test/role-1_6.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/role-1_6.quickbook (contents, props changed)
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/actions.cpp | 18 ++++++++++++++++++
   branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp | 16 ++++++++++++++--
   branches/quickbook-dev/tools/quickbook/src/phrase_tags.hpp | 1 +
   branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 | 1 +
   4 files changed, 34 insertions(+), 2 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.cpp 2011-11-02 03:58:32 EDT (Wed, 02 Nov 2011)
@@ -83,6 +83,7 @@
     void anchor_action(quickbook::actions&, value);
     void link_action(quickbook::actions&, value);
     void phrase_action(quickbook::actions&, value);
+ void role_action(quickbook::actions&, value);
     void footnote_action(quickbook::actions&, value);
     void raw_phrase_action(quickbook::actions&, value);
     void source_mode_action(quickbook::actions&, value);
@@ -165,6 +166,8 @@
             return footnote_action(actions, v);
         case phrase_tags::escape:
             return raw_phrase_action(actions, v);
+ case phrase_tags::role:
+ return role_action(actions, v);
         case source_mode_tags::cpp:
         case source_mode_tags::python:
         case source_mode_tags::teletype:
@@ -254,6 +257,21 @@
         values.finish();
     }
 
+ void role_action(quickbook::actions& actions, value role)
+ {
+ write_anchors(actions, actions.phrase);
+
+ value_consumer values = role;
+ actions.phrase
+ << "<phrase role=\"";
+ detail::print_string(values.consume().get_quickbook(), actions.phrase.get());
+ actions.phrase
+ << "\">"
+ << values.consume().get_boostbook()
+ << "</phrase>";
+ values.finish();
+ }
+
     void footnote_action(quickbook::actions& actions, value phrase)
     {
         write_anchors(actions, actions.phrase);

Modified: branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp 2011-11-02 03:58:32 EDT (Wed, 02 Nov 2011)
@@ -26,7 +26,8 @@
     struct phrase_element_grammar_local
     {
         cl::rule<scanner>
- image, anchor, link, empty, cond_phrase, inner_phrase
+ image, anchor, link, empty, cond_phrase, inner_phrase,
+ role
                         ;
     };
 
@@ -121,7 +122,18 @@
             ("python", element_info(element_info::phrase, &local.empty, source_mode_tags::python))
             ("teletype", element_info(element_info::phrase, &local.empty, source_mode_tags::teletype))
             ;
-
+
+ elements.add
+ ("role", element_info(element_info::phrase, &local.role, phrase_tags::role, 106u))
+ ;
+
+ local.role
+ = space
+ >> (+(cl::alnum_p | '_')) [actions.values.entry(ph::arg1, ph::arg2)]
+ >> hard_space
+ >> local.inner_phrase
+ ;
+
         local.empty = cl::eps_p;
 
         local.inner_phrase =

Modified: branches/quickbook-dev/tools/quickbook/src/phrase_tags.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/phrase_tags.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/phrase_tags.hpp 2011-11-02 03:58:32 EDT (Wed, 02 Nov 2011)
@@ -22,6 +22,7 @@
         (footnote)
         (escape)
         (break_mark)
+ (role)
     )
     
     QUICKBOOK_VALUE_NAMED_TAGS(source_mode_tags, 0x550,

Modified: branches/quickbook-dev/tools/quickbook/test/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 (original)
+++ branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 2011-11-02 03:58:32 EDT (Wed, 02 Nov 2011)
@@ -61,6 +61,7 @@
     [ quickbook-test para_test-1_5 ]
     [ quickbook-error-test post_process-fail ]
     [ quickbook-test preformatted-1_1 ]
+ [ quickbook-test role-1_6 ]
     [ quickbook-test section-1_4 ]
     [ quickbook-test section-1_5-unclosed ]
     [ quickbook-test section-1_5 ]

Added: branches/quickbook-dev/tools/quickbook/test/role-1_6.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/role-1_6.gold 2011-11-02 03:58:32 EDT (Wed, 02 Nov 2011)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="quickbook_role_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Quickbook Role Test</title>
+ <para>
+ <phrase role="keyword">Keyword</phrase> <phrase role="keyword"></phrase> [role]
+ </para>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/role-1_6.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/role-1_6.quickbook 2011-11-02 03:58:32 EDT (Wed, 02 Nov 2011)
@@ -0,0 +1,5 @@
+[article Quickbook Role Test
+[quickbook 1.6]
+]
+
+[role keyword Keyword] [role keyword] [role]


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