Skip to content

Commit e5a99a3

Browse files
committed
Change code span attr to support multiple different tags on same line
1 parent 9633ab8 commit e5a99a3

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/marked.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ var inline = {
458458
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
459459
em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
460460
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
461-
attr: /^({{)(.*)}}/,
461+
attr: /^{{([^}]*)}}/,
462462
br: /^ {2,}\n(?!\s*$)/,
463463
del: noop,
464464
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
@@ -666,9 +666,8 @@ InlineLexer.prototype.output = function(src) {
666666
var attr = undefined;
667667
if (attr_cap = this.rules.attr.exec(src)) {
668668
src = src.substring(attr_cap[0].length);
669-
attr = attr_cap[2];
669+
attr = attr_cap[1];
670670
}
671-
672671
out += this.renderer.codespan(escape(cap[2], true), attr);
673672

674673
continue;

test/tests/code_spans.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
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>
5+
<p><code class="execute">code with an attribute</code> in the same line as another <code>code block</code> followed by <code class="ui test">UI</code> or <code class="copy">copy</code></p>
6+
7+
<p><code class="execute EXTRA">code with an attribute with additional info</code></p>
68

79
<p>Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span></p>
810

test/tests/code_spans.text

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

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

5-
`code with an attribute`{{execute}} in the same line as another `code block`
5+
`code with an attribute`{{execute}} in the same line as another `code block` followed by `UI`{{ui test}} or `copy`{{copy}}
6+
7+
`code with an attribute with additional info`{{execute EXTRA}}
68

79
Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span>
810

0 commit comments

Comments
 (0)