mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-04-12 17:21:53 +02: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 import htmlmin
|
||||||
from Libs.bs4 import BeautifulSoup
|
from Libs.bs4 import BeautifulSoup
|
||||||
|
from Modules.HTML import *
|
||||||
from Modules.Markdown import *
|
from Modules.Markdown import *
|
||||||
from Modules.Pug import *
|
from Modules.Pug import *
|
||||||
from Modules.Utils import *
|
from Modules.Utils import *
|
||||||
@ -403,10 +404,7 @@ def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, ConfMenu,
|
|||||||
SiteLang=SiteLang,
|
SiteLang=SiteLang,
|
||||||
Locale=Locale)
|
Locale=Locale)
|
||||||
if NoScripts:
|
if NoScripts:
|
||||||
HTML = (HTML
|
HTML = StripTags(HTML, ['script'])
|
||||||
).replace('<script>', '<!-- script >'
|
|
||||||
).replace('<script ', '<!-- script '
|
|
||||||
).replace('</script>', '</ script -->')
|
|
||||||
if Minify:
|
if Minify:
|
||||||
HTML = DoMinifyHTML(HTML)
|
HTML = DoMinifyHTML(HTML)
|
||||||
WriteFile(PagePath, HTML)
|
WriteFile(PagePath, HTML)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user