How to use the lowlight/lib/core.highlight function in lowlight

To help you get started, we’ve selected a few lowlight 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 DefinitelyTyped / DefinitelyTyped / lowlight / lowlight-tests.ts View on Github external
`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 {
github rexxars / react-lowlight / src / Lowlight.js View on Github external
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))
github mohebifar / konsul / examples / src / components / konsul / CodeHighlight / Highlight.js View on Github external
render (): void {
    const { code, language, style } = this.props;
    const codeTree = low.highlight(language, code);
    console.log(codeTree)
    
    return (
      
    );
  }
}
github patternplate / patternplate / packages / components / lib / code / index.js View on Github external
function highlight(language, source) {
  if (!includes(languages, language)) {
    return source;
  }

  let _low$highlight = low.highlight(language, source),
      children = _low$highlight.value;

  return children;
}
github patternplate / patternplate / packages / client / src / app / components / common / code / highlight.js View on Github external
export default function highlight(language, source) {
  if (!includes(languages, language)) {
    return source;
  }
  const { value: children } = low.highlight(language, source);
  return children;
}