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

@shawspring/remark-container

v0.0.3

Published

This is a remark plugin to wrap something in custom containers, based on remark-directive

Downloads

13

Readme

What is this?

This is a remark plugin to wrap something in custom containers, based on remark-directive. you can passing arbitrary attributes to container, see remark-attr for more details.

for example: :::container{class="grid grid-cols-2"} will easily implement a grid layout.
the render result preview

install

:::container{class="grid grid-cols-2"}

npm install @shawspring/remark-container
yarn add @shawspring/remark-container 

:::

usage

[!NOTE] remark-directive is required before remark-container.

Say our document example.md contains:

# How to use remark-container

:::container{.cls1 .cls2 style="color: red"}
some **content**

>[!note] 
> this is a note
:::

…and our module example.js contains:

import rehypeFormat from 'rehype-format'
import rehypeStringify from 'rehype-stringify'
import remarkDirective from 'remark-directive'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import {read} from 'to-vfile'  
import {unified} from 'unified'

import remarkContainer from '@shawspring/remark-container'

const file = await unified()
    .use(remarkParse)
    .use(remarkDirective) 
    .use(remarkContainer,{attributes:{class:"container",style:"display:grid;grid-template-columns: 1fr 1fr;grid-gap: 1em;"}})
    .use(remarkRehype)
    .use(rehypeFormat)
    .use(rehypeStringify)
    .process(await read('example.md'));
console.log(String(file))

…then running node example.js yields:

<h1>How to use remark-container</h1>
<div class="container cls1 cls2" style="display:grid;grid-template-columns: 1fr 1fr;grid-gap: 1em; color: red">
  <p>some <strong>content</strong></p>
  <blockquote>
    <p>
      [!note]
      this is a note
    </p>
  </blockquote>
</div>

config

  • @param {Object} config - optional,The configuration object.
  • @param {string} config.name -optional, The container identifier behind :::.
  • @param {Object} config.attributes -optional, default attributes applied to all containers.

Examples

implement steps:

steps.png

or see website

the source code is as follows:

:::container{.steps-container .not-prose} 
1. install remark-container
```bash
npm install @shawspring/remark-container
```

1. import remark-container
```ts
import remarkContainer from '@shawspring/remark-container'
```

1. use remark-container
```ts
  ...
```
::: 

and css file as follows:

<style is:global>
    .steps-container {
        counter-reset: steps-counter;
        --bullet-size: 1.5em;
        --w-left: calc(var(--bullet-size) + 1em);
        --margin-bottom: 1em;
    }
    .steps-container > :not(ol) {
        padding-inline-start: var(--w-left);
        margin-bottom: var(--margin-bottom);
        position: relative;
    }
    .steps-container > ol {
        list-style: none;
        counter-increment: steps-counter;
        padding-inline-start: var(--w-left);
        position: relative;
    }
    .steps-container > ol::before {
        content: counter(steps-counter);
        position: absolute;
        inset-inline-start: 0;
        bottom: 0;
        box-sizing: content-box;
        width: var(--bullet-size);
        height: var(--bullet-size);
        line-height: var(--bullet-size);
        text-align: center;
        border-radius: 50%;
        border: 2px solid steelblue;
    }
    .steps-container > ol:hover::before {
        background-color: steelblue;
    }
    .steps-container > :not(ol):not(:last-of-type)::before {
        content: '';
        position: absolute;
        inset-inline-start: calc(var(--bullet-size) / 2 + 2px); 
        top: 0;
        bottom:calc(var(--margin-bottom) * -1); 
        box-sizing: border-box;
        border: 1px solid grey; 
    }
</style>