mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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:
@@ -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("[}{\">/<'&]", {
|
||||
["&"] = "&",
|
||||
["<"] = "<",
|
||||
[">"] = ">",
|
||||
['"'] = """,
|
||||
["'"] = "'",
|
||||
["/"] = "/",
|
||||
})
|
||||
end
|
||||
|
||||
return util
|
||||
|
||||
Reference in New Issue
Block a user