[#14] add initial github-flavored extension

simply handles strike-through for now.
This commit is contained in:
Corey Innis 2012-10-31 03:38:46 -07:00
parent 60c6eec3eb
commit d6d7f807ea
7 changed files with 40 additions and 4 deletions

View File

@ -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
src/extensions/github.js Normal file
View File

@ -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;
}());

View File

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

View File

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

View File

@ -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

View File

@ -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>

View File

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