Преглед на файлове

fix(spanGamut): code spans are hashed after parsing

Code spans are now hashed after parsing which means extensions
that listen to spanGamut events no longer need to worry about
escaping "custom" magic chars inside code spans.

Closes #464
Estevao Soares dos Santos преди 7 години
родител
ревизия
f4f63c5c39
променени са 8 файла, в които са добавени 12 реда и са изтрити 4 реда
  1. 5 2
      dist/showdown.js
  2. 0 0
      dist/showdown.js.map
  3. 0 1
      dist/showdown.min.js
  4. 0 0
      dist/showdown.min.js.map
  5. 3 1
      src/subParsers/codeSpans.js
  6. 1 0
      src/subParsers/hashHTMLSpans.js
  7. 1 0
      test/cases/inline-code.html
  8. 2 0
      test/cases/inline-code.md

+ 5 - 2
dist/showdown.js

@@ -1,4 +1,4 @@
-;/*! showdown v 1.8.2 - 17-11-2017 */
+;/*! showdown v 1.8.2 - 23-11-2017 */
 (function(){
 /**
  * Created by Tivie on 13-07-2015.
@@ -2878,7 +2878,9 @@ showdown.subParser('codeSpans', function (text, options, globals) {
       c = c.replace(/^([ \t]*)/g, '');	// leading whitespace
       c = c.replace(/[ \t]*$/g, '');	// trailing whitespace
       c = showdown.subParser('encodeCode')(c, options, globals);
-      return m1 + '<code>' + c + '</code>';
+      c = m1 + '<code>' + c + '</code>';
+      c = showdown.subParser('hashHTMLSpans')(c, options, globals);
+      return c;
     }
   );
 
@@ -3303,6 +3305,7 @@ showdown.subParser('unhashHTMLSpans', function (text, options, globals) {
       var num = RegExp.$1;
       repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]);
       if (limit === 10) {
+        console.error('maximum nesting of 10 spans reached!!!');
         break;
       }
       ++limit;

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/showdown.js.map


Файловите разлики са ограничени, защото са твърде много
+ 0 - 1
dist/showdown.min.js


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/showdown.min.js.map


+ 3 - 1
src/subParsers/codeSpans.js

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

+ 1 - 0
src/subParsers/hashHTMLSpans.js

@@ -51,6 +51,7 @@ showdown.subParser('unhashHTMLSpans', function (text, options, globals) {
       var num = RegExp.$1;
       repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]);
       if (limit === 10) {
+        console.error('maximum nesting of 10 spans reached!!!');
         break;
       }
       ++limit;

+ 1 - 0
test/cases/inline-code.html

@@ -4,3 +4,4 @@
 <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
 <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
 <p><code>&amp;#8212;</code> is the decimal-encoded equivalent of <code>&amp;mdash;</code>.</p>
+<p>this <code>inline **code** has ___magic___</code> chars</p>

+ 2 - 0
test/cases/inline-code.md

@@ -10,3 +10,5 @@ A backtick-delimited string in a code span: `` `foo` ``
 Please don't use any `<blink>` tags.
 
 `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
+
+this `inline **code** has ___magic___` chars

Някои файлове не бяха показани, защото твърде много файлове са промени