Crates.io | tui-markup-ansi-macro |
lib.rs | tui-markup-ansi-macro |
version | 0.1.0 |
source | src |
created_at | 2022-08-23 13:12:36.393215 |
updated_at | 2022-08-23 13:12:36.393215 |
description | a macro to generate styled ansi escape sequence from markup language |
homepage | https://github.com/7sDream/tui-markup-ansi-macro |
repository | https://github.com/7sDream/tui-markup-ansi-macro |
max_upload_size | |
id | 650979 |
size | 11,708 |
This create provided a macro to generated terminal styled text in ANSI escape sequence format using a markup language.
This macro compile your source at compile time, so it has no runtime overhead.
use tui_markup_ansi_macro::ansi;
let generated = ansi!("Press <blue Space> to <cyan Jump> over the <bg:yellow,i fox>");
let hardcode = "Press \u{001b}[34mSpace\u{001b}[0m to \u{001b}[36mJump\u{001b}[0m over the \u{001b}[3;43mfox\u{001b}[0m";
// Those two are equivalent.
assert_eq!(generated, hardcode);
// Use custom tag
let generated = ansi!(
"Press <keyboard Space> to <action Jump> over the <enemy fox>",
"keyboard" => "blue",
"action" => "cyan",
"enemy" => "bg:yellow,i",
);
assert_eq!(generated, hardcode);
println!("{}", generated);
Output:
The markup language used here is my tui markup language, See it's documentation for full syntax and supported style tags.
BSD-3-Clause-Clear, see LICENSE.