相对路径无效,已进入纯文本阅读模式。
\n" + ); + } + } + html.push_str("WELCOME TO
+代码即文档 · 文档即知识库 · 知识即可执行
+{note}
\n", + note = escape_text(note) + ); + } + } + + fn render_diagnostics(&self, html: &mut String, model: &PresentationModel) { + let mut items: Vec<(&str, &str, Option相对路径无效,已进入纯文本阅读模式。
\n" + ); + } + } + html.push_str(""); + render_inlines(html, content, model, ctx, current, assets); + html.push_str("
\n"); + } + DocBlock::List { + ordered, + start, + tight: _, + items, + .. + } => { + if *ordered { + match start { + Some(start) if *start != 1 => { + let _ = write!(html, "\n"); + render_blocks(html, children, model, ctx, current, assets); + html.push_str("\n"); + } + DocBlock::CodeBlock { + span, + info, + literal, + } => { + let resource = model + .semantic + .as_ref() + .and_then(|projection| projection.resource_for_span(*span)); + let language = info.split_whitespace().next().unwrap_or(""); + let _ = write!( + html, + "
{}| ", align_attr(align)); + render_inlines(html, cell, model, ctx, current, assets); + html.push_str(" | "); + } + html.push_str("
|---|
| ", align_attr(align)); + render_inlines(html, cell, model, ctx, current, assets); + html.push_str(" | "); + } + html.push_str("
{}公式原文 · 未渲染数学');
+ html.push_str(&escape_text(literal));
+ html.push_str("");
+ }
+ Inline::Strong { span, children } => {
+ let anchor = projection.and_then(|projection| projection.statement_for_inline(*span));
+ html.push_str("');
+ render_inlines(html, children, model, ctx, current, assets_placeholder());
+ html.push_str("");
+ }
+ Inline::Emph { span, children } => {
+ let anchor = projection.and_then(|projection| projection.statement_for_inline(*span));
+ html.push_str("');
+ render_inlines(html, children, model, ctx, current, assets_placeholder());
+ html.push_str("");
+ }
+ Inline::Strikethrough { children, .. } => {
+ html.push_str("{code}
{message}
", + code = escape_html(err.code()), + message = escape_html(&err.to_string()), + ); + respond_html(request, html.into_bytes(), is_head) +} + +fn serve_document_json(request: Request, model: &PresentationModel) -> ViewResult<()> { + let semantic = model.semantic.as_ref(); + let doc = serde_json::json!({ + "schema": "marqdo.view-document", + "schema_version": 1, + "title": model.title, + "document": { + "relative_path": model.document.identity.relative_path, + "module_id": model.document.identity.module_id, + "source_sha256": sha256_hex(model.document.source.as_bytes()), + }, + "source_status": model.source_status.data_value(), + "semantics_usable": model.source_status.semantics_usable(), + "analysis": semantic.map(|projection| serde_json::json!({ + "digest": projection.analysis_digest, + "schema_version": crate::version::ANALYSIS_PROTOCOL, + "producer_version": projection.producer_version, + "project_root_id": projection.project_root_id, + "functions": projection.functions.len(), + "units": projection.units.len(), + "diagnostics": projection.diagnostics.len(), + })), + "outline": model.outline.iter().map(|entry| serde_json::json!({ + "label": entry.label, + "anchor": entry.anchor, + "detail": entry.detail, + "kind": match entry.kind { + crate::presentation::OutlineKind::Function => "function", + crate::presentation::OutlineKind::Knowledge => "knowledge", + crate::presentation::OutlineKind::Section => "section", + }, + })).collect::