From 2b1e3e0f04419d5deab5ffe06b1cf01a7975854c Mon Sep 17 00:00:00 2001 From: DHTMLGoodies Date: Wed, 1 Mar 2017 19:51:08 +0100 Subject: [PATCH] Added support for one line pgn --- PgnParser.php | 1 + test/ParserTest.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/PgnParser.php b/PgnParser.php index 401bf9e..7130c8e 100755 --- a/PgnParser.php +++ b/PgnParser.php @@ -66,6 +66,7 @@ class PgnParser $c = $this->pgnContent; $c = preg_replace('/"\]\s{0,10}\[/s', "]\n[", $c); + $c = preg_replace('/"\]\s{0,10}([\.0-9])/s', "\"]\n\n$1", $c); $c = preg_replace("/{\s{0,6}\[%emt[^\}]*?\}/","",$c); diff --git a/test/ParserTest.php b/test/ParserTest.php index a83f507..cdc4640 100755 --- a/test/ParserTest.php +++ b/test/ParserTest.php @@ -2184,6 +2184,8 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1'; $this->assertEquals($expected["site"], $game["site"]); $this->assertEquals($expected["black"], $game["black"]); + $moves = count($expected["moves"]); + $this->assertCount($moves, $game["moves"]); } } @@ -2212,7 +2214,11 @@ Rc8 Ne6+ 72. Kf6 d2 73. c5+ Kd7 0-1'; $this->assertEquals($expected["site"], $game["site"]); $this->assertEquals($expected["black"], $game["black"]); + $moves = count($expected["moves"]); + $this->assertCount($moves, $game["moves"]); } + echo json_encode($games2[0]); + } }