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

hs-marked-extra

v1.0.2

Published

Feature extension for marked

Downloads

10

Readme

hs-marked-extra

This module is kind of a extension to chjj/marked.

Currently feature:

  • admonition

Admonition in this module is a porting of waylan's Python-Markdown admonition. More infomation about that can be found here. With CSS, admonition can make your rendered page more beautiful and expressive.

For example text below:

!!! note "Don't forget to drink water"
    first line here.

    second line here.

will produce:

<div class="admonition note">
<p class="admonition-title">Don't forget to drink water</p>
<p>first line here.</p>
<p>second line here.</p>
</div>

In the above example, the word "note" is considered as level, the string "Don't forget to drink water" is considered as title.

If the title is being omitted, then the level string will be the title(with 1st letter capitalized). So

!!! danger
    first line here.

will produce:

<div class="admonition danger">
<p class="admonition-title">Danger</p>
<p>first line here.</p>
</div>

Install

npm install hs-marked-extra --save

Usage

var md = require('hs-marked-extra');

var text = '!!! note "Tile"\n    fist line here.\n';
console.log(md(text, { admonition: true }));

And the API is same with original marked API.

var marked = require('hs-marked-extra');
marked.setOptions({
  renderer: new marked.Renderer(),
  gfm: true,
  tables: true,
  breaks: false,
  pedantic: false,
  sanitize: false,
  smartLists: true,
  smartypants: false,
  admonition: true
});

console.log(marked('!!! note "Tile"\n    fist line here.\n'));

Note: option admonition is false by default, and it doesn't compatable with option sanitize.

Admonition CSS example

in less:

.admonition {                                                                     
  padding: 15px;                                                                  
  margin-bottom: 20px;                                                            
  border: 1px solid transparent;                                                  
  border-radius: 4px;                                                             
  text-align: left;                                                               
  &.note,                                                                         
  &.info,                                                                         
  &.tips {                                                                        
    color: #98802b;                                                               
    background-color: #fff4cc;                                                    
    border-color: #f7d869;                                                        
  }                                                                               
  &.warning,                                                                      
  &.important {                                                                   
    color: #a06510;                                                               
    background-color: #fac170;                                                    
    border-color: #d88d21;                                                        
  }                                                                               
  &.danger,                                                                       
  &.critical {                                                                    
    color: #b94a48;                                                               
    background-color: #f2dede;                                                    
    border-color: #eed3d7;                                                        
  }                                                                               
}                                                                                 
                                                                                  
.admonition-title {                                                               
  font-weight: bold;                                                              
  text-align: left;                                                               
}

Or in CSS:

.admonition {                                                                     
  padding: 15px;                                                                  
  margin-bottom: 20px;                                                            
  border: 1px solid transparent;                                                  
  border-radius: 4px;                                                             
  text-align: left;                                                               
}                                                                                 

.admonition.note,                                                                 
.admonition.info,                                                                 
.admonition.tips {                                                                
  color: #98802b;                                                                 
  background-color: #fff4cc;                                                      
  border-color: #f7d869;                                                          
}                                                                                 

.admonition.warning,                                                              
.admonition.important {                                                           
  color: #a06510;                                                                 
  background-color: #fac170;                                                      
  border-color: #d88d21;                                                          
}                                                                                 

.admonition.danger,                                                               
.admonition.critical {                                                            
  color: #b94a48;                                                                 
  background-color: #f2dede;                                                      
  border-color: #eed3d7;                                                          
}                                                                                 

.admonition-title {                                                               
  font-weight: bold;                                                              
  text-align: left;                                                               
}

License

MIT