Module:Section link/sandbox: Difference between revisions

Content deleted Content added
cleanup code
trying decodeAnchor function
Line 4:
 
local p = {}
 
local function decodeAnchor(anchor)
return (anchor:gsub(
"%.([0-9A-F][0-9A-F])", -- lowercase a-f is not used
function (hexByte)
return string.char(tonumber(hexByte, 16))
end))
end
 
 
local function makeSectionLink(page, section, display)
Line 44 ⟶ 53:
if #sections <= 1 then
local linkPage = page or ''
local section = decodeAnchor(sections[1]) or 'Notes'
local display = '§&nbsp;' .. section
if isShowingPage then
Line 67 ⟶ 76:
local ret = {}
for i, section in ipairs(sections) do
ret[i] = makeSectionLink(page, decodeAnchor(section))
end