Module:Sandbox/Frietjes: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 8:
end
 
function p.cleanifexists(frame)
spage = frame.args[1]
if not page then return (frame.args['no'] or '') end
s = mw.ustring.gsub(s, '[Mm]etre', 'm')
if mw.title.new(page).exists then return (frame.args['yes'] or 'yes') end
s = mw.ustring.gsub(s, '([^a])meter', '%1m') -- prevents "parameter" from being changed to "param"
return (frame.args['no'] or '')
s = mw.ustring.gsub(s, '[Cc]enti', 'c') -- changes "centim" to "cm"
end
s = mw.ustring.gsub(s, 'ms', 'm')
s = mw.ustring.gsub(s, 'm[%.,]', 'm')
 
function p.lists(frame)
s = mw.ustring.gsub(s, '[Ff]eet', 'ft')
local s = mw'\n' .ustring.gsub (s,frame.args[1] or 'foot',) .. 'ft\n')
s = mw.ustring.gsub(s, 'ft([\r\n])%.,*([^\r\n]*)', 'ft%1<ul><li>%2</li></ul>')
s = mw.ustring.gsub(s, '([Mm\r\n]etre)#([^\r\n]*)', 'm%1<ol><li>%2</li></ol>')
 
s = mw.ustring.gsub(s, '</ol>%s*([Ii\r\n]nches*)<ol>', 'in%1')
s = mw.ustring.gsub(s, '</ul>%s*([Ii\r\n]nch*)<ul>', 'in%1')
s = mw.ustring.gsub(s, 'ins^[\r\n](.*)[\r\n]$', 'in%1')
s = mw.ustring.gsub(s, 'in[%.,]', 'in')
 
s = mw.ustring.gsub(s, '%[%[[Mm]%]%]s', '[[Metre|m]]')
s = mw.ustring.gsub(s, '%[%[[Cc]m%]%]s', '[[Centimetre|cm]]')
s = mw.ustring.gsub(s, '%[%[[Cc]entim|cm%]%]', '[[Centimetre|cm]]')
s = mw.ustring.gsub(s, '%[%[[Ii]n|in%]%]', '[[inch|in]]')
s = mw.ustring.gsub(s, '(%d)%s+(c?m)', '%1&nbsp;%2')
s = mw.ustring.gsub(s, '(%d)%s+(ft)', '%1&nbsp;%2')
s = mw.ustring.gsub(s, '(%d)%s+(in)', '%1&nbsp;%2')
return s
end
Line 74 ⟶ 62:
function p.hasOSM(frame)
return getBestStatement(mw.wikibase.getEntityIdForCurrentPage(), 'P402') and 'yes' or 'no'
end
 
function p.chart(frame)
local chart = require('Module:Chart')['bar-chart']
return chart(frame)
end