rubymark 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +2 -0
- data/LICENSE.txt +21 -0
- data/bin/rubymark +8 -0
- data/lib/rubymark.rb +111 -0
- data/spec/blockquote_spec.rb +22 -0
- data/spec/emphasis_spec.rb +35 -0
- data/spec/everything_spec.rb +14 -0
- data/spec/great_expectations.rb +163 -0
- data/spec/heading_spec.rb +19 -0
- data/spec/link_spec.rb +14 -0
- data/spec/list_spec.rb +29 -0
- data/spec/paragraph_spec.rb +19 -0
- data/spec/spec_helper.rb +3 -0
- metadata +79 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: a1ea8d8ceac3ac32a98c5db56444b536165fe966
|
|
4
|
+
data.tar.gz: 8c1ce72adc239a609165da2948558bbce09b25cb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5dc6634520c6ea349b7321a1520d6f19e94641a14638873b26abaa286b4a7dda662b5bdd297dd0a9ffaf66edefa7392ca62347955502b973a2a433cfbcefb3ef
|
|
7
|
+
data.tar.gz: 44165e6edc236918fff72e34091f9746b7ead1329a120e6f1bf23b1d31edccd8cc94e85d521bb800d0f47245798501893696c1c257d0b405bb9596b9a287a20d
|
checksums.yaml.gz.sig
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
��� ]���ܵqet���@'�Y|�[E�ioGc����F�[W�2C�
|
data.tar.gz.sig
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 ThoughtWorks, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/bin/rubymark
ADDED
data/lib/rubymark.rb
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
class RubyMark
|
|
2
|
+
def initialize(markdown)
|
|
3
|
+
@markdown = markdown
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def ordered_lists(markdown)
|
|
7
|
+
markdown
|
|
8
|
+
.gsub(/\n\n(\d*\. .*)/, "\n<ol>\n\\1")
|
|
9
|
+
.gsub(/^(\d*\. .*)\n\n/, "\\1\n</ol>\n")
|
|
10
|
+
.gsub(/^\d*\. (.*)/, "<li>\\1</li>")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def unordered_lists(markdown)
|
|
14
|
+
markdown
|
|
15
|
+
.gsub(/\n\n(\* .*)/, "<ul>\n\\1")
|
|
16
|
+
.gsub(/^(\* .*)\n\n/, "\\1\n</ul>\n\n")
|
|
17
|
+
.gsub(/^\* (.*)/, "<li>\\1</li>")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def emphasis(markdown)
|
|
21
|
+
markdown
|
|
22
|
+
.gsub(/__(.*)__/, "<strong>\\1</strong>")
|
|
23
|
+
.gsub(/_(.*)_/, "<em>\\1</em>")
|
|
24
|
+
.gsub(/ <em> /, " _ ")
|
|
25
|
+
.gsub(/ <\/em> /, " _ ")
|
|
26
|
+
.gsub(/\\<em>/, "_")
|
|
27
|
+
.gsub(/\\<\/em>/, "_")
|
|
28
|
+
.gsub(/\*\*(.*)\*\*/, "<strong>\\1</strong>")
|
|
29
|
+
.gsub(/\*(.*)\*/, "<em>\\1</em>")
|
|
30
|
+
.gsub(/ <em> /, " * ")
|
|
31
|
+
.gsub(/ <\/em> /, " * ")
|
|
32
|
+
.gsub(/\\<em>/, "*")
|
|
33
|
+
.gsub(/\\<\/em>/, "*")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def headings(markdown)
|
|
37
|
+
markdown
|
|
38
|
+
.gsub(/^\#\#\#\#\#\# (.*) \#\#\#\#\#\#/, '<h6>\1</h6>')
|
|
39
|
+
.gsub(/^\#\#\#\#\#\# (.*)/, '<h6>\1</h6>')
|
|
40
|
+
.gsub(/^\#\#\#\#\# (.*) \#\#\#\#\#/, '<h5>\1</h5>')
|
|
41
|
+
.gsub(/^\#\#\#\#\# (.*)/, '<h5>\1</h5>')
|
|
42
|
+
.gsub(/^\#\#\#\# (.*) \#\#\#\#/, '<h4>\1</h4>')
|
|
43
|
+
.gsub(/^\#\#\#\# (.*)/, '<h4>\1</h4>')
|
|
44
|
+
.gsub(/^\#\#\# (.*) \#\#\#/, '<h3>\1</h3>')
|
|
45
|
+
.gsub(/^\#\#\# (.*)/, '<h3>\1</h3>')
|
|
46
|
+
.gsub(/^\#\# (.*) \#\#/, '<h2>\1</h2>')
|
|
47
|
+
.gsub(/^\#\# (.*)/, '<h2>\1</h2>')
|
|
48
|
+
.gsub(/^\# (.*) \#/, '<h1>\1</h1>')
|
|
49
|
+
.gsub(/^\# (.*)/, '<h1>\1</h1>')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def paragraphs(markdown)
|
|
53
|
+
markdown
|
|
54
|
+
.gsub(/^\n(.+)\n$/, "\n<p>\\1</p>\n")
|
|
55
|
+
.gsub(/\A(.+)/, "<p>\\1")
|
|
56
|
+
.gsub(/(.+)\Z/, "\\1</p>")
|
|
57
|
+
.gsub(/\n\n/, "</p>\n\n<p>")
|
|
58
|
+
.gsub(/\n\n<p><\/p>\n\n/, "\n\n")
|
|
59
|
+
.gsub(/\A<\/p>/, "")
|
|
60
|
+
.gsub(/<p>\Z/, "")
|
|
61
|
+
.gsub(/<p>(<.*>)/, "\\1")
|
|
62
|
+
.gsub(/(<.*>)<\/p>/, "\\1")
|
|
63
|
+
.gsub(/<p>(<.*>)/, "\\1")
|
|
64
|
+
.gsub(/(<.*>)<\/p>/, "\\1")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def links(markdown)
|
|
68
|
+
markdown
|
|
69
|
+
.gsub(/\[(.*)\]\((.*) "(.*)"\)/, "<a href=\"\\2\" title=\"\\3\">\\1</a>")
|
|
70
|
+
.gsub(/\[(.*)\]\((.*)\)/, "<a href=\"\\2\">\\1</a>")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def blockquotes(markdown)
|
|
74
|
+
markdown.gsub!(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/) do
|
|
75
|
+
bq = $1
|
|
76
|
+
if bq
|
|
77
|
+
bq.gsub!(/^[ \t]*>[ \t]?/, "") # trim one level of quoting
|
|
78
|
+
bq.gsub!(/^[ \t]+$/, "") # trim whitespace-only lines
|
|
79
|
+
bq.strip!
|
|
80
|
+
|
|
81
|
+
"<blockquote><p>\n#{bq}\n</p></blockquote>\n\n"
|
|
82
|
+
else
|
|
83
|
+
$&
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
markdown
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def to_html
|
|
90
|
+
links(paragraphs(headings(emphasis(unordered_lists(ordered_lists(blockquotes(@markdown)))))))
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
class RubyMarkRunner
|
|
95
|
+
def run args
|
|
96
|
+
unless args[0]
|
|
97
|
+
print_usage
|
|
98
|
+
else
|
|
99
|
+
process_md_file(ARGV[0])
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def print_usage
|
|
104
|
+
puts "Usage: rubymark file.md # this will send HTML to STDOUT"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def process_md_file(md_file_name)
|
|
108
|
+
markdown = File.read(md_file_name)
|
|
109
|
+
puts RubyMark.new(markdown).to_html
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Block Quote" do
|
|
4
|
+
it "is between empty lines and start with '> '" do
|
|
5
|
+
expect(RubyMark.new("").blockquotes("\n\n> This is a block quote\n\n")).to match(/^\n\n<blockquote><p>\nThis is a block quote\n<\/p><\/blockquote>\n\n/)
|
|
6
|
+
expect(RubyMark.new("\n\n> This is a block quote\n\n").to_html).to match(/^\n\n<blockquote><p>\nThis is a block quote\n<\/p><\/blockquote>\n\n/)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "can be more than one paragraph long" do
|
|
10
|
+
# expect(RubyMark.new("").blockquotes("\n\n> This is a para in a block quote\nLine 2.\n\n> And this is the second para.\n\n")).to match(/^<blockquote>This is a para in a block quote\nLine 2.<\/blockquote>\n\n<blockquote>And this is the second para.<\/blockquote>/)
|
|
11
|
+
expect(RubyMark.new("\n\n> This is a para in a block quote\nLine 2.\n\n> And this is the second para.\n\n").to_html).to match(/^<blockquote><p>\nThis is a para in a block quote\nLine 2.<\/p>\n\n<p>And this is the second para.\n<\/p><\/blockquote>/)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "can be made of many lines that start with '> '" do
|
|
15
|
+
expect(RubyMark.new("").blockquotes("\n\n> This is a line in a block quote\n> And so is this.\n\n")).to match(/^<blockquote><p>\nThis is a line in a block quote\nAnd so is this.\n<\/p><\/blockquote>/)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "can exist more than once in a document" do
|
|
19
|
+
expect(RubyMark.new("").blockquotes("\n\n> This is a line in a block quote\n> And so is this.\n\nSome other stuff here.\n\n> Another block quote\n\n")).to eq("\n\n<blockquote><p>\nThis is a line in a block quote\nAnd so is this.\n</p></blockquote>\n\nSome other stuff here.\n\n<blockquote><p>\nAnother block quote\n</p></blockquote>\n\n")
|
|
20
|
+
expect(RubyMark.new("\n\n> This is a line in a block quote\n> And so is this.\n\nSome other stuff here.\n\n> Another block quote\n\n").to_html).to match(/^<blockquote><p>\nThis is a line in a block quote\nAnd so is this.\n<\/p><\/blockquote>\n\n<p>Some other stuff here.<\/p>\n\n<blockquote><p>\nAnother block quote\n<\/p><\/blockquote>\n\n/)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Emphasis" do
|
|
4
|
+
it "is between *s" do
|
|
5
|
+
expect(RubyMark.new("*Emphasis*").to_html).to match(/<em>Emphasis<\/em>/)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "is between _s" do
|
|
9
|
+
expect(RubyMark.new("_Emphasis_").to_html).to match(/<em>Emphasis<\/em>/)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "is strong between **s" do
|
|
13
|
+
expect(RubyMark.new("**I am strong!**").to_html).to match(/<strong>I am strong!<\/strong>/)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "is strong between __s" do
|
|
17
|
+
expect(RubyMark.new("__I am strong!__").to_html).to match(/<strong>I am strong!<\/strong>/)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "is not present when a _ is surrounded by spaces" do
|
|
21
|
+
expect(RubyMark.new("This _ underscores _ the point").to_html).to match(/This _ underscores _ the point/)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "is not present when a * is surrounded by spaces" do
|
|
25
|
+
expect(RubyMark.new("This * stars * the point").to_html).to match(/This \* stars \* the point/)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "is not present when a _ is escaped" do
|
|
29
|
+
expect(RubyMark.new("This \\_underscores\\_ the point").to_html).to match(/This _underscores_ the point/)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "is not present when a * is escaped" do
|
|
33
|
+
expect(RubyMark.new("This \\*stars\\* the point").to_html).to match(/This \*stars\* the point/)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'nokogiri'
|
|
3
|
+
require 'great_expectations'
|
|
4
|
+
|
|
5
|
+
describe "Markdown Document" do
|
|
6
|
+
extend GreatExpectations
|
|
7
|
+
|
|
8
|
+
great_expectations.each do |great, expectation|
|
|
9
|
+
it "#{great} is/are parsed correctly in its entirity" do
|
|
10
|
+
expect(RubyMark.new(expectation[:md]).to_html).to eq(expectation[:html])
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module GreatExpectations
|
|
4
|
+
def great_expectations
|
|
5
|
+
return {
|
|
6
|
+
:unordered_list => {
|
|
7
|
+
:md => <<-EOMD,
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
* Item One
|
|
11
|
+
* Item Two
|
|
12
|
+
* Item Three
|
|
13
|
+
|
|
14
|
+
EOMD
|
|
15
|
+
:html => <<-EOHTML,
|
|
16
|
+
<ul>
|
|
17
|
+
<li>Item One</li>
|
|
18
|
+
<li>Item Two</li>
|
|
19
|
+
<li>Item Three</li>
|
|
20
|
+
</ul>
|
|
21
|
+
|
|
22
|
+
EOHTML
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
:ordered_list => {
|
|
26
|
+
:md => <<-EOMD,
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
1. Item One
|
|
30
|
+
12. Item Two
|
|
31
|
+
332353. Item Three
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
EOMD
|
|
35
|
+
:html => <<-EOHTML,
|
|
36
|
+
|
|
37
|
+
<ol>
|
|
38
|
+
<li>Item One</li>
|
|
39
|
+
<li>Item Two</li>
|
|
40
|
+
<li>Item Three</li>
|
|
41
|
+
</ol>
|
|
42
|
+
|
|
43
|
+
EOHTML
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
:headings => {
|
|
47
|
+
:md => <<-EOMD,
|
|
48
|
+
|
|
49
|
+
# Heading One
|
|
50
|
+
|
|
51
|
+
## Heading Two
|
|
52
|
+
|
|
53
|
+
## Second Heading Two
|
|
54
|
+
|
|
55
|
+
### Heading Three
|
|
56
|
+
|
|
57
|
+
#### Heading Four
|
|
58
|
+
|
|
59
|
+
##### Heading Five
|
|
60
|
+
|
|
61
|
+
###### Heading Six
|
|
62
|
+
|
|
63
|
+
## Third Heading Two
|
|
64
|
+
|
|
65
|
+
EOMD
|
|
66
|
+
:html => <<-EOHTML,
|
|
67
|
+
|
|
68
|
+
<h1>Heading One</h1>
|
|
69
|
+
|
|
70
|
+
<h2>Heading Two</h2>
|
|
71
|
+
|
|
72
|
+
<h2>Second Heading Two</h2>
|
|
73
|
+
|
|
74
|
+
<h3>Heading Three</h3>
|
|
75
|
+
|
|
76
|
+
<h4>Heading Four</h4>
|
|
77
|
+
|
|
78
|
+
<h5>Heading Five</h5>
|
|
79
|
+
|
|
80
|
+
<h6>Heading Six</h6>
|
|
81
|
+
|
|
82
|
+
<h2>Third Heading Two</h2>
|
|
83
|
+
|
|
84
|
+
EOHTML
|
|
85
|
+
} ,
|
|
86
|
+
|
|
87
|
+
:headings_and_paragraphs => {
|
|
88
|
+
:md => <<-EOMD,
|
|
89
|
+
|
|
90
|
+
# Heading One
|
|
91
|
+
|
|
92
|
+
This is the introduction
|
|
93
|
+
|
|
94
|
+
## Heading Two
|
|
95
|
+
|
|
96
|
+
This talks about this section
|
|
97
|
+
|
|
98
|
+
### Heading Three
|
|
99
|
+
|
|
100
|
+
Here is info about this subsection.
|
|
101
|
+
|
|
102
|
+
And more info.
|
|
103
|
+
|
|
104
|
+
And more.
|
|
105
|
+
|
|
106
|
+
Then some.
|
|
107
|
+
|
|
108
|
+
And some more.
|
|
109
|
+
|
|
110
|
+
EOMD
|
|
111
|
+
:html => <<-EOHTML,
|
|
112
|
+
|
|
113
|
+
<h1>Heading One</h1>
|
|
114
|
+
|
|
115
|
+
<p>This is the introduction</p>
|
|
116
|
+
|
|
117
|
+
<h2>Heading Two</h2>
|
|
118
|
+
|
|
119
|
+
<p>This talks about this section</p>
|
|
120
|
+
|
|
121
|
+
<h3>Heading Three</h3>
|
|
122
|
+
|
|
123
|
+
<p>Here is info about this subsection.</p>
|
|
124
|
+
|
|
125
|
+
<p>And more info.</p>
|
|
126
|
+
|
|
127
|
+
<p>And more.</p>
|
|
128
|
+
|
|
129
|
+
<p>Then some.</p>
|
|
130
|
+
|
|
131
|
+
<p>And some more.</p>
|
|
132
|
+
|
|
133
|
+
EOHTML
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
:embedded_html => {
|
|
137
|
+
:md => <<-EOMD,
|
|
138
|
+
|
|
139
|
+
<section>
|
|
140
|
+
|
|
141
|
+
## Section Heading
|
|
142
|
+
|
|
143
|
+
Section contents.
|
|
144
|
+
|
|
145
|
+
</section>
|
|
146
|
+
|
|
147
|
+
EOMD
|
|
148
|
+
:html => <<-EOHTML,
|
|
149
|
+
|
|
150
|
+
<section>
|
|
151
|
+
|
|
152
|
+
<h2>Section Heading</h2>
|
|
153
|
+
|
|
154
|
+
<p>Section contents.</p>
|
|
155
|
+
|
|
156
|
+
</section>
|
|
157
|
+
|
|
158
|
+
EOHTML
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
end
|
|
163
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Heading" do
|
|
4
|
+
def i_hashes(i)
|
|
5
|
+
"#" * i
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
(1..6).each do |i|
|
|
9
|
+
describe "level #{i}" do
|
|
10
|
+
it "is parsed and rendered correctly when it doesn't end with a hash" do
|
|
11
|
+
expect(RubyMark.new("#{i_hashes(i)} Heading #{i}").to_html).to match("<h#{i}>Heading #{i}</h#{i}>")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "is parsed and rendered correctly when it ends with a hash" do
|
|
15
|
+
expect(RubyMark.new("#{i_hashes(i)} Heading #{i} #{i_hashes(i)}").to_html).to match("<h#{i}>Heading #{i}</h#{i}>")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/spec/link_spec.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Link" do
|
|
4
|
+
it "looks like this: [an example](http://example.com/ \"Title\")" do
|
|
5
|
+
expect(RubyMark.new("[an example](http://example.com/ \"Title\")").to_html)
|
|
6
|
+
.to match(/<a href="http:\/\/example.com\/" title="Title">an example<\/a>/)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "could look like this: [an example](http://example.com/)" do
|
|
10
|
+
expect(RubyMark.new("[an example](http://example.com/)").to_html)
|
|
11
|
+
.to match(/<a href="http:\/\/example.com\/">an example<\/a>/)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
data/spec/list_spec.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Unordered List" do
|
|
4
|
+
it "starts whenever you see a blank line followed by a line starting with *" do
|
|
5
|
+
expect(RubyMark.new("\n\n* List Item").to_html).to match(/^<ul>\n.*List Item.*/)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "has an element whenever a new line starts with a *" do
|
|
9
|
+
expect(RubyMark.new("* List Item").to_html).to eq("<li>List Item</li>")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "ends whenever a line that starts with a * is followed by a blank line" do
|
|
13
|
+
expect(RubyMark.new("* List Item\n\n").to_html).to match(/.*List Item.*\n<\/ul>/)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "Ordered List" do
|
|
18
|
+
it "starts whenever you see a blank line followed by a line starting with \d." do
|
|
19
|
+
expect(RubyMark.new("\n\n12. List Item").to_html).to match(/^<ol>\n.*List Item.*/)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "has an element whenever a new line starts with a *" do
|
|
23
|
+
expect(RubyMark.new("14. List Item").to_html).to eq("<li>List Item</li>")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "ends whenever a line that starts with a * is followed by a blank line" do
|
|
27
|
+
expect(RubyMark.new("1. List Item\n\n").to_html).to match(/.*List Item.*\n<\/ol>/)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Paragraph" do
|
|
4
|
+
it "starts whenever you see a block of text preceded and succeeded by a blank line" do
|
|
5
|
+
expect(RubyMark.new("\n\nThis is a paragraph.\n\n").to_html).to match(/<p>This is a paragraph.<\/p>/)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "doesn't start if there is already an html tag starting on that line" do
|
|
9
|
+
expect(RubyMark.new("\n\n<div>This is not a paragraph.</div>\n\n").to_html).not_to match(/<p>.*<\/p>/)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "can be followed by other paragraphs" do
|
|
13
|
+
expect(RubyMark.new("\n\nThis is a paragraph.\n\nThis is another paragraph.\n\nAnd another.\n\n").to_html).to match(/<p>This is a paragraph.<\/p>\n\n<p>This is another paragraph.<\/p>\n\n<p>And another.<\/p>/)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "can have multiple lines" do
|
|
17
|
+
expect(RubyMark.new("\n\nThis is a paragraph\nthat has\nmultiple lines.\n\n").to_html).to eq("\n\n<p>This is a paragraph\nthat has\nmultiple lines.</p>\n\n")
|
|
18
|
+
end
|
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rubymark
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Prasanna Pendse
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain:
|
|
11
|
+
- |
|
|
12
|
+
-----BEGIN CERTIFICATE-----
|
|
13
|
+
MIIDijCCAnKgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMRAwDgYDVQQDDAdwcGVu
|
|
14
|
+
ZHNlMRwwGgYKCZImiZPyLGQBGRYMdGhvdWdodHdvcmtzMRMwEQYKCZImiZPyLGQB
|
|
15
|
+
GRYDY29tMB4XDTEzMTIyMjE3MzEwOFoXDTE0MTIyMjE3MzEwOFowRTEQMA4GA1UE
|
|
16
|
+
AwwHcHBlbmRzZTEcMBoGCgmSJomT8ixkARkWDHRob3VnaHR3b3JrczETMBEGCgmS
|
|
17
|
+
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAODQ
|
|
18
|
+
DWG43cy55DoetegQwTfKgfMRaeLETHohp3G4Q+CLtYZADpmR7bOPhUTwbhj2urh4
|
|
19
|
+
jeoxPHERlTpPIcWgUOrW7nrpKw0M5JppuCxVfMdPQ3te94x6/JzyG7M4bDrSXOeJ
|
|
20
|
+
K1mEZeO1LfYfU+ilaTEuc4tzuF1CQHnF0If/S4IQgDkHMagxCJIiBCUy1d6+E4L9
|
|
21
|
+
hIWga7PKWmNANcLsucpJIaG2/Hz5fAcFmX9DWLlHr/VuKFfpLP9cvyvE1ORTKiH3
|
|
22
|
+
w9pJeXpEPnfjCOmKcDLx6tdmeQGxbiUEtbEVNArv86R0cNCSMYn3DbJqsgOQt3hR
|
|
23
|
+
JjEu62KqCF4wbZra0YECAwEAAaOBhDCBgTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
|
|
24
|
+
sDAdBgNVHQ4EFgQUl82/HGUn9c6xkWOm4PFyNMzD7KswIwYDVR0RBBwwGoEYcHBl
|
|
25
|
+
bmRzZUB0aG91Z2h0d29ya3MuY29tMCMGA1UdEgQcMBqBGHBwZW5kc2VAdGhvdWdo
|
|
26
|
+
dHdvcmtzLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEANpgOylfaecEbhwegCP1174Qs
|
|
27
|
+
N4pQjP2501YZutXgPOGnHJxcOZw1O+3Y5F/AWsErTaTeP1rInMYKsryqtLJBPawH
|
|
28
|
+
i2sPTQXJVPfFq/WY4Lg5m4JB9GPPjT8SGLEH2BZn+kPR8hpk3q1vn85PuMf2oRnA
|
|
29
|
+
Jumt5vcLOMp1y7qShzkySgskZrTgZsH2UVSyCPKiCgfB5wv8mR0TUn8P3QPfR5DD
|
|
30
|
+
Odd0ARXQ+MKbGEPHexqYWQ11WV5+puixnmTTePyoFlxT+OP88aXZjdUj5W9KHO+A
|
|
31
|
+
7ew1UU7TV+ZWEGPcD+pVDg6GvGt+ZUphvDx5quj5fcwPp6IAxvTeP3AN8ZR5FQ==
|
|
32
|
+
-----END CERTIFICATE-----
|
|
33
|
+
date: 2013-12-22 00:00:00.000000000 Z
|
|
34
|
+
dependencies: []
|
|
35
|
+
description: Trying to parse Markdown in a very simple and unit-testable way. Don't
|
|
36
|
+
know if I can cover all of Markdown yet.
|
|
37
|
+
email: ppendse@thoughtworks.com
|
|
38
|
+
executables:
|
|
39
|
+
- rubymark
|
|
40
|
+
extensions: []
|
|
41
|
+
extra_rdoc_files: []
|
|
42
|
+
files:
|
|
43
|
+
- lib/rubymark.rb
|
|
44
|
+
- spec/blockquote_spec.rb
|
|
45
|
+
- spec/emphasis_spec.rb
|
|
46
|
+
- spec/everything_spec.rb
|
|
47
|
+
- spec/great_expectations.rb
|
|
48
|
+
- spec/heading_spec.rb
|
|
49
|
+
- spec/link_spec.rb
|
|
50
|
+
- spec/list_spec.rb
|
|
51
|
+
- spec/paragraph_spec.rb
|
|
52
|
+
- spec/spec_helper.rb
|
|
53
|
+
- LICENSE.txt
|
|
54
|
+
- bin/rubymark
|
|
55
|
+
homepage: https://github.com/prasanna/rubymark
|
|
56
|
+
licenses:
|
|
57
|
+
- MIT
|
|
58
|
+
metadata: {}
|
|
59
|
+
post_install_message:
|
|
60
|
+
rdoc_options: []
|
|
61
|
+
require_paths:
|
|
62
|
+
- lib
|
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - '>='
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
|
+
requirements:
|
|
70
|
+
- - '>='
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: '0'
|
|
73
|
+
requirements: []
|
|
74
|
+
rubyforge_project:
|
|
75
|
+
rubygems_version: 2.1.11
|
|
76
|
+
signing_key:
|
|
77
|
+
specification_version: 4
|
|
78
|
+
summary: RubyMark is an experimental Markdown parser!
|
|
79
|
+
test_files: []
|
metadata.gz.sig
ADDED
|
Binary file
|