markdiff 0.5.0 → 0.5.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/README.md +1 -1
- data/lib/markdiff/differ.rb +2 -1
- data/lib/markdiff/operations/base.rb +4 -0
- data/lib/markdiff/operations/remove_operation.rb +4 -0
- data/lib/markdiff/operations/text_diff_operation.rb +4 -0
- 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: d21040c507d42a274d28a00d208d8f8870326697
|
4
|
+
data.tar.gz: d2530960295fac137bb42865a97f237b59b640bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d0210b09bff8321cac16ff7e2aa9e1d918bcf1fcc827d0fe024e799a2a1fa16e8cd14ea387f1bf6222dae6e783b3c488a735bf3960a5e5a57fb142f3b675693
|
7
|
+
data.tar.gz: 82f349441e1760e223fbdcf760a6e008cac624f9470d5ca67946bc18695601f2ab9289f75e6f718530cc48b3665d2dd0de77b7fe0be6715800f028a9cf0ba975
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ require "markdiff"
|
|
7
7
|
|
8
8
|
differ = Markdiff::Differ.new
|
9
9
|
node = differ.render("<p>a</p>", "<p>b</p>")
|
10
|
-
node.to_html #=> '<
|
10
|
+
node.to_html #=> '<div class="changed"><p><del>a</del><ins>b</ins></p></div>'
|
11
11
|
```
|
12
12
|
|
13
13
|
See [spec/markdiff/differ_spec.rb](spec/markdiff/differ_spec.rb) for more examples.
|
data/lib/markdiff/differ.rb
CHANGED
@@ -13,7 +13,7 @@ module Markdiff
|
|
13
13
|
# @param [Nokogiri::XML::Node] node
|
14
14
|
# @return [Nokogiri::XML::Node] Converted node
|
15
15
|
def apply_patch(operations, node)
|
16
|
-
operations.each do |operation|
|
16
|
+
operations.sort_by(&:priority).reverse.each do |operation|
|
17
17
|
case operation
|
18
18
|
when ::Markdiff::Operations::AddChildOperation
|
19
19
|
operation.target_node.add_child(operation.inserted_node)
|
@@ -201,6 +201,7 @@ module Markdiff
|
|
201
201
|
|
202
202
|
# @param [Nokogiri::XML::Node] node
|
203
203
|
def mark_top_level_node_as_changed(node)
|
204
|
+
return if node.nil?
|
204
205
|
node = node.parent until node.parent.nil? || node.parent.fragment?
|
205
206
|
unless node.parent.nil? || node["class"] == "changed"
|
206
207
|
div = Nokogiri::XML::Node.new("div", node.document)
|
data/lib/markdiff/version.rb
CHANGED