Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Sameboat/m3
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local function pre_block(text) -- Pre tags returned by a module do not act like wikitext <pre>...</pre>. return '<pre>' .. mw.text.nowiki(text) .. (text:sub(-1) == '\n' and '' or '\n') .. '</pre>\n' end function p.trimmer(frame) -- Trims first and last empty icon cell of each row. local org = mw.text.unstripNoWiki(frame.args[1]) or 'Paste Routemap RDT markups between the nowiki tags' local res = org local restable = {} for i, v in ipairs(mw.text.split(res, '\n')) do v = mw.text.split(v, '\\') for _ in ipairs(v) do if v[1] == '' and v[table.maxn(v)] == '' then table.remove(v, 1) table.remove(v, table.maxn(v)) end restable.row = table.concat(v, '\\') end table.insert(restable, restable.row) end --return table.concat(restable, '\n') return "\n'''Trimmed''':\n" .. pre_block(table.concat(restable, '\n')) .. "'''''Before trimming''''':\n" .. pre_block(org) --return table.maxn(mw.text.split([[1\2\3\4\5]], '\\')) --return table.concat(mw.text.split(mw.text.trim(org), '\\'), '\\') --return table.concat(mw.text.split([[\\\STR\STR\\]], '\\'), '\\') end function p.trimmer2(frame) -- Trims first and last empty icon cell of each row. local org = mw.text.unstripNoWiki(frame.args[1]) or 'Paste Routemap RDT markups between the nowiki tags' local res = org local restable = {} for i, v in ipairs(mw.text.split(res, '\n')) do v = mw.text.split(v, '! !') for i2, v2 in ipairs(v) do v2 = mw.text.split(v2, '~~') for i3, v3 in ipairs(v) do v3 = mw.text.split(v3, '\\') for _ in ipairs(v3) do if v3[1] == '' and v[table.maxn(v3)] == '' then table.remove(v3, 1) table.remove(v3, table.maxn(v3)) end restable.icon = table.concat(v3, '\\') end restable.right = {} table.insert(restable.right, restable.icon) restable.right2 = table.concat(restable.right, '~~') end restable.left = {} table.insert(restable.left, restable.right2) restable.left2 = table.concat(restable.left, '! !') end restable.row = {} table.insert(restable.row, restable.left2) end return "\n'''Trimmed''':\n" .. pre_block(table.concat(restable.row, '\n')) .. "'''''Before trimming''''':\n" .. pre_block(org) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Sameboat/m3/doc
(
edit
)