reverse_markdown 0.8.0 → 0.8.1

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
  SHA1:
3
- metadata.gz: 01b3bd87ed314c7c27b36ea54e85094b8978f47a
4
- data.tar.gz: 5e6281c33ddd442a52ada8b35753f7e50782f0f1
3
+ metadata.gz: ad925687978f44b00fbabc9a9a8f526033d94a4c
4
+ data.tar.gz: 39313ccac2c11accd0bb6b8c69f7c0ae39c3c1a1
5
5
  SHA512:
6
- metadata.gz: 9ddc12421dd427d581c14e0c4fe3eb98087bb057b24401b7e8bed7975ed8a1ff52b1ddefbbb9494c8a7136dbe35010cb0fcd31ef2419be338247bf45b5ef90ea
7
- data.tar.gz: 9078b5ed562091011c7d3de8578bf514fcfba0c83aad596c9752c38b5e56a00d63e38c737e6c9e09fcad75b338ed673b4f7a78f34c8ed3141e5cfb2a70748e3c
6
+ metadata.gz: dcd1e5ecfc3f651122af1a5b452c7aea5faec608a4fcef1e853d5a03b331ed32795f7050c29a8464ff911b063805ebe0bd7a82dca21b634aa8b0346abb512ada
7
+ data.tar.gz: becbab17c4dbc95024f056f1099248a8b3ea35d1d1c2e3a34dfa4948f4a2e2bbe9c8a92fb39b209e4465ddcb92743f448c39dba02ece6b04febd2c436113915c
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
+ ## 0.8.1 - April 2015
5
+ ### Changes
6
+ - Don't add newlines after nested lists
7
+
4
8
  ## 0.8.0 - April 2015
5
9
  ### Added
6
10
  - `article` tag is now supported and treated like a div
@@ -5,7 +5,7 @@ module ReverseMarkdown
5
5
  content = treat_children(node)
6
6
  indentation = indentation_for(node)
7
7
  prefix = prefix_for(node)
8
- "#{indentation}#{prefix}#{content}\n"
8
+ "#{indentation}#{prefix}#{content.chomp}\n"
9
9
  end
10
10
 
11
11
  def prefix_for(node)
@@ -1,3 +1,3 @@
1
1
  module ReverseMarkdown
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  <html>
2
2
  <body>
3
- some text...
3
+ <p>some text...</p>
4
4
 
5
5
  <ul>
6
6
  <li>unordered list entry</li>
@@ -26,10 +26,10 @@
26
26
  </li>
27
27
  </ol>
28
28
 
29
- a nested list with no whitespace:
29
+ <p>a nested list with no whitespace:</p>
30
30
  <ul><li>item a</li><li>item b<ul><li>item bb</li><li>item bc</li></ul></li></ul>
31
31
 
32
- a nested list with lots of whitespace:
32
+ <p>a nested list with lots of whitespace:</p>
33
33
  <ul> <li> item wa </li> <li> item wb <ul> <li> item wbb </li> <li> item wbc </li> </ul> </li> </ul>
34
34
 
35
35
  <ul>
@@ -76,5 +76,22 @@
76
76
  <li>three</li>
77
77
  </ol>
78
78
 
79
+ <p>a nested list between adjacent list items</p>
80
+ <ul>
81
+ <li>alpha</li>
82
+ <li>bravo
83
+ <ul>
84
+ <li>bravo alpha</li>
85
+ <li>bravo bravo
86
+ <ul>
87
+ <li>bravo bravo alpha</i>
88
+ </ul>
89
+ </li>
90
+ </ul>
91
+ </li>
92
+ <li>charlie</li>
93
+ <li>delta</li>
94
+ </ul>
95
+
79
96
  </body>
80
97
  </html>
@@ -6,21 +6,21 @@ describe ReverseMarkdown do
6
6
  let(:document) { Nokogiri::HTML(input) }
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
- it { should include ' [Foobar](http://foobar.com) ' }
10
- it { should include ' [Fubar](http://foobar.com "f\*\*\*\*\* up beyond all recognition") ' }
11
- it { should include ' [**Strong foobar**](http://strong.foobar.com) ' }
9
+ it { is_expected.to include ' [Foobar](http://foobar.com) ' }
10
+ it { is_expected.to include ' [Fubar](http://foobar.com "f\*\*\*\*\* up beyond all recognition") ' }
11
+ it { is_expected.to include ' [**Strong foobar**](http://strong.foobar.com) ' }
12
12
 
