更新配置相关显示等

This commit is contained in:
rucky
2026-03-20 14:04:51 +08:00
parent 923a1f9ce2
commit 63337b14d2
14 changed files with 886 additions and 98 deletions

View File

@@ -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