https://github.com/phoenixr-codes/syntect_minecraft_highlighting
Highlight code with Minecraft formatting
https://github.com/phoenixr-codes/syntect_minecraft_highlighting
bedrock-edition highlighting java-edition minecraft syntect
Last synced: 18 days ago
JSON representation
Highlight code with Minecraft formatting
- Host: GitHub
- URL: https://github.com/phoenixr-codes/syntect_minecraft_highlighting
- Owner: phoenixr-codes
- License: unlicense
- Created: 2024-11-04T21:23:26.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-26T14:06:09.000Z (about 1 year ago)
- Last Synced: 2025-09-20T21:05:51.579Z (4 months ago)
- Topics: bedrock-edition, highlighting, java-edition, minecraft, syntect
- Language: Rust
- Homepage: https://crates.io/crates/syntect_minecraft_highlighting
- Size: 88.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# syntect Minecraft Highlighting
This crate contains a function for highlighting styled fragments created by [syntect][] with
[Minecraft Formatting][].

## Example
```rust
use syntect::easy::HighlightLines;
use syntect::highlighting::{Style, ThemeSet};
use syntect::parsing::SyntaxSet;
use syntect::util::LinesWithEndings;
use syntect_minecraft_highlighting::as_minecraft_bedrock_escaped;
fn main() {
let ps = SyntaxSet::load_defaults_newlines();
let ts = ThemeSet::load_defaults();
let syntax = ps.find_syntax_by_extension("rs").unwrap();
let s = "pub struct Wow { hi: u64 }\nfn blah() -> u64 { 42 }\n";
let mut h = HighlightLines::new(syntax, &ts.themes["base16-ocean.light"]);
for line in LinesWithEndings::from(s) {
let ranges: Vec<(Style, &str)> = h.highlight_line(line, &ps).unwrap();
let escaped = as_minecraft_bedrock_escaped(&ranges[..]);
println!("{}", escaped);
}
}
```
[Minecraft Formatting]: https://minecraft.wiki/w/Formatting_codes
[syntect]: https://github.com/trishume/syntect