diff --git a/nbconvert.py b/nbconvert.py index 2fac471..e4802fe 100755 --- a/nbconvert.py +++ b/nbconvert.py @@ -109,13 +109,13 @@ class Converter(object): class ConverterRST(Converter): extension = 'rst' figures_counter = 0 + heading_level = {1: '=', 2: '-', 3: '`', 4: '\'', 5: '.', 6: '~'} def render_heading(self, cell): """convert a heading cell to rst Returns list.""" - heading_level = {1: '=', 2: '-', 3: '`', 4: '\'', 5: '.', 6: '~'} - marker = heading_level[cell.level] + marker = self.heading_level[cell.level] return ['{0}\n{1}\n'.format(cell.source, marker * len(cell.source))] def render_code(self, cell): diff --git a/tests/test_simple.py b/tests/test_simple.py index 7ee2485..eeb6577 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -55,9 +55,8 @@ def test_render_heading(): nt.assert_true(isinstance(rst_list, list)) # render should return a list rst_str = "".join(rst_list) # Confirm rst content - heading_level = {1: '=', 2: '-', 3: '`', 4: '\'', 5: '.', 6: '~'} chk_str = "Test for heading type H{0}\n{1}\n".format( - level, heading_level[level] * 24) + level, c.heading_level[level] * 24) nt.assert_equal(rst_str, chk_str)