public function testCreate() { // simple code $md = 'my text with `some code` for test ...'; $this->assertEquals((string) MarkdownExtended::parse($md, array('template' => false)), 'my text with <code>some code</code> for test ...', '[parsing] test of code span'); // code blocks $md = <<<MSG para1 My code here para2 MSG; $this->assertEquals($this->stripWhitespaces((string) MarkdownExtended::parse($md, array('template' => false))), '<p>para1</p><pre>My code here</pre><p>para2</p>', '[parsing] test of code block'); // fenced code blocks $md = <<<MSG ~~~~ My code here ~~~~ MSG; $this->assertEquals($this->stripWhitespaces((string) MarkdownExtended::parse($md, array('template' => false))), '<pre>My code here </pre>', '[parsing] test of fenced code block'); // fenced code blocks with language $md = <<<MSG ~~~~html My code here ~~~~ MSG; $this->assertEquals($this->stripWhitespaces((string) MarkdownExtended::parse($md, array('template' => false))), '<pre class="language-html">My code here </pre>', '[parsing] test of fenced code block with language info'); }
/** * The abstract process method to be called whenever file needs to be handled by this pipe. * * @param $asset which should be processed by this pipe * @param array $options to be applied on asset * @param string describing errors during file location process * * @return string containing the processed file's content */ public function process($asset, $options = [], $errors = '') { $html = null; $file = $this->_assetDirectory . DIRECTORY_SEPARATOR . $asset; $html = \MarkdownExtended\MarkdownExtended::parse($file)->getContent(); return $html; }
public function testCreate() { // classic link $md = '[Composer](http://getcomposer.org/)'; $this->assertEquals((string) MarkdownExtended::parse($md, array('template' => false)), '<a href="http://getcomposer.org/" title="See online http://getcomposer.org/">Composer</a>', '[parsing] test of simple links'); // link with a title $md = '[Composer](http://getcomposer.org/ "My title")'; $this->assertEquals((string) MarkdownExtended::parse($md, array('template' => false)), '<a href="http://getcomposer.org/" title="My title">Composer</a>', '[parsing] test of links with title'); }
public function testCreate() { // autolink $md = '<http://getcomposer.org/>'; $this->assertEquals((string) MarkdownExtended::parse($md, array('template' => false)), '<a href="http://getcomposer.org/" title="See online http://getcomposer.org/">http://getcomposer.org/</a>', '[parsing] test of autolink'); // autolink email $md = '<*****@*****.**>'; $this->assertEquals((string) MarkdownExtended::parse($md, array('template' => false)), '<a href="mailto:piero.wbmstr@gmail.com" title="Contact piero.wbmstr@gmail.com">piero.wbmstr@gmail.com</a>', '[parsing] test of email autolink'); }
public function testCreate() { $md = <<<MSG This is a definition with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. MSG; $this->assertEquals($this->stripWhitespaceAndNewLines((string) MarkdownExtended::parse($md, array('template' => false))), '<p>This is a definition with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.</p><p>Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</p>', '[parsing] test of hard break'); }
public function testCreate() { $md = <<<MSG This is a definition with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. ![Alt text](http://upload.wikimedia.org/wikipedia/commons/7/70/Example.png 'Optional image title') Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. MSG; $this->assertEquals($this->stripWhitespaceAndNewLines((string) MarkdownExtended::parse($md, array('template' => false))), '<p>This is a definition with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. <img alt="Alt text" src="http://upload.wikimedia.org/wikipedia/commons/7/70/Example.png" title="Optional image title" /></p><p>Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</p>', '[parsing] test of image'); }
public function testCreate() { $md = <<<MSG Term 1 : This is a definition with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. : Second definition for term 1, also wrapped in a paragraph because of the blank line preceding it. MSG; $this->assertEquals($this->stripWhitespaceAndNewLines((string) MarkdownExtended::parse($md, array('template' => false))), '<dl><dt>Term 1</dt><dd><p>This is a definition with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.</p><p>Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</p></dd><dd><p>Second definition for term 1, also wrapped in a paragraph because of the blank line preceding it.</p></dd></dl>', '[parsing] test of definitions list'); }
public function testCreate() { // unordered list $md = <<<MSG - first item * second item - first sub-item * second sub-item - third item MSG; $this->assertEquals($this->stripWhitespaceAndNewLines((string) MarkdownExtended::parse($md, array('template' => false))), '<ul><li>first item</li><li>second item <ul><li>first sub-item</li><li>second sub-item</li></ul></li><li>third item</li></ul>', '[parsing] test of unordered list'); // ordered list $md = <<<MSG 1. first item 1. second item 1. first sub-item 2. second sub-item 5. third item MSG; $this->assertEquals($this->stripWhitespaceAndNewLines((string) MarkdownExtended::parse($md, array('template' => false))), '<ol><li>first item</li><li>second item <ol><li>first sub-item</li><li>second sub-item</li></ol></li><li>third item</li></ol>', '[parsing] test of ordered list'); }
public function testCreate() { $md = '#Hello World'; $this->assertEquals((string) MarkdownExtended::parse($md, array('template' => false)), '<h1 id="hello-world">Hello World</h1>', '[parsing] test of header'); }
public function testCreate() { $md = '**Hello** _World_'; $this->assertEquals((string) MarkdownExtended::parse($md, array('template' => false)), '<strong>Hello</strong> <em>World</em>', '[parsing] test of emphasis'); }
public function testCreate() { // simple table $md = <<<MSG | First Header | Second Header | | ------------- | ------------: | | Content Cell | Content Cell | | Content Cell | Content Cell | MSG; $this->assertEquals($this->stripWhitespaceAndNewLines((string) MarkdownExtended::parse($md, array('template' => false))), '<table><thead><tr><th>First Header</th><th style="text-align:right;">Second Header</th></tr></thead><tbody><tr><td>Content Cell</td><td style="text-align:right;">Content Cell</td></tr><tr><td>Content Cell</td><td style="text-align:right;">Content Cell</td></tr></tbody></table>', '[parsing] test of simple table'); // simple table with no leading pipe $md = <<<MSG First Header | Second Header | ------------- | ------------: | Content Cell | Content Cell | Content Cell | Content Cell | MSG; $this->assertEquals($this->stripWhitespaceAndNewLines((string) MarkdownExtended::parse($md, array('template' => false))), '<table><thead><tr><th>First Header</th><th style="text-align:right;">Second Header</th></tr></thead><tbody><tr><td>Content Cell</td><td style="text-align:right;">Content Cell</td></tr><tr><td>Content Cell</td><td style="text-align:right;">Content Cell</td></tr></tbody></table>', '[parsing] test of simple table with no leading pipe'); // simple table with not constant spacing $md = <<<MSG | First Header | Second Header | | ------------ | ------------: | | Cell | Cell | | Cell | Cell | MSG; $this->assertEquals($this->stripWhitespaceAndNewLines((string) MarkdownExtended::parse($md, array('template' => false))), '<table><thead><tr><th>First Header</th><th style="text-align:right;">Second Header</th></tr></thead><tbody><tr><td>Cell</td><td style="text-align:right;">Cell</td></tr><tr><td>Cell</td><td style="text-align:right;">Cell</td></tr></tbody></table>', '[parsing] test of simple table with not constant spaced cells'); // table with multiple headers and label before $md = <<<MSG [prototype *table*] | | Grouping || First Header | Second Header | Third header | First comment | Second comment | Third comment | ------------- | ------------: | :----------: | Content Cell | *Long Cell* || Content Cell | **Cell** | **Cell** | New section | More | Data | And more | And more || And more || And more | MSG; $this->assertEquals($this->stripWhitespaceAndNewLines((string) MarkdownExtended::parse($md, array('template' => false))), '<table><caption id="prototype-table">[prototype <em>table</em>]</caption><thead><tr><th></th><th style="text-align:right;" colspan="2">Grouping</th></tr><tr><th>First Header</th><th style="text-align:right;">Second Header</th><th style="text-align:center;">Third header</th></tr><tr><th>First comment</th><th style="text-align:right;">Second comment</th><th style="text-align:center;">Third comment</th></tr></thead><tbody><tr><td>Content Cell</td><td style="text-align:right;" colspan="2"><em>Long Cell</em></td></tr><tr><td>Content Cell</td><td style="text-align:right;"><strong>Cell</strong></td><td style="text-align:center;"><strong>Cell</strong></td></tr><tr><td>New section</td><td style="text-align:right;">More</td><td style="text-align:center;">Data</td></tr><tr><td>And more</td><td style="text-align:right;" colspan="2">And more</td></tr><tr><td colspan="2">And more</td><td style="text-align:center;">And more</td></tr></tbody></table>', '[parsing] test of complex table with multiple headers and a caption above'); // table with multiple headers and label after /*/ $md = <<<MSG | | Grouping || First Header | Second Header | Third header | First comment | Second comment | Third comment | ------------- | ------------: | :----------: | Content Cell | *Long Cell* || Content Cell | **Cell** | **Cell** | New section | More | Data | And more | And more || And more || And more | [prototype *table*] MSG; $this->assertEquals( $this->stripWhitespaceAndNewLines( (string) MarkdownExtended::parse($md, array('template'=>false)) ), '<table><caption id="prototype_table">[prototype <em>table</em>]</caption><thead><tr><th></th><th style="text-align:right;" colspan="2">Grouping</th></tr><tr><th>First Header</th><th style="text-align:right;">Second Header</th><th style="text-align:center;">Third header</th></tr><tr><th>First comment</th><th style="text-align:right;">Second comment</th><th style="text-align:center;">Third comment</th></tr></thead><tbody><tr><td>Content Cell</td><td style="text-align:right;" colspan="2"><em>Long Cell</em></td></tr><tr><td>Content Cell</td><td style="text-align:right;"><strong>Cell</strong></td><td style="text-align:center;"><strong>Cell</strong></td></tr><tr><td>New section</td><td style="text-align:right;">More</td><td style="text-align:center;">Data</td></tr><tr><td>And more</td><td style="text-align:right;" colspan="2">And more</td></tr><tr><td colspan="2">And more</td><td style="text-align:center;">And more</td></tr></tbody></table>', '[parsing] test of a complex table with multiple headers and a caption below' ); //*/ // table with multiple bodies /*/ $md = <<<MSG | | Grouping || First Header | Second Header | Third header | ------------- | ------------: | :----------: | Content Cell | *Long Cell* || Content Cell | **Cell** | **Cell** | New section | More | Data | MSG; $this->assertEquals( $this->stripWhitespaceAndNewLines( (string) MarkdownExtended::parse($md, array('template'=>false)) ), '<table><thead><tr><th></th><th style="text-align:right;" colspan="2">Grouping</th></tr><tr><th>First Header</th><th style="text-align:right;">Second Header</th><th style="text-align:center;">Third header</th></tr></thead><tbody><tr><td>Content Cell</td><td style="text-align:right;" colspan="2"><em>Long Cell</em></td></tr><tr><td>Content Cell</td><td style="text-align:right;"><strong>Cell</strong></td><td style="text-align:center;"><strong>Cell</strong></td></tr></tbody><tbody><tr><td>New section</td><td style="text-align:right;">More</td><td style="text-align:center;">Data</td></tr><tr><td>And more</td><td style="text-align:right;" colspan="2">And more</td></tr></tbody></table>', '[parsing] test of complex table with multiple bodies' ); //*/ }
public function testCreate() { $md = "\n> My citation\n>\n> With a paragraph and some `code`\n>\n> and even a preformatted string\n "; $this->assertEquals($this->stripWhitespaces((string) MarkdownExtended::parse($md, array('template' => false))), '<blockquote><p>My citation</p><p>With a paragraph and some <code>code</code></p><pre>and even a preformatted string</pre></blockquote>', '[parsing] test of blockquote'); }
public function testCreate() { $md = "\nA text whit HTML expression.\n\n*[HTML]: Hyper Text Markup Language\n "; $this->assertEquals((string) MarkdownExtended::parse($md, array('template' => false)), 'A text whit <abbr title="Hyper Text Markup Language">HTML</abbr> expression.', '[parsing] Test of abbreviation'); }