File: inline_html_spec.rb

package info (click to toggle)
ruby-bluecloth 2.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 884 kB
  • sloc: ansic: 3,489; ruby: 2,506; makefile: 5
file content (196 lines) | stat: -rw-r--r-- 4,374 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env ruby
# encoding: utf-8

BEGIN {
	require 'pathname'
	basedir = Pathname.new( __FILE__ ).dirname.parent.parent
	
	libdir = basedir + 'lib'
	
#	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
#	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
}

require 'rspec'
require 'bluecloth'

require 'spec/lib/helpers'


#####################################################################
###	C O N T E X T S
#####################################################################

describe BlueCloth, "document with inline HTML" do

	it "preserves TABLE block" do
		the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
		This is a regular paragraph.

		<table>
		    <tr>
		        <td>Foo</td>
		    </tr>
		</table>

		This is another regular paragraph.
		---
		<p>This is a regular paragraph.</p>

		<table>
		    <tr>
		        <td>Foo</td>
		    </tr>
		</table>

		<p>This is another regular paragraph.</p>
		---
	end

	it "preserves DIV block" do
		the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
		This is a regular paragraph.

		<div>
		   Something
		</div>
		Something else.
		---
		<p>This is a regular paragraph.</p>

		<div>
		   Something
		</div>

		<p>Something else.</p>
		---
	end


	it "preserves HRs" do
		the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
		This is a regular paragraph.

		<hr />

		Something else.
		---
		<p>This is a regular paragraph.</p>

		<hr />

		<p>Something else.</p>
		---
	end


	it "preserves fancy HRs" do
		the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
		This is a regular paragraph.

		<hr class="publishers-mark" id="first-hrule" />

		Something else.
		---
		<p>This is a regular paragraph.</p>

		<hr class="publishers-mark" id="first-hrule" />

		<p>Something else.</p>
		---
	end


	it "preserves IFRAMEs" do
		the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
		This is a regular paragraph.

		<iframe src="foo.html" id="foo-frame"></iframe>

		Something else.
		---
		<p>This is a regular paragraph.</p>

		<iframe src="foo.html" id="foo-frame"></iframe>

		<p>Something else.</p>
		---
	end


	it "preserves span-level HTML" do
		the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
		This is some stuff with a <span class="foo">spanned bit of text</span> in
		it. And <del>this *should* be a bit of deleted text</del> which should be
		preserved, and part of it emphasized.
		---
		<p>This is some stuff with a <span class="foo">spanned bit of text</span> in
		it. And <del>this <em>should</em> be a bit of deleted text</del> which should be
		preserved, and part of it emphasized.</p>
		---
	end

	it "preserves block-level HTML case-insensitively" do
		the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
		This is a regular paragraph.

		<TABLE>
		    <TR>
		        <TD>Foo</TD>
		    </TR>
		</TABLE>

		This is another regular paragraph.
		---
		<p>This is a regular paragraph.</p>

		<TABLE>
		    <TR>
		        <TD>Foo</TD>
		    </TR>
		</TABLE>

		<p>This is another regular paragraph.</p>
		---
	end

	it "preserves span-level HTML case-insensitively" do
		the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
		This is some stuff with a <SPAN CLASS="foo">spanned bit of text</SPAN> in
		it. And <DEL>this *should* be a bit of deleted text</DEL> which should be
		preserved, and part of it emphasized.
		---
		<p>This is some stuff with a <SPAN CLASS="foo">spanned bit of text</SPAN> in
		it. And <DEL>this <em>should</em> be a bit of deleted text</DEL> which should be
		preserved, and part of it emphasized.</p>
		---
	end

	it "preserves HTML5 tags" do
		the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
		<aside>
			<p>This is a sidebar that explains some stuff.</p>
		</aside>

		The main content.

		<footer>
			<p>Copyright &copy; 2010 by J. Random Hacker.</p>
		</footer>
		---
		<aside>
		    <p>This is a sidebar that explains some stuff.</p>
		</aside>

		<p>The main content.</p>

		<footer>
		    <p>Copyright &copy; 2010 by J. Random Hacker.</p>
		</footer>
		---
	end


end