Documentation for this module may be created at Module:Quote/doc

local p = {}

local userError = require('Dev:User error')

function replacer(tag, text)
    return table.concat({
        '<span data-color="',
        tag,
        '">',
        text,
        '</span>'
    })
end

function p.main(frame)
    local args = frame:getParent().args
    if not args[1] then
        return userError('No quotation text provided', 'Pages with user errors')
    end
    local quote, _ = mw.ustring.gsub(mw.text.trim(args[1]), '\n', '<br />')
    quote, _ = mw.ustring.gsub(quote, '<(%w+)>([^<]+)</%1>', replacer)
    local html = mw.html.create('blockquote'):attr({
        ['data-template'] = 'quote',
        ['data-font']     = args[3]
    })
        :tag('p')
            :wikitext(quote)
        :done()
    if args[2] then
        html:tag('cite')
                :wikitext(args[2])
            :done()
    end
    return tostring(html:done())
end

return p
Community content is available under CC-BY-SA unless otherwise noted.