Naar inhoud springen

Module:Titelweergave

Uit Wikipedia, de vrije encyclopedie
Moduledocumentatie​[bekijk] [bewerk] [ververs] [geschiedenis]

Functies voor titelweergave. Momenteel 2 functies.

Mogelijke toekomstige functies:

  • "subscript" en "superscript": zet alle cijfers in sub- dan wel superscript.

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

function cursive(frame, lowercase)
    -- For which page?
    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

	if lowercase then
	    base = base:sub(1,1):lower() .. base:sub(2)
	    subpage = subpage:sub(1,1):lower() .. subpage:sub(2)
	end
    
    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

-- 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)
    return cursive(frame, false)
end

function p.kleincursief(frame)
    return cursive(frame, true)
end

return p