Estevão Soares dos Santos 10 yıl önce
ebeveyn
işleme
9ab2af0e89

+ 1 - 1
Gruntfile.js

@@ -89,7 +89,7 @@ module.exports = function (grunt) {
         options: {
           globals: ['should'],
           timeout: 3000,
-          ignoreLeaks: false,
+          ignoreLeaks: true,
           reporter: 'spec'
         }
       },

+ 20 - 11
dist/showdown.js

@@ -1174,6 +1174,14 @@ showdown.subParser('codeBlocks', function (text, options, globals) {
 showdown.subParser('codeSpans', function (text) {
   'use strict';
 
+  //special case -> literal html code tag
+  text = text.replace(/(<code[^><]*?>)([^]*?)<\/code>/g, function (wholeMatch, tag, c) {
+    c = c.replace(/^([ \t]*)/g, '');	// leading whitespace
+    c = c.replace(/[ \t]*$/g, '');	// trailing whitespace
+    c = showdown.subParser('encodeCode')(c);
+    return tag + c + '</code>';
+  });
+
   /*
    text = text.replace(/
    (^|[^\\])					// Character before opening ` can't be a backslash
@@ -1186,17 +1194,17 @@ showdown.subParser('codeSpans', function (text) {
    (?!`)
    /gm, function(){...});
    */
-
-  text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function (wholeMatch, m1, m2, m3) {
-    var c = m3;
-    c = c.replace(/^([ \t]*)/g, '');	// leading whitespace
-    c = c.replace(/[ \t]*$/g, '');	// trailing whitespace
-    c = showdown.subParser('encodeCode')(c);
-    return m1 + '<code>' + c + '</code>';
-  });
+  text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
+    function (wholeMatch, m1, m2, m3) {
+      var c = m3;
+      c = c.replace(/^([ \t]*)/g, '');	// leading whitespace
+      c = c.replace(/[ \t]*$/g, '');	// trailing whitespace
+      c = showdown.subParser('encodeCode')(c);
+      return m1 + '<code>' + c + '</code>';
+    }
+  );
 
   return text;
-
 });
 
 /**
@@ -1689,6 +1697,7 @@ showdown.subParser('images', function (text, options, globals) {
     }
 
     altText = altText.replace(/"/g, '&quot;');
+    altText = showdown.helper.escapeCharacters(altText, '*_', false);
     url = showdown.helper.escapeCharacters(url, '*_', false);
     var result = '<img src="' + url + '" alt="' + altText + '"';
 
@@ -1726,8 +1735,8 @@ showdown.subParser('italicsAndBold', function (text, options) {
   if (options.literalMidWordUnderscores) {
     //underscores
     // Since we are consuming a \s character, we need to add it
-    text = text.replace(/(^|\s)__(?=\S)([^]+?)__(?=\s|$)/gm, '$1<strong>$2</strong>');
-    text = text.replace(/(^|\s)_(?=\S)([^]+?)_(?=\s|$)/gm, '$1<em>$2</em>');
+    text = text.replace(/(^|\s|>|\b)__(?=\S)([^]+?)__(?=\b|<|\s|$)/gm, '$1<strong>$2</strong>');
+    text = text.replace(/(^|\s|>|\b)_(?=\S)([^]+?)_(?=\b|<|\s|$)/gm, '$1<em>$2</em>');
     //asterisks
     text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '<strong>$1</strong>');
     text = text.replace(/\*(?=\S)([^]+?)\*/g, '<em>$1</em>');

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
dist/showdown.js.map


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
dist/showdown.min.js


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
dist/showdown.min.js.map


+ 2 - 1
src/subParsers/codeSpans.js

@@ -53,7 +53,8 @@ showdown.subParser('codeSpans', function (text) {
       c = c.replace(/[ \t]*$/g, '');	// trailing whitespace
       c = showdown.subParser('encodeCode')(c);
       return m1 + '<code>' + c + '</code>';
-  });
+    }
+  );
 
   return text;
 });

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor