Created
March 5, 2015 15:22
-
-
Save harryfk/d12a228a3e26073fbf30 to your computer and use it in GitHub Desktop.
showdown-interview.js
This file contains hidden or 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
(function () { | |
var interview = function () { | |
return [ | |
{ type: 'lang', filter: function(text) { | |
var inlineRegex = /\[([QqAa])\]\((.*?)\)/g; | |
text = text.replace(inlineRegex, function(match, n, t) { | |
var cssClass = (n == 'Q' || n == 'q') ? 'text-question' : 'text-answer'; | |
var s = '<span class="'+cssClass+'">'+t+'</span>'; | |
return s; | |
}); | |
return text; | |
}} | |
]; | |
}; | |
// Client-side export | |
if (typeof window !== 'undefined' && window.Showdown && window.Showdown.extensions) { | |
window.Showdown.extensions.interview = interview; | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment