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

pimd

v0.6.0

Published

Processing instructions for Markdown

Downloads

37

Readme

PIMD

Build status (Travis CI) Dependency status (Greenkeeper) JavaScript Style Guide

Processing Instructions for MarkDown.

PIMD will be the base for the JavaScript version of LivingStyleGuide – an API to extend Markdown by DOM manipulations as known from the browsers.

Main targets

  • Easy to use in JavaScript projects – in build tools and within the browser
  • Focus on extendibility: The DOM tree known from the browser will be the main API
  • Compliance with the CommonMark specs – Markdown files will render perfectly on GitHub; all additional commands will be CommanMark compliant and won’t leave ugly artifacts when used in README.md files on GitHub

RailsGirls Summer of Code

This project is as part of LivingStyleGuide chosen for the RailsGirls Summer of Code 2018: Our team is @artnerdnet and @dianavile


Setup

npm install --save pimd

Usage

Render inline

const { Document } = require("pimd")
const markdown = `
# Headline
`
const doc = new Document(markdown)
console.log(doc.render())

Result:

<h1>
  Headline
</h1>

Render document

const { Document } = require("pimd")
const markdown = `
# Headline
`
const doc = new Document(markdown)
doc.renderDocument().then(html => {
  console.log(html)
})

Result:

<html>
  <head>
    <title>Headline</title>
  </head>
  <body>
    <h1>
      Headline
    </h1>
  </body>
</html>

Plugins

Plugins unleash the full power of PIMD. The official plugins offer functionality to create living style guides and to improve code documentation in general.

  • Classes: Add classes to code blocks or other elements for easy additional styling
  • ID: Add an ID to code blocks or other elements for easily accessing elements in the HTML preview via JavaScript to bring code examples to live
  • Preview: Add an HTML preview to code blocks for pattern libraries/living style guides
  • Highlight: Visually highlight important parts of code blocks in different background colors
  • Showmore: Hide less important parts of code blocks
  • Prism: Syntax highlighting with PrismJS
  • HTML injector: a plugin to create new plugins that manipulate the code blocks (already used by Highlight and Showmore)

Extending

Output generated data with JavaScript

PIMD extends Markdown with Processing Instructions known from XML. This is compliant with the CommonMark specs.

const { Document } = require("pimd")
const Config = require("pimd/lib/config")

const config = new Config()
config.commands["year"] = () => new Date().getFullYear()

const markdown = `
# Year <?year?>
`
const doc = new Document(markdown, config)
console.log(doc.render())

Result:

<h1>Year 2018</h1>

Accessing the DOM

PIMD uses the DOM internally to provide a well-known API to its users.

const { Document } = require("pimd")
const Config = require("pimd/lib/config")

const config = new Config()
config.commands["important"] = context => {
  context.element.style.background = "yellow"
}

const markdown = `
# Headline <?important?>
`
const doc = new Document(markdown, config)
console.log(doc.render())

Result:

<h1 style="background: yellow">Headline</h1>

Writing plugins

const { Document } = require("pimd")
const Config = require("pimd/lib/config")

const myPlugin = function(config) {
  config.addInfoStringCommand("info", { types: ["string"] }, function(text) {
    const div = this.renderer.dom.window.document.createElement("div")
    div.textContent = text
    this.element.appendChild(div)
  })
}

const config = new Config()
config.use(myPlugin)

const markdown = `
~~~html +info="Hello world!"
<p>Test</p>
~~~
`
const doc = new Document(markdown, config)
console.log(doc.render())

Result:

<div class="pimd-example">
  <div class="pimd-code">
    <pre>
      <code class="lang-html">
        &lt;p&gt;Test&lt;/p&gt;
      </code>
    </pre>
  </div>
  <div>Hello world!</div>
</div>

Tip: Check out the source code of PIMD’s official plugins for further inspiration.


Coding style

PIMD uses the Prettier style for all supported documents. To save the environment, semicolons are not required.


Copyright

Copyright 2018++ Nico Hagenburger. See MIT-LICENSE for details. Get in touch with @hagenburger on Twitter or open an issue.