From c1812edd072a0646b248acd98bc2e010d224d4a2 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sat, 10 Nov 2018 22:44:19 +0100 Subject: [PATCH] optimize/improve parser regex --- TODO | 9 --------- parser.cpp | 3 ++- 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 TODO diff --git a/TODO b/TODO deleted file mode 100644 index b6fd236..0000000 --- a/TODO +++ /dev/null @@ -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. diff --git a/parser.cpp b/parser.cpp index bf99445..cd278ed 100644 --- a/parser.cpp +++ b/parser.cpp @@ -120,7 +120,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 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) { std::string tag = match.str(1); std::string content = match.str(2);