From c591c2e033f630aaaff9521540d79b45f4e3393e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Launay?= Date: Thu, 18 Dec 2025 00:14:22 +0100 Subject: [PATCH] fix number of notes per page --- lib/Epub/Epub/Page.h | 2 +- lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp | 2 +- lib/Epub/Epub/parsers/ChapterHtmlSlimParser.h | 2 +- src/activities/reader/EpubReaderActivity.cpp | 11 +++++------ 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/Epub/Epub/Page.h b/lib/Epub/Epub/Page.h index d4657ae..4510fbf 100644 --- a/lib/Epub/Epub/Page.h +++ b/lib/Epub/Epub/Page.h @@ -48,7 +48,7 @@ class Page { elementCapacity = 24; elements = new std::shared_ptr[elementCapacity]; - footnoteCapacity = 8; + footnoteCapacity = 16; footnotes = new FootnoteEntry[footnoteCapacity]; for (int i = 0; i < footnoteCapacity; i++) { footnotes[i].number[0] = '\0'; diff --git a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp index 6867219..7b9eed1 100644 --- a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp +++ b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp @@ -60,7 +60,7 @@ void ChapterHtmlSlimParser::startNewTextBlock(const TextBlock::BLOCK_STYLE style } void ChapterHtmlSlimParser::addFootnoteToCurrentPage(const char* number, const char* href) { - if (currentPageFootnoteCount >= 32) return; + if (currentPageFootnoteCount >= 16) return; Serial.printf("[%lu] [ADDFT] Adding footnote: num=%s, href=%s\n", millis(), number, href); diff --git a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.h b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.h index a8a3113..b6231e8 100644 --- a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.h +++ b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.h @@ -77,7 +77,7 @@ class ChapterHtmlSlimParser { std::function noterefCallback = nullptr; // Footnote tracking for current page - FootnoteEntry currentPageFootnotes[32]; + FootnoteEntry currentPageFootnotes[16]; int currentPageFootnoteCount = 0; // Inline footnotes (aside) tracking diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 3b2356a..691ccd7 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -326,14 +326,13 @@ void EpubReaderActivity::renderScreen() { // Check footnote before copy bool hasCorruptedFootnotes = false; - for (int i = 0; i < p->footnoteCount && i < 16; i++) { + for (int i = 0; i < p->footnoteCount && i < 8; i++) { // Changé de 16 à 8 FootnoteEntry* fn = p->getFootnote(i); if (fn) { - // Vérifier que number et href sont null-terminés bool numberValid = false; bool hrefValid = false; - // Chercher le null terminator dans number (3 bytes) + // Search null terminator in number (3 bytes) for (int j = 0; j < 3; j++) { if (fn->number[j] == '\0') { numberValid = true; @@ -341,7 +340,7 @@ void EpubReaderActivity::renderScreen() { } } - // Chercher le null terminator dans href (64 bytes) + // Search null terminator in href (64 bytes) for (int j = 0; j < 64; j++) { if (fn->href[j] == '\0') { hrefValid = true; @@ -367,7 +366,7 @@ void EpubReaderActivity::renderScreen() { // Copy footnotes from page to currentPageFootnotes currentPageFootnotes.clear(); - int maxFootnotes = (p->footnoteCount < 16) ? p->footnoteCount : 16; + int maxFootnotes = (p->footnoteCount < 8) ? p->footnoteCount : 8; for (int i = 0; i < maxFootnotes; i++) { FootnoteEntry* footnote = p->getFootnote(i); @@ -375,7 +374,7 @@ void EpubReaderActivity::renderScreen() { currentPageFootnotes.addFootnote(footnote->number, footnote->href); } } - Serial.printf("[%lu] [ERS] Loaded %d footnotes for current page\n", millis(), p->footnoteCount); + Serial.printf("[%lu] [ERS] Loaded %d footnotes for current page\n", millis(), maxFootnotes); const auto start = millis(); renderContents(std::move(p));