mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
css
This commit is contained in:
parent
c1110822cb
commit
6f497fa489
@ -2483,14 +2483,14 @@ class mdict(cishubase):
|
||||
return "application/octet-stream"
|
||||
|
||||
def repairtarget(self, index, base, html_content):
|
||||
import base64
|
||||
import base64, uuid
|
||||
|
||||
src_pattern = r'src="([^"]+)"'
|
||||
href_pattern = r'href="([^"]+)"'
|
||||
|
||||
src_matches = re.findall(src_pattern, html_content)
|
||||
href_matches = re.findall(href_pattern, html_content)
|
||||
|
||||
divid = "luna_internal_" + str(uuid.uuid4())
|
||||
for url in src_matches + href_matches:
|
||||
oked = False
|
||||
iscss = url.lower().endswith(".css")
|
||||
@ -2537,6 +2537,34 @@ class mdict(cishubase):
|
||||
except:
|
||||
file_content = None
|
||||
if file_content:
|
||||
if iscss:
|
||||
try:
|
||||
import sass
|
||||
|
||||
css = file_content.decode("utf8")
|
||||
css = sass.compile(string=(f"#{divid} {{ {css} }}"))
|
||||
csss = css.split("\n")
|
||||
i = 0
|
||||
while i < len(csss):
|
||||
css = csss[i]
|
||||
if css.endswith(" body {"):
|
||||
csss[i] = css[: -len(" body {")] + "{"
|
||||
elif css == "@font-face {":
|
||||
csss[i + 1] = ""
|
||||
for j in range(i + 2, len(csss)):
|
||||
if csss[j].endswith("} }"):
|
||||
i = j
|
||||
csss[j] = csss[j][:-1]
|
||||
break
|
||||
i += 1
|
||||
css = "\n".join(csss)
|
||||
file_content = css.encode("utf8")
|
||||
# print(css)
|
||||
except:
|
||||
from traceback import print_exc
|
||||
|
||||
print_exc()
|
||||
|
||||
base64_content = base64.b64encode(file_content).decode("utf-8")
|
||||
if iscss:
|
||||
html_content = html_content.replace(
|
||||
@ -2548,7 +2576,7 @@ class mdict(cishubase):
|
||||
)
|
||||
elif not oked:
|
||||
print(url)
|
||||
return html_content
|
||||
return f'<div id="{divid}">{html_content}</div>'
|
||||
|
||||
def search(self, word):
|
||||
allres = []
|
||||
@ -2644,12 +2672,10 @@ function onclickbtn_mdict_internal(_id) {
|
||||
{commonstyle}
|
||||
<div class="tab-widget_mdict_internal">
|
||||
<div class="centerdiv_mdict_internal">
|
||||
<div class="tab-buttons_mdict_internal" id="tab_buttons_mdict_internal">
|
||||
{''.join(btns)}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="tab-content_mdict_internal" id="tab_contents_mdict_internal">
|
||||
<div class="tab-content_mdict_internal">
|
||||
{''.join(contents)}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -10,3 +10,4 @@ from importlib import resources
|
||||
from distutils.version import StrictVersion
|
||||
from dataclasses import dataclass
|
||||
import colorsys
|
||||
import sass
|
@ -40,9 +40,7 @@
|
||||
</div>
|
||||
|
||||
<div class="tab-widget">
|
||||
<div class="centerdiv">
|
||||
<div class="tab-buttons" id="tab_buttons">
|
||||
</div>
|
||||
<div class="centerdiv" id="tab_buttons">
|
||||
</div>
|
||||
<div class="centerdiv">
|
||||
<div class="tab-content" id="tab_contents">
|
||||
|
@ -34,9 +34,6 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tab-widget .tab-buttons {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.tab-widget .tab-button {
|
||||
padding: 10px 20px;
|
||||
|
@ -1,5 +1,7 @@
|
||||
#python3.7.9
|
||||
|
||||
PyQt5==5.15.10
|
||||
PyQt5-Qt5==5.15.2
|
||||
webviewpy==1.2.0
|
||||
pefile
|
||||
#python3.7.9
|
||||
libsass
|
@ -1,5 +1,7 @@
|
||||
#python3.11.8
|
||||
|
||||
PyQt6==6.7.0
|
||||
PyQt6-Qt6==6.7.0
|
||||
webviewpy==1.2.0
|
||||
pefile
|
||||
#python3.11.8
|
||||
libsass
|
Loading…
x
Reference in New Issue
Block a user