Fixed certain subjects not hyperlinking

master
AardCrowley 2 years ago committed by GitHub
parent 2de8be4b24
commit 24690a486b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,7 +40,9 @@ require 'themed_miniwindows'
fontName = GetAlphaOption("output_font_name")
fontHeight = GetOption("output_font_height")
postNo = ""
author = ""
subject = ""
if not GetVariable("noteShow") then
SetVariable("noteShow", "true")
@ -126,18 +128,30 @@ end
function shouldHyperlink(str, tbl)
local hyperTbl = {}
local youShould = false
postNo = ""
author = ""
subject = ""
table.insert(hyperTbl, TruncateStyles(tbl, 2, 7))
table.insert(hyperTbl, TruncateStyles(tbl, 23, 34))
table.insert(hyperTbl, TruncateStyles(tbl, 37, 72))
for _,v in ipairs(TruncateStyles(tbl, 2, 7)) do
postNo = postNo .. v.text
end
for _,v in ipairs(hyperTbl) do
for _,w in ipairs(v) do
if Hash(w.text):find(Hash(str)) then
youShould = true
break
for _,v in ipairs(TruncateStyles(tbl, 23, 34)) do
author = author .. v.text
end
for _,v in ipairs(TruncateStyles(tbl, 37, 72)) do
subject = subject .. v.text
end
postNo = postNo:gsub("[^%z\1-\127]+", ""):gsub("%s+$", "")
author = author:gsub("[^%z\1-\127]+", ""):gsub("%s+$", "")
subject = subject:gsub("[^%z\1-\127]+", ""):gsub("%s+$", "")
byteSubj = subject:gsub("%p", function(c) return string.format("\\%d", string.byte(c)) end)
str = str:gsub("[^%z\1-\127]+", ""):gsub("%s+$", ""):gsub("%p", function(c) return string.format("\\%d", string.byte(c)) end )
if str:find(postNo) or str:find(author) or str:find(byteSubj) then
youShould = true
end
return youShould
@ -154,19 +168,12 @@ function hyperText(tbl)
end
function hyperlinknotes(lines)
local postNo
local author
local subj
for i,v in ipairs(lines) do
if i == 1 then
Simulate(stylesToANSI(v) .. ColoursToANSI(" @C(Clickable posts)") .. "\n")
elseif i <= 4 or i == #lines then
Simulate(stylesToANSI(v) .. "\n")
elseif i < #lines then
--postNo = v[2].text:gsub(" ", "")
postNo = hyperText(TruncateStyles(v, 2, 7)):gsub(" ", "")
author = hyperText(TruncateStyles(v, 23, 34)):gsub("%s+$", "")
subject = hyperText(TruncateStyles(v, 37, 72)):gsub("%s+$", "")
for j,k in ipairs(v) do
if shouldHyperlink(k.text, v) then
Hyperlink(prefix .. "Execute('note read " .. postNo .. "')", k.text, "Post #" .. postNo .. ": " .. subject .. " (" .. author .. ")", RGBColourToName(k.textcolour), RGBColourToName(k.backcolour), false, true)

Loading…
Cancel
Save