Last active
August 29, 2015 14:17
-
-
Save harryfk/a0e9c669d0d80a63daf8 to your computer and use it in GitHub Desktop.
showdown interview extension
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: 'output', filter: function(source){ | |
var questionRegex = /(<p>)(<strong>)?(Q|speaker): /gi; | |
return source.replace(questionRegex, function(match, p, s, i) { | |
var cssClass; | |
if (i.toLowerCase() == 'q') { cssClass= 'text-question'; } | |
if (i.toLowerCase() == 'speaker') { cssClass = 'text-speaker'; } | |
if (s) { | |
return '<p class="'+cssClass+'">'+s; | |
} | |
return '<p class="'+cssClass+'">'; | |
}); | |
}} | |
]; | |
}; | |
// 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