from pathlib import Path from src.mdx_text_atoms import compare_atom_sets, extract_text_atoms, normalize_text_atom def test_extract_atoms_ignores_syntax_and_keeps_semantic_text(): mdx = """--- title: demo --- import Demo from './Demo.astro' ## 1. Title - **Important** text
More info

Nested semantic text

| A | B | | :--- | :--- | | one | two | ![Diagram caption](/assets/demo.png) """ atoms = extract_text_atoms(mdx, source_name="demo.mdx") texts = [a.normalized for a in atoms] assert "1. Title" in texts assert "Important text" in texts assert "More info" in texts assert "Nested semantic text" in texts assert "A" in texts assert "B" in texts assert "one" in texts assert "two" in texts assert "Diagram caption" in texts assert not any("cursor" in t for t in texts) def test_compare_atom_sets_reports_missing_and_added(): original = extract_text_atoms("- Original text\n- Shared text\n", source_name="original") standardized = extract_text_atoms("- Shared text\n- Added text\n", source_name="standardized") result = compare_atom_sets(original, standardized) assert [a.normalized for a in result["missing_from_standardized"]] == ["Original text"] assert [a.normalized for a in result["added_in_standardized"]] == ["Added text"] def test_normalize_text_atom_removes_markdown_markers_only(): assert normalize_text_atom("**Digital** `Transformation`") == "Digital Transformation"