|
@@ -9,12 +9,13 @@ var showdown = {},
|
|
|
parsers = {},
|
|
|
extensions = {},
|
|
|
defaultOptions = {
|
|
|
- omitExtraWLInCodeBlocks: false,
|
|
|
- prefixHeaderId: false,
|
|
|
- noHeaderId: false,
|
|
|
- headerLevelStart: 1,
|
|
|
- parseImgDimensions: false,
|
|
|
- simplifiedAutoLink: false
|
|
|
+ omitExtraWLInCodeBlocks: false,
|
|
|
+ prefixHeaderId: false,
|
|
|
+ noHeaderId: false,
|
|
|
+ headerLevelStart: 1,
|
|
|
+ parseImgDimensions: false,
|
|
|
+ simplifiedAutoLink: false,
|
|
|
+ literalMidWordUnderscores: false
|
|
|
},
|
|
|
globalOptions = JSON.parse(JSON.stringify(defaultOptions)); //clone default options out of laziness =P
|
|
|
|
|
@@ -432,11 +433,7 @@ showdown.Converter = function (converterOptions) {
|
|
|
* @private
|
|
|
* @type {{}}
|
|
|
*/
|
|
|
- options = {
|
|
|
- omitExtraWLInCodeBlocks: false,
|
|
|
- prefixHeaderId: false,
|
|
|
- noHeaderId: false
|
|
|
- },
|
|
|
+ options = {},
|
|
|
|
|
|
/**
|
|
|
* Language extensions used by this converter
|
|
@@ -1596,13 +1593,23 @@ showdown.subParser('images', function (text, options, globals) {
|
|
|
return text;
|
|
|
});
|
|
|
|
|
|
-showdown.subParser('italicsAndBold', function (text) {
|
|
|
+showdown.subParser('italicsAndBold', function (text, options) {
|
|
|
'use strict';
|
|
|
- // <strong> must go first:
|
|
|
- text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, '<strong>$2</strong>');
|
|
|
|
|
|
- text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, '<em>$2</em>');
|
|
|
+ if (options.literalMidWordUnderscores) {
|
|
|
+ //underscores
|
|
|
+ // Since we are consuming a \s character, we need to add it
|
|
|
+ text = text.replace(/(\s)__(?=\S)([^]+?)__(?=\s)/g, '$1<strong>$2</strong>');
|
|
|
+ text = text.replace(/(\s)_(?=\S)([^]+?)_(?=\s)/g, '$1<em>$2</em>');
|
|
|
+ //asterisks
|
|
|
+ text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '<strong>$1</strong>');
|
|
|
+ text = text.replace(/\*(?=\S)([^]+?)\*/g, '<em>$1</em>');
|
|
|
|
|
|
+ } else {
|
|
|
+ // <strong> must go first:
|
|
|
+ text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, '<strong>$2</strong>');
|
|
|
+ text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, '<em>$2</em>');
|
|
|
+ }
|
|
|
return text;
|
|
|
});
|
|
|
|