« Module:Version imprimable » : différence entre les versions

Contenu supprimé Contenu ajouté
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 3 :
-- Cherche et renvoie le contenu des pages du sommaire placé en paramètre, pour créé une version imprimable du livre.
function p.affiche_livre(frame)
local debugage = True
local param = frame.args[1]
if (param ~= nil and mw.text.trim(param) ~= '') then
Ligne 14 ⟶ 15 :
for i,v in ipairs(lines_) do
if string.sub(v, 1, 1) == "*" or string.sub(v, 1, 1) == "#" then
if debugage == True then
-- Extrait les titres des pages
chapter = mw.text.trim(mw.ustring.gsub(v, "[ \*\#\[]*([^\|]*).*", "%1"))
chapter = mw.ustring.gsub(chapter, "<small>", "")
if (chapter ~= nil and chapter ~= '' and mw.title.new(chapter).exists) then
--table.insert(lignes, frame:expandTemplate{ title = ':' .. chapter } .. '\n\n')
-- Débugage
text2 = title.getContent(title)
table.insert(lignes, text2 .. '\n')
else
-- Extrait les titres des pages
chapter = mw.text.trim(mw.ustring.gsub(v, "[ \*\#\[]*([^\|]*).*", "%1"))
chapter = mw.ustring.gsub(chapter, "<small>", "")
if (chapter ~= nil and chapter ~= '' and mw.title.new(chapter).exists) then
-- table.insert(lignes, frame:expandTemplate{ title = ':' .. chapter } .. '\n\n')
end
end
end