1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
//! # Standout Render - Styled Terminal Output Library
//!
//! `standout-render` combines templating, theming, and adaptive color handling so you
//! can ship consistent terminal UI without re-implementing styling utilities.
//! Although it powers the `standout` CLI framework, the crate is fully usable as a
//! stand-alone renderer for any Rust application that needs rich TTY output.
//!
//! ## Core Concepts
//!
//! - [`Theme`]: Named, adaptive styles that automatically respect [`ColorMode`]
//! - [`Renderer`]: Compile and reuse templates for fast repeated rendering
//! - [`validate_template`]: Surface typos or unknown tags before you ship templates
//! - [`OutputMode`]: Control how content is emitted (Auto/Term/Text/TermDebug/Json/Yaml)
//! - Style syntax: Tag-based `[name]content[/name]` markup for inline styling
//!
//! ## Quick Start
//!
//! Create a [`Theme`], pass serializable data, and call [`render`] to produce a styled
//! `String` that you can print, persist, or feed into other systems:
//!
//! ```rust
//! use standout_render::{render, Theme};
//! use console::Style;
//! use serde::Serialize;
//!
//! #[derive(Serialize)]
//! struct Summary {
//! title: String,
//! total: usize,
//! }
//!
//! let theme = Theme::new()
//! .add("title", Style::new().bold())
//! .add("count", Style::new().cyan());
//!
//! let template = r#"
//! [title]{{ title }}[/title]
//! ---------------------------
//! Total items: [count]{{ total }}[/count]
//! "#;
//!
//! let output = render(
//! template,
//! &Summary { title: "Report".into(), total: 3 },
//! &theme,
//! ).unwrap();
//! println!("{}", output);
//! ```
//!
//! ## Tag-Based Styling
//!
//! Templates use lightweight `[name]content[/name]` tags, so you can mix static text
//! and template variables without sprinkling manual `console::Style` calls. The
//! renderer resolves each tag to the appropriate entry in your [`Theme`]:
//!
//! ```rust
//! use standout_render::{render_with_output, Theme, OutputMode};
//! use console::Style;
//! use serde::Serialize;
//!
//! #[derive(Serialize)]
//! struct Data { name: String, count: usize }
//!
//! let theme = Theme::new()
//! .add("title", Style::new().bold())
//! .add("count", Style::new().cyan());
//!
//! let template = r#"[title]Report[/title]: [count]{{ count }}[/count] items by {{ name }}"#;
//!
//! let output = render_with_output(
//! template,
//! &Data { name: "Alice".into(), count: 42 },
//! &theme,
//! OutputMode::Text,
//! ).unwrap();
//!
//! assert_eq!(output, "Report: 42 items by Alice");
//! ```
//!
//! ## Adaptive Themes (Light & Dark)
//!
//! Styles automatically adapt to the current [`ColorMode`]. Provide explicit
//! overrides for light and dark variants, or rely on a shared default when you
//! do not need per-mode differences:
//!
//! ```rust
//! use standout_render::Theme;
//! use console::Style;
//!
//! let theme = Theme::new()
//! // Non-adaptive style (same in all modes)
//! .add("header", Style::new().bold().cyan())
//! // Adaptive style with light/dark variants
//! .add_adaptive(
//! "panel",
//! Style::new(), // Base
//! Some(Style::new().fg(console::Color::Black)), // Light mode
//! Some(Style::new().fg(console::Color::White)), // Dark mode
//! );
//! ```
//!
//! ## CSS-Based Themes
//!
//! Ship themes alongside your application or allow users to bring their own. The
//! [`Theme::from_css`] helper loads named styles (and adaptive overrides) directly
//! from a CSS definition:
//!
//! ```rust
//! use standout_render::Theme;
//!
//! let theme = Theme::from_css(r#"
//! .header { color: cyan; font-weight: bold; }
//! .panel { color: gray; }
//! @media (prefers-color-scheme: light) {
//! .panel { color: black; }
//! }
//! @media (prefers-color-scheme: dark) {
//! .panel { color: white; }
//! }
//! "#).unwrap();
//! ```
//!
//! ## Renderer Example
//!
//! For larger applications, use [`Renderer`] to register templates once and render
//! them repeatedly without reparsing:
//!
//! ```rust
//! use standout_render::{Renderer, Theme};
//! use console::Style;
//! use serde::Serialize;
//!
//! #[derive(Serialize)]
//! struct Entry { label: String, value: i32 }
//!
//! let theme = Theme::new()
//! .add("label", Style::new().bold())
//! .add("value", Style::new().green());
//!
//! let mut renderer = Renderer::new(theme).unwrap();
//! renderer.add_template("row", "[label]{{ label }}[/label]: [value]{{ value }}[/value]").unwrap();
//! let rendered = renderer.render("row", &Entry { label: "Count".into(), value: 42 }).unwrap();
//! assert_eq!(rendered, "Count: 42");
//! ```
// Internal modules
// Error type
pub use RenderError;
// Style module exports (including former stylesheet exports)
pub use ;
// Theme module exports
pub use ;
// Output module exports
pub use ;
// Render module exports
pub use ;
// Re-export BBParser types for template validation
pub use ;
// Utility exports
pub use ;
// File loader exports
pub use ;
// Embedded source types (for macros)
pub use ;