npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@neatico/code-highlight

v0.1.4

Published

Deterministic syntax highlighting helpers for Neatico visual and code blocks.

Readme


@neatico/code-highlight turns a string of source code into a bounded, escaped HTML fragment with inline colors. It is built for design and presentation pipelines that paint code onto editable cards and native PPTX text runs — not for documentation sites that can ship a full stylesheet.

  • No stylesheet, no DOM. Colors are emitted as inline style attributes, so the same fragment works in a browser, a canvas renderer, or a headless export.
  • Source is never altered. Whitespace, characters, and identifiers are preserved exactly.
  • Fail-safe by design. Unrecognized languages and oversized input degrade to plain, escaped text rather than throwing.
  • Hard execution ceiling. Grammar processing is skipped past 20,000 characters to avoid pathological input.

Installation

npm install @neatico/code-highlight

CommonJS only. No environment configuration is required.

Usage

const { highlightCodeHTML } = require("@neatico/code-highlight");

const html = highlightCodeHTML(
  'const greet = (name) => `Hello, ${name}`;',
  "javascript",
);

// <span style="color:#C4B5FD">const</span> greet = ...

Render the result inside a <pre> block so whitespace is preserved, and place it on a dark surface — the palette is tuned for that context.

Unknown languages and large payloads are escaped instead of highlighted:

highlightCodeHTML('<img src=x>', "unknown");
// &lt;img src=x&gt;

highlightCodeHTML("x".repeat(20001), "javascript");
// plain text, grammar execution skipped

API

highlightCodeHTML(code, language?)

| Parameter | Type | Description | |---|---|---| | code | string | Source code to highlight. Any other type throws TypeError. | | language | string | Language identifier, case-insensitive. Defaults to "" (plain text). | | returns | string | An HTML fragment with inline colors, or escaped plain text. |

The output never contains class attributes — every token carries an inline color. Only the following syntaxes are registered, which keeps the grammar bundle small and predictable.

| Language | Identifiers (aliases work) | |---|---| | JavaScript | javascript, js | | TypeScript | typescript, ts | | JSON | json | | Bash | bash, sh, zsh | | Python | python, py | | CSS | css | | HTML / XML | xml, html, xhtml, svg | | SQL | sql | | Java | java | | Go | go | | Rust | rust, rs | | YAML | yaml, yml |

The fragment escapes & < > " ', so registered grammars cannot inject executable markup. If you re-render the result in a non-HTML context, treat it as trusted display text only.

Security model

The library does not execute input code, access the network, or touch the file system. Highlighting is a pure string transformation. Always render the returned fragment with whitespace preserved and never concatenate it into an unescaped template.

Development

npm install
npm test        # node:test — escaping, palettes, size ceiling

Meet Neatico

This package is one of the engines inside Neatico — the AI workspace that turns a single idea into pixel-perfect, fully editable visuals. Describe what you want and Neatico designs social posts, presentations, and marketing graphics with real layouts, measured typography, your brand kit, and one-click PPTX/PNG export.

The @neatico/* packages are the framework-independent pieces extracted from that product so you can build your own editor or pipeline. Want the finished experience instead of the primitives? Start creating free on neatico.com →

License

MIT — built on highlight.js (BSD-3-Clause). See LICENSE.