From c960e32d0587f0bf613c60d934f63eabd6873d66 Mon Sep 17 00:00:00 2001 From: Jonas Diemer Date: Tue, 30 Dec 2025 14:10:10 +0100 Subject: [PATCH 1/2] Show ALT text of images. --- .../Epub/parsers/ChapterHtmlSlimParser.cpp | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp index a2b61899..7cb6d8fd 100644 --- a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp +++ b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp @@ -67,9 +67,27 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char* if (matches(name, IMAGE_TAGS, NUM_IMAGE_TAGS)) { // TODO: Start processing image tags - self->skipUntilDepth = self->depth; - self->depth += 1; - return; + std::string alt; + if (atts != nullptr) { + for (int i = 0; atts[i]; i += 2) { + if (strcmp(atts[i], "alt") == 0) { + alt = "Image[" + std::string(atts[i + 1]) + "]"; + } + } + Serial.printf("[%lu] [EHP] Image alt: %s\n", millis(), alt.c_str()); + + self->startNewTextBlock(TextBlock::CENTER_ALIGN); + self->italicUntilDepth = min(self->italicUntilDepth, self->depth); + self->boldUntilDepth = min(self->boldUntilDepth, self->depth); + self->depth += 1; + self->characterData(userData, alt.c_str(), alt.length()); + + } else { + // Skip for now + self->skipUntilDepth = self->depth; + self->depth += 1; + return; + } } if (matches(name, SKIP_TAGS, NUM_SKIP_TAGS)) { From 800a26b88df45c678d7e5d37e1a1c3b92333a75c Mon Sep 17 00:00:00 2001 From: Jonas Diemer Date: Tue, 30 Dec 2025 14:23:47 +0100 Subject: [PATCH 2/2] Only italic (because it shows also inline), move brackets around. --- lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp index 6c4744a3..0f768e87 100644 --- a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp +++ b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp @@ -70,14 +70,13 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char* if (atts != nullptr) { for (int i = 0; atts[i]; i += 2) { if (strcmp(atts[i], "alt") == 0) { - alt = "Image[" + std::string(atts[i + 1]) + "]"; + alt = "[Image: " + std::string(atts[i + 1]) + "]"; } } Serial.printf("[%lu] [EHP] Image alt: %s\n", millis(), alt.c_str()); self->startNewTextBlock(TextBlock::CENTER_ALIGN); self->italicUntilDepth = min(self->italicUntilDepth, self->depth); - self->boldUntilDepth = min(self->boldUntilDepth, self->depth); self->depth += 1; self->characterData(userData, alt.c_str(), alt.length());