View source for Module:Type in location
Appearance
You do not have permission to edit this page, for the following reason:
You can view and copy the source of this page.
local p = {}
local plaintext = require("Module:Plain text")._main
local language = mw.language.getContentLanguage()
--Cleanup/format location for use in short descriptions
function p.prepareLoc (frame)
return p._prepareLoc (frame.args[1])
end
function p._prepareLoc (text)
text = plaintext(text)
text = text..',' --comma at the end makes things convenient
text = mw.ustring.gsub(text,'%b()', ', ') --remove things in brackets as extraneous information
text = mw.ustring.gsub(text,'[^%s,]*%d[^%s,]*', '') --remove things with digits as generally being unnecessary postal codes/road numbers etc
text = mw.ustring.gsub(text,'(,%s-),', '%1') --fix possible blank separated commas from previous cleanup
text = mw.ustring.gsub(text,'%s%s', ' ') --fix possible extra spaces from previous cleanup
text = mw.ustring.gsub(text,'^[%s,]*', '') --trim commas and spaces from beginning
text = mw.ustring.gsub(text,'[%s,]*$', '') --trim commas and spaces from end
return text
end
--Gets general location from more specific one for short descriptions
000
1:0
Template used on this page:
Return to Module:Type in location.