@@ -219,16 +219,35 @@ public function parse_string( $source_code, $vars = array() )
219219 *
220220 * @return string
221221 */
222- public function parse_markdown ( $ source_code )
222+ public function parse_markdown ( $ source_code, $ flavour = ' default ' )
223223 {
224224 if ( ! class_exists ( 'Parsedown ' ) )
225225 {
226- throw new Exception ( 'The Erusev Parsedown must be loaded to use Parser with Markdown. ' );
226+ throw new Exception ( 'The Cebe Markdown must be loaded to use Parser with Markdown. ' );
227227 }
228228
229- $ markdown = new \Parsedown ();
229+ if ( $ flavour === 'github ' )
230+ {
231+ // use github markdown
232+ $ markdown = new \cebe \markdown \GithubMarkdown ();
233+ return $ markdown ->parse ( $ source_code );
234+ }
235+ elseif ( $ flavour === 'github-paragraph ' )
236+ {
237+ // parse only inline elements (useful for one-line descriptions)
238+ $ markdown = new \cebe \markdown \GithubMarkdown ();
239+ return $ markdown ->parseParagraph ( $ source_code );
240+ }
241+ elseif ( $ flavour === 'extra ' )
242+ {
243+ // use markdown extra
244+ $ markdown = new \cebe \markdown \MarkdownExtra ();
245+ return $ markdown ->parse ( $ source_code );
246+ }
230247
231- return $ markdown ->text ( $ source_code );
248+ // traditional markdown and parse full text
249+ $ markdown = new \cebe \markdown \Markdown ();
250+ return $ markdown ->parse ( $ source_code );
232251 }
233252
234253 /**
@@ -305,6 +324,7 @@ public function parse_php( $source_code, $vars = array() )
305324 {
306325 $ active = \O2System::$ active ;
307326 $ language = \O2System::$ language ;
327+
308328 extract ( \O2System::instance ()->getStorage ()->getArrayCopy () );
309329 }
310330
@@ -359,5 +379,10 @@ function_usable( 'eval' )
359379 */
360380 class Exception extends ExceptionInterface
361381 {
382+ public $ library = array (
383+ 'name ' => 'O2System Parser (O2Parser) ' ,
384+ 'description ' => 'Open Source PHP Parser Driver Library ' ,
385+ 'version ' => '1.0.0 ' ,
386+ );
362387 }
363- }
388+ }
0 commit comments