Přeskočit na obsah

Modul:Parse

Tato stránka je zamčena
Z Wikipedie, otevřené encyklopedie
(rozdíl) ← Starší revize | zobrazit aktuální verzi (rozdíl) | Novější revize → (rozdíl)

local p = {}

function p.horizontalList(context)
  local string_to_parse = context.args[1]
  local parsed_table = {}
  for substring in string.gmatch(string_to_parse, "(%w+)[, ]+") do
    parsed_table[substring] = true
  end
  for substring in string.gmatch(string_to_parse, "(%w+)$") do
    parsed_table[substring] = true
  end
  parsed_table['a'] = nil

  local result = ''
  context.args[1] = nil
  local unified_param = context.args[2]
  if unified_param == nil then
    for arg, _ in pairs(parsed_table) do
      if context.args[arg] ~= nil then
        result = result .. context.args[arg]
      else
        result = result .. arg
      end
    end
  else
    for arg, _ in pairs(parsed_table) do
      result = result .. string.gsub(unified_param, '%(hodnota%)', arg)
    end
  end
  return result
end

return p