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

markdown2typst

v0.1.4

Published

A comprehensive JavaScript library for converting Markdown to Typst code

Readme

markdown2typst

A JavaScript library for converting Markdown to Typst code.

Demo - Try it online

See as an example use case the demo of this repository published as a static website: https://Mapaor.github.io/markdown2typst.

Supported Markdown features

GitHub Flavored Markdown (GFM)

  • ✔ Headings
  • ✔ Bold, italics, striketrought, code
  • ✔ Bulleted lists, numbered lists
  • ✔ Links
  • ✔ Images (only local)
  • ✔ Math (inline and block equations)
  • ✔ Tables
  • ✔ Quotes
  • ✔ Code blocks (with highlighting)
  • ✔ Dividers (horizontal rule)
  • ✔ Footnotes
  • ✔ Table of Contents (ToC)
  • ✘ Mermaid diagrams --> Coming soon(!)
  • ✘ Checklists --> Coming soon(!)
  • ✘ HTML, GeoJSON, STL --> Not Typst compatible.

Markdown Frontmatter

Only works with YAML for now, TOML support is planned.

Currently supported keys:

  • title (rich text string)
  • author (string or array of strings)
  • description (string)
  • keywords (array of strings)
  • date (YYYY-MM-DD string)
  • abstract (rich text string)
  • lang (string)
  • region (string)

For more information see Typst Document Function, Jekyll Frontmatter Docs or check the examples.

Chosen design

By design the choice has been to support mainly the Typst document parameters, that in principle are just metadata. However the title, and author and date are also displayed. Those could be displayed in any way in Typst, the chosen one has been the more basic and default way: simply non-style top-centered Title, author and date. With newlines between them. Support for setting the language and a custom abstract in the frontmatter (or custom options) has also been added.

Example

The following is a complete Markdown example of all the supported front-matter keys:

---
title: The Fellowship of the Ring
author:
  - John Doe
  - Jack Doe
  - Jane Doe
description: This is just an example document, this information is in principle stored as metadata only but it can be displayed using context document.
keywords:
  - example
  - document
  - lotr
  - typst
date: 2026-01-12
abstract: In this paper we assess the impacts of the One Ring on Middle Earth and its inhabitants, analyzing both economic and social factors.
lang: en
region: gb
---

And the corresponding Typst output is:

// ===============  FRONTMATTER  ===============

#set document(
  title: [The Fellowship of the Ring],
  author: ("John Doe", "Jack Doe", "Jane Doe"),
  description: [This is just an example document, this information is in principle stored as metadata only but it can be displayed using context document.],
  keywords: ("example", "document", "lotr", "typst"),
  date: datetime(day: 12, month: 1, year: 2026)
)

#let abstract = [In this paper we assess the impacts of the One Ring on Middle Earth and its inhabitants, analyzing both economic and social factors.]

#align(center)[
  #title() \ \ #context document.author.join(", ", last: " & ") \ \ #context document.date.display() \ \  \ *Abstract* \ #abstract
]

#set text(lang: "en", region: "gb")

//  ============================================

Note: any non-standard key is simply ignored, all keys are optional. The front-matter as a whole is obviously also optional.

Installation

NPM package (for Node.js projects)

Package link:

https://www.npmjs.com/package/markdown2typst

Install it:

npm install tex2typst

JS Bundle

JSDelivr

<script src="https://cdn.jsdelivr.net/npm/markdown2typst@latest/dist/markdown2typst.min.js"></script>

Unpkg

<script src="https://unpkg.com/markdown2typst@latest/dist/markdown2typst.min.js"></script>

Build from source

# Clone the repository
git clone https://github.com/Mapaor/markdown2typst.git
cd markdown2typst

# Install dependencies
npm install

# Build the bundle
npm run build

A javascript bundle will appear in the dist folder. Make the desired changes to the library and then build again if you need. To test your modifications still comply with what's expected from the library run the tests.

# Testing
npm run test

Simple Usage

Using the package

Simplest example
import { markdown2typst } from 'markdown2typst';

const markdown = '# Hello Typst\n\nThis is a **test**.';
const typst = markdown2typst(markdown);
console.log(typst);
Converting a Markdown file
import { markdown2typst } from 'markdown2typst';
import { readFileSync } from 'fs';

const markdown = readFileSync('./example-file.md', 'utf-8');
const typst = markdown2typst(markdown);
console.log(typst);

Using the bundle - Locally

Suppose you've downloaded the JS bundle and saved it in a assets folder, now for using it in your website you would simply do:

In Node.js (ESM)
import { markdown2typst } from './assets/markdown2typst.min.js';

const markdown = '# Hello Typst\n\nThis is a **test**.';
const typst = markdown2typst(markdown);
console.log(typst);
In the browser
<script type="module">
  import { markdown2typst } from './assets/markdown2typst.min.js';
  
  const markdown = '# Hello Typst';
  const typst = markdown2typst(markdown);
  console.log(typst);
</script>

Using the bundle - Via CDN

<script src="https://cdn.jsdelivr.net/npm/markdown2typst@latest/dist/markdown2typst.min.js"></script>
<script>
  const markdown = '# Hello Typst\n\nThis is a **test**.';
  const typst = markdown2typst(markdown);
  console.log(typst);
</script>

Or in a javascript file

import markdown2typst from 'https://cdn.jsdelivr.net/npm/markdown2typst@latest/dist/markdown2typst.min.js';

const markdown = '# Hello Typst\n\nThis is a **test**.';
const typst = markdown2typst(markdown);
console.log(typst);

Which is what the demo uses.

Examples

See the Examples page for basic and advanced examples on how to use the library and all the features it supports.

Internal architecture

Check the Architecture doc for getting a better understanding of how the library works under the hood.

Contributing

Contributions are more than welcome! See the Contributing guide.

License

MIT License

Acknowledgments

Built thanks to the following open-source projects:

This code was initially based on the code by zhaoyiqun (@cosformula on GitHub), more specifically in his markdownToTypst.ts custom conversion library (renderer to Typst code) built for his open source project MDXport.

Roadmap

  • [X] Finish an initial working version
  • [X] Add frontmatter support and also allow to pass the keys as custom options of the main function
  • [X] Publish to npm
  • [X] Add a comprehensive test suite
  • [ ] Add CLI tool
  • [ ] Support custom templates
  • [ ] Support more Markdown extensions/flavors/specs