Ejemplo n.º 1
0
 /**
  * @param Text $text
  */
 public function buildParagraph(Text $text)
 {
     $parts = $text->replace('/\\A\\n+/', '')->replace('/\\n+\\z/', '')->split('/\\n{2,}/', PREG_SPLIT_NO_EMPTY);
     $parts->apply(function (Text $part) {
         if (!$this->markdown->getHashRegistry()->exists($part)) {
             $this->markdown->emit('inline', array($part));
             $part->replace('/^([ \\t]*)/', '');
             $part->setString($this->getRenderer()->renderParagraph((string) $part));
         }
         return $part;
     });
     $parts->apply(function (Text $part) {
         if ($this->markdown->getHashRegistry()->exists($part)) {
             $part->setString(trim($this->markdown->getHashRegistry()->get($part)));
         }
         return $part;
     });
     $text->setString($parts->join("\n\n"));
 }
Ejemplo n.º 2
0
 /**
  * @param Text $text
  */
 public function unhashHtmlBlocks(Text $text)
 {
     foreach ($this->markdown->getHashRegistry() as $hash => $html) {
         $text->replaceString($hash, trim($html));
     }
 }