mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Add a bounded Mermaid text renderer (#45817)
## What changed Add `codex-mermaid`, a standalone crate that renders supported subsets of flowchart, sequence, state, class, and ER diagrams as Unicode text. Expose `render` for plain text and `render_spans` for semantic node, edge, and text spans that callers can style. Enforce source, diagram, canvas, and display-width limits. Return errors for unsupported input or exceeded limits without producing partial diagrams, leaving source fallback to callers. Include documentation and a stdin rendering example. ## Testing Add snapshots for each diagram family, checks for relationship endpoints, Unicode labels, semantic spans, truncated input, and size limits, plus edge reconstruction for all 512 directed three-node graphs in all four layout directions. GitOrigin-RevId: 5b4e65d9152abce5d833e4e6b12113a5a21f700e
This commit is contained in:
1 parent
7f501cd334
commit
7c709f0ffd
21 files changed
+2259
No files matched your search
@@ -0,0 +1,17 @@
|
||||
//! Render a diagram from standard input for manual prototype evaluation.
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut source = String::new();
|
||||
std::io::stdin()
|
||||
.take(16 * 1024 + 1)
|
||||
.read_to_string(&mut source)?;
|
||||
let max_width = std::env::args()
|
||||
.nth(1)
|
||||
.map(|value| value.parse())
|
||||
.transpose()?
|
||||
.unwrap_or(120);
|
||||
println!("{}", codex_mermaid::render(&source, max_width)?);
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user