diff --git a/lib/marked.js b/lib/marked.js index c85f74ac95..79478498c9 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -730,6 +730,12 @@ InlineLexer.prototype.output = function(src) { } else if (this.inLink && /^<\/a>/i.test(cap[0])) { this.inLink = false; } + if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) { + this.inRawBlock = true; + } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) { + this.inRawBlock = false; + } + src = src.substring(cap[0].length); out += this.options.sanitize ? this.options.sanitizer @@ -820,7 +826,11 @@ InlineLexer.prototype.output = function(src) { // text if (cap = this.rules.text.exec(src)) { src = src.substring(cap[0].length); - out += this.renderer.text(escape(this.smartypants(cap[0]))); + if (this.inRawBlock) { + out += this.renderer.text(cap[0]); + } else { + out += this.renderer.text(escape(this.smartypants(cap[0]))); + } continue; } diff --git a/test/new/smartypants_code.html b/test/new/smartypants_code.html new file mode 100644 index 0000000000..3ceb5094c3 --- /dev/null +++ b/test/new/smartypants_code.html @@ -0,0 +1,11 @@ +
&
+

--foo +---foo

+ + +

Ensure that text such as custom tags that happen to +begin with the same letters as the above tags don’t +match and thus benefit from Smartypants-ing.

+ +

–foo +--foo <codebar –foo codebar>

diff --git a/test/new/smartypants_code.md b/test/new/smartypants_code.md new file mode 100644 index 0000000000..6c4c52332e --- /dev/null +++ b/test/new/smartypants_code.md @@ -0,0 +1,15 @@ +--- +smartypants: true +description: SmartyPants does not modify characters within
, , , or 
+
+Ensure that text such as custom tags that happen to
+begin with the same letters as the above tags don't
+match and thus benefit from Smartypants-ing.
+--foo
+`--foo`