diff --git a/src/code_snippet.cpp b/src/code_snippet.cpp index 92eed67..a0450da 100644 --- a/src/code_snippet.cpp +++ b/src/code_snippet.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include "template_stack.hpp" @@ -108,26 +109,35 @@ namespace quickbook cl::str_p("#]") ; - ignore = - *cl::blank_p >> "#<-" - >> (*(cl::anychar_p - "#->")) - >> "#->" >> *cl::blank_p >> cl::eol_p - | "\"\"\"<-\"\"\"" - >> (*(cl::anychar_p - "\"\"\"->\"\"\"")) - >> "\"\"\"->\"\"\"" - | "\"\"\"<-" - >> (*(cl::anychar_p - "->\"\"\"")) - >> "->\"\"\"" + ignore + = cl::confix_p( + *cl::blank_p >> "#<-", + *cl::anychar_p, + "#->" >> *cl::blank_p >> cl::eol_p + ) + | cl::confix_p( + "\"\"\"<-\"\"\"", + *cl::anychar_p, + "\"\"\"->\"\"\"" + ) + | cl::confix_p( + "\"\"\"<-", + *cl::anychar_p, + "->\"\"\"" + ) ; escaped_comment = - *cl::space_p >> "#`" - >> ((*(cl::anychar_p - cl::eol_p)) - >> cl::eol_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] - | *cl::space_p >> "\"\"\"`" - >> (*(cl::anychar_p - "\"\"\"")) - [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] - >> "\"\"\"" + cl::confix_p( + *cl::space_p >> "#`", + (*cl::anychar_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)], + cl::eol_p + ) + | cl::confix_p( + *cl::space_p >> "\"\"\"`", + (*cl::anychar_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)], + "\"\"\"" + ) ; } @@ -187,41 +197,54 @@ namespace quickbook cl::str_p("//]") | "/*]*/" ; - inline_callout = - "/*<" - >> *cl::space_p - >> (*(cl::anychar_p - ">*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)] - >> ">*/" + inline_callout + = cl::confix_p( + "/*<" >> *cl::space_p, + (*cl::anychar_p) [boost::bind(&actions_type::callout, &actions, _1, _2)], + ">*/" + ) + ; + + line_callout + = cl::confix_p( + "/*<<" >> *cl::space_p, + (*cl::anychar_p) [boost::bind(&actions_type::callout, &actions, _1, _2)], + ">>*/" + ) + >> *cl::space_p ; - line_callout = - "/*<<" - >> *cl::space_p - >> (*(cl::anychar_p - ">>*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)] - >> ">>*/" - >> *cl::space_p + ignore + = cl::confix_p( + *cl::blank_p >> "//<-", + *cl::anychar_p, + "//->" + ) + >> *cl::blank_p + >> cl::eol_p + | cl::confix_p( + "/*<-*/", + *cl::anychar_p, + "/*->*/" + ) + | cl::confix_p( + "/*<-", + *cl::anychar_p, + "->*/" + ) ; - ignore = - *cl::blank_p >> "//<-" - >> (*(cl::anychar_p - "//->")) - >> "//->" >> *cl::blank_p >> cl::eol_p - | "/*<-*/" - >> (*(cl::anychar_p - "/*->*/")) - >> "/*->*/" - | "/*<-" - >> (*(cl::anychar_p - "->*/")) - >> "->*/" - ; - - escaped_comment = - *cl::space_p >> "//`" - >> ((*(cl::anychar_p - cl::eol_p)) - >> cl::eol_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] - | *cl::space_p >> "/*`" - >> (*(cl::anychar_p - "*/")) - [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] - >> "*/" + escaped_comment + = cl::confix_p( + *cl::space_p >> "//`", + (*cl::anychar_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)], + cl::eol_p + ) + | cl::confix_p( + *cl::space_p >> "/*`", + (*cl::anychar_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)], + "*/" + ) ; }