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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@readme/markdown

v7.9.0

Published

ReadMe's React-based Markdown parser

Downloads

14,587

Readme

@readme/markdown

ReadMe's MDX rendering engine and custom component collection.   (Use ReadMe? Learn more about our upcoming move to MDX!)

Getting Started

To use the engine, install it from NPM:

npm install --save @readme/markdown

Then compile and run your MDX:

import RMDX from '@readme/markdown';

export default ({ body }) => (
  <div className="markdown-body">
    {RMDX.run(RMDX.compile(body))}
  </div>
);

API

compile

Compiles MDX to JS. Essentially a wrapper around mdx.compile. Used before calling run; it has been left as a seperate method for potential caching opportunities.

Parameters

  • string (string)—an MDX document
  • opts (CompileOpts, optional)—a configuration object

Returns

A string of compiled Javascript module code.

run

[!CAUTION] This is essentially a wrapper around mdx.run and it will eval the compiled MDX. Make sure you only call run on safe syntax from a trusted author!

Parameters

  • string (string)—a compiled mdx document
  • opts (RunOpts, optional)—configuration

Returns

An RMDXModule of renderable components.

mdx

Compiles an AST to a string of MDX syntax.

Parameters

  • tree (object)—an abstract syntax tree
  • opts (Options)—remark-stringify configuration.

Returns

An MDX string.

Other Methods

  • mdast: parse MDX syntax to MDAST.
  • hast: parse MDX syntax to HAST.
  • plain: parse MDX to a plaintext string with all Markdown syntax removed. (This does not eval the doc.)
  • tags: get a list of tag names from the doc. (This does not eval the doc.)
  • utils: additional defaults, helper methods, components, and so on.

Types

CompileOpts

Extends CompileOptions

Additional Properties
  • lazyImages (boolean, optional)—load images lazily
  • safeMode (boolean, optional)—extract script tags from HTMLBlocks
  • components (Record<string, string>, optional)—an object of tag names to mdx.
  • copyButtons (Boolean, optional) — add a copy button to code blocks

RunOpts

Extends RunOptions

Additional Properties
  • components (Record<string, MDXModule>, optional)—a set of custom MDX components
  • imports (Record<string, unknown>, optional)—an set of modules to import globally
  • terms (GlossaryTerm[], optional)
  • variables (Variables, optional)—an object containing user variables

RMDXModule

Properties
  • default (() => MDXContent)—the MDX douments default export
  • toc (HastHeading[])—a list of headings in the document
  • Toc (() => MDCContent)—a table of contents component

Local Development and Testing

To make changes to the RDMD engine locally, run the local development server. Clone the repo, cd in to it, npm install, and npm run start!

If you make changes to the docs or how the markdown is rendered, you may need to update the visual regression snapshots by running make updateSnapshot. Running these browser tests requires docker. Follow the docker install instructions for mac. You may want to increase the memory usage. If you have not already, you'll need to create an account for docker hub and sign-in locally.