-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(underline): add EXPERIMENTAL support for underline
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
- Loading branch information
Showing
13 changed files
with
993 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
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; | ||
}); |
Oops, something went wrong.