markdiff 0.2.0 → 0.2.1
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 +4 -4
- data/lib/markdiff/operations/add_child_operation.rb +7 -1
- data/lib/markdiff/operations/add_previous_sibling_operation.rb +8 -1
- data/lib/markdiff/operations/remove_operation.rb +7 -1
- data/lib/markdiff/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1701e665032bb63942b695d27e60fd525b45ee03
|
4
|
+
data.tar.gz: 7e499210e87d6c72e0a72311276fc5459d7a55b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fadc3f8eec548e6242e5a42953e2a14cca69e5c430d3915f27670a1d7d975d95fefc9d86086a80b5a0fd0787244fd964195d2f0bfdc60c265713f9e4aa686a21
|
7
|
+
data.tar.gz: 4fb4ee14d8183d2d831aeb3e62b1ccae757fe2d8cbc8e7e7844c763e45b625ea75412b188bb9472091b51ec8d26b644e2832ab8278cf37f919bf73c378595d60
|
data/CHANGELOG.md
CHANGED
data/lib/markdiff/differ.rb
CHANGED
@@ -30,10 +30,10 @@ module Markdiff
|
|
30
30
|
mark_top_level_node_as_changed(operation.target_node)
|
31
31
|
when ::Markdiff::Operations::AddPreviousSiblingOperation
|
32
32
|
operation.target_node.add_previous_sibling(operation.inserted_node)
|
33
|
-
mark_li_as_changed(operation.target_node)
|
33
|
+
mark_li_as_changed(operation.target_node) if operation.target_node.name != "li"
|
34
34
|
mark_top_level_node_as_changed(operation.target_node.parent)
|
35
35
|
when ::Markdiff::Operations::RemoveOperation
|
36
|
-
operation.target_node.replace(operation.inserted_node)
|
36
|
+
operation.target_node.replace(operation.inserted_node) if operation.target_node != operation.inserted_node
|
37
37
|
mark_li_as_changed(operation.target_node)
|
38
38
|
mark_top_level_node_as_changed(operation.target_node)
|
39
39
|
end
|
@@ -87,7 +87,7 @@ module Markdiff
|
|
87
87
|
if inverted_identity_map[after_child]
|
88
88
|
next
|
89
89
|
end
|
90
|
-
if before_child.to_html == after_child.to_html
|
90
|
+
if before_child.to_html.gsub("\n", "") == after_child.to_html.gsub("\n", "")
|
91
91
|
identity_map[before_child] = after_child
|
92
92
|
inverted_identity_map[after_child] = before_child
|
93
93
|
end
|
@@ -167,7 +167,7 @@ module Markdiff
|
|
167
167
|
# @param [Nokogiri::XML::Node] node
|
168
168
|
def mark_li_as_changed(node)
|
169
169
|
until node.parent.nil? || node.parent.fragment?
|
170
|
-
if node.name == "li" && node["class"]
|
170
|
+
if node.name == "li" && node["class"].nil?
|
171
171
|
node["class"] = "changed"
|
172
172
|
end
|
173
173
|
node = node.parent
|
@@ -5,7 +5,13 @@ module Markdiff
|
|
5
5
|
class AddChildOperation < Base
|
6
6
|
# @return [String]
|
7
7
|
def inserted_node
|
8
|
-
|
8
|
+
if @inserted_node.name == "li"
|
9
|
+
@inserted_node["class"] = "added"
|
10
|
+
@inserted_node.inner_html = "<ins>#{@inserted_node.inner_html}</ins>"
|
11
|
+
@inserted_node
|
12
|
+
else
|
13
|
+
"<ins>#{@inserted_node}</ins>"
|
14
|
+
end
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
@@ -5,7 +5,14 @@ module Markdiff
|
|
5
5
|
class AddPreviousSiblingOperation < Base
|
6
6
|
# @return [String]
|
7
7
|
def inserted_node
|
8
|
-
|
8
|
+
if @inserted_node.name == "li"
|
9
|
+
node = @inserted_node.clone
|
10
|
+
node["class"] = "added"
|
11
|
+
node.inner_html = "<ins>#{@inserted_node.inner_html}</ins>"
|
12
|
+
node
|
13
|
+
else
|
14
|
+
"<ins>#{@inserted_node}</ins>"
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
@@ -5,7 +5,13 @@ module Markdiff
|
|
5
5
|
class RemoveOperation < Base
|
6
6
|
# @return [String]
|
7
7
|
def inserted_node
|
8
|
-
|
8
|
+
if target_node.name == "li"
|
9
|
+
target_node["class"] = "removed"
|
10
|
+
target_node.inner_html = "<del>#{target_node.inner_html}</del>"
|
11
|
+
target_node
|
12
|
+
else
|
13
|
+
"<del>#{target_node}</del>"
|
14
|
+
end
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
data/lib/markdiff/version.rb
CHANGED