Content deleted Content added
No edit summary Tag: Reverted |
No edit summary |
||
(40 intermediate revisions by the same user not shown) | |||
Line 1:
local p = {}
local math_module = require("Module:Math")
local function rnd(num, digits)
-- This function implements {{rnd}}
return math_module._precision_format(tostring(num), digits)
end▼
if not page then return (frame.args['no'] or '') end
if mw.title.new(page).exists then return (frame.args['yes'] or 'yes') end
return (frame.args['no'] or '')
end▼
local s = '\n' .. (frame.args[1] or '') .. '\n'
s = mw.ustring.gsub(s, '([\r\n])%*([^\r\n]*)', '%1<ul><li>%2</li></ul>')
s = mw.ustring.gsub(s, '([\r\n])#([^\r\n]*)', '%1<ol><li>%2</li></ol>')
s = mw.ustring.gsub(s, '</ol>%s*([\r\n]*)<ol>', '%1')
s = mw.ustring.gsub(s, '</ul>%s*([\r\n]*)<ul>', '%1')
s = mw.ustring.gsub(s, '^[\r\n](.*)[\r\n]$', '%1')
function p.precision(frame)
return math_module._precision(frame.args[1])
function p.wpct(frame)
local w = tonumber(frame.args[1]) or 0
local l = tonumber(frame.args[2]) or 0
pct = rnd(w / (w + l), 3):gsub('^0', '')
end▼
function p.extractcolor(frame)
local str = frame.args[1] or ''
local color = mw.ustring.match(';' .. str .. ';', '.*;%s*([Cc][Oo][Ll][Oo][Rr]%s*:%s*.-)%s*;')
return color or 'NO MATCH'
local function getBestStatement(item_id, property_id)
Line 18 ⟶ 62:
function p.hasOSM(frame)
return getBestStatement(mw.wikibase.getEntityIdForCurrentPage(), 'P402') and 'yes' or 'no'
function p.chart(frame)
local chart = require('Module:Chart')['bar-chart']
return chart(frame)
end
Line 96 ⟶ 146:
return res
▲end
▲ {
▲function p._isValidHook(hook)
▲ local found = false
▲ end
▲ end
▲ end
▲ end
▲ return true
▲end
▲function p.isValidHook(frame)
▲ local hook = frame.args[1]
▲ if not hook then
▲ end
▲ return ""
▲ end
end
|