Don't replace stuff in search::cleanup_text() if nothing matched.
This commit is contained in:
parent
09090a1c13
commit
e1d29c5893
|
@ -104,7 +104,8 @@ std::vector<match> search(const fs::path &filepath, std::string_view regex,
|
|||
|
||||
void cleanup_text(std::string &text)
|
||||
{
|
||||
for (size_t pos{}; pos != std::string::npos; pos = text.find('<', pos))
|
||||
size_t pos{};
|
||||
while ((pos = text.find('<', pos)) != std::string::npos)
|
||||
{
|
||||
// Mark headlines. We need them later on.
|
||||
std::string replacement;
|
||||
|
@ -133,17 +134,20 @@ void cleanup_text(std::string &text)
|
|||
pos += replacement.length();
|
||||
}
|
||||
|
||||
for (size_t pos{}; pos != std::string::npos; pos = text.find('\r', pos))
|
||||
pos = 0;
|
||||
while ((pos = text.find('\r', pos)) != std::string::npos)
|
||||
{
|
||||
text.erase(pos, 1);
|
||||
}
|
||||
|
||||
for (size_t pos{}; pos != std::string::npos; pos = text.find('\n', pos))
|
||||
pos = 0;
|
||||
while ((pos = text.find('\n', pos)) != std::string::npos)
|
||||
{
|
||||
text.replace(pos, 1, " ");
|
||||
}
|
||||
|
||||
for (size_t pos{}; pos != std::string::npos; pos = text.find(" ", pos))
|
||||
pos = 0;
|
||||
while ((pos = text.find(" ", pos)) != std::string::npos)
|
||||
{
|
||||
text.replace(pos, 2, " ");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user