pozemka / ansiesc2html Goto Github PK
View Code? Open in Web Editor NEWConverts ANSI escape sequences to HTML. Library and CLI program.
License: MIT License
Converts ANSI escape sequences to HTML. Library and CLI program.
License: MIT License
See broken sgr then correct one
section of test case basic_bad_simple
:
std::string res = a2h.simpleParse("\x1b[31\x1b[32m aaa");
CHECK(body_start+R"(<font color="#39b54" aaa</font>)"+body_end == res);
It seems some variable are not cleaned up after exiting the function.
See bg+fg+bold
section of test case mixed
:
std::string res = a2h.simpleParse("\x1b[38;5;208;48;5;141;1m EvErYtHiNg \x1b[0m");
CHECK(body_start+R"(<font color="#ff8700"><span style="background-color:#af87ff"><b> EvErYtHiNg </b></span></font>)"+body_end == res);
That function will jsut convert ANSI to plain text without any tags.
More strict way to parse input. With correct close order an all that. It could be slower.
All common sequences just use the parameters as a series of semicolon-separated numbers such as 1;2;3. Missing numbers are treated as 0 (1;;3 acts like the middle number is 0, and no parameters at all in ESC[m acts like a 0 reset code).
1;;3
ESC[m
Or at least some part of it
All internal state can be wrapped in structure and passed along chain of function calls. (thanks @VladimirMarkelov for idea)
This will lead to thread safety too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.