luna-syntax-highlighter
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Luna Syntax Highlighter

Syntax highlighter using highlightjs.

Demo

https://luna.liriliri.io/?path=/story/syntax-highlighter

Install

Add the following script and style to your page.

<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/luna-syntax-highlighter/luna-syntax-highlighter.css" />
<script src="//cdn.jsdelivr.net/npm/luna-syntax-highlighter/luna-syntax-highlighter.js"></script>

You can also get it on npm.

npm install luna-syntax-highlighter --save
import 'luna-syntax-highlighter/luna-syntax-highlighter.css'
import LunaSyntaxHighlighter from 'luna-syntax-highlighter'

Usage

const syntaxHighlighter = new LunaSyntaxHighlighter(container)
syntaxHighlighter.setOption({
  code: 'const a = 1;',
  language: 'javascript',
})

Configuration

  • code(string): Code to highlight.
  • language(string): Language to highlight code in.
  • showLineNumbers(boolean): Show line numbers.
  • wrapLongLines(boolean): Wrap lone lines.

Api

static getLanguage(name: string): any

Highlight.js getLanguage.

static registerLanguage(name: string, fn: AnyFn): void

Highlight.js registerLanguage.

Readme

Keywords

Package Sidebar

Install

npm i luna-syntax-highlighter

Weekly Downloads

6

Version

1.0.0

License

MIT

Unpacked Size

514 kB

Total Files

12

Last publish

Collaborators

  • surunzi