def __init__(self, title="", author=""): """ :param title: it is the title of the Markdown file. It is written with Setext-style. :type title: str :param author: it is the author fo the Markdown file. :type author: str """ self.author = author self.header = Header() self.textUtils = TextUtils self.title = self.header.choose_header(level=1, title=title, style='setext') self.table_of_contents = "" self.file_data_text = "" self._table_titles = [] self.reference = Reference() self.image = Image(reference=self.reference)
def test_choose_header(self): header = Header() func_list = [ header.atx_level_1('Atx Example'), header.atx_level_2('Atx Example'), header.atx_level_3('Atx Example'), header.atx_level_4('Atx Example'), header.atx_level_5('Atx Example'), header.atx_level_6('Atx Example'), header.setext_level_1('Setext Example'), header.setext_level_2('Setext Example') ] for x in range(8): if x < 6: title = 'Atx Example' chosen_header = header.choose_header(level=x + 1, title=title, style='atx') else: title = 'Setext Example' chosen_header = header.choose_header(level=x - 5, title=title, style='setext') self.assertEqual(chosen_header, func_list[x])
def test_setext_level_2(self): title = "Text Title Setext 2" result = '\n' + title + '\n' + ''.join(['-' for _ in title]) + '\n' self.assertEqual(Header().setext_level_2(title), result)
def test_atx_level_6(self): title = "Text Title Atx 6" result = '\n###### ' + title + '\n' self.assertEqual(Header().atx_level_6(title), result)