support michelf\markdown 1.4+ API
[phorkie.git] / src / phorkie / Renderer / Markdown.php
index 628d87f1faa474f850e8269ecf5d2bdd4eebd598..65cb29c0469c062a9a253cc7b955538c0ffc87eb 100644 (file)
@@ -13,10 +13,16 @@ class Renderer_Markdown
      */
     public function toHtml(File $file, Tool_Result $res = null)
     {
-        /**
-         */
-        require_once 'markdown.php';
-        $markdown = \markdown($file->getContent());
+        if (class_exists('\\Michelf\\Markdown', true)) {
+            //composer-installed version 1.4+
+            $markdown = \Michelf\Markdown::defaultTransform(
+                $file->getContent()
+            );
+        } else {
+            //PEAR-installed version 1.0.2 has a different API
+            require_once 'markdown.php';
+            $markdown = \markdown($file->getContent());
+        }
 
         return '<div class="markdown">'
             . $markdown