Package Exports
- catage
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (catage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
catage (cat to image)
Node package and CLI tool to convert code into image with syntax highlighting.
Install using NPM
npm install --save catageAPI
const path = require( 'path' );
// import `convert` function and constants
const { convert, IMAGE_FORMATS, LANGUAGES, THEMES } = require( 'catage' );
// convert a code file to an image file
convert( options );options
| Name | Use | default Value |
|---|---|---|
| inputFile | Relative or absolue path of a code (text) file | undefined |
| outputFile | Relative or absolue of the output image file | undefined |
| language | Language of the code file | LANGUAGES.DART |
| theme | Theme for the syntax highlighting | THEMES.FIREWATCH |
| padding | Gap between code and image edges. Value could be string or a number | '20,30' |
| format | Format of the output image file | IMAGE_FORMATS.PNG |
Supported themes: https://iterm2colorschemes.com/
Supported languages: https://github.com/highlightjs/highlight.js/tree/master/src/languages
Supported image formats: jpeg,jpg
Example
const path = require( 'path' );
// import convert function and constants
const { convert, IMAGE_FORMATS, LANGUAGES, THEMES } = require( '../' );
// convert `code.dart` file to `code.png` file
convert( {
inputFile: path.resolve( __dirname, 'code.dart' ),
outputFile: path.resolve( __dirname, 'code.png' ),
language: LANGUAGES.DART,
theme: THEMES.FIREWATCH,
padding: '20,30',
format: IMAGE_FORMATS.PNG,
} );
Upcoming changes
- CLI tool to convert code to image files
- Ability to add output image corner radius [optional]
- Adding MacOS window frame to the output image [optional]
- Executing code file and compositing output image with the results [optional]