@@ -3170,15 +3170,15 @@ process.umask = function() { return 0; };
31703170var diff = printerUtils . diffHighlight ( oldLine . content , newLine . content , that . config ) ;
31713171
31723172processedOldLines +=
3173- that . makeLineHtml ( deleteType , oldLine . oldNumber , oldLine . newNumber ,
3173+ that . makeLineHtml ( file . isCombined , deleteType , oldLine . oldNumber , oldLine . newNumber ,
31743174diff . first . line , diff . first . prefix ) ;
31753175processedNewLines +=
3176- that . makeLineHtml ( insertType , newLine . oldNumber , newLine . newNumber ,
3176+ that . makeLineHtml ( file . isCombined , insertType , newLine . oldNumber , newLine . newNumber ,
31773177diff . second . line , diff . second . prefix ) ;
31783178}
31793179
31803180lines += processedOldLines + processedNewLines ;
3181- lines += that . _processLines ( oldLines . slice ( common ) , newLines . slice ( common ) ) ;
3181+ lines += that . _processLines ( file . isCombined , oldLines . slice ( common ) , newLines . slice ( common ) ) ;
31823182} ) ;
31833183
31843184oldLines = [ ] ;
@@ -3195,9 +3195,9 @@ process.umask = function() { return 0; };
31953195}
31963196
31973197if ( line . type === diffParser . LINE_TYPE . CONTEXT ) {
3198- lines += that . makeLineHtml ( line . type , line . oldNumber , line . newNumber , escapedLine ) ;
3198+ lines += that . makeLineHtml ( file . isCombined , line . type , line . oldNumber , line . newNumber , escapedLine ) ;
31993199} else if ( line . type === diffParser . LINE_TYPE . INSERTS && ! oldLines . length ) {
3200- lines += that . makeLineHtml ( line . type , line . oldNumber , line . newNumber , escapedLine ) ;
3200+ lines += that . makeLineHtml ( file . isCombined , line . type , line . oldNumber , line . newNumber , escapedLine ) ;
32013201} else if ( line . type === diffParser . LINE_TYPE . DELETES ) {
32023202oldLines . push ( line ) ;
32033203} else if ( line . type === diffParser . LINE_TYPE . INSERTS && Boolean ( oldLines . length ) ) {
@@ -3214,37 +3214,46 @@ process.umask = function() { return 0; };
32143214} ) . join ( '\n' ) ;
32153215} ;
32163216
3217- LineByLinePrinter . prototype . _processLines = function ( oldLines , newLines ) {
3217+ LineByLinePrinter . prototype . _processLines = function ( isCombined , oldLines , newLines ) {
32183218var lines = '' ;
32193219
32203220for ( var i = 0 ; i < oldLines . length ; i ++ ) {
32213221var oldLine = oldLines [ i ] ;
32223222var oldEscapedLine = utils . escape ( oldLine . content ) ;
3223- lines += this . makeLineHtml ( oldLine . type , oldLine . oldNumber , oldLine . newNumber , oldEscapedLine ) ;
3223+ lines += this . makeLineHtml ( isCombined , oldLine . type , oldLine . oldNumber , oldLine . newNumber , oldEscapedLine ) ;
32243224}
32253225
32263226for ( var j = 0 ; j < newLines . length ; j ++ ) {
32273227var newLine = newLines [ j ] ;
32283228var newEscapedLine = utils . escape ( newLine . content ) ;
3229- lines += this . makeLineHtml ( newLine . type , newLine . oldNumber , newLine . newNumber , newEscapedLine ) ;
3229+ lines += this . makeLineHtml ( isCombined , newLine . type , newLine . oldNumber , newLine . newNumber , newEscapedLine ) ;
32303230}
32313231
32323232return lines ;
32333233} ;
32343234
3235- LineByLinePrinter . prototype . makeLineHtml = function ( type , oldNumber , newNumber , content , prefix ) {
3235+ LineByLinePrinter . prototype . makeLineHtml = function ( isCombined , type , oldNumber , newNumber , content , possiblePrefix ) {
32363236var lineNumberTemplate = hoganUtils . render ( baseTemplatesPath , 'numbers' , {
32373237oldNumber :utils . valueOrEmpty ( oldNumber ) ,
32383238newNumber :utils . valueOrEmpty ( newNumber )
32393239} ) ;
32403240
3241+ var lineWithoutPrefix = content ;
3242+ var prefix = possiblePrefix ;
3243+
3244+ if ( ! prefix ) {
3245+ var lineWithPrefix = printerUtils . separatePrefix ( isCombined , content ) ;
3246+ prefix = lineWithPrefix . prefix ;
3247+ lineWithoutPrefix = lineWithPrefix . line ;
3248+ }
3249+
32413250return hoganUtils . render ( genericTemplatesPath , 'line' ,
32423251{
32433252type :type ,
32443253lineClass :'d2h-code-linenumber' ,
32453254contentClass :'d2h-code-line' ,
3246- prefix :prefix && utils . convertWhiteSpaceToNonBreakingSpace ( prefix ) ,
3247- content :content && utils . convertWhiteSpaceToNonBreakingSpace ( content ) ,
3255+ prefix :prefix ,
3256+ content :lineWithoutPrefix ,
32483257lineNumber :lineNumberTemplate
32493258} ) ;
32503259} ;
@@ -3277,6 +3286,24 @@ process.umask = function() { return 0; };
32773286function PrinterUtils ( ) {
32783287}
32793288
3289+ PrinterUtils . prototype . separatePrefix = function ( isCombined , line ) {
3290+ var prefix ;
3291+ var lineWithoutPrefix ;
3292+
3293+ if ( isCombined ) {
3294+ prefix = line . substring ( 0 , 2 ) ;
3295+ lineWithoutPrefix = line . substring ( 2 ) ;
3296+ } else {
3297+ prefix = line . substring ( 0 , 1 ) ;
3298+ lineWithoutPrefix = line . substring ( 1 ) ;
3299+ }
3300+
3301+ return {
3302+ 'prefix' :prefix ,
3303+ 'line' :lineWithoutPrefix
3304+ } ;
3305+ } ;
3306+
32803307PrinterUtils . prototype . getHtmlId = function ( file ) {
32813308var hashCode = function ( text ) {
32823309var i , chr , len ;
@@ -3747,18 +3774,18 @@ process.umask = function() { return 0; };
37473774var diff = printerUtils . diffHighlight ( oldLine . content , newLine . content , that . config ) ;
37483775
37493776fileHtml . left +=
3750- that . generateSingleLineHtml ( deleteType , oldLine . oldNumber ,
3777+ that . generateSingleLineHtml ( file . isCombined , deleteType , oldLine . oldNumber ,
37513778diff . first . line , diff . first . prefix ) ;
37523779fileHtml . right +=
3753- that . generateSingleLineHtml ( insertType , newLine . newNumber ,
3780+ that . generateSingleLineHtml ( file . isCombined , insertType , newLine . newNumber ,
37543781diff . second . line , diff . second . prefix ) ;
37553782}
37563783
37573784if ( max > common ) {
37583785var oldSlice = oldLines . slice ( common ) ;
37593786var newSlice = newLines . slice ( common ) ;
37603787
3761- var tmpHtml = that . processLines ( oldSlice , newSlice ) ;
3788+ var tmpHtml = that . processLines ( file . isCombined , oldSlice , newSlice ) ;
37623789fileHtml . left += tmpHtml . left ;
37633790fileHtml . right += tmpHtml . right ;
37643791}
@@ -3779,11 +3806,11 @@ process.umask = function() { return 0; };
37793806}
37803807
37813808if ( line . type === diffParser . LINE_TYPE . CONTEXT ) {
3782- fileHtml . left += that . generateSingleLineHtml ( line . type , line . oldNumber , escapedLine , prefix ) ;
3783- fileHtml . right += that . generateSingleLineHtml ( line . type , line . newNumber , escapedLine , prefix ) ;
3809+ fileHtml . left += that . generateSingleLineHtml ( file . isCombined , line . type , line . oldNumber , escapedLine , prefix ) ;
3810+ fileHtml . right += that . generateSingleLineHtml ( file . isCombined , line . type , line . newNumber , escapedLine , prefix ) ;
37843811} else if ( line . type === diffParser . LINE_TYPE . INSERTS && ! oldLines . length ) {
3785- fileHtml . left += that . generateSingleLineHtml ( diffParser . LINE_TYPE . CONTEXT , '' , '' , '' ) ;
3786- fileHtml . right += that . generateSingleLineHtml ( line . type , line . newNumber , escapedLine , prefix ) ;
3812+ fileHtml . left += that . generateSingleLineHtml ( file . isCombined , diffParser . LINE_TYPE . CONTEXT , '' , '' , '' ) ;
3813+ fileHtml . right += that . generateSingleLineHtml ( file . isCombined , line . type , line . newNumber , escapedLine , prefix ) ;
37873814} else if ( line . type === diffParser . LINE_TYPE . DELETES ) {
37883815oldLines . push ( line ) ;
37893816} else if ( line . type === diffParser . LINE_TYPE . INSERTS && Boolean ( oldLines . length ) ) {
@@ -3800,7 +3827,7 @@ process.umask = function() { return 0; };
38003827return fileHtml ;
38013828} ;
38023829
3803- SideBySidePrinter . prototype . processLines = function ( oldLines , newLines ) {
3830+ SideBySidePrinter . prototype . processLines = function ( isCombined , oldLines , newLines ) {
38043831var that = this ;
38053832var fileHtml = { } ;
38063833fileHtml . left = '' ;
@@ -3826,14 +3853,14 @@ process.umask = function() { return 0; };
38263853}
38273854
38283855if ( oldLine && newLine ) {
3829- fileHtml . left += that . generateSingleLineHtml ( oldLine . type , oldLine . oldNumber , oldContent , oldPrefix ) ;
3830- fileHtml . right += that . generateSingleLineHtml ( newLine . type , newLine . newNumber , newContent , newPrefix ) ;
3856+ fileHtml . left += that . generateSingleLineHtml ( isCombined , oldLine . type , oldLine . oldNumber , oldContent , oldPrefix ) ;
3857+ fileHtml . right += that . generateSingleLineHtml ( isCombined , newLine . type , newLine . newNumber , newContent , newPrefix ) ;
38313858} else if ( oldLine ) {
3832- fileHtml . left += that . generateSingleLineHtml ( oldLine . type , oldLine . oldNumber , oldContent , oldPrefix ) ;
3833- fileHtml . right += that . generateSingleLineHtml ( diffParser . LINE_TYPE . CONTEXT , '' , '' , '' ) ;
3859+ fileHtml . left += that . generateSingleLineHtml ( isCombined , oldLine . type , oldLine . oldNumber , oldContent , oldPrefix ) ;
3860+ fileHtml . right += that . generateSingleLineHtml ( isCombined , diffParser . LINE_TYPE . CONTEXT , '' , '' , '' ) ;
38343861} else if ( newLine ) {
3835- fileHtml . left += that . generateSingleLineHtml ( diffParser . LINE_TYPE . CONTEXT , '' , '' , '' ) ;
3836- fileHtml . right += that . generateSingleLineHtml ( newLine . type , newLine . newNumber , newContent , newPrefix ) ;
3862+ fileHtml . left += that . generateSingleLineHtml ( isCombined , diffParser . LINE_TYPE . CONTEXT , '' , '' , '' ) ;
3863+ fileHtml . right += that . generateSingleLineHtml ( isCombined , newLine . type , newLine . newNumber , newContent , newPrefix ) ;
38373864} else {
38383865console . error ( 'How did it get here?' ) ;
38393866}
@@ -3842,14 +3869,23 @@ process.umask = function() { return 0; };
38423869return fileHtml ;
38433870} ;
38443871
3845- SideBySidePrinter . prototype . generateSingleLineHtml = function ( type , number , content , prefix ) {
3872+ SideBySidePrinter . prototype . generateSingleLineHtml = function ( isCombined , type , number , content , possiblePrefix ) {
3873+ var lineWithoutPrefix = content ;
3874+ var prefix = possiblePrefix ;
3875+
3876+ if ( ! prefix ) {
3877+ var lineWithPrefix = printerUtils . separatePrefix ( isCombined , content ) ;
3878+ prefix = lineWithPrefix . prefix ;
3879+ lineWithoutPrefix = lineWithPrefix . line ;
3880+ }
3881+
38463882return hoganUtils . render ( genericTemplatesPath , 'line' ,
38473883{
38483884type :type ,
38493885lineClass :'d2h-code-side-linenumber' ,
38503886contentClass :'d2h-code-side-line' ,
3851- prefix :prefix && utils . convertWhiteSpaceToNonBreakingSpace ( prefix ) ,
3852- content :content && utils . convertWhiteSpaceToNonBreakingSpace ( content ) ,
3887+ prefix :prefix ,
3888+ content :lineWithoutPrefix ,
38533889lineNumber :number
38543890} ) ;
38553891} ;
@@ -3908,10 +3944,6 @@ module.exports = global.browserTemplates;
39083944function Utils ( ) {
39093945}
39103946
3911- Utils . prototype . convertWhiteSpaceToNonBreakingSpace = function ( str ) {
3912- return str . slice ( 0 ) . replace ( / / g, ' ' ) ;
3913- } ;
3914-
39153947Utils . prototype . escape = function ( str ) {
39163948return str . slice ( 0 )
39173949. replace ( / & / g, '&' )