Jump to content

Module:Titelweergave

Di Wikipedia, e ensiklopedia liber

Documentation for this module may be created at Module:Titelweergave/doc

-- Module for DISPLAYTITLE stuff
-- Note: the DISPLAYTITLE invocation cannot happen in Lua without invoking a preprocess
local p = {}

-- Returns a new page title where the (sub)pagename without parenthesized
-- suffix is surrounded by double quotes ('').
-- i.e. "Sinterklaas (film)" results in "''Sinterklaas'' (film)"
-- i.e. "User:Zwarte Piet/Kladblok/Sinterklaas (film)" results in 
--      "User:Zwarte Piet/Kladblok/''Sinterklaas'' (film)"
function p.cursief(frame)
    -- Voor welke pagina?
    local title = frame.args.pagina or frame.args[1]
	if ( not title or title == "" ) then
		title = mw.title.getCurrentTitle()
	else
		title = mw.title.new(title)
	end

    local namespace = title.namespace
    local base = title.baseText
    local subpage = title.subpageText

    local subpagei = string.gsub(subpage, "^([^%(]*)( %(.*%))$", "''%1''%2")
    if subpage == subpagei then
    	subpagei = "''"..subpage.."''"
    end
    local pagename
    if base == subpage then
		pagename = subpagei
	else
		pagename = base.."/"..subpagei
	end
    title = mw.title.makeTitle(namespace, pagename)
    local r = title.prefixedText
    return r
end

return p