function highlight(codeOrlanguageName, optionsOrCode, ignoreIllegals, continuation) {
    let code = "";
    let languageName = "";
    if (typeof optionsOrCode === "object") {
      code = codeOrlanguageName;
      ignoreIllegals = optionsOrCode.ignoreIllegals;
      languageName = optionsOrCode.language;
      // continuation not supported at all via the new API
      // eslint-disable-next-line no-undefined
      continuation = undefined;
    } 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;
    }

    /** @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, continuation);

    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
@param {CompiledMode} [continuation] - current continuation mode, if any

@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