13
- it { should include ' ![](http://foobar.com/logo.png) ' }
14
- it { should include ' ![foobar image](http://foobar.com/foobar.png) ' }
15
- it { should include ' ![foobar image 2](http://foobar.com/foobar2.png "this is the foobar image 2") ' }
16
- it { should include 'extra space after the [anchor](http://foobar.com).'}
17
- it { should include 'But inline, [there](http://foobar.com) should be a space.'}
13
+ it { is_expected.to include ' ![](http://foobar.com/logo.png) ' }
14
+ it { is_expected.to include ' ![foobar image](http://foobar.com/foobar.png) ' }
15
+ it { is_expected.to include ' ![foobar image 2](http://foobar.com/foobar2.png "this is the foobar image 2") ' }
16
+ it { is_expected.to include 'extra space after the [anchor](http://foobar.com).'}
17
+ it { is_expected.to include 'But inline, [there](http://foobar.com) should be a space.'}
18
18
 
19
19
  context "links to ignore" do
20
- it { should include ' ignore anchor tags with no link text ' }
21
- it { should include ' not ignore [![An Image](image.png)](foo.html) anchor tags with images' }
22
- it { should include ' pass through the text of internal jumplinks without treating them as links ' }
23
- it { should include ' pass through the text of anchor tags with no href without treating them as links ' }
20
+ it { is_expected.to include ' ignore anchor tags with no link text ' }
21
+ it { is_expected.to include ' not ignore [![An Image](image.png)](foo.html) anchor tags with images' }
22
+ it { is_expected.to include ' pass through the text of internal jumplinks without treating them as links ' }
23
+ it { is_expected.to include ' pass through the text of anchor tags with no href without treating them as links ' }
24
24
  end
25
25
 
26
26
  end
