Deze module is nog in ontwikkeling (versie 0.0) en wordt getest.
De Module:Layout is bedoeld om snel, consistent en uitgebreid een pagina op te maken.
Er is een op de module afgestemde handleiding over deze onderwijswiki beschikbaar.
localextract={};functionextract.book_progress(book,call)localnew_book={};new_book.text=book;new_book.progress="0";ifbookandbook~=""thenbook=mw.text.trim(book)localformatted_book=book:gsub(" "," ")localwiki_book=mw.title.new(book)ifwiki_bookthenlocalprogress_parameters=extract.parameter(wiki_book:getContent(),call.message.TEMPLATENAME,call.message.PROGRESS.NAME,call)ifprogress_parameters[1]thennew_book.progress=progress_parameters[1]:gsub("^%s*(.-)%s*$","%1");endendnew_book.text=mw.ustring.format('[[%s|%s]]',book,formatted_book);endreturnnew_book;end-- This function extracts the content of the page with the titlename.functionextract.content(call)localtext=call.include("text");ifnottext.valid(call.source)thenreturnnil;endlocaltitle=mw.title.new(call.source);if(title==nilortitle=='')thenreturnnil;endreturntitle:getContent();end-- This function extracts the level two headings out of the wikitext with the position as the key.functionextract.heading(wikitext,call)localtext=call.include("text");ifnottext.valid(wikitext)thenreturn{};endlocallines=mw.text.split(wikitext,'\n');localheadings={};for_,lineinipairs(lines)do-- Check if the beginning of the line is ==.if(line:match('^==')andnotline:match('^==='))thenline=mw.text.trim(line,"\t\r\n\f ");-- Check if the end of the line is also == and there are no = in between.ifstring.sub(line,-2)=='=='andnotstring.find(string.sub(line,3,-3),"=")thenline=line:gsub("=","");line=mw.text.trim(line,"\t\r\n\f ");table.insert(headings,line);endendendreturnheadings;end-- This functions get's the parameters of a template with the position as the key.functionextract.parameter(wikitext,templatename,parametername,call)-- :tablelocaltext=call.include("text");ifnottext.valid(wikitext)thenreturn{};endifnottext.valid(templatename)thenreturn{};endifparameternameandnottext.valid(parametername)thenreturn{};endlocaltemplate=extract.template(wikitext,templatename,call);localresult={};fori,sub_tableinipairs(template)dofork,vinpairs(sub_table)doif(parameternameandk==parametername)or(notparameternameandtype(k)=="number"andk>0)thentable.insert(result,v);endendendreturnresult;end-- This function returns all templates of the given template_name out in the given wikitext in a table with the position (first, second) number as the key.functionextract.template(wikitext,template_name,call)-- :table localtext,pattern,convert=call.include("text","pattern","convert");ifnottext.valid(wikitext)thenreturn{};endifnottext.valid(template_name)thenreturn{};endlocaltemplates={};locali=1;-- start index-- Find all templates in the wikitext by fist looking at matching brackets by the pattern '%b{}'.-- Not all machting brackets are templates or if so the template we are looking for.-- If the matsching brackets look like {{template_name}} or {{template+name|}} etcetera, which we catch with the '^{{' .. template_name .. '[^}]*}}$' pattern, we've got the template.wikitext=wikitext:gsub('%b{}',function(matching_brackets)-- Check if the template is the one we're interested in-- if matching_brackets:match('^{{' .. template_name .. '[^}]*}}$') ifpattern.template_definition_at_start_and_end(matching_brackets,template_name)then-- Add the template table to the listtemplates[i]=convert.template_to_table(matching_brackets,template_name,call);i=i+1;end-- Return an empty string to replace the matching_brackets in the wikitextreturn"";end);returntemplates;endreturnextract;