Created
February 19, 2009 08:02
-
-
Save icco/66792 to your computer and use it in GitHub Desktop.
[gist: ####] formatting with PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Gist replacement inspired by http://github.com/guitsaru/code-feather/ | |
if(preg_match("/\[gist: ([0-9]+)\]/i", $out, $matches)) { | |
return '<script src="http://gist.github.com/'.$matches[1].'.js"></script>'; | |
} | |
// Can also be done in one line. | |
$out = preg_replace("/\[gist: ([0-9]+)\]/i", '<script src="http://gist.github.com/\\1.js"></script>', $out); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment