Jump to content

Module:HexCode

From Keynotathlon Wiki

Documentation for this module may be created at Module:HexCode/doc

p={}
function p.hex(frame)
  local s=string.gsub(tostring(frame.args[1]),"#","#")
  local r=frame.args[2]~=nil and frame.args[2] or "#"
  local h=string.find(s,"#")~=nil
  
  if string.sub(s,1,1)=="#" then
  	s=string.sub(s,2,#s)
  end
  
  local rs=s
  if #s==3 or #s==4 then
  	rs=""
  	for i=1,#s do
		rs=rs..string.rep(string.sub(s,i,i),2)
	end
  end
  return (h and r or "")..string.upper(rs)
end
return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.