Module:Hatnote: Difference between revisions

m
51 revisions imported from wikipedia:Module:Hatnote
(don't add pages in the user namespace to Category:Hatnote templates with errors)
m (51 revisions imported from wikipedia:Module:Hatnote)
 
(2 intermediate revisions by 2 users not shown)
Line 130:
-- with colons if necessary, and links to sections are detected and displayed
-- with " § " as a separator rather than the standard MediaWiki "#". Used in
-- the {{format hatnote link}} template.
--------------------------------------------------------------------------------
 
Line 141:
return p.makeWikitextError(
'no link specified',
'Template:Format hatnote link#Errors',
args.category
)
Line 180:
local prePipe, display = link:match('^(.-)|(.*)$')
link = prePipe or link
 
-- Find the page, if it exists.
-- For links like [[#Bar]], the page will be nil.
local preHash, postHash = link:match('^(.-)#(.*)$')
local page
if not preHash then
-- We have a link like [[Foo]].
page = page or link
elseif preHash ~= '' then
-- We have a link like [[Foo#Bar]].
page = preHash
end
 
-- Find the section, if it exists.
local page, section = link:match('^(.-)#(.*)$')
if postHash and postHash ~= '' then
page = page or link
section = postHash
end
return {
Line 231 ⟶ 245:
local page = maybeItalicize(parsed.page, options.italicizePage)
local section = maybeItalicize(parsed.section, options.italicizeSection)
if sectionnot page then
display = string.format('§ %s', section)
elseif section then
display = string.format('%s § %s', page, section)
else