Add no-pretty

This commit is contained in:
Love 2025-01-24 13:43:10 +01:00
parent 8b0447668b
commit e91759c70d
2 changed files with 13 additions and 11 deletions

View File

@ -48,16 +48,6 @@ void italize_numbers(std::string &content, size_t leave_chars = 0) {
}
}
void pretty_format_page(std::string &content) {
content.insert(0, ansi::BOLD);
size_t line_end = content.find('\n');
if (line_end == std::string::npos)
line_end = content.size();
content.insert(line_end, ansi::CLEAR);
italize_numbers(content, line_end + ansi::CLEAR.size());
}
Page::Page(const int number): m_number(number), m_subpage(fetchSubpage()) {
}
@ -77,6 +67,18 @@ Page &Page::operator-=(int) {
}
std::string Page::str_pretty() const {
std::string content = str();
content.insert(0, ansi::BOLD);
size_t line_end = content.find('\n');
if (line_end == std::string::npos)
line_end = content.size();
content.insert(line_end, ansi::CLEAR);
italize_numbers(content, line_end + ansi::CLEAR.size());
return content;
}
std::string Page::str() const {
std::string ret;
std::istringstream stream(m_subpage);
@ -87,7 +89,6 @@ std::string Page::str_pretty() const {
string_utils::limitConsecutiveWhitespace(ret, MAX_WHITESPACE);
string_utils::removeTrailingWhitespace(ret);
pretty_format_page(ret);
return ret;
}

View File

@ -32,6 +32,7 @@ public:
Page &operator-=(int);
[[nodiscard]] std::string str_pretty() const;
[[nodiscard]] std::string str() const;
bool refresh();