#markup #css #ansi #color #terminal #css-color

colored_markup

A library for parsing and rendering colored markup with CSS style rules

1 unstable release

0.1.1 Aug 13, 2023
0.1.0 Aug 12, 2023

#2257 in Parser implementations

21 downloads per month

Custom license

25KB
565 lines

colored_markup

A rust library for parsing and rendering coloured markup with CSS style rules.

Usage

use colored_markup::{println_markup, StyleSheet};

let style_sheet =
    StyleSheet::parse("red { foreground: bright-red; styles: underline }").unwrap();
println_markup!(&style_sheet, "The next word is <red>{}</red>", "red");

See examples for more.

License

MIT. See LICENSE.txt for details.

TODO

  • RGB colour codes in CSS.
  • Better CSS parsing error handling.
  • Allow changing markup characters.
  • CLI tool.
  • Better documentation.
  • Get rid of re-exports?

lib.rs:

colored_markup is a library for rendering HTML-like markup with ANSI escape codes using CSS-like stylesheets.

 use colored_markup::{println_markup, StyleSheet};

 fn main() {
     let style_sheet =
         StyleSheet::parse("red { foreground: bright-red; styles: underline }").unwrap();
     println_markup!(&style_sheet, "The next word is <red>{}</red>", "red");
 }

Dependencies

~3–14MB
~129K SLoC