local p = {}
-- Search and display the book pages from the summary page, in order to create a printable version.
function p.affiche_livre(frame)
local param = frame.args[1]
if (param ~= nil and mw.text.trim(param) ~= '') then
title = mw.title.new(param)
else
return 'No TOC found'
end
text = title.getContent(title)
local lines_ = mw.text.split(text, "\n")
local lignes = {}
for i,v in ipairs(lines_) do
if string.sub(v, 1, 1) == "*" or string.sub(v, 1, 1) == "#" then
chapter = mw.text.trim(mw.ustring.gsub(v, "[ \*\#\[]*([^\|]*).*", "%1"))
if mw.title.new( chapter ).exists then
table.insert(lignes, frame:expandTemplate{ title = ':' .. chapter } .. '\n\n')
end
end
end
begining = frame:expandTemplate{title = "Print version notice"}
--ending = frame:expandTemplate{title = ""}
local list = begining .. table.concat(lignes, "\r\n") --.. ending
return list
end
return p