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 +4 -4
- data/.github/workflows/ci.yml +48 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +2 -2
- data/lib/reverse_markdown/converters/base.rb +5 -1
- data/lib/reverse_markdown/converters/blockquote.rb +1 -1
- data/lib/reverse_markdown/converters/div.rb +1 -1
- data/lib/reverse_markdown/converters/figcaption.rb +1 -1
- data/lib/reverse_markdown/converters/iframe.rb +11 -0
- data/lib/reverse_markdown/converters/ol.rb +1 -1
- data/lib/reverse_markdown/converters/p.rb +1 -1
- data/lib/reverse_markdown/converters/pre.rb +2 -2
- data/lib/reverse_markdown/converters/table.rb +1 -1
- data/lib/reverse_markdown/version.rb +1 -1
- data/lib/reverse_markdown.rb +1 -0
- data/reverse_markdown.gemspec +1 -1
- data/spec/assets/iframe.html +4 -0
- data/spec/assets/lists.html +5 -0
- data/spec/components/from_the_wild_spec.rb +0 -2
- data/spec/components/html_fragment_spec.rb +0 -2
- data/spec/components/iframe_spec.rb +22 -0
- data/spec/components/lists_spec.rb +3 -0
- data/spec/lib/reverse_markdown_spec.rb +2 -1
- data/spec/spec_helper.rb +1 -1
- metadata +14 -8
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94eded67b23dcb767fefb6415557b114e9901aa158e96d6de9eebace8e91cdde
|
4
|
+
data.tar.gz: 52e80dad7a9cfdbaa0c22698b7d08b7c977988bd36febc3fc4c3dece596366e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.
|
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
|
|
@@ -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
|
|
data/lib/reverse_markdown.rb
CHANGED
data/reverse_markdown.gemspec
CHANGED
@@ -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 '
|
26
|
+
s.add_development_dependency 'debug' unless RUBY_ENGINE == 'jruby'
|
27
27
|
s.add_development_dependency 'codeclimate-test-reporter'
|
28
28
|
end
|
data/spec/assets/lists.html
CHANGED
@@ -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
|
@@ -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
|
-
|
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
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:
|
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:
|
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:
|
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
|
-
- ".
|
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.
|
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
|