New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dictionary: Support images? #6056
Comments
Something like this should do the trick. You might have to change it to return function(html)
html = html:gsub('<rref[^>]*>([^<]*%.jpg)</rref>', '<img src="%1">')
return html
end |
@Frenzie return function(html)
html = html:gsub('<rref[^>]*>([^<]*%.jpg)</rref>', '<img src="/path/to/dictionary/img/files/%1" />')
return html
end KOReader version: 2020.12 |
@imkaihao That's what MuPDF puts in there when it can't find the referenced image file. Which is a virtual certainty if you kept |
@Frenzie I mean the real path to images. In Kobo Forma it's like this return function(html)
html = html:gsub('<rref[^>]*>([^<]*%.jpg)</rref>', '<img src="/mnt/onboard/.adds/koreader/data/dict/stardict-Longman_Dictionary_of_Contemporary_English_5th_Ed-2.4.2/res/%1" />')
return html
end It doesn't work. Just showing the result like the above screenshot. |
That way images can be made to work in a more generic, portable manner, such as: ``` return function(html, dict_path) html = html:gsub('<rref[^>]*>([^<]*%.jpg)</rref>', '<img src="'..dict_path..'res/%1">') return html end ``` Cf. <koreader#6056>.
If you use |
@Frenzie |
That way images can be made to work in a more generic, portable manner, such as: ``` return function(html, dict_path) html = html:gsub('<rref[^>]*>([^<]*%.jpg)</rref>', '<img src="'..dict_path..'res/%1">') return html end ``` Cf. <#6056>.
In fact, probably just about any image format you can throw at it except for WebP. (E.g., JPEG2000 isn't commonly supported but MuPDF does.) But as established above there's something slightly odd going on with full absolute paths. Sticking a file:// in front of it doesn't work either. I didn't want to spend time investigating since using relative paths worked, but that might mean it won't work on Android for the moment. Also I'm trying to avoid looking at MuPDF until #6738 is merged. As an aside, even if it's still an issue in 1.17/1.18, it'll support base64-encoded images which you always could use as a workaround. |
I see. I'll just live the relative path and shorter dirname attempt and wait a bit:
🔥🎉 |
Can I hope about showing pictures in dictionary queries?
They show up in the
=h
output as<blockquote><blockquote><rref>spire.jpg</rref></blockquote></blockquote>
For example:
I am complaining, just wanted to give you my feedback on how to make it better.
If it is not possible or too hard for the purpose, then I can just hide these references as
.wav
files (#6011)The text was updated successfully, but these errors were encountered: