##// END OF EJS Templates
Added heading cell converter. Also changed the down-parser for output to html (from looking for <div> and </div> to <body> and </body>.
smithj1 -
Show More
@@ -27,6 +27,14 b' def unknown_cell(cell):'
27 return rst_directive('.. warning:: Unknown cell') + \
27 return rst_directive('.. warning:: Unknown cell') + \
28 [repr(cell)]
28 [repr(cell)]
29
29
30 def heading_cell(cell):
31 """convert a heading cell to rst
32
33 Returns list."""
34 heading_level = {1:'=', 2:'-', 3:'`', 4:'\'', 5:'.',6:'~'}
35 marker = heading_level[cell.level]
36 return ['{0}\n{1}\n'.format(cell.source, marker*len(cell.source))]
37
30 def markdown_cell(cell):
38 def markdown_cell(cell):
31 """convert a markdown cell to rst
39 """convert a markdown cell to rst
32
40
@@ -97,7 +105,8 b' def out_pyout(output):'
97 return lines
105 return lines
98
106
99
107
100 converters = dict(code = code_cell,
108 converters = dict(heading = heading_cell,
109 code = code_cell,
101 markdown = markdown_cell,
110 markdown = markdown_cell,
102 pyout = out_pyout,
111 pyout = out_pyout,
103 display_data = out_display,
112 display_data = out_display,
@@ -142,7 +151,7 b' def rst2simplehtml(fname):'
142 # simplest html I could find. This should help in making it easier to
151 # simplest html I could find. This should help in making it easier to
143 # paste into the blogspot html window, though I'm still having problems
152 # paste into the blogspot html window, though I'm still having problems
144 # with linebreaks there...
153 # with linebreaks there...
145 cmd_template = ("rst2html --link-stylesheet --no-xml-declaration "
154 cmd_template = ("rst2html.py --link-stylesheet --no-xml-declaration "
146 "--no-generator --no-datestamp --no-source-link "
155 "--no-generator --no-datestamp --no-source-link "
147 "--no-toc-backlinks --no-section-numbering "
156 "--no-toc-backlinks --no-section-numbering "
148 "--strip-comments ")
157 "--strip-comments ")
@@ -165,13 +174,13 b' def rst2simplehtml(fname):'
165 # This may only work if there's a real title defined so we get a 'div class'
174 # This may only work if there's a real title defined so we get a 'div class'
166 # tag, I haven't really tried.
175 # tag, I haven't really tried.
167 for line in walker:
176 for line in walker:
168 if line.startswith('<div class'):
177 if line.startswith('<body>'):
169 break
178 break
170
179
171 newfname = os.path.splitext(fname)[0] + '.html'
180 newfname = os.path.splitext(fname)[0] + '.html'
172 with open(newfname, 'w') as f:
181 with open(newfname, 'w') as f:
173 for line in walker:
182 for line in walker:
174 if line.startswith('</div>'):
183 if line.startswith('</body>'):
175 break
184 break
176 f.write(line)
185 f.write(line)
177 f.write('\n')
186 f.write('\n')
General Comments 0
You need to be logged in to leave comments. Login now