Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/MarioGom/Multiple issues
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 state_initial = 1 local state_first_open_brace = 2 local state_first_closing_brace = 3 local c_open_brace = string.byte("{") local c_close_brace = string.byte("}") function p.number_of_templates(content) if content == nil then mw.log("content is nil") return 0 end local state = state_initial local count = 0 local level = 0 for i = 1, #content do local c = content:byte(i) if state == state_initial then if c == c_open_brace then state = state_first_open_brace elseif c == c_close_brace then state = state_first_closing_brace end elseif state == state_first_open_brace then if c == c_open_brace then state = state_initial level = level + 1 else state = state_initial end elseif state == state_first_closing_brace then if c == c_close_brace then level = level - 1 if level == 0 then count = count + 1 end end state = state_initial end end return count end function p.multiple_issues(frame) local frame = mw.getCurrentFrame() local first = frame.args[1] local second = frame.args[2] if p.number_of_templates(first) > 1 then return second end return first 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/MarioGom/Multiple issues/doc
(
edit
)