Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70184 - in trunk/tools/quickbook: . doc src test
From: dnljms_at_[hidden]
Date: 2011-03-19 10:33:48


Author: danieljames
Date: 2011-03-19 10:33:47 EDT (Sat, 19 Mar 2011)
New Revision: 70184
URL: http://svn.boost.org/trac/boost/changeset/70184

Log:
Quickbook: fix simple markup.

Added:
   trunk/tools/quickbook/src/parsers.hpp
      - copied unchanged from r69164, /branches/quickbook-filenames/tools/quickbook/src/parsers.hpp
Removed:
   trunk/tools/quickbook/src/scoped_parser.hpp
Properties modified:
   trunk/tools/quickbook/ (props changed)
Text files modified:
   trunk/tools/quickbook/doc/quickbook.qbk | 1
   trunk/tools/quickbook/src/actions_class.hpp | 2
   trunk/tools/quickbook/src/iterator.hpp | 15 ++++++++++-
   trunk/tools/quickbook/src/main_grammar.cpp | 48 +++++++++++++++++++++++----------------
   trunk/tools/quickbook/test/quickbook-manual.gold | 4 +-
   trunk/tools/quickbook/test/simple_markup.gold | 15 +++++++++++
   trunk/tools/quickbook/test/simple_markup.quickbook | 8 ++++++
   7 files changed, 67 insertions(+), 26 deletions(-)

Modified: trunk/tools/quickbook/doc/quickbook.qbk
==============================================================================
--- trunk/tools/quickbook/doc/quickbook.qbk (original)
+++ trunk/tools/quickbook/doc/quickbook.qbk 2011-03-19 10:33:47 EDT (Sat, 19 Mar 2011)
@@ -279,6 +279,7 @@
 * Improved error messages for unknown doc info attributes.
 * Richer copyright syntax. Now understands:
   `[copyright 2001-2006, 2010 One person, 2008 Another person]`.
+* Fix delimeter checking for simple markup.
 * Quickbook 1.6:
   * Scope source mode changes to the file they're made in.
 

Modified: trunk/tools/quickbook/src/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.hpp (original)
+++ trunk/tools/quickbook/src/actions_class.hpp 2011-03-19 10:33:47 EDT (Sat, 19 Mar 2011)
@@ -11,7 +11,7 @@
 #define BOOST_SPIRIT_ACTIONS_CLASS_HPP
 
 #include "actions.hpp"
-#include "scoped_parser.hpp"
+#include "parsers.hpp"
 #include "values_parse.hpp"
 #include <boost/tuple/tuple.hpp>
 #include <boost/scoped_ptr.hpp>

