text-tags
A lightweight Rust crate for parsing text-tags.
Features
- Uniform tag syntax:
[tag arg1 arg2=val2 ...]content[/tag] - Implicit first argument: The first value (e.g. font name, hex color, atlas index) may be written without a key.
- Named arguments: Any additional arguments use
key=valueform. - Strong types: Supports ints, floats, bools, hex colors, keywords, and quoted strings.
- Nested tags: Tags can wrap content and nest arbitrarily.
Syntax Overview
Basic tags
[b]Bold text[/b]
[i]Italic text[/i]
Implicit first argument
- Example Font:
[font Arial size=24]Text[/font]->fontname is"Arial" - Example Color:
[color #ff00aa a=0.8]Colored[/color]-> hex#ff00aa, alpha0.8 - Example Sprite:
[sprite 3 index=5]-> atlas3,index=5
Named arguments
[font name="Comic Sans" size=20 weight=700]
[color r=1.0 g=0.2 b=0.2]
Argument types
- Int:
val=42 - Float:
pi=3.14 - Bool:
enabled=true - Hex:
color=#aabbcc - Keyword:
mode=wrap - String:
label="Hello World"
Examples
This is [font Arial size=18]rendered[/font] with [color #00ff00]green[/color] text,
and an icon: [sprite atlas=1 index=2].
Usage
in Cargo.toml:
[]
= "0.1.0"