"""An image is not a cross-reference, and a carried image is counted (0.10.0). Two door-level properties that the asset layer would otherwise get wrong in opposite directions. **A markdown image is not a pointer to another concept.** `structure._LINK` reads `[...](target)` and does not care what stands in front of the bracket, so every pointer this capability writes would arrive in the index as a `references` edge to a concept that cannot exist. That is the same defect K3-21 hit when the `Enclosing section:` line was read as body text and became a second, unresolved edge; the repair there was to append after derivation, and the repair here is that an image link is a different construct from a link. **A concept says how many images it carries.** A bundle that holds an image and says nothing about it is only half an improvement: the count is what lets a consumer, or `okf quality`, tell "this document had no figures" from "this build dropped them". The key is CONDITIONAL -- written only where the count is non-zero -- so a bundle of documents without images is byte-identical to one built before this existed. """ from __future__ import annotations from llm_ingestion_okf.structure import derive_document_structure POINTER = ( "# 84 Boller\n\n" "Hevetidsklasse er gitt i tabell 84-2, jf. Q500.\n\n" "![Tabell 84-2](/assets/e54e5f5da0e8-tabell-84-2.png)\n" "Image: graphics/tabell-84-2.png (120x90 px) -- Tabell 84-2\n\n" "Se ellers [Q100](q100.md).\n" ) def test_an_image_pointer_is_not_a_reference() -> None: structure = derive_document_structure(POINTER, source_file="p761.xml") assert "/assets/e54e5f5da0e8-tabell-84-2.png" not in structure.references def test_the_links_beside_it_still_are() -> None: """The known-positive in the same text: masking must not eat real edges.""" structure = derive_document_structure(POINTER, source_file="p761.xml") assert "q100.md" in structure.references def test_the_asset_name_does_not_leak_a_number_into_references() -> None: """A masked span is still masked: `84-2` inside the file name is not a subject. The span is blanked rather than deleted for exactly this reason -- deleting would move every later offset and break first-appearance order, and leaving it would let the number scan read an identifier out of a file name. """ structure = derive_document_structure(POINTER, source_file="p761.xml") assert all("ASSETS" not in subject.upper() for subject in structure.references) assert "Q500" in structure.references