Skip to content

Loading cpp highlighter alone causes an error #2670

@SilentAntenna

Description

@SilentAntenna

The current cpp highlighter is basically a redirection to c-like highlighter. If one registers this highlighter as in the documentation:

const hljs = require("highlight.js/lib/core");
// separately require languages
hljs.registerLanguage('cpp', require('highlight.js/lib/languages/cpp'));

const highlightedCode = hljs.highlight('cpp', 'cout << "Hello World!"').value

Without loading c-like highlighter first, the script above will throw an error.

If this behavior is intended, it should be mentioned in the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions