Skip to content

v0.26.0 ShikiError: Language abnf not found, you may need to load it first #2609

Closed
@yoursunny

Description

When README.md contains a language not supported by TypeDoc syntax highlighting, v0.25.13 simply logs a warning, while v0.26.0 has turned this into a hard error.

In the use case, TypeDoc cannot highlight the ABNF language (and there isn't a Shiki option for this language), but GitHub can highlight this language.
Therefore, I'd like to keep the abnf tagging in the README file, so that readers browsing on GitHub can see the highlighted syntax.

Search terms

ShikiError highlight language

Expected Behavior

Upon seeing an unsupported language, TypeDoc should log a warning and render this language as plain text.

Actual Behavior

Upon seeing an unsupported language, TypeDoc exits with error:

TypeDoc exiting with unexpected error:
ShikiError: Language `abnf` not found, you may need to load it first
    at Object.getLanguage (file:///home/runner/work/typedoc-repros/typedoc-repros/node_modules/@shikijs/core/dist/index.mjs:5436:19)
    at codeToTokensBase (file:///home/runner/work/typedoc-repros/typedoc-repros/node_modules/@shikijs/core/dist/index.mjs:530:31)
    at file:///home/runner/work/typedoc-repros/typedoc-repros/node_modules/@shikijs/core/dist/index.mjs:674:62
    at Array.map (<anonymous>)
    at codeToTokensWithThemes (file:///home/runner/work/typedoc-repros/typedoc-repros/node_modules/@shikijs/core/dist/index.mjs:674:53)
    at Object.codeToTokensWithThemes (file:///home/runner/work/typedoc-repros/typedoc-repros/node_modules/@shikijs/core/dist/index.mjs:5520:52)
    at DoubleHighlighter.highlight (/home/runner/work/typedoc-repros/typedoc-repros/node_modules/typedoc/dist/lib/utils/highlighter.js:70:41)
    at highlight (/home/runner/work/typedoc-repros/typedoc-repros/node_modules/typedoc/dist/lib/utils/highlighter.js:162:24)
    at Object.highlight (/home/runner/work/typedoc-repros/typedoc-repros/node_modules/typedoc/dist/lib/output/themes/MarkedPlugin.js:259:56)
    at default_rules.fence (/home/runner/work/typedoc-repros/typedoc-repros/node_modules/markdown-it/dist/index.cjs.js:567:27)
error Command failed with exit code 6.

Steps to reproduce the bug

Insert an unsupported language block in README.md and build the project, like this:

```abnf
; taken from RFC5234
name =  elements crlf
```

Code: TypeStrong/typedoc-repros#41
Failing build: https://github.com/TypeStrong/typedoc-repros/actions/runs/9628193855/job/26556161522

Environment

  • Typedoc version: 0.26.0
  • TypeScript version: 5.4.5
  • Node.js version: 20.14.0
  • OS: Ubuntu 22.04

Metadata

Assignees

No one assigned

    Labels

    bugFunctionality does not match expectation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions