mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(literalMidWordAsterisks): fix option no longer treat punctuation as word character
Closes #398
This commit is contained in:
parent
7332582db3
commit
8f05be7788
12
dist/showdown.js
vendored
12
dist/showdown.js
vendored
@ -2342,14 +2342,14 @@ showdown.subParser('italicsAndBold', function (text, options, globals) {
|
||||
|
||||
// Now parse asterisks
|
||||
if (options.literalMidWordAsterisks) {
|
||||
text = text.trim().replace(/(?:^| +)\*{3}(\S[\s\S]*?)\*{3}(?: +|$)/g, function (wm, txt) {
|
||||
return parseInside (txt, ' <strong><em>', '</em></strong> ');
|
||||
text = text.trim().replace(/(^| )\*{3}(\S[\s\S]*?)\*{3}([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
|
||||
return parseInside (txt, lead + '<strong><em>', '</em></strong>' + trail);
|
||||
});
|
||||
text = text.trim().replace(/(?:^| +)\*{2}(\S[\s\S]*?)\*{2}(?: +|$)/g, function (wm, txt) {
|
||||
return parseInside (txt, ' <strong>', '</strong> ');
|
||||
text = text.trim().replace(/(^| )\*{2}(\S[\s\S]*?)\*{2}([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
|
||||
return parseInside (txt, lead + '<strong>', '</strong>' + trail);
|
||||
});
|
||||
text = text.trim().replace(/(?:^| +)\*{1}(\S[\s\S]*?)\*{1}(?: +|$)/g, function (wm, txt) {
|
||||
return parseInside (txt, ' <em>', '</em>' + (wm.slice(-1) === ' ' ? ' ' : ''));
|
||||
text = text.trim().replace(/(^| )\*(\S[\s\S]*?)\*([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
|
||||
return parseInside (txt, lead + '<em>', '</em>' + trail);
|
||||
});
|
||||
} else {
|
||||
text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
|
||||
|
2
dist/showdown.js.map
vendored
2
dist/showdown.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/showdown.min.js
vendored
2
dist/showdown.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/showdown.min.js.map
vendored
2
dist/showdown.min.js.map
vendored
File diff suppressed because one or more lines are too long
@ -40,14 +40,14 @@ showdown.subParser('italicsAndBold', function (text, options, globals) {
|
||||
|
||||
// Now parse asterisks
|
||||
if (options.literalMidWordAsterisks) {
|
||||
text = text.trim().replace(/(?:^| +)\*{3}(\S[\s\S]*?)\*{3}(?: +|$)/g, function (wm, txt) {
|
||||
return parseInside (txt, ' <strong><em>', '</em></strong> ');
|
||||
text = text.trim().replace(/(^| )\*{3}(\S[\s\S]*?)\*{3}([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
|
||||
return parseInside (txt, lead + '<strong><em>', '</em></strong>' + trail);
|
||||
});
|
||||
text = text.trim().replace(/(?:^| +)\*{2}(\S[\s\S]*?)\*{2}(?: +|$)/g, function (wm, txt) {
|
||||
return parseInside (txt, ' <strong>', '</strong> ');
|
||||
text = text.trim().replace(/(^| )\*{2}(\S[\s\S]*?)\*{2}([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
|
||||
return parseInside (txt, lead + '<strong>', '</strong>' + trail);
|
||||
});
|
||||
text = text.trim().replace(/(?:^| +)\*{1}(\S[\s\S]*?)\*{1}(?: +|$)/g, function (wm, txt) {
|
||||
return parseInside (txt, ' <em>', '</em>' + (wm.slice(-1) === ' ' ? ' ' : ''));
|
||||
text = text.trim().replace(/(^| )\*(\S[\s\S]*?)\*([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
|
||||
return parseInside (txt, lead + '<em>', '</em>' + trail);
|
||||
});
|
||||
} else {
|
||||
text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
|
||||
|
@ -0,0 +1 @@
|
||||
<p>strippers, <strong>hitler</strong>, and stalin</p>
|
@ -0,0 +1 @@
|
||||
strippers, **hitler**, and stalin
|
9
test/features/literalMidWordUnderscores.html
Normal file
9
test/features/literalMidWordUnderscores.html
Normal file
@ -0,0 +1,9 @@
|
||||
<p>some <em>foo</em> yeah</p>
|
||||
<p>some <strong>foo</strong> yeah</p>
|
||||
<p>some <strong><em>foo</em></strong> yeah</p>
|
||||
<p>some word_foo_yeah</p>
|
||||
<p>some word__foo__yeah</p>
|
||||
<p>some word___foo___yeah</p>
|
||||
<p>strippers, <em>hitler</em>, and stalin</p>
|
||||
<p>strippers, <strong>hitler</strong>, and stalin</p>
|
||||
<p>strippers, <strong><em>hitler</em></strong>, and stalin</p>
|
17
test/features/literalMidWordUnderscores.md
Normal file
17
test/features/literalMidWordUnderscores.md
Normal file
@ -0,0 +1,17 @@
|
||||
some _foo_ yeah
|
||||
|
||||
some __foo__ yeah
|
||||
|
||||
some ___foo___ yeah
|
||||
|
||||
some word_foo_yeah
|
||||
|
||||
some word__foo__yeah
|
||||
|
||||
some word___foo___yeah
|
||||
|
||||
strippers, _hitler_, and stalin
|
||||
|
||||
strippers, __hitler__, and stalin
|
||||
|
||||
strippers, ___hitler___, and stalin
|
@ -22,6 +22,8 @@ describe('makeHtml() features testsuite', function () {
|
||||
converter = new showdown.Converter({headerLevelStart: 3});
|
||||
} else if (testsuite[i].name === '#164.1.simple-autolink' || testsuite[i].name === '#204.certain-links-with-at-and-dot-break-url') {
|
||||
converter = new showdown.Converter({simplifiedAutoLink: true});
|
||||
} else if (testsuite[i].name === 'literalMidWordUnderscores') {
|
||||
converter = new showdown.Converter({literalMidWordUnderscores: true});
|
||||
} else if (testsuite[i].name === '#164.2.disallow-underscore-emphasis-mid-word') {
|
||||
converter = new showdown.Converter({literalMidWordUnderscores: true});
|
||||
} else if (testsuite[i].name === '#164.3.strikethrough' || testsuite[i].name === '#214.escaped-markdown-chars-break-strikethrough') {
|
||||
@ -84,6 +86,8 @@ describe('makeHtml() features testsuite', function () {
|
||||
converter = new showdown.Converter({backslashEscapesHTMLTags: true});
|
||||
} else if (testsuite[i].name === '#379.openLinksInNewWindow-breaks-em-markdup') {
|
||||
converter = new showdown.Converter({openLinksInNewWindow: true});
|
||||
} else if (testsuite[i].name === '#398.literalMidWordAsterisks-treats-non-word-characters-as-characters') {
|
||||
converter = new showdown.Converter({literalMidWordAsterisks: true});
|
||||
} else {
|
||||
converter = new showdown.Converter();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user