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

@snappywc/md

v1.0.5

Published

The little markdown element that can.

Downloads

20

Readme

<snappy-md>

The little markdown element that can.

Demo

Features

  • Anything marked can do
  • Code highlighting with highlight.js
  • Custom syntax highlighting themes
  • Inject custom styles into the Shadow DOM

Installation

Option 1: In your markup.

<script>
  import "//unpkg.com/@snappywc/md";
</script>

Option 2: As a package.

npm install @snappywc/md -P
import '@snappywc/md'

Usage

Render a Remote File

<snappy-md src="https://raw.githubusercontent.com/jameslovallo/snappy/main/packages/carousel/README.md"></snappy-md>

Render Inline Markdown

<snappy-md>
  # Heading

  - List item
  - List item

  [A link](https://example.com)
</snappy-md>

A note about rendering inline code blocks:

It is always unsafe to include unescaped HTML blocks in your page's markup. If you want to highlight an inline code block between <snappy-md> tags, wrap the code in the special html comment <!--safe ... safe-->. This will allow you to safely include your code snippet, but it also helps preserve code formatting because prettier and beautify will ignore formatting for HTML comments. The comments will be removed automatically when the code is highlighted, leaving you with a perfect-looking code snippet.

Styling

<snappy-md> provides a theme attribute that you can use to change the syntax highlighting theme. Any highlight.js theme is support, and you can find additional unoffical themes online. You may be wondering why highlight.js instead of Prism.js, and the answer is simple: highlight.js supports many more languages out of the box.

You can also nest a style tag inside the element to pass styles into the Shadow DOM.

Custom highlight.js Theme

<snappy-md theme="https://unpkg.com/@highlightjs/[email protected]/styles/night-owl.min.css"></snappy-md>

Injecting a Style Tag

<snappy-md>
  # Heading

  - List item
  - List item

  [A link](https://example.com)
  
  <style>
    h1 {color: blue;}
    ul {color: orange;}
    a {color: green;}
  </style>
</snappy-md>

MDX-Like Components in Markdown

Since marked allows HTML in markdown, and web cumponents work anywhere, you can use custom elements inside your markdown without worrying about compatability with 3rd-party frameworks. It's amazing how simple life can be when you #usetheplatform.

<snappy-md>
  # Weeee, web components in markdown!

  - Super easy
  - Works everywhere

  <script type="module">
    import "//unpkg.com/@snappywc/carousel"
  </script>

  <snappy-carousel style="--mobile: 50%; --gap: 8px;">
    <img src="//picsum.photos/seed/1/400/250" />
    <img src="//picsum.photos/seed/2/400/250" />
    <img src="//picsum.photos/seed/3/400/250" />
  </snappy-carousel>

  ## What a nice carousel

  You get the idea.
</snappy-md>