Remove unused + cosnt and so on

This commit is contained in:
Love 2025-01-23 16:29:28 +01:00
parent c09929d2f7
commit 28613af006
2 changed files with 12 additions and 15 deletions

View File

@ -19,45 +19,44 @@
#include "libxml/xpath.h"
bool is_number(std::string_view s){
return std::all_of(s.begin(), s.end(), [](unsigned char c ){
bool is_number(const std::string_view s) {
return std::ranges::all_of(s, [](const unsigned char c) {
return std::isdigit(c);
});
}
void italize_numbers(std::string &content, size_t leave_chars = 0) {
size_t end = content.size();
// Process backwards, word by word
for (;;) {
size_t space = content.rfind(' ', end - 1);
size_t begin = (space == std::string::npos) ? 0 : space + 1;
size_t word_length = end - begin;
const size_t space = content.rfind(' ', end - 1);
const size_t begin = (space == std::string::npos) ? 0 : space + 1;
const size_t word_length = end - begin;
if (is_number(content.substr(begin, word_length))) {
content.insert(end, ansi::CLEAR);
content.insert(begin, ansi::ITALIC);
}
if (space == std::string::npos)
break;
if (leave_chars >= space)
break;
end = space;
}
}
void pretty_format_page(std::string &content) {
content.insert(0, ansi::BOLD);
size_t line_end = content.find("\n");
const size_t line_end = content.find("\n");
content.insert(line_end, ansi::CLEAR);
italize_numbers(content, line_end + ansi::CLEAR.size());
}
Page::Page(const uint_fast8_t number): m_number(number), m_subpage(fetchSubpage()) {
}

View File

@ -18,7 +18,7 @@ static constexpr uint_fast8_t MAX_WHITESPACE = 2;
class Page
{
private:
uint_fast8_t m_number{};
uint_fast8_t m_number;
std::string m_subpage;
public:
@ -32,7 +32,7 @@ public:
Page &operator-=(int);
std::string str() const;
[[nodiscard]] std::string str() const;
bool refresh();
@ -40,6 +40,4 @@ private:
[[nodiscard]] std::string url() const;
[[nodiscard]] std::string fetchSubpage() const;
[[nodiscard]] bool contentEquals(const std::vector<std::string> &subpagesOther) const;
};