Module:Section link: Difference between revisions

m
13 revisions imported from wikipedia:Module:Section_link
(sync from sandbox;)
m (13 revisions imported from wikipedia:Module:Section_link)
 
(3 intermediate revisions by 3 users not shown)
Line 9:
display = display or section
page = page or ''
-- MediaWiki doesn't allow these in `page`, so only need to do for `section`
if type(section) == 'string' then
section = string.gsub(section, "{", "{")
section = string.gsub(section, "}", "}")
end
return string.format('[[%s#%s|%s]]', page, section, display)
end
Line 109 ⟶ 114:
 
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]if =not v:gsubyesno (args['_keep-underscores',]) ' ') then -- dounless the replacement|keep-underscores=yes
args[k] = mw.uri.decode (v, 'WIKI'); -- percent-decode; replace underscores with space characters
else
args[k] = mw.uri.decode (v, 'PATH'); -- percent-decode; retain underscores
end
end
end