File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -458,6 +458,7 @@ var inline = {
458
458
strong : / ^ _ _ ( [ \s \S ] + ?) _ _ (? ! _ ) | ^ \* \* ( [ \s \S ] + ?) \* \* (? ! \* ) / ,
459
459
em : / ^ \b _ ( (?: [ ^ _ ] | _ _ ) + ?) _ \b | ^ \* ( (?: \* \* | [ \s \S ] ) + ?) \* (? ! \* ) / ,
460
460
code : / ^ ( ` + ) \s * ( [ \s \S ] * ?[ ^ ` ] ) \s * \1(? ! ` ) / ,
461
+ attr : / ^ ( { { ) ( .* ) } } / ,
461
462
br : / ^ { 2 , } \n (? ! \s * $ ) / ,
462
463
del : noop ,
463
464
text : / ^ [ \s \S ] + ?(? = [ \\ < ! \[ _ * ` ] | { 2 , } \n | $ ) /
@@ -661,7 +662,15 @@ InlineLexer.prototype.output = function(src) {
661
662
// code
662
663
if ( cap = this . rules . code . exec ( src ) ) {
663
664
src = src . substring ( cap [ 0 ] . length ) ;
664
- out += this . renderer . codespan ( escape ( cap [ 2 ] , true ) ) ;
665
+
666
+ var attr ;
667
+ if ( attr_cap = this . rules . attr . exec ( src ) ) {
668
+ src = src . substring ( attr_cap [ 0 ] . length ) ;
669
+ attr = attr_cap [ 2 ] ;
670
+ }
671
+
672
+ out += this . renderer . codespan ( escape ( cap [ 2 ] , true ) , attr ) ;
673
+
665
674
continue ;
666
675
}
667
676
@@ -854,7 +863,10 @@ Renderer.prototype.em = function(text) {
854
863
return '<em>' + text + '</em>' ;
855
864
} ;
856
865
857
- Renderer . prototype . codespan = function ( text ) {
866
+ Renderer . prototype . codespan = function ( text , attr ) {
867
+ if ( attr ) {
868
+ return '<code class="' + attr + '">' + text + '</code>' ;
869
+ }
858
870
return '<code>' + text + '</code>' ;
859
871
} ;
860
872
Original file line number Diff line number Diff line change 1
1
< p > < code > <test a="</ code > content of attribute < code > "></ code > </ p >
2
2
3
+ < p > < code class ="lang "> code with an attribute</ code > </ p >
4
+
3
5
< p > Fix for backticks within HTML tag: < span attr ='`ticks` '> like this</ span > </ p >
4
6
5
7
< p > Here's how you put < code > `backticks`</ code > in a code span.</ p >
Original file line number Diff line number Diff line change 1
1
`<test a="` content of attribute `">`
2
2
3
+ `code with an attribute`{{lang}}
4
+
3
5
Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span>
4
6
5
7
Here's how you put `` `backticks` `` in a code span.
You can’t perform that action at this time.
0 commit comments