Skip to content

Commit

Permalink
remove(literalMidWordAsterisks): remove literalMidWordAsterisks feature
Browse files Browse the repository at this point in the history
This feature was seen as a bit "duh!" since midword asterisks are not really a thing and, for these situations, you can simply escape the asterisk character.

Closes #499

BREAKING CHANGE: literalMidWordAsterisks option was removed and so asterisks will always retain their markdown magic meaning in a source text.
If you're using this feature, and you wish to retain this option, you can find a shim here: <https://gist.github.com/tivie/7f8a88c89ffb00d2afe6c59a25528386>
  • Loading branch information
tivie committed Sep 14, 2018
1 parent a4be301 commit d9eea64
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 39 deletions.
27 changes: 14 additions & 13 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

30 changes: 13 additions & 17 deletions src/subParsers/makehtml/italicsAndBold.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ showdown.subParser('makehtml.italicsAndBold', function (text, options, globals)
// called "catastrophic backtrace". Ominous!

function parseInside (txt, left, right) {
/*
if (options.simplifiedAutoLink) {
txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
}
*/
return left + txt + right;
}

Expand Down Expand Up @@ -41,6 +36,7 @@ showdown.subParser('makehtml.italicsAndBold', function (text, options, globals)
}

// Now parse asterisks
/*
if (options.literalMidWordAsterisks) {
text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]+?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) {
return parseInside (txt, lead + '<strong><em>', '</em></strong>');
Expand All @@ -52,18 +48,18 @@ showdown.subParser('makehtml.italicsAndBold', function (text, options, globals)
return parseInside (txt, lead + '<em>', '</em>');
});
} else {
text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
});
text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
});
text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) {
// !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
});
}

*/
text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
});
text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
});
text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) {
// !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
});
//}

text = globals.converter._dispatch('makehtml.italicsAndBold.after', text, options, globals).getText();
return text;
Expand Down
9 changes: 3 additions & 6 deletions test/functional/makehtml/testsuite.features.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var bootstrap = require('./makehtml.bootstrap.js'),
emojisSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/emojis/'),
underlineSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/underline/'),
literalMidWordUnderscoresSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/literalMidWordUnderscores/'),
literalMidWordAsterisksSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/literalMidWordAsterisks/'),
//literalMidWordAsterisksSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/literalMidWordAsterisks/'),
completeHTMLOutputSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/completeHTMLOutput/'),
metadataSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/metadata/'),
splitAdjacentBlockquotesSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/splitAdjacentBlockquotes/');
Expand Down Expand Up @@ -75,8 +75,6 @@ describe('makeHtml() features testsuite', function () {
converter = new showdown.Converter({encodeEmails: false, simplifiedAutoLink: true});
} else if (testsuite[i].name === '#331.allow-escaping-of-tilde') {
converter = new showdown.Converter({strikethrough: true});
} else if (testsuite[i].name === 'enable-literalMidWordAsterisks') {
converter = new showdown.Converter({literalMidWordAsterisks: true});
} else if (testsuite[i].name === 'prefixHeaderId-simple') {
converter = new showdown.Converter({prefixHeaderId: true});
} else if (testsuite[i].name === 'prefixHeaderId-string') {
Expand All @@ -95,8 +93,6 @@ 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();
}
Expand Down Expand Up @@ -226,6 +222,7 @@ describe('makeHtml() features testsuite', function () {
});

/** test literalMidWordAsterisks option **/
/*
describe('literalMidWordAsterisks option', function () {
var converter,
suite = literalMidWordAsterisksSuite;
Expand All @@ -234,7 +231,7 @@ describe('makeHtml() features testsuite', function () {
it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter));
}
});

*/

/** test completeHTMLDocument option **/
describe('completeHTMLDocument option', function () {
Expand Down

0 comments on commit d9eea64

Please sign in to comment.