feat(reader): hash router, zero-flicker reload, honest weighted progress, and smart chapter detection
This commit is contained in:
@@ -594,6 +594,29 @@ Nearly ten years had passed.
|
||||
assert "Chapter 1" in chs[0]["title"]
|
||||
assert "Chapter 2" in chs[1]["title"]
|
||||
|
||||
# 3b. Smart chapter detection: word-spelled (CHAPTER ONE), numbered sections, ALL CAPS, bold
|
||||
smart_txt = """Some intro notes before starting.
|
||||
|
||||
CHAPTER ONE: THE BEGINNING
|
||||
It was a cold day in April.
|
||||
|
||||
1.1 Network Fundamentals
|
||||
Devices communicate over IP.
|
||||
|
||||
**Key Architecture**
|
||||
The architecture is modular.
|
||||
|
||||
CONCLUSION AND NEXT STEPS
|
||||
Final thoughts on the topic.
|
||||
"""
|
||||
st_title, st_auth, st_chs = parse_text(smart_txt, title="Smart Book")
|
||||
assert len(st_chs) >= 4
|
||||
titles = [c["title"] for c in st_chs]
|
||||
assert any("CHAPTER ONE" in t for t in titles)
|
||||
assert any("1.1 Network Fundamentals" in t for t in titles)
|
||||
assert any("Key Architecture" in t for t in titles)
|
||||
assert any("CONCLUSION AND NEXT STEPS" in t for t in titles)
|
||||
|
||||
# 4. parse_text chunking on long text
|
||||
long_words = ["word"] * 7000
|
||||
long_text = "\n\n".join([" ".join(long_words[i:i + 400]) for i in range(0, len(long_words), 400)])
|
||||
|
||||
Reference in New Issue
Block a user