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

metalsmith-data-markdown

v0.0.3

Published

A Metalsmith plugin to use markdown content within html tags (with data-markdown attribute)

Downloads

203

Readme

#metalsmith-data-markdown

A Metalsmith plugin to use markdown content within html tags via data-markdown attribute

Parses markdown (via marked) and inserts generated html in all tags that have the data-markdown attribute set (via cheerio).

Based on idea and code by Paul Irish. His implementation is currently used in reveal.js, a presentation framework. Likewise, this metalsmith plugin might become handy, if you want to compile these presentations down to HTML(during generation time with metalsmith.
Extracted from majodev.github.io.

As part the my note "Extracting libs from a node.js project: Publishing my metalsmith plugins".

Installation

npm install --save metalsmith-data-markdown

Usage

var Metalsmith = require("metalsmith");
var datamarkdown = require("metalsmith-data-markdown");

Metalsmith(__dirname)
  // ... state when html files are available
  .use(datamarkdown())
  // ...

Should also work in similar fashion with the metalsmith.json counterpart.

Options

datamarkdown accepts an hash to provide a few customization options.

marked (optional)

Object: Options you want to hand over to marked. Will get invoked via marked.setOptions(options.marked);. default: undefined

removeAttributeAfterwards (optional)

Boolean: If data-markdown attributes should be removed from tags after they were processed. default: false

Full example with options set

Here's how this will work with some marked options set + full input and output.

metalsmith config

var Metalsmith = require("metalsmith");
var headingsidentifier = require("metalsmith-headingsidentifier");


Metalsmith(__dirname)
  // ... state when html files are available
  .use(datamarkdown({
    marked: {
      gfm: true,
      breaks: true,
      tables: true,
      smartLists: true,
      smartypants: true
    },
    removeAttributeAfterwards: true
  }))
  // ...

html example input

<!-- ... -->
<section>
<section id="paper-esecurity-cover" data-markdown>
### WLAN Security Revisited (paper)
#### Rogue AP, Deauthentication Attack and Portal via PwnSTAR in 2 Minutes
published on June 2012
<small>FH JOANNEUM information management master</small>
</section>
<section id="paper-esecurity-video" data-markdown>
<iframe width="640" height="480" src="//www.youtube.com/embed/vy4leX_twTw" frameborder="0"></iframe>
*"Creating a Rogue Access Point with redirecting web portal and hijacking open wifi users via de-authentication attack."*
</section>
</section>
<!-- ... -->

html example output


<section>
  <section id="paper-esecurity-cover">
    <h3>WLAN Security Revisited (paper)</h3>
    <h4>Rogue AP, Deauthentication Attack and Portal via PwnSTAR in 2 Minutes</h4>
    <p>published on June 2012<br><small>FH JOANNEUM information management master</small></p>
  </section>
  <section id="paper-esecurity-video">
    <p><iframe width="640" height="480" src="//www.youtube.com/embed/vy4leX_twTw" frameborder="0"></iframe><br><em>“Creating a Rogue Access Point with redirecting web portal and hijacking open wifi users via de-authentication attack.”</em></p>
  </section>
</section>

Problems?

File an issue or fork 'n' fix and send a pull request.

License

(c) 2014 Mario Ranftl
MIT License