Socket
Socket
Sign inDemoInstall

@readme/syntax-highlighter

Package Overview
Dependencies
140
Maintainers
10
Versions
119
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @readme/syntax-highlighter

ReadMe's React-based syntax highlighter


Version published
Weekly downloads
960
decreased by-35.4%
Maintainers
10
Install size
23.6 MB
Created
Weekly downloads
 

Readme

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

Last updated on 05 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc