All Projects → wader → ansisvg

wader / ansisvg

Licence: MIT license
Convert ANSI to SVG

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to ansisvg

django-concurrency-talk
🎭 Database Integrity in Django: Safely Handling Critical Data in Distributed Systems
Stars: ✭ 49 (+19.51%)
Mutual labels:  ansi
log-utils
Basic logging utils: colors, symbols and timestamp.
Stars: ✭ 24 (-41.46%)
Mutual labels:  ansi
ansi-to-svg
😹 convert ANSI Escaped CLI strings to SVGs
Stars: ✭ 18 (-56.1%)
Mutual labels:  ansi
strip-ansi-stream
Strip ANSI escape codes
Stars: ✭ 32 (-21.95%)
Mutual labels:  ansi
leeks.js
Simple ANSI styling for your terminal
Stars: ✭ 12 (-70.73%)
Mutual labels:  ansi
ansicolor
A JavaScript ANSI color/style management. ANSI parsing. ANSI to CSS. Small, clean, no dependencies.
Stars: ✭ 91 (+121.95%)
Mutual labels:  ansi
kotter
A declarative, Kotlin-idiomatic API for writing dynamic console applications.
Stars: ✭ 355 (+765.85%)
Mutual labels:  ansi
edi-json
Serializing EDI as JSON
Stars: ✭ 73 (+78.05%)
Mutual labels:  ansi
yachalk
🖍️ Terminal string styling done right
Stars: ✭ 131 (+219.51%)
Mutual labels:  ansi
ansi-php
ANSI Control Functions and ANSI Control Sequences (Colors, Erasing, etc.) for PHP CLI Apps
Stars: ✭ 82 (+100%)
Mutual labels:  ansi
spinner
Progress indicators for command line Clojure apps, including support for indeterminate and determinate tasks.
Stars: ✭ 32 (-21.95%)
Mutual labels:  ansi
go-color
A lightweight, simple and cross-platform package to colorize text in terminals
Stars: ✭ 65 (+58.54%)
Mutual labels:  ansi
paper-terminal
Print Markdown to a paper in your terminal
Stars: ✭ 33 (-19.51%)
Mutual labels:  ansi
strings-ansi
Handle ANSI escape codes in strings
Stars: ✭ 17 (-58.54%)
Mutual labels:  ansi
ansiart2utf8
Processes legacy BBS-style ANSI art (ACiDDraw, PabloDraw, etc.) to UTF-8. Escape codes and line endings are processed for terminal friendliness.
Stars: ✭ 32 (-21.95%)
Mutual labels:  ansi
ckwin
C-Kermit for Windows - scriptable internet and serial communications with terminal emulation
Stars: ✭ 35 (-14.63%)
Mutual labels:  ansi
pytermgui
Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
Stars: ✭ 1,270 (+2997.56%)
Mutual labels:  ansi
kolorist
A tiny utility to colorize stdin/stdout
Stars: ✭ 160 (+290.24%)
Mutual labels:  ansi
p8-programming-fonts
A collection of fonts I've modified for PICO-8 programming.
Stars: ✭ 67 (+63.41%)
Mutual labels:  ansi
concolor
Colouring template strings using tags with annotations 🎨
Stars: ✭ 35 (-14.63%)
Mutual labels:  ansi

ansisvg

Convert ANSI to SVG.

Pipe output from a program thru ansisvg and it will output a SVG file on stdout.

Can be used to produce nice looking example output for presentations, markdown files etc. Note that it does not support programs that do cursor movements like ncurses programs etc.

./colortest | ansisvg > colortest.ansi.svg

Produces colortest.ansi.svg:

ansisvg output for colortest

$ ansisvg -h
Usage of ansisvg:
  -charboxsize value
    	Character box size (default 8x16)
  -colorscheme string
    	Color scheme (default "Builtin Dark")
  -fontname string
    	Font name
  -fontsize int
    	Font size (default 14)
  -transparent
    	Transparent background
  -width int
    	Terminal width (auto)

Color themes are the ones from https://github.com/mbadolato/iTerm2-Color-Schemes

Install

To build you will need at least go 1.16 or later.

Install latest master and copy it to /usr/local/bin:

go install github.com/wader/ansisvg@master
cp $(go env GOPATH)/bin/ansisvg /usr/local/bin

Development

Build from cloned repo:

go build -o ansisvg main.go

Tricks

ANSI to PDF or PNG

... | ansisvg | inkscape --pipe --export-type=pdf -o file.pdf
... | ansisvg | inkscape --pipe --export-type=png -o file.png

Use bat to produce source code highlighting

bat --color=always -p main.go | ansisvg

Use script to run with a pty

script -q /dev/null <command> | ansisvg

ffmpeg

TERM=a AV_LOG_FORCE_COLOR=1 ffmpeg ... 2>&1 | ansisvg

jq

jq -C | ansisvg

Development

Run all tests and write new difftest outputs

WRITE_ACTUAL=1 go test ./...

Visual inspect outputs in browser:

for i in ansisvg/testdata/*.ansi.svg; do echo "$i<br><img src=\"$i\"/><br>" ; done  > all.html
open all.html

Using ffcat:

for i in ansisvg/testdata/*.ansi; do echo $i ; cat $i | go run main.go | ffcat ; done

Licenses and thanks

Color themes from https://github.com/mbadolato/iTerm2-Color-Schemes, license https://github.com/mbadolato/iTerm2-Color-Schemes/blob/master/LICENSE

Uses colortest from https://github.com/pablopunk/colortest and terminal-colors from https://github.com/eikenb/terminal-colors.

TODO and ideas

  • Bold
  • Underline overlaps a bit, sometimes causing weird blending
  • Somehow use <tspan>/textLength to produce smaller output. Maybe em/ch CSS units for background rects, but seems inkscape do not like ch. Would also make it nicer to copy text from SVG.
  • Handle vertical tab and form feed (normalize into spaces?)
  • Handle overdrawing
  • More CSI, keep track of cursor?
  • PNG output (embed nice fonts?)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].