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 () {
150150
151151 if ( source . length ) {
152152 source . find ( '.syntaxhighlighter .gutter .line' ) . each ( function ( i , el ) {
153+ var line = $ ( el ) ;
153154 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+ } ) ;
157166 }
158167 } ) ;
159168
You can’t perform that action at this time.
0 commit comments