Comments (11)
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.
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.
@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.
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>
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`;
from diff2html.
Hi @beebek you are drawing in #line-by-line
and highlighting on #side-by-side
from diff2html.
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.
Also I am not sure what you want to highlight. That is not code so not sure what is the highlight
from diff2html.
Thanks for that quick reply. Please check this.
<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.
from diff2html.
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.
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.
Wow that is weird. They are both the same. Just a CLI wrapper.
from diff2html.
Related Issues (20)
- side-by-side diff is broken in Firefox HOT 2
- Output of diff not preserving escaped HTML characters HOT 3
- Can't run diff2html-cli on linux docker container HOT 2
- Make templates more flexible HOT 4
- How to remove the serial number of blank lines HOT 3
- Blank context lines are ignored by diff parser HOT 1
- Vertical align mismatch between inserted/deleted text and matching
- Code breaking when there is no change in a line HOT 3
- Is it possible to generate single html report for multiple git repos? HOT 1
- Unknown argument: diff.txt HOT 1
- 12341
- Suggest new option to Diff2Html library HOT 1
- If the diffString contains special symbols, the page will report an error HOT 1
- Diff2html fails with Error: Cannot find module 'tslib'
- Slim version doesn't fallback to 'plaintext' on unsupported file type HOT 4
- File list links are not working in Angular integration for diff2html-ui HOT 2
- the `multiline comment` syntax can not highlight correctly HOT 1
- CSS not working inside shadow DOM
- Feature request: option to only show first n files HOT 3
- when execute git diff --word-diff-regex=. ,diff2html is not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diff2html.