Module:Sandbox

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

function split(str, pattern) local out = {} for m in string.gmatch(str, "[^" .. pattern .. "]+") do     table.insert(out, m)    end return out end

function isEmpty(s) return s == nil or s == '' end

function keepLowercase(str) local small = { ["And"] = "and", ["An"] = "an", ["As"] = "as", ["At"] = "at", ["By"] = "by", ["En"] = "en", ["De"] = "de", ["For"] = "for", ["If"] = "if", ["In"] = "in", ["N"] = "n", ["Nor"] = "nor", ["Of"] = "of", ["On"] = "on", ["Or"] = "or", ["Only"] = "only", ["Over"] = "over", ["Per"] = "per", ["So"] = "so", ["Some"] = "some", ["That"] = "that", ["Than"] = "than", ["The"] = "the", ["To"] = "to", ["Upon"] = "upon", ["Vs"] = "vs", ["Versus"] = "versus", ["Via"] = "via", ["Where"] = "where", ["When"] = "when", ["With"] = "with", ["Without"] = "without", ["Yet"] = "yet" }	if small[str:gsub("^%l", string.upper)] then return small[str] else return str:gsub("^%l", string.upper) end end

function p.main(frame) local args        = getArgs(frame) local name         = args['1'] or '' return p.properCase(name) end

function p.properCase(name) local words = split( name, " " ) local word = "" local wordList = "" local fullName = "" local availabilityOutput = "" for k, w in ipairs(words) do       fullName = keepLowercase(w:gsub("^%s*(.-)%s*$", "%1")) .. " "       wordList = wordList .. string.gsub(fullName, "\s+$", "") end

local root = mw.html.create root:wikitext(wordList) return root end

return p