fix markdown in descriptions
[mdref/mdref] / mdref / Markdown.php
index 6d761c29ad2f8dc4ac577129820fc8a57e0ef101..e8c5cb67af21cba2ce19c717e3699348e7c0f671 100644 (file)
@@ -12,7 +12,7 @@ class Markdown
        /**
         * @param \mdref\Path $path
         */
-       function __construct(Path $path) {
+       function __construct(Path $path = null) {
                $this->path = $path;
        }
        
@@ -20,6 +20,9 @@ class Markdown
         * @return string
         */
        function __toString() {
+               if (!$this->path) {
+                       return "";
+               }
                try {
                        $r = fopen($this->path->getFullPath(".md"), "r");
                        $md = \MarkdownDocument::createFromStream($r);
@@ -31,4 +34,10 @@ class Markdown
                }
                return $html;
        }
+
+       function quick($string) {
+               $md = \MarkdownDocument::createFromString($string);
+               $md->compile(\MarkdownDocument::AUTOLINK);
+               return $md->getHtml();
+       }
 }