Module:Règle
De Nefald
Autres actions
La documentation pour ce module peut être créée à Module:Règle/doc
local p = {}
function p.regle(frame)
local args = frame:getParent().args
local numero = mw.text.trim(args[1] or "")
local texte = mw.text.trim(args[2] or "")
if numero == "" then return "" end
local _, points = string.gsub(numero, "%.", "")
local niveau = math.min(points + 1, 3)
local ancre = "r-" .. string.gsub(numero, "%.", "-")
local texte_parse = frame:preprocess(texte)
-- L'ancre est posée via un span SÉPARÉ du div principal
-- MediaWiki accepte les id sur les spans dans le wikitext parsé
local html = '<span id="' .. ancre .. '"></span>'
.. '<div class="regle-item regle-niveau-' .. niveau .. '">'
.. '<a class="regle-numero" href="#' .. ancre .. '">§ ' .. numero .. '</a>'
.. '<span class="regle-texte">' .. texte_parse .. '</span>'
.. '</div>'
return frame:preprocess(html)
end
return p