[#1334] turn off typographic substitution in certain blocks
This commit is contained in:
parent
7f2a917b36
commit
4ba30dba6b
@ -730,6 +730,14 @@ InlineLexer.prototype.output = function(src) {
|
|||||||
} else if (this.inLink && /^<\/a>/i.test(cap[0])) {
|
} else if (this.inLink && /^<\/a>/i.test(cap[0])) {
|
||||||
this.inLink = false;
|
this.inLink = false;
|
||||||
}
|
}
|
||||||
|
if (!this.inRawBlock
|
||||||
|
&& /^<pre|^<code|^<kbd|^<script/i.test(cap[0])) {
|
||||||
|
this.inRawBlock = true;
|
||||||
|
} else if (this.inRawBlock
|
||||||
|
&& /^<\/pre>|^<\/code>|^<\/kbd>|^<\/script>/i.test(cap[0])) {
|
||||||
|
this.inRawBlock = false;
|
||||||
|
}
|
||||||
|
|
||||||
src = src.substring(cap[0].length);
|
src = src.substring(cap[0].length);
|
||||||
out += this.options.sanitize
|
out += this.options.sanitize
|
||||||
? this.options.sanitizer
|
? this.options.sanitizer
|
||||||
@ -820,7 +828,11 @@ InlineLexer.prototype.output = function(src) {
|
|||||||
// text
|
// text
|
||||||
if (cap = this.rules.text.exec(src)) {
|
if (cap = this.rules.text.exec(src)) {
|
||||||
src = src.substring(cap[0].length);
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
test/new/smartypants_code.html
Normal file
4
test/new/smartypants_code.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<pre>&</pre>
|
||||||
|
<p><code>--foo</code>
|
||||||
|
<kbd>---foo</kbd></p>
|
||||||
|
<script>--foo</script>
|
9
test/new/smartypants_code.md
Normal file
9
test/new/smartypants_code.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
smartypants: true
|
||||||
|
description: SmartyPants does not modify characters within <pre>, <code>, <kbd>, or <script> tag blocks.
|
||||||
|
spec: https://daringfireball.net/projects/smartypants/
|
||||||
|
---
|
||||||
|
<pre>&</pre>
|
||||||
|
<code>--foo</code>
|
||||||
|
<kbd>---foo</kbd>
|
||||||
|
<script>--foo</script>
|
Loading…
x
Reference in New Issue
Block a user