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