"मोड्युल:Hatnote" का संशोधनहरू बिचको अन्तर
Content deleted Content added
parse pages for section-only links as nil - this prevents section-only links that have an italicized page parameter from having empty <i></i> tags |
परीक्षण |
||
पङ्क्ति ९:
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local mArguments -- lazily initialise [[Module:Arguments]]
local yesno -- lazily initialise [[Module:Yesno]]
Line ५७ ⟶ ५६:
local ret = {}
for i, page in ipairs(pages) do
ret[i] = p._formatLink
end
return ret
Line ७१ ⟶ ७०:
local link = t[1]
local display = t[2]
links[i] = p._formatLink
end
return links
Line ९४ ⟶ ९३:
-- Make the category text.
local category
if not title.isTalkPage
category = 'Hatnote templates with errors'
category = string.format(
Line ११७ ⟶ ११३:
function p.disambiguate(page, disambiguator)
-- Formats a page title with a disambiguation parenthetical,
-- i.e. "Example" → "Example (
checkType('disambiguate', 1, page, 'string')
checkType('disambiguate', 2, disambiguator, 'string', true)
disambiguator = disambiguator or '
return string.format('%s (%s)', page, disambiguator)
end
Line १३० ⟶ १२६:
-- 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.
--------------------------------------------------------------------------------
function p.formatLink(frame)
local args = getArgs(frame)
local link = args[1]
local display = args[2]
if not link then
return p.makeWikitextError(
'no link specified',
'Template:Format hatnote link#Errors',
args.category
)
end
return p._formatLink
end
checkType('_formatLink', 1, link, 'string')
checkType('_formatLink', 2, display, 'string', true)
-- Remove the initial colon for links where it was specified manually.
link = removeInitialColon(link)
-- Find whether a faux display value has been added with the {{!}} magic
-- word.
link = prePipe or link
display = postPipe
end
-- Find the
if not display then
local page, section = link:match('^(.-)#(.*)$')
if page then
display = page .. ' § ' .. section
end
end
-- Assemble the link.
if display then
return string.format(
'[[:%s|%s]]',
string.gsub(link, '|(.*)$', ''), --display overwrites manual piping
display
)
else
end
end
|