{"record":{"id":"2b3bb9e1cb2e105e","repo":"hexojs/hexo","slug":"syntax-highlighter-name-is-not-registered","errorCode":null,"errorMessage":"syntax highlighter ${name} is not registered","messagePattern":"syntax highlighter (.+?) is not registered","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/extend/syntax_highlight.ts","lineNumber":55,"sourceCode":"\n  constructor() {\n    this.store = {};\n  }\n\n  register(name: string, fn: StoreFunction): void {\n    if (typeof fn !== 'function') throw new TypeError('fn must be a function');\n\n    this.store[name] = fn;\n  }\n\n  query(name: string): StoreFunction {\n    return name && this.store[name];\n  }\n\n  exec(name: string, options: HighlightExecArgs): string {\n    const fn = this.store[name];\n\n    if (!fn) throw new TypeError(`syntax highlighter ${name} is not registered`);\n    const ctx = options.context;\n    const args = options.args || [];\n\n    return Reflect.apply(fn, ctx, args);\n  }\n}\n\nexport default SyntaxHighlight;\n","sourceCodeStart":37,"sourceCodeEnd":64,"githubUrl":"https://github.com/hexojs/hexo/blob/059cb17494d0632a053c24077f5bcb6ae92acc51/lib/extend/syntax_highlight.ts#L37-L64","documentation":"Thrown by SyntaxHighlight.exec when no highlighter is registered under the requested name. Unlike the other errors this is a runtime lookup failure: exec reads this.store[name] and, finding nothing, reports the engine as unregistered. The message is dynamic and includes the missing name.","triggerScenarios":"Calling exec('prismjs', opts) when 'prismjs' was never registered, or requesting a name with a typo/different casing than what was registered.","commonSituations":"The highlight config references an engine ('highlight.js' vs 'hljs' vs 'prismjs') that the corresponding plugin did not register, or the highlight plugin is not installed/enabled while the config requests it.","solutions":["Ensure the highlighter plugin that registers the requested name is installed and loaded.","Align the config highlight.engine value with a name that was actually registered (check exact spelling/casing).","Guard with query(name) before calling exec, falling back to a default highlighter or raw output."],"exampleFix":"// before\nhexo.extend.syntax_highlight.exec(engineName, opts);\n// after\nconst fn = hexo.extend.syntax_highlight.query(engineName);\nif (fn) hexo.extend.syntax_highlight.exec(engineName, opts);\nelse return raw; // or exec('default', opts)","handlingStrategy":"validation","validationCode":"const fn = hexo.extend.syntax_highlight.query(name);\nif (!fn) return raw; // or fall back to a registered default\nhexo.extend.syntax_highlight.exec(name, options);","typeGuard":"const isRegistered = (name: string) => typeof hexo.extend.syntax_highlight.query(name) === 'function';","tryCatchPattern":"try {\n  return hexo.extend.syntax_highlight.exec(name, options);\n} catch (e) {\n  if (e instanceof TypeError && /is not registered/.test(e.message)) return raw;\n  throw e;\n}","preventionTips":["Align the config highlight.engine value with the exact registered name.","Ensure the highlighter plugin is installed and loaded before rendering.","Use query() to probe availability and fall back to raw output when absent."],"tags":["syntax-highlight","runtime","lookup","config","plugin"],"backgroundTag":null,"analyzedSha":"059cb17494d0632a053c24077f5bcb6ae92acc51","analyzedAt":"2026-08-12T20:52:05.731Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}