/**
  * Encodes the content into HTML based on Markdown
  *
  * @return  void
  */
 protected function _cache_content()
 {
     $this->cached_content = Markdown::encode($this->content);
     if (preg_match_all('/<p>(.*)<\\/p>/', $this->cached_content, $matches)) {
         $this->description = substr(strip_tags($matches[1][0]), 0, 500);
     }
 }
Example #2
0
 /**
  * 
  * Encodes special Markdown characters to they are not parsed by
  * plugins.
  * 
  * @param string $text Source text.
  * 
  * @param bool $only_backslash Only encode backslashed characters.
  * 
  * @return string The encoded text.
  * 
  */
 protected function _encode($text, $only_backslash = false)
 {
     return $this->_markdown->encode($text, $only_backslash);
 }
Example #3
0
 public function testEncoding()
 {
     $formatter = new Markdown();
     $data = array('name' => 'Joe', 'age' => 21, 'employed' => true, 'body' => "Lorem ipsum dolor\nsit amet");
     $this->assertSame(file_get_contents(__DIR__ . '/fixtures/joe.md'), $formatter->encode($data));
 }