Module:Italic title: Difference between revisions

From Wikipedia of the Dark Brotherhood, an online Star Wars Club
m (Change i tag to span)
m (Move parentheses into span)
 
(4 intermediate revisions by the same user not shown)
Line 10: Line 10:
     local result
     local result
     if prefix and parentheses and args.all ~= 'yes' then
     if prefix and parentheses and args.all ~= 'yes' then
         result = string.format("<span class='italic-title'>%s</span> (<span class='parenthetical-title'>%s</span>)", prefix, parentheses)
         local className = string.match(parentheses, '(.*)%-class')
        if className then
            result = string.format("<i class='italic-title'>%s</i> <span class='parenthetical-title'>(<i>%s</i>-class)</span>", prefix, className)
        else
            result = string.format("<i class='italic-title'>%s</i> <span class='parenthetical-title'>(%s)</span>", prefix, parentheses)
        end
     else
     else
         result = string.format("<i>%s</i>", title.text)
         result = string.format("<i>%s</i>", title.text)

Latest revision as of 17:18, 26 June 2016

-- This module implements .

local p = {}

function p._main(args, frame, title)

   args = args or {}
   frame = frame or mw.getCurrentFrame()
   title = title or mw.title.getCurrentTitle()
   local prefix, parentheses = mw.ustring.match(title.text, '^(.+) %(([^%(%)]+)%)$')
   local result
   if prefix and parentheses and args.all ~= 'yes' then
       local className = string.match(parentheses, '(.*)%-class')
       if className then
           result = string.format("%s (%s-class)", prefix, className)
       else
           result = string.format("%s (%s)", prefix, parentheses)
       end
   else
       result = string.format("%s", title.text)
   end
   if title.namespace ~= 0 then
       result = title.nsText:gsub('_', ' ') .. ':' .. result
   end
   return frame:callParserFunction('DISPLAYTITLE', result, args[1])

end

function p.main(frame)

   local args = require('Module:Arguments').getArgs(frame, {
       wrappers = 'Template:Italic title'
   })
   return p._main(args, frame)

end

return p