Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import refractor from 'refractor';
import text from './text-language';
import './prism.css';
import './prism.overrides.scss';
// This is needed to provide a fallback in `getLanguage()` when the mime type
// has no corresponding syntax highlighting language.
refractor.register(text);
export default refractor;
const getHast = (code: string, lang: string): RefractorNode[] | null => {
if (!lang) return null;
if (!refractor.registered(lang)) {
try {
refractor.register(require(`refractor/lang/${lang}.js`));
} catch (ex) {}
}
if (refractor.registered(lang)) {
return refractor.highlight(code, lang);
}
return null;
};