Content deleted Content added
Fix Linter errors. I assume that this works; I am not a Lua programmer Tag: Reverted |
Slight logic simplification ("if a then else" to "if not a then") |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 110:
if ( letters_bt ) then b = b .. letters_row(rev, numbers_lt, numbers_rt, cols) .. '\n' end
if not footer:match('^%s*$') then
caption = '<div class="thumbcaption">' .. footer .. '</div>\n'
end
b = '<table cellpadding=0 cellspacing=0 class="center noviewer" style="line-height: 0; background:white; font-size:88%; border:1px #c8ccd1 solid;'
.. 'padding:0; margin:auto">\n' .. b .. '\n</table>'
Line 122 ⟶ 120:
else
return '<div class="thumb ' .. align .. '">'
.. '
.. b .. '\n' .. caption .. '</div></div>'
end
Line 133 ⟶ 131:
-- Loop over rows, which are delimited by /
for srow in string.gmatch("/" .. fen, "/%w+") do
srow = srow:gsub("/","") -- clean up row
-- Loop over all letters and numbers in the row
-- Since Lua regexes do not have the | operator, we have
for piece in srow:gmatch( "%w" ) do▼
-- to spell things
local index =
local piece = "" -- Piece can also
local place = 0
local pstart = 0
local pend = 0
local length = srow:len()
while index <= length do
-- Look for a number. Can have multiple digits
pstart, pend = srow:find("%d+", index)
if pstart == index then
index = pend + 1
for k=1,tonumber(piece) do
table.insert(res,' ')
end
else
-- If number not found, look for a
index = pstart + 1
-- l: White (light); d: Black (dark)
local color = piece:match( '%u' ) and 'l' or 'd'
piece = piece:lower()
table.insert(res, piece .. color)
else
index = length + 1 -- Break loop
end
end
end
end
return res
end
|