from utils.files import Files
class MarkDown:
    def __init__(self,markDownFile,parsedData):
        self.markDownFile=markDownFile
        self.parsedData=parsedData
        self.configs=self.loadConfigs("./Configs/formats/comments.json")

    def loadConfigs(self,configsPath):
        return Files.load_json(configsPath)

    def documentFile(self):
        formated_data=""
        for element in self.parsedData:
            formated_data+=str(self.documentElement(element))
        return formated_data

    def documentElement(self,element):
        splitElement=element.split(":")
        return {
            "T":lambda: MarkDownComponents.title(splitElement[1],1),
            "sT":lambda: MarkDownComponents.title(splitElement[1],2),
            "P":lambda: MarkDownComponents.paragraph(splitElement[1]),
            "I":lambda: MarkDownComponents.image(splitElement[1]),
            "i":lambda: MarkDownComponents.italic(splitElement[1])
            #"L":lambda: MarkDownComponents.title(splitElement[1])
        }.get(splitElement[0],lambda: None)()

class MarkDownComponents:
    
    @staticmethod
    def title(title,level):
        t="#"
        while(level>0):
            t+="#"
            level-=1
        return t+" "+title+"\n"

    @staticmethod
    def paragraph(text):
        return text+"\n"

    @staticmethod
    def unOrderedList(listData,listTitle):
        listD=""
        for item in listData:
            listD+="* "+item+"\n"
        return listD+"\n"

    @staticmethod
    def italic(text):
        return "*"+text+"*"

    @staticmethod
    def image(imagePath):
        return "![Screenshot]"+str(imagePath)


3aa9d0966a16807064cbfb953a21f0dfd99384cc
<mask token>


class MarkDown:
    <mask token>
    <mask token>
    <mask token>
    <mask token>


class MarkDownComponents:

    @staticmethod
    def title(title, level):
        t = '#'
        while level > 0:
            t += '#'
            level -= 1
        return t + ' ' + title + '\n'

    @staticmethod
    def paragraph(text):
        return text + '\n'

    @staticmethod
    def unOrderedList(listData, listTitle):
        listD = ''
        for item in listData:
            listD += '* ' + item + '\n'
        return listD + '\n'

    @staticmethod
    def italic(text):
        return '*' + text + '*'

    @staticmethod
    def image(imagePath):
        return '![Screenshot]' + str(imagePath)

<mask token>


class MarkDown:
    <mask token>
    <mask token>

    def documentFile(self):
        formated_data = ''
        for element in self.parsedData:
            formated_data += str(self.documentElement(element))
        return formated_data
    <mask token>


class MarkDownComponents:

    @staticmethod
    def title(title, level):
        t = '#'
        while level > 0:
            t += '#'
            level -= 1
        return t + ' ' + title + '\n'

    @staticmethod
    def paragraph(text):
        return text + '\n'

    @staticmethod
    def unOrderedList(listData, listTitle):
        listD = ''
        for item in listData:
            listD += '* ' + item + '\n'
        return listD + '\n'

    @staticmethod
    def italic(text):
        return '*' + text + '*'

    @staticmethod
    def image(imagePath):
        return '![Screenshot]' + str(imagePath)

<mask token>


class MarkDown:

    def __init__(self, markDownFile, parsedData):
        self.markDownFile = markDownFile
        self.parsedData = parsedData
        self.configs = self.loadConfigs('./Configs/formats/comments.json')

    def loadConfigs(self, configsPath):
        return Files.load_json(configsPath)

    def documentFile(self):
        formated_data = ''
        for element in self.parsedData:
            formated_data += str(self.documentElement(element))
        return formated_data
    <mask token>


class MarkDownComponents:

    @staticmethod
    def title(title, level):
        t = '#'
        while level > 0:
            t += '#'
            level -= 1
        return t + ' ' + title + '\n'

    @staticmethod
    def paragraph(text):
        return text + '\n'

    @staticmethod
    def unOrderedList(listData, listTitle):
        listD = ''
        for item in listData:
            listD += '* ' + item + '\n'
        return listD + '\n'

    @staticmethod
    def italic(text):
        return '*' + text + '*'

    @staticmethod
    def image(imagePath):
        return '![Screenshot]' + str(imagePath)

from utils.files import Files


class MarkDown:

    def __init__(self, markDownFile, parsedData):
        self.markDownFile = markDownFile
        self.parsedData = parsedData
        self.configs = self.loadConfigs('./Configs/formats/comments.json')

    def loadConfigs(self, configsPath):
        return Files.load_json(configsPath)

    def documentFile(self):
        formated_data = ''
        for element in self.parsedData:
            formated_data += str(self.documentElement(element))
        return formated_data

    def documentElement(self, element):
        splitElement = element.split(':')
        return {'T': lambda : MarkDownComponents.title(splitElement[1], 1),
            'sT': lambda : MarkDownComponents.title(splitElement[1], 2),
            'P': lambda : MarkDownComponents.paragraph(splitElement[1]),
            'I': lambda : MarkDownComponents.image(splitElement[1]), 'i': 
            lambda : MarkDownComponents.italic(splitElement[1])}.get(
            splitElement[0], lambda : None)()


class MarkDownComponents:

    @staticmethod
    def title(title, level):
        t = '#'
        while level > 0:
            t += '#'
            level -= 1
        return t + ' ' + title + '\n'

    @staticmethod
    def paragraph(text):
        return text + '\n'

    @staticmethod
    def unOrderedList(listData, listTitle):
        listD = ''
        for item in listData:
            listD += '* ' + item + '\n'
        return listD + '\n'

    @staticmethod
    def italic(text):
        return '*' + text + '*'

    @staticmethod
    def image(imagePath):
        return '![Screenshot]' + str(imagePath)

from utils.files import Files
class MarkDown:
    def __init__(self,markDownFile,parsedData):
        self.markDownFile=markDownFile
        self.parsedData=parsedData
        self.configs=self.loadConfigs("./Configs/formats/comments.json")

    def loadConfigs(self,configsPath):
        return Files.load_json(configsPath)

    def documentFile(self):
        formated_data=""
        for element in self.parsedData:
            formated_data+=str(self.documentElement(element))
        return formated_data

    def documentElement(self,element):
        splitElement=element.split(":")
        return {
            "T":lambda: MarkDownComponents.title(splitElement[1],1),
            "sT":lambda: MarkDownComponents.title(splitElement[1],2),
            "P":lambda: MarkDownComponents.paragraph(splitElement[1]),
            "I":lambda: MarkDownComponents.image(splitElement[1]),
            "i":lambda: MarkDownComponents.italic(splitElement[1])
            #"L":lambda: MarkDownComponents.title(splitElement[1])
        }.get(splitElement[0],lambda: None)()

class MarkDownComponents:
    
    @staticmethod
    def title(title,level):
        t="#"
        while(level>0):
            t+="#"
            level-=1
        return t+" "+title+"\n"

    @staticmethod
    def paragraph(text):
        return text+"\n"

    @staticmethod
    def unOrderedList(listData,listTitle):
        listD=""
        for item in listData:
            listD+="* "+item+"\n"
        return listD+"\n"

    @staticmethod
    def italic(text):
        return "*"+text+"*"

    @staticmethod
    def image(imagePath):
        return "![Screenshot]"+str(imagePath)

