Feature: Add Markdown parsing
authorJustin J. Novack <jnovack@gmail.com>
Tue, 18 Sep 2012 19:25:47 +0000 (15:25 -0400)
committerJustin J. Novack <jnovack@gmail.com>
Tue, 18 Sep 2012 21:58:07 +0000 (17:58 -0400)
ChangeLog
README.rst
data/config.default.php
src/phorkie/Renderer/Markdown.php [new file with mode: 0644]

index afefa9afa245d166e6157e87ccfd9560faafc9f7..8557be7f9beead4c78a936983bafd4e6aa44ce4b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-09-18  Justin J. Novack  <jnovack@gmail.com>
+
+       * Add Markdown as a known file-type.
+
 2012-09-16  Christian Weiske  <cweiske@cweiske.de>
 
        * Implement request #12: DOAP documents for all pastes
 2012-09-16  Christian Weiske  <cweiske@cweiske.de>
 
        * Implement request #12: DOAP documents for all pastes
index d1c64917a430cb8576d16a9154da1905f79f27bc..4a157bf606bce64ba5dc999ee5bd12ce528d53fe 100644 (file)
@@ -84,6 +84,9 @@ phorkie stands on the shoulders of giants.
   $ pear channel-discover zustellzentrum.cweiske.de
   $ pear install zz/mime_type_plaindetect-alpha
 
   $ pear channel-discover zustellzentrum.cweiske.de
   $ pear install zz/mime_type_plaindetect-alpha
 
+  $ pear channel-discover pear.michelf.ca
+  $ pear install michelf/Markdown
+
 Note that this version of GeSHi is a bit outdated, but it's the fastest
 way to install it.
 
 Note that this version of GeSHi is a bit outdated, but it's the fastest
 way to install it.
 
index 88c9ae5ef436427b05c39bad3ba2bf2e233711d3..3fc48f68226445e72e221f7c25118814e216fd4f 100644 (file)
@@ -57,6 +57,11 @@ $GLOBALS['phorkie']['languages'] = array(
         'mime'  => 'application/javascript',
         'geshi' => 'javascript'
     ),
         'mime'  => 'application/javascript',
         'geshi' => 'javascript'
     ),
+    'md' => array(
+        'title' => 'Markdown',
+        'mime'  => 'text/x-markdown',
+        'renderer' => '\\phorkie\\Renderer_Markdown'
+    ),
     'pl' => array(
         'title' => 'Perl',
         'mime'  => 'application/x-perl',
     'pl' => array(
         'title' => 'Perl',
         'mime'  => 'application/x-perl',
diff --git a/src/phorkie/Renderer/Markdown.php b/src/phorkie/Renderer/Markdown.php
new file mode 100644 (file)
index 0000000..628d87f
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+namespace phorkie;
+
+class Renderer_Markdown
+{
+    /**
+     * Converts the code to HTML
+     *
+     * @param File        $file File to render
+     * @param Tool_Result $res  Tool result to integrate
+     *
+     * @return string HTML
+     */
+    public function toHtml(File $file, Tool_Result $res = null)
+    {
+        /**
+         */
+        require_once 'markdown.php';
+        $markdown = \markdown($file->getContent());
+
+        return '<div class="markdown">'
+            . $markdown
+            . '</div>';
+    }
+}
+
+?>