reverse_markdown 2.1.1 → 3.0.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: cffa2a16f5ad4187cb23a2e6a1015121b943f1c83a688308cf0a480ec15d3c49
4
- data.tar.gz: 6941ad7c07005ff4d5c115fd894ee2a0cf40a09367833268f4c55c018f30263a
3
+ metadata.gz: 94eded67b23dcb767fefb6415557b114e9901aa158e96d6de9eebace8e91cdde
4
+ data.tar.gz: 52e80dad7a9cfdbaa0c22698b7d08b7c977988bd36febc3fc4c3dece596366e6
5
5
  SHA512:
6
- metadata.gz: 620ce03beae7238accdc6836e025dc7b19fe308a7bcbcd7143dc7472d09e7d25758a3f6c2080d5d75e60fee662bc87ab200f177b5b6f41fa5958bde4b569a49e
7
- data.tar.gz: ea69f20a1e70e4f41d6024502af362351ccaf6ec8936b4dcadc2414202e994cdf8ddf08ebbd829c0722c373bbe7e87a223c3c913bf6d845be9308ef418f3be75
6
+ metadata.gz: c1701257560c201e275587ab769e6965b9c8060918341c97a0ce971ddd4bb9b862e183e278e411aecedcae99515fbec6c3206ff22ccd7be7133e3f15e74d6f4e
7
+ data.tar.gz: 166e5fc564cbbbbfaae1f4f4bd4c4d9ce01adb92e8b5caadbcf4c78adaf98e17450eb5a0df1ba2055b9e31f72e43d3e79b765ee318dbb05113dd05c7e04b85c3
@@ -0,0 +1,48 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby-version: [ '2.7', '3.0', '3.1', '3.2', '3.3', 'jruby-9.4' ]
17
+
18
+ steps:
19
+ - name: Checkout code
20
+ uses: actions/checkout@v3
21
+
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby-version }}
26
+ bundler-cache: true
27
+
28
+ - name: Install dependencies
29
+ run: bundle install
30
+
31
+ - name: Run tests
32
+ run: bundle exec rspec
33
+
34
+ - name: Run Code Climate Test Reporter
35
+ run: |
36
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
37
+ chmod +x ./cc-test-reporter
38
+ ./cc-test-reporter before-build
39
+
40
+ - name: Run tests
41
+ run: bundle exec rspec
42
+
43
+ - name: Upload Code Climate Coverage Report
44
+ if: matrix.ruby-version == '3.3'
45
+ env:
46
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
47
+ run: |
48
+ ./cc-test-reporter after-build --exit-code $?
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.3.5
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 3.0.0 - October 2024
5
+ - BREAKING: Dropped support for ruby 2.6.0 and lower
6
+ - Bugfix for missing newline behind `ol`, thanks @Kevinrob, see #104
7
+ - Add support for `iframe` tags, thanks @gagandeepsinghj, see #102
8
+ - Support for frozen string literals, thanks @pat, see #105
9
+
4
10
  ## 2.1.1 - October 2021
5
11
  - Fixes unintentional newline characters within lists with paragraphs, thanks @diogoosorio, see #93
