Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@readme/syntax-highlighter

Package Overview
Dependencies
Maintainers
12
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@readme/syntax-highlighter

ReadMe's React-based syntax highlighter

  • 13.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.7K
increased by14.21%
Maintainers
12
Weekly downloads
 
Created
Source

@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

NameTypeDescription
customThemeStringHighlighting theme. One of neo, material-palenight, or tomorrow-night. (Setting this will override the dark mode option.)
darkBooleanEnable dark mode.
editableBooleanEnable the full CodeMirror instance
highlightModeBooleanEnable line number display.
inlineStringWrap code in a <span> tag, instead of a <div>.
rangesArrayRanges of line numbers to apply highlighting to. Requires highlightMode enabled
tokenizeVariablesBooleanMatch and render ReadMe variables in your markdown.

Languages Supported

LanguageAvailable language mode(s)
ASP.NETasp, aspx
Cc
C++c++, cpp, cplusplus
C#cs, csharp
Clojureclj, cljc, cljx, clojure
CSScss, less, sass, scss, styl, stylus
cURLcurl
Dd
Dartdart
Dockerdockerfile
Erlangerl, erlang
Gogo
GraphQLgql, graphql
Groovygradle, groovy
Handlebarshandlebars, hbs
HTML/XMLhtml, xhtml, xml
HTTPhttp
Javajava
JavaScriptcoffeescript, ecmascript, javascript, js, jsx, node
JSONjson
Juliajl, julia
Kotlinkotlin, kt
Liquidliquid
Markdownmarkdown
Objective-Cobjc, objectivec,
Objective-C++objc++, objcpp, objectivecpp, objectivecplusplus,
OCamlocaml, ml
Perlperl, pl
PHPphp
PowerShellpowershell, ps1
Pythonpy, python
Rr
Reactjsx
Rubyjruby, macruby, rake, rb, rbx, ruby
Rustrs, rust
Scalascala
Shellbash, sh, shell, zsh
SQLcql, mssql, mysql, plsql, postgres, postgresql, pgsql, sql, sqlite
Swiftswift
TOMLtoml
TypeScriptts, typescript
YAMLyaml, yml

FAQs

Package last updated on 12 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc