Narcoleptic Programmers' Medicine
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    code2imagepublic

    code2image

    NPM Version NPM Downloads

    The library allows to render an image from a code snippet. It's based on node-canvas module.

    Installation

    $ npm install code2image
    

    Example

    var code2image = require('code2image');
    var styles = { // it's default styles 
        fontName: "monospace",
        fontMinSize: '6px',
        fontSize: '18px',
        fontRatio: 1,
        lineHeight: '20px',
        color: "black",
        background: "white",
        keyword: '#444 bold',
        built_in: "black",
        number: "black",
        string: "green",
        comment: "gray",
        decorator: "black",
        function: "black",
        class: "black",
        title: "black",
        params: "black",
        section: "black",
        regexp: "red",
        preprocessor: "black",
        attribute: "black",
    };
     
    code2image.render("var hello = 'hello';\nvar world = 'world';\nconsole.log(hello + ' ' + world);", 'test.png', styles, function(){
        console.log('ok!');
    });
     

    Result:

    alt tag

    Supported languages

    https://github.com/kreshikhin/tolmach/blob/master/README.md#supported-languages

    License

    MIT

    Keywords

    none

    install

    npm i code2image

    Downloadsweekly downloads

    0

    version

    0.9.3

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar