syntax highlighting with geshi
[phorkie.git] / src / Phorkie / File.php
index 14a7bbf335fbbeb907a99941b1a29eee1ba1df33..6e71de37ca6cfef60fa7d62372ffc1a95921fbec 100644 (file)
@@ -57,6 +57,19 @@ class File
         return file_get_contents($this->path);
     }
 
+    public function getHighlightedContent()
+    {
+        /**
+         * Yes, geshi needs to be in your include path
+         * We use the mediawiki geshi extension package.
+         */
+        require 'MediaWiki/geshi/geshi/geshi.php';
+        $geshi = new \GeSHi($this->getContent(), $this->getType());
+        $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
+        $geshi->set_header_type(GESHI_HEADER_DIV);
+        return $geshi->parse_code();
+    }
+
     public function getMimeType()
     {
         $type = $this->getType();