This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 3 files changed +64
-3
lines changed
3 files changed +64
-3
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ Doc.prototype = {
105
105
IS_URL = / ^ ( h t t p s ? : \/ \/ | f t p s ? : \/ \/ | m a i l t o : | \. | \/ ) / ,
106
106
IS_ANGULAR = / ^ ( a p i \/ ) ? ( a n g u l a r | n g | A U T O ) \. / ,
107
107
IS_HASH = / ^ # / ,
108
- parts = trim ( text ) . split ( / ( < p r e > [ \s \S ] * ?< \/ p r e > | < d o c : e x a m p l e ( \S * ) .* ?> [ \s \S ] * ?< \/ d o c : e x a m p l e > | < e x a m p l e [ ^ > ] * > [ \s \S ] * ?< \/ e x a m p l e > ) / ) ,
108
+ parts = trim ( text ) . split ( / ( < p r e . * ? > [ \s \S ] * ?< \/ p r e > | < d o c : e x a m p l e ( \S * ) .* ?> [ \s \S ] * ?< \/ d o c : e x a m p l e > | < e x a m p l e [ ^ > ] * > [ \s \S ] * ?< \/ e x a m p l e > ) / ) ,
109
109
seq = 0 ,
110
110
placeholderMap = { } ;
111
111
@@ -191,9 +191,9 @@ Doc.prototype = {
191
191
192
192
return placeholder ( example . toHtml ( ) ) ;
193
193
} ) .
194
- replace ( / ^ < p r e > ( [ \s \S ] * ?) < \/ p r e > / mi, function ( _ , content ) {
194
+ replace ( / ^ < p r e ( . * ? ) > ( [ \s \S ] * ?) < \/ p r e > / mi, function ( _ , attrs , content ) {
195
195
return placeholder (
196
- '<pre class="prettyprint linenums">' +
196
+ '<pre' + attrs + ' class="prettyprint linenums">' +
197
197
content . replace ( / < / g, '<' ) . replace ( / > / g, '>' ) +
198
198
'</pre>' ) ;
199
199
} ) .
Original file line number Diff line number Diff line change @@ -241,3 +241,22 @@ ul.events > li > h3 {
241
241
.type-hint-number {
242
242
background : rgb (189 , 63 , 66 );
243
243
}
244
+
245
+ .syntax-links {
246
+ background : # eee ;
247
+ border : 1px solid # ddd ;
248
+ text-align : right;
249
+ padding : 1em ;
250
+ border-bottom : 0 ;
251
+ border-top-left-radius : 4px ;
252
+ border-top-right-radius : 4px ;
253
+ }
254
+
255
+ .syntax-links a {
256
+ margin-left : 10px ;
257
+ }
258
+
259
+ .syntax-links + pre {
260
+ border-top-left-radius : 0 ;
261
+ border-top-right-radius : 0 ;
262
+ }
Original file line number Diff line number Diff line change @@ -48,6 +48,48 @@ directive.dropdownToggle =
48
48
} ;
49
49
} ] ;
50
50
51
+ directive . syntax = function ( ) {
52
+ return {
53
+ restrict : 'A' ,
54
+ link : function ( scope , element , attrs ) {
55
+ function makeLink ( type , text , link , icon ) {
56
+ return '<a href="' + link + '" class="btn syntax-' + type + '" target="_blank" rel="nofollow">' +
57
+ '<span class="' + icon + '"></span> ' + text +
58
+ '</a>' ;
59
+ } ;
60
+ var html = '<nav class="syntax-links">' ;
61
+ var types = {
62
+ 'github' : {
63
+ text : 'View on Github' ,
64
+ key : 'syntaxGithub' ,
65
+ icon : 'icon-github'
66
+ } ,
67
+ 'plunkr' : {
68
+ text : 'View on Plunkr' ,
69
+ key : 'syntaxPlunkr' ,
70
+ icon : 'icon-arrow-down'
71
+ } ,
72
+ 'jsfiddle' : {
73
+ text : 'View on JSFiddle' ,
74
+ key : 'syntaxFiddle' ,
75
+ icon : 'icon-cloud'
76
+ }
77
+ } ;
78
+ for ( var type in types ) {
79
+ var data = types [ type ] ;
80
+ var link = attrs [ data . key ] ;
81
+ if ( link ) {
82
+ html += makeLink ( type , data . text , link , data . icon ) ;
83
+ }
84
+ } ;
85
+ html += '</nav>' ;
86
+ var nav = angular . element ( html ) ;
87
+ var node = element [ 0 ] ;
88
+ var par = node . parentNode ;
89
+ par . insertBefore ( nav [ 0 ] , node ) ;
90
+ }
91
+ }
92
+ }
51
93
52
94
directive . tabbable = function ( ) {
53
95
return {
You can’t perform that action at this time.
0 commit comments