Anonymous user
Module:Section link: Difference between revisions
fix error placement and tweak default conjunction
(create replacement for Template:Section link) |
(fix error placement and tweak default conjunction) |
||
Line 4:
local p = {}
end▼
local function makeSectionLink(page, section, display)
Line 32 ⟶ 25:
options = options or {}
title = title or mw.title.getCurrentTitle()
if #sections < 1 then▼
return makeWikitextError('at least one section must be specified')▼
-- Make the link(s).
Line 48 ⟶ 38:
return makeSectionLink(linkPage, section, display)
else
-- Multiple sections. First,
▲ end
-- Make the list of links.
local ret = {}
for i, section in ipairs(sections) do
ret[i] = makeSectionLink(page, section)
end
-- Assemble the list of links into a string with mw.text.listToText.
-- We use the default
-- conjunction. There is also a special case conjunction if we only
-- have two links.
local conjunction
if #sections == 2 then
conjunction = '​ and '
else
conjunction = ', and '
end
ret = mw.text.listToText(ret, nil, conjunction)
Line 69 ⟶ 67:
end
ret = intro .. ret
return ret
end
Line 107 ⟶ 105:
end
sections = compressArray(sections)
return p._main(page, sections, options)
end
|