Jump to content

Module:RemoveMiddleColumn

From Untitled Monster Game
Revision as of 14:12, 30 December 2025 by imported>Ziebster (Created page with "local p={} function p.slim(f) local t=f.args[1]or"" if t==""then return""end local l={} for s in t:gmatch("([^\n]*)\n?")do table.insert(l,s)end local r={} for _,s in ipairs(l)do local u=s:match("^%s*(.-)%s*$") if u:match("^%{%|")or u:match("^|%}")then table.insert(r,s) elseif u:match("^!")then local h={} local i=0 for v in u:gmatch("!%s*([^!|]+)")do i=i+1;if i~=2 then table.insert(h,"!"..v:gsub("%s+$",""))end end if#h>0 then table.insert(r," "..t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Example Usage:

{{Device Disambiguation|Example}}

local p={}

function p.slim(f)
 local t=f.args[1]or""
 if t==""then return""end
 local l={}
 for s in t:gmatch("([^\n]*)\n?")do table.insert(l,s)end
 local r={}
 for _,s in ipairs(l)do
  local u=s:match("^%s*(.-)%s*$")
  if u:match("^%{%|")or u:match("^|%}")then table.insert(r,s)
  elseif u:match("^!")then
   local h={}
   local i=0
   for v in u:gmatch("!%s*([^!|]+)")do i=i+1;if i~=2 then table.insert(h,"!"..v:gsub("%s+$",""))end end
   if#h>0 then table.insert(r," "..table.concat(h," !! "))end
  elseif u:match("^|%-")then table.insert(r,"|-")
  elseif u:match("^|")then
   local c={}
   local i=0
   for v in u:gmatch("|%s*([^|]+)")do i=i+1;if i~=2 then table.insert(c,"|"..v:gsub("%s+$",""))end end
   if#c>=2 then
    local b=table.concat(c," || ")
    b=b:gsub("^%s*||","|")
    table.insert(r,b)
   end
  end
 end
 return table.concat(r,"\n")
end

return p