text-tags

Crates.iotext-tags
lib.rstext-tags
version0.1.0
created_at2025-07-13 18:04:18.051877+00
updated_at2025-07-13 18:04:18.051877+00
descriptionA lightweight, text-tag markup parser
homepage
repositoryhttps://github.com/swamp/swamp
max_upload_size
id1750671
size14,949
Peter Bjorklund (piot)

documentation

README

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=value form.
  • 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] -> font name is "Arial"
  • Example Color: [color #ff00aa a=0.8]Colored[/color] -> hex #ff00aa, alpha 0.8
  • Example Sprite: [sprite 3 index=5] -> atlas 3, 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:

[dependencies]
text-tags = "0.1.0"
Commit count: 802

cargo fmt