Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75270 - in branches/quickbook-dev/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-11-02 04:52:07


Author: danieljames
Date: 2011-11-02 04:52:05 EDT (Wed, 02 Nov 2011)
New Revision: 75270
URL: http://svn.boost.org/trac/boost/changeset/75270

Log:
Quickbook: Better encoded template support.

- Detect encoded templates in `call_template` so they're handled if
  anything calls it or `call_code_snippet` directly.
- Handle any paragraphs that comebefore a encoded block template.
- Escaped templates should always be inline, it isn't block content.
- Try to support escaped encoded templates. It's a bit of a weird case
  so I wasn't sure what to do. Just wrote out the boostbook in a phrase
  which seems the best option.
- Escapes now override the template type. This should happen as the user
  explictly asks for an escaped template.
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/actions.cpp | 56 ++++++++++++++++++++++++++++++++-------
   branches/quickbook-dev/tools/quickbook/test/escape-1_1.gold | 3 ++
   branches/quickbook-dev/tools/quickbook/test/escape-1_1.quickbook | 4 ++
   branches/quickbook-dev/tools/quickbook/test/templates-1_5.gold | 9 ++++++
   branches/quickbook-dev/tools/quickbook/test/templates-1_5.quickbook | 13 +++++++++
   5 files changed, 75 insertions(+), 10 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 04:52:05 EDT (Wed, 02 Nov 2011)
@@ -1122,6 +1122,24 @@
             std::vector<value> const& args,
             string_iterator first)
     {
+ // If this template contains already encoded text, then just
+ // write it out, without going through any of the rigamarole.
+
+ if (symbol->content.is_encoded())
+ {
+ if (symbol->content.get_tag() == template_tags::block)
+ {
+ actions.paragraph();
+ actions.out << symbol->content.get_boostbook();
+ }
+ else
+ {
+ actions.phrase << symbol->content.get_boostbook();
+ }
+
+ return;
+ }
+
         // The template arguments should have the scope that the template was
         // called from, not the template's own scope.
         //
@@ -1310,15 +1328,9 @@
         template_symbol const* symbol = actions.templates.find(identifier);
         BOOST_ASSERT(symbol);
 
- // Deal with raw templates and escaped templates.
+ // Deal with escaped templates.
 
- if (symbol->content.is_encoded())
- {
- (symbol->content.get_tag() == template_tags::block ? actions.out : actions.phrase)
- << symbol->content.get_boostbook();
- return;
- }
- else if (template_escape)
+ if (template_escape)
         {
             if (!args.empty())
             {
@@ -1328,8 +1340,32 @@
                 ++actions.error_count;
             }
 
- (symbol->content.get_tag() == template_tags::block ? actions.out : actions.phrase)
- << symbol->content.get_quickbook();
+ if (symbol->content.is_encoded())
+ {
+ actions.phrase << symbol->content.get_boostbook();
+ }
+ else
+ {
+ actions.phrase << symbol->content.get_quickbook();
+
+ /*
+
+ This would surround the escaped template in escape
+ comments to indicate to the post-processor that it
+ isn't quickbook generated markup. But I'm not sure if
+ it would work.
+
+ quickbook::detail::markup escape_markup
+ = detail::get_markup(phrase_tags::escape);
+
+ actions.phrase
+ << escape_markup.pre
+ << symbol->content.get_quickbook()
+ << escape_markup.post
+ ;
+ */
+ }
+
             return;
         }
 

Modified: branches/quickbook-dev/tools/quickbook/test/escape-1_1.gold
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/escape-1_1.gold (original)
+++ branches/quickbook-dev/tools/quickbook/test/escape-1_1.gold 2011-11-02 04:52:05 EDT (Wed, 02 Nov 2011)
@@ -22,5 +22,8 @@
 <link linkend="$-256">two</link>,
 <link linkend="$text">three</link>.
     </para>
+ <para>
+ <emphasis>This will be escaped</emphasis>
+ </para>
   </section>
 </article>

Modified: branches/quickbook-dev/tools/quickbook/test/escape-1_1.quickbook
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/escape-1_1.quickbook (original)
+++ branches/quickbook-dev/tools/quickbook/test/escape-1_1.quickbook 2011-11-02 04:52:05 EDT (Wed, 02 Nov 2011)
@@ -24,4 +24,8 @@
 <link linkend="$text">three</link>.
 '''
 
+[template escapedtemplate <emphasis>This will be escaped</emphasis>]
+
+[`escapedtemplate]
+
 [endsect]

Modified: branches/quickbook-dev/tools/quickbook/test/templates-1_5.gold
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/templates-1_5.gold (original)
+++ branches/quickbook-dev/tools/quickbook/test/templates-1_5.gold 2011-11-02 04:52:05 EDT (Wed, 02 Nov 2011)
@@ -24,4 +24,13 @@
   <para>
     {1-2-3} {1-2-3}
   </para>
+ <para>
+ Some <emphasis role="bold">text</emphasis>
+ </para>
+ <para>
+ A &lt;emphasis&gt;paragraph&lt;/emphasis&gt;.
+ </para>
+ <para>
+ Some *text* A <emphasis>paragraph</emphasis>.
+ </para>
 </article>

Modified: branches/quickbook-dev/tools/quickbook/test/templates-1_5.quickbook
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/templates-1_5.quickbook (original)
+++ branches/quickbook-dev/tools/quickbook/test/templates-1_5.quickbook 2011-11-02 04:52:05 EDT (Wed, 02 Nov 2011)
@@ -44,3 +44,16 @@
 [template ternary[x y z] {[x]-[y]-[z]}]
 [ternary 1..2..3] [/ {1-2-3} ]
 [ternary 1 2 3] [/ {1-2-3} ]
+
+[/ Block vs. phrase templates ]
+
+[template phrase[] Some *text*]
+[template block[]
+
+A <emphasis>paragraph</emphasis>.
+]
+
+[phrase]
+[block]
+[`phrase]
+[`block]
\ 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