2.0.0 • Published 7 months ago

dot-preact-highlight v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

preact-highlight

a syntax highlight component for preact, base on awesome highlight.js

features

  • self managed theme style
  • cache highlight result
  • support multi-theme in same application

usage

use preact-highlight with your preact application

const { h, Component } = require('preact');
const { HighLight, THEME } = require('preact-highlight');
const demo = {
  a: 1,
  b: [ 1, 2, 3 ],
};

class CodeArea extends Component {
  render() {
    return <HighLight className="cmp-high-light" code={demo} theme={THEME.monokaiSublime}/>;
  }
}
module.exports = CodeArea;

note

HighLight component code property had supported string or json or object and function

propertytypedescription
classNamestringcss style classname
codestring or json or object and functioncode snippet which need highlight
languagestringuse which language syntax
themestringuse which theme
2.0.0

7 months ago