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

remark-video

v0.10.0

Published

A remark plugin to parse video components

Readme

remark-video

A remark plugin to parse HTML5 video component(s).

demo gif

Features

  • Compatible with the proposed generic syntax for custom directives/plugins in Markdown
  • Compatible with the HTML5 video and source tags combination
    • covering the mp4, webm, and ogg video formats
  • Fully customizable styles
  • Written in TypeScript
  • ESM only

How to Use

Installation

To install the plugin:

With npm:

npm install remark-video

With yarn:

yarn add remark-video

With pnpm:

pnpm add remark-video

With bun:

bun install remark-video

Usage

General usage:

import rehypeStringify from "rehype-stringify";
import remarkVideo from "remark-video";
import remarkDirective from "remark-directive";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import { unified } from "unified";

const BASE_URL = "https:\\BASE_URL.com";

const normalizeHtml = (html: string) => {
  return html.replace(/[\n\s]*(<)|>([\n\s]*)/g, (_match, p1, _p2) =>
    p1 ? "<" : ">"
  );
};

const parseMarkdown = async (markdown: string) => {
  const remarkProcessor = unified()
    .use(remarkParse)
    .use(remarkDirective)
    .use(remarkVideo, { baseUrl: BASE_URL, publicDir: "./public" })
    .use(remarkRehype)
    .use(rehypeStringify);

  const output = String(await remarkProcessor.process(markdown));

  return output;
}

const input_1 = "::video{src=/videos/sample-video-1.mp4}";
const input_2 = `
:::video
/videos/sample-video-1.mp4
:::
`;

const html_1 = await parseMarkdown(input_1);
const html_2 = await parseMarkdown(input_2);

console.log(normalizeHtml(html_1));
console.log(normalizeHtml(html_2));

Yields: (Both the html_1 and html_2 yields the same output)

<div data-remark-video-figure>
  <video controls preload="metadata" width="100%">
    <source src="/videos/sample-video-1.mp4" type="video/mp4">
  </video>
</div>

At the moment, it takes the following option(s):

export type Config = {
  baseUrl?: string; // e.g., your website's URL. Defaults to an empty string
  publicDir?: string; // A relative path to your public directory from the current working directory. Defaults to "./public"
  videoContainerTag?: string; // e.g., `div`, `figure`, etc. Defaults to `div`
  videoContainerClass?: string;
  fallbackContent?: Readonly<ElementContent> | null | undefined; // A fallback content to let appear when user's browser is not compatible with the HTML5 video tag
}

[!NOTE] Why is the triple-colon version provided? - Since MDX 2, the compiler has come to throw an error "Could not parse expression with acorn: $error" whenever there are unescaped curly braces and the expression inside them is invalid. This breaking change leads the directive syntax (::xxx{a=b}) to cause the error, so the options are like an escape hatch for that situation.

For more possible patterns and in-depths explanations on the generic syntax(e.g., :::something[...]{...}), see ./test/index.test.ts and this page, respectively.

Syntax

For example, the following Markdown content:

::video{src=/videos/sample-video-1.mp4}

Or

:::video
/videos/sample-video-1.mp4
:::

Yields:

<div data-remark-video-figure>
  <video controls preload="metadata" width="100%">
    <source src="/videos/sample-video-1.mp4" type="video/mp4">
  </video>
</div>

[!NOTE] You need to create the public directory and then add videos to it in advance.

Astro

If you want to use this in your Astro project, note that you need to install remark-directive and add it to the astro.config.{js,mjs,ts} file simultaneously.

import { defineConfig } from 'astro/config';
import remarkVideo from "remark-video";
import remarkDirective from "remark-directive";
// ...

export default defineConfig({
  // ...
  markdown: {
    // ...
    remarkPlugins: [
      // ...
      remarkDirective,
      remarkVideo,
      // ...
    ]
    // ...
  }
  // ...
})

Feature(s) pending to be added

Nothing special.

TODO(s)

  • [x] add a demo screenshot of the actual implementation to this page

License

This project is licensed under the MIT License, see the LICENSE file for more details.