« Module:Bases » : différence entre les versions

Un livre de Wikilivres.
Contenu supprimé Contenu ajouté
+fait_categorie (sans accent !)
+3 fonctions pour créer l'entête, une ligne, et la fin d'un tableau simple
Ligne 36 : Ligne 36 :
return ''
return ''
end
end
end

-- Crée l'entête d'un tableau wiki triable (avec les titres en paramètre)
function tableau_entete(titres)
local entete = '{| class="wikitable sortable"\r\n'
entete = entete .. '|-\r\n!' .. table.concat(titres, ' !! ')
return entete
end

-- Crée une ligne du tableau wiki
function tableau_ligne(elements)
local ligne = '|-\r\n|' .. table.concat(elements, ' || ')
return ligne
end

-- Crée la fin d'un tableau
function tableau_fin()
return "|}\r\n"
end
end



Version du 19 mars 2013 à 20:25

La documentation pour ce module peut être créée à Module:Bases/Documentation

local b = {}

-- Doit-on faire une élision devant ce mot ?
function b.is_elidable(mot)
    if (mw.ustring.match( mot, "^[aàâäeéèêëiîïoôöuùûü]" ) ~= nil) then
        return true
    else
        return false
    end
end

-- S'agit-il d'une locution ?
function b.is_locution(mot)
    if (mw.ustring.find(mot, ' ') ~= nil) then
        return true
    else
        return false
    end
end

-- Renvoie le texte avec la première lettre en majuscule (si le texte est en français)
function b.ucfirst(texte)
    locale = mw.language.new('fr')
    return locale:ucfirst(texte)
end

-- Renvoie une catégorie bien formée
function b.fait_categorie(texte, clef)
    if (texte ~= nil) then
        if (clef) then
            return '[[Catégorie:' .. texte .. '|' .. clef .. ']]'
        else
            return '[[Catégorie:' .. texte .. ']]'
        end
    else
        return ''
    end
end

-- Crée l'entête d'un tableau wiki triable (avec les titres en paramètre)
function tableau_entete(titres)
    local entete = '{| class="wikitable sortable"\r\n'
    entete = entete .. '|-\r\n!' .. table.concat(titres, ' !! ')
    return entete
end

-- Crée une ligne du tableau wiki
function tableau_ligne(elements)
    local ligne = '|-\r\n|' .. table.concat(elements, ' || ')
    return ligne
end

-- Crée la fin d'un tableau
function tableau_fin()
    return "|}\r\n"
end

return b