mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 06:37:38 +03:00
fix: Make sure img alt text is treated as separate text block (#497)
## Summary Should address issues discussed in #168 and potentially fix #478. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**PARTIALLY**_
This commit is contained in:
parent
6ca75c4653
commit
aca6dceaa8
@ -100,6 +100,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]) + "] ";
|
||||
}
|
||||
}
|
||||
@ -109,7 +112,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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user