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

msmark

v0.1.0

Published

A small, dependency-free Markdown -> HTML parser focused on common markdown features and producing lightweight HTML

Downloads

5

Readme

msmark

A small, dependency-free Markdown -> HTML parser focused on common markdown features and producing lightweight HTML.

msmark is a tiny, zero-dependency Markdown parser that converts a subset of Markdown into simple, lightweight HTML. It supports headings, paragraphs, lists, code blocks (with optional highlighting), links, images (including reference-style definitions), tables, blockquotes and common inline formatting.

Features

  • No dependencies, single-file implementation (msmark.js).
  • Works in Node.js and the browser (exposes msmark on window).
  • Support for code block highlighting via a user-supplied function.
  • Small and focused on common Markdown features — ideal for embedding in small projects.

Installation

Install from npm:

npm install msmark

Or include the script directly in a browser page and access the global msmark function.

Basic usage

Node / CommonJS

const msmark = require('msmark');

const md = `# Hello\n\nThis is *msmark*.`;
const html = msmark(md);
console.log(html);

Browser

Include msmark.js and call the global:

<script src="msmark.js"></script>
<script>
  const html = msmark('# Hello from browser');
  document.body.innerHTML = html;
</script>

API

msmark(markdownString, options?) -> string

Options (all optional)

  • hilightFunc(code: string, lang: string) => string — a function to highlight code blocks (for example using Prism or highlight.js). If provided, its return value will be used as the code block content. Otherwise code is HTML-escaped.
  • codeBlockWrapper — a string template used to wrap code block HTML. The template can include %lang% and %code% placeholders which will be replaced with the language and HTML-escaped code respectively.
  • imageLinkDefinitionBreak — a string used to customize the HTML comment marker that separates the main markdown body from image/link definitions. Default is Definitions (i.e. <!-- Definitions -->).

Notes and behavior

  • The package intentionally targets common Markdown constructs and aims to produce compact HTML rather than a fully spec-complete parser.
  • Reference-style image and link definitions are supported when provided after the special definition break comment.
  • Code fences using triple backticks or tildes are supported. If hilightFunc is provided, it'll be used to render the code contents.

Contributing

Bug reports and pull requests are welcome. Please keep changes small and focused. The repository contains msmark.js and msmark.d.ts — keep the public API stable.

License

ISC — see the LICENSE file included with this package.

Author

Pho Thin Mg [email protected]

Examples

  1. Simple markdown -> output (Node)
const msmark = require('msmark');

const md = `# Sample\n\nThis is **bold** and *italic*.`;
console.log('Markdown:\n', md);
console.log('\nHTML:\n', msmark(md));

Output (example):

Markdown:
# Sample

This is **bold** and *italic*.

HTML:
<h1>Sample</h1><p>This is <b>bold</b> and <em>italic</em>.</p>
  1. Code block with highlight function
const msmark = require('msmark');

const md = '```js\nconsole.log(42)\n```';
const html = msmark(md, {
  hilightFunc: (code, lang) => `<pre class="hl"><code>${code.replace(/</g, '&lt;')}</code></pre>`
});
console.log(html);
  1. ESM import (for ESM consumers)

If you consume this package as an ES module in a project, import the file directly:

import msmark from 'msmark'; // if your bundler maps 'msmark' to the distributed file
// or
import msmark from './msmark.js';

const html = msmark('# ESM Example');
console.log(html);

Running tests locally

This repo includes a small test suite. From the repository root run:

npm test

The test script runs a CommonJS and an ESM check to validate the exported function.