showdown.subParser('italicsAndBold', function (text, options) {
'use strict';
if (options.literalMidWordUnderscores) {
//underscores
// Since we are consuming a \s character, we need to add it
text = text.replace(/(^|\s|>|\b)__(?=\S)([^]+?)__(?=\b|<|\s|$)/gm, '$1$2');
text = text.replace(/(^|\s|>|\b)_(?=\S)([^]+?)_(?=\b|<|\s|$)/gm, '$1$2');
//asterisks
text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '$1');
text = text.replace(/\*(?=\S)([^]+?)\*/g, '$1');
} else {
// must go first:
text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, '$2');
text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, '$2');
}
return text;
});