Modul:Format judul
Tampilan
local _moduleYesno
local function yesno( ... )
if not _moduleYesno then
_moduleYesno = require( 'Module:Yesno' )
end
return _moduleYesno( ... )
end
local p = {}
function p.formatTitle(frame)
local args = frame.args
local title
if args.title then
title = mw.title.new(args.title)
else
title = mw.title.getCurrentTitle()
end
local prefix = ''
if title.nsText ~= '' then
prefix = title.nsText .. ':'
end
if title.isSubpage then
prefix = prefix .. title.baseText .. '/'
end
local mainPart = title.subpageText
local disambig = ''
local disambigStart = mainPart:find(' %(.+%)$')
if disambigStart then
disambig = mainPart:sub(disambigStart)
mainPart = mainPart:sub(1, disambigStart - 1)
end
local lang = args.lang
if lang and lang ~= '' then
mainPart = '<span lang="' .. lang .. '">' .. mainPart .. '</span>'
end
local italic = args.italic
if italic and italic ~= '' and yesno(italic) then
mainPart = '<i>' .. mainPart .. '</i>'
end
return prefix .. mainPart .. disambig
end
function p.setDisplayTitle(frame)
local displayTitle = p.formatTitle(frame)
if displayTitle == mw.title.getCurrentTitle().prefixedText then
return ''
end
return mw.getCurrentFrame():callParserFunction('DISPLAYTITLE', displayTitle, frame.args.options)
end
return p