Fix pagebreak-iterators.

Oopsie! 😄
This commit is contained in:
tastytea 2021-06-06 15:50:13 +02:00
parent 99e1cd8e98
commit 9067b387ef
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 4 additions and 4 deletions

View File

@ -136,6 +136,8 @@ void cleanup_text(string &text)
size_t pos{};
while ((pos = text.find('<', pos)) != string::npos)
{
auto endpos{text.find('>', pos) + 1};
// Mark headlines. We need them later on.
string replacement;
if (boost::regex_match(text.substr(pos, 3), re_header_start))
@ -148,13 +150,11 @@ void cleanup_text(string &text)
}
else if (text.substr(pos, 6) == "<span ")
{
auto endpos{text.find('>')};
boost::match_results<string::const_iterator> match;
using it_size_t = string::const_iterator::difference_type;
string::const_iterator begin{text.begin()
+ static_cast<it_size_t>(pos)};
string::const_iterator end{text.end()
string::const_iterator end{text.begin()
+ static_cast<it_size_t>(endpos)};
if (boost::regex_search(begin, end, match, re_pagebreak))
@ -168,7 +168,7 @@ void cleanup_text(string &text)
pos = text.find('>', pos) + 1;
}
text.replace(pos, text.find('>', pos) + 1 - pos, replacement);
text.replace(pos, endpos - pos, replacement);
pos += replacement.length();
}