markdiff 0.6.3 → 0.7.0

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
  SHA256:
3
- metadata.gz: 720d3daa84f7b4c40f555ef52f2e9912e1d8170a120be554069679beab0d1954
4
- data.tar.gz: 5b9a4631de297e8fa20e615d423c827075f0664b706f763334b65459bd8618a4
3
+ metadata.gz: f86c8ef911af47d5d4271365f2a576564b2425424f1bedc8fc66cda39186ce3a
4
+ data.tar.gz: 7c059f14e29a4b0496b9412f481ced9f10d4742e43d3cab31ade9b85f551b7df
5
5
  SHA512:
6
- metadata.gz: 8d26e5b8cb610502f323eb8f7084c17c43a5879112b978a6faaae193d96d5534ff2254a6cac6af26988f44cc2be163130fc242667c0d591e8073fc5b6b3fb5cb
7
- data.tar.gz: 945860da782918d04fbb6d38c61e4ae447aa1c3e448e2ec422617c3c52a5bc2ce904e14d3c8aaec43c1ab325a3fcf8c4880329d63303e679eeda66acfbbd4e47
6
+ metadata.gz: aa74b28c0589094b03defb2ccfadbba23572530fca2ec07e1fe73f0e810dbc8eba019257a119ea929736ca54c04c3721960e74d41037b07395b92495dbad2736
7
+ data.tar.gz: 8a6a633604eaa4fdb221a779133adae4e4489e98258ef1e39e81b44c73d0fd3215b9d3bb6b1aceffb850517c21f3f2bc3ec7153f7d19e84367e0791e068c95c2
@@ -0,0 +1,22 @@
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.2
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+ bundler-cache: true
22
+ - run: bundle exec rake
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ - Fixed replaces shown wrongly.
6
+
1
7
  ## 0.6.3
2
8
 
3
9
  - Support diff-lcs v1.4+.
data/Gemfile.lock ADDED
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ markdiff (0.6.3)
5
+ diff-lcs
6
+ nokogiri
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.5.0)
12
+ nokogiri (1.13.1-x86_64-linux)
13
+ racc (~> 1.4)
14
+ racc (1.6.0)
15
+ rake (10.5.0)
16
+ redcarpet (3.3.3)
17
+ rspec (3.4.0)
18
+ rspec-core (~> 3.4.0)
19
+ rspec-expectations (~> 3.4.0)
20
+ rspec-mocks (~> 3.4.0)
21
+ rspec-core (3.4.4)
22
+ rspec-support (~> 3.4.0)
23
+ rspec-expectations (3.4.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.4.0)
26
+ rspec-mocks (3.4.1)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.4.0)
29
+ rspec-support (3.4.1)
30
+
31
+ PLATFORMS
32
+ x86_64-linux
33
+
34
+ DEPENDENCIES
35
+ bundler
36
+ markdiff!
37
+ rake (~> 10.0)
38
+ redcarpet (= 3.3.3)
39
+ rspec (= 3.4.0)
40
+
41
+ BUNDLED WITH
42
+ 2.3.6
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # Markdiff [![Build Status](https://travis-ci.org/r7kamura/markdiff.svg)](https://travis-ci.org/r7kamura/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
@@ -15,14 +15,27 @@ module Markdiff
15
15
  def inserted_node
16
16
  before_elements = target_node.to_s.split(" ")
17
17
  after_elements = @after_node.to_s.split(" ")
18
+ last_deleted_pos = nil
19
+
18
20
  ::Diff::LCS.diff(before_elements, after_elements).flatten(1).each do |operation|
19
21
  type, position, element = *operation
22
+
20
23
  if type == "-"
21
24
  before_elements[position] = %(<del class="del">#{element}</del>)
25
+ last_deleted_pos = position
26
+ elsif type == "+"
27
+ insert = "<ins>#{element}</ins>"
28
+
29
+ if last_deleted_pos == position
30
+ before_elements[position] = "#{before_elements[position]}#{insert}"
31
+ else
32
+ before_elements[position] = "#{insert}#{before_elements[position]}"
33
+ end
22
34
  else
23
- before_elements[position] = "#{before_elements[position]}<ins>#{element}</ins>"
35
+ raise "Unhandled type: #{type}"
24
36
  end
25
37
  end
38
+
26
39
  ::Nokogiri::HTML.fragment(before_elements.join(" "))
27
40
  end
28
41
 
@@ -1,3 +1,3 @@
1
1
  module Markdiff
2
- VERSION = "0.6.3"
2
+ VERSION = "0.7.0"
3
3
  end
data/markdiff.gemspec CHANGED
@@ -13,8 +13,7 @@ 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", "~> 1.10"
17
- spec.add_development_dependency "pry", "0.10.3"
16
+ spec.add_development_dependency "bundler"
18
17
  spec.add_development_dependency "rake", "~> 10.0"
19
18
  spec.add_development_dependency "redcarpet", "3.3.3"
20
19
  spec.add_development_dependency "rspec", "3.4.0"
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdiff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-28 00:00:00.000000000 Z
11
+ date: 2022-01-29 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.10.3
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.10.3
26
+ version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -115,10 +101,11 @@ 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
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.0
4
- before_install: gem install bundler -v 1.10.6