Module:Correction syntaxique

De WikiTatafrik

local p = {}

local function sanitize(text) return mw.text.nowiki(tostring(text):gsub('\n', ' ↲ ')) end

local function _verif(passed_args, modele_args, cat) local rv = "" local nombre = 0 for a,b in pairs(passed_args) do if (modele_args[a] == nil and b ~= "") then nombre = nombre + 1 rv = rv .. '" end end if (nombre > 0) then local categorie if (cat) and (cat ~= "") then categorie = tostring(mw.title.new(cat, "Catégorie")) else categorie = "Catégorie:Page appelant un modèle avec un paramètre inconnu" end if (nombre > 10) then rv = rv .. "+" else rv = rv .. "" .. categorie .. "" end end return rv end

function p.verif( passed_args, modele_args_list, cat ) local modele_args = {} for i, v in ipairs( modele_args_list ) do if tonumber( v ) then modele_args[ tonumber( v ) ] = true else modele_args[ v ] = true end end return _verif( passed_args, modele_args, cat ) end

function p.verifierLesArguments(frame) local passed_args = frame:getParent().args local modele_args = frame.args local cat = modele_args["_catégorie"] return _verif(passed_args, modele_args, cat) end

return p