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

gist-to-prismjs

v1.0.1

Published

Converts embedded GitHub gists into PrismJS code blocks.

Downloads

5

Readme

gist-to-prismjs

Converts embedded GitHub gists into PrismJS code blocks.

Takes an input file of any type and searches it for embedded gist <script> tags that look something like this:

<script src="https://gist.github.com/lonekorean/6042c732c624d53b105fa03abcecc597.js"></script>

The code within each gist is fetched and put directly into PrismJS-compatible code blocks that look something like this:

<pre><code class="language-javascript">var dataURL = canvas.toDataURL();</code></pre>

A new file is created for you with all the aforementioned gist <script> tags replaced with PrismJS code blocks.

How To Use

Make sure you have Node.js installed. Then open your terminal to this package's directory and run npm install.

The easiest thing to do is put the file you want to convert into this package's directory, then run the following command (replacing arguments as needed):

node index.js --input=file.txt --user=github_username --pass=github_password

In this case, a file named file-output.txt will be created with all the replacements.

Done!

Rate Limiting

You technically don't need to provide --user and --pass, but without them GitHub will severely limit you to 60 API requests per hour. If you have more than 60 gists to convert, then they won't all succeed. By providing --user and --pass the limit goes up to 5,000 per hour.

If you have 2FA enabled on your GitHub account or just prefer not to use your actual password on the command line (respect) then you can use a personal API token. It's easy to create one and you simply use it for --pass instead of your GitHub password.

Command Line Arguments

You can use command line arguments to control how the script runs.

--input

  • Type: String

The file to process. Can be any file type. The output file will have the same filename as the input file, except suffixed with "-output".

--user

  • Type: String

Your GitHub username. Not required, but providing it (along with --pass) will substantially increase the number of gists that can be converted. See the Rate Limiting section above.

--pass

  • Type: String

Your GitHub password or API token. Not required, but providing it (along with --user) will substantially increase the number of gists that can be converted. See the Rate Limiting section above.

--escape

  • Type: String
  • Default: htmlencode

Code blocks typically require some sort of treatment to ensure that the code renders correctly (especially with HTML). There are several options for how to handle this.

| Value | Description | | - | - | | htmlencode | Encodes < and > to &lt; and &gt;. | | script | Wraps code blocks with specialized <script> tags, compatible with the unescaped-markup plugin. | | comment | Wraps the code inside of code blocks in an HTML comment (<!-- -->), compatible with the unescaped-markup plugin. | | none | Does no additional processing. Useful if you have your own additional processing to take care of things. Be warned, by itself, this can lead to improperly rendered code blocks. |