پرش به محتوا

پودمان:Format link: تفاوت میان نسخه‌ها

۲۶۶ بایت اضافه‌شده ،  ‏۲ فوریهٔ ۲۰۲۲
ایجادشده به کمک به ویکی‌فا، از https://en.imamatpedia.org/w/index.php?title=Module:Format_link&oldid=1064575531
جز (۱ نسخه واردشده)
(ایجادشده به کمک به ویکی‌فا، از https://en.imamatpedia.org/w/index.php?title=Module:Format_link&oldid=1064575531)
خط ۲۹: خط ۲۹:
local function removeInitialColon(s)
local function removeInitialColon(s)
-- Removes the initial colon from a string, if present.
-- Removes the initial colon from a string, if present.
return s:match('^:?(.*)')
return mw.ustring.match(s, '^:?(.*)')
end
end


خط ۵۲: خط ۵۲:
-- Find whether a faux display value has been added with the {{!}} magic
-- Find whether a faux display value has been added with the {{!}} magic
-- word.
-- word.
local prePipe, display = link:match('^(.-)|(.*)$')
local prePipe, display = mw.ustring.match(link, '^(.-)|(.*)$')
link = prePipe or link
link = prePipe or link


-- Find the page, if it exists.
-- Find the page, if it exists.
-- For links like [[#Bar]], the page will be nil.
-- For links like [[#Bar]], the page will be nil.
local preHash, postHash = link:match('^(.-)#(.*)$')
local preHash, postHash = mw.ustring.match(link, '^(.-)#(.*)$')
local page
local page
if not preHash then
if not preHash then
خط ۹۹: خط ۹۹:
mError = require('Module:Error')
mError = require('Module:Error')
return mError.error{message =
return mError.error{message =
'Error: no link or target specified! ([[' .. target .. '#Errors|help]])'
'خطا:پیوند یا هدف مشخص نشده‌است! ([[' .. target .. '#خطاها|راهنما]])'
}
}
end
end
خط ۱۱۱: خط ۱۱۱:
yesno = require('Module:Yesno')
yesno = require('Module:Yesno')
local args = getArgs(frame)
local args = getArgs(frame)
local link = args[1] or args.link
local link = args[1] or args.link or args['پیوند']
local target = args[3] or args.target
local target = args[3] or args.target or args['هدف']
if not (link or target) then
if not (link or target) then
return missingArgError('Template:Format link')
return missingArgError('الگو:قالب‌بندی پیوند')
end
end


return p._formatLink{
return p._formatLink{
link = link,
link = link,
display = args[2] or args.display,
display = args[2] or args.display or args['نمایش'],
target = target,
target = target,
italicizePage = yesno(args.italicizepage),
italicizePage = yesno(args.italicizepage or args['صفحه ایتالیک']),
italicizeSection = yesno(args.italicizesection),
italicizeSection = yesno(args.italicizesection or args['بخش ایتالیک']),
categorizeMissing = args.categorizemissing
categorizeMissing = args.categorizemissing or args['رده‌بندی ناموجودها']
}
}
end
end
خط ۱۴۶: خط ۱۴۶:
if options.target == '' then options.target = nil end
if options.target == '' then options.target = nil end
if not (options.link or options.target) then
if not (options.link or options.target) then
return missingArgError('Module:Format link')
return missingArgError('پودمان:Format link')
end
end


خط ۱۶۹: خط ۱۶۹:
if parsed.page then title = mw.title.new(parsed.page) end
if parsed.page then title = mw.title.new(parsed.page) end
if title and (not title.isExternal) and (not title.exists) then
if title and (not title.isExternal) and (not title.exists) then
category = mw.ustring.format('[[Category:%s]]', catMissing)
category = mw.ustring.format('[[رده:%s]]', catMissing)
end
end
end
end
کاربر ناشناس