import re from src.format_extractor import FormatExtractor extractor = FormatExtractor() cases = [ ("

“But what is the goal?” Amodei...

", "Quoted text with em"), ("

Q. What is artificial intelligence?

", "Simple Q&A"), ("

Text italic followed by dots...

", "Italic with trailing dots"), ] for html, desc in cases: print(f"--- Testing: {desc} ---") # Simulate how extract() identifies inner_html from bs4 import BeautifulSoup, Tag soup = BeautifulSoup(html, 'html.parser') root = list(soup.children)[0] if list(soup.children) else soup clean_text = root.get_text().strip() clean_text = re.sub(r'\s+', ' ', clean_text).strip() inner_html = root.decode_contents() if isinstance(root, Tag) else str(root) # Call v3 directly text_with_ph, local_map = extractor._smart_extract_v3(inner_html) stripped_text = re.sub(r'φ/?[0-9]+φ', '', text_with_ph) stripped_text = re.sub(r'\s+', ' ', stripped_text).strip() print(f"Clean: '{clean_text}'") print(f"Stripped: '{stripped_text}'") print(f"Text ph: '{text_with_ph}'") print(f"Map: {local_map}") if clean_text == stripped_text: print("✅ SUCCESS") else: print("❌ FAILED") print()