Anonymous user
Module:Section link: Difference between revisions
sync from sandbox;
(mw.text.decode() input per Template_talk:Section_link#Problem_with_page_names_containing_HTML_entities) |
(sync from sandbox;) |
||
Line 1:
-- This module implements {{section link}}.
require('Module:No globals');
local checkType = require('libraryUtil').checkType
Line 12 ⟶ 13:
local function normalizeTitle(title)
title = mw.ustring.gsub(mw.ustring.gsub(title, "'", ""), '"', '')
return mw.title.new(title).prefixedText
end
Line 94 ⟶ 96:
function p.main(frame)
local yesno = require('Module:Yesno')
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:Section link',
Line 104 ⟶ 107:
end
})
for k, v in pairs(args) do -- replace underscores in the positional parameter values
if 'number' == type(k) and not yesno (args['keep-underscores']) then -- unless |keep-underscores=yes
args[k] = v:gsub ('_', ' ') -- do the replacement
end
end
-- Sort the arguments.
Line 112 ⟶ 121:
-- Doing this in the loop because of a bug in [[Module:Arguments]]
-- when using pairs with deleted arguments.
page = mw.text.decode(v,
elseif type(k) == 'number' then
sections[k] = v
Line 119 ⟶ 128:
end
end
options.nopage = yesno (options.nopage); -- make boolean
-- Extract section from page, if present
|