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

@deepthinking/highlightjs-zig

v1.0.0

Published

Zig language definition for highlight.js

Readme

highlightjs-zig

A comprehensive highlight.js language definition for Zig — a general-purpose programming language designed for robustness, optimality, and maintainability.

Features

  • Full Zig syntax support: Keywords, built-in functions, types, and operators
  • Built-in functions: @import, @panic, @TypeOf, @sizeOf, @embedFile, and 50+ more
  • All Zig types: i8-i128, u8-u128, usize, f16-f64, bool, void, anytype, and more
  • String handling: Multi-line strings, escape sequences, and C-string literals
  • Numeric literals: Decimal, hexadecimal (0x), binary (0b), octal (0o), and underscores
  • Documentation comments: Both /// (top-level doc) and //! (inner doc) comments
  • Attributes: Full support for Zig's @[...] attribute syntax
  • Pointer syntax: *T, [*]T, ?*T, and more
  • TypeScript definitions: Full type declarations included

Installation

npm

npm install highlightjs-zig

yarn

yarn add highlightjs-zig

pnpm

pnpm add highlightjs-zig

Usage

CommonJS

const hljs = require('highlight.js');
const zig = require('highlightjs-zig');

hljs.registerLanguage('zig', zig);

ESM / ES6

import hljs from 'highlight.js';
import zig from 'highlightjs-zig';

hljs.registerLanguage('zig', zig);

With auto-detection

import hljs from 'highlight.js';
import zig from 'highlightjs-zig';

hljs.registerLanguage('zig', zig);

document.querySelectorAll('pre code').forEach((block) => {
  hljs.highlightElement(block);
});

Using with rehype-highlight (React / Markdown)

If you're using rehype-highlight in a React application or Markdown processor:

import rehypeHighlight from 'rehype-highlight';
import zig from 'highlightjs-zig';

// Register the Zig language
rehypeHighlight.languages.zig = zig;

Using with highlight.js auto-loader

If you use the highlight.js auto-loader script:

<script type="module">
  import hljs from 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11/dist/es/highlight.min.js';
  import zig from 'highlightjs-zig';

  hljs.registerLanguage('zig', zig);
  hljs.highlightAll();
</script>

API

registerLanguage('zig', zig)

Register the Zig language with highlight.js.

import hljs from 'highlight.js';
import zig from 'highlightjs-zig';

hljs.registerLanguage('zig', zig);

TypeScript

This package includes TypeScript definitions. No additional @types package needed:

import type { LanguageFn } from 'highlight.js';
import zig from 'highlightjs-zig';

const zigLanguage: LanguageFn = zig;

Supported Highlight.js Versions

  • highlight.js v11.x
  • highlight.js v10.x (via legacy import)

Example

const std = @import("std");

pub fn main() void {
    const stdout = std.io.getStdOut().writer();
    
    // Print Fibonacci numbers
    var a: u32 = 0;
    var b: u32 = 1;
    
    while (a < 100) {
        stdout.print("{} ", .{a}) catch return;
        const next = a + b;
        a = b;
        b = next;
    }
    
    stdout.print("\n", .{}) catch return;
}

/// A simple Fibonacci sequence generator
fn fibonacci(n: u32) u32 {
    if (n <= 1) return n;
    return fibonacci(n - 1) + fibonacci(n - 2);
}

Keywords & Syntax Covered

Control Flow

fn, if, else, while, for, return, break, continue, switch, case, defer, errdefer, try, catch, async, await, suspend, resume

Declarations

const, var, struct, enum, union, opaque, type, error, test

Modifiers

pub, export, extern, inline, noinline, volatile, allowzero, packed, comptime, noskip, align, section, usingnamespace, asm, mod

Built-in Types

| Type | Description | |------|-------------| | i8 - i128 | Signed integers | | u8 - u128 | Unsigned integers | | isize, usize | Platform-specific pointer sizes | | f16, f32, f64 | Floating-point numbers | | void | No value | | bool | Boolean (true/false) | | noreturn | Control flow that never returns | | anyopaque | Opaque pointer type | | anytype | Any type | | comptime_int | Compile-time integer | | comptime_float | Compile-time float |

Built-in Functions

@import, @compileLog, @panic, @assert, @field, @offsetOf, @TypeOf, @sizeOf, @embedFile, @panic, @trap, @inlineCall, @sqrt, @sin, @cos, @exp, @log, @pow, @floor, @ceil, @trunc, @round, @abs, @memcpy, @memset, @intCast, @floatCast, and 30+ more.

License

BSD 3-Clause License

Copyright (c) 2026, Jonathan Conway All rights reserved.

See LICENSE for full terms.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Support

If you encounter any issues or have questions: