support michelf\markdown 1.4+ API
authorChristian Weiske <cweiske@cweiske.de>
Fri, 16 May 2014 05:33:33 +0000 (07:33 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 16 May 2014 05:33:33 +0000 (07:33 +0200)
src/phorkie/Renderer/Markdown.php
src/phorkie/SetupCheck.php

index 628d87f..65cb29c 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
index 62bbf19..53e4fd0 100644 (file)
@@ -55,9 +55,12 @@ class SetupCheck
             }
         }
 
-        $markdown = stream_resolve_include_path('markdown.php');
-        if ($markdown === false) {
-            $this->fail('Markdown renderer not available');
+        if (!class_exists('\\Michelf\\Markdown', true)) {
+            //PEAR-installed version 1.0.2 has a different API
+            $markdown = stream_resolve_include_path('markdown.php');
+            if ($markdown === false) {
+                $this->fail('Markdown renderer not available');
+            }
         }
     }