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/cycle-markdown

v0.0.1

Published

Custom Markdown in Cycle.js

Downloads

1

Readme

cycle-markdown

This is a package that creates Cycle.js components that that resolve markdown streams to subsequent Cycle.js components whose sinks are merged according to user's control. The intention of this is so that the user could write some sort of markdown like:

# 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 route="/db/books"></recent-books>

and have each custom tag like <carousel> or <recent-books> resolve to Cycle.js components of which we may merge the sinks into the drivers of our app.

The package is designed as follows; we firstly have a function makeMarkdownCompiler which serves to generate components of form ({ markdown, ...otherSources }) => sinks, where markdown is a stream of strings we would like to compile. The compilation in big picture works as follows.

  1. The MarkdownCompiler uses a provided compiler (like one from the unified collection) that resolves Markdown+html to a snabbdom tree.
  2. The MarkdownCompiler uses a provided object components; any part of the snabbdom tree of the form <custom-tag></custom-tag> with components['custom-tag'] being defined will now be replaced with the DOM sink of components['custom-tag'].
  3. All other sinks are merged with an isolation scope corresponding to the location within the tree.

makeMarkdownCompiler

MarkdownCompiler = makeMarkdownCompiler({
  compiler: markdownStringToSnabbdom,
  components: { 'carousel': Carousel, 'recent-books': RecentBooks },
  domKey: 'DOM',
  vdomKey: 'vdom',
  sinkKeys: ['state', 'viewport', 'HTTP'],
})

In an execution like the one above, markdownStringToSnabbdom is the function which is used in the first step of the procedure delineated in the previous section. The object { 'carousel': Carousel, 'recent-books': RecentBooks } is our way of providing the compiler the (custom tag, component) pairs necessary in the second step of the procedure. The domKey is the key we assume all the components use in keying the dom stream in their sink; it is optional and 'DOM' by default. Each component will be given a copy of the snabbdom element that it is replacing, so that it may parse the attributes accordingly; the vdomKey corresponds to the key the components will use to get this stream out of its sources. This key is optional and is 'vdom' by default. The sinkKeys array corresponds to the non-DOM sink keys we desire from the final component. Each of these keys will correspond to the merged stream of the component streams corresponding to these keys; any component without such a sink will be opted to xs.empty().

Non-Fractal

It is important to note that we are prohibited from putting multiple layers of custom components in our markdown.

<custom-component-1>
  <custom-component-2></custom-component-2>
</custom-component-1>

Will only replace <custom-component-1> with its resolved app, and in its vdom source, it will have the snabbdom element with that of <custom-component-2> as a child.