Module:Quote

-- local Quote = {} local getArgs = require('Module:Arguments').getArgs

local function build(quotecontents, quotesource, options) local quotecontainer = mw.html.create('blockquote') :addClass('pull-quote') :addClass(options.align) :addClass(options.extraclasses) :css(options.styles) :cssText(options.extrastyles) quotecontainer:node(quotecontents) if quotesource then local quote_source = quotecontainer:tag('cite') :addClass('pull-quote__source') :wikitext(quotesource) end return quotecontainer end

local function options(args) local options = {} options.styles = {} options.extraclasses = args.class options.extrastyles = args.style options.align = '' if args.align then options.align = 'pull-quote--' .. args.align options.styles['width'] = args.width or args.quotewidth or '300px' end return options end

function Quote.quote(frame) local args = getArgs(frame)

local options = options(args) local quotetext = args[1] or args.quotetext or args.quote or args.text local person = args[2] or args.person or args.speaker or args.personquoted or nil local source = args[3] or args.source or args.quotesource or nil local quotecontents = mw.html.create('p') :addClass('pull-quote__text') :wikitext(quotetext) local quotesource = person if source then quotesource = person .. ', ' .. source end return build(quotecontents, quotesource, options) end

function Quote.dialogue(frame) local args = getArgs(frame) local options = options(args) local quotecontents = mw.html.create('div') :addClass('pull-quote__text') local quotesource

for i, v in ipairs(args) do       local next_param = i + 1 if i % 2 ~= 0 then quotecontents:tag('div') :addClass('pull-quote__line') :tag('strong') :addClass('pull-quote__speaker') :wikitext(v .. ':') :done :wikitext(' ' .. args[next_param]) :done end end if args.context and args.source then quotesource = args.context .. ', ' .. args.source elseif args.context and not args.source then quotesource = args.context elseif args.source and not args.context then quotesource = args.source end return build(quotecontents, quotesource, options) end

return Quote