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

remark-css-selectors

v1.0.1

Published

Adding class and id attribute to AST tree (not standard markdown syntax)

Downloads

36

Readme

about

This is extension plugin for remark markdown library whitch based on unified framework. It's allows you add id and css attributes to markdown language. Extension works with rehype by using hProperties.

installation

npm install remark-css-selectors

examples

{.big-head}# h3 Heading   
{.heading}#### h4 Heading {.line}~~Strikethrough~~  
##### h5 Heading {.w-800 text-red}**This is bold text**  {.lite}_This is italic text_

will output

<h1 class="big-head">h3 Heading</h1>
<h4 class="heading">h4 Heading  
    <del class="line">Strikethrough</del>  
</h4>  
<h5>h5 Heading <strong class="w-800 text-red">This is bold text</strong> <em class="lite">This is italic text</em></h5>
{.h2}{#hJs}## New rules
  
{#specilaLine}---

{.line-through}***  
  
{.quotes-title}## Blockquotes  
  
{.block}> Blockquotes can also be nested...  
>> ...by using additional greater-than signs right next to each other...  
> > > ...or with spaces between arrows.
<h2 class="h2" id="hJs">New rules</h2>
<hr id="specilaLine">  
<hr class="line-through">  
<h2 class="quotes-title">Blockquotes</h2>  
<blockquote class="block"><p>Blockquotes can also be nested...</p>  
 <blockquote><p>...by using additional greater-than signs right next to each other...</p>  
	 <blockquote>
		 <p>...or with spaces between arrows.</p>
	 </blockquote>  
 </blockquote>
</blockquote>
Inline {.code}`code`  
  
{.sample sample--red}```  
Sample text here...  
.```  
  
Syntax highlighting  
  
{#code}{.code-js}``` js  
var foo = function (bar) {  
 return bar++;};  
  
console.log(foo(5));  
.```
<p>Inline <code class="code">code</code></p>  
<pre>
	<code class="sample sample--red">Sample text here... </code>
</pre>  
<p>Syntax highlighting</p>  
<pre>
	<code class="code-js" id="code">
	var foo = function (bar) { return bar++; }; console.log(foo(5)); 
	</code>
</pre>
  1. with custom blocks
{.sm-col-6}[[block]]  
|{.pargraph-class} {#img-id}![Minion](https://....)  
|{.img-class}![Stormtroopocat](https://.... "The Stormtroopocat")  
  
you need one space in front to assign id to image not to paragraph  
 {#image}![Alt text][id]
<div class="custom-block custom-block sm-col-6">  
 <div class="custom-block-body">  
	 <p class="pargraph-class">
		 <img id="img-id" src="https://..." alt="Minion" >  
		 <img class="img-class" src="https://..." >  
	 </p> 
  </div>
 </div>
<p> you need one space in front to assign id to image not to paragraph 
	<img id="image" src="https://..." >
</p>

usage

import unified from 'unified'  
import parse from 'remark-parse';  
import selectors from 'ramark-css-selectors';
//import remarkCustomBlocks from 'remark-custom-blocks'  
import remark2rehype from "remark-rehype";  
import doc from'rehype-document';  
import format from'rehype-format';  
import html from 'rehype-stringify';

 let document = unified()  
    .use(parse)  
    .use(selectors)  
//  .use(remarkCustomBlocks, {  
//      block: {  
//          classes: 'custom-block'  
//      },  
//  })  
    .use(remark2rehype)
    .use(doc)  
    .use(format)  
    .use(html)  
    .processSync(md);
    
console.log(document.contents)
const processed = unified()
    .use(parse)
    .use(remarkAttr)
    .use(remark2rehype)
    .use(rehypeReact, {createElement: React.createElement})
    .processSync(md);
// will return react elemt
return processed.result;