Skip to content

Instantly share code, notes, and snippets.

@harryfk
Created March 5, 2015 15:22
Show Gist options
  • Save harryfk/d12a228a3e26073fbf30 to your computer and use it in GitHub Desktop.
Save harryfk/d12a228a3e26073fbf30 to your computer and use it in GitHub Desktop.
showdown-interview.js
(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