0.1.1 • Published 3 years ago

@evergreen-wc/eve-highlight v0.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

eve-highlight

An Evergreen Highlight.js Web Component

Demo

Install

npm i @evergreen-wc/eve-highlight

Usage

import { html, LitElement } from 'lit';
import '@evergreen-wc/eve-highlight';

// highlightjs themes https://github.com/highlightjs/highlight.js/tree/master/src/styles
import github from '@evergreen-wc/eve-highlight/themes/github.css';

// Javascript example
// Escape $ with \
const code = `
class MyComponent extends LitElement {
  constructor() {
    this.name = 'helloworld'
  }

  renderThing() {
    if(this.name === 'helloworld'){
      console.log(this.name)
    }
  }
}
customElements.define('my-component', MyComponent);
`;

class SomeComponent extends LitElement {
  render() {
    return html`
      <eve-highlight type="js" theme="${github}" code="${code}"></eve-highlight>
    `;
  }
}
customElements.define('some-component', SomeComponent);

Props

PropertyDescription
typeSet the syntax type e.g. html, css, js, xml, bash
themeSet the imported CSS file.
codeSet the code string to highlight.
hljsOptionally you may wish to use a language not already registered due to optimization. You can import and register the languages in your own hljs object and add it as an attribute.
0.1.0

3 years ago

0.1.1

3 years ago

0.0.10

3 years ago

0.0.9

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago