minidown 2.1.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
- data/.gitignore +18 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +73 -0
- data/Rakefile +4 -0
- data/bin/minidown +33 -0
- data/lib/minidown.rb +13 -0
- data/lib/minidown/document.rb +142 -0
- data/lib/minidown/element.rb +40 -0
- data/lib/minidown/elements.rb +15 -0
- data/lib/minidown/elements/block_element.rb +37 -0
- data/lib/minidown/elements/code_block_element.rb +44 -0
- data/lib/minidown/elements/dividing_line_element.rb +11 -0
- data/lib/minidown/elements/html_element.rb +22 -0
- data/lib/minidown/elements/indent_code_element.rb +23 -0
- data/lib/minidown/elements/line_element.rb +28 -0
- data/lib/minidown/elements/list_element.rb +36 -0
- data/lib/minidown/elements/list_group_element.rb +87 -0
- data/lib/minidown/elements/order_list_element.rb +20 -0
- data/lib/minidown/elements/paragraph_element.rb +56 -0
- data/lib/minidown/elements/raw_html_element.rb +11 -0
- data/lib/minidown/elements/table_element.rb +80 -0
- data/lib/minidown/elements/text_element.rb +198 -0
- data/lib/minidown/elements/unorder_list_element.rb +31 -0
- data/lib/minidown/html_helper.rb +18 -0
- data/lib/minidown/parser.rb +19 -0
- data/lib/minidown/utils.rb +28 -0
- data/lib/minidown/version.rb +3 -0
- data/minidown.gemspec +26 -0
- data/spec/blank_line_spec.rb +21 -0
- data/spec/code_block_spec.rb +182 -0
- data/spec/dividing_line_spec.rb +35 -0
- data/spec/h1_and_h2_spec.rb +55 -0
- data/spec/indent_block_spec.rb +17 -0
- data/spec/li_spec.rb +354 -0
- data/spec/minidown_spec.rb +12 -0
- data/spec/paragraph_spec.rb +17 -0
- data/spec/raw_html_spec.rb +43 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/start_with_gt_spec.rb +70 -0
- data/spec/start_with_shape_spec.rb +42 -0
- data/spec/table_spec.rb +63 -0
- data/spec/task_list_spec.rb +18 -0
- data/spec/text_element_spec.rb +317 -0
- metadata +175 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minidown do
|
4
|
+
describe '###### title' do
|
5
|
+
it 'should parse "#" as text' do
|
6
|
+
Minidown.render('#').should == '<p>#</p>'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should parse "#####"' do
|
10
|
+
(2..7).map{|n| '#' * n}.each do |str|
|
11
|
+
tag = "h#{str.size - 1}"
|
12
|
+
Minidown.render(str).should == "<#{tag}>#</#{tag}>"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should ignore blank' do
|
17
|
+
str =<<HERE
|
18
|
+
#### h4 ######
|
19
|
+
HERE
|
20
|
+
Minidown.render(str).should == "<h4>h4</h4>"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'should not parse escaped' do
|
25
|
+
it 'start with escape' do
|
26
|
+
%w{\####### \###### \#### \### \## \#}.each do |str|
|
27
|
+
Minidown.render(str).should == "<p>#{str[1..-1]}</p>"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'some other case' do
|
32
|
+
str = '#\##'
|
33
|
+
Minidown.render(str).should == "<h1>\\</h1>"
|
34
|
+
str = '##\##\\'
|
35
|
+
Minidown.render(str).should == "<h2>##\\</h2>"
|
36
|
+
str = '# \# #'
|
37
|
+
Minidown.render(str).should == "<h1>#</h1>"
|
38
|
+
str = '#\#'
|
39
|
+
Minidown.render(str).should == "<h1>\\</h1>"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/table_spec.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minidown do
|
4
|
+
describe 'table' do
|
5
|
+
it 'should parse correct' do
|
6
|
+
str =<<HERE
|
7
|
+
First Header | Second Header
|
8
|
+
------------- | -------------
|
9
|
+
Content Cell | Content Cell
|
10
|
+
Content Cell | Content Cell
|
11
|
+
HERE
|
12
|
+
Minidown.render(str).should == '<table><thead><tr><th>First Header</th><th>Second Header</th></tr></thead><tbody><tr><td>Content Cell</td><td>Content Cell</td></tr><tr><td>Content Cell</td><td>Content Cell</td></tr></tbody></table>'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should parse correct with pipe end' do
|
16
|
+
str =<<HERE
|
17
|
+
| First Header | Second Header |
|
18
|
+
| ------------- | ------------- |
|
19
|
+
| Content Cell | Content Cell |
|
20
|
+
| Content Cell | Content Cell |
|
21
|
+
HERE
|
22
|
+
Minidown.render(str).should == '<table><thead><tr><th>First Header</th><th>Second Header</th></tr></thead><tbody><tr><td>Content Cell</td><td>Content Cell</td></tr><tr><td>Content Cell</td><td>Content Cell</td></tr></tbody></table>'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should allow inline markdown' do
|
26
|
+
str = <<HERE
|
27
|
+
| Name | Description |
|
28
|
+
| ------------- | ----------- |
|
29
|
+
| Help | ~~Display the~~ help window.|
|
30
|
+
| Close | _Closes_ a window |
|
31
|
+
HERE
|
32
|
+
Minidown.render(str).should == '<table><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td>Help</td><td><del>Display the</del> help window.</td></tr><tr><td>Close</td><td><em>Closes</em> a window</td></tr></tbody></table>'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should allow define align' do
|
36
|
+
str = <<HERE
|
37
|
+
| Left-Aligned | Center Aligned | Right Aligned |
|
38
|
+
| :------------ |:---------------:| -----:|
|
39
|
+
| col 3 is | some wordy text | $1600 |
|
40
|
+
| col 2 is | centered | $12 |
|
41
|
+
| zebra stripes | are neat | $1 |
|
42
|
+
HERE
|
43
|
+
Minidown.render(str).should == '<table><thead><tr><th align="left">Left-Aligned</th><th align="center">Center Aligned</th><th align="right">Right Aligned</th></tr></thead><tbody><tr><td align="left">col 3 is</td><td align="center">some wordy text</td><td align="right">$1600</td></tr><tr><td align="left">col 2 is</td><td align="center">centered</td><td align="right">$12</td></tr><tr><td align="left">zebra stripes</td><td align="center">are neat</td><td align="right">$1</td></tr></tbody></table>'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should allow escape' do
|
47
|
+
str =<<HERE
|
48
|
+
\\| First Header | Second Header |
|
49
|
+
| ------------- | ------------- |
|
50
|
+
| Content Cell | Content Cell |
|
51
|
+
| Content Cell | Content Cell |
|
52
|
+
HERE
|
53
|
+
Minidown.render(str).should == '<p>| First Header | Second Header |<br>| ------------- | ------------- |<br>| Content Cell | Content Cell |<br>| Content Cell | Content Cell |</p>'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should not parse as table' do
|
57
|
+
str = "|not|table|"
|
58
|
+
Minidown.render(str).should == '<p>|not|table|</p>'
|
59
|
+
str = "not|table"
|
60
|
+
Minidown.render(str).should == '<p>not|table</p>'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minidown do
|
4
|
+
describe 'task list' do
|
5
|
+
it 'should parse correct' do
|
6
|
+
str =<<HERE
|
7
|
+
- [ ] a task list item
|
8
|
+
- [ ] list syntax required
|
9
|
+
- [ ] normal **formatting**,
|
10
|
+
@mentions, #1234 refs
|
11
|
+
- [ ] incomplete
|
12
|
+
- [x] completed
|
13
|
+
HERE
|
14
|
+
Minidown.render(str).should == '<ul class="task-list"><li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled=""> a task list item</li><li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled=""> list syntax required</li><li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled=""><p> normal <strong>formatting</strong>,</p>
|
15
|
+
<p>@mentions, #1234 refs</p></li><li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled=""> incomplete</li><li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" checked="" disabled=""> completed</li></ul>'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,317 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minidown do
|
4
|
+
describe 'text element' do
|
5
|
+
it 'escape' do
|
6
|
+
str = "<>"
|
7
|
+
Minidown.render(str).should == "<p><></p>"
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'escape special symbol' do
|
11
|
+
str = '\\\\
|
12
|
+
\\`
|
13
|
+
\\*
|
14
|
+
\\_
|
15
|
+
\\{
|
16
|
+
\\}
|
17
|
+
\\[
|
18
|
+
\\]
|
19
|
+
\\(
|
20
|
+
\\)
|
21
|
+
\\#
|
22
|
+
\\+
|
23
|
+
\\-
|
24
|
+
\\.
|
25
|
+
\\!'
|
26
|
+
Minidown.render(str).should == '<p>\
|
27
|
+
`
|
28
|
+
*
|
29
|
+
_
|
30
|
+
{
|
31
|
+
}
|
32
|
+
[
|
33
|
+
]
|
34
|
+
(
|
35
|
+
)
|
36
|
+
#
|
37
|
+
+
|
38
|
+
-
|
39
|
+
.
|
40
|
+
!</p>'.split.join('<br>')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'escape escape symbol' do
|
44
|
+
str = %q{\\\\`
|
45
|
+
\\\\*
|
46
|
+
\\\\_
|
47
|
+
\\\\{
|
48
|
+
\\\\}
|
49
|
+
\\\\[
|
50
|
+
\\\\]
|
51
|
+
\\\\(
|
52
|
+
\\\\)
|
53
|
+
\\\\#
|
54
|
+
\\\\+
|
55
|
+
\\\\-
|
56
|
+
\\\\.
|
57
|
+
\\\\!}
|
58
|
+
Minidown.render(str).should == %q{<p>\\`
|
59
|
+
\\*
|
60
|
+
\\_
|
61
|
+
\\{
|
62
|
+
\\}
|
63
|
+
\\[
|
64
|
+
\\]
|
65
|
+
\\(
|
66
|
+
\\)
|
67
|
+
\\#
|
68
|
+
\\+
|
69
|
+
\\-
|
70
|
+
\\.
|
71
|
+
\\!</p>}.split.join('<br>')
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'html tag' do
|
75
|
+
str = "<a href=\"http://github.com\">github</a>"
|
76
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'link' do
|
80
|
+
it 'should parse correct' do
|
81
|
+
str = %Q{This is [an example](http://example.com/ "Title") inline link.
|
82
|
+
|
83
|
+
[This link](http://example.net/) has no title attribute.}
|
84
|
+
Minidown.render(str).should == %Q{<p>This is <a href="http://example.com/" title="Title">an example</a> inline link.</p><p><a href="http://example.net/">This link</a> has no title attribute.</p>}
|
85
|
+
|
86
|
+
str = '[link a](https://a.example.com) and [link b](https://b.example.com)'
|
87
|
+
Minidown.render(str).should == "<p><a href=\"https://a.example.com\">link a</a> and <a href=\"https://b.example.com\">link b</a></p>"
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should allow related path' do
|
91
|
+
str = "See my [About](/about/) page for details."
|
92
|
+
Minidown.render(str).should == %Q{<p>See my <a href=\"/about/\">About</a> page for details.</p>}
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should allow reference' do
|
96
|
+
str =<<HERE
|
97
|
+
I get 10 times more traffic from [Google] [1] than from
|
98
|
+
[Yahoo] [2] or [MSN] [3].
|
99
|
+
|
100
|
+
[1]: http://google.com/ "Google"
|
101
|
+
[2]: http://search.yahoo.com/ "Yahoo Search"
|
102
|
+
[3]: http://search.msn.com/ "MSN Search"
|
103
|
+
HERE
|
104
|
+
str2 =<<HERE
|
105
|
+
I get 10 times more traffic from [Google][] than from
|
106
|
+
[Yahoo][] or [MSN][].
|
107
|
+
|
108
|
+
[google]: http://google.com/ "Google"
|
109
|
+
[yahoo]: http://search.yahoo.com/ "Yahoo Search"
|
110
|
+
[msn]: http://search.msn.com/ "MSN Search"
|
111
|
+
HERE
|
112
|
+
[str, str2].each do |s|
|
113
|
+
Minidown.render(s).should == '<p>I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from<br><a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'can ignore title' do
|
118
|
+
str =<<HERE
|
119
|
+
I get 10 times more traffic from [Google][] than from
|
120
|
+
[Yahoo][] or [MSN][].
|
121
|
+
|
122
|
+
[google]: http://google.com/ "Google"
|
123
|
+
[yahoo]: http://search.yahoo.com/
|
124
|
+
[msn]: http://search.msn.com/ "MSN Search"
|
125
|
+
HERE
|
126
|
+
Minidown.render(str).should == '<p>I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from<br><a href="http://search.yahoo.com/">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'auto link' do
|
131
|
+
it 'should parse link' do
|
132
|
+
str = "https://github.com/jjyr/minidown"
|
133
|
+
Minidown.render(str).should == "<p><a href=\"#{str}\">#{str}</a></p>"
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'can parse multi link' do
|
137
|
+
str = "https://github.com/jjyr/minidown https://github.com"
|
138
|
+
Minidown.render(str).should == "<p><a href=\"https://github.com/jjyr/minidown\">https://github.com/jjyr/minidown</a> <a href=\"https://github.com\">https://github.com</a></p>"
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'should not parse link in tag' do
|
142
|
+
str = "<a href=\"https://github.com/jjyr/minidown\">minidown</a>"
|
143
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should not parse link without scheme' do
|
147
|
+
str = "github.com/jjyr/minidown"
|
148
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should parse email address' do
|
152
|
+
str = "jjyruby@gmail.com"
|
153
|
+
Minidown.render(str).should == "<p><a href=\"mailto:#{str}\">#{str}</a></p>"
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'can parse multi email' do
|
157
|
+
str = "jjyruby@gmail.com jjyruby@gmail.com"
|
158
|
+
Minidown.render(str).should == "<p><a href=\"mailto:jjyruby@gmail.com\">jjyruby@gmail.com</a> <a href=\"mailto:jjyruby@gmail.com\">jjyruby@gmail.com</a></p>"
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'should play with normal text' do
|
162
|
+
str = "Hi, jjyruby@gmail.com is my email."
|
163
|
+
Minidown.render(str).should == "<p>Hi, <a href=\"mailto:jjyruby@gmail.com\">jjyruby@gmail.com</a> is my email.</p>"
|
164
|
+
|
165
|
+
str = "Hi, <jjyruby@gmail.com> is my email."
|
166
|
+
Minidown.render(str).should == "<p>Hi, <a href=\"mailto:jjyruby@gmail.com\">jjyruby@gmail.com</a> is my email.</p>"
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should not parse email in tag' do
|
170
|
+
str = "<a href=\"mailto:jjyruby@gmail.com\">jjyr</a>"
|
171
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should parse with <>' do
|
175
|
+
str = "<https://github.com/jjyr/minidown>"
|
176
|
+
Minidown.render(str).should == "<p><a href=\"#{str[1..-2]}\">#{str[1..-2]}</a></p>"
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should not parse with <> if url invalid' do
|
180
|
+
str = "<github.com/jjyr/minidown>"
|
181
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should parse email' do
|
185
|
+
str = "<jjyruby@gmail.com>"
|
186
|
+
Minidown.render(str).should == "<p><a href=\"mailto:jjyruby@gmail.com\">jjyruby@gmail.com</a></p>"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context '~~del~~' do
|
191
|
+
it 'should parse correct' do
|
192
|
+
['del', 'd', 'i am del'].each do |w|
|
193
|
+
str = "~~#{w}~~"
|
194
|
+
Minidown.render(str).should == "<p><del>#{w}</del></p>"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should allow mutil in oneline' do
|
199
|
+
str = '~~i am del~~ and ~~i am another del~~'
|
200
|
+
Minidown.render(str).should == '<p><del>i am del</del> and <del>i am another del</del></p>'
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'should not allow space' do
|
205
|
+
str = '~~ del ~~'
|
206
|
+
Minidown.render(str).should == '<p>~~ del ~~</p>'
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'should allow escape' do
|
210
|
+
str = "\\~~del~~"
|
211
|
+
Minidown.render(str).should == '<p>~~del~~</p>'
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
context '*_ em & strong' do
|
216
|
+
it 'parse as em' do
|
217
|
+
['*', '_'].each do |c|
|
218
|
+
Minidown.render("#{c}em#{c}").should == '<p><em>em</em></p>'
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'should work well with text' do
|
223
|
+
Minidown.render("a _close_ a window").should == '<p>a <em>close</em> a window</p>'
|
224
|
+
Minidown.render("a *close* a window").should == '<p>a <em>close</em> a window</p>'
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'can not mass' do
|
228
|
+
Minidown.render("*em_").should == '<p>*em_</p>'
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'parse as strong' do
|
232
|
+
['**', '__'].each do |c|
|
233
|
+
Minidown.render("#{c}strong#{c}").should == '<p><strong>strong</strong></p>'
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
it '* can work in string' do
|
238
|
+
Minidown.render("this*em*string").should == '<p>this<em>em</em>string</p>'
|
239
|
+
end
|
240
|
+
|
241
|
+
it '_ can not work in string' do
|
242
|
+
Minidown.render("_here_method").should == '<p>_here_method</p>'
|
243
|
+
Minidown.render("_here_method_").should == '<p><em>here_method</em></p>'
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should parse correct' do
|
247
|
+
Minidown.render("_ *what*_").should == '<p>_ <em>what</em>_</p>'
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'should allow escape' do
|
251
|
+
Minidown.render("\\*\\_\\*").should == '<p>*_*</p>'
|
252
|
+
end
|
253
|
+
|
254
|
+
it 'should work well' do
|
255
|
+
str = "*View the [source of this content](http://github.github.com/github-flavored-markdown/sample_content.html).*"
|
256
|
+
Minidown.render(str).should == "<p><em>View the <a href=\"http://github.github.com/github-flavored-markdown/sample_content.html\">source of this content</a>.</em></p>"
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
context 'inline code' do
|
261
|
+
it 'should parse correct' do
|
262
|
+
str = "Use the `printf()` function."
|
263
|
+
Minidown.render(str).should == "<p>Use the <code>printf()</code> function.</p>"
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'should can use multi `' do
|
267
|
+
str = "``There is a literal backtick (`) here.``"
|
268
|
+
Minidown.render(str).should == "<p><code>There is a literal backtick (`) here.</code></p>"
|
269
|
+
|
270
|
+
str = 'A single backtick in a code span: `` ` ``
|
271
|
+
|
272
|
+
A backtick-delimited string in a code span: `` `foo` ``'
|
273
|
+
Minidown.render(str).should == '<p>A single backtick in a code span: <code>`</code></p><p>A backtick-delimited string in a code span: <code>`foo`</code></p>'
|
274
|
+
end
|
275
|
+
|
276
|
+
it 'can parse multi inline code' do
|
277
|
+
str = "`hello` `world`"
|
278
|
+
Minidown.render(str).should == "<p><code>hello</code> <code>world</code></p>"
|
279
|
+
end
|
280
|
+
|
281
|
+
it 'should auto escape' do
|
282
|
+
str = "Please don't use any `<blink>` tags."
|
283
|
+
Minidown.render(str).should == "<p>Please don't use any <code><blink></code> tags.</p>"
|
284
|
+
end
|
285
|
+
|
286
|
+
it 'should not auto convert' do
|
287
|
+
str = "`jjyruby@gmail.com`"
|
288
|
+
Minidown.render(str).should == '<p><code>jjyruby@gmail.com</code></p>'
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
context 'image syntax' do
|
293
|
+
it 'should parse correct' do
|
294
|
+
str = ''
|
295
|
+
Minidown.render(str).should == "<p><img src=\"/path/to/img.jpg\" alt=\"Alt text\"></img></p>"
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'should have title' do
|
299
|
+
str = ""
|
300
|
+
Minidown.render(str).should == "<p><img src=\"/path/to/img.jpg\" alt=\"Alt text\" title=\"title\"></img></p>"
|
301
|
+
end
|
302
|
+
|
303
|
+
it 'should allow reference' do
|
304
|
+
str =<<HERE
|
305
|
+
![Image 1][img1]
|
306
|
+
![Image 2][img2]
|
307
|
+
![Image 3][img3]
|
308
|
+
|
309
|
+
[img1]: url/to/image1 "Image 1"
|
310
|
+
[img2]: url/to/image2
|
311
|
+
[img3]: url/to/image3 "Image 3"
|
312
|
+
HERE
|
313
|
+
Minidown.render(str).should == "<p><img src=\"url/to/image1\" alt=\"Image 1\" title=\"Image 1\"></img><br><img src=\"url/to/image2\" alt=\"Image 2\"></img><br><img src=\"url/to/image3\" alt=\"Image 3\" title=\"Image 3\"></img></p>"
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minidown
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jjy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-nav
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Minidown is a lightweight & fast markdown parser, with complete GFM support.
|
84
|
+
email:
|
85
|
+
- jjyruby@gmail.com
|
86
|
+
executables:
|
87
|
+
- minidown
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/minidown
|
98
|
+
- lib/minidown.rb
|
99
|
+
- lib/minidown/document.rb
|
100
|
+
- lib/minidown/element.rb
|
101
|
+
- lib/minidown/elements.rb
|
102
|
+
- lib/minidown/elements/block_element.rb
|
103
|
+
- lib/minidown/elements/code_block_element.rb
|
104
|
+
- lib/minidown/elements/dividing_line_element.rb
|
105
|
+
- lib/minidown/elements/html_element.rb
|
106
|
+
- lib/minidown/elements/indent_code_element.rb
|
107
|
+
- lib/minidown/elements/line_element.rb
|
108
|
+
- lib/minidown/elements/list_element.rb
|
109
|
+
- lib/minidown/elements/list_group_element.rb
|
110
|
+
- lib/minidown/elements/order_list_element.rb
|
111
|
+
- lib/minidown/elements/paragraph_element.rb
|
112
|
+
- lib/minidown/elements/raw_html_element.rb
|
113
|
+
- lib/minidown/elements/table_element.rb
|
114
|
+
- lib/minidown/elements/text_element.rb
|
115
|
+
- lib/minidown/elements/unorder_list_element.rb
|
116
|
+
- lib/minidown/html_helper.rb
|
117
|
+
- lib/minidown/parser.rb
|
118
|
+
- lib/minidown/utils.rb
|
119
|
+
- lib/minidown/version.rb
|
120
|
+
- minidown.gemspec
|
121
|
+
- spec/blank_line_spec.rb
|
122
|
+
- spec/code_block_spec.rb
|
123
|
+
- spec/dividing_line_spec.rb
|
124
|
+
- spec/h1_and_h2_spec.rb
|
125
|
+
- spec/indent_block_spec.rb
|
126
|
+
- spec/li_spec.rb
|
127
|
+
- spec/minidown_spec.rb
|
128
|
+
- spec/paragraph_spec.rb
|
129
|
+
- spec/raw_html_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
- spec/start_with_gt_spec.rb
|
132
|
+
- spec/start_with_shape_spec.rb
|
133
|
+
- spec/table_spec.rb
|
134
|
+
- spec/task_list_spec.rb
|
135
|
+
- spec/text_element_spec.rb
|
136
|
+
homepage: https://github.com/jjyr/minidown
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
metadata: {}
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 2.2.0.rc.1
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: Minidown is a lightweight & fast markdown parser, with complete GFM support.
|
160
|
+
test_files:
|
161
|
+
- spec/blank_line_spec.rb
|
162
|
+
- spec/code_block_spec.rb
|
163
|
+
- spec/dividing_line_spec.rb
|
164
|
+
- spec/h1_and_h2_spec.rb
|
165
|
+
- spec/indent_block_spec.rb
|
166
|
+
- spec/li_spec.rb
|
167
|
+
- spec/minidown_spec.rb
|
168
|
+
- spec/paragraph_spec.rb
|
169
|
+
- spec/raw_html_spec.rb
|
170
|
+
- spec/spec_helper.rb
|
171
|
+
- spec/start_with_gt_spec.rb
|
172
|
+
- spec/start_with_shape_spec.rb
|
173
|
+
- spec/table_spec.rb
|
174
|
+
- spec/task_list_spec.rb
|
175
|
+
- spec/text_element_spec.rb
|