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(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 {
constructor(version) {
this.version = version;
this.year = Number(version.match(/.+\d+$/));
}
version(){
return this.version;
}
}
`
, { prefix: 'core-', subset: ['purescript', 'javascript', 'typescript', 'coffeescript'] }));
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))
var code = h('code', codeProps, value)
blocks.forEach(block => {
let startPos = block.pos + 1
const nodes = low.highlightAuto(block.node.textContent).value
flatten(parseNodes(nodes))
.map(node => {
const from = startPos
const to = from + node.text.length
startPos = to
return {
...node,
from,
to,
}
})
.forEach(node => {
const decoration = Decoration.inline(node.from, node.to, {