minidown 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/spec/li_spec.rb
ADDED
@@ -0,0 +1,354 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minidown do
|
4
|
+
describe 'ul' do
|
5
|
+
it 'should basic parse correct' do
|
6
|
+
%w{* + -}.each do |s|
|
7
|
+
str = "#{s} ul"
|
8
|
+
Minidown.render(str).should == '<ul><li>ul</li></ul>'
|
9
|
+
str = " #{s} ul"
|
10
|
+
Minidown.render(str).should == '<ul><li>ul</li></ul>'
|
11
|
+
str = "#{s} li1\n#{s} li2\n#{s} li3"
|
12
|
+
Minidown.render(str).should == '<ul><li>li1</li><li>li2</li><li>li3</li></ul>'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should not parse' do
|
17
|
+
%w{* + -}.each do |s|
|
18
|
+
str = "#{s}ul"
|
19
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'escape' do
|
24
|
+
%w{* + -}.each do |s|
|
25
|
+
str = "\\#{s} li"
|
26
|
+
Minidown.render(str).should == "<p>#{str.gsub("\\", '')}</p>"
|
27
|
+
str = "#{s}\\ li"
|
28
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'auto new line' do
|
33
|
+
str = '+ li1
|
34
|
+
newline
|
35
|
+
- li2
|
36
|
+
newline'
|
37
|
+
Minidown.render(str).should == "<ul><li><p>li1</p>\n<p>newline</p></li><li>li2\nnewline</li></ul>"
|
38
|
+
end
|
39
|
+
|
40
|
+
it '<p> in li' do
|
41
|
+
str = '* li1
|
42
|
+
newline
|
43
|
+
|
44
|
+
* li2
|
45
|
+
newline'
|
46
|
+
Minidown.render(str).should == "<ul><li><p>li1<br>newline</p></li><li><p>li2<br>newline</p></li></ul>"
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should parse' do
|
50
|
+
str = 'line
|
51
|
+
* li2'
|
52
|
+
Minidown.render(str).should == "<p>line</p><ul><li>li2</li></ul>"
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'two ul' do
|
56
|
+
str = '- li1
|
57
|
+
newline
|
58
|
+
|
59
|
+
|
60
|
+
* li2
|
61
|
+
newline'
|
62
|
+
Minidown.render(str).should == '<ul><li><p>li1<br>newline</p></li><li><p>li2<br>newline</p></li></ul>'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'can work with indent' do
|
66
|
+
str =<<HERE
|
67
|
+
* here a line
|
68
|
+
noindent
|
69
|
+
HERE
|
70
|
+
Minidown.render(str).should == "<ul><li>here a line\nnoindent</li></ul>"
|
71
|
+
|
72
|
+
str =<<HERE
|
73
|
+
* here a line
|
74
|
+
noindent
|
75
|
+
HERE
|
76
|
+
Minidown.render(str).should == "<ul><li><p>here a line</p>\n<p>noindent</p></li></ul>"
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'can work with block' do
|
80
|
+
str =<<HERE
|
81
|
+
* A list item with a blockquote:
|
82
|
+
|
83
|
+
> This is a blockquote
|
84
|
+
> inside a list item.
|
85
|
+
HERE
|
86
|
+
Minidown.render(str).should == "<ul><li>A list item with a blockquote:\n<blockquote><p>This is a blockquote</p><p>inside a list item.</p></blockquote></li></ul>"
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'can not work with block without indent' do
|
90
|
+
str =<<HERE
|
91
|
+
* A list item with a blockquote:
|
92
|
+
|
93
|
+
> This is a blockquote
|
94
|
+
> inside a list item.
|
95
|
+
HERE
|
96
|
+
Minidown.render(str).should == "<ul><li>A list item with a blockquote:</li></ul><blockquote><p>This is a blockquote</p><p>inside a list item.</p></blockquote>"
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'newline' do
|
100
|
+
str =<<HERE
|
101
|
+
* A list
|
102
|
+
|
103
|
+
Newline
|
104
|
+
HERE
|
105
|
+
Minidown.render(str).should == "<ul><li>A list</li></ul><p>Newline</p>"
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should parse correct' do
|
109
|
+
str = '* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
110
|
+
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
111
|
+
viverra nec, fringilla in, laoreet vitae, risus.
|
112
|
+
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
113
|
+
Suspendisse id sem consectetuer libero luctus adipiscing.
|
114
|
+
---
|
115
|
+
Hi.'
|
116
|
+
Minidown.render(str).should == "<ul><li><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>\n<p>Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,</p>\n<p>viverra nec, fringilla in, laoreet vitae, risus.</p></li><li><p>Donec sit amet nisl. Aliquam semper ipsum sit amet velit.</p>\n<p>Suspendisse id sem consectetuer libero luctus adipiscing.</p></li></ul><hr><p>Hi.</p>"
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'list with indent' do
|
120
|
+
str ='* first
|
121
|
+
start with
|
122
|
+
#and indent'
|
123
|
+
Minidown.render(str).should == "<ul><li>first\nstart with</li></ul><h1>and indent</h1>"
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'nested should parse correct' do
|
127
|
+
str = '* 1
|
128
|
+
* 2
|
129
|
+
* 3
|
130
|
+
* 4
|
131
|
+
* 5
|
132
|
+
* 6
|
133
|
+
* 7'
|
134
|
+
Minidown.render(str).should == '<ul><li>1
|
135
|
+
<ul><li>2 </li><li>3</li></ul></li><li>4
|
136
|
+
<ul><li>5</li><li>6</li><li>7</li></ul></li></ul>'
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe 'ol' do
|
141
|
+
before :each do
|
142
|
+
@random_nums = 5.times.map{rand 42..4242}
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'should basic parse correct' do
|
146
|
+
5.times.map{(42..4242).to_a.sample 3}.each do |n, n2, n3|
|
147
|
+
str = "#{n}. ol"
|
148
|
+
Minidown.render(str).should == '<ol><li>ol</li></ol>'
|
149
|
+
str = "#{n}. li1\n#{n2}. li2\n#{n3}. li3"
|
150
|
+
Minidown.render(str).should == '<ol><li>li1</li><li>li2</li><li>li3</li></ol>'
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should not parse' do
|
155
|
+
@random_nums.each do |s|
|
156
|
+
str = "#{s}ol"
|
157
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
158
|
+
str = " #{s} ol"
|
159
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'escape' do
|
164
|
+
@random_nums.each do |s|
|
165
|
+
str = "\\#{s}. li"
|
166
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
167
|
+
str = "#{s}.\\ li"
|
168
|
+
Minidown.render(str).should == "<p>#{str}</p>"
|
169
|
+
str = "#{s}\\. li"
|
170
|
+
Minidown.render(str).should == "<p>#{s}. li</p>"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'auto new line' do
|
175
|
+
str = '1. li1
|
176
|
+
newline
|
177
|
+
2. li2
|
178
|
+
newline'
|
179
|
+
Minidown.render(str).should == "<ol><li><p>li1</p>\n<p>newline</p></li><li>li2\nnewline</li></ol>"
|
180
|
+
end
|
181
|
+
|
182
|
+
it '<p> in li' do
|
183
|
+
str = '1. li1
|
184
|
+
newline
|
185
|
+
|
186
|
+
2. li2
|
187
|
+
newline'
|
188
|
+
Minidown.render(str).should == '<ol><li><p>li1<br>newline</p></li><li><p>li2<br>newline</p></li></ol>'
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should not parse' do
|
192
|
+
str = 'line
|
193
|
+
1. li2'
|
194
|
+
Minidown.render(str).should == "<p>line</p><ol><li>li2</li></ol>"
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'two line' do
|
198
|
+
str = '1. li1
|
199
|
+
newline
|
200
|
+
|
201
|
+
|
202
|
+
2. li2
|
203
|
+
newline'
|
204
|
+
Minidown.render(str).should == '<ol><li><p>li1<br>newline</p></li><li><p>li2<br>newline</p></li></ol>'
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'can work with indent' do
|
208
|
+
str =<<HERE
|
209
|
+
1. here a line
|
210
|
+
noindent
|
211
|
+
HERE
|
212
|
+
Minidown.render(str).should == "<ol><li>here a line\nnoindent</li></ol>"
|
213
|
+
|
214
|
+
str =<<HERE
|
215
|
+
1. here a line
|
216
|
+
noindent
|
217
|
+
HERE
|
218
|
+
Minidown.render(str).should == "<ol><li><p>here a line</p>\n<p>noindent</p></li></ol>"
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'can work with block' do
|
222
|
+
str =<<HERE
|
223
|
+
1. A list item with a blockquote:
|
224
|
+
|
225
|
+
> This is a blockquote
|
226
|
+
> inside a list item.
|
227
|
+
HERE
|
228
|
+
Minidown.render(str).should == "<ol><li>A list item with a blockquote:\n<blockquote><p>This is a blockquote</p><p>inside a list item.</p></blockquote></li></ol>"
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'can not work with block without indent' do
|
232
|
+
str =<<HERE
|
233
|
+
1. A list item with a blockquote:
|
234
|
+
|
235
|
+
> This is a blockquote
|
236
|
+
> inside a list item.
|
237
|
+
HERE
|
238
|
+
Minidown.render(str).should == "<ol><li>A list item with a blockquote:</li></ol><blockquote><p>This is a blockquote</p><p>inside a list item.</p></blockquote>"
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'newline' do
|
242
|
+
str =<<HERE
|
243
|
+
1. A list
|
244
|
+
|
245
|
+
Newline
|
246
|
+
HERE
|
247
|
+
Minidown.render(str).should == "<ol><li>A list</li></ol><p>Newline</p>"
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'should parse correct' do
|
251
|
+
str = '1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
252
|
+
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
253
|
+
viverra nec, fringilla in, laoreet vitae, risus.
|
254
|
+
2. Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
255
|
+
Suspendisse id sem consectetuer libero luctus adipiscing.
|
256
|
+
---
|
257
|
+
Hi.'
|
258
|
+
Minidown.render(str).should == "<ol><li><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>\n<p>Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,</p>\n<p>viverra nec, fringilla in, laoreet vitae, risus.</p></li><li><p>Donec sit amet nisl. Aliquam semper ipsum sit amet velit.</p>\n<p>Suspendisse id sem consectetuer libero luctus adipiscing.</p></li></ol><hr><p>Hi.</p>"
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'list with indent' do
|
262
|
+
str ='1. first
|
263
|
+
start with
|
264
|
+
#and indent'
|
265
|
+
Minidown.render(str).should == "<ol><li>first\nstart with</li></ol><h1>and indent</h1>"
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'nested should parse correct' do
|
269
|
+
str = '1. 1
|
270
|
+
2. 2
|
271
|
+
3. 3
|
272
|
+
4. 4
|
273
|
+
5. 5
|
274
|
+
6. 6
|
275
|
+
7. 7'
|
276
|
+
Minidown.render(str).should == '<ol><li>1
|
277
|
+
<ol><li>2 </li><li>3</li></ol></li><li>4
|
278
|
+
<ol><li>5</li><li>6</li><li>7</li></ol></li></ol>'
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
describe 'other case' do
|
283
|
+
it 'should parse nest ul' do
|
284
|
+
str = '+ ul 1
|
285
|
+
+ ul 2
|
286
|
+
+ ul 3
|
287
|
+
+ ul 4
|
288
|
+
+ ul 5
|
289
|
+
+ ul 6'
|
290
|
+
Minidown.render(str).should == '<ul><li>ul 1</li><li>ul 2
|
291
|
+
<ul><li>ul 3</li><li>ul 4
|
292
|
+
<ul><li>ul 5</li></ul></li><li>ul 6</li></ul></li></ul>'
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'should parse nest ol' do
|
296
|
+
str = '1. ol 1
|
297
|
+
2. ol 2
|
298
|
+
1. ol 3
|
299
|
+
123. ol 4
|
300
|
+
2. ol 5
|
301
|
+
3. ol 6'
|
302
|
+
Minidown.render(str).should == '<ol><li>ol 1</li><li>ol 2
|
303
|
+
<ol><li>ol 3</li><li>ol 4
|
304
|
+
<ol><li>ol 5</li></ol></li><li>ol 6</li></ol></li></ol>'
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'should parse correct' do
|
308
|
+
str = '+ ul 1
|
309
|
+
+ ul 2
|
310
|
+
+ ul 3
|
311
|
+
+ ul 4
|
312
|
+
+ ul 5
|
313
|
+
+ ul 6
|
314
|
+
|
315
|
+
1. ul a
|
316
|
+
1. ul b
|
317
|
+
1. ul c
|
318
|
+
1. ul d'
|
319
|
+
Minidown.render(str).should == '<ul><li>ul 1</li><li>ul 2
|
320
|
+
<ul><li>ul 3</li><li>ul 4
|
321
|
+
<ul><li>ul 5</li></ul></li><li>ul 6</li></ul></li></ul><ol><li>ul a</li><li>ul b</li><li>ul c</li><li>ul d</li></ol>'
|
322
|
+
end
|
323
|
+
|
324
|
+
it 'mixed list should parsed correct' do
|
325
|
+
str = '* ul1
|
326
|
+
1. ol
|
327
|
+
2. ol
|
328
|
+
3. ol
|
329
|
+
|
330
|
+
* ul2
|
331
|
+
* ul3
|
332
|
+
1. ol
|
333
|
+
2. ol
|
334
|
+
3. ol
|
335
|
+
4. ol
|
336
|
+
5. ol
|
337
|
+
|
338
|
+
+ ul4
|
339
|
+
+ ul5
|
340
|
+
1. ol
|
341
|
+
2. ol
|
342
|
+
3. ol'
|
343
|
+
Minidown.render(str).should == '<ul><li><p>ul1<br><ol><li>ol</li><li>ol</li><li>ol</li></ol></p></li><li><p>ul2</p></li><li><p>ul3<br><ol><li>ol</li><li>ol</li><li>ol</li><li>ol</li><li>ol</li></ol></p></li><li><p>ul4</p></li><li>ul5
|
344
|
+
<ol><li>ol</li><li>ol</li><li>ol</li></ol></li></ul>'
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'list within block' do
|
348
|
+
str = '> block with list
|
349
|
+
- list within block
|
350
|
+
- list within block'
|
351
|
+
Minidown.render(str).should == '<blockquote><p>block with list</p><ul><li>list within block</li><li>list within block</li></ul></blockquote>'
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minidown do
|
4
|
+
it 'Minidown.render should == Parser#render' do
|
5
|
+
Minidown.render("hello").should == Minidown::Parser.new.render("hello")
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'allow options' do
|
9
|
+
options = {}
|
10
|
+
Minidown.render("hello", options).should == Minidown::Parser.new(options).render("hello")
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minidown do
|
4
|
+
describe 'paragraph' do
|
5
|
+
it 'should correct' do
|
6
|
+
str = 'line1
|
7
|
+
line2
|
8
|
+
|
9
|
+
new paragraph
|
10
|
+
some space
|
11
|
+
same paragraph
|
12
|
+
|
13
|
+
new p'
|
14
|
+
Minidown.render(str).should == '<p>line1<br>line2</p><p>new paragraph<br> some space<br>same paragraph</p><p>new p</p>'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minidown do
|
4
|
+
describe 'raw html spec' do
|
5
|
+
it 'should render correctly' do
|
6
|
+
Minidown.render('<a></a>').should == "<p><a></a></p>"
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should render mutilple line well' do
|
10
|
+
str = '<table>
|
11
|
+
<tr>
|
12
|
+
<td>first</td>
|
13
|
+
</tr>
|
14
|
+
<tr>
|
15
|
+
<td>second</td>
|
16
|
+
</tr>
|
17
|
+
</table>'
|
18
|
+
Minidown.render(str).should == "<p><table><tr><td>first</td></tr><tr><td>second</td></tr></table></p>"
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'can be escaped' do
|
22
|
+
Minidown.render("\\<a\\>\\</a\\>\\\\<br\\\\>").should == "<p><a></a>\\<br\\></p>"
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should allow mix with markdown' do
|
26
|
+
str = 'Table for two
|
27
|
+
-------------
|
28
|
+
|
29
|
+
<table>
|
30
|
+
<tr>
|
31
|
+
<th>ID</th><th>Name</th><th>Rank</th>
|
32
|
+
</tr>
|
33
|
+
<tr>
|
34
|
+
<td>1</td><td>Tom Preston-Werner</td><td>Awesome</td>
|
35
|
+
</tr>
|
36
|
+
<tr>
|
37
|
+
<td>2</td><td>Albert Einstein</td><td>Nearly as awesome</td>
|
38
|
+
</tr>
|
39
|
+
</table>'
|
40
|
+
Minidown.render(str).should == "<h2>Table for two</h2><p><table><tr><th>ID</th><th>Name</th><th>Rank</th></tr><tr><td>1</td><td>Tom Preston-Werner</td><td>Awesome</td></tr><tr><td>2</td><td>Albert Einstein</td><td>Nearly as awesome</td></tr></table></p>"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minidown do
|
4
|
+
describe 'start with <' do
|
5
|
+
it 'should parse as blockquote' do
|
6
|
+
[">block", "> block", "> block", "> block"].each do |str|
|
7
|
+
Minidown.render(str).should == "<blockquote><p>#{str[1..-1].strip}</p></blockquote>"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should parse correct' do
|
12
|
+
str =<<HERE
|
13
|
+
> here block
|
14
|
+
> here too
|
15
|
+
HERE
|
16
|
+
Minidown.render(str).should == '<blockquote><p>here block</p><p>here too</p></blockquote>'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should parse region' do
|
20
|
+
str =<<HERE
|
21
|
+
> here block
|
22
|
+
here too
|
23
|
+
yes
|
24
|
+
all is block
|
25
|
+
bbbbbbbbb
|
26
|
+
|
27
|
+
newline
|
28
|
+
HERE
|
29
|
+
Minidown.render(str).should == '<blockquote><p>here block<br>here too<br> yes<br> all is block<br>bbbbbbbbb</p></blockquote><p>newline</p>'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should parse nest' do
|
33
|
+
str =<<HERE
|
34
|
+
> here block
|
35
|
+
here too
|
36
|
+
> yes
|
37
|
+
all is block
|
38
|
+
>> two level
|
39
|
+
two too
|
40
|
+
> still level two
|
41
|
+
still in block
|
42
|
+
|
43
|
+
newline
|
44
|
+
HERE
|
45
|
+
Minidown.render(str).should == '<blockquote><p>here block<br> here too<br>yes<br> all is block</p><blockquote><p>two level<br>two too<br>still level two<br>still in block</p></blockquote></blockquote><p>newline</p>'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'can use other syntax' do
|
50
|
+
it 'use with #' do
|
51
|
+
str = '> ## here h2'
|
52
|
+
Minidown.render(str).should == '<blockquote><h2>here h2</h2></blockquote>'
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should render mutil <p>' do
|
56
|
+
str = '>line1
|
57
|
+
line2
|
58
|
+
###h3 ###
|
59
|
+
another p'
|
60
|
+
Minidown.render(str).should == '<blockquote><p>line1<br>line2</p><h3>h3</h3><p>another p</p></blockquote>'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'should allow escape' do
|
65
|
+
it 'should render correct' do
|
66
|
+
str = '>\>block'
|
67
|
+
Minidown.render(str).should == '<blockquote><p>>block</p></blockquote>'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|