Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
▄████████ ███▄▄▄▄ ▄████████ ▄█ ████████▄ ▄████████ ▄████████
███ ███ ███▀▀▀██▄ ███ ███ ███ ███ ▀███ ███ ███ ███ ███
███ ███ ███ ███ ███ █▀ ███▌ ███ ███ ███ █▀ ███ █▀
███ ███ ███ ███ ███ ███▌ ███ ███ ▄███▄▄▄ ███
▀███████████ ███ ███ ▀███████████ ███▌ ███ ███ ▀▀███▀▀▀ ███
███ ███ ███ ███ ███ ███ ███ ███ ███ █▄ ███ █▄
███ ███ ███ ███ ▄█ ███ ███ ███ ▄███ ███ ███ ███ ███
███ █▀ ▀█ █▀ ▄████████▀ █▀ ████████▀ ██████████ ████████▀
ANSIDec is a library for handling limited number of ANSI escape sequences for use in Browsers. The primary goal of the library is to allow of displaying ANSI and ASCII art in Browsers by transforming Unix encoding to html. But it can also be used from Node.js.
https://jcubic.github.io/ansidec/
Npm installation for use with webpack:
npm install ansidec
Besides npm you can also download that file locally or use unpkg.com:
<script src="https://unpkg.com/ansidec"></script>
// if you're using webpack or node.js you can use npm
var ansi = require('ansidec');
var format = ansi.format(function(styles, color, background, text) {
var style = [];
if (color) {
style.push('color:' + color);
}
if (background) {
style.push('background:' + background);
}
if (styles.bold) {
style.push('font-weight:bold');
}
if (styles.italic) {
style.push('font-style:italic');
}
if (styles.underline) {
styles.push('text-decoration:underline');
}
return '<span style="' + style.join(';') + '">' + text + '</span>';
});
document.querySelector('pre').innerHTML = format(text);
format function can be executed with text as second argument, then it will return string. If it don't get string as second argument it will return function. So it's like it was curried.
If you want just to output html you can use helper:
var ansi = require('ansidec');
document.querySelector('pre').innerHTML = ansi.html(text)
and use format only if you need different html or any different output text.
If you want to render ANSI art with this library you will need to covert the text from ANSI art file to UTF-8 to do that you can use iconv-lite library or iconv on a Back-End see how to do that in examples directory.
Released under MIT license
Copyright (c) 2018-2019 Jakub T. Jankiewicz
FAQs
Limited Unix ANSI escape sequences transformer for use in Browsers
The npm package ansidec receives a total of 613 weekly downloads. As such, ansidec popularity was classified as not popular.
We found that ansidec demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.