diffy 3.4.3 → 3.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/CONTRIBUTORS +1 -0
- data/lib/diffy/html_formatter.rb +5 -10
- data/lib/diffy/version.rb +1 -1
- data/spec/diffy_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47c21389e70aed2e702069a3dbe38eecc74bbc88f37f2ae9f82f26b8bafdea62
|
4
|
+
data.tar.gz: b9ac4fc40b5b9b9ec06da6006295733a3d0c5f20c60ba7d58d8d232e7a10c54d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14e8e0e6da9b5f34b3e065df2750cd0fc4af9a4523310578032d36fd288f2cca5fa5e3625d4bc8f4a864b4be72f3593c5cfce89dca1159b43274cf3c2501edbc
|
7
|
+
data.tar.gz: af3dd707b07f2a03489070bf5ae6d79decac71bf1a6370dfb0326f240d620711d44ff31818fcd8bc030c3bf38dda4a3e1762fe0ad044853b7cf72bef3c8b96d7
|
data/CHANGELOG
CHANGED
data/CONTRIBUTORS
CHANGED
data/lib/diffy/html_formatter.rb
CHANGED
@@ -91,12 +91,10 @@ module Diffy
|
|
91
91
|
def split_characters(chunk)
|
92
92
|
chunk.gsub(/^./, '').each_line.map do |line|
|
93
93
|
if @options[:ignore_crlf]
|
94
|
-
|
94
|
+
line.chomp.split('').map{|chr| ERB::Util.h(chr) } + ['<LINE_BOUNDARY>']
|
95
95
|
else
|
96
96
|
chars = line.sub(/([\r\n]$)/, '').split('')
|
97
|
-
|
98
|
-
chars << '\n'
|
99
|
-
chars.map{|chr| ERB::Util.h(chr) }
|
97
|
+
chars.map{|chr| ERB::Util.h(chr) } + ['<LINE_BOUNDARY>']
|
100
98
|
end
|
101
99
|
end.flatten.join("\n") + "\n"
|
102
100
|
end
|
@@ -104,7 +102,7 @@ module Diffy
|
|
104
102
|
def reconstruct_characters(line_diff, type)
|
105
103
|
enum = line_diff.each_chunk.to_a
|
106
104
|
enum.each_with_index.map do |l, i|
|
107
|
-
re = /(
|
105
|
+
re = /(^|<LINE_BOUNDARY>)#{Regexp.escape(type)}/
|
108
106
|
case l
|
109
107
|
when re
|
110
108
|
highlight(l)
|
@@ -113,7 +111,7 @@ module Diffy
|
|
113
111
|
highlight(l)
|
114
112
|
else
|
115
113
|
l.gsub(/^./, '').gsub("\n", '').
|
116
|
-
gsub('\r', "\r").gsub('
|
114
|
+
gsub('\r', "\r").gsub('<LINE_BOUNDARY>', "\n")
|
117
115
|
end
|
118
116
|
end
|
119
117
|
end.join('').split("\n").map do |l|
|
@@ -125,10 +123,7 @@ module Diffy
|
|
125
123
|
"<strong>" +
|
126
124
|
lines.
|
127
125
|
# strip diff tokens (e.g. +,-,etc.)
|
128
|
-
gsub(/(
|
129
|
-
# mark line boundaries from higher level line diff
|
130
|
-
# html is all escaped so using brackets should make this safe.
|
131
|
-
gsub('\n', '<LINE_BOUNDARY>').
|
126
|
+
gsub(/(^|<LINE_BOUNDARY>)./, '').
|
132
127
|
# join characters back by stripping out newlines
|
133
128
|
gsub("\n", '').
|
134
129
|
# close and reopen strong tags. we don't want inline elements
|
data/lib/diffy/version.rb
CHANGED
data/spec/diffy_spec.rb
CHANGED
@@ -530,6 +530,24 @@ baz
|
|
530
530
|
end
|
531
531
|
end
|
532
532
|
|
533
|
+
describe 'with lines that include \n but not as a diff' do
|
534
|
+
before do
|
535
|
+
@string1 = 'a\nb'"\n"
|
536
|
+
@string2 = 'a\nc'"\n"
|
537
|
+
end
|
538
|
+
|
539
|
+
it "should not leave lines out" do
|
540
|
+
expect(Diffy::Diff.new(@string1, @string2).to_s(:html)).to eq <<-DIFF
|
541
|
+
<div class="diff">
|
542
|
+
<ul>
|
543
|
+
<li class="del"><del>a\\n<strong>b</strong></del></li>
|
544
|
+
<li class="ins"><ins>a\\n<strong>c</strong></ins></li>
|
545
|
+
</ul>
|
546
|
+
</div>
|
547
|
+
DIFF
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
533
551
|
it "should do highlighting on the last line when there's no trailing newlines" do
|
534
552
|
s1 = "foo\nbar\nbang"
|
535
553
|
s2 = "foo\nbar\nbangleize"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diffy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Goldstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|