mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-03-12 17:20:22 +01:00
Strip scripts
This commit is contained in:
parent
ee981f2d57
commit
7ac41b2884
19
Source/Modules/HTML.py
Normal file
19
Source/Modules/HTML.py
Normal file
@ -0,0 +1,19 @@
|
||||
""" ================================= |
|
||||
| This file is part of |
|
||||
| staticoso |
|
||||
| Just a simple Static Site Generator |
|
||||
| |
|
||||
| Licensed under the AGPLv3 license |
|
||||
| Copyright (C) 2022, OctoSpacc |
|
||||
| ================================= """
|
||||
|
||||
from Libs.bs4 import BeautifulSoup
|
||||
from Modules.Utils import *
|
||||
|
||||
def StripTags(HTML, ToStrip):
|
||||
Soup = BeautifulSoup(HTML, 'html.parser')
|
||||
Tags = Soup.find_all()
|
||||
for t in Tags:
|
||||
if t.name in ToStrip:
|
||||
t.replace_with('')
|
||||
return str(Soup)
|
@ -9,6 +9,7 @@
|
||||
|
||||
from Libs import htmlmin
|
||||
from Libs.bs4 import BeautifulSoup
|
||||
from Modules.HTML import *
|
||||
from Modules.Markdown import *
|
||||
from Modules.Pug import *
|
||||
from Modules.Utils import *
|
||||
@ -403,10 +404,7 @@ def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, ConfMenu,
|
||||
SiteLang=SiteLang,
|
||||
Locale=Locale)
|
||||
if NoScripts:
|
||||
HTML = (HTML
|
||||
).replace('<script>', '<!-- script >'
|
||||
).replace('<script ', '<!-- script '
|
||||
).replace('</script>', '</ script -->')
|
||||
HTML = StripTags(HTML, ['script'])
|
||||
if Minify:
|
||||
HTML = DoMinifyHTML(HTML)
|
||||
WriteFile(PagePath, HTML)
|
||||
|
Loading…
x
Reference in New Issue
Block a user