Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
`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',
`class CPP {
constructor(version) {
this.version = version;
this.year = Number(version.match(/.+\d+$/));
}
version(){
return this.version;
}
}
`
, { prefix: 'core-' }));
console.info(core.highlightAuto(
`class CPP {
function Lowlight (props) {
if (process.env.NODE_ENV !== 'production') {
if (!props.language && registeredLanguages === 0) {
console.warn(
'No language definitions seems to be registered, ' +
'did you forget to call `Lowlight.registerLanguage`?'
)
}
}
var result = props.language
? low.highlight(props.language, props.value, {prefix: props.prefix})
: low.highlightAuto(props.value, {prefix: props.prefix, subset: props.subset})
var codeProps = result.language ? {className: 'hljs ' + result.language} : {className: 'hljs'}
if (props.inline) {
codeProps.style = {display: 'inline'}
codeProps.className = props.className
}
var ast = result.value
if (props.markers && props.markers.length > 0) {
ast = addMarkers(ast, {prefix: props.prefix, markers: props.markers})
}
var value = ast.length === 0 ? props.value : ast.map(mapChildren.depth(0))
render (): void {
const { code, language, style } = this.props;
const codeTree = low.highlight(language, code);
console.log(codeTree)
return (
);
}
}
function highlight(language, source) {
if (!includes(languages, language)) {
return source;
}
let _low$highlight = low.highlight(language, source),
children = _low$highlight.value;
return children;
}
export default function highlight(language, source) {
if (!includes(languages, language)) {
return source;
}
const { value: children } = low.highlight(language, source);
return children;
}