function highlight(codeOrLanguageName, optionsOrCode, ignoreIllegals) {
      let code = "";
      let languageName = "";
      if (typeof optionsOrCode === "object") {
        code = codeOrLanguageName;
        ignoreIllegals = optionsOrCode.ignoreIllegals;
        languageName = optionsOrCode.language;
      } else {
        // old API
        deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
        deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
        languageName = codeOrLanguageName;
        code = optionsOrCode;
      }

      // https://github.com/highlightjs/highlight.js/issues/3149
      // eslint-disable-next-line no-undefined
      if (ignoreIllegals === undefined) { ignoreIllegals = true; }

      /** @type {BeforeHighlightContext} */
      const context = {
        code,
        language: languageName
      };
      // the plugin can change the desired language or the code to be highlighted
      // just be changing the object it was passed
      fire("before:highlight", context);

      // a before plugin can usurp the result completely by providing it's own
      // in which case we don't even need to call highlight
      const result = context.result
        ? context.result
        : _highlight(context.language, context.code, ignoreIllegals);

      result.code = context.code;
      // the plugin can change anything in result to suite it
      fire("after:highlight", result);

      return result;
    }
Core highlighting function.

OLD API
highlight(lang, code, ignoreIllegals, continuation)

NEW API
highlight(code, {lang, ignoreIllegals})

@param {string} codeOrLanguageName - the language to use for highlighting
@param {string | HighlightOptions} optionsOrCode - the code to highlight
@param {boolean} [ignoreIllegals] - whether to ignore illegal matches, default is to bail

@returns {HighlightResult} Result - an object that represents the result
@property {string} language - the language name
@property {number} relevance - the relevance score
@property {string} value - the highlighted HTML code
@property {string} code - the original raw code
@property {CompiledMode} top - top of the current mode stack
@property {boolean} illegal - indicates whether any illegal matches were found