Modified: trunk/tools/quickbook/src/iterator.hpp
==============================================================================
--- trunk/tools/quickbook/src/iterator.hpp (original)
+++ trunk/tools/quickbook/src/iterator.hpp 2011-03-19 10:33:47 EDT (Sat, 19 Mar 2011)
@@ -11,6 +11,8 @@
 
 #include <boost/operators.hpp>
 #include <boost/iterator/iterator_traits.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <iterator>
 
 namespace quickbook
 {
@@ -35,9 +37,9 @@
     {
         position_iterator() {}
         explicit position_iterator(Iterator base)
- : base_(base), previous_('\0'), position_() {}
+ : original_(base), base_(base), previous_('\0'), position_() {}
         explicit position_iterator(Iterator base, file_position const& position)
- : base_(base), previous_('\0'), position_(position) {}
+ : original_(base), base_(base), previous_('\0'), position_(position) {}
     
         friend bool operator==(
             position_iterator const& x,
@@ -82,8 +84,17 @@
         Iterator base() const {
             return base_;
         }
+
+ typedef boost::iterator_range<std::reverse_iterator<Iterator> >
+ lookback_range;
+
+ lookback_range lookback() const
+ {
+ return lookback_range(base_, original_);
+ }
     
     private:
+ Iterator original_;
         Iterator base_;
         char previous_;
         file_position position_;

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp (original)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2011-03-19 10:33:47 EDT (Sat, 19 Mar 2011)
@@ -12,6 +12,7 @@
 #include "actions_class.hpp"
 #include "utils.hpp"
 #include "template_tags.hpp"
+#include "parsers.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_confix.hpp>
 #include <boost/spirit/include/classic_chset.hpp>
@@ -22,7 +23,7 @@
 namespace quickbook
 {
     namespace cl = boost::spirit::classic;
-
+
     template <typename Rule, typename Action>
     inline void
     simple_markup(
@@ -33,26 +34,33 @@
     )
     {
         simple =
- 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 >> mark) // Make sure that we don't go
- | close // past a single block
+ mark
+ >> lookback
+ [ cl::anychar_p
+ >> ~cl::eps_p(mark) // first mark not be preceeded by
+ // the same character.
+ >> (cl::space_p | cl::punct_p | cl::end_p)
+ // first mark must be preceeded
+ // by space or punctuation or the
+ // mark character or a the start.
+ ]
+ >> ( cl::graph_p // graph_p must follow first mark
+ >> *( cl::anychar_p -
+ ( lookback[cl::graph_p]
+ // final mark must be preceeded by
+ // graph_p
+ >> 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::eps_p(mark)
+ ) [action]
>> mark
             ;
     }

Deleted: trunk/tools/quickbook/src/scoped_parser.hpp
==============================================================================
--- trunk/tools/quickbook/src/scoped_parser.hpp 2011-03-19 10:33:47 EDT (Sat, 19 Mar 2011)
+++ (empty file)
@@ -1,94 +0,0 @@
-/*=============================================================================
- Copyright (c) 2010 Daniel James
- Copyright (c) 2003 Martin Wille
- http://spirit.sourceforge.net/
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- =============================================================================*/
-
-// Used to store variables/state while parsing
-
-#ifndef BOOST_QUICKBOOK_SCOPED_PARSER_HPP
-#define BOOST_QUICKBOOK_SCOPED_PARSER_HPP
-
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/include/classic_nil.hpp>
-
-namespace quickbook {
- namespace cl = boost::spirit::classic;
-
- template <typename ScopeT, typename DataT, typename ParserT>
- struct scoped_parser_impl
- : public cl::unary< ParserT, cl::parser< scoped_parser_impl<ScopeT, DataT, ParserT> > >
- {
- typedef scoped_parser_impl<ScopeT, DataT, ParserT> self_t;
- typedef cl::unary< ParserT, cl::parser< scoped_parser_impl<ScopeT, DataT, ParserT> > > base_t;
-
- template <typename ScannerT>
- struct result { typedef cl::match<> type; };
-
- scoped_parser_impl(DataT& actions, ParserT const &p)
- : base_t(p)
- , actions(actions)
- {}
-
- template <typename ScannerT>
- typename result<ScannerT>::type parse(ScannerT const &scan) const
- {
- typedef typename ScannerT::iterator_t iterator_t;
- iterator_t save = scan.first;
-
- ScopeT scope(actions);
- typename cl::parser_result<ParserT, ScannerT>::type result
- = this->subject().parse(scan);
-
- if (result) {
- scope.success(result);
- return scan.create_match(result.length(), cl::nil_t(), save, scan.first);
- }
- else {
- scope.failure();
- return scan.no_match();
- }
- }
-
- DataT& actions;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // scoped_parser
- //
- // generator for scoped_parser_impl objects
- // operator[] returns scoped_parser_impl according to its argument
- //
- ///////////////////////////////////////////////////////////////////////////
- template <typename ScopeT>
- struct scoped_parser
- {
- typedef typename ScopeT::data_type data_type;
-
- explicit scoped_parser(data_type& actions)
- : actions(actions) {}
-
- template<typename ParserT>
- scoped_parser_impl
- <
- ScopeT,
- data_type,
- typename cl::as_parser<ParserT>::type
- >
- operator[](ParserT const &p) const
- {
- typedef cl::as_parser<ParserT> as_parser_t;
- typedef typename as_parser_t::type parser_t;
-
- return scoped_parser_impl<ScopeT, data_type, parser_t>
- (actions, as_parser_t::convert(p));
- }
-
- data_type& actions;
- };
-}
-#endif // BOOST_QUICKBOOK_SCOPED_BLOCK_HPP

Modified: trunk/tools/quickbook/test/quickbook-manual.gold
==============================================================================
--- trunk/tools/quickbook/test/quickbook-manual.gold (original)
+++ trunk/tools/quickbook/test/quickbook-manual.gold 2011-03-19 10:33:47 EDT (Sat, 19 Mar 2011)
@@ -3178,8 +3178,8 @@
     :
         my_doc
     :
- &lt;xsl:param&gt;boost.image.src<literal>images/my_project_logo.png
- &lt;xsl:param&gt;boost.image.alt</literal>&quot;\&quot;My Project\&quot;&quot;
+ &lt;xsl:param&gt;boost.image.src=images/my_project_logo.png
+ &lt;xsl:param&gt;boost.image.alt=&quot;\&quot;My Project\&quot;&quot;
         &lt;xsl:param&gt;boost.image.w=100
         &lt;xsl:param&gt;boost.image.h=50
         &lt;xsl:param&gt;nav.layout=none

Modified: trunk/tools/quickbook/test/simple_markup.gold
==============================================================================
--- trunk/tools/quickbook/test/simple_markup.gold (original)
+++ trunk/tools/quickbook/test/simple_markup.gold 2011-03-19 10:33:47 EDT (Sat, 19 Mar 2011)
@@ -10,10 +10,23 @@
       role="underline">underline</emphasis> <literal>teletype</literal>
     </para>
     <para>
- /all<emphasis>italic</emphasis> * not bold*
+ <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>
       /not italic <ulink url="http://www.boost.org/"><emphasis role="bold">bold</emphasis></ulink>
     </para>
+ <para>
+ not_underlined_
+ </para>
   </section>
 </article>

Modified: trunk/tools/quickbook/test/simple_markup.quickbook
==============================================================================
--- trunk/tools/quickbook/test/simple_markup.quickbook (original)
+++ trunk/tools/quickbook/test/simple_markup.quickbook 2011-03-19 10:33:47 EDT (Sat, 19 Mar 2011)
@@ -6,8 +6,16 @@
 
 /italic/ *bold* _underline_ =teletype=
 
+//italic// **bold** __underline__ ==teletype==
+
+not__underlined__hopefully
+
+(*bold*)
+
 /all/italic/ * not bold*
 
 /not italic [@http://www.boost.org/ *bold*]
 
+not_underlined_
+
 [endsect]
\ 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