Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
}
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]);
}
}
};
[...content.querySelectorAll('code')].forEach((block) => {
Prism.highlightElement(block)
})
return content
Array.from(el.querySelectorAll("code[class^='lang']")).forEach(e =>
Prism.highlightElement(e)
)
highlight() {
prism.highlightElement(this.refs.code);
}
useEffect(() => {
Prism.highlightElement(elem.current, false)
}, [])
return (
highlight() {
Prism.highlightElement(this.node, false);
}
ready() {
this.removeWhitespace();
Prism.highlightElement(this.$els.code);
}
}