$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r86666 - in trunk/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2013-11-12 15:34:46
Author: danieljames
Date: 2013-11-12 15:34:46 EST (Tue, 12 Nov 2013)
New Revision: 86666
URL: http://svn.boost.org/trac/boost/changeset/86666
Log:
Support source code tagging for paragraphs.
Text files modified: 
   trunk/tools/quickbook/src/main_grammar.cpp           |    36 ++++++++++++++++++++++++++++++------    
   trunk/tools/quickbook/test/source_mode-1_7.gold      |    14 ++++++++++++++                          
   trunk/tools/quickbook/test/source_mode-1_7.quickbook |     6 ++++++                                  
   3 files changed, 50 insertions(+), 6 deletions(-)
Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp	Tue Nov 12 15:34:23 2013	(r86665)
+++ trunk/tools/quickbook/src/main_grammar.cpp	2013-11-12 15:34:46 EST (Tue, 12 Nov 2013)	(r86666)
@@ -233,6 +233,26 @@
         bool element_context_error_;
     };
 
+    struct scoped_paragraph : scoped_action_base
+    {
+        scoped_paragraph(quickbook::state& state) :
+            state(state), pushed(false) {}
+
+        bool start() {
+            state.push_tagged_source_mode(state.source_mode_next);
+            pushed = true;
+            state.source_mode_next = 0;
+            return true;
+        }
+
+        void cleanup() {
+            if (pushed) state.pop_tagged_source_mode();
+        }
+
+        quickbook::state& state;
+        bool pushed;
+    };
+
     struct in_list_impl {
         main_grammar_local& l;
 
@@ -304,6 +324,7 @@
         element_id_warning_action element_id_warning(state);
 
         scoped_parser<to_value_scoped_action> to_value(state);
+        scoped_parser<scoped_paragraph> scope_paragraph(state);
 
         // Local Actions
         scoped_parser<process_element_impl> process_element(local);
@@ -456,12 +477,15 @@
                                                 // Usually superfluous call
                                                 // for paragraphs in lists.
             cl::eps_p                           [paragraph_action]
-        >>  scoped_context(element_info::in_top_level)
-            [   scoped_still_in_block(true)
-                [   local.syntactic_block_item(element_info::is_contextual_block)
-                >>  *(  cl::eps_p(ph::var(local.still_in_block))
-                    >>  local.syntactic_block_item(element_info::is_block)
-                    )
+        >>  scope_paragraph()
+            [
+                scoped_context(element_info::in_top_level)
+                [   scoped_still_in_block(true)
+                    [   local.syntactic_block_item(element_info::is_contextual_block)
+                    >>  *(  cl::eps_p(ph::var(local.still_in_block))
+                        >>  local.syntactic_block_item(element_info::is_block)
+                        )
+                    ]
                 ]
             ]                                   [paragraph_action]
             ;
Modified: trunk/tools/quickbook/test/source_mode-1_7.gold
==============================================================================
--- trunk/tools/quickbook/test/source_mode-1_7.gold	Tue Nov 12 15:34:23 2013	(r86665)
+++ trunk/tools/quickbook/test/source_mode-1_7.gold	2013-11-12 15:34:46 EST (Tue, 12 Nov 2013)	(r86666)
@@ -42,4 +42,18 @@
       </simpara>
     </listitem>
   </itemizedlist>
+  <para>
+    <code><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase
+    role="special">()</phrase> <phrase role="special">{}</phrase></code> and <code><phrase
+    role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
+    <phrase role="special">{}</phrase></code> should both be C++ highlighted. <code>int
+    main() {}</code> shouldn't be, but <code><phrase role="keyword">int</phrase>
+    <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase
+    role="special">{}</phrase></code> should.
+  </para>
+  <para>
+    <code><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase
+    role="special">()</phrase> <phrase role="special">{}</phrase></code>. Not highlighted:
+    <code>int main() {}</code>.
+  </para>
 </article>
Modified: trunk/tools/quickbook/test/source_mode-1_7.quickbook
==============================================================================
--- trunk/tools/quickbook/test/source_mode-1_7.quickbook	Tue Nov 12 15:34:23 2013	(r86665)
+++ trunk/tools/quickbook/test/source_mode-1_7.quickbook	2013-11-12 15:34:46 EST (Tue, 12 Nov 2013)	(r86666)
@@ -11,3 +11,9 @@
 * `int main() {}`
 * `int main() {}`
 * [teletype] `int main() {}` [/ shouldn't be highlighted]
+
+[!c++]
+`int main() {}` and `int main() {}` should both be C++ highlighted.
+[!teletype]`int main() {}` shouldn't be, but `int main() {}` should.
+
+[!c++] `int main() {}`. Not highlighted: `int main() {}`.