Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log(highlight('typescript',
`class CPP {
private year: number;
public constructor(private version: string) {
this.year = Number(version.match(/.+\d+$/));
}
public version(): string {
return this.version;
}
}
`
));
console.info(highlightAuto(
`class CPP {
private year: number;
public constructor(private version: string) {
this.year = Number(version.match(/.+\d+$/));
}
public version(): string {
return this.version;
}
}
`
));
core.registerLanguage('math', highlighter);
console.log(core.highlight('javascript',
visit(ast, 'code', node => {
if (!node.data) {
node.data = {};
}
const lang = node.lang;
const highlighted = lang
? low.highlight(aliases[lang] || lang, node.value).value
: low.highlightAuto(node.value).value;
node.data.hChildren = highlighted;
node.data.hProperties = {
className: ['hljs', lang && `language-${lang}`],
};
});
}