소스 검색

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

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.