Add [cmd:permissions]
Tá an tiomantas seo le fáil i:
26
parser.cpp
26
parser.cpp
@@ -82,6 +82,28 @@ std::string Parser::extractCommand(std::string cmdname, const std::string &conte
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::vector<std::string> Parser::extractCommands(std::string cmdname, const std::string &content) const
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
std::string cmd = "[cmd:" + cmdname + "]";
|
||||
std::string cmdend = "[/cmd:" + cmdname + "]";
|
||||
|
||||
std::string_view view = content;
|
||||
size_t pos = 0;
|
||||
while((pos = view.find(cmd)) != std::string::npos)
|
||||
{
|
||||
view.remove_prefix(pos);
|
||||
view.remove_prefix(cmd.size());
|
||||
if((pos = view.find(cmdend)) != std::string::npos)
|
||||
{
|
||||
result.emplace_back(view.substr(0, pos));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string Parser::processLink(const PageDao &pageDao, UrlProvider &urlProvider, std::smatch &match) const
|
||||
{
|
||||
std::string linktag = match.str(1);
|
||||
@@ -148,7 +170,7 @@ std::string Parser::parse(const PageDao &pagedao, UrlProvider &provider, const s
|
||||
std::string result;
|
||||
// we don't care about commands, but we nevertheless replace them with empty strings
|
||||
std::regex tagfinder(
|
||||
R"(\[(b|i|u|s|li||ul|ol|code|blockquote|img|link|wikilink|h\d|cmd:visible|cmd:rename|cmd:redirect|cmd:pagetitle|cmd:allowinclude|category|dynamic:postlist|dynamic:includepage|dynamic:getvar|dynamic:setvar)*?\]((\s|\S)*?)\[/\1])");
|
||||
R"(\[(b|i|u|s|li||ul|ol|code|blockquote|img|link|wikilink|h\d|cmd:visible|cmd:rename|cmd:redirect|cmd:pagetitle|cmd:allowinclude|cmd:permissions|category|dynamic:postlist|dynamic:includepage|dynamic:getvar|dynamic:setvar)*?\]((\s|\S)*?)\[/\1])");
|
||||
result = utils::regex_callback_replacer(
|
||||
tagfinder, content,
|
||||
[&](std::smatch &match)
|
||||
@@ -180,7 +202,7 @@ std::string Parser::parse(const PageDao &pagedao, UrlProvider &provider, const s
|
||||
}
|
||||
if(tag == "code" || tag == "blockquote")
|
||||
{
|
||||
return "<pre><" + tag + ">"+ utils::strreplace(content, "\r\n", "\n") + "</"+tag+"></pre>";
|
||||
return "<pre><" + tag + ">" + utils::strreplace(content, "\r\n", "\n") + "</" + tag + "></pre>";
|
||||
}
|
||||
return callback(tag, content);
|
||||
});
|
||||
|
Tagairt in Eagrán Nua
Cuir bac ar úsáideoir