Modul:Parse
Vzhled
local p = {}
function p.horizontalList(context)
local string_to_parse = context.args[1]
local parsed_table = {}
local references_table = {}
for substring in string.gmatch(string_to_parse, string.char(0x7F) .. ".-" .. string.char(0x7F)) do
references_table[substring] = true
end
for substring in string.gmatch(string_to_parse, "(%l+)[, " .. string.char(0x7F) .. "]+") do
parsed_table[substring] = true
end
for substring in string.gmatch(string_to_parse, "(%l+)$") do
parsed_table[substring] = true
end
parsed_table['a'] = nil
local result = {}
context.args[1] = nil
local unified_param = context.args[2]
local pos = 1
if unified_param == nil then
for arg, _ in pairs(parsed_table) do
pos, _ = string.find(string_to_parse, arg, 1, true)
if context.args[arg] ~= nil then
table.insert(result, pos, context.args[arg])
else
table.insert(result, pos, arg)
end
end
else
for arg, _ in pairs(parsed_table) do
pos, _ = string.find(string_to_parse, arg, 1, true)
table.insert(result, pos, string.gsub(unified_param, '%(hodnota%)', arg))
end
end
for ref, _ in pairs(references_table) do
pos, _ = string.find(string_to_parse, ref, 1, true)
table.insert(result, pos, ref)
end
return result
end
return p