Răsfoiți Sursa

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 ani în urmă
părinte
comite
f4f63c5c39

+ 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;

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/showdown.js.map


Fișier diff suprimat deoarece este prea mare
+ 0 - 1
dist/showdown.min.js


Fișier diff suprimat deoarece este prea mare
+ 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

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff