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

@peaceroad/markdown-it-renderer-fence

v0.1.1

Published

In code blocks, the `<samp>` tag is used with the language keywords `samp`, `shell`, and `console`, and provides an option to display line numbers.

Downloads

2

Readme

p7d-markdown-it-renderer-fence

In code blocks, the <samp> tag is used with the language keywords samp, shell, and console.

To add specific styles to code blocks and display line numbers in code blocks, enclose each line in a span element and set CSS.

Use

It is assumed that you will use highlight.js and markdown-it-attrs together. It will probably work without them though.

import mdit from 'markdown-it'
import mditAttrs from 'markdown-it-attrs'
import highlightjs from 'highlihgtjs'
import mditRendererFence from '@peaceroad/markdown-it-renderer-fence'

const md = mdit({
             langPrefix: 'language-',
             highlight: (str, lang) => {
             if (lang && highlightjs.getLanguage(lang)) {
               try {
                  return highlightjs.highlight(str, { language: lang }).value
               } catch (__) {}
             }
             return ''
           }).use(mditAttrs).use(mditRendererFence)


const htmlCont = md.render('...')

It is also intended to be used in conjunction with @peaceroad/markdown-it-figure-with-p-caption.

Code block to samp block

[Markdown]
```samp
$ pwd
/home/User
```
[HTML]
<pre><samp>$ pwd
/home/User
</samp></pre>


[Markdown]
```shell
$ pwd
/home/User
```
[HTML]
<pre><samp class="language-shell"><span class="hljs-meta prompt_">$ </span><span class="language-bash"><span class="hljs-built_in">pwd</span></span>
/home/User
</samp></pre>


[Markdown]
```console
$ pwd
/home/User
```
[HTML]
<pre><samp class="language-console"><span class="hljs-meta prompt_">$ </span><span class="language-bash"><span class="hljs-built_in">pwd</span></span>
/home/User
</samp></pre>

Add span elements to display line number, and style attribute.

Add start or data-pre-start attribute by adding attributes used markdown-it-attrs.

```js {.style start="1"}
import mdit from 'markdonw-it'
const md = mdit()
md.render('Nyaan')
```
<pre><code class="language-js style" data-pre-start="1" style="counter-set:pre-line-number 1;"><span class="pre-line"><span class="hljs-keyword">import</span> mdit <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;markdonw-it&#x27;</span></span>
<span class="pre-line"><span class="hljs-keyword">const</span> md = <span class="hljs-title function_">mdit</span>()</span>
<span class="pre-line">md.<span class="hljs-title function_">render</span>(<span class="hljs-string">&#x27;Nyaan&#x27;</span>)</span>
</code></pre>

CSS example: https://codepen.io/peaceroad/pen/qBGpYGK