Modul:Italic title

Aus skandinavien-wiki.net
Version vom 17. Juni 2013, 10:47 Uhr von wpen>Mr. Stradivarius (match the start of the string as well)

Die Dokumentation für dieses Modul kann unter Modul:Italic title/doc erstellt werden

-- This module implements {{italic title}}.

local p = {}

function p.main()
    local title = mw.title.getCurrentTitle() -- Get the current page object.
    -- Find the parts before and after the disambiguation brackets, if any.
    local prefix, brackets = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$')
    -- If brackets were found, italicise only the part before them. Otherwise
    -- italicise the whole title.
    local result
    if prefix and brackets then
        result = "''" .. prefix .. "'' " .. brackets
    else
        result = "''" .. title.text .. "''"
    end
    -- Add the namespace if it exists.
    if title.nsText and title.nsText ~= "" then
        result = title.nsText .. ':' .. result
    end
    -- Call displaytitle with the text we generated.
    return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result )
end

return p