Code Monkey home page Code Monkey logo

highlighter's Introduction

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

highlighter's People

Contributors

bobris avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.