--- markdown-extra.php 2008-12-31 07:26:58.000000000 -0500
+++ markdown-extra-geshi.php 2009-05-17 08:51:16.000000000 -0400
@@ -15,6 +15,7 @@
define( 'MARKDOWN_VERSION', "1.0.1m" ); # Sat 21 Jun 2008
define( 'MARKDOWNEXTRA_VERSION', "1.2.3" ); # Wed 31 Dec 2008
+require_once realpath(dirname(__FILE__) . '/../geshi-1.0.8.3/geshi.php');
#
# Global default settings:
@@ -68,7 +69,7 @@
### WordPress Plugin Interface ###
/*
-Plugin Name: Markdown Extra
+Plugin Name: Markdown Extra +GeSHi
Plugin URI: http://www.michelf.com/projects/php-markdown/
Description: <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://www.michelf.com/projects/php-markdown/">More...</a>
Version: 1.2.2
@@ -1107,12 +1108,20 @@
$codeblock = $matches[1];
$codeblock = $this->outdent($codeblock);
- $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
# trim leading newlines and trailing newlines
$codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock);
- $codeblock = "<pre><code>$codeblock\n</code></pre>";
+ // if it start w/ a language tag, use GeSHi to convert the code
+ if (preg_match('/^\[(\w+)\]\s*/', $codeblock, $match)) {
+ $codeblock = str_replace("[${match[1]}]\n", '', $codeblock);
+ $geshi = new GeSHi($codeblock, $match[1]);
+ $codeblock = $geshi->parse_code();
+ } else {
+ $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
+ $codeblock = "<pre><code>$codeblock\n</code></pre>";
+ }
+
return "\n\n".$this->hashBlock($codeblock)."\n\n";
}
@@ -2819,6 +2828,14 @@
}
+// If there's command line argument, markdownify the file from the first argument
+if (!empty($argv[1])) {
+ $filename = realpath($argv[1]);
+ if (file_exists($filename)) {
+ $rawtext = file_get_contents($filename);
+ echo Markdown($rawtext);
+ }
+}
/*