Skip to content

Commit

Permalink
Fixed issue 30 (ampersands)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad.andersen committed May 31, 2010
1 parent 2da278b commit d672cb8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spyc.php
Expand Up @@ -303,7 +303,8 @@ private function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key
// do some folding here, for blocks
if (is_string ($value) && ((strpos($value,"\n") !== false || strpos($value,": ") !== false || strpos($value,"- ") !== false ||
strpos($value,"*") !== false || strpos($value,"#") !== false || strpos($value,"<") !== false || strpos($value,">") !== false || strpos ($value, ' ') !== false ||
strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || substr ($value, -1, 1) == ':')
strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || strpos($value,"&") !== false ||
substr ($value, -1, 1) == ':')
) {
$value = $this->_doLiteralBlock($value,$indent);
} else {
Expand Down
5 changes: 5 additions & 0 deletions tests/DumpTest.php
Expand Up @@ -48,6 +48,11 @@ public function testDumpAsterisks() {
$this->assertEquals ($awaiting, $dump);
}

public function testDumpAmpersands() {
$dump = Spyc::YAMLDump(array ('some' => '&foo'));
$awaiting = "---\nsome: '&foo'\n";
$this->assertEquals ($awaiting, $dump);
}

public function testDumpNumericHashes() {
$dump = Spyc::YAMLDump(array ("titel"=> array("0" => "", 1 => "Dr.", 5 => "Prof.", 6 => "Prof. Dr.")));
Expand Down

0 comments on commit d672cb8

Please sign in to comment.