Module:ChessBowserPrototype

local function build_notation_span(notation, plynum) local dnum = plynum and 'class="pgn-movelink" data-ply=' .. plynum or 'class="pgn-steplink"' return string.format(' %s ', dnum, notation) end

local function demo(frame) local pgn = frame.args.pgn if not pgn then error('no valid pgn found') end local parser = require('Module:Parse-pgn') local fens, plys, notations, metadata = parser.parsePgn(pgn) local passToScript = { fen = fens[1], plys = plys, }	local baseTemp = [[		 $notations          		 $rowLegends 		 $rowLegends 		 $fileLegends 		 $fileLegends

]]	local file_letters = { [0] = "a", [1] = "b", [2] = "c", [3] = "d", [4] = "e", [5] = "f", [6] = "g", [7] = "h" } local rowlegends, filelegends = ,  for r = 0 ,7 do rowlegends = rowlegends .. ' ' .. r + 1 .. ' '		filelegends = filelegends .. ' ' .. file_letters[r] .. ' '	end local notation_spans = { build_notation_span('⚃', 0) } for i, notation in ipairs(notations) do		if i % 2 == 1 then table.insert(notation_spans, build_notation_span((i + 1) / 2 .. '.'))		end table.insert(notation_spans, build_notation_span(notation, i)) end local result = string.gsub(baseTemp, '$passToScript', mw.text.jsonEncode(passToScript)) result = string.gsub(result, '$rowLegends', rowlegends) result = string.gsub(result, '$fileLegends', filelegends) result = string.gsub(result, '$notations', table.concat(notation_spans, ' ')) return result end

return { ['demo'] = demo, }