Adds ansi to svg script
This commit is contained in:
parent
495b5e3794
commit
b63f40300b
1 changed files with 82 additions and 0 deletions
82
bin/.bin/conversion/ansi2svg
Executable file
82
bin/.bin/conversion/ansi2svg
Executable file
|
@ -0,0 +1,82 @@
|
|||
#!/usr/bin/env node
|
||||
const {stdin} = process;
|
||||
|
||||
const ansiToSVG = require('ansi-to-svg')
|
||||
|
||||
getStdin = async () => {
|
||||
let result = '';
|
||||
|
||||
if (stdin.isTTY) {
|
||||
return result;
|
||||
}
|
||||
|
||||
stdin.setEncoding('utf8');
|
||||
|
||||
for await (const chunk of stdin) {
|
||||
result += chunk;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
(async () => {
|
||||
//=> 'unicorns'
|
||||
// Returns an SVG string
|
||||
console.log(ansiToSVG(await getStdin(), {
|
||||
// Defaults to 2x for Retina compatibility
|
||||
scale: 2,
|
||||
|
||||
// Font settings
|
||||
fontFace: 'Courier',
|
||||
fontSize: 14,
|
||||
lineHeight: 18,
|
||||
|
||||
// Padding
|
||||
paddingTop: 0,
|
||||
paddingLeft: 0,
|
||||
paddingBottom: 0,
|
||||
paddingRight: 0,
|
||||
|
||||
// Supply an iTerm2 Color file
|
||||
colors: './base16-flat-dark-f1lt3r-256.itermcolors',
|
||||
|
||||
// Or override the default colors
|
||||
// (all defaults shown here)
|
||||
colors: {
|
||||
black: '#000000',
|
||||
red: '#B22222',
|
||||
green: '#32CD32',
|
||||
yellow: '#DAA520',
|
||||
blue: '#4169E1',
|
||||
magenta: '#9932CC',
|
||||
cyan: '#008B8B',
|
||||
white: '#D3D3D3',
|
||||
gray: '#A9A9A9',
|
||||
redBright: '#FF4500',
|
||||
greenBright: '#ADFF2F',
|
||||
yellowBright: '#FFFF00',
|
||||
blueBright: '#87CEEB',
|
||||
magentaBright: '#FF00FF',
|
||||
cyanBright: '#00FFFF',
|
||||
whiteBright: '#FFFFFF',
|
||||
bgBlack: '#000000',
|
||||
bgRed: '#B22222',
|
||||
bgGreen: '#32CD32',
|
||||
bgYellow: '#DAA520',
|
||||
bgBlue: '#4169E1',
|
||||
bgMagenta: '#9932CC',
|
||||
bgCyan: '#008B8B',
|
||||
bgWhite: '#D3D3D3',
|
||||
bgGray: '#A9A9A9',
|
||||
bgRedBright: '#FF0000',
|
||||
bgGreenBright: '#ADFF2F',
|
||||
bgYellowBright: '#FFFF00',
|
||||
bgBlueBright: '#87CEEB',
|
||||
bgMagentaBright: '#FF00FF',
|
||||
bgCyanBright: '#00FFFF',
|
||||
bgWhiteBright: '#FFFFFF',
|
||||
backgroundColor: '#000000',
|
||||
foregroundColor: '#D3D3D3'
|
||||
}
|
||||
}))
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue