Welcome to mirror list, hosted at ThFree Co, Russian Federation.

highlight_utils.js « workers « source_viewer « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
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;
};