A simple markup language for styled text in terminal
I'm writing a terminal-based game recently, I found I need a guide page to introduce the keyboard binding to users.
I want it looks beautiful and easy to change and maintain, so I create a markup language to write it in plain text.
It's a simple markup language, that uses <style-tags text> element to add a style to the text.
Usage
// Parse markup into some final result for showing
let result = compile::<ANSIStringsGenerator>("You got a <yellow Coin>").unwrap();
// Show it
println!("{}", ANSIStrings(&result));
Syntax
- Normal:
<red Sun>to show "Sun" in red text. - Multi-tags:
<bg:blue,green,b text>to show a green bold "text" in a blue background. - Nested:
<bg:white <black Got 3> <yellow Coin>>, it creates a white background black color "Got 3" followed by a white background yellow color "Coin". - Custom: It also supports custom tags, you can define a style for a tag, e.g.
keyboard, first and then use it like this:Press <keyboard Space> to jump.
It's very useful for me, but I don't know if it's a common need.