1
0
Derivar 0

optimize/improve parser regex

Este cometimento está contido em:
Albert S. 2018-11-10 22:44:19 +01:00
ascendente 9abfa1f2b7
cometimento d3ab505f51
2 ficheiros modificados com 3 adições e 11 eliminações

9
TODO
Ver ficheiro

@ -1,9 +0,0 @@
search: allow all chars (filter sqlite match syntax)
add permission indicating whether user can see "invisible" pages in lists
diff
Redirection
UI for permission system.
user administration
user registration
more caching
not all config values take effect yet.

Ver ficheiro

@ -110,7 +110,7 @@ std::string Parser::processLink(const PageDao &pageDao, UrlProvider &urlProvider
{ {
htmllink.cssclass = "notexists"; htmllink.cssclass = "notexists";
} }
htmllink.href = urlProvider.page(htmllink.href); htmllink.href = urlProvider.page(htmllink.href);
} }
@ -123,7 +123,8 @@ std::string Parser::processLink(const PageDao &pageDao, UrlProvider &urlProvider
std::string Parser::parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const std::string Parser::parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const
{ {
std::string result; std::string result;
std::regex tagfinder(R"(\[(.*?)\]((\s|\S)*?)\[/\1\])"); //we don't care about commands, but we nevertheless replace them with empty strings
std::regex tagfinder(R"(\[(b|i|u|li||ul|ol|link|wikilink|h\d|cmd:rename|cmd:redirect)*?\]((\s|\S)*?)\[/\1])");
result = utils::regex_callback_replacer(tagfinder, content, [&](std::smatch &match) result = utils::regex_callback_replacer(tagfinder, content, [&](std::smatch &match)
{ {
std::string tag = match.str(1); std::string tag = match.str(1);