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 🙏

© 2025 – Pkg Stats / Ryan Hefner

examplify

v1.0.13

Published

Amplify your Markdown documentation with executable examples

Readme

examplify

Amplify your Markdown documentation with executable examples.

Introduction

examplify allows you to write Markdown documentation with executable examples.

It helps you to ensure that your examples are always in sync with executable JavaScript or presentable HTML output. You can do less work and deliver more.

If you like examplify, check out lazui at lazui.org for activating your Markdown files. Almost all the example code on lazui.org uses examplify, plus there are a lot of other goodies.

Installation

Local

npm install -g examplify

And use the file examplify.js in your project.

CDN

<script src="https://esm.sh/examplify"></script>

Usage

Before Markdown Parsing

Prior to handing a string to a Markdown parser, pass it through examplify. Any code blocks marked as !html will be processed and the internals inserted immediately after the code block.

import { examplify } from 'examplify';
import {default as MarkdownIt} from "markdown-it";

const md = new MarkdownIt({
    html: true,
    linkify: true,
    typographer: false
})

const string = "```!html\n<script>console.log('Hello, World!');</script>\n```";

const examplified = examplify(string);

const markedDown = md.render(examplified);

This Markdown:

    ```!html
    <script>console.log('Hello, World!');</script>;
    ```

Will be turned into this:

    ```html
    <script>console.log('Hello, World!');</script>;
    ```
    <script>console.log('Hello, World!')</script>;

And this Markdown:

    ```!html
    <form><input type="text" value="Hello, World!"></form>
    ```

Will be turned into this:

    ```html
    <form><input type="text" value="Hello, World!"></form>
    ```
    <form><input type="text" value="Hello, World!"></form>

Will actually render as a form with an input field after the Markdown.

!javascript is also supported.

    ```!javascript
    console.log('Hello, World!');
    ```

Will produce the following HTML:

    ```javascript
    console.log('Hello, World!');
    ```
    <script>console.log('Hello, World!');</script>

Note: The script tags generated do not have a type. If you need a module, provide the example as !html with the module script as source.

You can even spice things up by updating the final DOM with your JavaScript:

    <div id="message">
    ```!javascript
        const el = document.getElementById('message');
        el.innerHTML = 'Hello, World!';
    ```

After Markdown Parsing

examplify will also process code blocks marked as !html and !javascript after the Markdown has been parsed.

You can use this in a browser if your server does not support examplify.

Pass a document object or any HTMLElement to examplify. All code blocks matching code[class*='language-!html'] will be processed. The internals will be inserted immediately after the code block as HTML and the class will be changed to language-html. Any <script> elements will be executed, so make sure you are loading the Markdown from a trusted source.

import { examplify } from 'examplify';

examplify(document);

This Markdown:

    ```!html
    <script>console.log('Hello, World!');</script>;
    ```

Will generate this HTML:

<code class="language-!html">
    <span class="hljs-tag">
        &lt;<span class="hljs-name">script</span>&gt;
    </span>
    <span class="language-javascript">
        <span class="hljs-variable language_">console</span>.
        <span class="hljs-title function_">log</span>
        (<span class="hljs-string">"Hello, World!"</span>)
    </span>
    <span class="hljs-tag">&lt;/
        <span class="hljs-name">script</span>&gt;
    </span>
</code>

Which will be converted to this:

<code class="language-html">
    <span class="hljs-tag">
        &lt;<span class="hljs-name">script</span>&gt;
    </span>
    <span class="language-javascript">
        <span class="hljs-variable language_">console</span>.
        <span class="hljs-title function_">log</span>
        (<span class="hljs-string">"Hello, World!"</span>)
    </span>
    <span class="hljs-tag">&lt;/
        <span class="hljs-name">script</span>&gt;
    </span>
</code>
<script>console.log('Hello, World!');</script>

License

MIT

Release History (reverse chronological order)

2024-04-31 v1.0.13 Added 'Rendered by Examplify treatment'

2024-04-31 v1.0.12 Addressed bug with SCRIPT tags in PRE tags

2024-04-30 v1.0.11 More work on PRE

2024-04-30 v1.0.10 Added support for code blocks being inside a PRE tag and elevating the example outside the PRE

2023-11-06 v1.0.8-9 Documentation updates.

2023-11-06 v1.0.7 Sync npm and GitHub versions

2023-11-06 v1.0.6 Fixing README so npmjs.com will render it properly, even though GitHub already does. Added a unit test for !javascript. Updated docs.

2023-11-01 v1.0.5 More README formatting to handle GitHub nuances.

2023-11-01 v1.0.4 Fixed README formatting

2023-10-31 v1.0.3 Ensured script elements are executing when examplify applied to DOM node.

2023-10-30 v1.0.2 Fixed bug related to two tags blocks in sequence.

2023-10-30 v1.0.1 Adjusted DOM processing to return the passed in element.

2023-10-30 v1.0.0 Added support for post-processing of Markdown.

2023-10-29 v0.0.1 Initial Release.