API overview
SevenMark separates syntax parsing, document transformation, HTML rendering, and editor tooling. The host application owns persistence and authorization.
Crates
| Crate | Purpose | Target |
|---|---|---|
sevenmark_ast | AST types, document references, and traversal | Native/WASM |
sevenmark_spec | Shared syntax and parameter specifications | Native/WASM |
sevenmark_parser | Source text to SyntaxDocument | Native/WASM |
sevenmark_formatter | SevenMark source formatting | Native/WASM |
sevenmark_html | Processed AST to sanitized HTML and scoped CSS | Native |
sevenmark_utils | Shared text and position utilities | Native/WASM |
sevenmark_wasm | WASM parser bindings | WASM |
sevenmark_wasm_lsp | WASM LSP bindings | WASM |
sevenmark_wasm_formatter | WASM formatter bindings | WASM |
sevenmark_transform | Semantic processing and approved reference resolution | Native |
sevenmark_lsp_core | LSP methods without a transport or network client | Native/WASM |
sevenmark_language_server | Native LSP stdio transport | Native |
sevenmark_server | Approved-input HTTP API | Native |
Document processing
sevenmark_parserparses source into aSyntaxDocument.sevenmark_transformevaluates local variables and conditionals, then expands approved includes.sevenmark_transformapplies approved reference decisions to produce aRenderDocument.sevenmark_htmlrenders the processed AST as sanitized HTML and scoped CSS.sevenmark_serverreturns the HTML and document metadata in its HTTP response.
The host supplies approved source revisions and current reference decisions. The renderer does not acquire database, storage, session, or policy authority. Before delivery, the host rechecks access to the root and each used dependency.
Parser and AST
sevenmark_parser::parse_document(&str) returns a SyntaxDocument. It retains the original source byte length and the parsed Element nodes. The AST crate provides element types, visitors, and the shared DocumentReference enum.
Enable include_locations to serialize source positions. Native AST spans use UTF-8 byte offsets. sevenmark_utils::convert_ast_to_utf16_offset_json() converts those spans to absolute UTF-16 code unit offsets for editors.
See Parser API, AST structure, and document reference syntax.
WASM bindings
The parser wrapper exposes two functions:
parse_sevenmark(input)returns AST JSON with UTF-8 byte offsets.parse_sevenmark_to_codemirror(input)returns AST JSON with UTF-16 offsets.
The LSP wrapper exposes handle_lsp_message(json). It processes JSON-RPC messages and returns responses and notifications. Native and WASM transports use sevenmark_lsp_core for diagnostics, semantic tokens, completion, hover, and other language features.
For document references, the host supplies authorized candidates. The LSP formats exact-range UUID edits and returns parsed reference ranges. It does not fetch candidates or resolve access. See the document reference LSP contract.
Transform boundary
sevenmark_transform separates syntax from request-local semantic processing. Its result types mark each stage: SyntaxDocument, SemanticDocument, and RenderDocument with a RenderAst.
The transform requests approved data through the WikiResolver port. Its production dependencies do not include a database driver, object-storage SDK, HTTP/OpenAPI types, or the parser. The caller supplies parsed source and a resolver implementation.
HTTP service
sevenmark_server exposes these routes:
| Route | Purpose |
|---|---|
POST /v1/analyze | Analyze references, mentions, external links and a link preview in host source |
POST /v1/analyze-bundle | Analyze references after approved include expansion |
POST /v1/render | Render an approved source bundle |
GET /health/live | Check whether the service is running |
GET /health/ready | Check whether the service accepts work |
The HTTP routes use /v1. Payloads use contract_version: 8. The service bounds source bytes, include expansion, response bytes, CPU concurrency, and elapsed request time. See the renderer wire contract.
Browser runtime
The independent browser runtime hydrates sanitized renderer output. The host supplies routing, locale, theme, and authorized data adapters.