Browse Source

[#14] add initial github-flavored extension

simply handles strike-through for now.
Corey Innis 12 years ago
parent
commit
d6d7f807ea

+ 5 - 0
compressed/extensions/github.js

@@ -0,0 +1,5 @@
+//
+//  Github Extension (WIP)
+//  ~~strike-through~~   ->  <del>strike-through</del>
+//
+(function(){var a=function(a){return[{type:"lang",regex:"(~T){2}([^~]+)(~T){2}",replace:function(a,b,c,d){return"<del>"+c+"</del>"}}]};typeof window!="undefined"&&window.Showdown&&window.Showdown.extensions&&(window.Showdown.extensions.github=a),typeof module!="undefined"&&(module.exports=a)})();

+ 25 - 0
src/extensions/github.js

@@ -0,0 +1,25 @@
+//
+//  Github Extension (WIP)
+//  ~~strike-through~~   ->  <del>strike-through</del>
+//
+
+(function(){
+    var github = function(converter) {
+        return [
+            {
+              // strike-through
+              // NOTE: showdown already replaced "~" with "~T", so we need to adjust accordingly.
+              type    : 'lang',
+              regex   : '(~T){2}([^~]+)(~T){2}',
+              replace : function(match, prefix, content, suffix) {
+                  return '<del>' + content + '</del>';
+              }
+            }
+        ];
+    };
+
+    // Client-side export
+    if (typeof window !== 'undefined' && window.Showdown && window.Showdown.extensions) { window.Showdown.extensions.github = github; }
+    // Server-side export
+    if (typeof module !== 'undefined') module.exports = github;
+}());

+ 0 - 1
src/extensions/google-prettify.js

@@ -1,4 +1,3 @@
-
 //
 //  Google Prettify
 //  A showdown extension to add Google Prettify (http://code.google.com/p/google-code-prettify/)

+ 0 - 1
src/extensions/twitter.js

@@ -1,4 +1,3 @@
-
 //
 //  Twitter Extension
 //  @username   ->  <a href="http://twitter.com/username">@username</a>

+ 2 - 2
src/showdown.js

@@ -139,7 +139,7 @@ if (typeof module !== 'undefind' && typeof exports !== 'undefined' && typeof req
 // Options:
 //
 
-// Parse extensinos options into separate arrays
+// Parse extensions options into separate arrays
 if (converter_options && converter_options.extensions) {
 
 	// Iterate over each plugin
@@ -190,7 +190,7 @@ this.makeHtml = function(text) {
 	// attacklab: Replace ~ with ~T
 	// This lets us use tilde as an escape char to avoid md5 hashes
 	// The choice of character is arbitray; anything that isn't
-    // magic in Markdown will work.
+	// magic in Markdown will work.
 	text = text.replace(/~/g,"~T");
 
 	// attacklab: Replace $ with ~D

+ 5 - 0
test/extensions/github/basic.html

@@ -0,0 +1,5 @@
+<p><a href="http://github.github.com/github-flavored-markdown/">github-flavored markdown</a> adds support for:</p>
+
+<ul>
+  <li><del>strike-through text</del></li>
+</ul>

+ 3 - 0
test/extensions/github/basic.md

@@ -0,0 +1,3 @@
+[github-flavored markdown](http://github.github.com/github-flavored-markdown/) adds support for:
+
+  * ~~strike-through text~~