diff options
| -rw-r--r-- | README.rst | 8 | ||||
| -rw-r--r-- | data/templates/display.htm | 2 | ||||
| -rw-r--r-- | src/Phorkie/File.php | 13 |
3 files changed, 22 insertions, 1 deletions
@@ -35,3 +35,11 @@ Internal directory layout Search ====== Use ``ack-grep`` + + +Install geshi +============= +:: + + $ pear channel-discover mediawiki.googlecode.com/svn + $ pear install mediawiki/geshi diff --git a/data/templates/display.htm b/data/templates/display.htm index ea2e2cd..43a76fc 100644 --- a/data/templates/display.htm +++ b/data/templates/display.htm @@ -10,7 +10,7 @@ <p> <a href="{{file.getLink('raw')}}">raw</a> </p> - <pre>{{file.getContent}}</pre> + {{file.getHighlightedContent|raw}} </div> {% endfor %} {% endblock %} diff --git a/src/Phorkie/File.php b/src/Phorkie/File.php index 14a7bbf..6e71de3 100644 --- a/src/Phorkie/File.php +++ b/src/Phorkie/File.php @@ -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(); |
