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

@mvarble/markdown-compiler

v1.0.5

Published

A cycle.js driver which compiles markdown into Snabbdom streams.

Downloads

5

Readme

Note. This project has been moved to cycle-markdown.

markdown-compiler

This is a Cycle.js component which converts a Markdown stream into that of Snabbdom. The Markdown-to-Snabbdom processing is handled by a unified processor and a collection of user-provided cycle components. As a use case, suppose I had the following Markdown for some page on a website.

# This is a title

Here is some text and a nice little Carousel of images that the user can click through to navigate.

<carousel>
  <img src="/img/1.png">
  <img src="/img/2.png">
  <img src="/img/3.png">
  <img src="/img/4.png">
</carousel>

Here are my most recently read books; showing these amounts to looking at the current state of a database.

<recent-books></recent-books>

Of course, some of this page is vanilla Markdown which can be converted, but the <carousel> and <recent-books> tags are nonstandard. Moreover, these tags may require event callbacks and asynchronous server requests. Writing Cycle.js components that act accordingly will be easy by interfacing with sources.DOM, sources.HTTP, sinks.DOM, sinks.HTTP, and the like; however, I don't want to write new apps for each new page I create on my website. This is particularly the case with a component like <carousel>, which I may repeatedly want to reuse in a blog or something of this form.

The purpose of this package is to allow the user to write a Cycle.js component like carousel of the usual sources => sinks structure and mount said component to the corresponding tag.

Writing Components

A component is able to use any sources the user would like, along with the provided sources.staleDom, which is a Snabbdom stream corresponding to the Snabbdom seralization of the HTML tag provided in the Markdown file. A component currently is only capable of manipulating the DOM and sending HTTP requests. For the former, the component should use @cycle/state functionality; that is, it should return a reducer stream of functions (previousState) => state, where the state is an object with { DOM: <Snabbdom> }. For the latter, the component should return the request to its sink.HTTP. Custom sinks will be provided in the future.

Mounting Components

By using makeMarkdownCompiler, the user may mount the components they'd like:

// no babel
const makeMarkdownCompiler = require('@mvarble/markdown-compiler').makeMarkdownCompiler;

// babel
import { makeMarkdownCompiler } from '@mvarble/markdown-compiler';

// ... create some components
function carousel(sources) {
  ...
  return { 
    state: reducerStream$
  };
}

// mount them
const app = makeMarkdownCompiler({ 'carousel': carousel });

// use withState from @cycle/state and run from @cycle/run to see!
run(withState(app), { markdown: () => someMarkdownStream$ });

As hinted, the app will take sources.markdown as the stream for parsing. Everything else from that point is handled!