function testParsingMarkdown()
 {
     $text = "**A test**\n\nAnd a new paragraph.";
     $expected = "<p><strong>A test</strong></p><p>And a new paragraph.</p>";
     $parser = new MarkdownParser($text);
     // we ignore wrapping whitespace and newlines
     $result = trim(str_replace("\n", '', $parser->parse()));
     $this->assertEquals($result, $expected, 'Translation markdown to HTML.');
 }
 /**
  * Return Markdown content as HTML
  * @return string HTML
  */
 public function MarkdownAsHTML()
 {
     $parser = new MarkdownParser($this->value);
     return $parser->parse();
 }
 /**
  * Parse markdown into html
  * @return string html
  */
 public function parse()
 {
     $parser = new MarkdownParser($this->request['markdown']);
     return $this->enable_extra ? $parser->parseExtra() : $parser->parse();
 }
 /**
  * Integration-esque tests ensuring that markdown is correctly parsed to HTML
  *
  * @dataProvider markdownProvider
  *
  * @param string $markdown
  * @param string $expected
  */
 public function testParseMarkdown($markdown, $expected)
 {
     $parser = new MarkdownParser($markdown);
     $result = $parser->parse($parser);
     $this->assertSame($expected, $result);
 }
Exemple #5
0
 /**
  * Processes a text string.
  * This method is required by the parent class.
  * @param string text string to be processed
  * @return string the processed text result
  */
 public function processText($text)
 {
     $renderer = new MarkdownParser();
     $result = $renderer->parse($text);
     return preg_replace_callback('/<pre><code>\\[\\s*(\\w+)\\s*\\]\\n+((.|\\n)*?)\\s*<\\/code><\\/pre>/im', array($this, 'highlightCode'), $result);
 }