Skip to content

Commit

Permalink
fix(spanGamut): code spans are hashed after parsing
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tivie committed Nov 23, 2017
1 parent 21194c8 commit f4f63c5
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 7 deletions.
7 changes: 5 additions & 2 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/subParsers/codeSpans.js
Expand Up @@ -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;
}
);

Expand Down
1 change: 1 addition & 0 deletions src/subParsers/hashHTMLSpans.js
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/cases/inline-code.html
Expand Up @@ -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 changes: 2 additions & 0 deletions test/cases/inline-code.md
Expand Up @@ -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

0 comments on commit f4f63c5

Please sign in to comment.