How to use the prismjs.highlightElement function in prismjs

To help you get started, we’ve selected a few prismjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngx-prism / core / src / prism.service.ts View on Github external
public highlight(el: ElementRef, options: OptionsInterface): void {
    // Always need to have el.
    if (el instanceof ElementRef) {
      if (options.code) {
        el.nativeElement.innerHTML = this.sanitizer.sanitize(SecurityContext.HTML, this.escapeHtml(options.code));
      }
      // Perform interpolate.
      if (options.interpolation) {
        el.nativeElement.innerHTML = this.interpolate(el.nativeElement.innerHTML, options.interpolation);
      }
      // Perform prism highlight code.
      Prism.highlightElement(el.nativeElement, options.async, options.callback);
    }
  }
github williaster / data-ui / packages / demo / storybook-config / components / Markdown.jsx View on Github external
const highlightCode = (instance) => {
  const domNode = ReactDOM.findDOMNode(instance); // eslint-disable-line react/no-find-dom-node
  const nodes = domNode.querySelectorAll('code');

  if (nodes.length > 0) {
    for (let i = 0; i < nodes.length; i += 1) {
      nodes[i].classList.add('language-jsx');
      Prism.highlightElement(nodes[i]);
    }
  }
};
github cssinjs / cssinjs / src / components / Content / utils.js View on Github external
[...content.querySelectorAll('code')].forEach((block) => {
    Prism.highlightElement(block)
  })
  return content
github 30-seconds / 30-seconds-of-interviews / website / js / components / Markdown.js View on Github external
Array.from(el.querySelectorAll("code[class^='lang']")).forEach(e =>
    Prism.highlightElement(e)
  )
github timmywil / panzoom / demo / Code.tsx View on Github external
useEffect(() => {
    Prism.highlightElement(elem.current, false)
  }, [])
  return (
github gpbl / react-day-picker / docs / src / ui / CodeBlock.js View on Github external
highlight() {
    Prism.highlightElement(this.node, false);
  }
github logaretm / vee-validate / docs / components / CodeBlock.vue View on Github external
ready() {
        this.removeWhitespace();
        Prism.highlightElement(this.$els.code);
    }
}