Recognize and use raster svg images (upstream PR 2024 by LSTAR9000)

This commit is contained in:
jpirnay
2026-05-17 17:32:19 +02:00
parent 5057345b2b
commit d0b722cbff
5 changed files with 21 additions and 7 deletions
@@ -75,7 +75,7 @@ constexpr int NUM_UNDERLINE_TAGS = sizeof(UNDERLINE_TAGS) / sizeof(UNDERLINE_TAG
const char* STRIKETHROUGH_TAGS[] = {"s", "del", "strike"};
constexpr int NUM_STRIKETHROUGH_TAGS = sizeof(STRIKETHROUGH_TAGS) / sizeof(STRIKETHROUGH_TAGS[0]);
const char* IMAGE_TAGS[] = {"img"};
const char* IMAGE_TAGS[] = {"img", "image"};
constexpr int NUM_IMAGE_TAGS = sizeof(IMAGE_TAGS) / sizeof(IMAGE_TAGS[0]);
const char* SKIP_TAGS[] = {"head"};
@@ -520,8 +520,13 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
std::string alt;
if (atts != nullptr) {
for (int i = 0; atts[i]; i += 2) {
if (strcmp(atts[i], "src") == 0) {
src = atts[i + 1];
if (strcmp(atts[i], "src") == 0 || strcmp(atts[i], "href") == 0 || strcmp(atts[i], "xlink:href") == 0) {
if (src.empty()) {
src = atts[i + 1];
// Strip fragment anchors (e.g. "cover.jpg#xywh=0,0,100,100")
auto hash = src.find('#');
if (hash != std::string::npos) src.erase(hash);
}
} else if (strcmp(atts[i], "alt") == 0) {
alt = atts[i + 1];
}