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

markdown-it-github-preamble

v1.0.0

Published

Markdown It! plugin for parsing and rendering GitHub flavoured markdown YAML preambles Edit

Downloads

623

Readme

Markdown It! plugin for YAML preambles

This plugin can turn fenced code blocks at the start of your markdown files into tables, replicating functionality from GitHub flavoured markdown, commonly required for static site generators such as Jekyll. Originally built for Appraise.

Turns blocks like these:

---
fixture: fixtures/path.js
---

Into tables like this:

Quick summary of features

  • By default, renders a table with property names and values
  • Optionally adding a CSS class or marker HTML attributes to the table for easy identification
  • Easily configurable to use different block markers
  • Supports pluggable rendering, so you can easily display the results it differently
  • Works with js-yaml, so it parses almost any valid YAML easily

Status

Stable, production worthy, nicely unit tested. Tested with js-yaml 3.9.0 and markdown-it 8.3.1.

Install

Grab it from NPM:

npm i markdown-it-github-preamble -S

Usage

The plugin works the same way Markdown It! plugins work, so just .use it:

const Markdown = require('markdown-it'),
	markdownItGithubPreamble = require('markdown-it-github-preamble'),
  md = new Markdown().use(markdownItGithubPreamble);

console.log(md.render(
`---
propa: vala
propb: valb
---

abcd
`));

You can also supply additional options and customise the plugin:

const Markdown = require('markdown-it'),
	markdownItGithubPreamble = require('markdown-it-github-preamble'),
  md = new Markdown().use(markdownItGithubPreamble, {className: 'preamble'});

console.log(md.render(
`---
propa: vala
propb: valb
---

abcd
`));

Options

See the unit tests for examples of how to use all these options.

  • className: (string) a CSS class that will be added to the root table element of the preamble, for easy styling.
  • tableAttributeName and tableAttributeValue: (string) the name and value of a HTML attribute that will be added to the root table element of the preamble, for easy identification in DOM parsers.
  • marker: (string) the fence character identifying the YAML preamble block (by default, '-')
  • render: (function) a custom Markdown It! rendered to use for turning the preamble tokens into HTML, instead of a table.
  • name: (string) internal identifier for the plugin, used as a prefix for tokens and renderers. Change it to avoid conflicts with other plugins using similar token names. By default, it's preamble

License

MIT, see the License