Dictionary: fix missing images (#12877)

Pass the dictionary's res directory to Mupdf.openDocumentFromText to allow MuPDF to display images referenced by HTML dictionaries.

Depends on: https://github.com/koreader/koreader-base/pull/2002
Fixes: https://github.com/koreader/koreader/issues/12628
This commit is contained in:
TnS-hun
2024-12-12 21:58:35 +01:00
committed by GitHub
parent 7efd033489
commit f232b0e8e6
4 changed files with 14 additions and 6 deletions

View File

@@ -641,10 +641,10 @@ local function tidyMarkup(results)
result.ifo_lang = ifo.lang
end
if ifo and ifo.is_html then
local dict_path = util.splitFilePathName(ifo.file)
result.is_html = ifo.is_html
result.css = ifo.css
if ifo.fix_html_func then
local dict_path = util.splitFilePathName(ifo.file)
local ok, fixed_definition = pcall(ifo.fix_html_func, result.definition, dict_path)
if ok then
result.definition = fixed_definition
@@ -652,6 +652,11 @@ local function tidyMarkup(results)
logger.warn("Dict's user provided function failed:", fixed_definition)
end
end
local res_dir = dict_path .. "res"
if lfs.attributes(res_dir, "mode") == "directory" then
result.dictionary_resource_directory = res_dir
end
else
local def = result.definition
-- preserve the <br> tag for line break