The function tries to edit the pgn data with regexes. It appears that:
some rules may break the PGN: 1, 2, 9, 13.
some look like for a specific need: 3.
some do not work, or I don't understand them: 5.
Next one adds a \n between ] and [, when separated by 0 to 10 (!) blank characters. *Should be simplified with `\s. This will break PGN if movetext section contains a line like{ [action "arg"]followed by a line like[action xxx]`.**
Set 2 newlines between between tags and movetext sections (when separated by 0 to 10 (!) blank characters. *Should be simplified with `\s. This will break PGN if we have a movetext section like:{ [%command "string"] 1.e4 }**
Add a space between ( and {. If parser if correct, this should not be needed.
$c = str_replace("({", "( {", $c);
Supposed to match { XXX[ YYY}. However, will only work if strlen(ZZZ) is zero or one, I don't see any reason for this to happen. It will fail also if comment is split between lines. The first [ is replaced by -SB-. Reverted in rule 11.
Sets two \n between non tag line and tag line. This will break PGN if [...] within a comment starts a line after a line ending with a dot or a digit. For example a line ending with { 1.e4 followed by a line like [%action ...]}.
Fixed with #5ca6c49.
To detect brackets within comments, I use PCRE negative lookahead, such as: \[(?!(?:{[^}]*}|[^}])*$).
See: this answer on startoverflow.
The function tries to edit the pgn data with regexes. It appears that:
\n
between]
and[
, when separated by 0 to 10 (!) blank characters. *Should be simplified with `\s. This will break PGN if movetext section contains a line like
{ [action "arg"]followed by a line like
[action xxx]`.**. This will break PGN if we have a movetext section like:
{ [%command "string"] 1.e4 }**[%emt
, but not other similar constructions, like[%clk
, etc... Should be removed(
and{
. If parser if correct, this should not be needed.{ XXX[ YYY}
. However, will only work ifstrlen(ZZZ)
is zero or one, I don't see any reason for this to happen. It will fail also if comment is split between lines. The first[
is replaced by-SB-
. Reverted in rule 11.[
. Why only one ?\n
between non tag line and tag line. This will break PGN if[...]
within a comment starts a line after a line ending with a dot or a digit. For example a line ending with{ 1.e4
followed by a line like[%action ...]}
.O
(the letter, not zeroes).[
. Will break PGN if first game has no tags.