#minecraft #ping #server #color #code

no-std mc-legacy-formatting

A non-allocating parser for Minecraft's legacy formatting system

6 releases

0.3.1 Nov 20, 2020
0.3.0 Nov 20, 2020
0.2.0 Oct 20, 2020
0.1.2 Oct 20, 2020

#1129 in Parser implementations

Download history 32/week @ 2023-02-16 8/week @ 2023-02-23 10/week @ 2023-03-02 14/week @ 2023-03-09 21/week @ 2023-03-16 7/week @ 2023-03-23 7/week @ 2023-03-30 23/week @ 2023-04-06 11/week @ 2023-04-13 3/week @ 2023-04-20 15/week @ 2023-04-27 20/week @ 2023-05-04 17/week @ 2023-05-11 18/week @ 2023-05-18 22/week @ 2023-05-25 24/week @ 2023-06-01

87 downloads per month
Used in 2 crates


438 lines


Docs.rs docs Crates.io version Crates.io downloads CI

A parser for Minecraft's legacy formatting system, created with careful attention to the quirks of the vanilla client's implementation.


  • Iterator-based, non-allocating parser
  • Supports #![no_std] usage (with default-features set to false)
  • Implements the entire spec as well as vanilla client quirks (such as handling of whitespace with the STRIKETHROUGH style)
  • Helpers for pretty-printing the parsed Spans to the terminal
  • Support for parsing any start character for the formatting codes (vanilla uses § 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));

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()));


The Minimum Supported Rust Version is currently 1.48.0. This will be bumped to the latest stable version of Rust when needed.


Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.