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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b3010fbe85faa7a63e166ffe7d18c45007f01a3
4
- data.tar.gz: b1a4af8e050c517e9017e60539f3ccb946f394e4
3
+ metadata.gz: 1701e665032bb63942b695d27e60fd525b45ee03
4
+ data.tar.gz: 7e499210e87d6c72e0a72311276fc5459d7a55b0
5
5
  SHA512:
6
- metadata.gz: 6012e20cb4d9129e710c4f49c88cdfe652b8a1951c8b07425433745bead2d49dc58d58c3a251a4042e11c9ef24c2788bee4beb81b705b17f6a6cfeaca737699f
7
- data.tar.gz: aab0e79a022a104345388c5f79d378a6affa4774f92ee7aad69abb4211058449d454b0399ee52d49c75216c2bf5844653cdc592abc9a17405bb697edaa7ecb1a
6
+ metadata.gz: fadc3f8eec548e6242e5a42953e2a14cca69e5c430d3915f27670a1d7d975d95fefc9d86086a80b5a0fd0787244fd964195d2f0bfdc60c265713f9e4aa686a21
7
+ data.tar.gz: 4fb4ee14d8183d2d831aeb3e62b1ccae757fe2d8cbc8e7e7844c763e45b625ea75412b188bb9472091b51ec8d26b644e2832ab8278cf37f919bf73c378595d60
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.1
2
+ - Support li.added and li.removed
3
+
1
4
  ## 0.2.0
2
5
  - Support div.changed and li.changed
3
6
 
@@ -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"] != "changed"
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
- "<ins>#{@inserted_node}</ins>"
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
- "<ins>#{@inserted_node}</ins>"
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
- "<del>#{@target_node}</del>"
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
@@ -1,3 +1,3 @@
1
1
  module Markdiff
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura