File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -151,10 +151,19 @@ $(function () {
151
151
152
152
if ( source . length ) {
153
153
source . find ( '.syntaxhighlighter .gutter .line' ) . each ( function ( i , el ) {
154
+ var line = $ ( el ) ;
154
155
var res ;
155
- if ( res = el . className . match ( / ( ^ | \s ) n u m b e r ( \d + ) ( \s | $ ) / ) ) {
156
- var id = 'L' + res [ 2 ] ;
157
- $ ( el ) . contents ( ) . wrap ( '<a href="#' + id + '" id="' + id + '"></a>' ) ;
156
+ if ( res = line . attr ( 'class' ) . match ( / ( ^ | \s ) n u m b e r ( \d + ) ( \s | $ ) / ) ) {
157
+ var linenr = res [ 2 ] ;
158
+ var id = 'L' + linenr ;
159
+ line . contents ( ) . wrap ( '<a href="#' + id + '" id="' + id + '"></a>' ) ;
160
+ var link = line . children ( 'a' ) ;
161
+ link . click ( function ( e ) {
162
+ e . preventDefault ( ) ;
163
+ link . removeAttr ( 'id' ) ;
164
+ document . location . hash = '#' + id ;
165
+ link . attr ( 'id' , id ) ;
166
+ } ) ;
158
167
}
159
168
} ) ;
160
169
You can’t perform that action at this time.
0 commit comments