Module:Hatnote: Difference between revisions

m
1 revision imported from wikipedia:Module:Hatnote
(Remove stray space per edit request; update comment and error message for move of Template:Format hatnote link to Template:Format link in 2014)
m (1 revision imported from wikipedia:Module:Hatnote)
 
(4 intermediate revisions by 3 users not shown)
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 not page or page == '' then
display = string.format('§ %s', section)
elseif section then
Line 279 ⟶ 293:
end
return string.format(
'%s<div role="note" class="%s">%s</div>',
mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:Hatnote/styles.css' }
},
table.concat(classes, ' '),
s