Benutzer:Antonsusi/Spielwiese/Modul:Test
aus Wikipedia, der freien Enzyklopädie
--[=[
{{#invoke:Test|readpage|Seite=Benutzer:Antonsusi/Spielwiese/Testeingabe}}
Aufruf
-- ]=]
--
local function split_newlines(s,nobreak) local ts = {} local posa = 1 while 1 do local pos, chars = s:match('()([\r\n].?)', posa) if pos then if chars == '\r\n' then pos = pos + 1 end local line = s:sub(posa, pos) if nobreak then line = line:sub(1,#line - 1) end ts[#ts+1] = line posa = pos + 1 else local line = s:sub(posa) if line ~= '' then ts[#ts+1] = line end break end end return ts end local function splitaline(s,sign) local a, b, sleft ,sright; a, b = s:find(sign) if a then sleft = s:sub(1,a-1); sright= s:sub(a+1); else sleft = s; sright=''; end return sleft, sright; end local p = {} function p.readpage(frame) local tbl = {}; local pagename =frame.args['Seite']; local page = mw.title.new(pagename); local Ergebnis=''; local text = page:getContent(); text = text:gsub('<onlyinclude>',''); text = text:gsub('</onlyinclude>',''); tbl = split_newlines(text,true); for i,v in ipairs(tbl) do if (#v > 2) then val_left, val_right = splitaline(v,"=") if val_left == val_right or val_right=="" then data = "[[" .. val_left .. "]]"; else data = "[[" .. val_left .."|" .. val_right .."]]"; end Ergebnis = Ergebnis .. data .. ", "; end end Ergebnis = Ergebnis .. "\n"; return Ergebnis; end return p --