mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +03:00
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.
This commit is contained in:
parent
eb84bcee7c
commit
c1c94c0112
@ -79,9 +79,26 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
|
|||||||
|
|
||||||
if (matches(name, IMAGE_TAGS, NUM_IMAGE_TAGS)) {
|
if (matches(name, IMAGE_TAGS, NUM_IMAGE_TAGS)) {
|
||||||
// TODO: Start processing image tags
|
// TODO: Start processing image tags
|
||||||
self->skipUntilDepth = self->depth;
|
std::string alt;
|
||||||
self->depth += 1;
|
if (atts != nullptr) {
|
||||||
return;
|
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->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)) {
|
if (matches(name, SKIP_TAGS, NUM_SKIP_TAGS)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user