A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Feature: Show img alt text (#168)

Let's start small by showing the ALT text of IMG. This is rudimentary,
but avoids those otherwise completely blank chapters.

I feel we will need this even when we can render images if that
rendering takes >1s - I would then prefer rendering optional and showing
the ALT text first.

authored by

Jonas Diemer and committed by
GitHub
c1c94c01 eb84bcee

+20 -3
+20 -3
lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp
··· 79 79 80 80 if (matches(name, IMAGE_TAGS, NUM_IMAGE_TAGS)) { 81 81 // TODO: Start processing image tags 82 - self->skipUntilDepth = self->depth; 83 - self->depth += 1; 84 - return; 82 + std::string alt; 83 + if (atts != nullptr) { 84 + for (int i = 0; atts[i]; i += 2) { 85 + if (strcmp(atts[i], "alt") == 0) { 86 + alt = "[Image: " + std::string(atts[i + 1]) + "]"; 87 + } 88 + } 89 + Serial.printf("[%lu] [EHP] Image alt: %s\n", millis(), alt.c_str()); 90 + 91 + self->startNewTextBlock(TextBlock::CENTER_ALIGN); 92 + self->italicUntilDepth = min(self->italicUntilDepth, self->depth); 93 + self->depth += 1; 94 + self->characterData(userData, alt.c_str(), alt.length()); 95 + 96 + } else { 97 + // Skip for now 98 + self->skipUntilDepth = self->depth; 99 + self->depth += 1; 100 + return; 101 + } 85 102 } 86 103 87 104 if (matches(name, SKIP_TAGS, NUM_SKIP_TAGS)) {