diff2html icon indicating copy to clipboard operation
diff2html copied to clipboard

[Question] Is it possible to use diff2html just for code highlighting?

Open rostykode opened this issue 9 years ago • 3 comments

Hello,

In some specific cases along with diff-view I need to show code as-is, and I want to show it in the same way as diff-view doing it.

Right now I using some tricky solution where I creating patch compared with empty string:

var diff = JsDiff.createPatch('Diff Name', '', code_here, '', '');
var diff2htmlUi = new Diff2HtmlUI({diff: diff});
diff2htmlUi.draw('#line-by-line', {inputFormat: 'diff', outputFormat: 'line-by-line', showFiles: false, matching: 'lines'});
diff2htmlUi.highlightCode('#line-by-line');

And it works in following way: firefox_2017-11-07_13-10-54

And it's okay for me, but in this case I would like to remove these two UI elements (header and "newline" marks) and left only line number and code: firefox_2017-11-07_13-10-54_n

Is there any way to achieve that using this approach, or we have some better way to do that.

Thanks.

rostykode avatar Nov 07 '17 11:11 rostykode

I hope that I can do it using template overrides for these specific cases, but maybe we have some better way to do that?

rostykode avatar Nov 07 '17 11:11 rostykode

With a first look I think you could do that with overriding generic-line to remove the prefixes, then disabling the comparison of lines and also removing the header line from the json. Let me know if you need any other tips.

rtfpessoa avatar Nov 17 '17 21:11 rtfpessoa

@rtfpessoa, thanks a lot. That's all what I need.

rostykode avatar Nov 26 '17 15:11 rostykode