Crates.io | mc-legacy-formatting |
lib.rs | mc-legacy-formatting |
version | 0.3.1 |
source | src |
created_at | 2020-10-20 03:10:51.988501 |
updated_at | 2020-11-20 03:46:59.306297 |
description | A non-allocating parser for Minecraft's legacy formatting system |
homepage | |
repository | https://github.com/Cldfire/mc-legacy-formatting |
max_upload_size | |
id | 303276 |
size | 78,154 |
A parser for Minecraft's legacy formatting system, created with careful attention to the quirks of the vanilla client's implementation.
#![no_std]
usage (with default-features
set to false
)STRIKETHROUGH
style)Span
s to the terminal§
while many community tools use &
)Using SpanIter
:
use mc_legacy_formatting::{SpanExt, Span, Color, Styles};
let s = "§4This will be dark red §oand italic";
let mut span_iter = s.span_iter();
assert_eq!(span_iter.next().unwrap(), Span::new_styled("This will be dark red ", Color::DarkRed, Styles::empty()));
assert_eq!(span_iter.next().unwrap(), Span::new_styled("and italic", Color::DarkRed, Styles::ITALIC));
assert!(span_iter.next().is_none());
With a custom start character:
use mc_legacy_formatting::{SpanExt, Span, Color, Styles};
let s = "&6It's a lot easier to type &b& &6than &b§";
let mut span_iter = s.span_iter().with_start_char('&');
assert_eq!(span_iter.next().unwrap(), Span::new_styled("It's a lot easier to type ", Color::Gold, Styles::empty()));
assert_eq!(span_iter.next().unwrap(), Span::new_styled("& ", Color::Aqua, Styles::empty()));
assert_eq!(span_iter.next().unwrap(), Span::new_styled("than ", Color::Gold, Styles::empty()));
assert_eq!(span_iter.next().unwrap(), Span::new_styled("§", Color::Aqua, Styles::empty()));
assert!(span_iter.next().is_none());
The Minimum Supported Rust Version is currently 1.48.0. This will be bumped to the latest stable version of Rust when needed.