MediaWiki:Gadget-codeLineNumbers.js

// ( function ( mw, $ ) { var arrLines = $( '.mw-highlight pre' ).html.split( '\n' );  var intPadding = String( arrLines.length ).length;  arrLines.forEach( ( line, numb ) => { var paddedIndex = String( numb + 1 ).padStart( intPadding, ' ' ); var newLine = ' ' + paddedIndex + ' ' + line.trimStart; if ( line !== '' ) { $( '.mw-highlight pre' ).html( $( '.mw-highlight pre' ).html.replace( line, newLine ) ); } else { /* Skip it for now until I can figure out how to inject the number at the right spot */ } } ); } )( mediaWiki, jQuery ); //