440
edits
(don't add pages in the user namespace to Category:Hatnote templates with errors) |
m (1 revision imported from wikipedia:Module:Hatnote) |
||
(5 intermediate revisions by 4 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
--------------------------------------------------------------------------------
Line 141:
return p.makeWikitextError(
'no link specified',
'Template:Format
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]].
elseif preHash ~= '' then
-- We have a link like [[Foo#Bar]].
page = preHash
end
-- Find the section, if it exists.
local
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
display = string.format('§ %s', section)
elseif section then
display = string.format('%s § %s', page, section)
else
Line 277 ⟶ 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
|