更新配置相关显示等
This commit is contained in:
29
BookUI.lua
29
BookUI.lua
@@ -74,6 +74,33 @@ local function TextHeight(fs, fallback)
|
||||
return fallback or 14
|
||||
end
|
||||
|
||||
local function StripItemTextHTML(text)
|
||||
if not text or text == "" then return text end
|
||||
if not string.find(text, "<") then return text end
|
||||
|
||||
text = string.gsub(text, "</?HTML>", "")
|
||||
text = string.gsub(text, "</?html>", "")
|
||||
text = string.gsub(text, "</?BODY>", "")
|
||||
text = string.gsub(text, "</?body>", "")
|
||||
text = string.gsub(text, "<H1[^>]*>", "")
|
||||
text = string.gsub(text, "<h1[^>]*>", "")
|
||||
text = string.gsub(text, "</H1>", "\n")
|
||||
text = string.gsub(text, "</h1>", "\n")
|
||||
text = string.gsub(text, "<P[^>]*>", "")
|
||||
text = string.gsub(text, "<p[^>]*>", "")
|
||||
text = string.gsub(text, "</P>", "\n")
|
||||
text = string.gsub(text, "</p>", "\n")
|
||||
text = string.gsub(text, "<BR/>", "\n")
|
||||
text = string.gsub(text, "<br/>", "\n")
|
||||
text = string.gsub(text, "<br>", "\n")
|
||||
text = string.gsub(text, "<[^>]+>", "")
|
||||
|
||||
text = string.gsub(text, "^[\n%s]+", "")
|
||||
text = string.gsub(text, "[\n%s]+$", "")
|
||||
text = string.gsub(text, "\n\n\n+", "\n\n")
|
||||
return text
|
||||
end
|
||||
|
||||
local function IsTrue(v)
|
||||
return v == true or v == 1
|
||||
end
|
||||
@@ -178,7 +205,7 @@ local function UpdateBookContent()
|
||||
text = ItemTextPageText:GetText() or ""
|
||||
end
|
||||
if text and text ~= "" then
|
||||
-- Keep paragraph gap readable: collapse 3+ consecutive newlines.
|
||||
text = StripItemTextHTML(text)
|
||||
text = string.gsub(text, "\n%s*\n%s*\n+", "\n\n")
|
||||
end
|
||||
local pageNum = ItemTextGetPage and tonumber(ItemTextGetPage()) or 1
|
||||
|
||||
Reference in New Issue
Block a user