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

@readme/syntax-highlighter

v13.1.0

Published

ReadMe's React-based syntax highlighter

Downloads

15,464

Readme

@readme/syntax-highlighter

ReadMe's React-based syntax highlighter based on CodeMirror and react-codemirror2

npm Build

Installation

npm install --save @readme/syntax-highlighter

Usage

Read Only Mode

const syntaxHighlighter = require('@readme/syntax-highlighter');
const ele = syntaxHighlighter('console.log("Hello, world!");', 'js');

Read Only with Line Numbers

const syntaxHighlighter = require('@readme/syntax-highlighter');
const ele = syntaxHighlighter('console.log("Hello, world!");', 'js', { ...opts, highlightMode: true });

Read Only with Line Numbers and Highlighted Ranges

const syntaxHighlighter = require('@readme/syntax-highlighter');
const ele = syntaxHighlighter('console.log("Hello, world!");', 'js', {
  ...opts,
  highlightMode: true,
  ranges: [
    [
      { ch: 0, line: 0 },
      { ch: 0, line: 1 },
    ],
  ],
});

Full CodeMirror

Access to a full code Mirror instance. See configuration settings in the react-codemirror2 library

const syntaxHighlighter = require('@readme/syntax-highlighter');
const ele = syntaxHighlighter('console.log("Hello, world!");', 'js', { ...opts, editable: true }, { ...editorProps });

Available Options

| Name | Type | Description | | :--- | :--- | :--- | | customTheme | String | Highlighting theme. One of neo, material-palenight, or tomorrow-night. (Setting this will override the dark mode option.) | dark | Boolean | Enable dark mode. | | editable | Boolean | Enable the full CodeMirror instance | | highlightMode | Boolean | Enable line number display. | | inline | String | Wrap code in a <span> tag, instead of a <div>. | | ranges | Array | Ranges of line numbers to apply highlighting to. Requires highlightMode enabled | | tokenizeVariables | Boolean | Match and render ReadMe variables in your markdown. |

Languages Supported

| Language | Available language mode(s) | | :--- | :--- | | ASP.NET | asp, aspx | | C | c | | C++ | c++, cpp, cplusplus | | C# | cs, csharp | | Clojure | clj, cljc, cljx, clojure | | CSS | css, less, sass, scss, styl, stylus | | cURL | curl | | D | d | | Dart | dart | | Docker | dockerfile | | Erlang | erl, erlang | | Go | go | | GraphQL | gql, graphql | | Groovy | gradle, groovy | | Handlebars | handlebars, hbs | | HTML/XML | html, xhtml, xml | | HTTP | http | | Java | java | | JavaScript | coffeescript, ecmascript, javascript, js, jsx, node | | JSON | json | | Julia | jl, julia | | Kotlin | kotlin, kt | | Liquid | liquid | | Markdown | markdown | | Objective-C | objc, objectivec, | | Objective-C++ | objc++, objcpp, objectivecpp, objectivecplusplus, | | OCaml | ocaml, ml | | Perl | perl, pl | | PHP | php | | PowerShell | powershell, ps1 | | Python | py, python | | R | r | | React | jsx | | Ruby | jruby, macruby, rake, rb, rbx, ruby | | Rust | rs, rust | | Scala | scala | | Shell | bash, sh, shell, zsh | | SQL | cql, mssql, mysql, plsql, postgres, postgresql, pgsql, sql, sqlite | | Swift | swift | | TOML | toml | | TypeScript | ts, typescript | | YAML | yaml, yml |