2626showdown . subParser ( 'codeSpans' , function ( text ) {
2727 'use strict' ;
2828
29+ //special case -> literal html code tag
30+ text = text . replace ( / ( < c o d e [ ^ > < ] * ?> ) ( [ ^ ] * ?) < \/ c o d e > / g, function ( wholeMatch , tag , c ) {
31+ c = c . replace ( / ^ ( [ \t ] * ) / g, '' ) ; // leading whitespace
32+ c = c . replace ( / [ \t ] * $ / g, '' ) ; // trailing whitespace
33+ c = showdown . subParser ( 'encodeCode' ) ( c ) ;
34+ return tag + c + '</code>' ;
35+ } ) ;
36+
2937 /*
3038 text = text.replace(/
3139 (^|[^\\]) // Character before opening ` can't be a backslash
@@ -38,15 +46,14 @@ showdown.subParser('codeSpans', function (text) {
3846 (?!`)
3947 /gm, function(){...});
4048 */
41-
42- text = text . replace ( / ( ^ | [ ^ \\ ] ) ( ` + ) ( [ ^ \r ] * ? [ ^ ` ] ) \2 (? ! ` ) / gm , function ( wholeMatch , m1 , m2 , m3 ) {
43- var c = m3 ;
44- c = c . replace ( / ^ ( [ \t ] * ) / g, '' ) ; // leading whitespace
45- c = c . replace ( / [ \t ] * $ / g, '' ) ; // trailing whitespace
46- c = showdown . subParser ( 'encodeCode' ) ( c ) ;
47- return m1 + '<code>' + c + '</code>' ;
49+ text = text . replace ( / ( ^ | [ ^ \\ ] ) ( ` + ) ( [ ^ \r ] * ? [ ^ ` ] ) \2 (? ! ` ) / gm ,
50+ function ( wholeMatch , m1 , m2 , m3 ) {
51+ var c = m3 ;
52+ c = c . replace ( / ^ ( [ \t ] * ) / g, '' ) ; // leading whitespace
53+ c = c . replace ( / [ \t ] * $ / g, '' ) ; // trailing whitespace
54+ c = showdown . subParser ( 'encodeCode' ) ( c ) ;
55+ return m1 + '<code>' + c + '</code>' ;
4856 } ) ;
4957
5058 return text ;
51-
5259} ) ;
0 commit comments