Skip to content

Znak

Znak is a parser for a Markdown-like markup language that supports a smaller subset of Markdown syntax, and is stricter and more opinionated. It has features like Shiki syntax highlighting, KaTeX, and heading IDs built-in.

The name "Znak" comes from the Polish word "znak", meaning "sign" or "mark".

Usage

  1. Install the package as a dependency to your project.

    sh
    # Use the command for your package manager
    npx jsr add @noclaps/znak
    yarn dlx jsr add @noclaps/znak
    pnpm dlx jsr add @noclaps/znak
    bunx jsr add @noclaps/znak
    deno add @noclaps/znak
  2. Import the package in your code, and use it.

    ts
    import { render, headings } from "@noclaps/znak";
    
    const text = "# Hello World"; // Your text to be rendered.
    const renderedHTML = await render(text);
    // <h1 id="hello-world">Hello World</h1>
    const headings = headings(text);
    // [{depth: 1, slug: "hello-world", title: "Hello World"}]

You will have to include the KaTeX CSS file somewhere in your page for it to render correctly. See KaTeX browser usage for instructions.

See the Types documentation for all of the configuration options and types, and the Syntax documentation for the supported syntax.

Released under the 0BSD license.