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-component

v1.1.0

Published

component that offers a textarea as input for markdown formatted text, and a div that outputs the rendered markdown

Downloads

13

Readme

markdown-component

Stability Experimental

barebones component that offers a textarea as input for markdown formatted text, and a div that outputs the rendered markdown.

a markdown editing nanocomponent

example screenshot

Usage

var MarkdownComponent = require('markdown-component')

var md = new MarkdownComponent()
var component = md.render('# title\n - list item', {
  component: {
    classes: 'flex justify-center'
  },
  textarea: {
    classes: 'outline w-50 pa3 mr2'
  },
  div: {
    classes: 'outline w-50 pa3 mr2'
  }
})

API

// default
var markdownComponent = require('markdown-component')
var md = new MarkdownComponent()
var component = md.render()

md.render: String|Object

  • String: (optional), markdown formatted string
  • Object: (optional), options for the rendered elements

options object

}
  component: {
    classes: 'classes for the containg div'
  },
  textarea: {
    classes: 'classes for the textarea element'
  },
  div: {
    classes: 'classes for the the output div'
  },
  onDrop: `Function|Boolean` 
    // Defualt: Adds markdown syntax for an image blob to the text editor, and renders the image in the output.
    // Implementing your own `onDrop` function will override the default onDrop function.
    // Setting `onDrop: false` will prevent the text editor from doing anything with file drag and drops.
}

Example

var choo = require('choo')
var html = require('choo/html')
var css = require('sheetify')
var strftime = require('strftime')
var MarkdownComponent = require('markdown-component')

css('tachyons')

var app = choo()
if (process.env.NODE_ENV !== 'production') {
  app.use(require('choo-devtools')())
}

app.route('/*', view)

module.exports = app.mount('body')

function view (state, emit) {
  var time = strftime('%B %d %Y - %X')
  var md = new MarkdownComponent()
  var component = md.render('# wow\n - cool', {
    component: {
      classes: 'flex justify-center'
    },
    textarea: {
      classes: 'outline w-50 pa3 mr2'
    },
    div: {
      classes: 'outline w-50 pa3 mr2'
    }
  })
  return html`
    <body class="code lh-copy">
      <main class="cf center">
        <section class="f6 ttu fw6 mt0 mb3 bb pb2 pa3">
          <h2>${time}</h2>
        </section>
        <form id=${time}>
          ${component}
        </form>
      </main>
    </body>
  `
}

Install

With npm installed, run

$ npm install markdown-component

Todo

  • [ ] Write tests
  • [ ] Expand on documentation
  • [ ] Explore if this is even a good idea

License

MIT