@@ -6,38 +6,38 @@ describe ReverseMarkdown do
6
6
  let(:document) { Nokogiri::HTML(input) }
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
- it { should match /plain text ?\n/ }
10
- it { should match /# h1\n/ }
11
- it { should match /## h2\n/ }
12
- it { should match /### h3\n/ }
13
- it { should match /#### h4\n/ }
14
- it { should match /##### h5\n/ }
15
- it { should match /###### h6\n/ }
16
-
17
- it { should match /_em tag content_/ }
18
- it { should match /before and after empty em tags/ }
19
- it { should match /before and after em tags containing whitespace/ }
20
- it { should match /_double em tags_/ }
21
- it { should match /_double em tags in p tag_/ }
22
- it { should match /_em with leading and trailing_ whitespace/ }
23
- it { should match /_em with extra leading and trailing_ whitespace/ }
24
-
25
- it { should match /\*\*strong tag content\*\*/ }
26
- it { should match /before and after empty strong tags/ }
27
- it { should match /before and after strong tags containing whitespace/ }
28
- it { should match /\*\*double strong tags\*\*/ }
29
- it { should match /\*\*double strong tags in p tag\*\*/ }
30
- it { should match /before \*\*double strong tags containing whitespace\*\* after/ }
31
- it { should match /\*\*strong with leading and trailing\*\* whitespace/ }
32
- it { should match /\*\*strong with extra leading and trailing\*\* whitespace/ }
33
-
34
- it { should match /_i tag content_/ }
35
- it { should match /\*\*b tag content\*\*/ }
36
-
37
- it { should match /br tags become double space followed by newline \n/ }
9
+ it { is_expected.to match /plain text ?\n/ }
10
+ it { is_expected.to match /# h1\n/ }
11
+ it { is_expected.to match /## h2\n/ }
12
+ it { is_expected.to match /### h3\n/ }
13
+ it { is_expected.to match /#### h4\n/ }
14
+ it { is_expected.to match /##### h5\n/ }
15
+ it { is_expected.to match /###### h6\n/ }
16
+
17
+ it { is_expected.to match /_em tag content_/ }
18
+ it { is_expected.to match /before and after empty em tags/ }
19
+ it { is_expected.to match /before and after em tags containing whitespace/ }
20
+ it { is_expected.to match /_double em tags_/ }
21
+ it { is_expected.to match /_double em tags in p tag_/ }
22
+ it { is_expected.to match /_em with leading and trailing_ whitespace/ }
23
+ it { is_expected.to match /_em with extra leading and trailing_ whitespace/ }
24
+
25
+ it { is_expected.to match /\*\*strong tag content\*\*/ }
26
+ it { is_expected.to match /before and after empty strong tags/ }
27
+ it { is_expected.to match /before and after strong tags containing whitespace/ }
28
+ it { is_expected.to match /\*\*double strong tags\*\*/ }
29
+ it { is_expected.to match /\*\*double strong tags in p tag\*\*/ }
30
+ it { is_expected.to match /before \*\*double strong tags containing whitespace\*\* after/ }
31
+ it { is_expected.to match /\*\*strong with leading and trailing\*\* whitespace/ }
32
+ it { is_expected.to match /\*\*strong with extra leading and trailing\*\* whitespace/ }
33
+
34
+ it { is_expected.to match /_i tag content_/ }
35
+ it { is_expected.to match /\*\*b tag content\*\*/ }
36
+
37
+ it { is_expected.to match /br tags become double space followed by newline \n/ }
38
38
  #it { should match /br tags XXX \n/ }
39
39
 
40
- it { should match /before hr \n\* \* \*\n after hr/ }
40
+ it { is_expected.to match /before hr \n\* \* \*\n after hr/ }
41
41
 
42
- it { should match /section 1\n ?\nsection 2/ }
42
+ it { is_expected.to match /section 1\n ?\nsection 2/ }
43
43
  end
@@ -6,22 +6,22 @@ describe ReverseMarkdown do
6
6
  let(:document) { Nokogiri::HTML(input) }
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
- it { should match /inline `code` block/ }
10
- it { should match /\ var this\;\n this\.is/ }
11
- it { should match /block"\)\n console/ }
9
+ it { is_expected.to match /inline `code` block/ }
10
+ it { is_expected.to match /\ var this\;\n this\.is/ }
11
+ it { is_expected.to match /block"\)\n console/ }
12
12
 
13
13
  context "with github style code blocks" do
14
14
  subject { ReverseMarkdown.convert(input, github_flavored: true) }
15
- it { should match /inline `code` block/ }
16
- it { should match /```\nvar this\;\nthis/ }
17
- it { should match /it is"\) ?\n```/ }
15
+ it { is_expected.to match /inline `code` block/ }
16
+ it { is_expected.to match /```\nvar this\;\nthis/ }
17
+ it { is_expected.to match /it is"\) ?\n```/ }
18
18
  end
19
19
 
20
20
  context "code with indentation" do
21
21
  subject { ReverseMarkdown.convert(input) }
22
- it { should match(/^ tell application "Foo"\n/) }
23
- it { should match(/^ beep\n/) }
24
- it { should match(/^ end tell\n/) }
22
+ it { is_expected.to match(/^ tell application "Foo"\n/) }
23
+ it { is_expected.to match(/^ beep\n/) }
24
+ it { is_expected.to match(/^ end tell\n/) }
25
25
  end
26
26
 
27
27
  end
@@ -7,16 +7,16 @@ describe ReverseMarkdown do
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
9
  context "multiple asterisks" do
10
- it { should include ' \*\*two asterisks\*\* ' }
11
- it { should include ' \*\*\*three asterisks\*\*\* ' }
10
+ it { is_expected.to include ' \*\*two asterisks\*\* ' }
11
+ it { is_expected.to include ' \*\*\*three asterisks\*\*\* ' }
12
12
  end
13
13
 
14
14
  context "multiple underscores" do
15
- it { should include ' \_\_two underscores\_\_ ' }
16
- it { should include ' \_\_\_three underscores\_\_\_ ' }
15
+ it { is_expected.to include ' \_\_two underscores\_\_ ' }
16
+ it { is_expected.to include ' \_\_\_three underscores\_\_\_ ' }
17
17
  end
18
18
 
19
19
  context "underscores within words in code blocks" do
20
- it { should include ' var theoretical_max_infin = 1.0;' }
20
+ it { is_expected.to include ' var theoretical_max_infin = 1.0;' }
21
21
  end
22
22
  end
@@ -6,6 +6,6 @@ describe ReverseMarkdown do
6
6
  let(:document) { Nokogiri::HTML(input) }
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
- it { should == "naked text 1\n\nparagraph text\n\nnaked text 2" }
9
+ it { is_expected.to eq("naked text 1\n\nparagraph text\n\nnaked text 2") }
10
10
  end
11
11
 
@@ -6,51 +6,62 @@ describe ReverseMarkdown do
6
6
  let(:document) { Nokogiri::HTML(input) }
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
- it { should match /\n- unordered list entry\n/ }
10
- it { should match /\n- unordered list entry 2\n/ }
11
- it { should match /\n1. ordered list entry\n/ }
12
- it { should match /\n2. ordered list entry 2\n/ }
13
- it { should match /\n1. list entry 1st hierarchy\n/ }
14
- it { should match /\n {2}- nested unsorted list entry\n/ }
15
- it { should match /\n {4}1. deep nested list entry\n/ }
9
+ it { is_expected.to match /\n- unordered list entry\n/ }
10
+ it { is_expected.to match /\n- unordered list entry 2\n/ }
11
+ it { is_expected.to match /\n1. ordered list entry\n/ }
12
+ it { is_expected.to match /\n2. ordered list entry 2\n/ }
13
+ it { is_expected.to match /\n1. list entry 1st hierarchy\n/ }
14
+ it { is_expected.to match /\n {2}- nested unsorted list entry\n/ }
15
+ it { is_expected.to match /\n {4}1. deep nested list entry\n/ }
16
16
 
17
17
  context "nested list with no whitespace" do
18
- it { should match /\n- item a\n/ }
19
- it { should match /\n- item b\n/ }
20
- it { should match /\n {2}- item bb\n/ }
21
- it { should match /\n {2}- item bc\n/ }
18
+ it { is_expected.to match /\n- item a\n/ }
19
+ it { is_expected.to match /\n- item b\n/ }
20
+ it { is_expected.to match /\n {2}- item bb\n/ }
21
+ it { is_expected.to match /\n {2}- item bc\n/ }
22
22
  end
23
23
 
24
24
  context "nested list with lots of whitespace" do
25
- it { should match /\n- item wa \n/ }
26
- it { should match /\n- item wb \n/ }
27
- it { should match /\n - item wbb \n/ }
28
- it { should match /\n - item wbc \n/ }
25
+ it { is_expected.to match /\n- item wa \n/ }
26
+ it { is_expected.to match /\n- item wb \n/ }
27
+ it { is_expected.to match /\n - item wbb \n/ }
28
+ it { is_expected.to match /\n - item wbc \n/ }
29
29
  end
30
30
 
31
31
  context "lists containing links" do
32
- it { should match /\n- \[1 Basic concepts\]\(Basic_concepts\)\n/ }
33
- it { should match /\n- \[2 History of the idea\]\(History_of_the_idea\)\n/ }
34
- it { should match /\n- \[3 Intelligence explosion\]\(Intelligence_explosion\)\n/ }
32
+ it { is_expected.to match /\n- \[1 Basic concepts\]\(Basic_concepts\)\n/ }
33
+ it { is_expected.to match /\n- \[2 History of the idea\]\(History_of_the_idea\)\n/ }
34
+ it { is_expected.to match /\n- \[3 Intelligence explosion\]\(Intelligence_explosion\)\n/ }
35
35
  end
36
36
 
37
37
  context "lists containing embedded <p> tags" do
38
- xit { should match /\n- I want to have a party at my house!\n/ }
38
+ xit { is_expected.to match /\n- I want to have a party at my house!\n/ }
39
39
  end
40
40
 
41
41
  context "list item containing multiple <p> tags" do
42
- xit { should match /\n- li 1, p 1\n\n- li 1, p 2\n/ }
42
+ xit { is_expected.to match /\n- li 1, p 1\n\n- li 1, p 2\n/ }
43
43
  end
44
44
 
45
45
  context 'it produces correct numbering' do
46
- it { should include "1. one" }
47
- it { should include " 1. one one" }
48
- it { should include " 2. one two" }
49
- it { should include "2. two" }
50
- it { should include " 1. two one" }
51
- it { should include " 1. two one one" }
52
- it { should include " 2. two one two" }
53
- it { should include " 2. two two" }
54
- it { should include "3. three" }
46
+ it { is_expected.to include "1. one" }
47
+ it { is_expected.to include " 1. one one" }
48
+ it { is_expected.to include " 2. one two" }
49
+ it { is_expected.to include "2. two" }
50
+ it { is_expected.to include " 1. two one" }
51
+ it { is_expected.to include " 1. two one one" }
52
+ it { is_expected.to include " 2. two one two" }
53
+ it { is_expected.to include " 2. two two" }
54
+ it { is_expected.to include "3. three" }
55
55
  end
56
+
57
+ context "properly embeds a nested list between adjacent list items" do
58
+ it { is_expected.to match /\n- alpha\n/ }
59
+ it { is_expected.to match /\n- bravo/ }
60
+ it { is_expected.to match /\n - bravo alpha\n/ }
61
+ it { is_expected.to match /\n - bravo bravo/ }
62
+ it { is_expected.to match /\n - bravo bravo alpha/ }
63
+ it { is_expected.to match /\n- charlie\n/ }
64
+ it { is_expected.to match /\n- delta\n/ }
65
+ end
66
+
56
67
  end
@@ -6,10 +6,10 @@ describe ReverseMarkdown do
6
6
  let(:document) { Nokogiri::HTML(input) }
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
- it { should_not start_with "\n\n" }
10
- it { should start_with "First content\n\nSecond content\n\n" }
11
- it { should include "\n\n_Complex_\n\n Content" }
12
- it { should include "**Trailing whitespace:**" }
13
- it { should include "**Trailing non-breaking space:&nbsp;**" }
14
- it { should include "**_Combination:&nbsp;_**" }
9
+ it { is_expected.not_to start_with "\n\n" }
10
+ it { is_expected.to start_with "First content\n\nSecond content\n\n" }
11
+ it { is_expected.to include "\n\n_Complex_\n\n Content" }
12
+ it { is_expected.to include "**Trailing whitespace:**" }
13
+ it { is_expected.to include "**Trailing non-breaking space:&nbsp;**" }
14
+ it { is_expected.to include "**_Combination:&nbsp;_**" }
15
15
  end
@@ -6,7 +6,7 @@ describe ReverseMarkdown do
6
6
  let(:document) { Nokogiri::HTML(input) }
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
- it { should match /^ Block of code$/ }
10
- it { should include "\n> First quoted paragraph\n> \n> Second quoted paragraph" }
9
+ it { is_expected.to match /^ Block of code$/ }
10
+ it { is_expected.to include "\n> First quoted paragraph\n> \n> Second quoted paragraph" }
11
11
 
12
12
  end
@@ -6,11 +6,11 @@ describe ReverseMarkdown do
6
6
  let(:document) { Nokogiri::HTML(input) }
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
- it { should match /\n\| header 1 \| header 2 \| header 3 \|\n\| --- \| --- \| --- \|\n/ }
10
- it { should match /\n\| data 1-1 \| data 2-1 \| data 3-1 \|\n/ }
11
- it { should match /\n\| data 1-2 \| data 2-2 \| data 3-2 \|\n/ }
9
+ it { is_expected.to match /\n\| header 1 \| header 2 \| header 3 \|\n\| --- \| --- \| --- \|\n/ }
10
+ it { is_expected.to match /\n\| data 1-1 \| data 2-1 \| data 3-1 \|\n/ }
11
+ it { is_expected.to match /\n\| data 1-2 \| data 2-2 \| data 3-2 \|\n/ }
12
12
 
13
- it { should match /\n\| _header oblique_ \| \*\*header bold\*\* \| `header code` \|\n| --- \| --- \| --- \|\n/ }
14
- it { should match /\n\| _data oblique_ \| \*\*data bold\*\* \| `data code` \|\n/ }
13
+ it { is_expected.to match /\n\| _header oblique_ \| \*\*header bold\*\* \| `header code` \|\n| --- \| --- \| --- \|\n/ }
14
+ it { is_expected.to match /\n\| _data oblique_ \| \*\*data bold\*\* \| `data code` \|\n/ }
15
15
 
16
16
  end
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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Opper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri