|
@@ -39,16 +39,29 @@ showdown.subParser('italicsAndBold', function (text, options, globals) {
|
|
|
}
|
|
|
|
|
|
// Now parse asterisks
|
|
|
- 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;
|
|
|
- });
|
|
|
+ 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(/(?:^| +)\*{2}(\S[\s\S]*?)\*{2}(?: +|$)/g, function (wm, txt) {
|
|
|
+ return parseInside (txt, ' <strong>', '</strong> ');
|
|
|
+ });
|
|
|
+ text = text.trim().replace(/(?:^| +)\*{1}(\S[\s\S]*?)\*{1}(?: +|$)/g, function (wm, txt) {
|
|
|
+ return parseInside (txt, ' <em>', '</em>' + (wm.slice(-1) === ' ' ? ' ' : ''));
|
|
|
+ });
|
|
|
+ } 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 = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
|
|
|
return text;
|