Пример #1
0
 def go(self):
     fname = '../outMark/srbl-' + self.numrev + '.html'
     print('writing: ' + fname)
     f = open(fname, 'wb')
     filelines=[]
     #http://www.penzilla.net/tutorials/python/fileio/
     filelines.append(bytes('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n', 'UTF-8'))
     filelines.append(bytes('<HTML>\n<HEAD>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">', 'UTF-8'))
     filelines.append(bytes('<TITLE>SERRABLO '+ self.numrev +'</TITLE>\n', 'UTF-8'))
     
     filelines.append(bytes('<link rel="stylesheet" type="text/css" href="srbl.css">\n', 'UTF-8'))
     
              
     
     
     filelines.append(bytes('</HEAD>\n<BODY>', 'UTF-8'))
     
     line_number = 0
     
     with open('../data/serrablo'+self.numrev+'.txt', encoding='utf-8') as a_file:  
         for a_line in a_file:
             ln = mylinea(self.numrev, a_line, line_number, self.runto);                                               
             line_number += 1
             filelines.append(ln.prn()+ bytes('\n', 'UTF-8') )
     filelines.append(bytes('\n</BODY>\n</HTML>', 'UTF-8'))   
     allin=""
     for linea in filelines:
         allin += str(linea, encoding='utf8')
         
     #print (allin) 
     fhtml = markdown(allin)
     print (fhtml) 
     f.write (fhtml.encode(encoding='utf_8', errors='strict'))
     f.close()
Пример #2
0
from mark3 import markdown

if __name__ == "__main__":
    import sys

    print(markdown.markdown(sys.stdin.read()))
def raw_row_to_dict(raw_row):
    return dict(uri=raw_row[0],
                title=raw_row[1],
                rating=int(raw_row[2]),
                notes=raw_row[3],
                mdnotes=markdown(raw_row[3]))
Пример #4
0
    def go(self):
        # vacio el directrorio de imagenes si existe
        dirimg='..\data\IMAGENES'+ self.numrev +'\web'
        if (processImg and os.path.exists(dirimg)):
            shutil.rmtree(dirimg)

        fname = '../outMark/srbl-' + self.numrev + '.html'
        print('writing: ' + fname)
        f = open(fname, 'wb')
        filelines=[]
        #http://www.penzilla.net/tutorials/python/fileio/
        filelines.append(bytes('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n', 'UTF-8'))
        filelines.append(bytes('<HTML>\n<HEAD>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">', 'UTF-8'))
        filelines.append(bytes('<TITLE>SERRABLO '+ self.numrev +'</TITLE>\n', 'UTF-8'))
        
        filelines.append(bytes('<link rel="stylesheet" type="text/css" href="srbl.css">\n', 'UTF-8'))
        
        filelines.append(bytes('</HEAD>\n<BODY>', 'UTF-8'))
        
        line_number = 0
        
        with open('../data/serrablo'+self.numrev+'.txt', encoding='utf-8') as a_file:  
            for a_line in a_file:
                ln = mylinea(self.numrev, a_line, line_number, self.runto, self.processImg);                                               
                line_number += 1
                filelines.append(ln.prn() )
                # Si es un título, pongo la url
                # ## <a name="a2"/>Arrieros en el Alto Gállego: Éramos pocos… y llegó el ferrocarril (III)
                h2markup = "## "
                lintratada = a_line #.rstrip()
                        
                # construye la url        
                if lintratada.startswith(h2markup):
                    strtmp1 = lintratada.replace(h2markup, "").rstrip()
                    # busco >
                    inicio = strtmp1.find (">") + 1
                    #>>> x[2:]
                    #'llo World!'
                    res = strtmp1[inicio:]
                    #filelines.append(bytes(res + "\n", 'UTF-8'))
                    print ("*********************************************************") 
                    print ("strtmp1" + strtmp1) 
                    #print ("inicio" + inicio) 
                    print ("inicio= %d", inicio )
                    res = res.lower()
                    res = res.replace(" ", "-")
                    res = res.replace(":", "-")
                    res = res.replace("á", "a")
                    res = res.replace("é", "e")
                    res = res.replace("í", "i")
                    res = res.replace("ó", "o")
                    res = res.replace("ú", "u")
                    res = res.replace("ú", "u")
                    res = res.replace(".", "")
                    res = res.replace("(", "")
                    res = res.replace(")", "")
                    res = res.replace("“", "")
                    res = res.replace("”", "")
                    
                    # quito los dobles que puedan quedar
                    res = res.replace("--", "-").replace("--", "-")
                    
                    
                    #print (res10) 
                    filelines.append(bytes('revista/'+self.numrev+'/'+res + "\n", 'UTF-8'))
                 
        filelines.append(bytes('\n</BODY>\n</HTML>', 'UTF-8'))   
        allin=""
        for linea in filelines:
            allin += str(linea, encoding='utf8')
            
        #print (allin) 
        #return md.convert(some_text)
        fhtml = markdown(allin)
        print (fhtml) 
        f.write (fhtml.encode(encoding='utf_8', errors='strict'))
        f.close()
Пример #5
0
from mark3.markdown import markdown
html = markdown(raw_text)