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
This commit is contained in:
Estevao Soares dos Santos 2017-11-23 05:18:20 +00:00
parent 21194c8a03
commit f4f63c5c39
8 changed files with 7 additions and 1 deletions

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -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;
}
);

View File

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

View File

@ -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>

View File

@ -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