feat(PR-06): one-command frozen-CLI acceptance, evidence and final docs

- tools/acceptance.sh: RFC §18.1 end-to-end acceptance against the frozen CLI
  release archive in an isolated tool home (build/test/bundle/archive-install/
  view help/verify/export/browse/explicit CSRF run/export+security+browser
  suites/CLI SHA check) and generation of docs/evidence/<CLI-SHA>/manifest.json
- tools/test-contract.sh + .woodpecker.yml CI lanes (remote CI unverified)
- docs/ACCEPTANCE.md gate table (P0 all PASS; U-01/U-04 honestly PARTIAL),
  docs/audits/protocol-conformance.md, ADR-0006 documented RFC deviations
- unicode/CRLF/duplicate-text examples + frozen goldens + tests (S-04)
- presentation degradation matrix tests (S-05..S-07), hostile-stdout escaping
  test (X-05), keyboard accessibility browser checks (U-03)
- final README/STATUS/COMPATIBILITY/CHANGELOG with honest limitations
This commit is contained in:
marqdo-view dev committed 2026-11-22 12:06:45 +08:00
1 parent 1f34daffb0
commit d641ca58ac
21 files changed
+1562 -70

No files matched your search

+24
View File
@@ -70,6 +70,30 @@ function localHostOnly(url) {
(await page.locator('.mq-dock-btn[data-action="run"]').count()) === 1
);
// Keyboard reachability: focus must move through named interactive elements.
const namedTabStops = await page.evaluate(async () => {
return Array.from(document.querySelectorAll("a[href], button")).map((el) => ({
label: (el.getAttribute("aria-label") || el.textContent || "").trim(),
hidden: el.offsetParent === null,
}));
});
check(
"interactive controls have accessible names",
namedTabStops.filter((item) => !item.hidden && item.label.length > 0).length >= 8,
JSON.stringify(namedTabStops.slice(0, 8))
);
let focusedNamed = 0;
for (let index = 0; index < 10; index += 1) {
await page.keyboard.press("Tab");
const label = await page.evaluate(() => {
const element = document.activeElement;
if (!element) return "";
return (element.getAttribute("aria-label") || element.textContent || "").trim();
});
if (label.length > 0) focusedNamed += 1;
}
check("Tab reaches named controls", focusedNamed >= 6, String(focusedNamed));
// Source/document mode switch through the single menu.
await page.click('.mq-dock-btn[data-action="more"]');
check("more dialog opens", await page.locator("#mq-dialog-more").isVisible());
+7 -1
View File
@@ -74,7 +74,13 @@ fn degradation_without_core_keeps_prose_readable() {
// invent semantic annotations or a fake run state.
let project = common::TempProject::new("cli-degrade-no-core");
project.marqdo_project("# @knowledge 标题\n\n正文 **加粗**。\n");
let context = marqdo_view::app::AppContext::open(&project.dir, None).unwrap();
// Explicitly point at a missing core so the test is independent of the
// caller environment (acceptance scripts export MARQDO_BIN).
let context = marqdo_view::app::AppContext::open(
&project.dir,
Some(std::path::Path::new("/definitely/missing/marqdo-frozen")),
)
.unwrap();
let relative = context.project().entry().relative.clone();
let model = context.load(&relative).unwrap();
assert_eq!(model.source_status.data_value(), "core-unavailable");
@@ -0,0 +1,212 @@
{
"diagnostics": [],
"modules": [
{
"calls": [],
"functions": [
{
"body": [
{
"arms": [
{
"body": [
{
"kind": "return",
"span": {
"end": 148,
"start": 138
},
"value": {
"kind": "variable",
"name": "n",
"span": {
"end": 147,
"start": 146
}
}
}
],
"condition": {
"kind": "binary",
"left": {
"kind": "variable",
"name": "n",
"span": {
"end": 128,
"start": 127
}
},
"op": "gt",
"right": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "int",
"value": "0"
},
"span": {
"end": 132,
"start": 127
}
},
"condition_span": {
"end": 134,
"start": 122
},
"span": {
"end": 134,
"start": 122
}
},
{
"body": [
{
"kind": "return",
"span": {
"end": 174,
"start": 164
},
"value": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "int",
"value": "0"
}
}
],
"condition": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "bool",
"value": true
},
"condition_span": {
"end": 134,
"start": 122
},
"span": {
"end": 134,
"start": 122
}
}
],
"kind": "branch",
"span": {
"end": 134,
"start": 122
}
}
],
"effects": [
"unknown"
],
"heading_span": {
"end": 98,
"start": 85
},
"id": "root:unicode-spans@0.1.0::crlf.mq.md::演示.main",
"local_name": "main",
"namespace": "演示",
"signature": {
"kind": "explicit",
"params": [
{
"default": null,
"name": "n",
"required": true,
"span": {
"end": 115,
"start": 109
},
"type": "Int"
}
]
},
"span": {
"end": 185,
"start": 85
},
"unit_id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main"
}
],
"id": "root:unicode-spans@0.1.0::crlf.mq.md",
"imports": [],
"package_instance_id": "root:unicode-spans@0.1.0",
"references": [],
"relative_path": "crlf.mq.md",
"resources": [],
"source_digest": "3d6c99d8e1666b14cc51e6774a4cf514a3a252f3b2f9f541c7cde4a090551b1f",
"units": [
{
"function": null,
"id": "root:unicode-spans@0.1.0::crlf.mq.md#",
"kind": "root",
"level": 0,
"name": "",
"span": {
"end": 185,
"start": 0
}
},
{
"function": null,
"id": "root:unicode-spans@0.1.0::crlf.mq.md#CRLF 文档",
"kind": "namespace",
"level": 1,
"name": "CRLF 文档",
"span": {
"end": 24,
"start": 0
}
},
{
"function": null,
"id": "root:unicode-spans@0.1.0::crlf.mq.md#演示",
"kind": "namespace",
"level": 1,
"name": "演示",
"span": {
"end": 81,
"start": 67
}
},
{
"function": "root:unicode-spans@0.1.0::crlf.mq.md::演示.main",
"id": "root:unicode-spans@0.1.0::crlf.mq.md#演示/main",
"kind": "function",
"level": 2,
"name": "main",
"span": {
"end": 98,
"start": 85
}
}
]
}
],
"producer": {
"markdown_profile": "marqdo.md.v1",
"name": "marqdo",
"version": "3.0.0-beta.1"
},
"project": {
"identity_kind": "manifest",
"lock_digest": "",
"root_id": "root:unicode-spans@0.1.0",
"stdlib": {
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
"version": "0.1.0"
}
},
"schema": "marqdo.analysis",
"schema_version": 2
}
+213
View File
@@ -0,0 +1,213 @@
{
"diagnostics": [],
"modules": [
{
"calls": [],
"functions": [
{
"body": [
{
"arms": [
{
"body": [
{
"kind": "return",
"span": {
"end": 271,
"start": 261
},
"value": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "int",
"value": "1"
}
}
],
"condition": {
"kind": "binary",
"left": {
"kind": "variable",
"name": "n",
"span": {
"end": 253,
"start": 252
}
},
"op": "gt",
"right": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "int",
"value": "0"
},
"span": {
"end": 257,
"start": 252
}
},
"condition_span": {
"end": 259,
"start": 247
},
"span": {
"end": 259,
"start": 247
}
},
{
"body": [
{
"kind": "return",
"span": {
"end": 293,
"start": 283
},
"value": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "int",
"value": "1"
}
}
],
"condition": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "bool",
"value": true
},
"condition_span": {
"end": 259,
"start": 247
},
"span": {
"end": 259,
"start": 247
}
}
],
"kind": "branch",
"span": {
"end": 259,
"start": 247
}
}
],
"effects": [
"unknown"
],
"heading_span": {
"end": 227,
"start": 214
},
"id": "root:unicode-spans@0.1.0::index.mq.md::演示.main",
"local_name": "main",
"namespace": "演示",
"signature": {
"kind": "explicit",
"params": [
{
"default": null,
"name": "n",
"required": true,
"span": {
"end": 242,
"start": 236
},
"type": "Int"
}
]
},
"span": {
"end": 302,
"start": 214
},
"unit_id": "root:unicode-spans@0.1.0::index.mq.md#演示/main"
}
],
"id": "root:unicode-spans@0.1.0::index.mq.md",
"imports": [],
"package_instance_id": "root:unicode-spans@0.1.0",
"references": [],
"relative_path": "index.mq.md",
"resources": [],
"source_digest": "b4f8dd12f18a984af129974bc4dd153e97df99cc262bcafb2ae1187b6c5ce7d0",
"units": [
{
"function": null,
"id": "root:unicode-spans@0.1.0::index.mq.md#",
"kind": "root",
"level": 0,
"name": "",
"span": {
"end": 302,
"start": 0
}
},
{
"function": null,
"id": "root:unicode-spans@0.1.0::index.mq.md#中文 🙂 标题",
"kind": "namespace",
"level": 1,
"name": "中文 🙂 标题",
"span": {
"end": 31,
"start": 0
}
},
{
"function": null,
"id": "root:unicode-spans@0.1.0::index.mq.md#演示",
"kind": "namespace",
"level": 1,
"name": "演示",
"span": {
"end": 212,
"start": 198
}
},
{
"function": "root:unicode-spans@0.1.0::index.mq.md::演示.main",
"id": "root:unicode-spans@0.1.0::index.mq.md#演示/main",
"kind": "function",
"level": 2,
"name": "main",
"span": {
"end": 227,
"start": 214
}
}
]
}
],
"producer": {
"markdown_profile": "marqdo.md.v1",
"name": "marqdo",
"version": "3.0.0-beta.1"
},
"project": {
"identity_kind": "manifest",
"lock_digest": "",
"root_id": "root:unicode-spans@0.1.0",
"stdlib": {
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
"version": "0.1.0"
}
},
"schema": "marqdo.analysis",
"schema_version": 2
}
+29
View File
@@ -509,6 +509,35 @@ fn failed_run_reports_core_error_code_without_fake_success() {
assert!(!page.contains("data-run-state=\"succeeded\""));
}
#[test]
fn program_stdout_is_escaped_not_injected_as_markup() {
let tmp = std::path::PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join(format!(
"hostile-stdout-{}-{}.json",
std::process::id(),
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_nanos())
.unwrap_or(0)
));
std::fs::write(
&tmp,
r#"{"command":"run","success":true,"stdout":"<script>alert(1)</script>","stderr":"<img src=x onerror=alert(2)>","trace":[],"value":{"type":"int","decimal":"3"}}"#,
)
.unwrap();
let server = start_server_with(
"examples/control-flow",
"tests/golden/analysis-v2/control-flow.json",
Some(tmp.to_str().unwrap()),
Some("tests/golden/trace-v2/control-flow.trace.json"),
);
let (_, page) = run_and_get_page(&server);
assert!(page.contains("&lt;script&gt;alert(1)&lt;/script&gt;"));
assert!(!page.contains("<script>alert(1)"));
assert!(!page.contains("onerror=\""));
assert!(!page.contains("<img src=x"));
let _ = std::fs::remove_file(&tmp);
}
#[test]
fn cli_verify_output_contract_still_holds_for_installed_style_invocation() {
// Regression guard: `view verify` must remain a pure static check.
+154
View File
@@ -0,0 +1,154 @@
//! Degradation/state matrix contract (RFC-VIEW-0001 S-05..S-07, §12.3):
//! prose stays readable while semantics become explicitly unusable.
mod common;
use common::{minimal_analysis, sha256_hex, FakeCore, TempProject};
use marqdo_view::app::AppContext;
use marqdo_view::presentation::SourceStatus;
fn project(name: &str) -> (TempProject, FakeCore) {
let project = TempProject::new(name);
project.marqdo_project("# @knowledge 标题\n\n正文 **加粗**,包含 `n`。\n");
let core = FakeCore::new(&format!("{name}-core"));
(project, core)
}
#[test]
fn failed_check_keeps_prose_and_shows_core_diagnostics() {
let (project, core) = project("state-check-fail");
let source = std::fs::read(project.path("index.mq.md")).unwrap();
// Emit a broken analysis too; it must NOT be used after a failed check.
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 2));
core.set_check(1, "");
core.set_check_json(
r#"{"command":"check","success":false,"errors":1,"diagnostics":[{"code":"sem.unclosed_control","column":1,"file":"/home/secret/index.mq.md","line":3,"message":"`if` is not closed by `end`","module":"root:fixture@0.1.0::index.mq.md","severity":"error"}]}"#,
);
let context = AppContext::open(&project.dir, Some(&core.script)).unwrap();
let relative = context.project().entry().relative.clone();
let model = context.load(&relative).unwrap();
assert_eq!(model.source_status, SourceStatus::CoreError);
assert!(
model.semantic.is_none(),
"failed check must revoke semantics"
);
assert!(model.document.plain_text().contains("正文"));
assert!(model
.diagnostics
.iter()
.any(|diagnostic| diagnostic.code == "sem.unclosed_control"));
assert!(!model.source_status.semantics_usable());
// Pending run state is explicit, never a success claim.
assert_eq!(model.run_state().data_value(), "not-run");
}
#[test]
fn source_digest_mismatch_degrades_instead_of_misbinding() {
let (project, core) = project("state-source-mismatch");
core.set_analysis(&minimal_analysis("index.mq.md", &"0".repeat(64), 2));
let context = AppContext::open(&project.dir, Some(&core.script)).unwrap();
let relative = context.project().entry().relative.clone();
let model = context.load(&relative).unwrap();
assert_eq!(model.source_status, SourceStatus::SourceMismatch);
assert!(model.semantic.is_none());
assert!(model.source_status.label().contains("不一致"));
}
#[test]
fn unknown_analysis_schema_is_a_hard_protocol_error() {
let (project, core) = project("state-protocol");
let source = std::fs::read(project.path("index.mq.md")).unwrap();
core.set_analysis(&minimal_analysis("index.mq.md", &sha256_hex(&source), 3));
let context = AppContext::open(&project.dir, Some(&core.script)).unwrap();
let relative = context.project().entry().relative.clone();
let err = context.load(&relative).unwrap_err();
assert_eq!(err.code(), "view.protocol_incompatible");
assert_eq!(err.exit_code(), 2);
}
#[test]
fn invalid_core_span_is_dropped_with_an_explicit_warning() {
let (project, core) = project("state-span-invalid");
let source = std::fs::read(project.path("index.mq.md")).unwrap();
let mut analysis: serde_json::Value =
serde_json::from_str(&minimal_analysis("index.mq.md", &sha256_hex(&source), 2)).unwrap();
// A span in the middle of a multi-byte character / beyond EOF.
analysis["modules"][0]["units"] = serde_json::json!([{
"id": "x", "name": "坏", "level": 1, "kind": "namespace", "function": null,
"span": {"start": 0, "end": 999_999}
}]);
core.set_analysis(&serde_json::to_string(&analysis).unwrap());
let context = AppContext::open(&project.dir, Some(&core.script)).unwrap();
let relative = context.project().entry().relative.clone();
let model = context.load(&relative).unwrap();
assert_eq!(model.source_status, SourceStatus::StaticOk);
assert!(model.semantic.as_ref().unwrap().units.is_empty());
assert!(model
.warnings
.iter()
.any(|warning| warning.code == "view.source_span_invalid"));
let _ = source;
}
#[test]
fn run_attached_to_changed_source_becomes_stale() {
let repo_root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let project = TempProject::new("state-stale-run");
project.write(
"marqdo.yaml",
"project:\n name: control-flow\n version: 0.1.0\n",
);
let source =
std::fs::read_to_string(repo_root.join("examples/control-flow/index.mq.md")).unwrap();
project.write("index.mq.md", &source);
let core = FakeCore::new("state-stale-run-core");
let analysis =
std::fs::read(repo_root.join("tests/golden/analysis-v2/control-flow.json")).unwrap();
core.set_analysis(std::str::from_utf8(&analysis).unwrap());
let context = AppContext::open(&project.dir, Some(&core.script)).unwrap();
let relative = context.project().entry().relative.clone();
// Build a verified run directly from the golden trace + golden analysis.
let source_index = marqdo_view::source_map::SourceIndex::new(&source);
let verified_analysis =
marqdo_view::semantic::verify_analysis(&analysis, &source, &source_index, "index.mq.md")
.unwrap();
let trace =
std::fs::read(repo_root.join("tests/golden/trace-v2/control-flow.trace.json")).unwrap();
let run_json: serde_json::Value = serde_json::from_slice(
&std::fs::read(repo_root.join("tests/golden/trace-v2/control-flow.run.json")).unwrap(),
)
.unwrap();
let run = marqdo_view::trace::verify_trace(marqdo_view::trace::TraceVerificationInput {
trace_bytes: &trace,
analysis_bytes: &analysis,
semantic: &verified_analysis.projection,
modules: &verified_analysis.projection.modules,
source: &source,
source_index: &source_index,
run_json: &run_json,
exit_code: 0,
})
.unwrap();
let attached = context.load_with_run(&relative, Some(&run)).unwrap();
assert_eq!(attached.run_state().data_value(), "succeeded");
// Change the source and rebuild through the same server path.
std::fs::write(
project.path("index.mq.md"),
format!("{source}\n<!-- changed -->\n"),
)
.unwrap();
let changed = context.load_with_run(&relative, Some(&run)).unwrap();
assert!(
changed.run_state().data_value() == "stale"
|| changed.source_status == SourceStatus::SourceMismatch,
"expected stale/source-mismatch, got run={} source={}",
changed.run_state().data_value(),
changed.source_status.data_value()
);
if let Some(run) = &changed.run {
assert!(run.events.iter().all(|event| event.anchor_span.is_none()));
}
let _ = core;
}
+173
View File
@@ -0,0 +1,173 @@
//! Unicode/CRLF/duplicate-text span contract (RFC-VIEW-0001 S-04).
//! Goldens are emitted by the frozen CLI from the exact fixture bytes.
use marqdo_view::document::{DocumentIdentity, DocumentModel};
use marqdo_view::presentation::{self, BuildInput, Navigation, SourceStatus};
use marqdo_view::project::{Project, SafeRelativePath, ViewConfig};
use marqdo_view::render::{ReaderRenderer, RenderContext};
use marqdo_view::semantic;
use marqdo_view::source_map::sha256_hex;
fn repo_root() -> std::path::PathBuf {
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
}
fn load(path: &str, golden: &str) -> (String, Vec<u8>, semantic::VerifiedAnalysis) {
let root = repo_root();
let source = std::fs::read_to_string(root.join(path)).unwrap();
let index = marqdo_view::source_map::SourceIndex::new(&source);
let analysis = std::fs::read(root.join(golden)).unwrap();
let relative = std::path::Path::new(path)
.file_name()
.unwrap()
.to_string_lossy()
.to_string();
let verified = semantic::verify_analysis(&analysis, &source, &index, &relative).unwrap();
(source, analysis, verified)
}
fn render(verified: &semantic::VerifiedAnalysis, source: &str, relative: &str) -> String {
let root = repo_root().join("examples/unicode-spans");
let project = Project::open(&root).unwrap();
let entry = SafeRelativePath::parse(relative).unwrap();
let document = DocumentModel::parse(source.to_string(), DocumentIdentity::placeholder(&entry));
let navigation = Navigation::from_project(&project, &ViewConfig::default(), &entry);
let model = presentation::build(BuildInput {
document,
analysis: Some(verified),
status: SourceStatus::StaticOk,
status_note: None,
diagnostics: Vec::new(),
navigation,
core_version: Some("3.0.0-beta.1".to_string()),
run: None,
});
ReaderRenderer::new()
.render(&model, &RenderContext::live())
.html
}
#[test]
fn unicode_spans_are_exact_and_duplicate_returns_get_distinct_anchors() {
let (source, analysis, verified) = load(
"examples/unicode-spans/index.mq.md",
"tests/golden/analysis-v2/unicode-spans.json",
);
assert_eq!(
verified.projection.source_digest,
sha256_hex(source.as_bytes())
);
let function = &verified.projection.functions[0];
let returns: Vec<_> = function
.flattened_statements()
.into_iter()
.filter(|statement| statement.kind == semantic::StatementKind::Return)
.collect();
assert_eq!(returns.len(), 2);
let first = returns[0].span;
let second = returns[1].span;
assert_ne!(first, second);
let index = marqdo_view::source_map::SourceIndex::new(&source);
// Core statement spans cover the whole carrier node (including markers).
assert_eq!(index.source_text(&source, first), Some("`return 1`"));
assert_eq!(index.source_text(&source, second), Some("`return 1`"));
// The carrier text is identical, so only spans can distinguish the two.
assert_eq!(first.start, source.find("`return 1`").unwrap() as u64);
assert_ne!(first.start, second.start);
let html = render(&verified, &source, "index.mq.md");
let statement_ids: Vec<&str> = html.matches("data-source-id=\"").map(|_| "").collect();
let _ = statement_ids;
// 3 anchored statements: branch header + two returns.
assert_eq!(html.matches("class=\"mq-anchor\"").count(), 3, "{html}");
let ids: Vec<&str> = html
.split("data-source-id=\"")
.skip(1)
.filter_map(|rest| rest.split('"').next())
.collect();
let mut unique = ids.clone();
unique.sort();
unique.dedup();
assert_eq!(ids.len(), unique.len(), "duplicate source ids: {ids:?}");
// Emoji and CJK survive both rendering and source mapping.
assert!(html.contains("中文 🙂 标题"));
assert!(html.contains("甲🙂"));
let _ = analysis;
}
#[test]
fn crlf_source_keeps_exact_digest_and_line_mapping() {
let (source, _analysis, verified) = load(
"examples/unicode-spans/crlf.mq.md",
"tests/golden/analysis-v2/unicode-spans-crlf.json",
);
assert!(source.contains("\r\n"), "fixture must stay CRLF");
assert_eq!(
verified.projection.source_digest,
sha256_hex(source.as_bytes())
);
let index = marqdo_view::source_map::SourceIndex::new(&source);
let function = &verified.projection.functions[0];
for (_, statement) in verified
.projection
.all_statements()
.into_iter()
.filter(|(_, statement)| statement.kind == semantic::StatementKind::Return)
{
assert!(
index
.source_text(&source, statement.span)
.map(|text| text.contains("return"))
.unwrap_or(false),
"span {:?} does not slice a return",
statement.span
);
}
let html = render(&verified, &source, "crlf.mq.md");
assert!(html.contains("CRLF 文档"));
// One list item per source line (SourceIndex counts the trailing line too).
let source_lines = index.line_count();
assert_eq!(html.matches("class=\"mq-line-text\"").count(), source_lines);
let _ = function;
}
#[test]
fn knowledge_emphasis_never_becomes_an_execution_anchor() {
let root = repo_root();
let project = Project::open(&root.join("examples/mixed-modes")).unwrap();
let entry = project.entry().relative.clone();
let source = project.read_source_text(&entry).unwrap();
let index = marqdo_view::source_map::SourceIndex::new(&source);
let analysis = std::fs::read(root.join("tests/golden/analysis-v2/mixed-modes.json")).unwrap();
let verified = semantic::verify_analysis(&analysis, &source, &index, entry.as_str()).unwrap();
assert_eq!(
verified.projection.source_digest,
sha256_hex(source.as_bytes())
);
let document = DocumentModel::parse(source.clone(), DocumentIdentity::placeholder(&entry));
let navigation = Navigation::from_project(&project, &ViewConfig::default(), &entry);
let model = presentation::build(BuildInput {
document,
analysis: Some(&verified),
status: SourceStatus::StaticOk,
status_note: None,
diagnostics: Vec::new(),
navigation,
core_version: Some("3.0.0-beta.1".to_string()),
run: None,
});
let html = ReaderRenderer::new()
.render(&model, &RenderContext::live())
.html;
// Exactly the four Exec statements are anchored (branch + assign + 2 returns).
assert_eq!(html.matches("class=\"mq-anchor\"").count(), 4, "{html}");
let knowledge_bold = "此处加粗是知识内容,不执行。";
let position = html.find(knowledge_bold).expect("knowledge bold text");
let before = &html[..position];
let last_anchor = before.rfind("class=\"mq-anchor\"");
let last_paragraph = before.rfind("<p>");
assert!(
last_anchor.is_none() || last_paragraph > last_anchor,
"knowledge emphasis received an execution anchor"
);
}