Module:Sandbox/Codemini/Testarea
Appearance
local p = {}
local function parseLink(link)
link = removeInitialColon(link)
local prePipe, display = link:match('^(.-)|(.*)$')
link = prePipe or link
local preHash, postHash = link:match('^(.-)#(.*)$')
local page
if not preHash then
page = link
elseif preHash ~= '' then
page = preHash
end
local section
if postHash and postHash ~= '' then
section = postHash
end
return {
link = link,
page = page,
section = section,
display = display,
}
end
local function removeInitialColon(s)
return s:match('^:?(.*)')
end
function p.main(parsed)
section = parsed.section
page = parsed.page
if (not section) then
return page
elseif (not page) then
return mw.ustring.format('§ %s', section)
else return mw.string.format('%s § %s', page, section)
end
end
return p