reverse_markdown 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +32 -0
- data/README.md +1 -16
- data/Rakefile +7 -3
- data/lib/reverse_markdown/cleaner.rb +15 -7
- data/lib/reverse_markdown/converters/bypass.rb +2 -0
- data/lib/reverse_markdown/converters/ignore.rb +12 -0
- data/lib/reverse_markdown/converters/text.rb +13 -1
- data/lib/reverse_markdown/version.rb +1 -1
- data/lib/reverse_markdown.rb +1 -0
- data/spec/assets/tables.html +23 -15
- data/spec/components/from_the_wild_spec.rb +1 -2
- data/spec/components/unknown_tags_spec.rb +3 -3
- data/spec/html_to_markdown_to_html_spec.rb +3 -2
- data/spec/lib/reverse_markdown/cleaner_spec.rb +21 -13
- data/spec/lib/reverse_markdown/converters/blockquote_spec.rb +2 -2
- data/spec/lib/reverse_markdown/converters/br_spec.rb +1 -1
- data/spec/lib/reverse_markdown/converters/del_spec.rb +7 -7
- data/spec/lib/reverse_markdown/converters/li_spec.rb +1 -1
- data/spec/lib/reverse_markdown/converters/text_spec.rb +25 -0
- data/spec/lib/reverse_markdown_spec.rb +7 -7
- data/spec/spec_helper.rb +0 -2
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 345b5116f393914034fa05e3ceae0f7cabbda791
|
4
|
+
data.tar.gz: ecc2a58d1b46fb2c338d95009d2866239b4de880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d509a043b014bd9e6f72e56bb728befc8923668646b054e7ea6b4cd8576e45e2130a51d1a3100e87c61b518be80e47078b1d19a741e3469ff835790cf901d543
|
7
|
+
data.tar.gz: f199c4efb681293e100f7c5bfbd7436c6ea194273b3a7e76509ec6387f689ceabdfeb1838de8a8e5de976802f6f7e3945f6458aaa6a01d71751c160d1402c286
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
|
5
|
+
## 0.6.0 - September 2014
|
6
|
+
### Added
|
7
|
+
- Ignore `col` and `colgroup` tags
|
8
|
+
- Bypass `thead` and `tbody` tags to show the tables correctly
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
- Eliminate ruby warnings on load (thx @vsipuli)
|
12
|
+
- Treat newlines within text nodes as space
|
13
|
+
- Remove whitespace between inline tags and punctuation characters
|
14
|
+
|
15
|
+
|
16
|
+
## 0.5.1 - April 2014
|
17
|
+
### Added
|
18
|
+
- Adds support for ruby versions 1.9.3 back in
|
19
|
+
- More options for handling of unknown tags
|
20
|
+
|
21
|
+
### Changed
|
22
|
+
- Bugfixes in `li` indentation behavior
|
23
|
+
|
24
|
+
|
25
|
+
## 0.5.0 - March 2014
|
26
|
+
**There were some breaking changes, please make sure you don't miss them:**
|
27
|
+
|
28
|
+
1. Only ruby versions 2.0.0 or above are supported
|
29
|
+
2. There is no `Mapper` class any more. Just use `ReverseMarkdown.convert(input, options)`
|
30
|
+
3. Config option `github_style_code_blocks` changed its name to `github_flavored`
|
31
|
+
|
32
|
+
Please open an issue and let me know about it if you have any trouble with the new version.
|
data/README.md
CHANGED
@@ -6,22 +6,7 @@ Transform html into markdown. Useful for example if you want to import html into
|
|
6
6
|
|
7
7
|
## Changelog
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
1. Adds support for ruby versions 1.9.3 back in
|
12
|
-
2. More options for handling of unknown tags
|
13
|
-
3. Bugfixes in `li` indentation behavior
|
14
|
-
|
15
|
-
### 0.5.0 - March 2014
|
16
|
-
|
17
|
-
There were some breaking changes, please make sure you don't miss them:
|
18
|
-
|
19
|
-
1. Only ruby versions 2.0.0 or above are supported
|
20
|
-
2. There is no `Mapper` class any more. Just use `ReverseMarkdown.convert(input, options)`
|
21
|
-
3. Config option `github_style_code_blocks` changed its name to `github_flavored`
|
22
|
-
|
23
|
-
Please open an issue and let me know about it if you have any trouble with the new version.
|
24
|
-
|
9
|
+
See [Change Log](CHANGELOG.md)
|
25
10
|
|
26
11
|
## Requirements
|
27
12
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
if File.exist?('.codeclimate')
|
4
|
+
ENV["CODECLIMATE_REPO_TOKEN"] = File.read('.codeclimate').strip
|
5
|
+
end
|
2
6
|
|
3
7
|
require 'rspec/core/rake_task'
|
4
8
|
RSpec::Core::RakeTask.new(:spec)
|
5
9
|
task :default => :spec
|
6
10
|
|
7
|
-
desc
|
11
|
+
desc 'Open an irb session preloaded with this library'
|
8
12
|
task :console do
|
9
|
-
sh
|
13
|
+
sh 'irb -rubygems -I lib -r reverse_markdown.rb'
|
10
14
|
end
|
@@ -2,7 +2,11 @@ module ReverseMarkdown
|
|
2
2
|
class Cleaner
|
3
3
|
|
4
4
|
def tidy(string)
|
5
|
-
|
5
|
+
result = remove_inner_whitespaces(string)
|
6
|
+
result = remove_newlines(result)
|
7
|
+
result = remove_leading_newlines(result)
|
8
|
+
result = clean_tag_borders(result)
|
9
|
+
clean_punctuation_characters(result)
|
6
10
|
end
|
7
11
|
|
8
12
|
def remove_newlines(string)
|
@@ -10,7 +14,7 @@ module ReverseMarkdown
|
|
10
14
|
end
|
11
15
|
|
12
16
|
def remove_leading_newlines(string)
|
13
|
-
string.gsub
|
17
|
+
string.gsub(/\A\n+/, '')
|
14
18
|
end
|
15
19
|
|
16
20
|
def remove_inner_whitespaces(string)
|
@@ -22,35 +26,39 @@ module ReverseMarkdown
|
|
22
26
|
end
|
23
27
|
|
24
28
|
# Find non-asterisk content that is enclosed by two or
|
25
|
-
# more asterisks. Ensure that only one whitespace
|
29
|
+
# more asterisks. Ensure that only one whitespace occurs
|
26
30
|
# in the border area.
|
27
31
|
# Same for underscores and brackets.
|
28
32
|
def clean_tag_borders(string)
|
29
|
-
result = string.gsub
|
33
|
+
result = string.gsub(/\s?\*{2,}.*?\*{2,}\s?/) do |match|
|
30
34
|
preserve_border_whitespaces(match, default_border: ' ') do
|
31
35
|
match.strip.sub('** ', '**').sub(' **', '**')
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
|
-
result = result.gsub
|
39
|
+
result = result.gsub(/\s?\_{2,}.*?\_{2,}\s?/) do |match|
|
36
40
|
preserve_border_whitespaces(match, default_border: ' ') do
|
37
41
|
match.strip.sub('__ ', '__').sub(' __', '__')
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
|
-
result = result.gsub
|
45
|
+
result = result.gsub(/\s?~{2,}.*?~{2,}\s?/) do |match|
|
42
46
|
preserve_border_whitespaces(match, default_border: ' ') do
|
43
47
|
match.strip.sub('~~ ', '~~').sub(' ~~', '~~')
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
47
|
-
result.gsub
|
51
|
+
result.gsub(/\s?\[.*?\]\s?/) do |match|
|
48
52
|
preserve_border_whitespaces(match) do
|
49
53
|
match.strip.sub('[ ', '[').sub(' ]', ']')
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
58
|
+
def clean_punctuation_characters(string)
|
59
|
+
string.gsub(/(\*\*|~~|__)\s([\.!\?'"])/, "\\1".strip + "\\2")
|
60
|
+
end
|
61
|
+
|
54
62
|
private
|
55
63
|
|
56
64
|
def preserve_border_whitespaces(string, options = {}, &block)
|
@@ -9,6 +9,8 @@ module ReverseMarkdown
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
private
|
13
|
+
|
12
14
|
def treat_empty(node)
|
13
15
|
parent = node.parent.name.to_sym
|
14
16
|
if [:ol, :ul].include?(parent) # Otherwise the identation is broken
|
@@ -21,7 +23,17 @@ module ReverseMarkdown
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def treat_text(node)
|
24
|
-
|
26
|
+
text = remove_border_newlines(node.text)
|
27
|
+
text = remove_inner_newlines(text)
|
28
|
+
escape_keychars text
|
29
|
+
end
|
30
|
+
|
31
|
+
def remove_border_newlines(text)
|
32
|
+
text.gsub(/\A\n+/, '').gsub(/\n+\z/, '')
|
33
|
+
end
|
34
|
+
|
35
|
+
def remove_inner_newlines(text)
|
36
|
+
text.tr("\n\t", ' ').squeeze(' ')
|
25
37
|
end
|
26
38
|
end
|
27
39
|
|
data/lib/reverse_markdown.rb
CHANGED
@@ -17,6 +17,7 @@ require 'reverse_markdown/converters/drop'
|
|
17
17
|
require 'reverse_markdown/converters/em'
|
18
18
|
require 'reverse_markdown/converters/h'
|
19
19
|
require 'reverse_markdown/converters/hr'
|
20
|
+
require 'reverse_markdown/converters/ignore'
|
20
21
|
require 'reverse_markdown/converters/img'
|
21
22
|
require 'reverse_markdown/converters/li'
|
22
23
|
require 'reverse_markdown/converters/ol'
|
data/spec/assets/tables.html
CHANGED
@@ -3,21 +3,29 @@
|
|
3
3
|
some text...
|
4
4
|
|
5
5
|
<table>
|
6
|
-
<
|
7
|
-
<
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
<
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
<
|
19
|
-
|
20
|
-
|
6
|
+
<thead>
|
7
|
+
<colgroup>
|
8
|
+
<col span="2" style="background-color:red">
|
9
|
+
<col style="background-color:yellow">
|
10
|
+
</colgroup>
|
11
|
+
</thead>
|
12
|
+
<tbody>
|
13
|
+
<tr>
|
14
|
+
<th>header 1</th>
|
15
|
+
<th>header 2</th>
|
16
|
+
<th>header 3</th>
|
17
|
+
</tr>
|
18
|
+
<tr>
|
19
|
+
<td>data 1-1</td>
|
20
|
+
<td>data 2-1</td>
|
21
|
+
<td>data 3-1</td>
|
22
|
+
</tr>
|
23
|
+
<tr>
|
24
|
+
<td>data 1-2</td>
|
25
|
+
<td>data 2-2</td>
|
26
|
+
<td>data 3-2</td>
|
27
|
+
</tr>
|
28
|
+
</tbody>
|
21
29
|
</table>
|
22
30
|
|
23
31
|
<table>
|
@@ -7,8 +7,7 @@ describe ReverseMarkdown do
|
|
7
7
|
subject { ReverseMarkdown.convert(input) }
|
8
8
|
|
9
9
|
it "should make sense of strong-crazy markup (as seen in the wild)" do
|
10
|
-
subject.
|
11
|
-
'** .' + " \n" +
|
10
|
+
expect(subject).to eq '**.' + " \n" +
|
12
11
|
' \*\*\* intentcast ** : logo design' + " \n" +
|
13
12
|
"**.**\n\n"
|
14
13
|
end
|
@@ -9,7 +9,7 @@ describe ReverseMarkdown do
|
|
9
9
|
context 'with unknown_tags = :pass_through' do
|
10
10
|
before { ReverseMarkdown.config.unknown_tags = :pass_through }
|
11
11
|
|
12
|
-
it { result.
|
12
|
+
it { expect(result).to include "<bar>Foo with bar</bar>" }
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'with unknown_tags = :raise' do
|
@@ -21,13 +21,13 @@ describe ReverseMarkdown do
|
|
21
21
|
context 'with unknown_tags = :drop' do
|
22
22
|
before { ReverseMarkdown.config.unknown_tags = :drop }
|
23
23
|
|
24
|
-
it { result.
|
24
|
+
it { expect(result).to eq '' }
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'with unknown_tags = :bypass' do
|
28
28
|
before { ReverseMarkdown.config.unknown_tags = :bypass }
|
29
29
|
|
30
|
-
it { result.
|
30
|
+
it { expect(result).to eq "Foo with bar\n\n" }
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'with unknown_tags = :something_wrong' do
|
@@ -7,8 +7,9 @@ describe 'Round trip: HTML to markdown (via reverse_markdown) to HTML (via redca
|
|
7
7
|
|
8
8
|
# helpers
|
9
9
|
|
10
|
-
def roundtrip_should_preserve(
|
11
|
-
|
10
|
+
def roundtrip_should_preserve(input)
|
11
|
+
output = html2markdown2html input
|
12
|
+
expect(normalize_html(input)).to eq normalize_html(output)
|
12
13
|
end
|
13
14
|
|
14
15
|
def html2markdown2html(orig_html)
|
@@ -6,44 +6,52 @@ describe ReverseMarkdown::Cleaner do
|
|
6
6
|
describe '#remove_newlines' do
|
7
7
|
it 'removes more than 2 subsequent newlines' do
|
8
8
|
result = cleaner.remove_newlines("foo\n\n\nbar")
|
9
|
-
result.
|
9
|
+
expect(result).to eq "foo\n\nbar"
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'skips single and double newlines' do
|
13
13
|
result = cleaner.remove_newlines("foo\nbar\n\nbaz")
|
14
|
-
result.
|
14
|
+
expect(result).to eq "foo\nbar\n\nbaz"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe '#remove_inner_whitespaces' do
|
19
19
|
it 'removes duplicate whitespaces from the string' do
|
20
20
|
result = cleaner.remove_inner_whitespaces('foo bar')
|
21
|
-
result.
|
21
|
+
expect(result).to eq "foo bar"
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'performs changes for multiple lines' do
|
25
25
|
result = cleaner.remove_inner_whitespaces("foo bar\nbar foo")
|
26
|
-
result.
|
26
|
+
expect(result).to eq "foo bar\nbar foo"
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'keeps leading whitespaces' do
|
30
30
|
result = cleaner.remove_inner_whitespaces(" foo bar\n bar foo")
|
31
|
-
result.
|
31
|
+
expect(result).to eq " foo bar\n bar foo"
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'keeps trailing whitespaces' do
|
35
35
|
result = cleaner.remove_inner_whitespaces("foo \n")
|
36
|
-
result.
|
36
|
+
expect(result).to eq "foo \n"
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'keeps trailing newlines' do
|
40
40
|
result = cleaner.remove_inner_whitespaces("foo\n")
|
41
|
-
result.
|
41
|
+
expect(result).to eq "foo\n"
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'removes tabs as well' do
|
45
45
|
result = cleaner.remove_inner_whitespaces("foo\t \tbar")
|
46
|
-
result.
|
46
|
+
expect(result).to eq "foo bar"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#clean_punctuation_characters' do
|
51
|
+
it 'removes whitespace between tag end and punctuation characters' do
|
52
|
+
input = "**fat** . ~~strike~~ ? __italic__ ! "
|
53
|
+
result = cleaner.clean_punctuation_characters(input)
|
54
|
+
expect(result).to eq "**fat**. ~~strike~~? __italic__! "
|
47
55
|
end
|
48
56
|
end
|
49
57
|
|
@@ -51,31 +59,31 @@ describe ReverseMarkdown::Cleaner do
|
|
51
59
|
it 'removes not needed whitespaces from strong tags' do
|
52
60
|
input = "foo ** foobar ** bar"
|
53
61
|
result = cleaner.clean_tag_borders(input)
|
54
|
-
result.
|
62
|
+
expect(result).to eq "foo **foobar** bar"
|
55
63
|
end
|
56
64
|
|
57
65
|
it 'remotes leading or trailing whitespaces independently' do
|
58
66
|
input = "1 **fat ** 2 ** fat** 3"
|
59
67
|
result = cleaner.clean_tag_borders(input)
|
60
|
-
result.
|
68
|
+
expect(result).to eq "1 **fat** 2 **fat** 3"
|
61
69
|
end
|
62
70
|
|
63
71
|
it 'adds whitespaces if there are none' do
|
64
72
|
input = "1**fat**2"
|
65
73
|
result = cleaner.clean_tag_borders(input)
|
66
|
-
result.
|
74
|
+
expect(result).to eq "1 **fat** 2"
|
67
75
|
end
|
68
76
|
|
69
77
|
it 'cleans italic stuff as well' do
|
70
78
|
input = "1 __italic __ 2 __ italic__ 3__italic __4"
|
71
79
|
result = cleaner.clean_tag_borders(input)
|
72
|
-
result.
|
80
|
+
expect(result).to eq "1 __italic__ 2 __italic__ 3 __italic__ 4"
|
73
81
|
end
|
74
82
|
|
75
83
|
it 'cleans strikethrough stuff as well' do
|
76
84
|
input = "1 ~~italic ~~ 2 ~~ italic~~ 3~~italic ~~4"
|
77
85
|
result = cleaner.clean_tag_borders(input)
|
78
|
-
result.
|
86
|
+
expect(result).to eq "1 ~~italic~~ 2 ~~italic~~ 3 ~~italic~~ 4"
|
79
87
|
end
|
80
88
|
end
|
81
89
|
|
@@ -7,12 +7,12 @@ describe ReverseMarkdown::Converters::Blockquote do
|
|
7
7
|
it 'converts nested elements as well' do
|
8
8
|
input = Nokogiri::XML.parse("<blockquote><ul><li>foo</li></ul></blockquote>").root
|
9
9
|
result = converter.convert(input)
|
10
|
-
result.
|
10
|
+
expect(result).to eq "> - foo"
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'can deal with paragraphs inside' do
|
14
14
|
input = Nokogiri::XML.parse("<blockquote><p>Some text.</p><p>Some more text.</p></blockquote>").root
|
15
15
|
result = converter.convert(input)
|
16
|
-
result.
|
16
|
+
expect(result).to eq "> Some text.\n> \n> Some more text."
|
17
17
|
end
|
18
18
|
end
|
@@ -8,17 +8,17 @@ describe ReverseMarkdown::Converters::Del do
|
|
8
8
|
|
9
9
|
it 'converts the input as expected' do
|
10
10
|
input = Nokogiri::XML.parse('<del>deldeldel</del>').root
|
11
|
-
converter.convert(input).
|
11
|
+
expect(converter.convert(input)).to eq '~~deldeldel~~'
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'skips empty tags' do
|
15
15
|
input = Nokogiri::XML.parse('<del></del>').root
|
16
|
-
converter.convert(input).
|
16
|
+
expect(converter.convert(input)).to eq ''
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'knows about its enabled/disabled state' do
|
20
|
-
converter.
|
21
|
-
converter.
|
20
|
+
expect(converter).to be_enabled
|
21
|
+
expect(converter).not_to be_disabled
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -27,12 +27,12 @@ describe ReverseMarkdown::Converters::Del do
|
|
27
27
|
|
28
28
|
it 'does not convert anything' do
|
29
29
|
input = Nokogiri::XML.parse('<del>deldeldel</del>').root
|
30
|
-
converter.convert(input).
|
30
|
+
expect(converter.convert(input)).to eq 'deldeldel'
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'knows about its enabled/disabled state' do
|
34
|
-
converter.
|
35
|
-
converter.
|
34
|
+
expect(converter).not_to be_enabled
|
35
|
+
expect(converter).to be_disabled
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -7,7 +7,7 @@ describe ReverseMarkdown::Converters::Li do
|
|
7
7
|
it 'does not fail without a valid parent context' do
|
8
8
|
input = Nokogiri::XML.parse("<li>foo</li>").root
|
9
9
|
result = converter.convert(input)
|
10
|
-
result.
|
10
|
+
expect(result).to eq "- foo\n"
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ReverseMarkdown::Converters::Text do
|
4
|
+
|
5
|
+
let(:converter) { ReverseMarkdown::Converters::Text.new }
|
6
|
+
|
7
|
+
it 'treats newline within text as a single whitespace' do
|
8
|
+
input = Nokogiri::XML.parse("<p>foo\nbar</p>").root
|
9
|
+
result = converter.convert(input)
|
10
|
+
expect(result).to eq 'foo bar'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'removes leading newlines' do
|
14
|
+
input = Nokogiri::XML.parse("<p>\n\nfoo bar</p>").root
|
15
|
+
result = converter.convert(input)
|
16
|
+
expect(result).to eq 'foo bar'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'removes trailing newlines' do
|
20
|
+
input = Nokogiri::XML.parse("<p>foo bar\n\n</p>").root
|
21
|
+
result = converter.convert(input)
|
22
|
+
expect(result).to eq 'foo bar'
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -5,33 +5,33 @@ describe ReverseMarkdown do
|
|
5
5
|
let(:document) { Nokogiri::HTML(input) }
|
6
6
|
|
7
7
|
it "parses nokogiri documents" do
|
8
|
-
|
8
|
+
expect { ReverseMarkdown.convert(document) }.not_to raise_error
|
9
9
|
end
|
10
10
|
|
11
11
|
it "parses nokogiri elements" do
|
12
|
-
|
12
|
+
expect { ReverseMarkdown.convert(document.root) }.not_to raise_error
|
13
13
|
end
|
14
14
|
|
15
15
|
it "parses string input" do
|
16
|
-
|
16
|
+
expect { ReverseMarkdown.convert(input) }.not_to raise_error
|
17
17
|
end
|
18
18
|
|
19
19
|
it "behaves in a sane way when root element is nil" do
|
20
|
-
ReverseMarkdown.convert(nil).
|
20
|
+
expect(ReverseMarkdown.convert(nil)).to eq ''
|
21
21
|
end
|
22
22
|
|
23
23
|
describe '#config' do
|
24
24
|
it 'stores a given configuration option' do
|
25
25
|
ReverseMarkdown.config.github_flavored = true
|
26
|
-
ReverseMarkdown.config.github_flavored.
|
26
|
+
expect(ReverseMarkdown.config.github_flavored).to eq true
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'can be used as a block configurator as well' do
|
30
30
|
ReverseMarkdown.config do |config|
|
31
|
-
config.github_flavored.
|
31
|
+
expect(config.github_flavored).to eq false
|
32
32
|
config.github_flavored = true
|
33
33
|
end
|
34
|
-
ReverseMarkdown.config.github_flavored.
|
34
|
+
expect(ReverseMarkdown.config.github_flavored).to eq true
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
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: 0.
|
4
|
+
version: 0.6.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: 2014-
|
11
|
+
date: 2014-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -104,7 +104,9 @@ extensions: []
|
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
106
|
- ".gitignore"
|
107
|
+
- ".rspec"
|
107
108
|
- ".travis.yml"
|
109
|
+
- CHANGELOG.md
|
108
110
|
- Gemfile
|
109
111
|
- LICENSE
|
110
112
|
- README.md
|
@@ -126,6 +128,7 @@ files:
|
|
126
128
|
- lib/reverse_markdown/converters/em.rb
|
127
129
|
- lib/reverse_markdown/converters/h.rb
|
128
130
|
- lib/reverse_markdown/converters/hr.rb
|
131
|
+
- lib/reverse_markdown/converters/ignore.rb
|
129
132
|
- lib/reverse_markdown/converters/img.rb
|
130
133
|
- lib/reverse_markdown/converters/li.rb
|
131
134
|
- lib/reverse_markdown/converters/ol.rb
|
@@ -170,6 +173,7 @@ files:
|
|
170
173
|
- spec/lib/reverse_markdown/converters/br_spec.rb
|
171
174
|
- spec/lib/reverse_markdown/converters/del_spec.rb
|
172
175
|
- spec/lib/reverse_markdown/converters/li_spec.rb
|
176
|
+
- spec/lib/reverse_markdown/converters/text_spec.rb
|
173
177
|
- spec/lib/reverse_markdown_spec.rb
|
174
178
|
- spec/spec_helper.rb
|
175
179
|
homepage: http://github.com/xijo/reverse_markdown
|
@@ -226,5 +230,6 @@ test_files:
|
|
226
230
|
- spec/lib/reverse_markdown/converters/br_spec.rb
|
227
231
|
- spec/lib/reverse_markdown/converters/del_spec.rb
|
228
232
|
- spec/lib/reverse_markdown/converters/li_spec.rb
|
233
|
+
- spec/lib/reverse_markdown/converters/text_spec.rb
|
229
234
|
- spec/lib/reverse_markdown_spec.rb
|
230
235
|
- spec/spec_helper.rb
|