Git Product home page Git Product logo

Comments (11)

rtfpessoa avatar rtfpessoa commented on May 24, 2024

The code was initially done to Parse only git diffs. Since they are similar I am thinking of doing compatibility for both but did not git time yet.

I will look at this when I get some time today or tomorrow.

from diff2html.

adius avatar adius commented on May 24, 2024

Actually the git diff is just a normal unidiff.
Every line which does not start with a space, +, - or @ is just a comment....
Thanks for looking into this!

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

@adius This was fixed in #73 let me know if you have any other cases where it fails.

Released under version 2.0.0-beta18.

from diff2html.

beebek avatar beebek commented on May 24, 2024

I have following code snippet for which diffs are not getting highlighted.

    <script>
        var lineDiff = `diff a/sample b/sample
--- a/sample
+++ b/sample
@@ -11 @@
-test
+test1r`;
        document.addEventListener("DOMContentLoaded", function() {
            var diff2htmlUi = new Diff2HtmlUI({diff: lineDiff});
            diff2htmlUi.draw('#line-by-line', {inputFormat: 'json', outputFormat: 'line-by-line', matching:'words'});
            diff2htmlUi.highlightCode('#line-by-line');
        });
    </script>

screen shot 2017-10-09 at 9 40 01 am

But if there is preceding or succeeding line, the diffs are getting highlighted. Am I missing something?
Checked with diff2html ie diff a/sample b/sample | diff2html -i stdin --style line which is giving proper highlighted html page.

    var lineDiff = `diff a/sample b/sample
--- a/sample
+++ b/sample
@@ -11 @@
-test
+test1r
this_will_highlight_above_change`;

screen shot 2017-10-09 at 9 39 44 am

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

Hi @beebek you are drawing in #line-by-line and highlighting on #side-by-side

from diff2html.

beebek avatar beebek commented on May 24, 2024

Hi, @rtfpessoa sorry for the typo, actually I am drawing on #line-by-line div. Updated the sinppet.
This is happening for outputFormat: 'side-by-side' as well. Found difference between the div's and span's.

<!-- not highlighting properly -->
<td class="d2h-code-side-linenumber d2h-del">0</td>
<td class="d2h-del">      
    <div class="d2h-code-side-line d2h-del">
        <span class="d2h-code-line-ctn hljs diff">
            <span class="hljs-deletion">-test</span>
        </span>
    </div>    
</td>


<!-- Properly highlighted -->
<td class="d2h-code-side-linenumber d2h-del">0</td>
<td class="d2h-del">      
    <div class="d2h-code-side-line d2h-del">
        <span class="d2h-code-line-prefix">-</span>
        <span class="d2h-code-line-ctn hljs bash">
            <del><span class="hljs-built_in">test</span></del>
        </span>
    </div>    
</td>

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

Also I am not sure what you want to highlight. That is not code so not sure what is the highlight

from diff2html.

beebek avatar beebek commented on May 24, 2024

Thanks for that quick reply. Please check this.
screen shot 2017-10-09 at 11 03 09 am

    <script>
        var lineDiff = 
'diff -U 1 /tmp/asdfjson /tmp/asdfasdf.F1PQ6n.json\n' +
'--- /tmp/asdf.json   2017-10-06 14:09:23.000000000 -0700\n' +
'+++ /tmp/asdf.json   2017-10-06 14:09:23.000000000 -0700\n' +
'@@ -4141,3 +4197,3 @@\n' +
'-               "description":""Experience null",\n' +
'+               "description":null,\n' +
'addition\n' +
'@@ -4173,3 +4229,3 @@\n' +
'-               "description":"false null",\n' +
'+               "description":null,\n' +
'addition\n' +
'\n';
        document.addEventListener("DOMContentLoaded", function() {
            var diff2htmlUi = new Diff2HtmlUI({diff: lineDiff});
            diff2htmlUi.draw('#side-by-side', {inputFormat: 'json', outputFormat: 'side-by-side', matching:'words'});
            diff2htmlUi.highlightCode('#side-by-side');
        });
    </script>

if I do not have extra line 'e.g. addition\n' + above or below the changes, it is not highlighting the differences.
screen shot 2017-10-09 at 11 13 41 am

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

Ahh I see what you mean now.

Highlight is a very hardcore feature since it relies on filenames to detect the language and with partial snippets the job is even harder. I am using highlight.js but this case might just be a problem with the few information.

Since the filename is not correctly grabbed the job of the highlight is even harder. So I guess there is not much to do here.

Are you using git diff or diff from gnu tools?

from diff2html.

beebek avatar beebek commented on May 24, 2024

I am using diff. The result is just a diff between two files.

$ diff --version
diff (GNU diffutils) 2.8.1
...
...

The same diff content is correctly rendered by diff2html from terminal though. e.g.
diff -U 0 /tmp/content1.json /tmp/content2.json | diff2html -i stdin --style side

from diff2html.

rtfpessoa avatar rtfpessoa commented on May 24, 2024

Wow that is weird. They are both the same. Just a CLI wrapper.

from diff2html.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.