blob: 0da57f9e6fa4175721a553574e367347345f9b1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import hljs from 'highlight.js/lib/core';
import languageLoader from '~/content_editor/services/highlight_js_language_loader';
import { registerPlugins } from '../plugins/index';
const initHighlightJs = async (fileType, content, language) => {
const languageDefinition = await languageLoader[language]();
registerPlugins(hljs, fileType, content);
hljs.registerLanguage(language, languageDefinition.default);
};
export const highlight = (fileType, content, language) => {
initHighlightJs(fileType, content, language);
return hljs.highlight(content, { language }).value;
};
|