6
6
7
7
'''
8
8
import urllib .request , urllib .parse , urllib .error , urllib .request , urllib .error , urllib .parse , os , yaml
9
- from bs4 import BeautifulSoup as bs ,Comment
9
+ from bs4 import BeautifulSoup as bs ,Comment , Doctype
10
10
import shutil
11
11
12
12
with open (os .path .join ( os .path .dirname (__file__ ),'config.yml' ),'r' ) as file :
@@ -95,7 +95,7 @@ def getMaths(soup):
95
95
urllib .request .install_opener (opener )
96
96
urllib .request .urlretrieve ( img ['src' ] , savepath )
97
97
maths .append ( mathname )
98
- linkurl = os .path .join ('.' ,'imgs\ maths' ,mathname )
98
+ linkurl = os .path .join ('.' ,'imgs/ maths' ,mathname ). replace ( ' \\ ' , '/' )
99
99
img ['src' ] = linkurl
100
100
101
101
except :
@@ -121,7 +121,7 @@ def getImages(tag):
121
121
imgs .append (imgpath )
122
122
123
123
del tag .img ['srcset' ]
124
- imgpath = os .path .join ('.' , 'imgs' , imgname )
124
+ imgpath = os .path .join ('.' , 'imgs' , imgname ). replace ( ' \\ ' , '/' )
125
125
tag .img ['src' ] = imgpath
126
126
tag ['href' ]= imgpath
127
127
@@ -200,6 +200,12 @@ def getFooter( url, name ):
200
200
return bs (footer ,'html.parser' )
201
201
202
202
def getStyled (soup ,title ):
203
+ tag = Doctype ('html' )
204
+ soup .insert (0 , tag )
205
+ soup .html ['lang' ]= 'en'
206
+ meta_tag = soup .new_tag ('meta' )
207
+ meta_tag ['charset' ] = 'UTF-8'
208
+ soup .head .insert (0 ,meta_tag )
203
209
css_tag = bs ('<link rel="stylesheet" href="./styles/style.css">' ,'html.parser' )
204
210
soup .head .append (css_tag )
205
211
soup .body ['class' ] = 'mw-body'
0 commit comments