10 releases

0.2.11 Oct 22, 2024
0.2.9 Sep 17, 2024
0.2.5 Jun 10, 2024
0.2.2 May 21, 2024
0.1.0 Apr 20, 2024

#597 in Parser implementations

Download history 2/week @ 2024-07-24 6/week @ 2024-07-31 151/week @ 2024-09-04 287/week @ 2024-09-11 112/week @ 2024-09-18 32/week @ 2024-09-25 10/week @ 2024-10-02 13/week @ 2024-10-09 105/week @ 2024-10-16 56/week @ 2024-10-23 12/week @ 2024-10-30 14/week @ 2024-11-06

189 downloads per month
Used in 2 crates

MIT license

235KB
2K SLoC

Parse ansi strings and convert them to html and svg formats

install

It is recommended to use npm, it will compress svg using svgo

npm i ansi2 -g
cargo binstall ansi2
cargo install ansi2 --features="cli"

usage

neofetch | ansi2 > ./neofetch.svg
neofetch | ansi2 --format=svg --theme=vscode > neofetch.svg

vitest bench --run | ansi2 --format=html --mode=light > bench.html
vitest bench --run | ansi2 --format=text > bench.txt
vitest bench --run | ansi2 --format=svg --mode=dark  | resvg - -c > bench.png

ansi2

use ansi2::{Canvas};

let canvas = Canvas::new(s);
for row in canvas.pixels.iter() {
  for pixel in row.iter() {
      // draw pixel
  }
}

ansi2-wasm

npm i ansi2 -g

neofetch | ansi2 > ./neofetch.svg
neofetch | ansi2 --format=svg --theme=vscode > neofetch.svg

options

format

neofetch | ansi2 --format=html > neofetch.html
neofetch | ansi2 --format=svg > neofetch.svg

theme

vga / vscode / ubuntu

neofetch | ansi2 --format=svg --theme=vscode > neofetch.svg

font

neofetch | ansi2 --format=svg --font=./font.ttf > neofetch.svg

mode

dark / light

neofetch | ansi2 --format=svg --mode=dark > neofetch.svg

example

neofetch

vitest

Dependencies

~1.2–3MB
~63K SLoC