« Module:Règle » : différence entre les versions
De Nefald
Autres actions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| (5 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
local function makeAncre(numero) | |||
return "r-" .. string.gsub(numero, "%.", "-") | |||
end | |||
function p.regle(frame) | function p.regle(frame) | ||
| Ligne 8 : | Ligne 12 : | ||
if numero == "" then return "" end | if numero == "" then return "" end | ||
local _, points = string.gsub(numero, "%.", "") | local _, points = string.gsub(numero, "%.", "") | ||
local niveau = math.min(points + 1, 3) | local niveau = math.min(points + 1, 3) | ||
local ancre = makeAncre(numero) | |||
local lien = '[[#' .. ancre .. '|§ ' .. numero .. ']]' | |||
local sortie = '<span id="' .. ancre .. '"></span>' .. lien .. ' ' .. texte | |||
return frame:preprocess(sortie) | |||
end | |||
function p.rref(frame) | |||
local | local args = frame:getParent().args | ||
local numero = mw.text.trim(args[1] or "") | |||
local page = mw.text.trim(args["page"] or "") | |||
if numero == "" then return "" end | |||
local ancre = makeAncre(numero) | |||
local | local label = '§ ' .. numero | ||
local lien | |||
-- | if page ~= "" then | ||
-- Lien vers une autre page | |||
lien = '[[' .. page .. '#' .. ancre .. '|' .. label .. ']]' | |||
else | |||
-- Lien vers la page courante | |||
lien = '[[#' .. ancre .. '|' .. label .. ']]' | |||
end | |||
return frame:preprocess( | return frame:preprocess(lien) | ||
end | end | ||
return p | return p | ||