Module:Sandbox/Evad37/X1: Difference between revisions

Content deleted Content added
.
put coords into mapframe map
Line 1:
-- This module is a sandbox. It is also used for testing XFDcloser
local getArgs = require('Module:Arguments').getArgs
local transclude = require("Module:Transclude")
local mapframe = require("Module:Mapframe")
 
local p = {}
Line 10 ⟶ 13:
 
p.getCoords = function(frame)
local args = getArgs(frame, {parentFirst = true})
local parent = frame:getParent()
local title = args.article and mw.title.new(args.article) or mw.title.getCurrentTitle()
local content = frame:preprocess(title:getContent())
args.section and transclude.getSection(content, args.section) or title:getContent()
)
local coords = {}
for coordgeo in mw.ustring.gmatch(content, "<span class=\"geo%-default\">(.-)%)</span></span></span>%]</span>") do
local coord = mw.ustring.match(geo, "<span class=\"geo%-dec\">(.-)</span>")
table.insert(coords, coord)
if coord then
coord = mw.ustring.gsub(coord, "[° ]", "_")
end
local name = mw.ustring.match(geo, "<span class=\"fn org\">(.-)</span>")
coords[coord] = name
end
local mapframeArgs = {
return table.concat( coords, "\n\n")
display = "inline",
frame = yes
}
local count = 1
for coord, name in pairs(coords) do
mapframeArgs["type"..count] = coord
mapframeArgs["title"..count] = name
end
local map = mapframe._main(mapframeArgs)
return frame:preprocess(map)
end