Modul:Italic title: Unterschied zwischen den Versionen
add comments
(try using callParserFunction again) |
(add comments) |
||
Zeile 1: | Zeile 1: | ||
-- This module implements {{italic title}}. | |||
local p = {} | local p = {} | ||
function p.main() | function p.main() | ||
local title = mw.title.getCurrentTitle() | 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, '(.+) (%([^%(%)]+%))$') | 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 | local result | ||
if prefix and brackets then | if prefix and brackets then | ||
Zeile 10: | Zeile 15: | ||
result = "''" .. title.text .. "''" | result = "''" .. title.text .. "''" | ||
end | end | ||
-- Add the namespace if it exists. | |||
if title.nsText and title.nsText ~= "" then | if title.nsText and title.nsText ~= "" then | ||
result = title.nsText .. ':' .. result | result = title.nsText .. ':' .. result | ||
end | end | ||
-- Call displaytitle with the text we generated. | |||
return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result ) | return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result ) | ||
end | end | ||
return p | return p |