Skip to main content

cascivo_html/
lib.rs

1//! Renders agent-written `.cv` text into one deterministic, self-contained cascivo HTML file.
2//!
3//! The library has no dependencies and does no file I/O: pass images and brand files through
4//! [`Options`]. The `cascivo-html` CLI (crate `cascivo-html-cli`) wires files for you.
5//!
6//! ```
7//! use cascivo_html::{render, Options};
8//!
9//! let html = render("@title \"Hi\"\ncard \"Hello\"\n", &Options::default()).unwrap();
10//! assert!(html.starts_with("<!doctype html>") || html.contains("<html"));
11//! assert!(html.contains("Hello"));
12//! ```
13//!
14//! [`GUIDE`] and [`guide_for`] return the agent cheat sheet. Full guide:
15//! <https://cascivo.com/docs/guides/using-cascivo-html>.
16
17pub mod asset;
18pub mod ast;
19pub mod brand;
20pub mod catalog;
21mod catalog_gen;
22mod css_gen;
23pub mod diag;
24pub mod emit;
25pub mod guide;
26mod guide_gen;
27pub mod html;
28mod lex;
29mod parse;
30pub mod path;
31pub mod render;
32
33pub use ast::{BrandItem, Directive, Doc, Node, Value};
34pub use brand::{Brand, parse_brand_file};
35pub use catalog::{
36    ArgKind, ArgSpec, Children, ClientJs, CompSpec, PropKind, PropSpec, lookup, suggest,
37};
38pub use diag::Diagnostic;
39pub use guide::{GUIDE, guide_for};
40pub use parse::parse;
41pub use render::{
42    AssetResolver, BrandResolver, Cx, Fragment, Options, render, render_fragment, render_parts,
43    script, stylesheet,
44};
45
46/// Parse-only validation: every diagnostic in `src`, empty when it is valid.
47/// Brand files need a resolver, so they are checked by `render` instead.
48pub fn check(src: &str) -> Vec<Diagnostic> {
49    parse(src).err().unwrap_or_default()
50}