markdiff 0.6.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +23 -0
- data/.gitignore +0 -1
- data/CHANGELOG.md +54 -0
- data/Gemfile.lock +42 -0
- data/README.md +5 -1
- data/lib/markdiff/operations/text_diff_operation.rb +29 -9
- data/lib/markdiff/version.rb +1 -1
- data/markdiff.gemspec +4 -5
- metadata +25 -38
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50d045a93d1bcd80cd9013959fac8d671c856e298a4d0834b0b1c97b1c920143
|
4
|
+
data.tar.gz: 16c0aad8bfdc01e84406ac9fd0201c65851429dc505f5519c23aac20221e5ebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 402f46556ab43370f244cd6adeb9ddd538d0dbc0a9668fa12ba25cf244b27b561c254ea9fb9173991c464d6d5775766f0d37a742209290cdda742d48bbed1fc7
|
7
|
+
data.tar.gz: 1c1e45375255e2a13ec0dffd193a06574abe0aff60154256ec0254d0c6b4bee6766404e9de108a4a1b470b75d5338195c9bf1d3505d00e1fee901f3119c6d755
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby:
|
15
|
+
- 2.7.3
|
16
|
+
- 3.1.3
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
bundler-cache: true
|
23
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,60 +1,114 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
## 0.8.0
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- Add class attributes to ins element: `.ins.ins-before` or `.ins.ins-after`.
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
- Fix issue on insertion and deletion on same position.
|
14
|
+
- Fix issue with long sentences.
|
15
|
+
|
16
|
+
## 0.7.0
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Fixed replaces shown wrongly.
|
21
|
+
|
1
22
|
## 0.6.3
|
2
23
|
|
24
|
+
### Fixed
|
25
|
+
|
3
26
|
- Support diff-lcs v1.4+.
|
4
27
|
|
5
28
|
## 0.6.2
|
6
29
|
|
30
|
+
### Changed
|
31
|
+
|
7
32
|
- Support tr.added and tr.deleted.
|
8
33
|
|
9
34
|
## 0.6.1
|
10
35
|
|
36
|
+
### Changed
|
37
|
+
|
11
38
|
- Fix patch order bug by making sort stable.
|
12
39
|
|
13
40
|
## 0.6.0
|
14
41
|
|
42
|
+
### Changed
|
43
|
+
|
15
44
|
- Add .del class to all del elements.
|
16
45
|
|
17
46
|
## 0.5.5
|
18
47
|
|
48
|
+
### Fixed
|
49
|
+
|
19
50
|
- Preserve classes on adding new class (e.g. .added).
|
20
51
|
|
21
52
|
## 0.5.4
|
22
53
|
|
54
|
+
### Fixed
|
55
|
+
|
23
56
|
- Fix bug on patch operations order.
|
24
57
|
|
25
58
|
## 0.5.3
|
26
59
|
|
60
|
+
### Fixed
|
61
|
+
|
27
62
|
- Fix bug on comparing nodes.
|
28
63
|
|
29
64
|
## 0.5.2
|
30
65
|
|
66
|
+
### Fixed
|
67
|
+
|
31
68
|
- Fix bug on comparing attributes and text nodes.
|
32
69
|
|
33
70
|
## 0.5.1
|
34
71
|
|
72
|
+
### Fixed
|
73
|
+
|
35
74
|
- Fix bug on text-diff operation.
|
36
75
|
|
37
76
|
## 0.5.0
|
38
77
|
|
78
|
+
### Changed
|
79
|
+
|
39
80
|
- Wrap changed nodes by div.changed.
|
40
81
|
|
41
82
|
## 0.4.0
|
42
83
|
|
84
|
+
### Changed
|
85
|
+
|
43
86
|
- Chanage .changed specs.
|
87
|
+
|
88
|
+
### Fixed
|
89
|
+
|
44
90
|
- Fix bugs on text diff.
|
45
91
|
|
46
92
|
## 0.3.0
|
47
93
|
|
94
|
+
### Changed
|
95
|
+
|
48
96
|
- Support partial text diff.
|
49
97
|
|
50
98
|
## 0.2.1
|
51
99
|
|
100
|
+
### Changed
|
101
|
+
|
52
102
|
- Support li.added and li.removed.
|
53
103
|
|
54
104
|
## 0.2.0
|
55
105
|
|
106
|
+
### Changed
|
107
|
+
|
56
108
|
- Support div.changed and li.changed.
|
57
109
|
|
58
110
|
## 0.1.0
|
59
111
|
|
112
|
+
### Added
|
113
|
+
|
60
114
|
- 1st Release.
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
markdiff (0.8.0)
|
5
|
+
diff-lcs
|
6
|
+
nokogiri
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
nokogiri (1.14.2-x86_64-linux)
|
13
|
+
racc (~> 1.4)
|
14
|
+
racc (1.6.2)
|
15
|
+
rake (13.0.6)
|
16
|
+
redcarpet (3.6.0)
|
17
|
+
rspec (3.12.0)
|
18
|
+
rspec-core (~> 3.12.0)
|
19
|
+
rspec-expectations (~> 3.12.0)
|
20
|
+
rspec-mocks (~> 3.12.0)
|
21
|
+
rspec-core (3.12.1)
|
22
|
+
rspec-support (~> 3.12.0)
|
23
|
+
rspec-expectations (3.12.2)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.12.0)
|
26
|
+
rspec-mocks (3.12.3)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.12.0)
|
29
|
+
rspec-support (3.12.0)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
x86_64-linux
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
bundler
|
36
|
+
markdiff!
|
37
|
+
rake
|
38
|
+
redcarpet
|
39
|
+
rspec
|
40
|
+
|
41
|
+
BUNDLED WITH
|
42
|
+
2.3.6
|
data/README.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
# Markdiff
|
1
|
+
# Markdiff
|
2
|
+
|
3
|
+
[![test](https://github.com/r7kamura/markdiff/actions/workflows/test.yml/badge.svg)](https://github.com/r7kamura/markdiff/actions/workflows/test.yml)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/markdiff.svg)](https://rubygems.org/gems/markdiff)
|
5
|
+
|
2
6
|
Rendered Markdown differ.
|
3
7
|
|
4
8
|
## Usage
|
@@ -13,17 +13,37 @@ module Markdiff
|
|
13
13
|
|
14
14
|
# @return [Nokogiri::XML::Node]
|
15
15
|
def inserted_node
|
16
|
-
before_elements = target_node.to_s.split(
|
17
|
-
after_elements = @after_node.to_s.split(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
before_elements = target_node.to_s.split(' ')
|
17
|
+
after_elements = @after_node.to_s.split(' ')
|
18
|
+
last_operation = nil
|
19
|
+
|
20
|
+
groupings = ::Diff::LCS.sdiff(before_elements, after_elements)
|
21
|
+
.slice_when { |prev, cur| prev.action != cur.action }
|
22
|
+
|
23
|
+
output = groupings.map do |grouping|
|
24
|
+
action = grouping.first.action
|
25
|
+
|
26
|
+
response = case action
|
27
|
+
when "="
|
28
|
+
grouping.map(&:new_element).join(" ")
|
29
|
+
when "-"
|
30
|
+
%(<del class="del">#{grouping.map(&:old_element).join(" ")}</del>)
|
31
|
+
when "+"
|
32
|
+
%(<ins class="ins ins-before">#{grouping.map(&:new_element).join(" ")}</ins>)
|
33
|
+
when "!"
|
34
|
+
%(<del class="del">#{grouping.map(&:old_element).join(" ")}</del><ins class="ins ins-after">#{grouping.map(&:new_element).join(" ")}</ins>)
|
35
|
+
else
|
36
|
+
raise "Unknown action #{action}"
|
24
37
|
end
|
38
|
+
|
39
|
+
response = " #{response}" if last_operation && last_operation != '+'
|
40
|
+
|
41
|
+
last_operation = action
|
42
|
+
|
43
|
+
response
|
25
44
|
end
|
26
|
-
|
45
|
+
|
46
|
+
::Nokogiri::HTML.fragment(output.join(''))
|
27
47
|
end
|
28
48
|
|
29
49
|
def priority
|
data/lib/markdiff/version.rb
CHANGED
data/markdiff.gemspec
CHANGED
@@ -13,11 +13,10 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.start_with?("spec/") }
|
14
14
|
spec.require_paths = ["lib"]
|
15
15
|
|
16
|
-
spec.add_development_dependency "bundler"
|
17
|
-
spec.add_development_dependency "
|
18
|
-
spec.add_development_dependency "
|
19
|
-
spec.add_development_dependency "
|
20
|
-
spec.add_development_dependency "rspec", "3.4.0"
|
16
|
+
spec.add_development_dependency "bundler"
|
17
|
+
spec.add_development_dependency "rake"
|
18
|
+
spec.add_development_dependency "redcarpet"
|
19
|
+
spec.add_development_dependency "rspec"
|
21
20
|
spec.add_runtime_dependency "diff-lcs"
|
22
21
|
spec.add_runtime_dependency "nokogiri"
|
23
22
|
end
|
metadata
CHANGED
@@ -1,85 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.10'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.10'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: pry
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '='
|
17
|
+
- - ">="
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
19
|
+
version: '0'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- -
|
24
|
+
- - ">="
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
26
|
+
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- - "
|
31
|
+
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '0'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - "
|
38
|
+
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
40
|
+
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: redcarpet
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- -
|
45
|
+
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
47
|
+
version: '0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- -
|
52
|
+
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
54
|
+
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- -
|
59
|
+
- - ">="
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
61
|
+
version: '0'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- -
|
66
|
+
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
68
|
+
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: diff-lcs
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,17 +94,18 @@ dependencies:
|
|
108
94
|
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
111
|
-
description:
|
97
|
+
description:
|
112
98
|
email:
|
113
99
|
- r7kamura@gmail.com
|
114
100
|
executables: []
|
115
101
|
extensions: []
|
116
102
|
extra_rdoc_files: []
|
117
103
|
files:
|
104
|
+
- ".github/workflows/test.yml"
|
118
105
|
- ".gitignore"
|
119
|
-
- ".travis.yml"
|
120
106
|
- CHANGELOG.md
|
121
107
|
- Gemfile
|
108
|
+
- Gemfile.lock
|
122
109
|
- LICENSE.txt
|
123
110
|
- README.md
|
124
111
|
- Rakefile
|
@@ -140,7 +127,7 @@ homepage: https://github.com/r7kamura/markdiff
|
|
140
127
|
licenses:
|
141
128
|
- MIT
|
142
129
|
metadata: {}
|
143
|
-
post_install_message:
|
130
|
+
post_install_message:
|
144
131
|
rdoc_options: []
|
145
132
|
require_paths:
|
146
133
|
- lib
|
@@ -155,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
142
|
- !ruby/object:Gem::Version
|
156
143
|
version: '0'
|
157
144
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
159
|
-
signing_key:
|
145
|
+
rubygems_version: 3.3.26
|
146
|
+
signing_key:
|
160
147
|
specification_version: 4
|
161
148
|
summary: Rendered Markdown differ.
|
162
149
|
test_files: []
|
data/.travis.yml
DELETED