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