mirror of
https://gitlab.com/CodeSolutionsProject/MiniThunder.git
synced 2026-02-17 10:31:32 +01:00
Support twig and htm[l]
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"supported": ["js","css"]
|
"supported": ["js","css","htm","html","twig"]
|
||||||
}
|
}
|
||||||
@@ -45,9 +45,38 @@ def minimizeFile(source, production, format):
|
|||||||
output.write(jsmin(input.read()))
|
output.write(jsmin(input.read()))
|
||||||
if format == "css":
|
if format == "css":
|
||||||
output.write(cssmin(input.read(), keep_bang_comments=False))
|
output.write(cssmin(input.read(), keep_bang_comments=False))
|
||||||
|
if format == "html" or format == "htm" or format == "twig":
|
||||||
|
output.write(htmlmin(input.read()))
|
||||||
input.close()
|
input.close()
|
||||||
output.close()
|
output.close()
|
||||||
|
|
||||||
|
def htmlmin(source):
|
||||||
|
ret=""
|
||||||
|
codePre=False #Is inside a code or pre label
|
||||||
|
lines=source.split("\n")
|
||||||
|
for i in lines:
|
||||||
|
if "<!DOCTYPE" in i:
|
||||||
|
ret=i+"\n"
|
||||||
|
else:
|
||||||
|
if "</pre>" in i or "</code>" in i:
|
||||||
|
codePre=False
|
||||||
|
elif "<pre>" in i or "<code>" in i:
|
||||||
|
codePre=True
|
||||||
|
|
||||||
|
if codePre:
|
||||||
|
ret+="\n"+i
|
||||||
|
else:
|
||||||
|
index=0
|
||||||
|
for j in i:
|
||||||
|
if j != " " and j != "\t":
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
index+=1
|
||||||
|
i=i[index:]
|
||||||
|
ret+=i
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(_) == 1 or _[1] == "-h":
|
if len(_) == 1 or _[1] == "-h":
|
||||||
help()
|
help()
|
||||||
|
|||||||
Reference in New Issue
Block a user