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 16 additions and 7 deletions

7
dist/showdown.js vendored
View File

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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