markdiff 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/markdiff/differ.rb +8 -8
- data/lib/markdiff/operations/add_child_operation.rb +1 -1
- data/lib/markdiff/operations/add_previous_sibling_operation.rb +1 -1
- data/lib/markdiff/operations/remove_operation.rb +1 -1
- data/lib/markdiff/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ee2a5b3a813d720c09eb7899ed15d8f04bc0c67
|
4
|
+
data.tar.gz: 604b3c40a6e7bd2c52c33638ffb285a0bcfe2a23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aae5604ad09ce8ca3baeb318849477daee6fce59052f3a315640c511b7c25618d8c8163f12476f1da26dbde500eb1c3aff5ceb8a2e1e2dfaf11a15ecc7d83c67
|
7
|
+
data.tar.gz: 8f1b14bd5fcf4f12d45f221e70d9b8d6af764e89729cc7ba3f3c8d9baf367840568657b594c85cf3c3c1dbd46849fd82029035323f91a697b1e41216c2924689
|
data/CHANGELOG.md
CHANGED
data/lib/markdiff/differ.rb
CHANGED
@@ -19,30 +19,30 @@ module Markdiff
|
|
19
19
|
case operation
|
20
20
|
when ::Markdiff::Operations::AddChildOperation
|
21
21
|
operation.target_node.add_child(operation.inserted_node)
|
22
|
-
|
22
|
+
mark_li_or_tr_as_changed(operation.target_node)
|
23
23
|
mark_top_level_node_as_changed(operation.target_node)
|
24
24
|
when ::Markdiff::Operations::AddDataBeforeHrefOperation
|
25
25
|
operation.target_node["data-before-href"] = operation.target_node["href"]
|
26
26
|
operation.target_node["href"] = operation.after_href
|
27
|
-
|
27
|
+
mark_li_or_tr_as_changed(operation.target_node)
|
28
28
|
mark_top_level_node_as_changed(operation.target_node)
|
29
29
|
when ::Markdiff::Operations::AddDataBeforeTagNameOperation
|
30
30
|
operation.target_node["data-before-tag-name"] = operation.target_node.name
|
31
31
|
operation.target_node.name = operation.after_tag_name
|
32
|
-
|
32
|
+
mark_li_or_tr_as_changed(operation.target_node)
|
33
33
|
mark_top_level_node_as_changed(operation.target_node)
|
34
34
|
when ::Markdiff::Operations::AddPreviousSiblingOperation
|
35
35
|
operation.target_node.add_previous_sibling(operation.inserted_node)
|
36
|
-
|
36
|
+
mark_li_or_tr_as_changed(operation.target_node) if operation.target_node.name != "li" && operation.target_node.name != "tr"
|
37
37
|
mark_top_level_node_as_changed(operation.target_node.parent)
|
38
38
|
when ::Markdiff::Operations::RemoveOperation
|
39
39
|
operation.target_node.replace(operation.inserted_node) if operation.target_node != operation.inserted_node
|
40
|
-
|
40
|
+
mark_li_or_tr_as_changed(operation.target_node)
|
41
41
|
mark_top_level_node_as_changed(operation.target_node)
|
42
42
|
when ::Markdiff::Operations::TextDiffOperation
|
43
43
|
parent = operation.target_node.parent
|
44
44
|
operation.target_node.replace(operation.inserted_node)
|
45
|
-
|
45
|
+
mark_li_or_tr_as_changed(parent)
|
46
46
|
mark_top_level_node_as_changed(parent)
|
47
47
|
end
|
48
48
|
end
|
@@ -182,9 +182,9 @@ module Markdiff
|
|
182
182
|
end
|
183
183
|
|
184
184
|
# @param [Nokogiri::XML::Node] node
|
185
|
-
def
|
185
|
+
def mark_li_or_tr_as_changed(node)
|
186
186
|
until node.parent.nil? || node.parent.fragment?
|
187
|
-
if node.name == "li"
|
187
|
+
if node.name == "li" || node.name == "tr"
|
188
188
|
classes = node["class"].to_s.split(/\s/)
|
189
189
|
unless classes.include?("added") || classes.include?("changed") || classes.include?("removed")
|
190
190
|
node["class"] = (classes + ["changed"]).join(" ")
|
@@ -5,7 +5,7 @@ module Markdiff
|
|
5
5
|
class AddChildOperation < Base
|
6
6
|
# @return [String]
|
7
7
|
def inserted_node
|
8
|
-
if @inserted_node.name == "li"
|
8
|
+
if @inserted_node.name == "li" || @inserted_node.name == "tr"
|
9
9
|
@inserted_node["class"] = (@inserted_node["class"].to_s.split(/\s/) + ["added"]).join(" ")
|
10
10
|
@inserted_node.inner_html = "<ins>#{@inserted_node.inner_html}</ins>"
|
11
11
|
@inserted_node
|
@@ -5,7 +5,7 @@ module Markdiff
|
|
5
5
|
class AddPreviousSiblingOperation < Base
|
6
6
|
# @return [String]
|
7
7
|
def inserted_node
|
8
|
-
if @inserted_node.name == "li"
|
8
|
+
if @inserted_node.name == "li" || @inserted_node.name == "tr"
|
9
9
|
node = @inserted_node.clone
|
10
10
|
node["class"] = (node["class"].to_s.split(/\s/) + ["added"]).join(" ")
|
11
11
|
node.inner_html = "<ins>#{@inserted_node.inner_html}</ins>"
|
@@ -5,7 +5,7 @@ module Markdiff
|
|
5
5
|
class RemoveOperation < Base
|
6
6
|
# @return [String]
|
7
7
|
def inserted_node
|
8
|
-
if target_node.name == "li"
|
8
|
+
if target_node.name == "li" || target_node.name == "tr"
|
9
9
|
target_node["class"] = "removed"
|
10
10
|
target_node.inner_html = %(<del class="del">#{target_node.inner_html}</del>)
|
11
11
|
target_node
|
data/lib/markdiff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|