mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
084b819b14
Syntax is: ``` __double underscores__ or ___triple unserscores___ ``` Keep in mind that, with this option enabled, underscore no longer parses as `<em>` or `<strong>` Closes #450
27 lines
782 B
JavaScript
27 lines
782 B
JavaScript
showdown.subParser('underline', function (text, options, globals) {
|
|
'use strict';
|
|
|
|
if (!options.underline) {
|
|
return text;
|
|
}
|
|
|
|
text = globals.converter._dispatch('underline.before', text, options, globals);
|
|
|
|
if (options.literalMidWordUnderscores) {
|
|
text = text.replace(/\b_?__(\S[\s\S]*)___?\b/g, function (wm, txt) {
|
|
return '<u>' + txt + '</u>';
|
|
});
|
|
} else {
|
|
text = text.replace(/_?__(\S[\s\S]*?)___?/g, function (wm, m) {
|
|
return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
|
|
});
|
|
}
|
|
|
|
// escape remaining underscores to prevent them being parsed by italic and bold
|
|
text = text.replace(/(_)/g, showdown.helper.escapeCharactersCallback);
|
|
|
|
text = globals.converter._dispatch('underline.after', text, options, globals);
|
|
|
|
return text;
|
|
});
|