HTML dictionary support (#3573)

* Adds a generic HTML widget modeled after the text widget, and HTML dictionary support. HTML dictionaries can have their own CSS (for X.ifo it must be X.css). The base CSS just resets the margin and sets the font.

Note that the widget doesn't handle links, that wasn't needed for the dictionary.

Closes <https://github.com/koreader/koreader/issues/1776>.

* Show tag stripped HTML if the dictionary entry isn't valid HTML

* Simulate the normal <br/> behavior

* Bump base
This commit is contained in:
TnS-hun
2018-01-07 20:24:15 +01:00
committed by Frans de Jonge
parent 5245f018a6
commit 06a8a33d39
6 changed files with 444 additions and 22 deletions

View File

@@ -564,4 +564,18 @@ function util.htmlToPlainTextIfHtml(text)
return text
end
--- Encode the HTML entities in a string
-- @string text the string to escape
-- Taken from https://github.com/kernelsauce/turbo/blob/e4a35c2e3fb63f07464f8f8e17252bea3a029685/turbo/escape.lua#L58-L70
function util.htmlEscape(text)
return text:gsub("[}{\">/<'&]", {
["&"] = "&amp;",
["<"] = "&lt;",
[">"] = "&gt;",
['"'] = "&quot;",
["'"] = "&#39;",
["/"] = "&#47;",
})
end
return util