13.0.0 • Published 29 days ago

@readme/syntax-highlighter v13.0.0

Weekly downloads
2,977
License
ISC
Repository
github
Last release
29 days ago

@readme/syntax-highlighter

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

npm Build

npm.io

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
13.0.0

29 days ago

12.1.5

2 months ago

12.1.3

2 months ago

12.1.2

10 months ago

12.1.1

12 months ago

12.1.0

1 year ago

12.0.2

2 years ago

12.0.1

2 years ago

12.0.0

2 years ago

11.0.0

2 years ago

10.14.4

2 years ago

10.14.2

2 years ago

10.14.3

2 years ago

10.14.0

2 years ago

10.14.1

2 years ago

10.13.2

3 years ago

10.12.0

3 years ago

10.13.0

3 years ago

10.11.1

3 years ago

10.11.0

3 years ago

10.10.1

3 years ago

10.10.0

3 years ago

10.9.0

3 years ago

10.8.0

3 years ago

10.7.0

3 years ago

10.6.0

3 years ago

10.5.0

3 years ago

10.4.5

3 years ago

10.4.4

3 years ago

10.4.3

3 years ago

10.4.2

3 years ago

10.4.1

3 years ago

10.4.0

3 years ago

10.3.1

3 years ago

10.3.0

3 years ago

10.2.0

4 years ago

10.1.2

4 years ago

10.1.1

4 years ago

10.1.0

4 years ago

10.0.1

4 years ago

10.0.0

4 years ago

7.2.3

4 years ago

9.0.1

4 years ago

9.0.0

4 years ago

7.2.2

4 years ago

8.0.3

4 years ago

8.0.2

4 years ago

7.2.1

4 years ago

8.0.1

4 years ago

8.0.0

4 years ago

7.1.0

4 years ago

7.0.0

4 years ago

6.16.1

4 years ago

6.15.2

4 years ago

6.15.1

4 years ago

6.15.0

4 years ago

6.13.0

4 years ago

6.10.2

4 years ago

6.10.0

4 years ago

6.9.6

4 years ago

6.9.4

4 years ago

6.7.0

4 years ago

6.5.0

4 years ago

6.4.0

4 years ago

6.3.5

4 years ago

6.3.4

4 years ago

6.2.0

4 years ago

6.0.15

4 years ago

6.0.10

4 years ago

6.0.5

4 years ago

6.0.3

4 years ago

6.0.2

4 years ago

6.0.0

4 years ago

5.0.0

4 years ago

4.19.2

4 years ago

4.18.2

4 years ago

5.0.0-alpha.4

4 years ago

4.18.0

4 years ago

4.16.0

4 years ago

5.0.0-alpha.0

4 years ago

4.15.0

4 years ago

4.14.0

4 years ago

4.13.0

4 years ago

4.12.1

4 years ago

4.12.0

4 years ago

4.11.0

5 years ago

4.10.5

5 years ago

4.10.3

5 years ago

4.10.0

5 years ago

4.9.0

5 years ago

4.8.6

5 years ago

4.8.5

5 years ago

4.8.4

5 years ago

4.8.1

5 years ago

4.7.2

5 years ago

4.7.0

5 years ago

4.6.0

5 years ago

4.5.2

5 years ago

4.3.2

5 years ago

4.3.1

5 years ago

4.3.0

5 years ago

4.1.1

5 years ago

4.0.0

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.3.0

5 years ago

2.2.11

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago

1.0.0-1

6 years ago

1.0.0-0

6 years ago

0.9.0

6 years ago

0.8.1

6 years ago

0.7.0

6 years ago

0.3.2

6 years ago

0.2.1

6 years ago

0.1.0

6 years ago