mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(literalMidWordAsterisks): no longer treats colon as alphanumeric char
Closes #461
This commit is contained in:
parent
dd7efb5a8a
commit
21194c8a03
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.
|
@ -42,14 +42,14 @@ showdown.subParser('italicsAndBold', function (text, options, globals) {
|
||||||
|
|
||||||
// Now parse asterisks
|
// Now parse asterisks
|
||||||
if (options.literalMidWordAsterisks) {
|
if (options.literalMidWordAsterisks) {
|
||||||
text = text.trim().replace(/(^| )\*{3}(\S[\s\S]*?)\*{3}([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
|
text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]+?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) {
|
||||||
return parseInside (txt, lead + '<strong><em>', '</em></strong>' + trail);
|
return parseInside (txt, lead + '<strong><em>', '</em></strong>');
|
||||||
});
|
});
|
||||||
text = text.trim().replace(/(^| )\*{2}(\S[\s\S]*?)\*{2}([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
|
text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]+?)\*\*\B(?!\*)/g, function (wm, lead, txt) {
|
||||||
return parseInside (txt, lead + '<strong>', '</strong>' + trail);
|
return parseInside (txt, lead + '<strong>', '</strong>');
|
||||||
});
|
});
|
||||||
text = text.trim().replace(/(^| )\*(\S[\s\S]*?)\*([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
|
text = text.replace(/([^*]|^)\B\*(\S[\s\S]+?)\*\B(?!\*)/g, function (wm, lead, txt) {
|
||||||
return parseInside (txt, lead + '<em>', '</em>' + trail);
|
return parseInside (txt, lead + '<em>', '</em>');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
|
text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<p>this is a sentence*with*mid asterisks</p>
|
<p>this is a sentence*with*mid asterisks</p>
|
||||||
<p>this is a sentence**with**two mid asterisks</p>
|
<p>this is a sentence**with**two mid asterisks</p>
|
||||||
<p>this is a sentence***with***three mid asterisks</p>
|
<p>this is a sentence***with***three mid asterisks</p>
|
||||||
|
<p>this is double*asterisk*mid word with another**asterisk**word</p>
|
||||||
|
<p>this is double**asterisk**mid word with another**asterisk**word</p>
|
||||||
|
<p>this is double***asterisk***mid word with another***asterisk***word</p>
|
||||||
|
<p>this is double*asterisk**mid word with another***asterisk*word</p>
|
||||||
|
<p>this is double**asterisk*mid word with another***asterisk**word</p>
|
||||||
<p>this is a sentence with just*one asterisk</p>
|
<p>this is a sentence with just*one asterisk</p>
|
||||||
<p>this is a sentence with just**one asterisk</p>
|
<p>this is a sentence with just**one asterisk</p>
|
||||||
<p>this is a sentence with just***one asterisk</p>
|
<p>this is a sentence with just***one asterisk</p>
|
||||||
|
|
|
@ -4,6 +4,16 @@ this is a sentence**with**two mid asterisks
|
||||||
|
|
||||||
this is a sentence***with***three mid asterisks
|
this is a sentence***with***three mid asterisks
|
||||||
|
|
||||||
|
this is double*asterisk*mid word with another**asterisk**word
|
||||||
|
|
||||||
|
this is double**asterisk**mid word with another**asterisk**word
|
||||||
|
|
||||||
|
this is double***asterisk***mid word with another***asterisk***word
|
||||||
|
|
||||||
|
this is double*asterisk**mid word with another***asterisk*word
|
||||||
|
|
||||||
|
this is double**asterisk*mid word with another***asterisk**word
|
||||||
|
|
||||||
this is a sentence with just*one asterisk
|
this is a sentence with just*one asterisk
|
||||||
|
|
||||||
this is a sentence with just**one asterisk
|
this is a sentence with just**one asterisk
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<p><strong>Bold:</strong></p>
|
||||||
|
<p><strong>Bold</strong></p>
|
||||||
|
<p><strong>Bold</strong>:</p>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Bold</strong><ul>
|
||||||
|
<li>Tier 2</li></ul></li>
|
||||||
|
</ul>
|
8
test/features/literalMidWordAsterisks/punctation-test.md
Normal file
8
test/features/literalMidWordAsterisks/punctation-test.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
**Bold:**
|
||||||
|
|
||||||
|
**Bold**
|
||||||
|
|
||||||
|
**Bold**:
|
||||||
|
|
||||||
|
- **Bold**
|
||||||
|
- Tier 2
|
|
@ -0,0 +1,7 @@
|
||||||
|
<p><strong>Bold:</strong></p>
|
||||||
|
<p><strong>Bold</strong></p>
|
||||||
|
<p><strong>Bold</strong>:</p>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Bold</strong><ul>
|
||||||
|
<li>Tier 2</li></ul></li>
|
||||||
|
</ul>
|
|
@ -0,0 +1,8 @@
|
||||||
|
__Bold:__
|
||||||
|
|
||||||
|
__Bold__
|
||||||
|
|
||||||
|
__Bold__:
|
||||||
|
|
||||||
|
- __Bold__
|
||||||
|
- Tier 2
|
|
@ -13,6 +13,7 @@ var bootstrap = require('../bootstrap.js'),
|
||||||
rawPrefixHeaderIdSuite = bootstrap.getTestSuite('test/features/rawPrefixHeaderId/'),
|
rawPrefixHeaderIdSuite = bootstrap.getTestSuite('test/features/rawPrefixHeaderId/'),
|
||||||
emojisSuite = bootstrap.getTestSuite('test/features/emojis/'),
|
emojisSuite = bootstrap.getTestSuite('test/features/emojis/'),
|
||||||
underlineSuite = bootstrap.getTestSuite('test/features/underline/'),
|
underlineSuite = bootstrap.getTestSuite('test/features/underline/'),
|
||||||
|
literalMidWordUnderscoresSuite = bootstrap.getTestSuite('test/features/literalMidWordUnderscores/'),
|
||||||
literalMidWordAsterisksSuite = bootstrap.getTestSuite('test/features/literalMidWordAsterisks/');
|
literalMidWordAsterisksSuite = bootstrap.getTestSuite('test/features/literalMidWordAsterisks/');
|
||||||
|
|
||||||
describe('makeHtml() features testsuite', function () {
|
describe('makeHtml() features testsuite', function () {
|
||||||
|
@ -211,6 +212,16 @@ describe('makeHtml() features testsuite', function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** test literalMidWordUnderscores option **/
|
||||||
|
describe('literalMidWordUnderscores option', function () {
|
||||||
|
var converter,
|
||||||
|
suite = literalMidWordUnderscoresSuite;
|
||||||
|
for (var i = 0; i < suite.length; ++i) {
|
||||||
|
converter = new showdown.Converter({literalMidWordUnderscores: true});
|
||||||
|
it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/** test literalMidWordAsterisks option **/
|
/** test literalMidWordAsterisks option **/
|
||||||
describe('literalMidWordAsterisks option', function () {
|
describe('literalMidWordAsterisks option', function () {
|
||||||
var converter,
|
var converter,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user