Module:Section link: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(Detect anchors in page parameter, other code cleanup) |
(cleanup code) |
||
Line 16: | Line 16: | ||
end |
end |
||
function p._main(page, sections, options, title |
function p._main(page, sections, options, title) |
||
-- Validate input. |
-- Validate input. |
||
checkType('_main', 1, page, 'string', true) |
checkType('_main', 1, page, 'string', true) |
||
Line 48: | Line 48: | ||
if isShowingPage then |
if isShowingPage then |
||
page = page or title.prefixedText |
page = page or title.prefixedText |
||
if |
if options.display and options.display ~= '' then |
||
if normalizeTitle( |
if normalizeTitle(options.display) == normalizeTitle(page) then |
||
display = |
display = options.display .. ' ' .. display |
||
else |
else |
||
error(string.format( |
error(string.format( |
||
'Display title "%s" was ignored since it is ' .. |
'Display title "%s" was ignored since it is ' .. |
||
"not equivalent to the page's actual title", |
"not equivalent to the page's actual title", |
||
options.display |
|||
), 0) |
), 0) |
||
end |
end |
||
Line 106: | Line 106: | ||
-- Sort the arguments. |
-- Sort the arguments. |
||
local page |
local page |
||
local sections, options = {}, {} |
local sections, options = {}, {} |
||
for k, v in pairs(args) do |
for k, v in pairs(args) do |
||
Line 115: | Line 115: | ||
elseif type(k) == 'number' then |
elseif type(k) == 'number' then |
||
sections[k] = v |
sections[k] = v |
||
elseif k == 'display' then |
|||
displaytitle = v |
|||
else |
else |
||
options[k] = v |
options[k] = v |
||
Line 142: | Line 140: | ||
sections = compressArray(sections) |
sections = compressArray(sections) |
||
return p._main(page, sections, options |
return p._main(page, sections, options) |
||
end |
end |
||