66Uncomment the steps as you add to your rendering.
77
88"""
9- from io import open , StringIO
9+ from cStringIO import StringIO
1010
1111
1212# importing the html_rendering code with a short name for easy typing.
1313import html_render as hr
14- reload (hr )
14+ reload (hr ) #reloding in case you are ruuing this in iPython
15+ # -- want to make sure the latest version is used
1516
1617
1718## writing the file out:
@@ -24,26 +25,26 @@ def render(page, filename):
2425 """
2526
2627 f = StringIO ()
27- page .render (f , u " " )
28+ page .render (f , " " )
2829
2930 f .seek (0 )
3031
3132 print f .read ()
3233
3334 f .seek (0 )
34- open (filename , 'w' , encoding = "utf-8" ).write ( f .read () )
35+ open (filename , 'w' ).write ( f .read () )
3536
3637
3738## Step 1
3839##########
3940
4041page = hr .Element ()
4142
42- page .append (u "Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text" )
43+ page .append ("Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text" )
4344
44- page .append (u "And here is another piece of text -- you should be able to add any number" )
45+ page .append ("And here is another piece of text -- you should be able to add any number" )
4546
46- render (page , u "test_html_output1.html" )
47+ render (page , "test_html_output1.html" )
4748
4849# ## Step 2
4950# ##########
@@ -52,134 +53,134 @@ def render(page, filename):
5253
5354# body = hr.Body()
5455
55- # body.append(hr.P(u "Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text"))
56+ # body.append(hr.P("Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text"))
5657
57- # body.append(hr.P(u "And here is another piece of text -- you should be able to add any number"))
58+ # body.append(hr.P("And here is another piece of text -- you should be able to add any number"))
5859
5960# page.append(body)
6061
61- # render(page, u "test_html_output2.html")
62+ # render(page, "test_html_output2.html")
6263
6364# # Step 3
6465# ##########
6566
6667# page = hr.Html()
6768
6869# head = hr.Head()
69- # head.append(hr.Title(u "PythonClass = Revision 1087:"))
70+ # head.append(hr.Title("PythonClass = Revision 1087:"))
7071
7172# page.append(head)
7273
7374# body = hr.Body()
7475
75- # body.append(hr.P(u "Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text"))
76- # body.append(hr.P(u "And here is another piece of text -- you should be able to add any number"))
76+ # body.append(hr.P("Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text"))
77+ # body.append(hr.P("And here is another piece of text -- you should be able to add any number"))
7778
7879# page.append(body)
7980
80- # render(page, u "test_html_output3.html")
81+ # render(page, "test_html_output3.html")
8182
8283# # Step 4
8384# ##########
8485
8586# page = hr.Html()
8687
8788# head = hr.Head()
88- # head.append(hr.Title(u "PythonClass = Revision 1087:"))
89+ # head.append(hr.Title("PythonClass = Revision 1087:"))
8990
9091# page.append(head)
9192
9293# body = hr.Body()
9394
94- # body.append(hr.P(u "Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
95- # style=u "text-align: center; font-style: oblique;"))
95+ # body.append(hr.P("Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
96+ # style="text-align: center; font-style: oblique;"))
9697
9798# page.append(body)
9899
99- # render(page, u "test_html_output4.html")
100+ # render(page, "test_html_output4.html")
100101
101102# # Step 5
102103# #########
103104
104105# page = hr.Html()
105106
106107# head = hr.Head()
107- # head.append(hr.Title(u "PythonClass = Revision 1087:"))
108+ # head.append(hr.Title("PythonClass = Revision 1087:"))
108109
109110# page.append(head)
110111
111112# body = hr.Body()
112113
113- # body.append(hr.P(u "Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
114- # style=u "text-align: center; font-style: oblique;"))
114+ # body.append(hr.P("Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
115+ # style="text-align: center; font-style: oblique;"))
115116
116117# body.append(hr.Hr())
117118
118119# page.append(body)
119120
120- # render(page, u "test_html_output5.html")
121+ # render(page, "test_html_output5.html")
121122
122123# # Step 6
123124# #########
124125
125126# page = hr.Html()
126127
127128# head = hr.Head()
128- # head.append(hr.Title(u "PythonClass = Revision 1087:"))
129+ # head.append(hr.Title("PythonClass = Revision 1087:"))
129130
130131# page.append(head)
131132
132133# body = hr.Body()
133134
134- # body.append(hr.P(u "Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
135- # style=u "text-align: center; font-style: oblique;"))
135+ # body.append(hr.P("Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
136+ # style="text-align: center; font-style: oblique;"))
136137
137138# body.append(hr.Hr())
138139
139- # body.append(u "And this is a ")
140- # body.append( hr.A(u "http://google.com", "link") )
141- # body.append(u "to google")
140+ # body.append("And this is a ")
141+ # body.append( hr.A("http://google.com", "link") )
142+ # body.append("to google")
142143
143144# page.append(body)
144145
145- # render(page, u "test_html_output6.html")
146+ # render(page, "test_html_output6.html")
146147
147148# # Step 7
148149# #########
149150
150151# page = hr.Html()
151152
152153# head = hr.Head()
153- # head.append(hr.Title(u "PythonClass = Revision 1087:"))
154+ # head.append(hr.Title("PythonClass = Revision 1087:"))
154155
155156# page.append(head)
156157
157158# body = hr.Body()
158159
159- # body.append( hr.H(2, u "PythonClass - Class 6 example") )
160+ # body.append( hr.H(2, "PythonClass - Class 6 example") )
160161
161- # body.append(hr.P(u "Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
162- # style=u "text-align: center; font-style: oblique;"))
162+ # body.append(hr.P("Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
163+ # style="text-align: center; font-style: oblique;"))
163164
164165# body.append(hr.Hr())
165166
166- # list = hr.Ul(id=u "TheList", style=u "line-height:200%")
167+ # list = hr.Ul(id="TheList", style="line-height:200%")
167168
168- # list.append( hr.Li(u "The first item in a list") )
169- # list.append( hr.Li(u "This is the second item", style="color: red") )
169+ # list.append( hr.Li("The first item in a list") )
170+ # list.append( hr.Li("This is the second item", style="color: red") )
170171
171172# item = hr.Li()
172- # item.append(u "And this is a ")
173- # item.append( hr.A(u "http://google.com", u "link") )
174- # item.append(u "to google")
173+ # item.append("And this is a ")
174+ # item.append( hr.A("http://google.com", "link") )
175+ # item.append("to google")
175176
176177# list.append(item)
177178
178179# body.append(list)
179180
180181# page.append(body)
181182
182- # render(page, u "test_html_output7.html")
183+ # render(page, "test_html_output7.html")
183184
184185# # Step 8
185186# ########
@@ -188,37 +189,37 @@ def render(page, filename):
188189
189190
190191# head = hr.Head()
191- # head.append( hr.Meta(charset=u "UTF-8") )
192- # head.append(hr.Title(u "PythonClass = Revision 1087:"))
192+ # head.append( hr.Meta(charset="UTF-8") )
193+ # head.append(hr.Title("PythonClass = Revision 1087:"))
193194
194195# page.append(head)
195196
196197# body = hr.Body()
197198
198- # body.append( hr.H(2, u "PythonClass - Class 6 example") )
199+ # body.append( hr.H(2, "PythonClass - Class 6 example") )
199200
200- # body.append(hr.P(u "Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
201- # style=u "text-align: center; font-style: oblique;"))
201+ # body.append(hr.P("Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
202+ # style="text-align: center; font-style: oblique;"))
202203
203204# body.append(hr.Hr())
204205
205- # list = hr.Ul(id=u "TheList", style=u "line-height:200%")
206+ # list = hr.Ul(id="TheList", style="line-height:200%")
206207
207- # list.append( hr.Li(u "The first item in a list") )
208- # list.append( hr.Li(u "This is the second item", style="color: red") )
208+ # list.append( hr.Li("The first item in a list") )
209+ # list.append( hr.Li("This is the second item", style="color: red") )
209210
210211# item = hr.Li()
211- # item.append(u "And this is a ")
212- # item.append( hr.A(u "http://google.com", "link") )
213- # item.append(u "to google")
212+ # item.append("And this is a ")
213+ # item.append( hr.A("http://google.com", "link") )
214+ # item.append("to google")
214215
215216# list.append(item)
216217
217218# body.append(list)
218219
219220# page.append(body)
220221
221- # render(page, u "test_html_output8.html")
222+ # render(page, "test_html_output8.html")
222223
223224
224225
0 commit comments