Skip to content

Commit

Permalink
save dark mode settings to db
Browse files Browse the repository at this point in the history
  • Loading branch information
cdhigh committed Sep 3, 2024
1 parent 9121cfc commit d5d3f5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions application/lib/ebook_translator/html_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ def _tag_is_filtered(tag):
def _extract(tag, position):
for child in tag.find_all(recursive=False):
if _contains_text(child) and not _tag_is_filtered(child):
text = str(child).strip()
if text:
#因为非AI翻译容易误翻译超链接里面的内容,所以这里去掉超链接
if position != 'replace' and '<a' in text:
text = re.sub(r'<a\b[^>]*>', '<u>', text)
text = text.replace('</a>', '</u>')
elements.append((child, text))
text = str(child).strip() if position == 'replace' else child.get_text()
elements.append((child, text))
#if text:
# #因为非AI翻译容易误翻译超链接里面的内容,所以这里去掉超链接
# if position != 'replace' and '<a' in text:
# text = re.sub(r'<a\b[^>]*>', '<u>', text)
# text = text.replace('</a>', '</u>')
else:
_extract(child, position)

Expand All @@ -148,7 +148,9 @@ def add_translation_soup(self, soup, tag, trans, dst):
transTag = transTag.contents[0]
if isinstance(transTag, NavigableString):
oldTxt = str(transTag)
transTag = soup.new_tag('span')
transTagName = 'span' if tag.name in ('title', 'tr', 'td', 'th', 'thead', 'tbody', 'table',
'ul', 'ol', 'li', 'a') else tag.name
transTag = soup.new_tag(transTagName)
transTag.string = oldTxt

if origStyle:
Expand Down
2 changes: 1 addition & 1 deletion application/static/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ function decreaseFontSize() {
//将目前的配置保存到服务器
function saveSettings() {
ajax_post('/reader/settings', {fontSize: g_fontSize, allowLinks: g_allowLinks, inkMode: g_inkMode,
topleftDict: g_topleftDict});
darkMode: g_darkMode, topleftDict: g_topleftDict});
}

//显示触摸区域图示
Expand Down

0 comments on commit d5d3f5c

Please sign in to comment.