0.1.12 • Published 2 years ago

@dan-online/solid-highlight-ts v0.1.12

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

solid-highlight

size size npm

solid-top-loading-bar

Documentation

Example

TBA

Installation

  • using npm
npm install --save solid-highlight
  • using yarn
yarn add solid-highlight

Usage

Importing component

import Highlight from "solid-highlight";

Adding styles

Choose the theme for syntax highlighting and add corresponding styles of highlight.js, either as a stylesheet or by importing in your index.tsx file

  <link rel="stylesheet" href="/path/to/styles/theme-name.css">
import "highlight.js/styles/stackoverflow-light.css";

The styles will most likely be in node_modules/highlight.js/styles folder.

Properties

PropertyTypeDefaultDescription
classstringCustom css classes to be included
languagestring (optional)''Language of code to be highlighted (will be detected automatically by default)
autoDetectboolean (optional)trueWhether to automatically detect the language of code to be highlighted
ignoreIllegalsboolean (optional)trueWhether to ignore illegal characters in the code to be highlighted

Syntax highlighting of code snippet

Code snippet that requires syntax highlighting should be passed as children to Highlight component in string format.

<Highlight autoDetect={true}> {"function foo() { return 'bar' }"} </Highlight>
<Highlight autoDetect={false} language={"js"}>
  {"function foo() { return 'bar' }"}
</Highlight>