How to use the refractor/core.js.highlight function in refractor

To help you get started, we’ve selected a few refractor 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 hshoff / ui-kit / packages / code / src / index.js View on Github external
export default function Code({
  className,
  children,
  language,
  style,
}) {
  const nodes = refractor.highlight(children, language);
  const html = rehype()
    .stringify({ type: 'root', children: nodes })
    .toString();
  return (
    <pre style="{style}">  );
}
</pre>
github hshoff / ui-kit / packages / code / build / index.js View on Github external
function Code(_ref) {
  var className = _ref.className,
      children = _ref.children,
      language = _ref.language,
      style = _ref.style;

  var nodes = refractor.highlight(children, language);
  var html = (0, _rehype2.default)().stringify({ type: 'root', children: nodes }).toString();
  return _react2.default.createElement('pre', {
    style: style,
    className: (0, _classnames2.default)('ui-kit-code', className),
    dangerouslySetInnerHTML: { __html: html }
  });
}
github patternplate / patternplate / components / next-generation / code / src / code.tsx View on Github external
function highlight(language, source) {
  const lang = ALIASES[language] || language;

  if (!refractor.registered(lang)) {
    return source;
  }

  return refractor.highlight(source, lang);
}

refractor

Lightweight, robust, elegant virtual syntax highlighting using Prism

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis