Module:OnshokoeseScript: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local p = {} | local p = {} | ||
function p. | local CharData = mw.loadData( 'Module:OnshokoeseScript/data' ) | ||
function p._onshokoese( humanwords, size ) | |||
end - | local output_string = {} | ||
local humanwords = string.lower(humanwords) | |||
local span = mw.html.create( 'span' ) | |||
if (size == nil or size == '') then size='14' end | |||
local i=1 | |||
local j=string.len(humanwords) | |||
while (i <= j) do | |||
local replacement = CharData[humanwords:sub(i,i + 2)] | |||
if replacement ~= nil then | |||
table.insert(output_string,'[[File:'..replacement..'|x'..size..'px|link=]]') | |||
i = i + 3 | |||
else | |||
local replacement = CharData[humanwords:sub(i,i + 1)] | |||
if replacement ~= nil then | |||
table.insert(output_string,'[[File:'..replacement..'|x'..size..'px|link=]]') | |||
i = i + 2 | |||
else | |||
local replacement = CharData[humanwords:sub(i,i)] | |||
if replacement ~= nil then | |||
table.insert(output_string,'[[File:'..replacement..'|x'..size..'px|link=]]') | |||
i = i + 1 | |||
else | |||
table.insert(output_string,' ') | |||
i = i + 1 | |||
end | |||
end | |||
end | |||
end | |||
span :css( 'font-size', size..'px' ) | |||
:wikitext( table.concat(output_string) ) | |||
return tostring(span) | |||
end | |||
function p.main(frame) | |||
local string_input = frame.args[1] | |||
local num_input = frame.args[2] | |||
return p._onshokoese(string_input, num_input) | |||
end | |||
function p._main(args) | function p._main(args) | ||
local first = args[1] or '' | local first = args[1] or '' | ||
return first | local second = args[2] or '' | ||
return first .. ' ' .. second | |||
end | end | ||
return p | return p |
Latest revision as of 22:59, 25 April 2024
Documentation for this module may be created at Module:OnshokoeseScript/doc
local getArgs = require('Module:Arguments').getArgs
local p = {}
local CharData = mw.loadData( 'Module:OnshokoeseScript/data' )
function p._onshokoese( humanwords, size )
local output_string = {}
local humanwords = string.lower(humanwords)
local span = mw.html.create( 'span' )
if (size == nil or size == '') then size='14' end
local i=1
local j=string.len(humanwords)
while (i <= j) do
local replacement = CharData[humanwords:sub(i,i + 2)]
if replacement ~= nil then
table.insert(output_string,'[[File:'..replacement..'|x'..size..'px|link=]]')
i = i + 3
else
local replacement = CharData[humanwords:sub(i,i + 1)]
if replacement ~= nil then
table.insert(output_string,'[[File:'..replacement..'|x'..size..'px|link=]]')
i = i + 2
else
local replacement = CharData[humanwords:sub(i,i)]
if replacement ~= nil then
table.insert(output_string,'[[File:'..replacement..'|x'..size..'px|link=]]')
i = i + 1
else
table.insert(output_string,' ')
i = i + 1
end
end
end
end
span :css( 'font-size', size..'px' )
:wikitext( table.concat(output_string) )
return tostring(span)
end
function p.main(frame)
local string_input = frame.args[1]
local num_input = frame.args[2]
return p._onshokoese(string_input, num_input)
end
function p._main(args)
local first = args[1] or ''
local second = args[2] or ''
return first .. ' ' .. second
end
return p