6
12
  - Lets \n to be present in <pre> tag. solves #77 #78, thanks @shivabhusal
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Transform html into markdown. Useful for example if you want to import html into your markdown based application.
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/xijo/reverse_markdown.svg?branch=master)](https://travis-ci.org/xijo/reverse_markdown) [![Gem Version](https://badge.fury.io/rb/reverse_markdown.svg)](http://badge.fury.io/rb/reverse_markdown) [![Code Climate](https://codeclimate.com/github/xijo/reverse_markdown.svg)](https://codeclimate.com/github/xijo/reverse_markdown) [![Code Climate](https://codeclimate.com/github/xijo/reverse_markdown/coverage.png)](https://codeclimate.com/github/xijo/reverse_markdown)
5
+ ![Build Status](https://github.com/xijo/reverse_markdown/actions/workflows/ci.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/reverse_markdown.svg)](http://badge.fury.io/rb/reverse_markdown) [![Code Climate](https://codeclimate.com/github/xijo/reverse_markdown.svg)](https://codeclimate.com/github/xijo/reverse_markdown) [![Test Coverage](https://api.codeclimate.com/v1/badges/6ce481ba7ae6f57dc4d3/test_coverage)](https://codeclimate.com/github/xijo/reverse_markdown/test_coverage)
6
6
 
7
7
  ## Changelog
8
8
 
@@ -11,7 +11,7 @@ See [Change Log](CHANGELOG.md)
11
11
  ## Requirements
12
12
 
13
13
  1. [Nokogiri](http://nokogiri.org/)
14
- 2. Ruby 2.0.0 or higher
14
+ 2. Ruby 2.7.0 or higher
15
15
 
16
16
  ## Installation
17
17
 
@@ -2,7 +2,7 @@ module ReverseMarkdown
2
2
  module Converters
3
3
  class Base
4
4
  def treat_children(node, state)
5
- node.children.inject('') do |memo, child|
5
+ node.children.inject(+'') do |memo, child|
6
6
  memo << treat(child, state)
7
7
  end
8
8
  end
@@ -19,6 +19,10 @@ module ReverseMarkdown
19
19
  title = escape_keychars(node['title'].to_s)
20
20
  title.empty? ? '' : %[ "#{title}"]
21
21
  end
22
+
23
+ def extract_src(node)
24
+ node['src'].to_s.empty? ? '' : node['src'].to_s
25
+ end
22
26
  end
23
27
  end
24
28
  end
@@ -4,7 +4,7 @@ module ReverseMarkdown
4
4
  def convert(node, state = {})
5
5
  content = treat_children(node, state).strip
6
6
  content = ReverseMarkdown.cleaner.remove_newlines(content)
7
- "\n\n> " << content.lines.to_a.join('> ') << "\n\n"
7
+ +"\n\n> " << content.lines.to_a.join('> ') << "\n\n"
8
8
  end
9
9
  end
10
10
 
@@ -2,7 +2,7 @@ module ReverseMarkdown
2
2
  module Converters
3
3
  class Div < Base
4
4
  def convert(node, state = {})
5
- "\n" << treat_children(node, state) << "\n"
5
+ +"\n" << treat_children(node, state) << "\n"
6
6
  end
7
7
  end
8
8
 
@@ -5,7 +5,7 @@ module ReverseMarkdown
5
5
  if node.text.strip.empty?
6
6
  ""
7
7
  else
8
- "\n" << "_#{node.text.strip}_" << "\n"
8
+ +"\n" << "_#{node.text.strip}_" << "\n"
9
9
  end
10
10
  end
11
11
  end
@@ -0,0 +1,11 @@
1
+ module ReverseMarkdown
2
+ module Converters
3
+ class Iframe < Base
4
+ def convert(node, state = {})
5
+ extract_src(node)
6
+ end
7
+ end
8
+
9
+ register :iframe, Iframe.new
10
+ end
11
+ end
@@ -3,7 +3,7 @@ module ReverseMarkdown
3
3
  class Ol < Base
4
4
  def convert(node, state = {})
5
5
  ol_count = state.fetch(:ol_count, 0) + 1
6
- "\n" << treat_children(node, state.merge(ol_count: ol_count))
6
+ +"\n" << treat_children(node, state.merge(ol_count: ol_count)) << "\n"
7
7
  end
8
8
  end
9
9
 
@@ -2,7 +2,7 @@ module ReverseMarkdown
2
2
  module Converters
3
3
  class P < Base
4
4
  def convert(node, state = {})
5
- "\n\n" << treat_children(node, state).strip << "\n\n"
5
+ +"\n\n" << treat_children(node, state).strip << "\n\n"
6
6
  end
7
7
  end
8
8
 
@@ -4,9 +4,9 @@ module ReverseMarkdown
4
4
  def convert(node, state = {})
5
5
  content = treat_children(node, state)
6
6
  if ReverseMarkdown.config.github_flavored
7
- "\n```#{language(node)}\n" << content.strip << "\n```\n"
7
+ +"\n```#{language(node)}\n" << content.strip << "\n```\n"
8
8
  else
9
- "\n\n " << content.lines.to_a.join(" ") << "\n\n"
9
+ +"\n\n " << content.lines.to_a.join(" ") << "\n\n"
10
10
  end
11
11
  end
12
12
 
@@ -2,7 +2,7 @@ module ReverseMarkdown
2
2
  module Converters
3
3
  class Table < Base
4
4
  def convert(node, state = {})
5
- "\n\n" << treat_children(node, state) << "\n"
5
+ +"\n\n" << treat_children(node, state) << "\n"
6
6
  end
7
7
  end
8
8
 
@@ -1,3 +1,3 @@
1
1
  module ReverseMarkdown
2
- VERSION = '2.1.1'
2
+ VERSION = '3.0.0'
3
3
  end
@@ -31,6 +31,7 @@ require 'reverse_markdown/converters/table'
31
31
  require 'reverse_markdown/converters/td'
32
32
  require 'reverse_markdown/converters/text'
33
33
  require 'reverse_markdown/converters/tr'
34
+ require 'reverse_markdown/converters/iframe'
34
35
 
35
36
  module ReverseMarkdown
36
37
 
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency 'simplecov'
24
24
  s.add_development_dependency 'rake'
25
25
  s.add_development_dependency 'kramdown'
26
- s.add_development_dependency 'byebug'
26
+ s.add_development_dependency 'debug' unless RUBY_ENGINE == 'jruby'
27
27
  s.add_development_dependency 'codeclimate-test-reporter'
28
28
  end
@@ -0,0 +1,4 @@
1
+ <h1>Welcome to My Page</h1>
2
+ <p>This is a sample paragraph before the iframe.</p>
3
+ <iframe src="https://www.example.com" width="600" height="400"></iframe>
4
+ <p>This is a sample paragraph after the iframe.</p>
@@ -95,5 +95,10 @@
95
95
  <li>delta</li>
96
96
  </ul>
97
97
 
98
+ <ul>
99
+ <li>item followed with a text</li>
100
+ </ul>
101
+ text after the list
102
+
98
103
  </body>
99
104
  </html>
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ReverseMarkdown do
4
-
5
4
  let(:input) { File.read('spec/assets/from_the_wild.html') }
6
5
  let(:document) { Nokogiri::HTML(input) }
7
6
  subject { ReverseMarkdown.convert(input) }
@@ -13,5 +12,4 @@ describe ReverseMarkdown do
13
12
  it "should not over escape * or _" do
14
13
  expect(subject).to include '[![](example.com/foo_bar.png) I\_AM\_HELPFUL](example.com/foo_bar)'
15
14
  end
16
-
17
15
  end
@@ -1,11 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ReverseMarkdown do
4
-
5
4
  let(:input) { File.read('spec/assets/html_fragment.html') }
6
5
  let(:document) { Nokogiri::HTML(input) }
7
6
  subject { ReverseMarkdown.convert(input) }
8
7
 
9
8
  it { is_expected.to eq("naked text 1\n\nparagraph text\n\nnaked text 2") }
10
9
  end
11
-
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseMarkdown do
4
+ let(:input) { File.read('spec/assets/iframe.html') }
5
+ let(:document) { Nokogiri::HTML(input) }
6
+ subject { ReverseMarkdown.convert(input) }
7
+
8
+ it do
9
+ expected = <<~MD
10
+ # Welcome to My Page
11
+
12
+ This is a sample paragraph before the iframe.
13
+
14
+ https://www.example.com
15
+
16
+ This is a sample paragraph after the iframe.
17
+
18
+ MD
19
+
20
+ expect(subject).to eq expected
21
+ end
22
+ end
@@ -65,4 +65,7 @@ describe ReverseMarkdown do
65
65
  it { is_expected.to match /\n- delta\n/ }
66
66
  end
67
67
 
68
+ context "text following list should have a new line separator" do
69
+ it { is_expected.to match /\n- item followed with a text\n\n text after the list/ }
70
+ end
68
71
  end
@@ -36,7 +36,8 @@ describe ReverseMarkdown do
36
36
 
37
37
  describe 'force_encoding option', jruby: :exclude do
38
38
  it 'raises invalid byte sequence in UTF-8 exception' do
39
- expect { ReverseMarkdown.convert("hi \255") }.to raise_error(ArgumentError)
39
+ # Older versions of ruby used to raise ArgumentError here. Remove when we drop support for 3.1.
40
+ expect { ReverseMarkdown.convert("hi \255") }.to raise_error { [Encoding::CompatibilityError, ArgumentError].include?(_1.class) }
40
41
  end
41
42
 
42
43
  it 'handles invalid byte sequence if option is set' do
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'simplecov'
2
- # require 'byebug'
2
+ require 'debug' unless RUBY_ENGINE == 'jruby'
3
3
 
4
4
  SimpleCov.profiles.define 'gem' do
5
5
  add_filter '/spec/'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reverse_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Opper
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-31 00:00:00.000000000 Z
11
+ date: 2024-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: byebug
84
+ name: debug
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -117,9 +117,10 @@ executables:
117
117
  extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
+ - ".github/workflows/ci.yml"
120
121
  - ".gitignore"
121
122
  - ".rspec"
122
- - ".travis.yml"
123
+ - ".tool-versions"
123
124
  - CHANGELOG.md
124
125
  - Gemfile
125
126
  - LICENSE
@@ -145,6 +146,7 @@ files:
145
146
  - lib/reverse_markdown/converters/figure.rb
146
147
  - lib/reverse_markdown/converters/h.rb
147
148
  - lib/reverse_markdown/converters/hr.rb
149
+ - lib/reverse_markdown/converters/iframe.rb
148
150
  - lib/reverse_markdown/converters/ignore.rb
149
151
  - lib/reverse_markdown/converters/img.rb
150
152
  - lib/reverse_markdown/converters/li.rb
@@ -167,6 +169,7 @@ files:
167
169
  - spec/assets/from_the_wild.html
168
170
  - spec/assets/full_example.html
169
171
  - spec/assets/html_fragment.html
172
+ - spec/assets/iframe.html
170
173
  - spec/assets/lists.html
171
174
  - spec/assets/minimum.html
172
175
  - spec/assets/paragraphs.html
@@ -179,6 +182,7 @@ files:
179
182
  - spec/components/escapables_spec.rb
180
183
  - spec/components/from_the_wild_spec.rb
181
184
  - spec/components/html_fragment_spec.rb
185
+ - spec/components/iframe_spec.rb
182
186
  - spec/components/lists_spec.rb
183
187
  - spec/components/paragraphs_spec.rb
184
188
  - spec/components/quotation_spec.rb
@@ -203,7 +207,7 @@ homepage: http://github.com/xijo/reverse_markdown
203
207
  licenses:
204
208
  - WTFPL
205
209
  metadata: {}
206
- post_install_message:
210
+ post_install_message:
207
211
  rdoc_options: []
208
212
  require_paths:
209
213
  - lib
@@ -218,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
222
  - !ruby/object:Gem::Version
219
223
  version: '0'
220
224
  requirements: []
221
- rubygems_version: 3.1.4
222
- signing_key:
225
+ rubygems_version: 3.5.16
226
+ signing_key:
223
227
  specification_version: 4
224
228
  summary: Convert html code into markdown.
225
229
  test_files:
@@ -230,6 +234,7 @@ test_files:
230
234
  - spec/assets/from_the_wild.html
231
235
  - spec/assets/full_example.html
232
236
  - spec/assets/html_fragment.html
237
+ - spec/assets/iframe.html
233
238
  - spec/assets/lists.html
234
239
  - spec/assets/minimum.html
235
240
  - spec/assets/paragraphs.html
@@ -242,6 +247,7 @@ test_files:
242
247
  - spec/components/escapables_spec.rb
243
248
  - spec/components/from_the_wild_spec.rb
244
249
  - spec/components/html_fragment_spec.rb
250
+ - spec/components/iframe_spec.rb
245
251
  - spec/components/lists_spec.rb
246
252
  - spec/components/paragraphs_spec.rb
247
253
  - spec/components/quotation_spec.rb
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
-
4
- rvm:
5
- - 2.0
6
- - 2.1
7
- - 2.2
8
- - 2.3
9
- - 2.4
10
- - 2.5
11
- - 2.6
12
- - 2.7
13
- - jruby-9.2.8.0
14
-
15
- notifications:
16
- disabled: false
17
- recipients:
18
- - xijo@pm.me