mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(underline): Make underline lazy
fix underline if literalMidwordUnderscores option is enabled it should end at the nearest closing underscores, not the furthest
This commit is contained in:
parent
4da93e8e13
commit
81edc70da7
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -8,11 +8,17 @@ showdown.subParser('makehtml.underline', function (text, options, globals) {
|
|||
text = globals.converter._dispatch('makehtml.underline.before', text, options, globals).getText();
|
||||
|
||||
if (options.literalMidWordUnderscores) {
|
||||
text = text.replace(/\b_?__(\S[\s\S]*)___?\b/g, function (wm, txt) {
|
||||
text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
|
||||
return '<u>' + txt + '</u>';
|
||||
});
|
||||
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) {
|
||||
text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
|
||||
return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
|
||||
});
|
||||
text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
|
||||
return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
<p><u>an underlined sentence</u></p>
|
||||
<p><u>three underscores are fine</u></p>
|
||||
<p>_single_ underscores are left alone</p>
|
||||
<p><u>multiple</u> underlines in a <u>paragraph</u></p>
|
|
@ -5,3 +5,5 @@ __an underlined sentence__
|
|||
___three underscores are fine___
|
||||
|
||||
_single_ underscores are left alone
|
||||
|
||||
__multiple__ underlines in a __paragraph__
|
Loading…
Reference in New Issue
Block a user