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

abdk-highlightjs-huff

v1.0.1

Published

Highlight.js syntax definition for the Huff EVM assembly language

Readme

abdk-highlightjs-huff

npm version CI License: MIT

A Highlight.js language plugin that adds rich syntax highlighting for Huff — the low-level EVM assembly language for writing highly optimised Ethereum smart contracts.


Features

  • All #define variants highlighted: macro, fn, test, function, event, error, constant, jumptable, jumptable__packed, table
  • Definition names highlighted as title.function
  • takes / returns stack-annotation keywords
  • Function modifiers: view, pure, payable, nonpayable, indexed
  • FREE_STORAGE_POINTER keyword
  • Complete EVM opcode set (including Cancun: tload, tstore, mcopy, blobhash, blobbasefee)
  • Compiler built-in functions: __FUNC_SIG, __EVENT_HASH, __ERROR, __RIGHTPAD, __codesize, __tablestart, __tablesize
  • Constant references [NAME] highlighted as variable
  • Macro argument invocations <name> highlighted as variable
  • Label definitions (label:) highlighted as symbol
  • Test decorators (#[calldata(...), value(...)])
  • #include paths highlighted as strings
  • Decimal and hexadecimal numeric literals
  • Line and block comments
  • Reliable auto-detection via highlightAuto

Installation

npm install abdk-highlightjs-huff

highlight.js ≥ 11 is a peer dependency — install it separately if you haven't already:

npm install highlight.js

Usage

CommonJS / Node.js

const hljs = require("highlight.js");
const huff = require("abdk-highlightjs-huff");

hljs.registerLanguage("huff", huff.default ?? huff);

const code = `
#define macro MAIN() = takes (0) returns (0) {
    0x00 calldataload
    0xE0 shr
    __FUNC_SIG(transfer) eq transfer jumpi
    0x00 0x00 revert
    transfer:
        0x01 0x00 mstore
        0x20 0x00 return
}
`.trim();

const html = hljs.highlight(code, { language: "huff" }).value;
console.log(html);

ES Modules

import hljs from "highlight.js";
import huff from "abdk-highlightjs-huff";

hljs.registerLanguage("huff", huff);

const result = hljs.highlight(code, { language: "huff" });

Browser (CDN)

Load Highlight.js first, then load this plugin:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/styles/github-dark.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/highlight.min.js"></script>
<!-- abdk-highlightjs-huff -->
<script src="https://unpkg.com/abdk-highlightjs-huff/dist/index.js"></script>
<script>
  hljs.registerLanguage("huff", window.hljsHuff?.default ?? window.hljsHuff);
  hljs.highlightAll();
</script>

Then mark up your code blocks:

<pre><code class="language-huff">
#define macro MAIN() = takes (0) returns (0) {
    0x00 calldataload 0xE0 shr
    __FUNC_SIG(transfer) eq transfer jumpi
    0x00 0x00 revert
    transfer:
        0x04 calldataload
        0x24 calldataload
        TRANSFER()
        0x20 0x00 return
}
</code></pre>

Auto-detection

The plugin registers Huff with high relevance scores on #define directives and built-in functions so highlightAuto correctly identifies Huff source files:

const result = hljs.highlightAuto(unknownCode);
console.log(result.language); // "huff"

Supported syntax elements

| Element | Highlight class | |---------|----------------| | #define, #include, #[…] decorator | hljs-meta | | Definition types (macro, fn, test, …) | hljs-keyword | | takes, returns, modifiers | hljs-keyword | | FREE_STORAGE_POINTER | hljs-keyword | | Definition names | hljs-title function_ | | EVM opcodes | hljs-built_in | | Compiler built-ins (__FUNC_SIG, …) | hljs-built_in | | Constant references [NAME] | hljs-variable | | Macro argument invocations <name> | hljs-variable | | Label definitions (label:) | hljs-symbol | | Numeric literals | hljs-number | | String literals | hljs-string | | Comments | hljs-comment |


Example

#include "huffmate/auth/Owned.huff"

#define function transfer(address, uint256) nonpayable returns (bool)
#define event Transfer(address indexed, address indexed, uint256)
#define error InsufficientBalance(uint256, uint256)

#define constant BALANCE_SLOT = FREE_STORAGE_POINTER()

#define macro TRANSFER() = takes (2) returns (0) {
    // Input stack: [to, amount]
    caller                    // [from, to, amount]
    dup3                      // [amount, from, to, amount]
    [BALANCE_SLOT] sload      // [balance, amount, from, to, amount]
    dup2 dup2 lt              // [balance < amount, balance, amount, from, to, amount]
    insufficient jumpi        // [balance, amount, from, to, amount]

    sub                       // [new_balance, from, to, amount]
    caller [BALANCE_SLOT] sstore   // [from, to, amount]

    // emit Transfer(from, to, amount)
    __EVENT_HASH(Transfer)
    0x00 0x00 log3

    stop

    insufficient:
        __ERROR(InsufficientBalance)
        0x00 mstore
        0x24 0x00 revert
}

License

MIT © ABDK Consulting