{"id":14156360,"url":"https://github.com/F1LT3R/chromafi","last_synced_at":"2025-08-06T02:33:14.214Z","repository":{"id":46900465,"uuid":"125471007","full_name":"F1LT3R/chromafi","owner":"F1LT3R","description":"🦅  cli syntax highlighting: any function - any object - 176 languages.","archived":false,"fork":false,"pushed_at":"2022-12-07T09:17:27.000Z","size":2209,"stargazers_count":39,"open_issues_count":29,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-04T00:03:06.442Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://f1lt3r.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/F1LT3R.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-16T06:03:07.000Z","updated_at":"2024-04-02T17:43:56.000Z","dependencies_parsed_at":"2023-01-24T15:31:01.710Z","dependency_job_id":null,"html_url":"https://github.com/F1LT3R/chromafi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fchromafi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fchromafi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fchromafi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fchromafi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/F1LT3R","download_url":"https://codeload.github.com/F1LT3R/chromafi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228829156,"owners_count":17978159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-17T08:05:24.512Z","updated_at":"2024-12-09T03:31:34.249Z","avatar_url":"https://github.com/F1LT3R.png","language":"JavaScript","funding_links":["https://patreon.com/bePatron?u=9720216"],"categories":["others"],"sub_categories":[],"readme":"# Chromafi\n\n[![Build Status](https://travis-ci.org/F1LT3R/chromafi.svg?branch=master)](https://travis-ci.org/F1LT3R/chromafi)\n[![Coverage Status](https://coveralls.io/repos/github/F1LT3R/chromafi/badge.svg?branch=master)](https://coveralls.io/github/F1LT3R/chromafi?branch=master)\n[![Npm Version](https://img.shields.io/npm/v/chromafi.svg)](https://www.npmjs.com/package/chromafi)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n\n\u003e 🦅  cli syntax highlighting: any function - any object - 176 languages\n\n![Figure 00](examples/figure-00.png)\n\n## Support\n\nSupport the development of Chromafi by [becoming a patreon](https://patreon.com/bePatron?u=9720216).\n\n\u003ca href=\"https://patreon.com/bePatron?u=9720216\"\u003e\u003cimg width=\"120\" src=\"https://f1lt3r.io/content/images/2018/04/become_a_patron_button@2x.png\"\u003e\u003c/a\u003e\n\n## Features\n\n\u003ccenter\u003e\u003cimg width=\"360px\" src=\"chromafi-logo.png\"\u003e\u003c/center\u003e\n\n* JavaScript objects that are logged to the console... still look like JavaScript objects.\n* Chromafi highlights JavaScript functions.\n* Adjust indentation for tabbed code with Chromafi.\n* User defined color palettes.\n* Line numbers optional.\n* Padding adjustment for use with background colors or tight spaces.\n* Chromafi also highlights strings of code in 176 languages.\n\n## Usage\n\n### Chromafi a JavaScript Object\n\n```javascript\nconst chromafi = require('chromafi')\n\nconst obj = {\n    foo: 'bar',\n    baz: 1337,\n    qux: true,\n    zxc: null,\n    'foogle-bork': function (a, b) {\n        return b - a\n    }\n}\n\nconst chromatastic = chromafi(obj)\n\nconsole.log(chromatastic)\n```\n\n![Figure 01](examples/figure-01.png)\n\n### Chromafi a JavaScript Function\n\n```javascript\nconst chromafi = require('chromafi')\n\nfunction add (a, b) {\n    return a + b\n}\n\nconst chromantic = chromafi(add)\n\nconsole.log(chromantic)\n```\n\n![Figure 02](examples/figure-02.png)\n\n### Chromafi a String of Code\n\n```javascript\nconst chromafi = require('chromafi')\n\nconst codeString = `\n// Creates a Class based on Type\nconst create = (kind, parent) =\u003e {\n    // Create the Class based on the Type's\n    // Constructor or use an Anon. Func\n    const protoclass = kind.ctor || function () {}\n\n    // Inherit from a parent object\n    if (parent) {\n        protoclass.prototype = new Parent()\n    }\n\n    // Merge prototype from Class's Type\n    if (kind.proto) {\n        merge.call(protoclass.prototype, kind.proto)\n    }\n\n    return protoclass\n}\n`\n\nconst chromadactic = chromafi(codeString)\n\nconsole.log(chromadactic)\n```\n\n![Figure 03](examples/figure-03.png)\n\n## Options\n\n```javascript\nconst chromafi = require('chromafi')\nconst chalk = require('chalk')\n\nconst obj = {foobar: 1337}\n\nconst options = {\n    lineNumberPad: 0,\n    codePad: 0,\n    indent: 2,\n    lineNumbers: true,\n    colors: {\n        base: chalk.bgBlack.white.bold,\n        line_numbers: chalk.bgCyan.black\n    }\n}\n\nconst chromafanatic = chromafi(obj, options)\n\nconsole.log(chromafanatic)\n\n```\n\n![Figure 04](examples/figure-04.png)\n\n## Light Color Scheme\n\nChromafi uses [Chalk](https://github.com/chalk/chalk) to write ANSI color codes to the terminal.\n\n```javascript\nconst chromafi = require('chromafi')\n\nconst chromafi = require('.')\nconst chalk = require('chalk')\n\nconst obj = {\n    foo: 'bar',\n    baz: 1337,\n    qux: true,\n    zxc: null,\n    'foogle-bork': function (a, b) {\n        return b - a\n    }\n}\n\nconst chromafantastic = chromafi(obj, {\n    colors: {\n        base: chalk.bgWhite.black.bold,\n        keyword: chalk.red,\n        number: chalk.blue.dim,\n        function: chalk.black,\n        title: chalk.blue,\n        params: chalk.black,\n        string: chalk.black,\n        built_in: chalk.blue,\n        literal: chalk.blue,\n        attr: chalk.black,\n        // Just pass `chalk` to ignore colors\n        trailing_space: chalk,\n        regexp: chalk.blue,\n        line_numbers: chalk.bgBlue.white\n    }\n})\n\nconsole.log(chromafantastic)\n```\n\n![Figure 05](examples/figure-05.png)\n\n## Highlighting Other Languages\n\nChromafi uses [Highlight.js](https://highlightjs.org/) to syntax highlight to your code. This means Chromafi can highlight any language that `Highlight.js` can.\n\nLet's Chromafi some assembler syntax:\n\n```javascript\nconst chromafi = require('chromafi')\n\nconst armAssemblyCode = `\n.text\n\n.global connect\nconnect:\n    mov     r3, #2              ; s-\u003esin_family = AF_INET\n    strh    r3, [sp]\n    ldr     r3, =server_port    ; s-\u003esin_port = server_port\n    ldr     r3, [r3]\n    strh    r3, [sp, #2]\n    ldr     r3, =server_addr    ; s-\u003esin_addr = server_addr\n    ldr     r3, [r3]\n    str     r3, [sp, #4]\n    mov     r3, #0              ; bzero(\u0026s-\u003esin_zero)\n    str     r3, [sp, #8]\n    str     r3, [sp, #12]\n    mov     r1, sp      ; const struct sockaddr *addr = sp\n\n    ldr     r7, =connect_call\n    ldr     r7, [r7]\n    swi     #0\n\n    add     sp, sp, #16\n    pop     {r0}        ; pop sockfd\n\n    pop     {r7}\n    pop     {fp, ip, lr}\n    mov     sp, ip\n    bx      lr\n\n.data\nsocket_call:   .long 281\nconnect_call:  .long 283\n\n/* all addresses are network byte-order (big-endian) */\nserver_addr:            .long 0x0100007f ; localhost\nserver_port:            .hword 0x0b1a\n`\n\nconst chromalicious = chromafi(armAssemblyCode, {lang: 'arm'})\n\nconsole.log(chromalicious)\n```\n\n![Figure 06](examples/figure-06.png)\n\n## Supported Languages\n\n\u003e 1c, abnf, accesslog, actionscript, ada, apache, applescript, arduino, armasm, asciidoc, aspectj, autohotkey, autoit, avrasm, awk, axapta, bash, basic, bnf, brainfuck, cal, capnproto, ceylon, clean, clojure-repl, clojure, cmake, coffeescript, coq, cos, cpp, crmsh, crystal, cs, csp, css, d, dart, delphi, diff, django, dns, dockerfile, dos, dsconfig, dts, dust, ebnf, elixir, elm, erb, erlang-repl, erlang, excel, fix, flix, fortran, fsharp, gams, gauss, gcode, gherkin, glsl, go, golo, gradle, groovy, haml, handlebars, haskell, haxe, hsp, htmlbars, http, hy, inform7, ini, irpf90, java, javascript, jboss-cli, json, julia-repl, julia, kotlin, lasso, ldif, leaf, less, lisp, livecodeserver, livescript, llvm, lsl, lua, makefile, markdown, mathematica, matlab, maxima, mel, mercury, mipsasm, mizar, mojolicious, monkey, moonscript, n1ql, nginx, nimrod, nix, nsis, objectivec, ocaml, openscad, oxygene, parser3, perl, pf, php, pony, powershell, processing, profile, prolog, protobuf, puppet, purebasic, python, q, qml, r, rib, roboconf, routeros, rsl, ruby, ruleslanguage, rust, scala, scheme, scilab, scss, shell, smali, smalltalk, sml, sqf, sql, stan, stata, step21, stylus, subunit, swift, taggerscript, tap, tcl, tex, thrift, tp, twig, typescript, vala, vbnet, vbscript-html, vbscript, verilog, vhdl, vim, x86asm, xl, xml, xquery, yaml, zephir\n\n\n## Credits\n\nThank you to the following Noun Project artists for the vectors used in the lead graphic.\n\n- [Yoshi](https://thenounproject.com/aure7/)\n- [Tom Ingebretsen](https://thenounproject.com/tomplusplus/)\n- [Roussy Lucas](https://thenounproject.com/lroussy/)\n- [Wira](https://thenounproject.com/wirawizinda097/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FF1LT3R%2Fchromafi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FF1LT3R%2Fchromafi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FF1LT3R%2Fchromafi/lists"}