Skip to content

(java) Code not getting tokenized (and thus not highlighted) #4229

Open
@Jurredr

Description

@Jurredr

Describe the issue

Which language seems to have the issue?
Java. It works perfectly fine for any other language we've tested with. Just Java seems to break for some reason, with multiple different code examples tested.

Are you using highlight or highlightAuto?
Highlighting it through hljs.highlightElement(codeElement); where codeElement is an HTML element of type code, and then rendering that HTML element to the DOM.

Sample Code to Reproduce

const codeElement = DomBuilder.getInstance().build({
  type: 'code',
  classNames: [
    ...(props.language !== undefined ? [ `language-${props.language}` ] : [ 'language-plaintext' ])
  ],
  innerHTML: "Some code string here"
});
hljs.highlightElement(codeElement);
Image

Expected behavior
The code is tokenized into spans and highlighted accordingly.

Additional context

This issue is occurring in the open source MynahUI repository for AWS, specifically in the SyntaxHighlighter component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions