Skip to content

Commit

Permalink
Added ability to embed gists using [gist: {gist id}]
Browse files Browse the repository at this point in the history
  • Loading branch information
guitsaru committed Jul 27, 2008
1 parent 242e15d commit 53d6265
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
9 changes: 6 additions & 3 deletions code.php
Expand Up @@ -62,10 +62,13 @@ public function feed_content($post) {
return $post->code;
}

public function format_code($text, $post = null) {
if (isset($post)) {
$post->code_unformatted = $post->code;
public function format_code($text, $post = null) {
if(isset($post)) {
$code = $text;
if(preg_match("/\[gist: ([0-9]+)\]/i", $code, $matches)) {
return '<script src="http://gist.github.com/'.$matches[1].'.js"></script>';
}
$post->code_unformatted = $post->code;
$languages = getLanguages();
$geshi = new GeSHi($code, $languages[$post->language]);

Expand Down
2 changes: 1 addition & 1 deletion info.yaml
@@ -1,6 +1,6 @@
name: Code
url: http://guitsaru.com/
version: 1
version: 1.1
description: Post code snippets with geshi syntax highlighting.
author:
name: Matt Pruitt
Expand Down
4 changes: 3 additions & 1 deletion readme.txt
@@ -1,4 +1,6 @@
Install:
Copy the code folder into your feathers directory
Copy code.twig into your themes feathers directory
Add the contents of style.css to your themes stylesheets/screen.css file
Add the contents of style.css to your themes stylesheets/screen.css file

You can now embed gists using [gist: 2729], replacing 2729 with your gists id.
6 changes: 3 additions & 3 deletions style.css
@@ -1,7 +1,7 @@
pre#geshi_code {
padding: 7px 2px;
overflow: auto;
line-height: 11pt;
padding: 7px 2px;
overflow: auto;
line-height: 11pt;
border-style: dotted;
border-width: 1px;
max-height: 300px;
Expand Down

1 comment on commit 53d6265

@icco
Copy link

@icco icco commented on 53d6265 Feb 19, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, your replacement for [gist: id#] is really smart. I stole the regex from you for use in my project. http://github.com/icco/self-note. Thanks :)

Please sign in to comment.