reverse_markdown 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +6 -4
- data/CHANGELOG.md +4 -0
- data/lib/reverse_markdown/converters/li.rb +8 -4
- data/lib/reverse_markdown/converters/text.rb +1 -1
- data/lib/reverse_markdown/version.rb +1 -1
- data/reverse_markdown.gemspec +1 -1
- data/spec/html_to_markdown_to_html_spec.rb +10 -0
- data/spec/lib/reverse_markdown/converters/pre_spec.rb +5 -0
- data/spec/lib/reverse_markdown/converters/text_spec.rb +6 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 69b75c5dec924f267e5861ed24edafa23a8bb12f3e03cd7068e00ae19406424b
|
4
|
+
data.tar.gz: d53a1f8630a532183b491e982250a3bb175d9ed84188103535255e27ff8d39a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '02949ddc3b08f23f07148bbda7e00a07214d3bc423ec880284c938e30fa872e305ca66fe2b1a9af796c5225dc935fa06c4e19f4085c75d5eaa0b0023eca45961'
|
7
|
+
data.tar.gz: 7c58e5b6fc0560de0e3ef879685db3a8d8f541b07d471b7747492e9918a40334d84a66fcc1c8f76bff061990c661c9b53730e994b435aab28e634ff12cfd6968
|
data/.travis.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
before_install:
|
2
|
-
|
1
|
+
# before_install:
|
2
|
+
# - gem install bundler
|
3
3
|
|
4
4
|
rvm:
|
5
5
|
- 1.9.3
|
@@ -12,11 +12,13 @@ rvm:
|
|
12
12
|
- 2.3.0
|
13
13
|
- 2.3.1
|
14
14
|
- 2.4.2
|
15
|
-
-
|
15
|
+
- 2.5.3
|
16
|
+
- 2.6.2
|
17
|
+
- jruby-9.2.8.0
|
16
18
|
|
17
19
|
script: "bundle exec rake spec"
|
18
20
|
|
19
21
|
notifications:
|
20
22
|
disabled: false
|
21
23
|
recipients:
|
22
|
-
-
|
24
|
+
- xijo@pm.me
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## 1.2.0 - August 2019
|
5
|
+
- Handle windows `\r\n` within text blocks, thanks for reporting @krisdigital
|
6
|
+
- Handle paragraphs in `li` tags, thanks @gstamp
|
7
|
+
|
4
8
|
## 1.1.0 - April 2018
|
5
9
|
- Support Jruby, thanks @grddev (#71)
|
6
10
|
- Bypass `<tfoot>` tags, thanks @mu-is-too-short (#70)
|
@@ -2,10 +2,14 @@ module ReverseMarkdown
|
|
2
2
|
module Converters
|
3
3
|
class Li < Base
|
4
4
|
def convert(node, state = {})
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
contains_child_paragraph = node.children.first ? node.children.first.name == 'p' : false
|
6
|
+
content_node = contains_child_paragraph ? node.children.first : node
|
7
|
+
content = treat_children(content_node, state)
|
8
|
+
indentation = indentation_from(state)
|
9
|
+
prefix = prefix_for(node)
|
10
|
+
|
11
|
+
"#{indentation}#{prefix}#{content.chomp}\n" +
|
12
|
+
(contains_child_paragraph ? "\n" : '')
|
9
13
|
end
|
10
14
|
|
11
15
|
def prefix_for(node)
|
data/reverse_markdown.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "http://github.com/xijo/reverse_markdown"
|
11
11
|
s.summary = %q{Convert html code into markdown.}
|
12
12
|
s.description = %q{Map simple html back into markdown, e.g. if you want to import existing html data in your application.}
|
13
|
-
|
13
|
+
s.licenses = ["WTFPL"]
|
14
14
|
s.rubyforge_project = "reverse_markdown"
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
@@ -52,6 +52,16 @@ describe 'Round trip: HTML to markdown (via reverse_markdown) to HTML (via redca
|
|
52
52
|
")
|
53
53
|
end
|
54
54
|
|
55
|
+
it "should preserve lists with paragraphs" do
|
56
|
+
roundtrip_should_preserve("
|
57
|
+
<ul>
|
58
|
+
<li><p>Bird</p></li>
|
59
|
+
<li><p>McHale</p></li>
|
60
|
+
<li><p>Parish</p></li>
|
61
|
+
</ul>
|
62
|
+
")
|
63
|
+
end
|
64
|
+
|
55
65
|
it "should preserve <hr> tags" do
|
56
66
|
roundtrip_should_preserve("<hr />")
|
57
67
|
end
|
@@ -21,6 +21,11 @@ describe ReverseMarkdown::Converters::Pre do
|
|
21
21
|
node = node_for("<pre><code>foobar</code></pre>")
|
22
22
|
expect(converter.convert(node)).to eq "\n\n foobar\n\n"
|
23
23
|
end
|
24
|
+
|
25
|
+
it 'handles indented correctly' do
|
26
|
+
node = node_for("<pre><code>if foo\n return bar\nend</code></pre>")
|
27
|
+
expect(converter.convert(node)).to eq "\n\n if foo\n return bar\n end\n\n"
|
28
|
+
end
|
24
29
|
end
|
25
30
|
|
26
31
|
context 'for github_flavored markdown' do
|
@@ -10,6 +10,12 @@ describe ReverseMarkdown::Converters::Text do
|
|
10
10
|
expect(result).to eq 'foo bar'
|
11
11
|
end
|
12
12
|
|
13
|
+
it 'handles windows-style \r\n correctly' do
|
14
|
+
input = node_for("<p>foo \r\n\r\n bar</p>")
|
15
|
+
result = converter.convert(input)
|
16
|
+
expect(result).to eq 'foo bar'
|
17
|
+
end
|
18
|
+
|
13
19
|
it 'removes leading newlines' do
|
14
20
|
input = node_for("<p>\n\nfoo bar</p>")
|
15
21
|
result = converter.convert(input)
|
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Opper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -181,7 +181,8 @@ files:
|
|
181
181
|
- spec/lib/reverse_markdown_spec.rb
|
182
182
|
- spec/spec_helper.rb
|
183
183
|
homepage: http://github.com/xijo/reverse_markdown
|
184
|
-
licenses:
|
184
|
+
licenses:
|
185
|
+
- WTFPL
|
185
186
|
metadata: {}
|
186
187
|
post_install_message:
|
187
188
|
rdoc_options: []
|
@@ -198,8 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
199
|
- !ruby/object:Gem::Version
|
199
200
|
version: '0'
|
200
201
|
requirements: []
|
201
|
-
|
202
|
-
rubygems_version: 2.6.4
|
202
|
+
rubygems_version: 3.0.3
|
203
203
|
signing_key:
|
204
204
|
specification_version: 4
|
205
205
|
summary: Convert html code into markdown.
|