Make sure img alt text is treated as separate text block

This commit is contained in:
Jonas Diemer 2026-01-22 17:07:18 +01:00 committed by cottongin
parent d5a9873bd7
commit c166b89f7b
No known key found for this signature in database
GPG Key ID: 0ECC91FE4655C262

View File

@ -135,6 +135,9 @@ 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) {
// add " " (counts as whitespace) at the end of alt
// so the corresponding text block ends.
// TODO: A zero-width breaking space would be more appropriate (once/if we support it)
alt = "[Image: " + std::string(atts[i + 1]) + "] ";
}
}
@ -144,7 +147,7 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
self->italicUntilDepth = min(self->italicUntilDepth, self->depth);
self->depth += 1;
self->characterData(userData, alt.c_str(), alt.length());
return;
} else {
// Skip for now
self->skipUntilDepth = self->depth;