Module:Ordnance Survey coordinates/sandbox: Difference between revisions

Content deleted Content added
misc cleanup
more cleanup
Line 56:
local e = mw.ustring.sub(num,1,pr)
-- Hack to move to center of square: append a 5 to northings and eastings
if shift ~= nil and yesno(shift > 0 then)
if shift then
n = n.."5"
e = e.."5"
Line 274 ⟶ 275:
 
local function empty(s)
return not s == nil or s == ''
end
 
Line 281 ⟶ 282:
ngr, _ = mw.ustring.gsub(mw.ustring.upper(ngr),"[%s%p]","")
local first, last, lett, num = mw.ustring.find(ngr,"^([A-Z]+)(%d+)$")
if not first == nil or empty(lett) or empty(num) or mw.ustring.len(lett) > 2 then
return {err="Malformed NGR"}
end
Line 307 ⟶ 308:
 
local function alldigits(s)
return not mw.ustring.find(s,"%D") == nil
end
 
Line 315 ⟶ 316:
local html = preview._warning({ msg })
 
if namespace == 0 and errmsg ~= nil then
html = html..'[[Category:Pages with malformed OS coordinates]]'
end