Documentation icon دستاویز [تخلیق]
local p = {}

require "mw.ustring"

function p.remove_parents( frame )
     str = frame.args.string
     gsub = mw.ustring.gsub
     
     str=gsub(str, " *[(].*[)]","")
     return str
     
end

function p.only_parents_contents( frame )
     str = frame.args.string
     match = mw.ustring.match
     gsub = mw.ustring.gsub
     
     str=p.remove_sq_parents_internal(str)
     str=match(str, "%b()$") -- a(b) ==> (b) or nil
     if (str == nil) then return "" end

     str=gsub(str,"^%((.*)%)$", "%1") -- (b) ==> b
     return str
     
end

function p.remove_sq_parents_internal( str )
     gsub = mw.ustring.gsub
     
     str=gsub(str, "^%[%[(.*)%|.*%]%]$","%1") -- [[x|y]] ==> x
     str=gsub(str, "^%[%[(.*)%]%]$","%1") -- [[x]] ==> x
     return str
     
end

function p.remove_sq_parents( frame )
     str = frame.args.string
     return p.remove_sq_parents_internal(str)
     
end
 
return p