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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/reverse_markdown/converters/li.rb +1 -1
- data/lib/reverse_markdown/version.rb +1 -1
- data/spec/assets/lists.html +20 -3
- data/spec/components/anchors_spec.rb +12 -12
- data/spec/components/basic_spec.rb +31 -31
- data/spec/components/code_spec.rb +9 -9
- data/spec/components/escapables_spec.rb +5 -5
- data/spec/components/html_fragment_spec.rb +1 -1
- data/spec/components/lists_spec.rb +40 -29
- data/spec/components/paragraphs_spec.rb +6 -6
- data/spec/components/quotation_spec.rb +2 -2
- data/spec/components/tables_spec.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad925687978f44b00fbabc9a9a8f526033d94a4c
|
4
|
+
data.tar.gz: 39313ccac2c11accd0bb6b8c69f7c0ae39c3c1a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/spec/assets/lists.html
CHANGED
@@ -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 {
|
10
|
-
it {
|
11
|
-
it {
|
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 {
|
14
|
-
it {
|
15
|
-
it {
|
16
|
-
it {
|
17
|
-
it {
|
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 {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
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 {
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
it {
|
15
|
-
it {
|
16
|
-
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
29
|
-
it {
|
30
|
-
it {
|
31
|
-
it {
|
32
|
-
it {
|
33
|
-
|
34
|
-
it {
|
35
|
-
it {
|
36
|
-
|
37
|
-
it {
|
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 {
|
40
|
+
it { is_expected.to match /before hr \n\* \* \*\n after hr/ }
|
41
41
|
|
42
|
-
it {
|
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 {
|
10
|
-
it {
|
11
|
-
it {
|
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 {
|
16
|
-
it {
|
17
|
-
it {
|
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 {
|
23
|
-
it {
|
24
|
-
it {
|
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 {
|
11
|
-
it {
|
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 {
|
16
|
-
it {
|
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 {
|
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 {
|
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 {
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
it {
|
15
|
-
it {
|
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 {
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
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 {
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
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 {
|
33
|
-
it {
|
34
|
-
it {
|
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 {
|
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 {
|
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 {
|
47
|
-
it {
|
48
|
-
it {
|
49
|
-
it {
|
50
|
-
it {
|
51
|
-
it {
|
52
|
-
it {
|
53
|
-
it {
|
54
|
-
it {
|
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 {
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
it {
|
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: **" }
|
14
|
+
it { is_expected.to include "**_Combination: _**" }
|
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 {
|
10
|
-
it {
|
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 {
|
10
|
-
it {
|
11
|
-
it {
|
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 {
|
14
|
-
it {
|
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.
|
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-
|
11
|
+
date: 2015-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|