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

Contenu supprimé Contenu ajouté
MEP
MEP
Ligne 10 :
templateLeft = '<div style="float: left;">[[File:Go-previous-grey.svg|48px|link=]] [[printf]]</div>'
templateRight = '<div style="float: right;">[[printf]] [[File:Go-next-grey.svg|48px|link=]]</div>'
linkTemplate = "C"
TOC = "Sommaire"
sep = "/"
Ligne 28 ⟶ 27 :
if frame.args == nil then return '' end
if frame.args[1] == nil then return '' end
local BookName = p._escapePattern(frame.args[1])
if (BookName ~= nil and mw.text.trim(BookName) ~= '') then
title = mw.title.new(BookName)
if frame.args[2] ~= nil and frame.args[2] ~= '' then
BookName = p._escapePattern(frame.args[2])
else
if mw.ustring.find(BookName, p._escapePattern(sep .. TOC)) ~= nil then BookName = mw.ustring.gsub(BookName, "^(.*)" .. sep .. TOC .. "$", "%1") end
Ligne 107 ⟶ 106 :
chapter = mw.ustring.gsub(chapter, "%/%]%]", "]]")
chapter = mw.ustring.gsub(chapter, "%/$", "")
 
if mw.ustring.find(chapter, "%[%[") ~= nil then
-- Pages titles extraction from the TOC
Ligne 128 ⟶ 126 :
if OnlySubpages then
-- Book subpages only (and ignoring the other links like "see also")
if mw.ustring.find(chapter, p._escapePattern(BookName .. sep)) == nil then
if debug then chapter = "<font color=red>No book subpage into the internal link:</font> '" .. chapter .. "' doesn't include '" .. BookName .. sep .. "'" else chapter = '' end
end
Ligne 144 ⟶ 142 :
if frame.args == nil then return '' end
if frame.args[1] == nil then return '' end
local BookName = p._escapePattern(frame.args[1])
local currentPageName = p._escapePattern(frame.args[2])
 
if (BookName ~= nil and mw.text.trim(BookName) ~= '') then
Ligne 174 ⟶ 172 :
chapter = p.subpage(BookName, v)
if chapter ~= nil then
if mw.ustring.find(chapter, p._escapePattern(BookName .. sep)) == nil then
chapter = BookName .. sep .. chapter
end
Ligne 208 ⟶ 206 :
 
if found == true and table.getn(footer) == 0 then
if debug then table.insert(footer, "<font color=red>No next chapter</font>\n") end
theTemplateLeft, nb = mw.ustring.gsub(templateLeft, "printf", BookName .. sep .. previousChapter .. '|' .. previousChapter)
table.insert(footer, theTemplateLeft)
theTemplateRight, nb = mw.ustring.gsub(templateRight, "printf", BookName .. '|' .. TOC)
table.insert(footer, theTemplateRight)
end