Esempio n. 1
0
def main(filein, fileout, verbose=True):

    text = tools.readFile(filein, verbose)
    if verbose:
        print('# <markdown2zim>: Converting to zim...')
    newtext = Zim2Markdown(file=filein).convert(text)
    tools.saveFile(fileout, newtext, verbose)

    return
Esempio n. 2
0
def main(filein,fileout,verbose=True):

    text=tools.readFile(filein,verbose)
    if verbose:
        print('# <markdown2zim>: Converting to zim...')
    newtext=Markdown2Zim().convert(text)
    tools.saveFile(fileout,newtext,verbose)

    return
Esempio n. 3
0
def main(filein,fileout,tag,syntax='markdown',verbose=True):
    '''Extract tagged texts from file.

    filein
    '''

    text=tools.readFile(filein,verbose)
    if verbose:
        print('# <tagextract>: Extracting tagged lines...')
    tagfinder=TagFinder(syntax)
    newtext=tagfinder.extractTag(text,tag)

    headersym='# ' if syntax=='markdown' else '====='
    header='Summary of tag: %s' %tag
    header='%s %s %s' %(headersym, header, headersym)
    newtext=header+'\n\n'+newtext

    tools.saveFile(fileout,newtext,verbose)

    return
Esempio n. 4
0
    def preprocess(self):
        self.filename=os.path.splitext(os.path.split(self.file_in)[1])[0]

        self.text=tools.readFile(self.file_in)
        #self.text=self.text.encode('utf8')
        self.text=self.textparser.unifyNewline(self.text)
        
        self.lines=self.text.split('\n')
        self.lines=[ii+'\n' for ii in self.lines]

        self.nb_struc=self.mapping['notebook']
        self.tt_struc=self.mapping['title']
        self.cnt_struc=self.mapping['content']

        #-------Structure should follow a tree model-------
        struc=[self.structures[ii] for ii in [self.nb_struc,self.tt_struc,self.cnt_struc]]
        if struc!=sorted(struc):
            raise Exception("Structure level wrong")

        return
Esempio n. 5
0
    def preprocess(self):
        self.filename = os.path.splitext(os.path.split(self.file_in)[1])[0]

        self.text = tools.readFile(self.file_in)
        #self.text=self.text.encode('utf8')
        self.text = self.textparser.unifyNewline(self.text)

        self.lines = self.text.split('\n')
        self.lines = [ii + '\n' for ii in self.lines]

        self.nb_struc = self.mapping['notebook']
        self.tt_struc = self.mapping['title']
        self.cnt_struc = self.mapping['content']

        #-------Structure should follow a tree model-------
        struc = [
            self.structures[ii]
            for ii in [self.nb_struc, self.tt_struc, self.cnt_struc]
        ]
        if struc != sorted(struc):
            raise Exception("Structure level wrong")

        return