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

kml_wasm

v1.1.0

Published

Kernel ML (KML) parser compiled to WASM

Readme

Kernel ML (KML) parser

Canonical Rust implementation of Kernel ML (KML). The package exposes a native compiler API and a WASM build for browser clients. It emits body-only HTML snippets, leaving full-page rendering, styling, sanitisation policy, and MathJax loading to the host application.

The KML language spec, implementation notes, tests, and showcase fixture are vendored in spec/, so the crate can be cloned, tested, and built without relying on sibling directories.

Prerequisites

Native compiler

cargo run --bin compile_kml -- path/to/file.kml
# or:
cat path/to/file.kml | cargo run --bin compile_kml

The command prints the compiled body HTML snippet to stdout and reports compile errors with line, column, and byte offset diagnostics.

Rust API

let html = kml_wasm::compile_inner("# Title")?;
let safe = kml_wasm::compile_inner_safe(untrusted_source)?;

Use compile_inner(source) from native Rust code when you want a Result<String, CompileError>. Use compile_inner_safe(source) for KML from untrusted sources — it strips raw :::html blocks, allowlists link URL schemes, and validates code-fence language identifiers. See spec/language.md for the full safe-mode contract.

WASM build

rustup target add wasm32-unknown-unknown
wasm-pack build --target bundler

Output is written to pkg/ (kml_wasm.js, kml_wasm_bg.wasm, and package metadata). pkg/ is generated and intentionally ignored by git.

Browser/bundler usage:

import init, { compile, compile_safe } from 'kml_wasm'

await init()
const html = compile('# Title')
const safeHtml = compile_safe(untrustedSource)

For interactive editors, use the stateful LiveCompiler export. It keeps parsed AST blocks for unchanged top-level chunks and re-emits the full document so global output such as footnote numbering remains correct.

import init, { LiveCompiler } from 'kml_wasm'

await init()
const compiler = new LiveCompiler()
const html = compiler.render(source)
const stats = JSON.parse(compiler.stats_json())

// Or, for untrusted input:
const safeCompiler = LiveCompiler.new_safe()
const safeHtml = safeCompiler.render(source)

Host applications can consume the generated package through a file dependency, a workspace package, a published package, or by serving the generated files from a public assets directory.

KML spec

Tests

cargo test

Troubleshooting

  • linker wasm-ld not found / missing WASM target: Run rustup target add wasm32-unknown-unknown. If you use Homebrew Rust instead of Rustup, see the wasm-pack documentation for non-rustup setups.
  • Host app cannot import kml_wasm: Build the WASM package first with wasm-pack build --target bundler, then point the host dependency or alias at the generated pkg/ directory.