5 from docutils
import core
8 def rst2html(rst_path
):
10 Convert the file `rst_path` to embedable html string
11 (containing no <body> tags)
13 parts
= core
.publish_parts(
14 source
=open(rst_path
).read(),
15 source_path
=rst_path
, writer_name
='html')
16 return parts
['title'], parts
['html_body']
19 if __name__
== '__main__':
20 FILES
= 'example/blog/*.rst'
22 title
, body
= rst2html(f
)
24 open(f
+'.html', 'w').write(r
'''
26 <title>%(title)s</title>
28 <div style="float: right; background-color: gray; border: 1px solid;">
32 <div style="text-align: center; color: gray; font-size: 10pt; margin-top: 1px dotted;">Copyright (c) Foo Bar</div>