diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-03-26 22:37:04 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-03-26 22:37:04 +0200 |
| commit | 089fcac67ae3c3e83e2c330498d211e6b7693534 (patch) | |
| tree | 721eccb6f16d7bc089f23c4e38d605d475310d2b | |
| parent | e3757ad55ac7f161d4de11e38fb57166a8ee85f7 (diff) | |
| download | phorkie-089fcac67ae3c3e83e2c330498d211e6b7693534.tar.gz phorkie-089fcac67ae3c3e83e2c330498d211e6b7693534.zip | |
syntax highlighting with geshi
| -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(); |
