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

@phucbm/gfm

v0.0.1

Published

Turn markdown text into GitHub Flavoured Markdown with light/dark code syntax highlight.

Downloads

8

Readme

@phucbm/gfm

pages-build-deployment

Turn Markdown text into GitHub Flavored Markdown (GFM) with light/dark code syntax highlight.

What is this?

Ever want to just write Markdown for your app, then make it to HTML with the styling from GitHub, along with code syntax highlight? This project was made for you.

Install

Install with npm:

npm i @phucbm/gfm

# webpack loader for markdown
npm i markdown-loader

# styling for GFM
npm i github-markdown-css

Use

Convert Markdown format using markdown-loader by markedjs

Say our document example.md contains:

# GFM

## Autolink literals

www.example.com, https://example.com, and [email protected].

## Footnote

A note[^1]

[^1]: Big note.

## Strikethrough

~one~ or ~~two~~ tildes.

## Table

| a | b | c | d |
| - | :- | -: | :-: |

## Tasklist

* [ ] to do
* [x] done

To be able to read the .md file format, add markdown-loader to your webpack.config.js

// webpack.config.js
export default {
    module: {
        rules: [
            {
                test: /\.md$/,
                use: [
                    {
                        loader: "html-loader",
                    },
                    {
                        loader: "markdown-loader",
                        options: {
                            // Pass options to marked
                            // See https://marked.js.org/using_advanced#options
                        },
                    },
                ],
            },
        ],
    },
};

…and our module example.js looks as follows:

import markdownText from "./example.md";
import 'github-markdown-css/github-markdown.css';

// the Markdown text will be converted to HTML text using "markdown-loader"
console.log(markdownText);

const content = document.querySelector('#content');

// insert the HTML text to the DOM
content.insertAdjacentHTML('beforeend', markdownText);

See how it looks like.

Code highlight

Your Markdown code block must have a language identifier like in the example.md, then run highlightCodeSyntax() only when the HTML has loaded.

import {highlightCodeSyntax} from "../src/code-syntax-highlight";

// insert HTML

// code highlight (only run once the HTML as loaded)
highlightCodeSyntax().then();

Info Check the folder example for demo files.

API

highlightCodeSyntax(codeBlocks)

Loop through all <code> in the DOM and replace with highlighted code syntax.

Parameters
  • codeBlocks - HTMLElement, optional.
Return

{Promise<HTMLElement[]>}

Development

Clone this repo, then:

# install
npm i

# run dev server
npm run dev

License

MIT © Phuc Bui