A modult a Modul:0ugly hacks/doc lapon tudod dokumentálni
local export = {}
function export.explode(frame)
local wanted_index = tonumber(frame.args)
local count = 1
for item in mw.text.gsplit(frame.args, frame.args, true) do
if count == wanted_index then
return item
end
count = count + 1
end
return ""
end
function export.substr(frame)
return mw.ustring.sub(frame.args or "", tonumber(frame.args) or 1, tonumber(frame.args) or -1)
end
function export.find(frame)
return mw.ustring.find(frame.args or "", frame.args or "", 1, true) or ""
end
function export.find_pattern(frame)
return mw.ustring.find(frame.args or "", frame.args or "", 1, false) or ""
end
function export.replace(frame)
return (mw.ustring.gsub(frame.args or "", frame.args or "", frame.args or ""))
end
function export.match(frame)
return (mw.ustring.match(frame.args or "", frame.args or ""))
end
function export.escape_wiki(frame)
return mw.text.nowiki(frame.args or "")
end
function export.escape_html(frame)
return mw.text.encode(frame.args or "")
end
function export.zeropad(frame)
if #frame.args >= tonumber(frame.args) then
return frame.args
else
return mw.ustring.sub(string.rep("0", frame.args) .. (frame.args or ""), -frame.args)
end
end
function export.is_valid_page_name(frame)
return mw.title.new(frame.args) and "valid" or ""
end
return setmetatable({ }, {
__index = function(self, key)
local m_debug = require('Module:0debug')
local frame = mw.getCurrentFrame()
local pframe = frame:getParent()
local tname = pframe and pframe:getTitle()
m_debug.track('ugly hacks/' .. key)
if pframe then
m_debug.track('ugly hacks/' .. key .. '/from ' .. tname)
else
mw.log(debug.traceback('ugly hacks: parent frame not available'))
end
return export
end
})