Anonymous user
Module:Section link: Difference between revisions
implement display= parameter
(changing to non-breaking nbsp per lengthy talk discussion with Edokter, SMcCandlish, LLarson, among others about § not wrapping) |
(implement display= parameter) |
||
Line 11:
end
local function
title = mw.ustring.gsub(title,"'","")
title = mw.ustring.gsub(title,'"','')
title = mw.ustring.gsub(title,"%b<>","")
return mw.title.new(title).prefixedText
end
function p._main(page, sections, options, title, displaytitle)
-- Validate input.
checkType('_main', 1, page, 'string', true)
Line 43 ⟶ 50:
if isShowingPage then
page = page or title.prefixedText
if displaytitle then
display = page .. ' ' .. display▼
if normalizeTitle(displaytitle) == normalizeTitle(page) then
display = displaytitle .. ' ' .. display
else
error(string.format(
'Display title "%s" was ignored since it is ' ..
"not equivalent to the page's actual title",
displaytitle
), 0)
end
else
▲ display = page .. ' ' .. display
end
end
return makeSectionLink(linkPage, section, display)
Line 89 ⟶ 108:
-- Sort the arguments.
local page, displaytitle
local sections, options = {}, {}
for k, v in pairs(args) do
Line 98 ⟶ 117:
elseif type(k) == 'number' then
sections[k] = v
elseif k == 'display' then
displaytitle = v
else
options[k] = v
Line 117 ⟶ 138:
sections = compressArray(sections)
return p._main(page, sections, options, nil, displaytitle)
end
|