Skip to content

Commit a15c9c0

Browse files
committed
Don't inherit attributes
1 parent 9d59d25 commit a15c9c0

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

lib/marked.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ InlineLexer.prototype.output = function(src) {
663663
if (cap = this.rules.code.exec(src)) {
664664
src = src.substring(cap[0].length);
665665

666-
var attr;
666+
var attr = undefined;
667667
if (attr_cap = this.rules.attr.exec(src)) {
668668
src = src.substring(attr_cap[0].length);
669669
attr = attr_cap[2];
@@ -1106,7 +1106,7 @@ function escape(html, encode) {
11061106
}
11071107

11081108
function unescape(html) {
1109-
// explicitly match decimal, hex, and named HTML entities
1109+
// explicitly match decimal, hex, and named HTML entities
11101110
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
11111111
n = n.toLowerCase();
11121112
if (n === 'colon') return ':';

test/tests/code_spans.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
<p><code class="lang">code with an attribute</code></p>
44

5+
<p><code class="execute">code with an attribute</code> in the same line as another<code>code block</code></p>
6+
57
<p>Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span></p>
68

79
<p>Here&#39;s how you put <code>`backticks`</code> in a code span.</p>
8-

test/tests/code_spans.text

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
`code with an attribute`{{lang}}
44

5+
`code with an attribute`{{execute}} in the same line as another `code block`
6+
57
Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span>
68

79
Here's how you put `` `backticks` `` in a code span.
8-

test/tests/file_blocks.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<p>Regular text.</p>
2+
<div class="file">file block on the first line
3+
</div>
4+
<p>Regular text.</p>
5+
6+
<div class="file"> file block with leading spaces
7+
and multiple lines
8+
</div>
9+

test/tests/file_blocks.text

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Regular text.
2+
3+
///
4+
file block on the first line
5+
///
6+
7+
Regular text.
8+
9+
///
10+
file block with leading spaces
11+
and multiple lines
12+
///

0 commit comments

Comments
 (0)