maplefu0602 / spyc

Automatically exported from code.google.com/p/spyc
MIT License
0 stars 0 forks source link

Supporting > and >- #48

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
content: >
  this
  is
  content
other: >-
  this
  is
  also
  content

What is the expected output? What do you see instead?
array('content' => "this is content\n", 'other' => 'this is also content')

instead:
array('content' => "this is content", 'other' => array('this'), array('is'), 
array('also'), array('content'))

What version of the product are you using? On what operating system?
0.5.0

Please provide any additional information below.
--- .../spyc-0.5/spyc.php   2011-06-02 17:16:54.000000000 -0600
+++ .../spyc/Spyc.class.php 2011-06-07 16:29:32.000000000 -0600
@@ -423,13 +423,14 @@

       $literalBlockStyle = self::startsLiteralBlock($line);
       if ($literalBlockStyle) {
-        $line = rtrim ($line, $literalBlockStyle . " \n");
+        $line = rtrim ($line, $literalBlockStyle . " \t\n");
         $literalBlock = '';
         $line .= $this->LiteralPlaceHolder;
         $literal_block_indent = strlen($Source[$i+1]) - strlen(ltrim($Source[$i+1]));
         while (++$i < $cnt && $this->literalBlockContinues($Source[$i], $this->indent)) {
           $literalBlock = $this->addLiteralLine($literalBlock, $Source[$i], $literalBlockStyle, $literal_block_indent);
         }
+        if ( $literalBlockStyle == '>' )  $literalBlockStyle .= "\n";
         $i--;
       }

@@ -822,6 +824,9 @@
   }

   private static function startsLiteralBlock ($line) {
+    $lastChar = substr (trim($line), -2);
+    if ( $lastChar == '>-' )  return $lastChar;
+    
     $lastChar = substr (trim($line), -1);
     if ($lastChar != '>' && $lastChar != '|') return false;
     if ($lastChar == '|') return $lastChar;

Original issue reported on code.google.com by coli...@gmail.com on 7 Jun 2011 at 10:44