Crate tui_markup

Source
Expand description

§tui markup

This crate provides a markup language to quickly write colorful and styled terminal text in plain text.

I suggest to check examples/help.txt, which generated this self-describing syntax help document:

For formal syntax specification, see docs/syntax.ebnf.

§How to use

let output = tui_markup::compile::<Generator>("<bg:blue,green,b hello>").unwrap();

The string wrapped in <>(like the bg:blue,green,b in above example) is called a element, start with a tag list(comma separated), those tags add styles to inner items.

Usable tags are vary depending on the the Generator you use, and generator will ignore all tags it does not understand.

So it’s better checkout their document before write your markup text.

§Builtin generators

The builtin generators are under feature gates:

featureTargetgenerator type
ansiDirect print into stdout when using an asni compatible terminalANSIStringsGenerator
ratatuiIntegrated with the ratatui crateRatatuiTextGenerator
crosstermIntegrated with crossterm crateCrosstermCommandsGenerator

The example screenshot above is using the ratatui generator, print in Windows Terminal.

If you want write your own generator, please checkout documents of Generator trait.

Modules§

generator
Generator generates final output for showing.
parser
Parsing stage of the compilation process.

Enums§

Error
Error for markup source compile pipeline.

Traits§

LocatedError
Error with a location info.

Functions§

compile
Parse markup language source, then generate final output using the default configure of a generator type.
compile_with
Parse markup language source, then generate final output using the provided generator.