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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d579e119bf15ea1d6629b7b6fb1f17d2fa2406a0
4
- data.tar.gz: 35fa6ffd2804f296fe768b12f3ad550bd2551f2a
3
+ metadata.gz: d21040c507d42a274d28a00d208d8f8870326697
4
+ data.tar.gz: d2530960295fac137bb42865a97f237b59b640bd
5
5
  SHA512:
6
- metadata.gz: 612cfea493d82b55cd8ddb35e7284584cf72b96fbc2b7603d9ef0c183653ad019d5183b6c69dd7463d4b741d27cba46f22318d7593b3664a95983afa7401d402
7
- data.tar.gz: f7fc3e3dc5aad82b271d31d145f4674904e5e2d3da34d6b34e99ec3cab0103d30f584e2cfa99b62fe6808815df906962defe49d7c000f18bdf8c06049a0f3103
6
+ metadata.gz: 0d0210b09bff8321cac16ff7e2aa9e1d918bcf1fcc827d0fe024e799a2a1fa16e8cd14ea387f1bf6222dae6e783b3c488a735bf3960a5e5a57fb142f3b675693
7
+ data.tar.gz: 82f349441e1760e223fbdcf760a6e008cac624f9470d5ca67946bc18695601f2ab9289f75e6f718530cc48b3665d2dd0de77b7fe0be6715800f028a9cf0ba975
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.5.1
2
+ - Fix bug on text-diff operation
3
+
1
4
  ## 0.5.0
2
5
  - Wrap changed nodes by div.changed
3
6
 
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 #=> '<p class="changed"><del>a</del><ins>b</ins></p>'
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.
@@ -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)
@@ -10,6 +10,10 @@ module Markdiff
10
10
  @inserted_node = inserted_node
11
11
  @target_node = target_node
12
12
  end
13
+
14
+ def priority
15
+ 3
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -13,6 +13,10 @@ module Markdiff
13
13
  "<del>#{target_node}</del>"
14
14
  end
15
15
  end
16
+
17
+ def priority
18
+ 2
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -25,6 +25,10 @@ module Markdiff
25
25
  end
26
26
  ::Nokogiri::HTML.fragment(before_elements.join(" "))
27
27
  end
28
+
29
+ def priority
30
+ 1
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -1,3 +1,3 @@
1
1
  module Markdiff
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdiff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura