meta.anchors.content.explicit_end

A standalone line containing exactly <!-- end anchor -->, apart from surrounding horizontal whitespace, ends the active anchor immediately before that line. The comment is excluded from the anchor’s content. Subsequent prose remains outside an anchor until a new definition begins; the explicit marker is optional when another closing boundary already ends the content.

Read in specification context · design/meta/anchors.md

Implementation

Implemented crates/sage-meta/src/spec.rs:435–440

sage_meta::spec · lib:sage_meta

#![allow(unused)]
fn main() {
// {anchor}`meta.anchors.content.explicit_end`
fn explicit_anchor_end(source: &str, block: &Range<usize>) -> Option<Span> {
    const MARKER: &str = "<!-- end anchor -->";
    let line_start = source[..block.start].rfind('\n').map_or(0, |pos| pos + 1);
    let line = source[line_start..block.end]
        .strip_suffix('\n')

}

See more source ↗

Tests and review

Indexed tests and the implementation-completeness and test-adequacy review; no test run is implied.

Implemented sage_meta::prose_rendering_hides_control_comments_but_preserves_literal_examples

crates/sage-meta/tests/browser.rs · test:browser

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.content.explicit_end)]
#[sage::test(meta.anchors.content.literal_syntax)]
fn prose_rendering_hides_control_comments_but_preserves_literal_examples() {
    use sage_meta::spec::{SpecChapter, SpecIndex, SpecSource};
    let source = "{anchor}`demo.rule` A rule.\n\nMore of the rule.\n\n<!-- end anchor -->\n\nOutside commentary.\n\n```html\n<!-- end anchor -->\n```\n\nInline `<!-- end anchor -->`.\n\n<div>\n\n<!-- end anchor -->\n\n</div>\n";
    let mut spec = SpecIndex::from_sources(&[SpecSource {
        file: "design/demo.md".into(),
        source: source.into(),
    }]);
    assert!(spec.diagnostics.is_empty(), "{:?}", spec.diagnostics);
    spec.chapters.insert(
        "design/demo.md".into(),
        SpecChapter {
            file: "design/demo.md".into(),
            namespace: String::new(),
            url: "design/demo.html".into(),
            normative: true,
        },
    );
    let html =
        sage_meta::render_spec_markdown(&spec, "design/demo.md", source, "sage-explorer.html")
            .unwrap();
    assert!(html.contains("More of the rule."));
    assert!(html.contains("Outside commentary."));
    assert!(!html.contains("<!-- end anchor -->"));
    assert_eq!(html.matches("&lt;!-- end anchor --&gt;").count(), 3);
    assert!(html.contains("<code>&lt;!-- end anchor --&gt;</code>"));
    assert!(html.contains("<pre><code class=\"language-html\">&lt;!-- end anchor --&gt;"));
    assert!(html.contains("&lt;div&gt;"));
}
}

See more source ↗

Implemented sage_meta::claims_retain_all_blocks_until_the_next_definition_or_document_end

crates/sage-meta/tests/spec.rs · test:spec

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.content.blocks)]
#[sage::test(meta.anchors.content.next_anchor)]
#[sage::test(meta.anchors.content.source_end)]
#[sage::test(meta.anchors.content.explicit_end)]
#[sage::test(meta.anchors.content.unmatched_end)]
fn claims_retain_all_blocks_until_the_next_definition_or_document_end() {
    let body = "Cachés retain **results**.\n\nA later paragraph qualifies the rule.\n\n- Keep unchanged inputs.\n- Recompute edited inputs.\n\n| Input | Result |\n| --- | --- |\n| same | reused |\n\n```rust\nlet résultat = cached();\n```\n\n    An indented example.\n\n> A quoted qualification.";
    let text = format!(
        "# Règles\n\n{{anchor}}`meta.first`\n{body}\n\n{{anchor}}`meta.second` Réévaluate.\n\nFinal qualification.  \n\n"
    );
    let index = SpecIndex::from_sources(&[source("rules.md", &text)]);
    assert!(index.diagnostics.is_empty(), "{:?}", index.diagnostics);
    let first = &index.anchors["meta.first"];
    let second = &index.anchors["meta.second"];
    assert_eq!(first.content, body);
    assert_eq!(second.content, "Réévaluate.\n\nFinal qualification.");
    for anchor in [first, second] {
        assert_eq!(
            &text[anchor.content_span.start..anchor.content_span.end],
            anchor.content
        );
    }
    assert!(first.content_span.end < second.span.start);
}
}

See more source ↗

Implemented sage_meta::every_atx_and_setext_heading_closes_content_until_a_new_definition

crates/sage-meta/tests/spec.rs · test:spec

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.content.heading)]
#[sage::test(meta.anchors.content.explicit_end)]
fn every_atx_and_setext_heading_closes_content_until_a_new_definition() {
    // The explicit_end rule also says its marker is optional at another boundary.
    // Every input omits that marker: the heading alone must close the claim
    // without a missing-end error or capturing the following prose.
    for heading in [
        "# Heading",
        "## Heading",
        "### Heading",
        "#### Heading",
        "##### Heading",
        "###### Heading",
        "Heading\n=======",
        "Heading\n-------",
    ] {
        let text = format!(
            "{{anchor}}`meta.before` Opening.\n\nA qualification.\n\n{heading}\n\nOutside prose.\n\n{{anchor}}`meta.after` Fresh claim."
        );
        let index = SpecIndex::from_sources(&[source("headings.md", &text)]);
        assert!(
            index.diagnostics.is_empty(),
            "{heading}: {:?}",
            index.diagnostics
        );
        assert_eq!(
            index.anchors["meta.before"].content,
            "Opening.\n\nA qualification."
        );
        assert_eq!(index.anchors["meta.after"].content, "Fresh claim.");
        assert!(index.anchors["meta.before"].content_span.end < text.find(heading).unwrap());
    }
}
}

See more source ↗

Implemented sage_meta::exact_standalone_comments_end_content_and_allow_fresh_definitions

crates/sage-meta/tests/spec.rs · test:spec

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.content.explicit_end)]
fn exact_standalone_comments_end_content_and_allow_fresh_definitions() {
    for end in [
        "<!-- end anchor -->",
        "  <!-- end anchor --> \t",
        "<!-- end anchor -->\r",
    ] {
        let text = format!(
            "{{anchor}}`meta.first` Opening.\n\nFurther detail.\n{end}\nOutside prose.\n\n{{anchor}}`meta.second` Fresh claim.\n<!-- end anchor -->"
        );
        let index = SpecIndex::from_sources(&[source("ends.md", &text)]);
        assert!(
            index.diagnostics.is_empty(),
            "{end:?}: {:?}",
            index.diagnostics
        );
        assert_eq!(
            index.anchors["meta.first"].content,
            "Opening.\n\nFurther detail."
        );
        assert_eq!(index.anchors["meta.second"].content, "Fresh claim.");
        for anchor in index.anchors.values() {
            assert_eq!(
                &text[anchor.content_span.start..anchor.content_span.end],
                anchor.content
            );
        }
    }
}
}

See more source ↗

Implemented sage_meta::malformed_looking_comments_are_content_and_do_not_end_claims

crates/sage-meta/tests/spec.rs · test:spec

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.content.explicit_end)]
#[sage::test(meta.anchors.content.literal_syntax)]
fn malformed_looking_comments_are_content_and_do_not_end_claims() {
    let body = "Opening.\n\n<!--end anchor-->\n\n<!-- end anchor --> trailing text\n\n<!-- end anchor --> <!-- another comment -->\n\nBefore <!-- end anchor -->\n\n<!-- end anchor\n-->\n\n<!-- outer comment\n<!-- end anchor -->\n\nAfter all examples.";
    let text = format!("{{anchor}}`meta.rule` {body}\n\n<!-- end anchor -->\nOutside.");
    let index = SpecIndex::from_sources(&[source("comments.md", &text)]);
    assert!(index.diagnostics.is_empty(), "{:?}", index.diagnostics);
    assert_eq!(index.anchors["meta.rule"].content, body);
}
}

See more source ↗

Implemented sage_meta::rendering_removes_only_parsed_end_markers

crates/sage-meta/tests/spec.rs · test:spec

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.anchors.content.explicit_end)]
#[sage::test(meta.anchors.content.literal_syntax)]
fn rendering_removes_only_parsed_end_markers() {
    let text = "{anchor}`claim` A claim.\n\n```html\n<!-- end anchor -->\n```\n\n<div>\n\n<!-- end anchor -->\n\n</div>\n\n<!--end anchor-->\n\n  <!-- end anchor --> \t\n\nOutside prose.\n";
    let fixture = BookFixture::new("- [Rules](design/rules.md)\n");
    fixture.write("design/rules.md", text);
    let index = fixture.load();
    assert!(index.diagnostics.is_empty(), "{:?}", index.diagnostics);
    for rendered in [
        render_anchors(text).unwrap(),
        index.render_chapter("design/rules.md", text).unwrap(),
    ] {
        assert!(!rendered.contains("  <!-- end anchor --> \t"));
        assert_eq!(rendered.matches("<!-- end anchor -->").count(), 2);
        assert!(rendered.contains("```html\n<!-- end anchor -->\n```"));
        assert!(rendered.contains("<div>\n\n<!-- end anchor -->\n\n</div>"));
        assert!(rendered.contains("<!--end anchor-->"));
        assert!(rendered.ends_with("Outside prose.\n"));
    }
    let replacements = index.role_replacements("design/rules.md", text).unwrap();
    let removals = replacements
        .iter()
        .filter(|(_, value)| value.is_empty())
        .collect::<Vec<_>>();
    assert_eq!(removals.len(), 1);
    let (span, _) = removals[0];
    assert_eq!(&text[span.start..span.end], "  <!-- end anchor --> \t");
}
}

See more source ↗

Review: Accepted · final_quality.

Fresh final marker followup of meta.anchors.content.explicit_end. Preserved previous input/output, started fresh, read the complete claim and all six ordinary tests, and recaptured every previous dependency: spec test source helper lines 1–15, BookFixture lines 536–582 and browser rendering lines 146–225. Compared all fragments by path/selector and both association metadata sets. The only difference is an implementation_references comment on spec.rs validate_implementation_references. Claim, explicit-end behavior, test bodies, helper/rendering captures and metadata are unchanged; no fragments were removed. I reassessed the actual delta against the complete prior assessment below.

The sole ordinary implementation association is explicit_anchor_end with its whole spec.rs context. It examines the complete standalone HTML block line, removes its newline/CR and surrounding spaces/tabs, and requires exact equality with <!-- end anchor -->. parse_anchors invokes recognition at HTML-block start only outside tracked HTML containers; inspecting the whole block prevents individual lines inside larger comments from becoming controls. On recognition finish_anchor ends the active claim before that line and removes the active state, so the comment is excluded and following prose remains unattached until a new definition. Heading, next-definition and source-end boundaries independently close claims; no explicit marker is required. Code/inline examples and tracked HTML containers stay literal. Rendering removes only recorded parsed marker spans, not global matching text. The captured browser helper consumes shared role_replacements and skips their empty marker replacements before rendering other HTML literally.

All six tests provide visible assertions. exact_standalone_comments_end_content_and_allow_fresh_definitions covers exact syntax, padded spaces/tabs and CRLF, two fresh claims, excluded outside prose and original byte slices. malformed_looking_comments_are_content_and_do_not_end_claims retains changed internal spacing, trailing/preceding text, multiple comments, a split comment and nested-looking lines until the actual closing marker. claims_retain_all_blocks_until_the_next_definition_or_document_end checks optional markers at next definition and EOF while preserving intervening rich blocks and spans. every_atx_and_setext_heading_closes_content_until_a_new_definition covers every ATX level and both setext forms, excluding following outside prose and permitting a fresh definition without an end marker. rendering_removes_only_parsed_end_markers exercises direct and chapter rendering, retaining code/HTML-container/malformed examples and outside prose; it asserts exactly one empty replacement with the exact padded marker span. prose_rendering_hides_control_comments_but_preserves_literal_examples checks normal/outside text, absence of raw control comments, exactly three escaped literal occurrences and inline/fenced/container markup. The real BookFixture loads a normative source rather than supplying fabricated spans.

Together the evidence accounts for exact standalone syntax, allowed whitespace/line endings, immediate closure, exclusion, unattached following prose, reopening, optionality at other boundaries and literal/nonexact examples. There are no TODO or N/A entries. The unrelated association comment changes none of this evidence. No source edits, formatting, tests or workspace build were performed; executed review start/read, capture comparisons and record only. No requested edits.

Browse meta anchors

116 anchors

Specification anchors and declared coverage
AnchorImplementationTests
meta (116)102 Implemented24 TODO103 Implemented36 TODO
meta.anchors (22)22 Implemented21 Implemented12 TODO
anchor_pagesImplementedImplementedTODO
book_explorerImplementedImplementedTODO
canonical_sourcesImplementedImplementedTODO
meta.anchors.content (7)7 Implemented7 Implemented
blocksImplementedImplemented
explicit_endImplementedImplemented
headingImplementedImplemented
literal_syntaxImplementedImplemented
next_anchorImplementedImplemented
source_endImplementedImplemented
unmatched_endImplementedImplemented
context_navigationImplementedImplementedTODO
evidence_statusImplementedImplementedTODO
explorer_navigationImplementedTODO
implementation_coverageImplementedImplementedTODO
implementation_referencesImplementedImplementedTODO
placeholder_statusImplementedImplementedTODO
point_excerptsImplementedImplementedTODO
region_balanceImplementedImplemented
region_excerptsImplementedImplementedTODO
test_coverageImplementedImplemented
test_referencesImplementedImplemented
unique_namesImplementedImplementedTODO
meta.book (21)10 Implemented18 TODO12 Implemented18 TODO
anchor_movesImplementedTODOImplementedTODO
authorityImplementedTODOImplementedTODO
browser_deliveryTODOImplementedTODO
browser_dependenciesTODOTODO
browser_rust_sourceTODOTODO
browser_searchTODOTODO
browser_serveTODOTODO
browser_structureTODOTODO
chapter_namesImplementedTODOImplementedTODO
crate_ownershipImplementedImplemented
crates_landingImplementedImplemented
entity_linksTODOTODO
index_groupsImplementedTODOImplementedTODO
index_namespace_pagesImplementedImplemented
index_rowsImplementedTODOImplementedTODO
index_statusImplementedTODOImplementedTODO
rfd_changesTODOTODO
sage_chaptersTODOImplementedTODO
self_descriptionTODOTODO
shared_modelImplementedTODOImplementedTODO
source_rolesTODOTODO
meta.contracts (4)4 Implemented3 TODO4 Implemented3 TODO
cache_invocationsImplementedTODOImplementedTODO
correspondenceImplementedImplemented
observation_coverageImplementedTODOImplementedTODO
validated_sessionImplementedTODOImplementedTODO
meta.language (39)39 Implemented39 Implemented
meta.language.calls (2)2 Implemented2 Implemented
declaredImplementedImplemented
forbiddenImplementedImplemented
meta.language.classes (3)3 Implemented3 Implemented
abstract_completeImplementedImplemented
override_signatureImplementedImplemented
single_inheritanceImplementedImplemented
meta.language.contexts (1)1 Implemented1 Implemented
inheritanceImplementedImplemented
meta.language.envelopes (7)7 Implemented7 Implemented
class_callsImplementedImplemented
createsImplementedImplemented
direct_callsImplementedImplemented
leafImplementedImplemented
permissionsImplementedImplemented
readsImplementedImplemented
receiver_callsImplementedImplemented
meta.language.fields (2)2 Implemented2 Implemented
context_stateImplementedImplemented
kindsImplementedImplemented
meta.language.methods (2)2 Implemented2 Implemented
kindsImplementedImplemented
proseImplementedImplemented
meta.language.model (3)3 Implemented3 Implemented
forbidden_pathsImplementedImplemented
inherited_prohibitionsImplementedImplemented
virtual_dispatchImplementedImplemented
meta.language.types (19)19 Implemented19 Implemented
argument_arityImplementedImplemented
declaration_proseImplementedImplemented
enum_variantsImplementedImplemented
field_proseImplementedImplemented
generic_parametersImplementedImplemented
member_commasImplementedImplemented
name_resolutionImplementedImplemented
opaque_representationImplementedImplemented
preludeImplementedImplemented
qualified_namesImplementedImplemented
recursive_valuesImplementedImplemented
struct_fieldsImplementedImplemented
tuplesImplementedImplemented
type_expressionsImplementedImplemented
unique_fieldsImplementedImplemented
unique_parametersImplementedImplemented
unique_variantsImplementedImplemented
unknown_namesImplementedImplemented
variant_proseImplementedImplemented
meta.reviews (27)27 Implemented27 Implemented
claim_textImplementedImplemented
complete_test_setImplementedImplemented
decisionsImplementedImplemented
fragment_associationsImplementedImplemented
fragment_formatImplementedImplemented
fragment_freshnessImplementedImplemented
gateImplementedImplemented
input_formatImplementedImplemented
input_fragmentsImplementedImplemented
output_formatImplementedImplemented
preparationImplementedImplemented
record_requiredImplementedImplemented
recorded_readsImplementedImplemented
recordingImplementedImplemented
review_delegationImplementedImplemented
review_diagnosticsImplementedImplemented
review_instructionsImplementedImplemented
review_scopeImplementedImplemented
selector_claimImplementedImplemented
selector_line_rangeImplementedImplemented
selector_testImplementedImplemented
selector_whole_fileImplementedImplemented
source_representationImplementedImplemented
stalenessImplementedImplemented
summary_formatImplementedImplemented
test_sourceImplementedImplemented
validation_layoutImplementedImplemented
meta.validation (3)3 TODO3 TODO
claim_specific_evidenceTODOTODO
independent_inspectionTODOTODO
review_packetsTODOTODO