##// END OF EJS Templates
make render_heading reusable
Paul Ivanov -
Show More
@@ -109,13 +109,13 b' class Converter(object):'
109 class ConverterRST(Converter):
109 class ConverterRST(Converter):
110 extension = 'rst'
110 extension = 'rst'
111 figures_counter = 0
111 figures_counter = 0
112 heading_level = {1: '=', 2: '-', 3: '`', 4: '\'', 5: '.', 6: '~'}
112
113
113 def render_heading(self, cell):
114 def render_heading(self, cell):
114 """convert a heading cell to rst
115 """convert a heading cell to rst
115
116
116 Returns list."""
117 Returns list."""
117 heading_level = {1: '=', 2: '-', 3: '`', 4: '\'', 5: '.', 6: '~'}
118 marker = self.heading_level[cell.level]
118 marker = heading_level[cell.level]
119 return ['{0}\n{1}\n'.format(cell.source, marker * len(cell.source))]
119 return ['{0}\n{1}\n'.format(cell.source, marker * len(cell.source))]
120
120
121 def render_code(self, cell):
121 def render_code(self, cell):
@@ -55,9 +55,8 b' def test_render_heading():'
55 nt.assert_true(isinstance(rst_list, list)) # render should return a list
55 nt.assert_true(isinstance(rst_list, list)) # render should return a list
56 rst_str = "".join(rst_list)
56 rst_str = "".join(rst_list)
57 # Confirm rst content
57 # Confirm rst content
58 heading_level = {1: '=', 2: '-', 3: '`', 4: '\'', 5: '.', 6: '~'}
59 chk_str = "Test for heading type H{0}\n{1}\n".format(
58 chk_str = "Test for heading type H{0}\n{1}\n".format(
60 level, heading_level[level] * 24)
59 level, c.heading_level[level] * 24)
61 nt.assert_equal(rst_str, chk_str)
60 nt.assert_equal(rst_str, chk_str)
62
61
63
62
General Comments 0
You need to be logged in to leave comments. Login now