skip spaces in delimiter change tags

This commit is contained in:
Daniel Sipka 2015-05-04 11:27:51 +02:00
parent d14c647134
commit 65d6395e71
3 changed files with 13 additions and 2 deletions

View File

@ -18,6 +18,8 @@ void template_type::process_text(citer begin, citer end) {
}
}
#include <iostream>
void template_type::tokenize(const std::string& tmp) {
std::string open{"{{"}, close{"}}"};
citer beg = tmp.begin();
@ -41,8 +43,12 @@ void template_type::tokenize(const std::string& tmp) {
if (*(beg + open_pos + open.size()) == '=' &&
*(beg + close_pos - 1) == '=')
{
open = {beg + open_pos + open.size() + 1, beg + tmp.find(' ',open_pos)};
close = {beg + tmp.find(' ', open_pos) + 1, beg + close_pos - 1};
auto tok_beg = beg + open_pos + open.size() + 1;
auto tok_end = beg + close_pos - 1;
auto front_skip = first_not_ws(tok_beg, tok_end);
auto back_skip = first_not_ws(reverse(tok_end), reverse(tok_beg));
open = {front_skip, beg + tmp.find(' ', front_skip - beg)};
close = {beg + tmp.rfind(' ', back_skip - beg) + 1, back_skip + 1};
}
} else {
process_text(beg + cur_pos, tmp.end());

View File

@ -12,6 +12,10 @@ mstch::citer mstch::first_not_ws(mstch::criter begin, mstch::criter end) {
return --(end.base());
}
mstch::criter mstch::reverse(mstch::citer it) {
return std::reverse_iterator<mstch::citer>(it);
}
std::string mstch::html_escape(const std::string& str) {
std::string out;
citer start = str.begin();

View File

@ -11,6 +11,7 @@ using criter = std::string::const_reverse_iterator;
citer first_not_ws(citer begin, citer end);
citer first_not_ws(criter begin, criter end);
std::string html_escape(const std::string& str);
criter reverse(citer it);
template<class... Args>
auto visit(Args&&... args) -> decltype(boost::apply_visitor(