Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68943 - in branches/quickbook-filenames/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-02-16 03:29:00


Author: danieljames
Date: 2011-02-16 03:28:59 EST (Wed, 16 Feb 2011)
New Revision: 68943
URL: http://svn.boost.org/trac/boost/changeset/68943

Log:
Deal with some simple markup edge cases.
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp | 56 ++++++++++++++++++++++-----------------
   branches/quickbook-filenames/tools/quickbook/test/simple_markup.gold | 10 +++++++
   branches/quickbook-filenames/tools/quickbook/test/simple_markup.quickbook | 6 ++++
   3 files changed, 47 insertions(+), 25 deletions(-)

Modified: branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp 2011-02-16 03:28:59 EST (Wed, 16 Feb 2011)
@@ -37,6 +37,7 @@
 
         simple_markup_start_parser(char c)
             : base_t(cl::ch_p(c))
+ , mark_(c)
         {}
 
         template <typename ScannerT>
@@ -47,14 +48,21 @@
 
             typename cl::parser_result<cl::chlit<char>, ScannerT>::type result
                 = this->subject().parse(scan);
-
- typename iterator_t::lookback_range lookback = save.lookback();
 
- if (result && (
- lookback.begin() == lookback.end() ||
- cl::punct_p.test(*lookback.begin()) ||
- cl::space_p.test(*lookback.begin())
- ))
+ typename iterator_t::lookback_range::iterator
+ lookback_begin = save.lookback().begin(),
+ lookback_end = save.lookback().end();
+
+ if (lookback_begin != lookback_end) {
+ if (*lookback_begin == mark_)
+ return scan.no_match();
+
+ if (!cl::punct_p.test(*lookback_begin) &&
+ !cl::space_p.test(*lookback_begin))
+ return scan.no_match();
+ }
+
+ if (result)
             {
                 return scan.create_match(result.length(), cl::nil_t(), save, scan.first);
             }
@@ -62,6 +70,8 @@
                 return scan.no_match();
             }
         }
+
+ char mark_;
     };
     
     simple_markup_start_parser start_parser(char c)
@@ -79,29 +89,25 @@
     )
     {
         simple =
- start_parser(mark) >>
- (
- (
- cl::graph_p // A single char. e.g. *c*
- >> cl::eps_p(mark
- >> (cl::space_p | cl::punct_p | cl::end_p))
- // space_p, punct_p or end_p
- ) // must follow mark
- |
- ( cl::graph_p >> // graph_p must follow mark
- *(cl::anychar_p -
- ( cl::graph_p
+ start_parser(mark) // first mark must be preceeded
+ // by space or punctuation or the
+ // mark character.
+ >> cl::eps_p(cl::graph_p) // graph_p must follow first mark
+ >> ( *(cl::anychar_p -
+ ( cl::graph_p // graph_p must precede final mark
>> mark
+ >> ~cl::eps_p(mark) // final mark not be followed by
+ // the same character.
>> (cl::space_p | cl::punct_p | cl::end_p)
+ // final mark must be followed by
+ // space or punctuation
                         | close // Make sure that we don't go
                                                 // past a single block
                         )
- ) >> cl::graph_p // graph_p must precede mark
- >> cl::eps_p(mark
- >> (cl::space_p | cl::punct_p | cl::end_p))
- // space_p, punct_p or end_p
- ) // must follow mark
- ) [action]
+ )
+ >> cl::graph_p
+ >> cl::eps_p(mark >> (cl::space_p | cl::punct_p | cl::end_p))
+ ) [action]
>> mark
             ;
     }

Modified: branches/quickbook-filenames/tools/quickbook/test/simple_markup.gold
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/simple_markup.gold (original)
+++ branches/quickbook-filenames/tools/quickbook/test/simple_markup.gold 2011-02-16 03:28:59 EST (Wed, 16 Feb 2011)
@@ -10,6 +10,16 @@
       role="underline">underline</emphasis> <literal>teletype</literal>
     </para>
     <para>
+ <emphasis>/italic/</emphasis> <emphasis role="bold">*bold*</emphasis> <emphasis
+ role="underline">_underline_</emphasis> <literal>=teletype=</literal>
+ </para>
+ <para>
+ not__underlined__hopefully
+ </para>
+ <para>
+ (<emphasis role="bold">bold</emphasis>)
+ </para>
+ <para>
       <emphasis>all/italic</emphasis> * not bold*
     </para>
     <para>

Modified: branches/quickbook-filenames/tools/quickbook/test/simple_markup.quickbook
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/simple_markup.quickbook (original)
+++ branches/quickbook-filenames/tools/quickbook/test/simple_markup.quickbook 2011-02-16 03:28:59 EST (Wed, 16 Feb 2011)
@@ -6,6 +6,12 @@
 
 /italic/ *bold* _underline_ =teletype=
 
+//italic// **bold** __underline__ ==teletype==
+
+not__underlined__hopefully
+
+(*bold*)
+
 /all/italic/ * not bold*
 
 /not italic [@http://www.boost.org/ *bold*]


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