Skip to content

Commit

Permalink
Merge pull request #13 from localheinz/fix/continue
Browse files Browse the repository at this point in the history
Fix: Continue after handling colon
  • Loading branch information
localheinz authored Jan 5, 2018
2 parents 475383c + dcd8374 commit ad702b6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,18 @@ public function print(string $original, bool $unEscapeUnicode, bool $unEscapeSla
* Ensure space after ":" character.
*/
if (':' === $character) {
$character .= ' ';
} elseif ('}' === $character || ']' === $character) {
$printed .= ': ';

continue;
}

/**
* Output a new line and indent the next line if the current character indicates the end of an element.
*/
if ('}' === $character || ']' === $character) {
--$indentLevel;
$previousCharacter = \substr($original, $i - 1, 1);

/**
* Output a new line and indent the next line if the current character indicates the end of an element.
*/
if ('{' !== $previousCharacter && '[' !== $previousCharacter) {
$printed .= $newLine;

Expand Down

0 comments on commit ad702b6

Please sign in to comment.