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

@bobril/highlighter

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bobril/highlighter

Syntax highlighter component for Bobril

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Bobril Highlighter

Bobril component for syntax highlighting of source code. For actual work uses highlight.js.

npm version

Demo

Updated to use version 11.9.0 of highlight.js.

How to use

import * as b from "bobril";
import * as high from "@bobril/highlighter";
import { docco } from "@bobril/highlighter/styles";

b.init(() => <high.Highlighter style={docco}>{`let actual = "code " + "shine";`}</high.Highlighter>);

By default only most common languages are registered. If all are needed use this:

import "@bobril/highlighter/allLanguages";

Props of component

  • language?: string - if not provided then autodetect (slower)
  • style?: HighlightStyle - provide theme to use for styling
  • showLineNumbers?: boolean - default is true
  • startingLineNumber?: number - default is 1, NaN is automatically set to 1 as well.
  • lineStyle?: ((line: number) => b.IBobrilStyles) | undefined - allow style div for each line
  • lineContentStyle?: ((line: number) => b.IBobrilStyles) | undefined - allow to style div of line content without line number
  • lineNumberStyle?: ((largestLineNumber: number, style: HighlightStyle) => (line: number) => b.IBobrilStyles) | undefined - allows complete override of default line number style
  • children?: string - only one string child is allowed and it must contain code to format

Acknowledges

  • highlight.js - actual ground work
  • lowlight - for Emitter Tree approach
  • react-syntax-highlighter - scripts and inspirations in line number styling

Keywords

FAQs

Package last updated on 03 Jul 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