Release v0.13: Typography V3 (Safe mode) & Endnote Extraction Fix

This commit is contained in:
谭凯
2026-02-01 11:51:36 +08:00
parent 8e58415173
commit 40491e6386
95 changed files with 8493 additions and 11 deletions
+19 -2
View File
@@ -82,11 +82,28 @@ class BackfillEngine:
new_tag.string = plain_text
# Copy attributes
# Copy classes and add 'translation'
# Copy classes and add 'translation' or 'translation-no-indent'
classes = element.get('class', [])
if isinstance(classes, str):
classes = classes.split()
new_tag['class'] = classes + ['translation']
# Heuristic: Check for Drop Cap / No-Indent indicators
# Keywords: 'drop', 'first', 'no-indent', 'noindent'
# REMOVED: 'chapter', 'start', 'opener' (too broad, catches titles)
special_keywords = ['drop', 'no-indent', 'noindent']
# 'first' can be risky (e.g. 'first-title').
# Be conservative: match 'first' only if combined with 'para' or 'letter' or similar?
# For now, let's keep 'first' but be aware.
# Actually, user said minimal change. Let's stick to 'drop' and explicit 'no-indent'.
# Checking 'calibre1' etc is useless.
is_special_para = any(k in c.lower() for k in special_keywords for c in classes)
if is_special_para:
new_tag['class'] = classes + ['translation-no-indent']
else:
new_tag['class'] = classes + ['translation']
# Copy style
style = element.get('style')