File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 11from  bs4  import  BeautifulSoup 
22import  os , glob , sys 
33
4- #TODO remove breaks 
5- 
64def  file_replace_text (fname , toreplace , replacement ):
75    #print("opening " + fname) 
86    with  open (fname , 'r' ,  encoding = 'ANSI' ) as  file :
@@ -29,6 +27,7 @@ def main():
2927    os .chdir (folderpath )
3028    for  file  in  glob .glob ('*.html' ):
3129        filename  =  file 
30+     os .chdir ('..' )
3231
3332    filepath  =  os .path .join (folderpath , filename )
3433
@@ -42,11 +41,6 @@ def main():
4241    with  open (filepath , encoding = 'utf-8' ) as  fp :
4342        soup  =  BeautifulSoup (fp , "html.parser" )
4443
45-     
46-     # #saves title name for later 
47-     # title = soup.title.get_text() 
48-     # #print(title) 
49- 
5044    #shameless self-promotion 
5145    creditMe  =  soup .new_tag ('meta' , content = 'Converted to HTML by Vinay Janardhanam' )
5246    soup .head .append (creditMe )
@@ -55,8 +49,13 @@ def main():
5549    for  s  in  soup ('style' ):
5650        s .extract ()
5751
58-     # for br in soup('br'): 
59-     #     br.extract() 
52+     #replace <h1> with <h3> 
53+     for  h1  in  soup ('h1' ):
54+         h1 .name  =  'h3' 
55+ 
56+     #replace <h2> with <h4> 
57+     for  h2  in  soup ('h2' ):
58+         h2 .name  =  'h4' 
6059
6160    #remove unnecessary attributes 
6261    for  tag  in  soup ():
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments