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
//! Style registry macros.
//!
//! [`style!`] registers a named style in the global registry. [`prefix!`] attaches
//! a literal prefix string to an already-registered style. Both require the `format` feature.
/// Defines a named style in the global registry.
///
/// Parses `$markup` as a farben markup string and stores the resulting style
/// under `$name`. The style can then be used in markup as `[$name]`.
/// Panics if the markup is invalid.
///
/// # Examples
///
/// ```
/// use farben::prelude::*;
///
/// style!("danger", "[bold red]");
/// // [danger] in markup now expands to bold red text
/// ```
/// Sets a prefix string on a previously defined named style.
///
/// The prefix is injected as a literal string before the style's ANSI escape sequence
/// when rendered. The style must already exist in the registry; call [`style!`] first.
///
/// # Panics
///
/// Panics if `$name` has not been registered. Use [`farben_core::registry::set_prefix`]
/// directly to handle this case without panicking.
///
/// # Examples
///
/// ```
/// use farben::prelude::*;
///
/// style!("warn", "[yellow]");
/// prefix!("warn", "⚠ ");
/// // [warn] now renders "⚠ " followed by the yellow escape sequence
/// ```