« Module:Règle » : différence entre les versions
De Nefald
Autres actions
m ancre + copie dans le presse-papier |
Aucun résumé des modifications |
||
| Ligne 12 : | Ligne 12 : | ||
local ancre = "r-" .. string.gsub(numero, "%.", "-") | local ancre = "r-" .. string.gsub(numero, "%.", "-") | ||
local | -- Lien en wikitext pur (interprété correctement par preprocess) | ||
.. ' | local lien = '[[#' .. ancre .. '|§ ' .. numero .. ']]' | ||
.. texte | |||
-- Ancre native + lien + texte, tout en wikitext | |||
local sortie = '<span id="' .. ancre .. '"></span>' .. lien .. ' ' .. texte | |||
return frame:preprocess(sortie) | return frame:preprocess(sortie) | ||
Version du 22 février 2026 à 11:59
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, "%.", "-")
-- Lien en wikitext pur (interprété correctement par preprocess)
local lien = '[[#' .. ancre .. '|§ ' .. numero .. ']]'
-- Ancre native + lien + texte, tout en wikitext
local sortie = '<span id="' .. ancre .. '"></span>' .. lien .. ' ' .. texte
return frame:preprocess(sortie)
end
return p