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
+36
View File
@@ -0,0 +1,36 @@
import json
from bs4 import BeautifulSoup
path = ".work/Gambling Man/book_structure.json"
target_file = "e9781668070765/xhtml/ch08.xhtml"
target_id = "uuid-100309c1-0643-4aa1-8ffb-1d2bfbd0e376"
try:
with open(path, 'r') as f:
data = json.load(f)
target_res = None
for item_id, res in data['resources'].items():
if "ch08.xhtml" in res.get('href', ''):
print(f"Found resource with ID: {item_id}, href: {res.get('href')}")
target_res = res
break
if not target_res:
print(f"Resource {target_file} not found by href search.")
exit(1)
content = target_res['content']
soup = BeautifulSoup(content, 'html.parser')
element = soup.find(id=target_id)
if element:
print(f"--- HTML for {target_id} ---")
print(element.prettify())
print("--- Raw ---")
print(str(element))
else:
print("Element not found")
except Exception as e:
print(e)