diff options
| author | Grégoire Duchêne <gduchene@fastmail.net> | 2010-12-05 00:45:11 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@fastmail.net> | 2010-12-05 00:45:11 +0100 |
| commit | f7d1468cc0fe4237b702252f9bbaae5ba61b6bfd (patch) | |
| tree | b2f2417a552d0c9385997a042417afdab81c7391 | |
| parent | dc0ac72c987ec48c6b2a90d0056b4e79a3be092b (diff) | |
Bug inside the inline code text rule fixed.
It turned out that the inline code text rule was not honoring the
verbatim constraint either. This issue is now solved.
Also, I made the text_p parser more flexible by adding an inherited
attribute to it.
| -rw-r--r-- | src/parser/document_p.cpp | 2 | ||||
| -rw-r--r-- | src/parser/document_p.h | 4 | ||||
| -rw-r--r-- | src/parser/text_p.cpp | 19 | ||||
| -rw-r--r-- | src/parser/text_p.h | 11 |
4 files changed, 21 insertions, 15 deletions
diff --git a/src/parser/document_p.cpp b/src/parser/document_p.cpp index 875211c..f4a95e2 100644 --- a/src/parser/document_p.cpp +++ b/src/parser/document_p.cpp @@ -16,5 +16,5 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "document_p.h" document_p::document_p() : document_p::base_type(document_) { - document_ = +text_; + document_ = +text_(ph::val(L"*'`")); } diff --git a/src/parser/document_p.h b/src/parser/document_p.h index fc6530e..d2a7c44 100644 --- a/src/parser/document_p.h +++ b/src/parser/document_p.h @@ -15,8 +15,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MPPDOWN_DOCUMENT_P #define _MPPDOWN_DOCUMENT_P +#include <boost/spirit/include/qi.hpp> #include "text_p.h" +namespace qi = boost::spirit::qi; +namespace ph = boost::phoenix; + struct document_p : qi::grammar<iiterator, document_t()> { qi::rule<iiterator, document_t()> document_; text_p text_; diff --git a/src/parser/text_p.cpp b/src/parser/text_p.cpp index 22e2a12..46dd37b 100644 --- a/src/parser/text_p.cpp +++ b/src/parser/text_p.cpp @@ -17,18 +17,19 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. text_p::text_p() : text_p::base_type(text_) { using namespace qi; + using namespace ph; using qi::standard_wide::char_; - text_ = stext_ | ptext_; + text_ = stext_(_r1) | ptext_(_r1); - stext_ = lit("***") >> attr(VSEMPH) >> +text_ >> "***" - | lit("**") >> attr(SEMPH) >> +text_ >> "**" - | lit('*') >> attr(EMPH) >> +text_ >> '*' - | lit("''") >> attr(SALT) >> +text_ >> "''" - | lit('\'') >> attr(ALT) >> +text_ >> '\'' - | lit('`') >> attr(CODE) >> +ptext_ >> '`'; + stext_ = lit("***") >> attr(VSEMPH) >> +text_(val(L"*'`")) >> "***" + | lit("**") >> attr(SEMPH) >> +text_(val(L"*'`")) >> "**" + | lit('*') >> attr(EMPH) >> +text_(val(L"*'`")) >> '*' + | lit("''") >> attr(SALT) >> +text_(val(L"*'`"))>> "''" + | lit('\'') >> attr(ALT) >> +text_(val(L"*'`")) >> '\'' + | lit('`') >> attr(CODE) >> +ptext_(val(L"`")) >> '`'; - ptext_ = +(echar_ | rchar_); + ptext_ = +(echar_ | rchar_(_r1)); echar_ = lit('\\') >> char_; - rchar_ = char_ - char_(L"*'`"); + rchar_ = char_ - char_(_r1); } diff --git a/src/parser/text_p.h b/src/parser/text_p.h index 83ef54f..3b99ab2 100644 --- a/src/parser/text_p.h +++ b/src/parser/text_p.h @@ -21,13 +21,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "../elements.h" namespace qi = boost::spirit::qi; +namespace ph = boost::phoenix; -struct text_p : qi::grammar<iiterator, text_t()> { - qi::rule<iiterator, text_t()> text_; - qi::rule<iiterator, stext_t()> stext_; - qi::rule<iiterator, std::wstring()> ptext_; +struct text_p : qi::grammar<iiterator, text_t(std::wstring)> { + qi::rule<iiterator, text_t(std::wstring)> text_; + qi::rule<iiterator, stext_t(std::wstring)> stext_; + qi::rule<iiterator, std::wstring(std::wstring)> ptext_; qi::rule<iiterator, wchar_t()> echar_; - qi::rule<iiterator, wchar_t()> rchar_; + qi::rule<iiterator, wchar_t(std::wstring)> rchar_; text_p(); }; |
