| Crates.io | semantic-dom-ssg |
| lib.rs | semantic-dom-ssg |
| version | 0.2.0 |
| created_at | 2026-01-16 18:16:50.699328+00 |
| updated_at | 2026-01-16 20:45:36.707039+00 |
| description | Machine-readable web semantics for AI agents. O(1) lookup, deterministic navigation, token-efficient serialization. |
| homepage | |
| repository | https://github.com/gorgalxandr/semantic-dom-ssg |
| max_upload_size | |
| id | 2049075 |
| size | 126,422 |
Machine-readable web semantics for AI agents.
O(1) element lookup, deterministic navigation, and token-efficient serialization optimized for LLM consumption.
AHashMap for constant-time element accessuse semantic_dom_ssg::{SemanticDOM, Config};
let html = r#"
<html>
<body>
<nav><a href="/">Home</a></nav>
<main><button>Submit</button></main>
</body>
</html>
"#;
let sdom = SemanticDOM::parse(html, Config::default()).unwrap();
// O(1) lookup by iterating index
for (id, node) in &sdom.index {
println!("{}: {:?} - {}", id, node.role, node.label);
}
// Token-efficient summary (~100 tokens)
let summary = sdom.to_agent_summary();
println!("{}", summary);
Add to your Cargo.toml:
[dependencies]
semantic-dom-ssg = "0.2"
# Install CLI
cargo install semantic-dom-ssg
# Parse HTML to JSON
semantic-dom parse input.html --format json
# Token-efficient summary
semantic-dom parse input.html --format summary
# One-line summary (~20 tokens)
semantic-dom parse input.html --format oneline
# Validate for agent compatibility
semantic-dom validate input.html --level aa --ci
# Compare token usage
semantic-dom tokens input.html
{
"title": "My Page",
"landmarks": ["sdom_nav_1", "sdom_main_1"],
"interactables": ["sdom_a_1", "sdom_button_1"],
"nodes": { ... }
}
PAGE: My Page
LANDMARKS: nav(nav), main(main)
ACTIONS: [nav]Home, [act]Submit
STATE: initial -> Home
STATS: 2L 2A 0H
My Page | 2L 2A | nav,main | lnk:Home,btn:Submit
This crate implements security hardening per ISO/IEC-SDOM-SSG-DRAFT-2024:
https, http, file protocols allowedjavascript:, data:, vbscript:, blob: blockeduse semantic_dom_ssg::validate_url;
assert!(validate_url("https://example.com").is_ok());
assert!(validate_url("javascript:alert(1)").is_err());
Validate HTML documents for AI agent compatibility:
use semantic_dom_ssg::{SemanticDOM, Config, AgentCertification};
let sdom = SemanticDOM::parse(html, Config::default()).unwrap();
let cert = AgentCertification::certify(&sdom);
println!("{} Level: {} (Score: {})",
cert.level.badge(),
cert.level.name(),
cert.score
);
| Level | Badge | Requirements |
|---|---|---|
| AAA | 🥇 | Score 90+ (full compliance) |
| AA | 🥈 | Score 70-89 (deterministic FSM) |
| A | 🥉 | Score 50-69 (basic compliance) |
| None | ❌ | Score < 50 |
Benchmarks on standard HTML documents:
| Operation | Time |
|---|---|
| Parse (10KB) | ~500μs |
| Parse (100KB) | ~5ms |
| O(1) Lookup | ~10ns |
| Agent Summary | ~50μs |
Implements ISO/IEC-SDOM-SSG-DRAFT-2024 specification for:
MIT License - see LICENSE for details.
George Alexander info@gorgalxandr.com