JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 43
  • Score
    100M100P100Q58402F
  • License MIT

Node package and CLI tool to convert code into image with syntax highlighting

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 catage

API

const path = require( 'path' );

// import convert function and constants
const { convert, IMAGE_FORMATS, LANGUAGES, THEMES } = require( 'catage' );

// output code of `code` in `code.png` 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( '../' );

// output code of `code` in `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,
} );

example

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]