Skip to content

Commit 15aea42

Browse files
committed
more output formats & side by side diff
1 parent f9ebd73 commit 15aea42

File tree

7 files changed

+259
-71
lines changed

7 files changed

+259
-71
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This project uses [diff2html](https://github.com/rtfpessoa/diff2html) as base.
1818

1919
* GitHub like style
2020

21-
## Real Example
21+
## Online Example
2222

2323
> Go to [Diff2HTML](http://rtfpessoa.github.io/diff2html/)
2424
@@ -38,12 +38,14 @@ This project uses [diff2html](https://github.com/rtfpessoa/diff2html) as base.
3838

3939
Options:
4040

41-
-h, --help output usage information
42-
-V, --version output the version number
43-
-i, --input [file] Diff input file.
44-
-o, --output [file] Output to file path. Defaults to stdout.
45-
-l, --line Line by Line diff.
46-
-s, --side Side by Side diff.
41+
-h, --help output usage information
42+
-V, --version output the version number
43+
-i, --input [file] Diff input file.
44+
-o, --output [file] Output to file path. Defaults to stdout.
45+
-p, --preview Open preview in the browser.
46+
-l, --line Line by Line diff.
47+
-s, --side Side by Side diff.
48+
-j, --json Export diff in json format.
4749

4850
## Contribution
4951

dist/diff2html.css

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Diff to HTML (diff2html.css)
44
* Author: rtfpessoa
55
* Date: Friday 29 August 2014
6-
* Last Update: Saturday 6 September 2014
6+
* Last Update: Sunday 14 September 2014
77
*
88
*/
99

@@ -28,7 +28,7 @@
2828
}
2929

3030
.d2h-file-stats {
31-
display: inline-block;
31+
display: inline;
3232
font-size: 12px;
3333
text-align: center;
3434
max-width: 15%;
@@ -53,7 +53,7 @@
5353
}
5454

5555
.d2h-file-name {
56-
display: inline-flex;
56+
display: inline;
5757
height: 33px;
5858
line-height: 33px;
5959
max-width: 80%;
@@ -68,6 +68,22 @@
6868
font-size: 12px;
6969
height: 18px;
7070
line-height: 18px;
71+
width: 100%;
72+
}
73+
74+
.d2h-files-diff {
75+
width: 100%;
76+
}
77+
78+
.d2h-file-diff {
79+
overflow-x: scroll;
80+
}
81+
82+
.d2h-file-side-diff {
83+
display: inline-block;
84+
overflow-x: scroll;
85+
width: 50%;
86+
margin-right: -4px;
7187
}
7288

7389
.d2h-code-line {
@@ -76,11 +92,20 @@
7692
padding-right: 10px;
7793
height: 18px;
7894
line-height: 18px;
79-
width: 557px;
80-
overflow: scroll;
95+
margin-left: 80px;
8196
}
8297

83-
.d2h-code-line del {
98+
.d2h-code-side-line {
99+
white-space: pre;
100+
padding-left: 10px;
101+
padding-right: 10px;
102+
height: 18px;
103+
line-height: 18px;
104+
margin-left: 50px;
105+
}
106+
107+
.d2h-code-line del,
108+
.d2h-code-side-line del {
84109
display: inline-block;
85110
margin-top: -1px;
86111
text-decoration: none;
@@ -89,7 +114,8 @@
89114
border-radius: 0.2em;
90115
}
91116

92-
.d2h-code-line ins {
117+
.d2h-code-line ins,
118+
.d2h-code-side-line ins {
93119
display: inline-block;
94120
margin-top: -1px;
95121
text-decoration: none;
@@ -98,22 +124,53 @@
98124
border-radius: 0.2em;
99125
}
100126

127+
.line-num1 {
128+
display: inline-block;
129+
float: left;
130+
width: 30px;
131+
overflow: hidden;
132+
text-overflow: ellipsis;
133+
}
134+
135+
.line-num2 {
136+
display: inline-block;
137+
float: right;
138+
width: 30px;
139+
overflow: hidden;
140+
text-overflow: ellipsis;
141+
}
142+
101143
.d2h-code-linenumber {
102-
width: 1%;
103-
min-width: 30px;
144+
position: absolute;
145+
width: 2%;
146+
min-width: 65px;
104147
padding-left: 10px;
105148
padding-right: 10px;
106149
height: 18px;
107150
line-height: 18px;
151+
background-color: #fff;
108152
color: rgba(0, 0, 0, 0.3);
109153
text-align: right;
110154
border: solid #eeeeee;
111-
border-width: 0 1px 0 0;
155+
border-width: 0 1px 0 1px;
112156
cursor: pointer;
113157
}
114158

115-
.d2h-code-linenumber:not(:first-child) {
159+
.d2h-code-side-linenumber {
160+
position: absolute;
161+
width: 35px;
162+
padding-left: 10px;
163+
padding-right: 10px;
164+
height: 18px;
165+
line-height: 18px;
166+
background-color: #fff;
167+
color: rgba(0, 0, 0, 0.3);
168+
text-align: right;
169+
border: solid #eeeeee;
116170
border-width: 0 1px 0 1px;
171+
cursor: pointer;
172+
overflow: hidden;
173+
text-overflow: ellipsis;
117174
}
118175

119176
.d2h-del {

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Diff to HTML (template.html)
99
Author: rtfpessoa
1010
Date: Friday 29 August 2014
11-
Last Update: Saturday 6 September 2014
11+
Last Update: Sunday 14 September 2014
1212
-->
1313

1414
<link rel="stylesheet" type="text/css" href="diff2html.css">

dist/template.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Diff to HTML by rtfpessoa</title>
6+
7+
<!--
8+
Diff to HTML (template.html)
9+
Author: rtfpessoa
10+
Date: Friday 29 August 2014
11+
Last Update: Sunday 14 September 2014
12+
-->
13+
14+
<link rel="stylesheet" type="text/css" href="{{css}}">
15+
</head>
16+
<body style="text-align: center; font-family: 'Source Sans Pro',sans-serif;">
17+
<h1>Diff to HTML by <a href="https://github.com/rtfpessoa">rtfpessoa</a></h1>
18+
19+
<div>
20+
{{diff}}
21+
</div>
22+
</body>
23+
</html>

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
{
22
"name": "diff2html",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44

55
"homepage": "https://www.github.com/rtfpessoa/diff2html-nodejs",
66
"description": "Fast Diff to colorized HTML",
77
"keywords": [
88
"git",
99
"diff",
1010
"pretty",
11+
"side",
12+
"line",
13+
"side-by-side",
14+
"line-by-line",
15+
"character",
16+
"highlight",
17+
"pretty",
1118
"color",
1219
"html",
1320
"diff2html",

0 commit comments

Comments
 (0)