feature/markdown #23
11
parser.cpp
11
parser.cpp
@ -30,19 +30,12 @@ SOFTWARE.
|
|||||||
std::vector<Headline> Parser::extractHeadlines(std::string content) const
|
std::vector<Headline> Parser::extractHeadlines(std::string content) const
|
||||||
{
|
{
|
||||||
std::vector<Headline> result;
|
std::vector<Headline> result;
|
||||||
std::string reg = R"(\[h(1|2|3)\](.*?)\[/h\1\])";
|
utils::regex_callback_extractor(std::regex(R"(\[h(1|2|3)\](.*?)\[/h\1\])"), content, [&](std::smatch &smatch) {
|
||||||
std::regex headerfinder(reg);
|
|
||||||
auto begin = std::sregex_iterator(content.begin(), content.end(), headerfinder);
|
|
||||||
auto end = std::sregex_iterator();
|
|
||||||
|
|
||||||
for(auto it = begin; it != end; it++)
|
|
||||||
{
|
|
||||||
auto smatch = *it;
|
|
||||||
Headline h;
|
Headline h;
|
||||||
h.level = utils::toUInt(smatch.str(1));
|
h.level = utils::toUInt(smatch.str(1));
|
||||||
h.title = smatch.str(2);
|
h.title = smatch.str(2);
|
||||||
result.push_back(h);
|
result.push_back(h);
|
||||||
}
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user