Skip to content

Commit 0ad9b4f

Browse files
committed
Added doctype and charset
1 parent 555932a commit 0ad9b4f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/offline-doc-generator.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
'''
88
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
1010
import shutil
1111

1212
with open(os.path.join( os.path.dirname(__file__),'config.yml'),'r') as file:
@@ -95,7 +95,7 @@ def getMaths(soup):
9595
urllib.request.install_opener(opener)
9696
urllib.request.urlretrieve( img['src'] , savepath )
9797
maths.append( mathname )
98-
linkurl = os.path.join('.','imgs\maths',mathname)
98+
linkurl = os.path.join('.','imgs/maths',mathname).replace('\\','/')
9999
img['src'] = linkurl
100100

101101
except:
@@ -121,7 +121,7 @@ def getImages(tag):
121121
imgs.append(imgpath)
122122

123123
del tag.img['srcset']
124-
imgpath = os.path.join('.', 'imgs', imgname)
124+
imgpath = os.path.join('.', 'imgs', imgname).replace('\\','/')
125125
tag.img['src'] = imgpath
126126
tag['href']= imgpath
127127

@@ -200,6 +200,12 @@ def getFooter( url, name ):
200200
return bs(footer,'html.parser')
201201

202202
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)
203209
css_tag = bs('<link rel="stylesheet" href="./styles/style.css">','html.parser')
204210
soup.head.append(css_tag)
205211
soup.body['class'] = 'mw-body'

0 commit comments

Comments
 (0)